πŸ‘›
Wallet Management
To manage wallet connection, switching chains, etc., the widget uses the @lifi/wallet-management package internally and provides UI to connect to a wallet.
If you already have your wallet management UI, you can utilize a set of callbacks provided for your convenience and help the widget communicate with your wallet management solution.
Some callbacks are optional, and we will use our implementation if you don't provide any.
import { Signer } from 'ethers';
​
export interface WidgetWalletManagement {
// will be called when the user presses Connect Wallet button
connect(): Promise<Signer>;
// will be called to disconnect the wallet by the user or internally
disconnect(): Promise<void>;
// will be called to switch the current wallet chain by the user or internally
switchChain?(chainId: number): Promise<Signer>;
// will be called to add a token to a wallet if not present
addToken?(token: Token, chainId: number): Promise<void>;
// will be called to add a chain to a wallet if not present
addChain?(chainId: number): Promise<boolean>;
// we retrieve information about the user account from ethers Signer abstraction
signer?: Signer;
}
You can find an example of how we use these callbacks to communicate with transferto.xyz external wallet management solution in the repository here.
Copy link