/** * Wallet Class * * Represents a Sequence0 threshold wallet. Sign transactions * on any blockchain without holding any private keys — the FROST * network handles distributed signing. * * @example * ```typescript * const wallet = await s0.createWallet({ chain: 'ethereum' }); * * // Sign and send ETH * const txHash = await wallet.sendTransaction({ * to: '0xRecipientAddress', * value: '1000000000000000000', // 1 ETH in wei * }); * * // Sign a message (EIP-191) * const sig = await wallet.signMessage('Hello, World!'); * * // Get balance * const balance = await wallet.getBalance(); * ``` */ import { Chain, Threshold, SignedTransaction, EvmTransaction, BtcTransaction, SolTransaction, OwnerSigner } from '../core/types'; import { AtomicOperation, AtomicSignResult } from '../core/atomic'; import { DelegateOptions, SubDelegateOptions, DelegationGrant, DelegationTree } from '../core/delegation'; export interface WalletConfig { walletId: string; chain: Chain; address: string; publicKey?: string; threshold: Threshold; network: string; agentUrl: string; rpcUrl: string; curve: string; /** Optional signer for wallet ownership proofs on sign requests */ ownerSigner?: OwnerSigner; } export declare class Wallet { /** The wallet's unique ID in the Sequence0 network */ readonly walletId: string; /** Target blockchain */ readonly chain: Chain; /** On-chain address (derived from FROST public key) */ readonly address: string; /** FROST public key (hex) — may differ from address on ed25519 chains */ readonly publicKey: string; /** Threshold configuration (t-of-n) */ readonly threshold: Threshold; /** Elliptic curve used */ readonly curve: string; private network; private http; private adapter; private agentUrl; private rpcUrl; private ownerSigner; /** ANAMNESIS (K8): Password for T-OPRF authentication */ private anamnesisPassword; /** ANAMNESIS (K8): Cached OPRF token from last authentication */ private cachedOprfToken; constructor(config: WalletConfig); /** * Set the password for ANAMNESIS T-OPRF authentication. * When set, signing requests use OPRF token instead of EIP-712. */ setPassword(password: string): void; /** * Enroll this wallet for ANAMNESIS authentication. * Must be called once after wallet creation to set up T-OPRF. * @param password The user's password * @param agentUrls URLs of all agents in the committee */ enrollAnamnesis(password: string, agentUrls?: string[]): Promise; /** * Authenticate with ANAMNESIS and get an OPRF token. * Called automatically during signing when password is set. */ private getOprfToken; /** * Sign a transaction using the FROST threshold network * * Builds a chain-native unsigned transaction, submits it to the * agent network for distributed signing, waits for t-of-n agents * to produce partial signatures, and returns the aggregated result. * * @example * ```typescript * const signed = await wallet.sign({ * to: '0x...', * value: '1000000000000000000', * }); * console.log(signed.hash); * ``` */ sign(transaction: EvmTransaction | BtcTransaction | SolTransaction): Promise; /** * Sign and broadcast a transaction in one call * * @returns Transaction hash on the target chain * * @example * ```typescript * // Send ETH * const txHash = await wallet.sendTransaction({ * to: '0xRecipient', * value: '500000000000000000', // 0.5 ETH * }); * * // Send BTC via Taproot * const txHash = await wallet.sendTransaction({ * to: 'bc1p...recipient', * amount: 50000, // satoshis * feeRate: 15, // sat/vB * }); * * // Send with contract call * const txHash2 = await wallet.sendTransaction({ * to: '0xContract', * data: '0xa9059cbb000000...', // ERC-20 transfer * }); * ``` */ sendTransaction(transaction: EvmTransaction | BtcTransaction | SolTransaction): Promise; /** * Build, threshold-sign, and broadcast the per-chain service fee TX to FeeSplitter. * * Phase 1a optimization: fires fee TX IMMEDIATELY using estimated gas, without * waiting for the main TX receipt (which takes ~12s on Ethereum). Pessimistic * overestimation is acceptable — agents keep any difference. This eliminates * the ~12s background delay on fee collection. /** * Broadcast an already-signed transaction to the blockchain * * @returns Transaction hash */ broadcast(signedTx: SignedTransaction): Promise; /** * Sign a message (EIP-191 for EVM, raw for others) * * @example * ```typescript * const sig = await wallet.signMessage('Hello from Sequence0!'); * // Verify: ethers.verifyMessage('Hello from Sequence0!', sig) === wallet.address * ``` */ signMessage(message: string): Promise; /** * Sign EIP-712 typed data (EVM only) * * @example * ```typescript * const sig = await wallet.signTypedData({ * domain: { name: 'MyDApp', version: '1', chainId: 1 }, * types: { Permit: [...] }, * message: { owner: '0x...', spender: '0x...', value: 100 }, * }); * ``` */ signTypedData(typedData: { domain: Record; types: Record>; primaryType?: string; message: Record; }): Promise; /** * Sign this wallet's transaction as part of an atomic multi-chain operation. * * Builds the signing message from the provided transaction, combines it * with the other operations, and submits the entire batch atomically via * the agent network. Either all operations succeed or none do. * * **Important: Same-owner requirement.** All wallets participating in an * atomic batch (this wallet and every wallet in `otherOperations`) must be * owned by the same address. The ownership proof for every operation is * generated from this wallet's `ownerSigner`, which means it will only be * valid on the agent side if the other wallets share the same on-chain * owner. If any wallet in the batch has a different owner, the agent * network will reject the batch with an ownership-verification failure. * * @param transaction - Transaction to build and sign for this wallet * @param otherOperations - Other wallet operations in the atomic batch. * All referenced wallets must share the same on-chain owner as this wallet. * @returns Atomic result with all signatures or abort error * * @throws {Sequence0Error} If no ownerSigner is configured * @throws {Sequence0Error} If any wallet in otherOperations has a known different owner * @throws {TimeoutError} If the atomic signing times out * * @example * ```typescript * const ethWallet = await s0.getWallet('eth-wallet'); * const result = await ethWallet.signInAtomic( * { to: '0x...', value: '1000000000000000000' }, * [ * { walletId: 'arb-wallet', chain: 'arbitrum', message: '0x...' }, * ], * ); * ``` */ signInAtomic(transaction: EvmTransaction | BtcTransaction | SolTransaction, otherOperations: AtomicOperation[]): Promise; /** * Get the wallet's native token balance * * @returns Balance as string (wei for EVM, satoshis for BTC, lamports for SOL) */ getBalance(): Promise; /** * Get wallet info summary */ info(): Record; /** * Submit a message for FROST signing and wait for the result. * * Default timeout is 60s (FROST DKG/sign rounds can be slow under fleet * load). Override with the SEQUENCE0_SIGN_TIMEOUT_MS env var, or pass an * explicit `timeoutMs` (caller wins). No hardcoded values — see * feedback_no_hardcoded_anything. */ private requestAndWaitSignature; /** * Build an ownership proof for a sign request using EIP-712 typed structured data. * * EIP-712 domain: { name: "Sequence0", version: "1", chainId, verifyingContract: WalletFactory } * EIP-712 type: Sequence0Auth(string walletId, string action, uint256 timestamp) * * For sign requests, the "action" is the message hex being signed. * * Returns null when no ownerSigner is configured (backwards compatible). */ private signOwnershipProof; private createAdapter; private static readonly EVM_CHAINS; private isEvmChain; /** * Extract the BIP-341 sighash from a Taproot adapter's buildTransaction output. * * The Taproot adapter returns hex-encoded JSON containing a `sighash` field. * The FROST agent must sign ONLY this 32-byte sighash (not the entire blob). * * For multi-input transactions, this returns the first input's sighash. * Multi-input support (signing each input separately) is handled at a * higher level via the BitcoinTaprootAdapter's direct API. */ private extractBitcoinSighash; /** * Delegate signing authority to another address. */ delegate(options: DelegateOptions): Promise; /** * Create a sub-delegation from an existing delegation grant. */ delegateFrom(options: SubDelegateOptions): Promise; /** * Revoke a delegation grant (cascading to all sub-grants). */ revoke(delegationId: string): Promise; /** * List all delegation grants for this wallet. */ listDelegations(): Promise; /** * Get the delegation tree for this wallet. */ getDelegationTree(): Promise; /** * Send heartbeat for dead-man's switch delegation grants. */ heartbeat(): Promise; } //# sourceMappingURL=wallet.d.ts.map