@usebutr/sui
Wallet Standard discovery, the adapter builder, and the Sui feature types.
Discovery
discoverSuiAdapters(onAdapter, loadModule?): () => void
Subscribes to Wallet Standard registrations for Sui wallets (Slush, Phantom,
Suiet, Surf, …). Lazily imports @wallet-standard/app, an optional peer
dependency; loadModule injects a registry for tests. It is a WalletSource
as-is:
import type { WalletManagerConfig } from "@usebutr/core";
import { discoverSuiAdapters } from "@usebutr/sui";
const config: WalletManagerConfig = { sources: [discoverSuiAdapters] };Adapter builder
buildSuiAdapter(wallet, registerDisconnector?): SuiAdapter | null
Wraps a WalletStandardWallet, or returns null when it speaks no Sui. The
id is slugify("sui", wallet.name). Each optional method exists only when the
wallet advertises its feature:
| Method | Feature | Resolves |
|---|---|---|
sendTx | sui:signAndExecuteTransaction | The transaction digest. |
signMessage | sui:signPersonalMessage | { signature, signedMessage }. |
signTransaction | sui:signTransaction | { bytes, signature } for executeTransactionBlock. |
Transactions are a @mysten/sui Transaction, its JSON string, BCS bytes, or
their base64 (SuiTransactionInput); the wallet receives the string
prepareSuiTransaction produces through toJSON(). switchChain needs more
than one advertised Sui network. There is no getBalance or
getTransactionReceipt. See the Sui connector.
Transaction input
Import from @usebutr/sui/transaction. This entry point loads no wallet
discovery code. Wallet Standard, WalletConnect and Ledger share it; see
Sui inputs for what each transport takes.
prepareSuiTransaction(tx): Promise<SuiSigningPayload>
Reads a SuiTransactionInput the way Transaction.from does: a string
starting with { is a Transaction's JSON, any other string is base64 BCS
bytes. Resolves serialized, the string every transport sends, and bytes,
the BCS bytes when the input carried them (bytes or base64). A Transaction
or its JSON has no bytes until it is built against an RPC client. A string
that is neither JSON nor base64 rejects.
serializeEd25519Signature(signature, publicKey): Uint8Array
Sui's serialized signature for an Ed25519 key: the scheme flag 0, the
64-byte signature and the 32-byte public key, as executeTransactionBlock
takes it. Rejects any other length. Ledger uses it on the device's signature.
Signer
getSigner() resolves { kind: "wallet-standard", wallet }. Reach a feature
with getFeature from
@usebutr/wallet-standard-shared and the
feature types below.
Types
SuiSignPersonalMessageFeature,SuiSignPersonalMessageInput,SuiSignPersonalMessageOutputSuiSignTransactionFeature,SuiSignTransactionInput,SuiSignTransactionOutputSuiSignAndExecuteTransactionFeature,SuiSignAndExecuteTransactionInput,SuiSignAndExecuteTransactionOutputSuiSigningPayload, from@usebutr/sui/transaction
The Sui chain registry (SUI_CHAINS, CHAINS_BY_PLATFORM.sui) lives in
@usebutr/core.
Source: packages/sui/src/index.ts, packages/sui/src/transaction.ts.