-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: ✨ kleverHub provider and types
- Loading branch information
Showing
5 changed files
with
65 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,16 @@ | ||
import { NotInjectedError } from '@/errors'; | ||
import { NoAvailableAccountsError } from '@/errors/no-accounts-available-error'; | ||
import { web3Window } from '@/types'; | ||
import type { KleverAddress } from './types'; | ||
import type { KleverAccount } from './types'; | ||
|
||
export async function connect(): Promise<KleverAddress> { | ||
if (!web3Window.kleverWeb) | ||
export async function connect(): Promise<KleverAccount> { | ||
if (!web3Window.kleverHub) | ||
throw new NotInjectedError() | ||
|
||
await web3Window.kleverWeb.initialize(); | ||
await web3Window.kleverHub.initialize(); | ||
|
||
const address = web3Window.kleverWeb.getWalletAddress(); | ||
|
||
if (!address) | ||
if (!web3Window.kleverHub.account) | ||
throw new NoAvailableAccountsError() | ||
|
||
return address | ||
return web3Window.kleverHub.account | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,27 @@ | ||
export type KleverAddress = string | ||
export enum Chain { | ||
KLV = 1, | ||
ETH = 4, | ||
TRX = 2, | ||
} | ||
|
||
export interface KleverAccount { | ||
address: string | ||
chain: number | ||
name: string | ||
provider: string | ||
} | ||
|
||
interface Communication { | ||
waitingResponse: boolean | ||
} | ||
|
||
export interface KleverHub { | ||
name: string | ||
communication: Communication | ||
accountChangeListeners: any[] | ||
blockChainChangeListeners: any[] | ||
isConnected: boolean | ||
isKleverHub: boolean | ||
account?: KleverAccount | ||
initialize: () => Promise<void> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters