Configure your widget for seamless 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.
The example below shows how to preconfigure a basic wallet management.
In the next major version, we will migrate to wagmi and simplify wallet management integration.
Check out our example of how to integrate your wagmi wallet management with the widget. Also, see the wagmi ethers adapters (react/core) documentation for wallet client -> signer conversion.
Some callbacks are optional, and we will use our implementation if you don't provide any.
import { Signer } from'ethers';exportinterfaceWidgetWalletManagement {// will be called when the user presses Connect Wallet buttonconnect():Promise<Signer>;// will be called to disconnect the wallet by the user or internallydisconnect():Promise<void>;// will be called to switch the current wallet chain by the user or internallyswitchChain?(chainId:number):Promise<Signer>;// will be called to add a token to a wallet if not presentaddToken?(token:Token, chainId:number):Promise<void>;// will be called to add a chain to a wallet if not presentaddChain?(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 jumper.exchange external wallet management solution in the repository here.