1.0.2 • Published 10 months ago
wallet_integration v1.0.2
React component for integration with Bitcoin Wallets: Hiro, Unisat, XVerse
How it works
WalletContext
Context
- Exposes:
type WalletValue = {
getWallets: () => string[]; // gets ids of available wallets
connect: (id: string) => Promise<boolean>; // connects to a wallet with id
wallet: Wallet | null; // instance of a wallet class. If connected to a wallet it won't be null
loading: boolean; // if an operation is currently in progress
disconnect: () => void; // function to destroy current wallet instance
};
- To use context use the
useWallet
hook - Use by wrapping parent with
WalletProvider
WalletConnect
Component (Needs to be inside of WalletProvider)
- Props:
type WalletConnectProps = {
buttonText: string; // text to display on button
buttonStyle?: React.CSSProperties; // style for the button
containerStyle?: React.CSSProperties; // style for the container of button
includeStatusInfo?: boolean; // should the status info be displayed under button
onNoWalletsAvailable?: () => void; // callback for when no wallets are available
onMultipleWalletsAvailable?: (wallets: string[]) => string | null; // callback for when multiple wallets are available
};
- Uses
WalletManager
to get available wallets.- If available wallets = 0. Call
onNoWalletsAvailable
or alert - If available wallets = 1, Connect to that wallet
- If available wallets > 1, Call
onMultipleWalletsAvailable
or prompt user to type which wallet should be selected
- If available wallets = 0. Call