import { type Address, type Hash, type Hex, type TransactionReceipt } from "viem"; import { type DecodedSmartContractError } from "../../utils/decodeSmartContractErrors.js"; import type { ProviderService } from "../providerService/index.js"; import type { EVCBatchItem, PermitSingleTypedData, TransactionPlanPrepared } from "./executionServiceTypes.js"; export type Permit2MaterializationInput = { planItemIndex: number; resolvedIndex: number; nonce: number; sigDeadline: bigint; expiration: number; }; export type MaterializeExecutionArgs = { prepared: TransactionPlanPrepared; inputs: { evcAddress: Address; permit2: readonly Permit2MaterializationInput[]; }; }; export type MaterializedExecutionRequestKind = "approval" | "evcBatch" | "contractCall"; /** Exact transaction template sealed before dynamic signatures are collected. */ export type MaterializedExecutionRequest = { requestIndex: number; sourcePlanItemIndex: number; kind: MaterializedExecutionRequestKind; chainId: number; from: Address; to: Address; data: Hex; value: bigint; }; export type MaterializedSafeCall = Pick; export type MaterializedPermit2SignatureSlot = { slotId: Hash; kind: "permit2"; signer: Address; chainId: number; planItemIndex: number; resolvedIndex: number; nonce: number; validUntil: bigint; typedDataHash: Hash; typedData: PermitSingleTypedData; insertion: { requestIndex: number; batchItemIndex: number; }; }; export type MaterializedExecution = { readonly __materialized: true; readonly chainId: number; readonly from: Address; readonly evcAddress: Address; readonly requests: readonly MaterializedExecutionRequest[]; readonly signatureSlots: readonly MaterializedPermit2SignatureSlot[]; readonly safeCalls: readonly MaterializedSafeCall[]; }; export type MaterializedSignatureValue = { slotId: Hash; signature: Hex; }; /** * A finalized request vector supplied as trusted application input. The SDK * does not authenticate this artifact. The application must cover the complete * artifact with its accepted review digest before passing it to * `executeMaterialized`. */ export type FinalizedMaterializedExecution = { readonly __materialized: true; /** Structural discriminator only; this is not a security seal. */ readonly __finalized: true; readonly chainId: number; readonly from: Address; readonly evcAddress: Address; readonly requests: readonly MaterializedExecutionRequest[]; readonly signatureSlots: readonly MaterializedPermit2SignatureSlot[]; readonly signatureValues: readonly MaterializedSignatureValue[]; readonly safeCalls: readonly MaterializedSafeCall[]; }; export type MaterializedExecutionProgress = { completed: number; total: number; request?: MaterializedExecutionRequest; status: "signature" | "transaction" | "completed"; hash?: Hash; }; export type ExecuteMaterializedOptions = { sendTransaction: (request: MaterializedExecutionRequest) => Promise; signTypedData?: (typedData: PermitSingleTypedData) => Promise; revalidate?: { permit2NonceMustEqualPinned?: boolean; }; /** Awaited immediately before every signature wallet prompt. */ onBeforeSignature?: (slot: MaterializedPermit2SignatureSlot, index: number) => Promise | void; /** Awaited after all signatures are inserted and before the first signed batch. */ onFinalized?: (execution: FinalizedMaterializedExecution) => Promise | void; /** Awaited immediately before every transaction wallet prompt. */ onBeforeStep?: (request: MaterializedExecutionRequest, index: number) => Promise | void; /** Awaited after broadcast and before receipt polling. */ onTransactionHash?: (request: MaterializedExecutionRequest, index: number, hash: Hash) => Promise | void; /** Awaited after a successful receipt and before the next wallet prompt. */ onAfterStep?: (request: MaterializedExecutionRequest, index: number, hash: Hash, receipt: TransactionReceipt) => Promise | void; onProgress?: (progress: MaterializedExecutionProgress) => void; }; export type MaterializedExecutionResult = { execution: FinalizedMaterializedExecution; hashes: Hash[]; receipts: TransactionReceipt[]; }; export interface MaterializedExecutionEncoder { getPermit2TypedData(args: { chainId: number; token: Address; amount: bigint; spender: Address; nonce: number; sigDeadline: bigint; expiration: number; }): PermitSingleTypedData; encodePermit2Call(args: { chainId: number; owner: Address; message: PermitSingleTypedData["message"]; signature: Hex; }): EVCBatchItem; encodeBatch(items: EVCBatchItem[]): Hex; } export declare class MaterializedExecutionError extends Error { readonly decodedErrors: DecodedSmartContractError[]; readonly originalError: unknown; constructor(message: string, originalError: unknown, decodedErrors: DecodedSmartContractError[]); } export declare class MaterializedTransactionRevertedError extends Error { readonly hash: Hash; constructor(hash: Hash); } /** * Purely compose a prepared plan into deterministic transaction templates. * All live values used by composition are explicit inputs. Permit2 signatures * are represented by typed signature slots and a fixed placeholder. */ export declare function materializeExecution(encoder: MaterializedExecutionEncoder, args: MaterializeExecutionArgs): MaterializedExecution; /** Purely insert the exact provided signatures without changing any other byte. */ export declare function finalizeMaterializedExecution(encoder: MaterializedExecutionEncoder, materialized: MaterializedExecution, signatures: readonly MaterializedSignatureValue[]): FinalizedMaterializedExecution; /** * Dispatch static prerequisites that precede the first signed batch, collect * the declared signatures, finalize a new immutable request vector, then * dispatch its remaining exact requests. No transaction is recomposed during * dispatch. A supplied FinalizedMaterializedExecution is not authenticated by * the SDK; this function assumes the application already authenticated the * complete finalized input against its accepted review digest. */ export declare function executeMaterialized(encoder: MaterializedExecutionEncoder, providerService: ProviderService, materialized: MaterializedExecution | FinalizedMaterializedExecution, options: ExecuteMaterializedOptions): Promise; //# sourceMappingURL=materializedExecution.d.ts.map