import { HexString, SS58String } from 'polkadot-api'; import { Weight } from '@parity/product-sdk-tx'; import { A as AbiEntry, a as ContractRuntime, w as ReviveDryRunResult } from './types-Dtu4IsSh.js'; import '@parity/result'; import '@parity/product-sdk-signer'; import '@parity/product-sdk-errors'; /** Options for {@link fakeDryRunResult}. */ interface FakeDryRunResultOptions { /** Raw ABI-encoded return bytes. Ignored when the runtime encodes for you. */ data?: Uint8Array; /** Simulate a revert: `true` for an empty reason, a string for a UTF-8 reason. Sets the revert flag. */ revert?: boolean | string; /** Simulate a dispatch failure (`result.success: false`) carrying this payload. */ failure?: unknown; /** Weight surfaced as a query's `gasRequired`. Default `{ ref_time: 1n, proof_size: 1n }`. */ weightRequired?: Weight; } /** * Build a {@link ReviveDryRunResult}. Defaults to a successful, empty return; * pass `data` for a raw payload, `revert` for a revert, or `failure` for a * dispatch error. */ declare function fakeDryRunResult(options?: FakeDryRunResultOptions): ReviveDryRunResult; /** The dry-run / query a fake runtime was asked to perform. */ interface DecodedContractCall { origin: SS58String; dest: HexString; value: bigint; data: Uint8Array; /** Decoded function name — present only when `abi` was supplied. */ functionName?: string; /** Decoded arguments — present only when `abi` was supplied. */ args?: unknown[]; } /** The extrinsic a fake runtime was asked to build via `.tx()` / `.prepare()`. */ interface BuiltContractCall { dest: HexString; value: bigint; weight_limit: Weight; storage_deposit_limit: bigint; data: Uint8Array; } /** A fake {@link ContractRuntime} with an inspection surface for tests. */ interface FakeContractRuntime extends ContractRuntime { /** Every dry-run / query the runtime handled, in order. */ readonly calls: ReadonlyArray; /** Clear the recorded calls. */ reset(): void; } /** Options for {@link createFakeContractRuntime}. */ interface CreateFakeContractRuntimeOptions { /** * ABI used to decode inbound calldata (so `onQuery` gets `functionName` / * `args`) and to encode a value `onQuery` returns. Omit only if `onQuery` * returns raw bytes or a {@link fakeDryRunResult}. */ abi?: AbiEntry[]; /** * Handle each query / dry-run. Return the value to decode to (encoded via * `abi`), raw bytes, or a {@link fakeDryRunResult}. Default: empty success. */ onQuery?: (call: DecodedContractCall) => unknown; /** Called with the extrinsic `.tx()` / `.prepare()` builds. */ onCall?: (call: BuiltContractCall) => void; } /** * Create an in-memory {@link ContractRuntime}. * * @example * ```ts * import { createContract } from "@parity/product-sdk-contracts"; * import { createFakeContractRuntime } from "@parity/product-sdk-contracts/testing"; * * const runtime = createFakeContractRuntime({ * abi: erc20Abi, * onQuery: ({ functionName }) => (functionName === "balanceOf" ? 1000n : 0n), * }); * const token = createContract(runtime, ADDRESS, erc20Abi); * const { value } = await token.balanceOf.query(HOLDER); // 1000n * ``` */ declare function createFakeContractRuntime(options?: CreateFakeContractRuntimeOptions): FakeContractRuntime; export { type BuiltContractCall, type CreateFakeContractRuntimeOptions, type DecodedContractCall, type FakeContractRuntime, type FakeDryRunResultOptions, createFakeContractRuntime, fakeDryRunResult };