import { type AbstractSigner, type TypedDataDomain } from 'ethers'; export declare const SPENDING_AUTH_TYPES: { SpendingAuth: { name: string; type: string; }[]; }; export declare const RESERVE_AUTH_TYPES: { ReserveAuth: { name: string; type: string; }[]; }; export declare const SET_OPERATOR_TYPES: { SetOperator: { name: string; type: string; }[]; }; export declare const FREE_USAGE_OPEN_TYPES: { FreeUsageOpen: { name: string; type: string; }[]; }; export declare const FREE_USAGE_AUTH_TYPES: { FreeUsageAuth: { name: string; type: string; }[]; }; /** * EIP-3009 receiveWithAuthorization typed data, as implemented by Circle's * FiatToken (USDC). Must match the token's typehash exactly: * ReceiveWithAuthorization(address from,address to,uint256 value, * uint256 validAfter,uint256 validBefore,bytes32 nonce) * * For deposit sweeps this is the ONLY buyer signature: addressing the * authorization to the AntseedDepositRelay contract is consent to its * public, immutable fixed FEE. */ export declare const RECEIVE_WITH_AUTHORIZATION_TYPES: { ReceiveWithAuthorization: { name: string; type: string; }[]; }; export interface SpendingAuthMessage { channelId: string; cumulativeAmount: bigint; metadataHash: string; } export interface ReserveAuthMessage { channelId: string; maxAmount: bigint; deadline: bigint; } export interface SetOperatorMessage { operator: string; nonce: bigint; } export interface FreeUsageOpenMessage { channelId: string; deadline: bigint; } export interface FreeUsageAuthMessage { channelId: string; sequence: bigint; metadataHash: string; deadline: bigint; } export interface ReceiveAuthorizationMessage { from: string; to: string; value: bigint; validAfter: bigint; validBefore: bigint; nonce: string; } /** * SpendingAuth metadata v4. * * ABI layout: * abi.encode( * uint256 version, * uint256 cumulativeInputTokens, * uint256 cumulativeOutputTokens, * uint256 cumulativeRequestCount, * uint256 cumulativeOutputImages, * uint256 cumulativeVideoGenerations, * uint256 cumulativeVideoSeconds, * ServiceTotal[] services * ) * * The first four fields intentionally match v1/v2 so legacy decoders can read * aggregate token/request counters by decoding only those fields. Service * entries are buyer-side attribution metadata for indexers: input tokens * include cached input, with cached input broken out separately. The service * tuple appends image and video counters after the v2 fields; decoders must * switch on the leading version word before decoding the services array. * * Generated images are counted twice, deliberately: * - cumulativeOutputImages holds the raw image count (ground truth), * - cumulativeOutputTokens is additionally credited a flat * OUTPUT_IMAGE_TOKEN_EQUIVALENT per image, so token counters reflect * image work. Real text tokens are recoverable as * cumulativeOutputTokens - cumulativeOutputImages * OUTPUT_IMAGE_TOKEN_EQUIVALENT. * * Service cumulativeAmount values may be lower than the top-level * cumulativeAmount because the buyer can sign reserve headroom, cap a * per-request amount, or extend auth without attributing that delta to a * specific service. */ export interface SpendingAuthMetadata { cumulativeInputTokens: bigint; cumulativeOutputTokens: bigint; cumulativeRequestCount: bigint; /** Optional so FreeUsageMetadata-shaped objects remain assignable; encodes as 0. */ cumulativeOutputImages?: bigint; cumulativeVideoGenerations?: bigint; cumulativeVideoSeconds?: bigint; services?: SpendingAuthServiceMetadata[]; } export interface SpendingAuthServiceMetadata { serviceId: string; cumulativeAmount: bigint; cumulativeInputTokens: bigint; cumulativeCachedInputTokens: bigint; cumulativeOutputTokens: bigint; cumulativeRequestCount: bigint; cumulativeOutputImages: bigint; cumulativeVideoGenerations?: bigint; cumulativeVideoSeconds?: bigint; } export declare const METADATA_VERSION = 4n; /** * Flat output-token equivalent credited per generated image in payment metadata * (Gemini 2.5 Flash Image's published rate). Attribution only — never feeds * cost verification. Bound to METADATA_VERSION: changing it requires a bump. */ export declare const OUTPUT_IMAGE_TOKEN_EQUIVALENT = 1290n; export declare function encodeMetadata(metadata: SpendingAuthMetadata): string; export declare function getServiceMetadataId(service: string): string; export interface ServiceMetadataDelta { amount: bigint; inputTokens: bigint; cachedInputTokens: bigint; outputTokens: bigint; requests: bigint; outputImages: bigint; videoGenerations?: bigint; videoSeconds?: bigint; } /** * Most service entries one metadata blob carries. Every SpendingAuth repeats the * full metadata (twice when it carries a reserve batch), so an unbounded list * grows with each distinct service a channel uses until the payment frame * exceeds the 64 KiB payload limit and the seller drops every later auth. * 32 entries keep a batched SpendingAuth well under that limit. */ export declare const MAX_METADATA_SERVICES = 32; /** * Service entry that collects usage of services beyond MAX_METADATA_SERVICES. * Attribution only: the aggregate counters still include every request. */ export declare const OTHER_SERVICES_METADATA_ID: string; /** * Fold a service list that is longer than MAX_METADATA_SERVICES (metadata * persisted before the cap existed) into the largest services by amount plus * the OTHER_SERVICES_METADATA_ID entry. Lists within the cap are returned * unchanged, so this is a no-op once accumulation goes through * withServiceMetadata. */ export declare function boundServiceMetadata(metadata: T): T; export declare function withServiceMetadata(metadata: T, service: string | undefined, delta: ServiceMetadataDelta): T; export declare function computeMetadataHash(metadata: SpendingAuthMetadata): string; export declare const ZERO_METADATA: SpendingAuthMetadata; export declare const ZERO_METADATA_HASH: string; /** * FreeUsage metadata v1. * * ABI layout: * abi.encode( * uint256 version, * uint256 cumulativeInputTokens, * uint256 cumulativeOutputTokens, * uint256 cumulativeRequestCount, * ServiceTotal[] services * ) * * Uses the v2 service tuple (no cumulativeOutputImages field — extra object * properties are ignored when encoding), so existing FreeUsage v1 decoders * keep working unchanged. cumulativeAmount is always zero for free usage. */ export interface FreeUsageMetadata { cumulativeInputTokens: bigint; cumulativeOutputTokens: bigint; cumulativeRequestCount: bigint; services?: SpendingAuthServiceMetadata[]; } export type FreeUsageServiceMetadata = SpendingAuthServiceMetadata; export declare const FREE_USAGE_METADATA_VERSION = 1n; export declare function encodeFreeUsageMetadata(metadata: FreeUsageMetadata): string; export declare function computeFreeUsageMetadataHash(metadata: FreeUsageMetadata): string; export declare const ZERO_FREE_USAGE_METADATA: FreeUsageMetadata; export declare const ZERO_FREE_USAGE_METADATA_HASH: string; /** * Compute the deterministic channelId. * Must match: keccak256(abi.encode(buyer, seller, salt)) */ export declare function computeChannelId(buyer: string, seller: string, salt: string): string; export declare const FREE_USAGE_CHANNEL_DOMAIN: string; /** * Compute the deterministic free usage channelId. * Domain-separated from AntseedChannels.computeChannelId so a paid and free * channel cannot share an ID even if buyer, seller, and salt are identical. */ export declare function computeFreeUsageChannelId(buyer: string, seller: string, salt: string): string; export declare function makeChannelsDomain(chainId: number, contractAddress: string): TypedDataDomain; export declare function makeDepositsDomain(chainId: number, contractAddress: string): TypedDataDomain; export declare function makeFreeUsageDomain(chainId: number, contractAddress: string): TypedDataDomain; /** * EIP-712 domain of Circle's USDC (FiatTokenV2). Verified against the deployed * Base mainnet token (0x8335...2913): name "USD Coin", version "2". MockUSDC * on base-local mirrors the same params. Callers with RPC access should verify * via the token's DOMAIN_SEPARATOR() before first use (the params can differ * on other deployments). */ export declare function makeUsdcDomain(chainId: number, usdcAddress: string): TypedDataDomain; export declare function signSpendingAuth(signer: AbstractSigner, domain: TypedDataDomain, msg: SpendingAuthMessage): Promise; export declare function signReserveAuth(signer: AbstractSigner, domain: TypedDataDomain, msg: ReserveAuthMessage): Promise; export declare function signSetOperator(signer: AbstractSigner, domain: TypedDataDomain, msg: SetOperatorMessage): Promise; export declare function signFreeUsageOpen(signer: AbstractSigner, domain: TypedDataDomain, msg: FreeUsageOpenMessage): Promise; export declare function signFreeUsageAuth(signer: AbstractSigner, domain: TypedDataDomain, msg: FreeUsageAuthMessage): Promise; export interface SignedReceiveAuthorization { message: ReceiveAuthorizationMessage; signature: string; } /** * Build and sign an EIP-3009 ReceiveWithAuthorization for USDC. Works with a * provider-less signer — the hot wallet never needs RPC access to sign. * A random 32-byte nonce is generated when none is supplied. */ export declare function buildReceiveAuthorization(signer: AbstractSigner, domain: TypedDataDomain, params: { to: string; value: bigint; validAfter: bigint; validBefore: bigint; nonce?: string; }): Promise; //# sourceMappingURL=signatures.d.ts.map