Migrate to the wallet manager
Every rename and removal in the breaking releases, from the provider props to the current API, with before and after code.
This page maps every removed or renamed API to its current replacement. The breaking releases did these things:
- An adapter method exists only when it works.
capabilitiesis gone; check the method instead. - One
sendTxwith options replacessendTxandsendTxToChain, and every method takes an options object. createWalletManagerowns discovery, hydration and persistence. The React provider only binds it.- Signers are a tagged union.
getSigner()resolves{ kind, … }, so no casts are needed. - Storage owns its key prefix.
storageKeyPrefixis gone, and onecreateCookieWalletStoragecall gives both the cookie persistence and the server reader that replacesreadWalletSnapshot. autoDiscoverylists each wallet once. It owns fallback deferral, and the per-platform*Discovererobjects are gone.- Adapters check the chain and account of a call before the wallet is
asked, so the same refusal raises the same
ConnectionErrorkind on every transport.
The reasoning is in ADR 0004 and ADR 0005.
Adapter kit, restore() and wallet keys
The latest major moves the adapter building blocks out of @usebutr/core, so
an app that only connects wallets no longer takes a major for them.
| Before | Now |
|---|---|
createAccountTarget, createRoutedChainTarget, createSwitchingChainTarget, createFixedChainTarget from core | the same names from @usebutr/adapter-kit |
createConnectorEmitter, sanitizeIcon, logWarn from core | the same names from @usebutr/adapter-kit |
createRoutedChainTarget({ advertised, current, … }) | createRoutedChainTarget({ accounts, chains, chainsOf, emit, start, … }); it holds the current chain and switchChain |
connector.connect({ silent: true }) | connector.restore?.(); connect() takes no options |
an adapter that cannot reconnect silently rejects connect({ silent: true }) | it defines no restore; hydration reports the wallet as dropped with NotConnected |
wallets matched by name (groupByBrand in your picker) | adapter.walletKey, and groupByWallet(adapters) from core |
a hand-rolled adapter has id and name | it also has walletKey: toWalletKey(name) from @usebutr/adapter-kit, or a literal |
OKX Wallet (Bitcoin), WalletConnect (EVM) | OKX Wallet, WalletConnect; tell platforms apart by chainPlatform |
EVM_CHAINS_LIST, SVM_CHAINS_LIST, SUI_CHAINS_LIST, BITCOIN_CHAINS_LIST, POLKADOT_CHAINS_LIST | CHAINS_BY_PLATFORM.evm and so on |
| the native asset of a chain typed by hand | chain.nativeCurrency on every registry chain |
createBrowserStorageDriver() swallows storage errors | it lets them through; the manager reports them to onStorageError |
A StoredPoolEntry now carries walletKey. Entries persisted by an earlier
version lack it and are dropped on the first load, so each user reconnects
once.
Provider and discovery
// Before
const discovery = autoDiscovery();
<WalletManagerProvider
discovery={discovery}
connectors={[{ id: wc.id, name: wc.name, chainPlatform: wc.chainPlatform }]}
createConnector={(id) => extra.get(id) ?? null}
storageKeyPrefix="my-app"
onConnect={track}
>
{children}
</WalletManagerProvider>;
// After
import type { WalletManagerConfig } from "@usebutr/core";
import { createWalletStorage, fromAdapters } from "@usebutr/core";
const config: WalletManagerConfig = {
onConnect: track,
sources: [autoDiscovery(), fromAdapters(createWalletConnectAdapters({ … }))],
storage: createWalletStorage({ keyPrefix: "my-app" }),
};
<WalletManagerProvider config={config}>{children}</WalletManagerProvider>;| Before | After |
|---|---|
discovery={source} | config.sources: [source] |
connectors, createConnector | config.sources: [fromAdapters(adapter, adapters, or a promise of either)]; those adapters now also appear in useDiscoveredWallets() |
createWalletSource(discoverEvmAdapters) | discoverEvmAdapters as-is: a WalletSource is now the function |
autoDiscovery({ evm: true, svm: true }) | autoDiscovery(["evm", "svm"]) |
autoDiscovery({ injected: false, … }) | autoDiscovery(platforms, { fallbacks: false }) |
PlatformDiscoverer, evmDiscoverer, svmDiscoverer, suiDiscoverer, bitcoinDiscoverer, polkadotDiscoverer | autoDiscovery(platforms), or one package's discover*Adapters source |
discoverWalletAdapters(options), DiscoverOptions | autoDiscovery(platforms, options) |
settleMs, hasAnyEip6963Adapter, hasAnyWalletStandardAdapter | removed: autoDiscovery defers the fallback channels; discoverInjectedAdapter and discoverInjectedBitcoinAdapter emit when subscribed |
window.btc through discoverInjectedBitcoinAdapter | discoverLegacyBitcoinAdapter |
discoverWalletStandard(onAdapter, build, loadModule) | discoverWalletStandard([{ build, onAdapter }], { loadModule, onReady }) |
storageKeyPrefix | config.storage: createWalletStorage({ keyPrefix }), or createCookieWalletStorage({ keyPrefix }) |
initialState prop | unchanged: <WalletManagerProvider config={config} initialState={snapshot}> |
createWalletStore(config) | createWalletManager(config, { initialState }), then manager.start() |
onConnect(wallet) | onConnect(wallet, { reconnected }): also fires for silent reconnects |
onDisconnect(chainPlatform) | onDisconnect(wallet, { byUser }) |
onReset | removed: run your logic after calling disconnectAll() |
onStorageError(error, context) | onStorageError(error) |
CHAINS, CHAINS_BY_PLATFORM from @usebutr/wallets | CHAINS_BY_PLATFORM, EVM_CHAINS, SVM_CHAINS, … from @usebutr/core; per-platform packages no longer export chain registries |
buildChainsByPlatform | removed: import only the *_CHAINS_LIST you need |
setAccount(id, account) selects an account already exposed by the wallet.
It preserves every account's chain and ignores unknown accounts. To change
networks, call the adapter's switchChain; the adapter reports the resulting
accounts through its events.
Hooks
| Before | After |
|---|---|
useConnectWallet() | const { connect, connectAsync } = useConnect(): connect(id) never rejects (the failure lands in error); connectAsync(id) resolves the ConnectedWallet or rejects with a ConnectionError |
useConnectingConnectorId(), useConnectionError(), useIsConnecting(), useResetConnectionStatus() | const { connectingId, error, status, reset } = useConnect() |
useDisconnectWallet(), useResetWallet() | const { disconnect, disconnectAll } = useWalletManager() |
useSetActiveConnector(), useSetSelection(), useUpdateWalletAccount(), useRequestAccounts() | const { setActive, setSelection, setAccount, requestAccounts } = useWalletManager() |
useActiveWallet(), useWalletEntry(id) | useWallet() (active) or useWallet(id); useWallet(null) is no wallet |
useSelectedWallet(platform) | unchanged, and now typed to that platform's adapter |
useConnectionStatus(): "idle" | "connecting" | "success" | "error" | "reconnecting" | "connected" | "connecting" | "disconnected" | "reconnecting"; the attempt's outcome is on useConnect() |
useWalletStore(selector) | useWalletState(selector) |
useWalletStoreContext(), WalletStoreContext | useWalletManager() |
usePool(), useSelection(), useActiveConnectorId(), useWalletConnected(), useIsPlatformConnected(p), useIsUserDisconnected() | useWalletState((s) => s.pool) and so on, or useConnectedWallets() / useWallet() / useSelectedWallet(p) |
useGetWallet(), useGetSelectedWallet(), useGetConnectorInstance() | useWalletManager().getState() |
useRefreshWallet(), useSetConnectionError() | removed |
useBalance(connectorId, mint) | useBalance(wallet, { token, account }), with the entry from useWallet() or useSelectedWallet(p); stays "idle" without a wallet and for adapters without getBalance. error is an Error |
useSigner(connectorId) | useSigner(wallet), with the entry from useWallet() or useSelectedWallet(p); data is now a WalletSigner union and error an Error |
Adapters
Capabilities are gone: check for the method.
// Before
if (wallet.connector.capabilities.signMessage) {
await wallet.connector.signMessage(bytes, account);
}
// After
if (wallet.connector.signMessage) {
await wallet.connector.signMessage(bytes, { account });
}| Before | After |
|---|---|
capabilities.x | connector.x !== undefined. sendTransaction → sendTx, signIn → signIn, switchChain → switchChain, and so on |
getAccount() | (await getAccounts())[0]: the active account is always first |
sendTx(tx, account) | sendTx(tx, { account }) |
sendTxToChain(tx, chainId, account, onSwitched) | sendTx(tx, { account, chain }), where chain is a ChainBase such as EVM_CHAINS.base |
signMessage(msg, account) | signMessage(msg, { account }) |
signTransaction(tx, account) | signTransaction(tx, { account, chain }) |
getBalance(mint) | getBalance({ token, account }): EVM only; Wallet Standard chains need your own RPC client |
switchAccount(address) | removed: no adapter implemented it |
ConnectorEvent { type: "accountChanged", account, accounts } | { type: "accountsChanged", accounts }, active first |
TransactionInput | per platform: EvmTransactionRequest, Uint8Array (SVM), SuiTransactionInput, BitcoinTransfer |
isShadowAdapter(adapter) | exported from @usebutr/core; useIsReconnecting(id) and state.reconnectingIds.has(id) answer the same question by id |
resolveEip6963Capabilities, resolveWalletStandardCapabilities, … | removed |
isSolanaSignMessageFeature and other feature guards | getFeature<SolanaSignMessageFeature>(wallet, "solana:signMessage", "signMessage") |
subscribe emits disconnected for an empty account list | accountsChanged with no accounts; the manager treats both as a disconnect |
Solana account ids solana:mainnet-beta:<address> | solana:mainnet:<address>; SVM_CHAINS.mainnet reaches a wallet that names it solana:mainnet-beta |
Polkadot Wallet Standard signMessage signs the raw bytes | signs them wrapped in <Bytes>…</Bytes>, as injectedWeb3 does; verify against signedMessage |
An account the wallet does not expose now rejects with AccountNotExposed
on every adapter instead of signing with the first account, and a chain the
transport cannot reach rejects with ChainMismatch before the wallet is
asked. chain.name is now always the chain's name, never the wallet's.
Signers
// Before
const provider = (await wallet.connector.getSigner()) as EIP1193Provider;
// After
const signer = await wallet.connector.getSigner();
if (signer.kind === "eip1193") {
createWalletClient({ transport: custom(signer.provider) });
}kind | Fields | Comes from |
|---|---|---|
eip1193 | provider | injected EVM wallets, WalletConnect's EVM namespace |
wallet-standard | wallet | every Wallet Standard adapter (Solana, Sui, Bitcoin, Polkadot) |
walletconnect | provider, chainId | WalletConnect's Solana, Sui and Bitcoin namespaces |
ledger-evm, ledger-svm, ledger-sui, ledger-bitcoin | app | @usebutr/ledger |
unisat, sats-connect | provider | injected Bitcoin wallets |
polkadot-injected | extension, extensionName | window.injectedWeb3 extensions |
SignerForPlatform and SignerOf are replaced by WalletSigner and
WalletSignerOf<"eip1193">.
Errors
ConnectionError is now a class extending Error, with the same kind and
message plus a standard cause. useConnect().connectAsync() and
useWalletManager().connect() reject with it directly; useConnect().connect()
never rejects and puts it in error.
mapConnectionError(raw) is toConnectionError(raw). Two kinds are new:
WalletNotFound covers an id no source announced, and AccountNotExposed an
account the wallet does not expose. A switch over ConnectionErrorKind needs
a case for each.
Custom persistence
WalletPersistence shrinks from eleven methods to two. The manager derives
the whole persisted state after every change, so an implementation never
merges or diffs.
const storage: WalletPersistence = {
load: async () =>
JSON.parse((await kv.get("wallets")) ?? "null") ?? {
activeConnectorId: null,
isUserDisconnected: false,
pool: {},
selection: {},
},
save: async (state) => {
await kv.set("wallets", JSON.stringify(state));
},
};new WalletStorage({ keyPrefix, persistent, session }) is now
createWalletStorage({ keyPrefix, persistent, session }). The storage keys
are unchanged, so existing sessions keep working.
Cookie persistence and the server read come from one call, so the prefix is set once:
// Before
const storage = createWalletStorage({
keyPrefix: "my-app",
persistent: createCookieStorageDriver({ secure: true }),
});
const initialState = readWalletSnapshot(cookies, { keyPrefix: "my-app" });
// After, in a module both the Server Component and the provider import
const walletStorage = createCookieWalletStorage({ keyPrefix: "my-app", secure: true });
const initialState = walletStorage.readInitialState(cookies);createCookieStorageDriver, its initialCookies option, readWalletSnapshot
and EMPTY_SNAPSHOT are removed. A snapshot's active id is now the stored one;
the manager falls back to the first pool entry when it names none or a wallet
the pool does not hold, as it does after a client-side load.
Testing
createFakeAdapter({ chainPlatform }) builds a realistic adapter for that
platform, with the methods that platform has. The capabilities option is
replaced by overrides (replace members) and omit (leave optional members
off). getSigner() resolves the new signer option, any WalletSigner, and
rejects without one; the package registers no signer kind of its own.
createFakeConnectedWallet takes the adapter options instead of an adapter,
and createFakePersistence({ wallets, active, isUserDisconnected }) takes
connected wallets instead of a hand-built PersistedWalletState and records
every save in saves. The fake adapter runs on the same chain targets as the
real ones, so an unexposed account rejects with AccountNotExposed and a
chain outside the platform's registry with ChainMismatch.
@usebutr/testing/contract adds describeAdapterContract, the suite every
butr adapter runs. See Testing.
Testing
@usebutr/testing: fake adapters, fake connected wallets, fake persistence, and the contract suite every adapter runs.
Caveats & Troubleshooting
The sharp edges: connect timeouts, silent storage, best-effort errors, rejected accounts and chains, missing methods, Ledger browser support, hydration races.