Namespace: wallet
Functions
autoSwitchNetwork
▸ autoSwitchNetwork(callbacks?
, force?
): Promise
<void
>
If non-default network is connected and if auto-switch is configured globally or requested by "force" parameter, switch wallet to the default network
Throws
Unsupported network error if the user is on incorrect network, and neither global settings nor the parameter requires the switch
Parameters
Name | Type | Default value | Description |
---|---|---|---|
callbacks? | IGenericTransactionCallbacks | undefined | - |
force | boolean | false | True to force switching to the default network |
Returns
Promise
<void
>
Defined in
checkIsWalletInstalled
▸ checkIsWalletInstalled(): any
Check if a web3 wallet is installed
Throws
If this is not run in a browser
Returns
any
installed web3 provider or null if none
Defined in
connect
▸ connect(): Promise
<string
>
Connects user's web3 wallet
Returns
Promise
<string
>
address of the connected account
Defined in
getNetwork
▸ getNetwork(): Promise
<Network
>
Get parameters of the network that the wallet is connected to
Returns
Promise
<Network
>
Network parameters
Defined in
getSupportedNetworks
▸ getSupportedNetworks(): Object
Get list of networks supported by the configuration
Returns
Object
List and parameters of all configured networks
Defined in
getWalletAccount
▸ getWalletAccount(): Promise
<string
>
Returns connected wallet account (Attempts to connect to the wallet if not connected)
Returns
Promise
<string
>
Account address
Defined in
getWeb3Provider
▸ getWeb3Provider(): Promise
<Web3Provider
>
Returns
Promise
<Web3Provider
>
Defined in
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
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
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
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
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 : number ) => void | Function to be called when the wallet switches to another network |
Returns
void
Defined in
stopListening
▸ stopListening(): void
Stop listening to wallet account changes
Returns
void
Defined in
stopListeningNetwork
▸ stopListeningNetwork(): void
Stop listening to network switch
Returns
void
Defined in
switchNetwork
▸ switchNetwork(name
): Promise
<DefaultNetwork
>
Asks user's web3 wallet to switch to a selected network
Throws
Error if the user rejected adding or switching to the network
Parameters
Name | Type | Description |
---|---|---|
name | DefaultNetwork | Name of one of the configured networks ('arbitrum', 'development', or 'goerli' in standard SDK installation) |
Returns
Promise
<DefaultNetwork
>
Name of the network that the wallet was switched to. Null if no wallet is installed