Namespace: wallet
Functions
autoSwitchNetwork
▸ autoSwitchNetwork(callbacks?, force?): Promise<boolean>
Sends a chain switch request to the user's wallet if:
- The user is connected to a different network than the one currently configured with module:config~config, and
autoSwitchis enabled - The switch is requested by calling this function with the
forceparameter
Parameters
| Name | Type | Default value | Description |
|---|---|---|---|
callbacks? | IGenericTransactionCallbacks | undefined | - |
force | boolean | false | true to send a switch request to the network configured via module:config~config |
Returns
Promise<boolean>
Throws
Unsupported network error if the user is connected to a different network than the configured one, and both autoSwitch and force are false.
Defined in
wallet/index.ts:170
connect
▸ connect(): Promise<string>
Connects user's web3 wallet
Returns
Promise<string>
address of the connected account
Defined in
wallet/index.ts:72
getCurrentWalletAddress
▸ getCurrentWalletAddress(): Promise<string>
Returns connected wallet account (Attempts to connect to the wallet if not connected)
Returns
Promise<string>
Account address
Defined in
wallet/index.ts:329
getNetwork
▸ getNetwork(): Promise<Network>
Get parameters of the network that the wallet is connected to
Returns
Promise<Network>
Network info of where the wallet switched to
Throws
Error if no wallet is installed or if the user rejected adding or switching to the network
Defined in
wallet/index.ts:199
getSupportedNetworks
▸ getSupportedNetworks(): Object
Get list of networks supported by the configuration
Returns
Object
List and parameters of all configured networks
Defined in
wallet/index.ts:216
getWeb3Provider
▸ getWeb3Provider(): Promise<BrowserProvider>
Returns
Promise<BrowserProvider>
Defined in
wallet/index.ts:295
isCorrectNetworkConnected
▸ isCorrectNetworkConnected(): Promise<boolean>
Checks, based on chainId comparison, if the wallet is connected to the default network
Returns
Promise<boolean>
true/false if the wallet is connected to the default network
Defined in
wallet/index.ts:225
isListening
▸ isListening(): boolean
Check if the app is listening to account or network change
Returns
boolean
true if at least one of the listeners is active
Defined in
wallet/index.ts:277
isSupportedNetworkConnected
▸ isSupportedNetworkConnected(): Promise<boolean>
Checks, based on chainId comparison, if the wallet is connected to one of the networks supported by the configuration
Returns
Promise<boolean>
true/false
Defined in
wallet/index.ts:235
isWeb3WalletConnected
▸ isWeb3WalletConnected(): Promise<boolean>
Check if a web3 wallet is connected
Returns
Promise<boolean>
boolean
Throws
If this is not run in a browser
Defined in
wallet/index.ts:318
isWeb3WalletInstalled
▸ isWeb3WalletInstalled(): boolean
Check if a web3 wallet is installed
Returns
boolean
boolean
Throws
If this is not run in a browser
Defined in
wallet/index.ts:305
startListening
▸ startListening(onChangeWalletCallback): void
Start listening to change in wallet connection and run the callback function if the account changes
Parameters
| Name | Type | Description |
|---|---|---|
onChangeWalletCallback | (walletAddress: string) => void | Function to be called if the user changes a connected account |
Returns
void
Defined in
wallet/index.ts:249
startListeningNetwork
▸ startListeningNetwork(onChangeNetworkCallback): void
Listen to whether the wallet switches to another network and run the provided callback if yes
Parameters
| Name | Type | Description |
|---|---|---|
onChangeNetworkCallback | (networkId: bigint) => void | Function to be called when the wallet switches to another network |
Returns
void
Defined in
wallet/index.ts:263
stopListening
▸ stopListening(): void
Stop listening to wallet account changes
Returns
void
Defined in
wallet/index.ts:284
stopListeningNetwork
▸ stopListeningNetwork(): void
Stop listening to network switch
Returns
void
Defined in
wallet/index.ts:291
switchNetwork
▸ switchNetwork(chainId): Promise<bigint>
Sends a chain switch request to the user's wallet.
Parameters
| Name | Type | Description |
|---|---|---|
chainId | bigint | chainId of one of the supported networks (see: module:wallet~NETWORK) |
Returns
Promise<bigint>
chainId of the network that the wallet was switched to.
Throws
Error if no wallet is present or the user rejected adding or switching to the network
Defined in
wallet/index.ts:102