Wallet Delegation
WalletDelegation
A set of small building blocks shared by the delegation tools on /governance/delegate (DRep delegation) and /stake-pool-delegation. They cover the parts every wallet flow needs: picking and connecting a CIP-30 wallet, warning about the wrong network, showing the transaction status, searching a list, and showing an avatar with an initials fallback.
Use these exports when you build another wallet flow, instead of writing a new wallet picker or status banner.
Because the components need a browser wallet and live transactions, there is no live preview here, only the usage pattern.
Basic Usage
import { WalletPicker, NetworkWarning, TxBanner } from '@site/src/components/WalletDelegation';
{!wallet && <WalletPicker onConnect={setWallet} busy={txBusy} />}
{wrongNetwork && <NetworkWarning />}
<TxBanner state={tx} />
tx is an object such as { status: 'building', message }, { status: 'success', message, txHash }, or { status: 'error', message }. The caller translates message.
WalletPicker
Detects the installed CIP-30 wallets, lists them as buttons, and connects the one the reader picks. While it looks for wallets and while the wallet's own approval dialog is open, it shows a status line, and the buttons stay disabled so a second click cannot open a second prompt. A cancelled approval shows no error.
| Prop | Type | Default | Description |
|---|---|---|---|
onConnect | ({ instance, name, address, networkId }) => void | required | Called after a successful connection with the wallet API, its name, the first address in bech32, and the network ID. |
busy | boolean | false | Disables the wallet buttons, for example while a transaction is being signed. |
emptyMessage | string | built-in text | Text shown when no wallet is installed. |
NetworkWarning
A warning banner that asks the reader to switch the wallet to Mainnet. It has no props. Render it when the connected wallet's network ID is not Mainnet.
TxBanner
A status banner for a transaction. It renders nothing while state.status is anything other than building, success, or error. On success it adds a link to the transaction on the explorer.
| Prop | Type | Default | Description |
|---|---|---|---|
state | { status, message, txHash } | required | status picks the tone, message is the translated text, txHash is needed for the explorer link on success. |