import { TypedData } from 'starknet'; /** A chain-native contract call (Starknet `Call`-shaped; generic for portability). */ interface ChainCall { contractAddress: string; entrypoint: string; calldata: string[]; } /** * Options for state-changing wallet calls (`execute`, `upgrade`, etc.). * * await wallet.execute(calls); // the account pays * await wallet.execute(calls, { fee: 'sponsored' }); // the app pays * await wallet.execute(calls, { fee: { token: USDC } }); // the user pays, in USDC * * `fee` answers one question — who pays, and in what — so the three answers are * one field rather than several flags that look independent and are not. * * - `'self'` (the default on Solana): the account pays from its own balance. * - `'sponsored'`: the Cavos relayer / paymaster pays, so the user signs but * never holds a gas token. On Starknet and Stellar this is the default, * because a fresh account there cannot deploy itself or meet the base * reserve without help. * - `{ token }`: the user pays, in a token they already hold. Solana only. * Toll is the fee payer and settles in that token in the same transaction, * so an account holding no SOL still transacts. Requires a `toll` client. */ /** Who pays. Meaningful on every chain. */ type FeeMode = 'self' | 'sponsored'; /** * Solana can also be paid in a token, through Toll. No other chain can, so no * other chain's options accept it — a `{ token }` written against Stellar or * Starknet fails to compile rather than being quietly ignored, which is what * it was doing when `fee` lived in the shared type but only Solana read it. */ type SolanaFeeMode = FeeMode | { token: string; }; interface ExecuteOptions { fee?: FeeMode; /** * @deprecated Use `fee`. `true` is `'sponsored'`, `false` is `'self'`. */ sponsored?: boolean; } interface SolanaExecuteOptions extends Omit { fee?: SolanaFeeMode; } /** * Off-chain message signing + sign-without-submit types, shared across chains. * * `signMessage` signs an arbitrary message off-chain (no transaction, no gas, * no state change) so a third party can verify the wallet owner endorsed it — * the canonical primitive for Sign-In-with-X, off-chain auth, and attestations. * * `signTransaction` signs a chain-native transaction WITHOUT submitting it, * returning the signed artifact a relayer/backend can broadcast later. */ /** Curve a signature was produced with. Determines how a verifier checks it. */ type SignatureCurve = "secp256r1" | "ed25519" | "stark"; /** * Result of `wallet.signMessage(message)`. The signature is over the SNIP-12 * typed-data hash for Starknet (stark curve) and over `prefixedMessageBytes` * for the Ed25519 keys of Solana and Stellar. `publicKey` is the string a verifier needs to confirm ownership: * - Starknet: the stark public key (hex) the account was deployed with. * - Solana: the system-account address (ed25519). * - Stellar: the `G…` control address (ed25519). * * Check `curve` to know which verification path to use. */ interface MessageSignature { /** Chain-native signature bytes (64 bytes: stark r‖s, or ed25519). */ signature: Uint8Array; /** Verifier input: the key/address that owns this wallet's signing authority. */ publicKey: string; /** Curve used to produce the signature. */ curve: SignatureCurve; /** The SNIP-12 typed data that was signed (Starknet). */ typedData?: TypedData; } /** * A transaction signed but NOT submitted. The concrete shape is chain-specific * — narrow on `chain` to read the fields. * * : every variant is **single-use and binds to on-chain * state** (Starknet nonce + resourceBounds, Stellar sequence number, Solana * on-chain nonce). If any other transaction from the same account is submitted * first, this signature becomes invalid. Broadcast promptly. */ type SignedTransaction = StarknetSignedTransaction | StellarSignedTransaction | SolanaSignedTransaction; /** Starknet invoke, signed by the account key (2-felt stark signature), not broadcast. */ interface StarknetSignedTransaction { chain: "starknet"; /** Hex-encoded calldata felts of the built invoke. */ calldata: string[]; /** The stark signature as hex strings: `[r, s]`. */ signature: string[]; /** Account nonce the signature binds to. */ nonce: string; /** Resource bounds the signature binds to (L1/L2 gas). */ resourceBounds: { l1Gas: { maxAmount: string; maxPricePerUnit: string; }; l2Gas: { maxAmount: string; maxPricePerUnit: string; }; }; /** Transaction version (hex). */ version: string; } /** Stellar classic transaction, signed by the ed25519 control key, as base64 XDR. */ interface StellarSignedTransaction { chain: "stellar"; /** Base64-encoded signed inner Transaction envelope (fee-bumpable by a relayer). */ xdr: string; } /** * Solana device signature over the serialized transaction message. The spend * key is the native Ed25519 of the system account. */ interface SolanaSignedTransaction { chain: "solana"; /** Serialized Solana message the spend key signed. */ message: Uint8Array; /** 64-byte Ed25519 signature. */ signature: Uint8Array; /** 32-byte Ed25519 public key. */ publicKey: Uint8Array; } /** Prefix scheme for off-chain messages, mirroring EIP-191 / Solana's convention. */ declare const CAVOS_MESSAGE_PREFIX = "Cavos Signed Message:\n"; /** Build the prefixed message bytes an Ed25519 chain signs for `signMessage`. * Format: `CAVOS_MESSAGE_PREFIX` + ASCII decimal length + `\n` + message. */ declare function prefixedMessageBytes(message: Uint8Array): Uint8Array; export { type ChainCall as C, type ExecuteOptions as E, type FeeMode as F, type MessageSignature as M, type StarknetSignedTransaction as S, type StellarSignedTransaction as a, type SolanaExecuteOptions as b, type SolanaSignedTransaction as c, CAVOS_MESSAGE_PREFIX as d, type SignatureCurve as e, type SignedTransaction as f, type SolanaFeeMode as g, prefixedMessageBytes as p };