Saltar al contenido principal

Get Involved

Whether you are a developer, designer, writer, project builder, or just someone passionate about Cardano.

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.

PropTypeDefaultDescription
onConnect({ instance, name, address, networkId }) => voidrequiredCalled after a successful connection with the wallet API, its name, the first address in bech32, and the network ID.
busybooleanfalseDisables the wallet buttons, for example while a transaction is being signed.
emptyMessagestringbuilt-in textText 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.

PropTypeDefaultDescription
state{ status, message, txHash }requiredstatus picks the tone, message is the translated text, txHash is needed for the explorer link on success.

SearchRow​

A search field with a "Clear" button that appears once the field has a value.

PropTypeDefaultDescription
valuestringrequiredCurrent search text.
onChange(value: string) => voidrequiredCalled with the new text, and with an empty string on "Clear".
placeholderstring-Placeholder text.
labelstring-Accessible name of the field. Pass it, because the field has no visible label.

SnapshotImage​

An avatar or logo from the self-hosted image snapshots, such as DRep avatars and stake pool logos. It falls back to Initials when the ID has no image or the file fails to load.

PropTypeDefaultDescription
idsSet<string>requiredThe IDs that have an image, from the snapshot manifest.
idstringrequiredThe ID to look up.
pathstringrequiredSite path of the image, resolved with the base URL.
namestring-Name used for the initials fallback.
classNamestring-Class on the <img>.

Initials​

A round placeholder with up to two initials of name, hidden from screen readers.

PropTypeDefaultDescription
namestring"?"Name to take the initials from.

Helpers​

@site/src/components/WalletDelegation/helpers holds small utilities for the same tools: fisherYates (shuffled copy of an array), chunk (split an array into pages), and readCache and writeCache (a sessionStorage cache with an expiry time that treats every failure as a miss).

Translation​

All built-in texts are translated with IDs under governance.delegate.*, so the DRep and stake pool tools share them.