/** * Shared EIP-2612 Variant-D payment builder. * * Extracted from `commands/call.ts` so `pipeline call` signs permits with the * exact same code path as `call` (skills). Keeping one implementation matters: * if the two drifted, a purchase could pass for skills and fail for pipelines, * or vice versa, for reasons invisible in either test suite. * * Server contract (`/v1/skills/:id/invoke` and `/v1/pipelines/:id/invoke` both): * 1. Call without `payment` → 402 `{ mode: 'eip2612_permit_variant_d', ... }` * carrying token/chain/recipients/amounts. * 2. Sign a Permit over the 402 fields and retry with `{ payment }`. * * The permit value is the TOTAL charged (rent, not token cost — the server * settles the token/compute difference from its own accounting afterwards). */ import { Wallet } from 'ethers'; export interface PermitD402 { code: 'PAYMENT_REQUIRED'; mode: 'eip2612_permit_variant_d'; skill_id: string; price_usdc: number; commission_bps: number; author_recipient: string; treasury_recipient: string; amount_to_author: string; amount_to_treasury: string; operator_address: string; token_address: string; chain_id: number; permit_deadline_recommended: number; } export interface Eip2612Permit { owner: string; spender: string; value: string; nonce: number; deadline: string; v: number; r: string; s: string; } export interface VariantDPayment { asset_id: string; permit: Eip2612Permit; author_recipient: string; treasury_recipient: string; amount_to_author: string; amount_to_treasury: string; shared_link: string; } export declare function isPermitD402(body: unknown): body is PermitD402; export declare function sharedLinkFromPermit(permitNonce: number, assetId: string, buyerAddress: string, operatorAddress: string): string; /** * Sign a Permit for the given 402 challenge and return a retry `payment` body. * * `assetId` must be the id the server addressed (pipeline id or skill id); the * server validates asset_id against the route parameter, and the shared_link is * derived from it, so a mismatch is rejected fail-closed. */ export declare function buildVariantDPayment(challenge: PermitD402, assetId: string, buyerAddress: string, wallet: Wallet): Promise;