import { TransactionSigner, Rpc, SolanaRpcApi, RpcSubscriptions, SolanaRpcSubscriptionsApi, Commitment, Slot, AccountRole, Instruction } from '@solana/kit'; import { TransactionTransport, SendOptions, TransactionInspectionOptions, TransactionInspectionResult, TransactionVersion, WalletAdapter, BuiltInstruction, WalletExecutionContext, SendResult, TransactionFailureOutcome, BuiltAccountMeta } from '@usearete/sdk'; /** * Wallet Standard → kit signer bridge. * * The handoff is byte-oriented on purpose: the app picks the transaction * format, the wallet decodes the version out of the bytes it is given, and * Arete forwards whatever came back without converting versions. Nothing * here routes a transaction through a web3.js 1.x wrapper, which cannot * represent V1 at all. * * The capability check is a local fact about the wallet, not proof the * cluster has activated a version: the account must advertise * `solana:signTransaction`, and *that* feature must advertise the version * being signed. Sign-and-send support is never read as sign-only support — * a wallet that can only sign-and-send cannot hand bytes back for Arete to * relay. * * As of Kit 8, the upstream Wallet Standard `signTransaction` feature still * types `supportedTransactionVersions` as `legacy | 0`. The interfaces below * are therefore declared structurally rather than imported, so a wallet that * does advertise `1` is usable without a cast and one that does not is * refused before it is ever prompted. */ /** The feature name a sign-only handoff requires. */ declare const SOLANA_SIGN_TRANSACTION = "solana:signTransaction"; /** The feature name that is explicitly *not* evidence of sign-only support. */ declare const SOLANA_SIGN_AND_SEND_TRANSACTION = "solana:signAndSendTransaction"; type WalletStandardTransactionVersion = 'legacy' | 0 | 1; interface WalletStandardAccount { readonly address: string; readonly features: readonly string[]; } interface WalletStandardSignTransactionInput { readonly account: WalletStandardAccount; readonly transaction: Uint8Array; readonly chain?: string; } interface WalletStandardSignTransactionOutput { readonly signedTransaction: Uint8Array; } interface WalletStandardSignTransactionFeature { readonly version: string; readonly supportedTransactionVersions: readonly WalletStandardTransactionVersion[]; signTransaction(...inputs: readonly WalletStandardSignTransactionInput[]): Promise; } interface WalletStandardWallet { readonly features: Readonly>; } type WalletStandardSignerErrorCode = 'sign_transaction_unsupported' | 'transaction_version_unsupported' | 'wallet_returned_invalid_transaction'; /** Typed refusal from the Wallet Standard bridge. */ declare class WalletStandardSignerError extends Error { readonly code: WalletStandardSignerErrorCode; constructor(code: WalletStandardSignerErrorCode, message: string); } interface WalletStandardSignerConfig { readonly wallet: WalletStandardWallet; readonly account: WalletStandardAccount; /** CAIP-2 chain forwarded to the wallet, e.g. `solana:devnet`. */ readonly chain?: string; } /** * A kit {@link TransactionSigner} backed by a Wallet Standard account. * * The feature is resolved once, at creation, so a wallet that cannot sign at * all fails before any transaction is built. The per-version check happens * per transaction, against the version decoded from the bytes about to be * handed over — so a v0-only wallet refuses a V1 transaction without ever * showing the user a prompt. */ declare function createWalletStandardSigner(config: WalletStandardSignerConfig): TransactionSigner; /** * @usearete/adapter-kit * * A reference {@link WalletAdapter} implementation backed by @solana/kit * (the functional successor to @solana/web3.js). * * The Arete core SDK is RPC-free: it only builds `BuiltInstruction` objects. * This adapter owns blockhash fetching, message construction, signing, * sending, and confirmation. */ /** Wire ceiling for legacy and v0 transactions, in bytes (one UDP packet). */ declare const LEGACY_TRANSACTION_SIZE_LIMIT = 1232; /** Wire ceiling for V1 transactions, in bytes (SIMD-0385). */ declare const V1_TRANSACTION_SIZE_LIMIT = 4096; /** Structural V1 caps enforced before a signer is reached (SIMD-0385). */ declare const V1_MAX_SIGNATURES = 12; declare const V1_MAX_ACCOUNTS = 64; declare const V1_MAX_INSTRUCTIONS = 64; /** * Per-transaction compute-unit maximum. Also the limit a *provisional* V1 * message declares for a budget the caller omitted: SIMD-0385 makes an unset * V1 config field request the **minimum**, not a default, so a provisional * message carrying nothing could never produce an ordinary successful * execution estimate. */ declare const MAX_COMPUTE_UNIT_LIMIT = 1400000; /** Loaded-account-data maximum (64 MiB), used the same way. */ declare const MAX_LOADED_ACCOUNTS_DATA_SIZE: number; /** * Headroom added to measured compute consumption, in percent: a simulation * is one slot's view of the chain and the transaction that lands may take a * slightly different branch. */ declare const ESTIMATED_COMPUTE_UNIT_HEADROOM_PERCENT = 20n; /** * The runtime accounts for loaded data in pages of this size, so an * estimated data budget is rounded up to a whole page plus one page of * headroom for account growth between simulation and execution. */ declare const LOADED_ACCOUNTS_DATA_PAGE_BYTES: number; type AdapterTransportSelection = 'auto' | 'direct' | TransactionTransport; interface KitAdapterConfig { /** A Solana RPC client (from `createSolanaRpc`). */ rpc?: Rpc; /** A Solana RPC subscriptions client (from `createSolanaRpcSubscriptions`). */ rpcSubscriptions?: RpcSubscriptions; transport?: AdapterTransportSelection; /** The fee-payer / signer for transactions. */ signer: TransactionSigner; /** Optional local signers that can satisfy additional required signatures. */ additionalSigners?: readonly TransactionSigner[]; /** Default commitment used when the caller does not specify one. */ defaultCommitment?: Commitment; } interface KitSendOptions extends SendOptions { /** Extra local signers for this send only. */ additionalSigners?: readonly TransactionSigner[]; /** Override the fee payer for this send. */ feePayer?: TransactionSigner; confirmationTimeoutMs?: number; statusPollIntervalMs?: number; } interface KitTransactionInspectionOptions extends TransactionInspectionOptions { /** Commitment used to fetch the blockhash, fee, and simulation context. */ commitment?: Commitment; /** Reject RPC responses evaluated before this slot. */ minContextSlot?: Slot; /** Fee payer address used to compile the unsigned transaction. */ feePayer?: string; } interface KitTransactionInspectionResult extends TransactionInspectionResult { /** RPC context used for the fee estimate. */ feeContextSlot?: number; /** The version the inspected message was compiled for. */ transactionVersion: TransactionVersion; /** * The resource budget the inspected message actually declares, as decimal * strings. For a V1 message this includes the protocol maxima standing in * for the ceilings the caller omitted, which is what the reported metrics * let you replace with pinned values. */ resources: Record; } interface KitWalletAdapter extends WalletAdapter { readonly signerAddresses: readonly string[]; readonly supportedTransactionVersions: readonly ['legacy', 0, 1]; signAndSend(instructions: readonly BuiltInstruction[], options?: KitSendOptions, context?: WalletExecutionContext): Promise; inspectTransaction(instructions: readonly BuiltInstruction[], options?: KitTransactionInspectionOptions, context?: WalletExecutionContext): Promise; } /** Structured adapter error consumed by the Arete transaction outcome APIs. */ declare class KitTransactionExecutionError extends Error { readonly outcome: TransactionFailureOutcome; readonly cause: unknown; readonly signature?: string; readonly slot?: number; constructor(outcome: TransactionFailureOutcome); } /** The backend one operation runs on, selected once before it starts. */ type ResolvedTransport = { readonly kind: 'arete'; readonly transport: TransactionTransport; } | { readonly kind: 'direct'; readonly rpc: Rpc; readonly rpcSubscriptions: RpcSubscriptions; }; /** Map an Arete account meta to a kit AccountRole. */ declare function toAccountRole(meta: BuiltAccountMeta): AccountRole; /** Map a kit AccountRole back to Arete signer/writable flags. */ declare function fromAccountRole(role: AccountRole): { isSigner: boolean; isWritable: boolean; }; /** Convert an Arete BuiltInstruction to a kit Instruction. */ declare function toKitInstruction(ix: BuiltInstruction): Instruction; /** Convert a kit Instruction to an Arete BuiltInstruction. */ declare function fromKitInstruction(ix: Instruction): BuiltInstruction; /** Measured consumption plus headroom, positive and protocol-bounded. */ declare function estimatedComputeUnitLimit(unitsConsumed: bigint): bigint; /** Measured loaded data rounded up to a whole page plus one page of headroom. */ declare function estimatedLoadedAccountsDataSize(loadedBytes: bigint): bigint; /** * Create a {@link WalletAdapter} from a kit RPC pair and a signer. */ declare function createWalletAdapter(config: KitAdapterConfig): KitWalletAdapter; interface InspectOnlyWalletAdapterConfig { /** The address transactions are prepared for (fee payer and wallet signer). */ publicKey: string; /** A Solana RPC client, for inspection without an Arete client. */ rpc?: Rpc; /** A Solana RPC subscriptions client, paired with `rpc`. */ rpcSubscriptions?: RpcSubscriptions; /** Arete when connected, direct when explicitly selected, or a custom transport. */ transport?: AdapterTransportSelection; /** Default commitment for blockhash, fee and simulation RPCs. */ defaultCommitment?: Commitment; } /** `name` of the error an inspect-only adapter refuses a sign or send with. */ declare const INSPECT_ONLY_WALLET_ERROR = "InspectOnlyWalletError"; /** * A {@link WalletAdapter} that holds only a public key: operations prepare * against it and `client.inspectOperation()` estimates fees and simulates * them, but every sign or send is refused before anything is built or * dispatched. For agents and CI that verify transactions without keys. */ declare function createInspectOnlyWalletAdapter(config: InspectOnlyWalletAdapterConfig): KitWalletAdapter; export { ESTIMATED_COMPUTE_UNIT_HEADROOM_PERCENT, INSPECT_ONLY_WALLET_ERROR, KitTransactionExecutionError, LEGACY_TRANSACTION_SIZE_LIMIT, LOADED_ACCOUNTS_DATA_PAGE_BYTES, MAX_COMPUTE_UNIT_LIMIT, MAX_LOADED_ACCOUNTS_DATA_SIZE, SOLANA_SIGN_AND_SEND_TRANSACTION, SOLANA_SIGN_TRANSACTION, V1_MAX_ACCOUNTS, V1_MAX_INSTRUCTIONS, V1_MAX_SIGNATURES, V1_TRANSACTION_SIZE_LIMIT, WalletStandardSignerError, createInspectOnlyWalletAdapter, createWalletAdapter, createWalletStandardSigner, estimatedComputeUnitLimit, estimatedLoadedAccountsDataSize, fromAccountRole, fromKitInstruction, toAccountRole, toKitInstruction }; export type { AdapterTransportSelection, InspectOnlyWalletAdapterConfig, KitAdapterConfig, KitSendOptions, KitTransactionInspectionOptions, KitTransactionInspectionResult, KitWalletAdapter, ResolvedTransport, WalletStandardAccount, WalletStandardSignTransactionFeature, WalletStandardSignTransactionInput, WalletStandardSignTransactionOutput, WalletStandardSignerConfig, WalletStandardSignerErrorCode, WalletStandardTransactionVersion, WalletStandardWallet };