/** * Command Composition Layer * Shared plumbing for write commands: context resolution (org + signer), * the confirmation policy, transaction result rendering, interactive * gap-filling for missing args, and idempotency wiring. Commands compose * these helpers instead of re-implementing the same boilerplate. */ import { ethers } from 'ethers'; import type { TxResult } from './tx'; export interface WriteContext { orgId: string; modules: any; signer: ethers.Wallet; provider: ethers.providers.Provider; address: string; chainId: number; networkName: string; } /** Test-only hook: reset the per-process context memo. */ export declare function _clearWriteContextCacheForTest(): void; /** * Resolve everything a write command needs: org modules (unless * opts.needsOrg is false), a connected signer, and network identity. */ export declare function getWriteContext(argv: any, opts?: { needsOrg?: boolean; }): Promise; /** * Confirmation policy for write commands: * - --yes or POP_ASSUME_YES=1 → proceed without asking (explicit consent) * - destructive without explicit consent → interactive TTY prompts; anything * else refuses. --json is NOT consent: it selects the output format, and * every automated integrator runs with it, so treating it as consent made * the destructive guard dead code for exactly the audience it protects. * - non-destructive: --json or non-TTY proceed (preserves agent behavior); * interactive TTY shows the summary and asks. */ export declare function confirmWrite(argv: any, summary: Record, opts?: { destructive?: boolean; actionLabel?: string; }): Promise; /** * Render a TxResult consistently: * - dry-run → one success line with method/to/gasEstimate, no lag warning * - success → success line with entity fields + txHash/explorerUrl, then * onSuccess() (e.g. idempotency recording) and the subgraph lag warning * - failure → decoded error details, exit EXIT.TX_FAILED */ export declare function finishWrite(result: TxResult, opts: { successMsg: string; fields?: Record; onSuccess?: () => void; }): void; export interface MissingArgSpec { key: string; question: string; kind: 'input' | 'select' | 'number'; choices?: Array<{ label: string; value: any; }>; validate?: (s: string) => string | true; } /** * Fill missing argv keys (undefined/null/empty string) interactively. * Non-TTY sessions get the classic hard error instead, so agents keep * their explicit-flags contract. */ export declare function promptMissing(argv: A, spec: MissingArgSpec[]): Promise; /** * Idempotency wrapper — the pattern from task/create.ts + vote/cast.ts * (task #369/#370) extracted. Cache hit within the TTL prints the prior * result and returns without running; otherwise `run()` executes and its * returned fields are recorded for the next retry. Honors * --idempotency-key, --no-idempotency, and --idempotency-ttl (seconds, * resolved via resolveTtlSeconds's param → env → default chain). */ export declare function withIdempotency(argv: any, orgId: string, command: string, run: () => Promise>): Promise;