@invisi-labs/sdk 1.1.3 → 1.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-FSQYZO66.js → chunk-BE52B32Z.js} +608 -196
- package/dist/chunk-BE52B32Z.js.map +1 -0
- package/dist/ethers.d.cts +2 -2
- package/dist/ethers.d.ts +2 -2
- package/dist/index.cjs +910 -421
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +240 -39
- package/dist/index.d.ts +240 -39
- package/dist/index.js +247 -131
- package/dist/index.js.map +1 -1
- package/dist/indexeddb.cjs +645 -242
- package/dist/indexeddb.cjs.map +1 -1
- package/dist/indexeddb.d.cts +2 -2
- package/dist/indexeddb.d.ts +2 -2
- package/dist/indexeddb.js +1 -1
- package/dist/memory.cjs +645 -242
- package/dist/memory.cjs.map +1 -1
- package/dist/memory.d.cts +3 -3
- package/dist/memory.d.ts +3 -3
- package/dist/memory.js +1 -1
- package/dist/{gas-estimation-BU3or4AH.d.ts → operation-types-D7I405FX.d.ts} +122 -118
- package/dist/{gas-estimation-C1OEgFFJ.d.cts → operation-types-DIazgS2d.d.cts} +122 -118
- package/dist/sqlite.cjs +645 -242
- package/dist/sqlite.cjs.map +1 -1
- package/dist/sqlite.d.cts +2 -2
- package/dist/sqlite.d.ts +2 -2
- package/dist/sqlite.js +1 -1
- package/dist/{state-DHl6j33x.d.cts → state-AUnz7TG7.d.cts} +3 -1
- package/dist/{state-DHl6j33x.d.ts → state-AUnz7TG7.d.ts} +3 -1
- package/dist/{store-Dlol1q1s.d.ts → store-BMN8kd0c.d.ts} +1 -1
- package/dist/{store-1zgwa--h.d.cts → store-Cz75STRl.d.cts} +1 -1
- package/package.json +5 -5
- package/dist/chunk-FSQYZO66.js.map +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/session/state.ts","../src/session/operation-protocol.ts","../src/data/gas-benchmarks.json","../src/gas-estimation.ts","../src/session/protocol-events.ts","../src/session/receipt-logs.ts","../src/session/discovery.ts","../src/session/DisclosureVerifier.ts","../src/session/store.ts","../src/session/operation-execution.ts","../src/session/proof-integrity.ts","../src/session/operation-preview.ts","../src/session/Operation.ts","../src/session/operation-confirmation.ts","../src/session/aggregate-receipt.ts","../src/session/credit-values.ts","../src/session/membership.ts","../src/session/receipts.ts","../src/session/WalletSession.ts","../src/session/transaction-preparation.ts","../src/session/prepare-common.ts","../src/session/selection.ts","../src/session/prepare-credit.ts","../src/session/refresh.ts","../src/session/WalletUpdater.ts","../src/session/inventory.ts","../src/session/codec.ts","../src/session/index.ts"],"sourcesContent":["import type { CreditDeliveryState, Note } from \"@invisi-labs/core\";\nimport type { Hex } from \"@invisi-labs/prover\";\n\nexport interface WalletScope {\n namespace: string;\n chainId: bigint;\n protocolAddress: Hex;\n walletIdentity: Hex;\n}\n\nexport function creditReservationKey(commitment: string): string {\n return \"credit:\" + commitment;\n}\n\nexport interface Checkpoint {\n number: bigint;\n hash: Hex;\n}\n\nexport type SpentState = \"unknown\" | \"unspent\" | \"spent\";\n\nexport interface ReceiptPosition {\n commitment: Hex;\n treeId: bigint;\n leafIndex: number;\n blockNumber: bigint;\n blockHash: Hex;\n transactionHash?: Hex;\n}\n\nexport interface StoredNote extends ReceiptPosition {\n note: Note;\n spent: SpentState;\n checkedThrough?: Checkpoint;\n}\n\nexport interface StoredCredit extends ReceiptPosition {\n receivingKeySource?: { kind: \"draw\" | \"top-up\"; commitment: Hex };\n state: CreditDeliveryState;\n role: \"owner\" | \"spender\";\n spent: SpentState;\n checkedThrough?: Checkpoint;\n}\n\nexport type OperationStatus =\n | \"prepared\"\n | \"authorized\"\n | \"proved\"\n | \"ready\"\n | \"submitted\"\n | \"confirmed\"\n | \"failed\"\n | \"expired\"\n | \"uncertain\"\n | \"reorged\";\n\nexport interface OperationRecord {\n id: string;\n status: OperationStatus;\n inputs: string[];\n deadline?: bigint;\n transactionHash?: Hex;\n payload?: unknown;\n}\n\nexport interface WalletState {\n schemaVersion: 1;\n scope: WalletScope;\n revision: number;\n notes: Record<string, StoredNote>;\n credits: Record<string, StoredCredit>;\n reservations: Record<string, string>;\n operations: Record<string, OperationRecord>;\n /** Last canonical block observed while processing known candidates; never a completeness claim. */\n observedThrough?: Checkpoint;\n invalidated?: string;\n}\n\nexport interface WalletStore {\n readonly persistent: boolean;\n readSnapshot(scope: WalletScope): Promise<WalletState>;\n /** Pure synchronous mutation; an optimistic persistent adapter may retry it. */\n transaction<T>(scope: WalletScope, action: (draft: WalletState) => T): Promise<T>;\n}\n\nexport interface BalanceSnapshot {\n tokenAddress: Hex;\n scope: WalletScope;\n checkedThrough: Checkpoint | null;\n confirmedKnown: bigint;\n reserved: bigint;\n availableKnown: bigint | null;\n invalidated: boolean;\n}\n\nexport function walletBalance(state: WalletState, tokenAddress: Hex): BalanceSnapshot {\n let confirmedKnown = 0n;\n let reserved = 0n;\n let unknown = !!state.invalidated;\n const records = Object.values(state.notes).filter(\n (r) => r.note.tokenAddress === BigInt(tokenAddress)\n );\n const points = records.map((record) => record.checkedThrough);\n let checkedThrough: Checkpoint | null = null;\n if (\n records.length &&\n points.every((point) => point !== undefined) &&\n records.every((record) => record.spent !== \"unknown\")\n ) {\n checkedThrough = points.reduce((earliest, point) =>\n point!.number < earliest!.number ? point : earliest\n )!;\n } else if (!records.length) {\n checkedThrough = state.observedThrough ?? null;\n }\n if (!records.length && !checkedThrough) {\n unknown = true;\n }\n for (const [id, record] of Object.entries(state.notes)) {\n if (record.note.tokenAddress !== BigInt(tokenAddress)) continue;\n if (record.spent !== \"spent\") {\n confirmedKnown += record.note.amount;\n if (record.spent === \"unknown\") {\n unknown = true;\n }\n if (state.reservations[id]) {\n reserved += record.note.amount;\n }\n }\n }\n return {\n tokenAddress,\n scope: { ...state.scope },\n checkedThrough: state.invalidated ? null : checkedThrough ? { ...checkedThrough } : null,\n confirmedKnown,\n reserved,\n availableKnown: unknown ? null : confirmedKnown - reserved,\n invalidated: !!state.invalidated,\n };\n}\n\n/** Balances are listed by asset; amounts from different tokens are never added. */\nexport function walletBalances(state: WalletState): BalanceSnapshot[] {\n const tokens = new Set(\n Object.values(state.notes).map(\n (r) => `0x${r.note.tokenAddress.toString(16).padStart(40, \"0\")}` as Hex\n )\n );\n return [...tokens].sort().map((token) => walletBalance(state, token));\n}\n","import type { Hex, InputSource } from \"@invisi-labs/protocol/contracts\";\n\nimport { creditPeriods, type AuthorizedStatement, type WalletOperation } from \"@invisi-labs/core\";\nimport {\n WitnessBuilder,\n buildCancelCreditCalldata,\n buildCreateCreditCalldata,\n buildCreditDrawCalldata,\n buildShieldCalldata,\n buildTopUpCreditCalldata,\n buildTransactCalldata,\n cancelCreditPublicInputs,\n createCreditPublicInputs,\n creditDrawPublicInputs,\n encodeAggregateFundingTypedData,\n encodeCreateCreditFundingTypedData,\n encodeShieldFundingTypedData,\n encodeTopUpCreditFundingTypedData,\n encodeTransactFundingTypedData,\n topUpCreditPublicInputs,\n transactUserPublicInputs,\n type TokenProtocol,\n type TransactionCall,\n} from \"@invisi-labs/protocol\";\nimport type { ProofBundle, ProofStatement, ProvingRequest } from \"@invisi-labs/prover\";\n\nimport type { OperationPlan, SavedOperation } from \"./operation-types\";\nimport { creditReservationKey } from \"./state\";\n\nexport function requiresAuthorization(plan: OperationPlan): boolean {\n if (plan.kind === \"sweep\") {\n if (\n plan.credit ||\n !plan.inputs.length ||\n plan.outputs.length ||\n !plan.params ||\n plan.params.outputCommitments.length ||\n (plan.funding.amount ?? 0n) !== 0n ||\n BigInt(plan.params.withdrawalAddress) !== BigInt(plan.scope.walletIdentity) ||\n plan.params.withdrawalAmount !==\n plan.inputs.reduce((sum, input) => sum + input.note.amount, 0n) ||\n plan.inputs.some((input) => input.note.walletIdentity !== plan.scope.walletIdentity)\n )\n throw new Error(\"invalid owner-only sweep plan\");\n return false;\n }\n return !!plan.credit || plan.inputs.length > 0;\n}\n\nexport function inputFacts(\n plan: OperationPlan\n): Array<{ key: string; reservationKey: string; nullifier: Hex; kind: \"notes\" | \"credits\" }> {\n const credit = plan.credit;\n const noteNullifiers = plan.params?.nullifiers ?? credit?.creation?.nullifiers ?? [];\n let creditNullifiers: readonly Hex[] = [];\n\n if (credit?.draw) {\n creditNullifiers = credit.draw.nullifiers;\n } else if (credit?.topUp) {\n creditNullifiers = [credit.topUp.creditNullifier];\n } else if (credit?.cancel) {\n creditNullifiers = [credit.cancel.nullifier];\n }\n\n if (\n noteNullifiers.length !== plan.inputs.length ||\n creditNullifiers.length !== (credit?.inputs.length ?? 0)\n ) {\n throw new Error(\"operation input statement count mismatch\");\n }\n\n return [\n ...plan.inputs.map((input, index) => ({\n key: input.commitment,\n reservationKey: input.commitment,\n nullifier: noteNullifiers[index]!,\n kind: \"notes\" as const,\n })),\n ...(credit?.inputs ?? []).map((input, index) => ({\n key: input.commitment + \":\" + input.role,\n reservationKey: creditReservationKey(input.commitment),\n nullifier: creditNullifiers[index]!,\n kind: \"credits\" as const,\n })),\n ];\n}\n\nexport function operationSources(plan: OperationPlan): readonly InputSource[] {\n const noteSources = plan.params?.sources;\n if (noteSources != null) return noteSources;\n\n const credit = plan.credit;\n if (credit?.topUp) {\n return [...credit.topUp.creation.sources, credit.topUp.creditSource];\n }\n if (credit?.creation) return credit.creation.sources;\n if (credit?.draw) return credit.draw.sources;\n if (credit?.cancel) return [credit.cancel.source];\n return [];\n}\n\nexport function statement(plan: OperationPlan): ProofStatement {\n if (!plan.statement) throw new Error(\"operation has no proof statement\");\n\n const credit = plan.credit;\n let words: Hex[];\n if (credit?.topUp) {\n words = topUpCreditPublicInputs(\n plan.context,\n credit.topUp,\n credit.deliveries,\n plan.funding\n );\n } else if (credit?.creation) {\n words = createCreditPublicInputs(\n plan.context,\n credit.creation,\n credit.deliveries,\n plan.funding\n );\n } else if (credit?.draw) {\n words = creditDrawPublicInputs(plan.context, credit.draw, credit.deliveries);\n } else if (credit?.cancel) {\n words = cancelCreditPublicInputs(plan.context, credit.cancel);\n } else {\n words = transactUserPublicInputs(\n plan.context,\n plan.params!,\n plan.outputs.map((output) => output.delivery),\n plan.funding\n );\n }\n\n const result = WitnessBuilder.statement(\n plan.statement.circuitName,\n words,\n plan.statement.target\n );\n if (JSON.stringify(result) !== JSON.stringify(plan.statement)) {\n throw new Error(\"frozen operation statement changed\");\n }\n return result;\n}\n\nexport function authorizationRequest(plan: OperationPlan) {\n let operation: WalletOperation = \"transact\";\n if (plan.kind === \"draw-credit\") {\n operation = \"credit-draw\";\n } else if (\n plan.kind === \"create-credit\" ||\n plan.kind === \"top-up-credit\" ||\n plan.kind === \"cancel-credit\"\n ) {\n operation = plan.kind;\n }\n\n return {\n context: {\n chainId: plan.context.chainId,\n protocolAddress: BigInt(plan.context.protocolAddress),\n },\n operation,\n capacity: plan.capacity!,\n words: statement(plan).expectedPublicInputs.slice(0, -2).map(BigInt),\n };\n}\n\nexport async function witnessFor(\n protocol: TokenProtocol,\n plan: OperationPlan,\n authorization?: AuthorizedStatement\n): Promise<ProvingRequest> {\n const builder = new WitnessBuilder(protocol);\n const credit = plan.credit;\n\n if (credit) {\n if (!authorization) throw new Error(\"private Credit wallet authorization required\");\n\n if (credit.topUp) {\n return builder.topUpCredit({\n params: credit.topUp,\n deliveries: credit.deliveries,\n funding: plan.funding,\n inputs: plan.inputs,\n state: credit.outputs[0]!.state,\n ...(plan.outputs[0] ? { change: plan.outputs[0].note } : {}),\n previous: credit.inputs[0]!,\n authorization,\n });\n }\n if (credit.creation) {\n return builder.createCredit({\n params: credit.creation,\n deliveries: credit.deliveries,\n funding: plan.funding,\n inputs: plan.inputs,\n state: credit.outputs[0]!.state,\n ...(plan.outputs[0] ? { change: plan.outputs[0].note } : {}),\n authorization,\n });\n }\n if (credit.draw) {\n return builder.drawCredit({\n timestamp: plan.preparedAt.timestamp,\n params: credit.draw,\n deliveries: credit.deliveries,\n inputs: credit.inputs,\n amounts: credit.amounts!,\n authorization,\n });\n }\n if (credit.cancel) {\n return builder.cancelCredit({\n params: credit.cancel,\n input: credit.inputs[0]!,\n authorization,\n });\n }\n throw new Error(\"unsupported Credit operation\");\n }\n\n return builder.transact({\n params: plan.params!,\n deliveries: plan.outputs.map((output) => output.delivery),\n funding: plan.funding,\n inputs: plan.inputs,\n outputs: plan.outputs.map((output) => output.note),\n ...(authorization ? { authorization } : {}),\n target: plan.statement!.target,\n });\n}\n\nexport async function encodeOperation(saved: SavedOperation): Promise<TransactionCall> {\n const plan = saved.plan;\n const credit = plan.credit;\n const caller = plan.fundingMode === \"caller\" ? plan.funding.payer : undefined;\n const common = { context: plan.context, proof: saved.proof?.proofHex ?? (\"0x\" as Hex) };\n const funded = { ...common, funding: plan.funding, ...(caller ? { caller } : {}) };\n\n let encoded: { data: Hex };\n if (credit?.topUp) {\n encoded = buildTopUpCreditCalldata({\n ...funded,\n params: credit.topUp,\n deliveries: credit.deliveries,\n });\n } else if (credit?.creation) {\n encoded = buildCreateCreditCalldata({\n ...funded,\n params: credit.creation,\n deliveries: credit.deliveries,\n });\n } else if (credit?.draw) {\n encoded = buildCreditDrawCalldata({\n ...common,\n params: credit.draw,\n deliveries: credit.deliveries,\n });\n } else if (credit?.cancel) {\n encoded = buildCancelCreditCalldata({ ...common, params: credit.cancel });\n } else if (plan.kind === \"shield\") {\n encoded = await buildShieldCalldata({\n ...funded,\n params: plan.shieldParams!,\n outputs: plan.shieldOutputs!,\n deliveries: plan.outputs.map((output) => output.delivery),\n });\n } else {\n encoded = buildTransactCalldata({\n ...funded,\n params: plan.params!,\n deliveries: plan.outputs.map((output) => output.delivery),\n });\n }\n\n return { to: plan.context.protocolAddress, data: encoded.data, value: 0n };\n}\n\nexport async function fundingTypedData(saved: SavedOperation) {\n const plan = saved.plan;\n const credit = plan.credit;\n\n if (credit?.topUp) {\n return encodeTopUpCreditFundingTypedData(\n plan.context,\n credit.topUp,\n credit.deliveries,\n plan.funding\n );\n }\n if (credit?.creation) {\n return encodeCreateCreditFundingTypedData(\n plan.context,\n credit.creation,\n credit.deliveries,\n plan.funding\n );\n }\n if (plan.kind === \"shield\") {\n return encodeShieldFundingTypedData({\n context: plan.context,\n params: plan.shieldParams!,\n outputs: plan.shieldOutputs!,\n deliveries: plan.outputs.map((output) => output.delivery),\n funding: plan.funding,\n });\n }\n if (plan.statement?.target === \"noir-recursive\") {\n return encodeAggregateFundingTypedData(plan.context, {\n params: plan.params!,\n deliveries: plan.outputs.map((output) => output.delivery),\n funding: plan.funding,\n });\n }\n return encodeTransactFundingTypedData(\n plan.context,\n saved.proof!.proofHex,\n plan.params!,\n plan.outputs.map((output) => output.delivery),\n plan.funding\n );\n}\n\n/** Whitelist the public proof fields; a custom local backend cannot accidentally export its witness. */\nexport function publicProof(bundle: ProofBundle): ProofBundle {\n return {\n formatVersion: bundle.formatVersion,\n circuitName: bundle.circuitName,\n target: bundle.target,\n bbVersion: bundle.bbVersion,\n artifactSha256: bundle.artifactSha256,\n vkSha256: bundle.vkSha256,\n proofHex: bundle.proofHex,\n proofSha256: bundle.proofSha256,\n publicInputs: [...bundle.publicInputs],\n };\n}\n\nexport function operationExpired(plan: OperationPlan, now: bigint): boolean {\n if (now > plan.deadline) return true;\n\n const credit = plan.credit;\n if (credit?.topUp && now >= credit.topUp.previousExpiry) return true;\n if (credit?.creation && now >= credit.creation.expiry) return true;\n if (credit?.draw) {\n if (credit.draw.expiries.some((expiry) => now >= expiry)) return true;\n const prepared = creditPeriods(plan.preparedAt.timestamp),\n current = creditPeriods(now);\n if (\n prepared.currentDay !== current.currentDay ||\n prepared.currentMonth !== current.currentMonth\n )\n return true;\n }\n return false;\n}\n","[\n {\n \"formatVersion\": 1,\n \"id\": \"protocol-42f2546-621cbef5f84a-prague-credit-real\",\n \"deployment\": {\n \"chainId\": \"31337\",\n \"protocolAddress\": \"0xEeD9be753bccbCB21463C49f0c56cC0E48bEcf3c\",\n \"runtimeCodeHash\": \"0x80228a2080d224b4481fc5df24fe8ce080d4536c663b13ec7829ecf0ef46abbd\",\n \"tokenAddress\": \"0x99bbA657f2BbC93c02D617f8bA121cB8Fc104Acf\"\n },\n \"source\": {\n \"protocolCommit\": \"42f2546b62312e4c11e21b8e6b2ff6f72187d6a6\",\n \"measuredAt\": \"2026-10-29T10:56:24.758Z\",\n \"chain\": \"Anvil 31337\",\n \"hardfork\": \"prague\",\n \"token\": \"MockERC20\",\n \"verifier\": \"real\",\n \"fingerprints\": {\n \"protocolSourceSha256\": \"621cbef5f84a133ca96674a2dba39b21b5f9fbc022977d4d2ab296d9d6e685e0\",\n \"dirtyDiffSha256\": \"eb2c41cca3802a47196181648397ec6f47fb2ba0efa8aa3800508d8d255fae3f\",\n \"compiledArtifactsSha256\": \"c0e658d74fe49caeebf5ef9deadc1751d9e48add690f7e9ab478de7a00dab7e4\",\n \"creditManifestSha256\": \"da819378af60471905cc902a43e464b58159e0c75bd46fb804ea9d34d8aa7ef6\",\n \"userManifestSha256\": \"067b6c50e4bc4d9c19dd29f25352db88d189a5f49aed0ed603daa70760e699df\",\n \"sdkSourceSha256\": \"37e1f82a447db741f46e1490b866ddf85718eab42c33d369cf5f5d2ec3a25c78\"\n },\n \"toolchain\": {\n \"solidity\": \"0.8.38\",\n \"barretenberg\": \"6.0.0\",\n \"noir\": \"1.0.0-rc.6\",\n \"evmVersion\": \"prague\",\n \"optimizerRuns\": 200,\n \"anvil\": \"anvil Version: 1.8.6\"\n },\n \"blockGasLimit\": \"500000000\",\n \"runtimeContracts\": {\n \"transact_user_slots14_direct_Verifier\": {\n \"address\": \"0x5FbDB2315678afecb367f032d93F642f64180aa3\",\n \"runtimeCodeHash\": \"0xedab185b2b9fc7d98660db2cdc99fe30b9d1341dfe568172a1626e322d208f7e\"\n },\n \"transact_user_slots14-adapter\": {\n \"address\": \"0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512\",\n \"runtimeCodeHash\": \"0xe222cd9c142bc2b13e083e6fe66ea76c0e1e9a194715bfa57082b625c55d867f\"\n },\n \"transact_user_slots56_direct_Verifier\": {\n \"address\": \"0x9fE46736679d2D9a65F0992F2272dE9f3c7fa6e0\",\n \"runtimeCodeHash\": \"0x8913eb7060f38234aca199c4a1007892f68e703de48b588c436b24faaeb23a53\"\n },\n \"transact_user_slots56-adapter\": {\n \"address\": \"0xCf7Ed3AccA5a467e9e704C703E8D87F634fB0Fc9\",\n \"runtimeCodeHash\": \"0x97c416d190da0b9b8111a5ee17367e8a702ba7884019bf724155ae629a783477\"\n },\n \"transact_user_slots112_direct_Verifier\": {\n \"address\": \"0xDc64a140Aa3E981100a9becA4E685f962f0cF6C9\",\n \"runtimeCodeHash\": \"0x501a4791ff0c0a96465ab5e0d42d0ce763bbbb7fd8aebe21929de4d460e1b42c\"\n },\n \"transact_user_slots112-adapter\": {\n \"address\": \"0x5FC8d32690cc91D4c39d9d3abcBD16989F875707\",\n \"runtimeCodeHash\": \"0xf22ed8ea34a4011650a41c1b9f664b5259ea5a8d66a82d706dab9611a38c109f\"\n },\n \"transact_user_slots168_direct_Verifier\": {\n \"address\": \"0x0165878A594ca255338adfa4d48449f69242Eb8F\",\n \"runtimeCodeHash\": \"0xc22acdfa6f3e278ae46d194a1c50b905e4815fd7b61e39edb52334570670fdce\"\n },\n \"transact_user_slots168-adapter\": {\n \"address\": \"0xa513E6E4b8f2a923D98304ec87F64353C4D5C853\",\n \"runtimeCodeHash\": \"0x05a318f54d93440a501b6fc6be88e4e76e89d72f1be8333553cb4a61f4f9a0d7\"\n },\n \"transact_aggregate_14_4_Verifier\": {\n \"address\": \"0x2279B7A0a67DB372996a5FaB50D91eAA73d2eBe6\",\n \"runtimeCodeHash\": \"0x7a6f2bafe4c61a72a99a195e188f2f4a32900c0cc63cc132e33881d8199fd446\"\n },\n \"transact_aggregate_14_4-adapter\": {\n \"address\": \"0x8A791620dd6260079BF849Dc5567aDC3F2FdC318\",\n \"runtimeCodeHash\": \"0x15877da9940d5b8dd4868ffa92ded3b93d6092c3963ba9e18b50f1ea15d89898\"\n },\n \"transact_aggregate_14_8_Verifier\": {\n \"address\": \"0x610178dA211FEF7D417bC0e6FeD39F05609AD788\",\n \"runtimeCodeHash\": \"0x5667d16b39973813a499375f6885a3082d7bfcd6e3c0f3548d7de3131cd285f3\"\n },\n \"transact_aggregate_14_8-adapter\": {\n \"address\": \"0xB7f8BC63BbcaD18155201308C8f3540b07f84F5e\",\n \"runtimeCodeHash\": \"0x9d1a93c78edf7e81b4b6da10ab209b3fb009ed8355594f670559a67842d88cfc\"\n },\n \"transact_aggregate_14_12_Verifier\": {\n \"address\": \"0xA51c1fc2f0D1a1b8494Ed1FE312d7C3a78Ed91C0\",\n \"runtimeCodeHash\": \"0xa4e67840a47182d4011d577981c2477bb4ab2bc36845bb136375f19f12c0800b\"\n },\n \"transact_aggregate_14_12-adapter\": {\n \"address\": \"0x0DCd1Bf9A1b36cE34237eEaFef220932846BCD82\",\n \"runtimeCodeHash\": \"0x96a6e170aafc0af9d46232ba00206d950bba85e65962d43501bafb6d7f9fe61d\"\n },\n \"create_credit_direct_Verifier\": {\n \"address\": \"0x9A676e781A523b5d0C0e43731313A708CB607508\",\n \"runtimeCodeHash\": \"0xbdc6450bf9ba01001082f345b8bd21006a4f75274f32d026cf6e14270e6d56e6\"\n },\n \"create_credit-adapter\": {\n \"address\": \"0x0B306BF915C4d645ff596e518fAf3F9669b97016\",\n \"runtimeCodeHash\": \"0x3a95a22b32aef18ce053a7110056bbfbf13bb0b07932a49765ebb136528a4707\"\n },\n \"credit_draw_slots1_direct_Verifier\": {\n \"address\": \"0x959922bE3CAee4b8Cd9a407cc3ac1C251C2007B1\",\n \"runtimeCodeHash\": \"0x47be80e72c3a22ea044638f6004de8c3a0264d5a0d17189c01153cdabfd7bab6\"\n },\n \"credit_draw_slots1-adapter\": {\n \"address\": \"0x9A9f2CCfdE556A7E9Ff0848998Aa4a0CFD8863AE\",\n \"runtimeCodeHash\": \"0x28f25aeb97659fb9253ae67f2ff284789710bc59e1ed077ffc7a07b800cbfcc1\"\n },\n \"credit_draw_slots12_direct_Verifier\": {\n \"address\": \"0x68B1D87F95878fE05B998F19b66F4baba5De1aed\",\n \"runtimeCodeHash\": \"0x244d9ba22f5c736c2a5c42c466701e2a8ba7ae8108665133541026ea45d56e04\"\n },\n \"credit_draw_slots12-adapter\": {\n \"address\": \"0x3Aa5ebB10DC797CAC828524e59A333d0A371443c\",\n \"runtimeCodeHash\": \"0x60d48a35279d318a0621e5f59b293f44074463b8002ce180b7e6a31b995ac195\"\n },\n \"credit_draw_slots50_direct_Verifier\": {\n \"address\": \"0xc6e7DF5E7b4f2A278906862b61205850344D4e7d\",\n \"runtimeCodeHash\": \"0x2ad5eb64bcfae34ef04111dd8f9c1ffc5fc8aa6c1ad3a65d8da78233f3390660\"\n },\n \"credit_draw_slots50-adapter\": {\n \"address\": \"0x59b670e9fA9D0A427751Af201D676719a970857b\",\n \"runtimeCodeHash\": \"0x468966de20e5c71cf7b6f3cda7fa7a76b5d80dc5ddf82119f441ea6a7c6c1e70\"\n },\n \"credit_draw_slots120_direct_Verifier\": {\n \"address\": \"0x4ed7c70F96B99c776995fB64377f0d4aB3B0e1C1\",\n \"runtimeCodeHash\": \"0x523b6d211618bbd33d708f8198b9f3daafc10e2fa7a6a857db5795ed748a24e4\"\n },\n \"credit_draw_slots120-adapter\": {\n \"address\": \"0x322813Fd9A801c5507c9de605d63CEA4f2CE6c44\",\n \"runtimeCodeHash\": \"0xa91d585ce6037e703efb914205bf193881fde4f470d2fc63b615699b56175239\"\n },\n \"credit_cancel_direct_Verifier\": {\n \"address\": \"0xa85233C63b9Ee964Add6F2cffe00Fd84eb32338f\",\n \"runtimeCodeHash\": \"0x182e86861a73f712071e40a6b8497b80c58c383eaa799182e7a50e39196399fd\"\n },\n \"credit_cancel-adapter\": {\n \"address\": \"0x4A679253410272dd5232B3Ff7cF5dbB88f295319\",\n \"runtimeCodeHash\": \"0xea1f0f22445eed5a92c8d6990219059b7e241ad66c55a6d9ddef22a94a0f015f\"\n },\n \"credit_top_up_direct_Verifier\": {\n \"address\": \"0x7a2088a1bFc9d81c55368AE168C2C02570cB814F\",\n \"runtimeCodeHash\": \"0xeeb42a2b6377ab305b713d1caf4ca96edb302c6d1e1007239e5c70091819c266\"\n },\n \"credit_top_up-adapter\": {\n \"address\": \"0x09635F643e140090A9A8Dcd712eD6285858ceBef\",\n \"runtimeCodeHash\": \"0xbcf35a1d0e6c16dd01b09f944889aa5917d358d986fe399a0343d06bbdedaa61\"\n },\n \"PrivateTransferVerifierRegistry\": {\n \"address\": \"0xc5a5C42992dECbae36851359345FE25997F5C42d\",\n \"runtimeCodeHash\": \"0x678684af147cb42c872184b6e22c8439748139ae0c5885032941ab8832fcb142\"\n },\n \"CrossTreeVerifierRegistry\": {\n \"address\": \"0x67d269191c92Caf3cD7723F116c85e6E9bf55933\",\n \"runtimeCodeHash\": \"0xa5ee16fc7ed9f982450e42a48365a93bfca784fa884adcb8695b557e921cb93b\"\n },\n \"DualVerifierRouter\": {\n \"address\": \"0xE6E340D132b5f46d1e472DebcD681B2aBc16e57E\",\n \"runtimeCodeHash\": \"0xcc094ed6f1bcc9270c597f62b817e4fc0a54770f373320133c2836e5b07ef2cc\"\n },\n \"AtomicBatchOutputLib\": {\n \"address\": \"0xc3e53F4d16Ae77Db1c982e75a937B9f60FE63690\",\n \"runtimeCodeHash\": \"0x7c138c13e40b3ad0fee3b319d6c1580a21855cb5ecdda92571d530509d9b7316\"\n },\n \"FundingLib\": {\n \"address\": \"0x84eA74d481Ee0A5332c457a4d796187F6Ba67fEB\",\n \"runtimeCodeHash\": \"0x898d13d6ec4123df85f21ee0f98678dcd9f9b9a60134f88e35c1ef1aaa0a45f9\"\n },\n \"PrivateTransferLib\": {\n \"address\": \"0x9E545E3C0baAB3E08CdfD552C960A1050f373042\",\n \"runtimeCodeHash\": \"0xfb18f2dd0a39af1b99ae35c25e2746cb5bc85c205e041db5f440671d84c82e5e\"\n },\n \"CrossTreeTransferLib\": {\n \"address\": \"0xa82fF9aFd8f496c3d6ac40E2a0F282E47488CFc9\",\n \"runtimeCodeHash\": \"0x7b33a08f2feb9da462b951c95482cb2909796a85c0fde7cc9a6b65ff8b7ff253\"\n },\n \"AggregateTransferLib\": {\n \"address\": \"0x1613beB3B2C4f22Ee086B2b38C1476A3cE7f78E8\",\n \"runtimeCodeHash\": \"0xb3b4bd3a428f5c35712a57180f07b2249774d399ca87d4494929148ea26c5b99\"\n },\n \"CreateCreditLib\": {\n \"address\": \"0x851356ae760d987E095750cCeb3bC6014560891C\",\n \"runtimeCodeHash\": \"0xe37a4b7c129c4fba5615d25ed8b7e898e64a306c68f7e599ade911db98fe881c\"\n },\n \"CreditLifecycleLib\": {\n \"address\": \"0xf5059a5D33d5853360D16C683c16e67980206f36\",\n \"runtimeCodeHash\": \"0xf87a2227680efa7070071516587793e2e847c172b83261b8983c826f8a8c79bb\"\n },\n \"ShieldLib\": {\n \"address\": \"0x95401dc811bb5740090279Ba06cfA8fcF6113778\",\n \"runtimeCodeHash\": \"0x371e57d8d324e44445a4ec30303b89a8bc98bbdbd03aeaa80faf0f821a65451d\"\n },\n \"InvisiFactory\": {\n \"address\": \"0x998abeb3E57409262aE5b751f60747921B33613E\",\n \"runtimeCodeHash\": \"0xc56e5a0b71f4a1f63576a6663efb62b17c0d7520b6885a8d3483a356e12edf9b\"\n },\n \"InvisiAddressRegistry\": {\n \"address\": \"0x70e0bA845a1A0F2DA3359C97E0285013525FFC49\",\n \"runtimeCodeHash\": \"0x007da3f4e888366ba0eed52cd511c4a369359291387ad19ca37e89eb395fce30\"\n },\n \"InvisiProtocol\": {\n \"address\": \"0xEeD9be753bccbCB21463C49f0c56cC0E48bEcf3c\",\n \"runtimeCodeHash\": \"0x80228a2080d224b4481fc5df24fe8ce080d4536c663b13ec7829ecf0ef46abbd\"\n },\n \"MockERC20\": {\n \"address\": \"0x99bbA657f2BbC93c02D617f8bA121cB8Fc104Acf\",\n \"runtimeCodeHash\": \"0xf7f676b5c54f6e94f82f0de65a0117468a0d915e8a79d150e74f76bd6d7f708b\"\n }\n },\n \"assumptions\": [\n \"normal CREATE/Factory deployment and fresh registry; EIP170/EIP3860 unchanged; no code/storage injection\",\n \"Solidity0.8.38 optimizer200 Prague; pinned BB6.0.0 real verifiers; every native proof independently verified\",\n \"one physical source tree and 123 existing leaves shared by every sample; top-up has two authenticated source groups; no rollover or screener\",\n \"funding/approvals/121 genuine Credit seeds/usage-seed draw/payout reset excluded from business gas\",\n \"each round restores identical token balances, exact caller allowance100, note cursor, nullifiers and baseline; spender payout starts zero\",\n \"complete receipt.gasUsed is measured, including verifier/calldata/logging/output insertion; memo0\",\n \"Prague local block gas limit500000000; measured transactions may be unmineable under lower network transaction/block limits\",\n \"observed three-sample ranges are neither a confidence interval nor a recommended transaction gas limit\"\n ]\n },\n \"measurements\": [\n {\n \"id\": \"create-credit-caller-0x0\",\n \"shape\": {\n \"kind\": \"create-credit\",\n \"target\": \"evm\",\n \"capacity\": 10,\n \"noteInputs\": 0,\n \"noteOutputs\": 0,\n \"sourceTrees\": 0,\n \"creditInputs\": 0,\n \"creditOutputs\": 1,\n \"creditRemainders\": 0,\n \"funding\": \"caller\",\n \"permit\": false,\n \"deliveryBytes\": 1132\n },\n \"circuit\": {\n \"circuitName\": \"create_credit\",\n \"target\": \"evm\",\n \"artifactSha256\": \"3ed6cfdee4f5fd840f023580f76c208768777fea79737f2511377e5c55be0230\",\n \"vkSha256\": \"56f663c6053be0d158a271022d200c732597efd3a2e0be48fe94549d0b1795e0\"\n },\n \"samples\": [\n {\n \"gasUsed\": \"1574696\",\n \"transactionHash\": \"0x76112c532a1b5f24ad84fb83f91789ba4acd15ed9473ec9a0267cd5fe605448d\",\n \"blockNumber\": \"172\",\n \"blockHash\": \"0x0d91421e94947132a19f38ffdd76932c2d85add201de3d9189325ed3568125a7\",\n \"calldataBytes\": 11780\n },\n {\n \"gasUsed\": \"1574576\",\n \"transactionHash\": \"0x545f72d9d207329bfc69ef0d1e96470c614924d5e463d974cc001712bf619fd8\",\n \"blockNumber\": \"172\",\n \"blockHash\": \"0x2053f97a2b2f3cf66e14da0ab9c1d7bd462d2d4f3ef2b13021aefcddedb71cf8\",\n \"calldataBytes\": 11780\n },\n {\n \"gasUsed\": \"1574612\",\n \"transactionHash\": \"0x880ec0c666068d0756fba39947dc5b211aeebb31f41bd1e1e54856b090f65d34\",\n \"blockNumber\": \"172\",\n \"blockHash\": \"0xbb86ed21379a917e9688a3c90364ae8fbe1ba633ac068360e0a82bf4d3113b6d\",\n \"calldataBytes\": 11780\n }\n ]\n },\n {\n \"id\": \"create-credit-1x1\",\n \"shape\": {\n \"kind\": \"create-credit\",\n \"target\": \"evm\",\n \"capacity\": 10,\n \"noteInputs\": 1,\n \"noteOutputs\": 1,\n \"sourceTrees\": 1,\n \"creditInputs\": 0,\n \"creditOutputs\": 1,\n \"creditRemainders\": 0,\n \"funding\": \"none\",\n \"permit\": false,\n \"deliveryBytes\": 1360\n },\n \"circuit\": {\n \"circuitName\": \"create_credit\",\n \"target\": \"evm\",\n \"artifactSha256\": \"3ed6cfdee4f5fd840f023580f76c208768777fea79737f2511377e5c55be0230\",\n \"vkSha256\": \"56f663c6053be0d158a271022d200c732597efd3a2e0be48fe94549d0b1795e0\"\n },\n \"samples\": [\n {\n \"gasUsed\": \"1671641\",\n \"transactionHash\": \"0x24ca3f03681aeb188b48989d5eaf7dd264a8c32e828acd34ff1b44be74f17ea6\",\n \"blockNumber\": \"172\",\n \"blockHash\": \"0xcdac07aa5d3ec187874dc1fc9be65503235289c7036ebe455feaf5161db42bb5\",\n \"calldataBytes\": 12132\n },\n {\n \"gasUsed\": \"1671509\",\n \"transactionHash\": \"0x31a7f69ab02effa5fdd2e02bd02fb7e715a54786813261113fd7c07a0d3ef549\",\n \"blockNumber\": \"172\",\n \"blockHash\": \"0xc78ca874aa22cc6b8ea19e12a2806ba448a0f844345450d3fedc9841ea71c3a8\",\n \"calldataBytes\": 12132\n },\n {\n \"gasUsed\": \"1671485\",\n \"transactionHash\": \"0xc5a30116885dcac8b3631c15847544cfeb91c46bde44c3765ac0ce42e3259157\",\n \"blockNumber\": \"172\",\n \"blockHash\": \"0x4a2c90ff972da4d37408567062779762efbb5790d4784d03842ee2c926c8c894\",\n \"calldataBytes\": 12132\n }\n ]\n },\n {\n \"id\": \"draw-credit-1-partial\",\n \"shape\": {\n \"kind\": \"draw-credit\",\n \"target\": \"evm\",\n \"capacity\": 1,\n \"noteInputs\": 0,\n \"noteOutputs\": 0,\n \"sourceTrees\": 1,\n \"creditInputs\": 1,\n \"creditOutputs\": 1,\n \"creditRemainders\": 1,\n \"funding\": \"none\",\n \"permit\": false,\n \"deliveryBytes\": 1132\n },\n \"circuit\": {\n \"circuitName\": \"credit_draw_slots1\",\n \"target\": \"evm\",\n \"artifactSha256\": \"4542b227e0552b45c302f1dace21cadeba4962c96244e021472f1f7531cff8d1\",\n \"vkSha256\": \"43c051a2bedf9454c12e70b10156361e414944823ba23e80662c16c7ced0a2ce\"\n },\n \"samples\": [\n {\n \"gasUsed\": \"1588303\",\n \"transactionHash\": \"0x85c5180692470aa952aa13eb29ca0404d4f5b5192cb31475f90d03d78864895e\",\n \"blockNumber\": \"172\",\n \"blockHash\": \"0xfe4876c0a2ebf05385a46562bca693b6df80da731fd9651117593916015dc38c\",\n \"calldataBytes\": 11588\n },\n {\n \"gasUsed\": \"1588303\",\n \"transactionHash\": \"0x61684313840623187ca1205b4b07b43a08038448524ee1a028c7e14050032682\",\n \"blockNumber\": \"172\",\n \"blockHash\": \"0x9726d31c10e6516e38e3f63c84fc4b9a8a161486d35e0d8d07e6829261a88fe7\",\n \"calldataBytes\": 11588\n },\n {\n \"gasUsed\": \"1588255\",\n \"transactionHash\": \"0x0aa052fb8e356cc81dd73bcdae72f760937cd2e56bd4a3e8eb5878208b4f7596\",\n \"blockNumber\": \"172\",\n \"blockHash\": \"0x2c958cfba0627e18cd5cb47001b278628c305071929596e3335d770b92c1dc16\",\n \"calldataBytes\": 11588\n }\n ]\n },\n {\n \"id\": \"draw-credit-1-full\",\n \"shape\": {\n \"kind\": \"draw-credit\",\n \"target\": \"evm\",\n \"capacity\": 1,\n \"noteInputs\": 0,\n \"noteOutputs\": 0,\n \"sourceTrees\": 1,\n \"creditInputs\": 1,\n \"creditOutputs\": 0,\n \"creditRemainders\": 0,\n \"funding\": \"none\",\n \"permit\": false,\n \"deliveryBytes\": 0\n },\n \"circuit\": {\n \"circuitName\": \"credit_draw_slots1\",\n \"target\": \"evm\",\n \"artifactSha256\": \"4542b227e0552b45c302f1dace21cadeba4962c96244e021472f1f7531cff8d1\",\n \"vkSha256\": \"43c051a2bedf9454c12e70b10156361e414944823ba23e80662c16c7ced0a2ce\"\n },\n \"samples\": [\n {\n \"gasUsed\": \"1042812\",\n \"transactionHash\": \"0xb5d55729d975abdc92ca44c0b72e44a0d5841da8b23dc11b5bd31f46d88a341a\",\n \"blockNumber\": \"172\",\n \"blockHash\": \"0x8a6ddbe2f1630e1956485cac7984fb9cdc4fbb26b10522e158b38e2970ee4f3b\",\n \"calldataBytes\": 10372\n },\n {\n \"gasUsed\": \"1042824\",\n \"transactionHash\": \"0xf64f3186fbf94fcbd9fb12426c714b4a8425599e1a7e5677866fae3d6873b7ae\",\n \"blockNumber\": \"172\",\n \"blockHash\": \"0xd630c44d8ce96234ec836dd2178caac2a6d0bc2df5cf37df1534eb8896be48d3\",\n \"calldataBytes\": 10372\n },\n {\n \"gasUsed\": \"1042884\",\n \"transactionHash\": \"0xdf634e809b87603a62292ef046fa5e84715561fa76ef121c768303dd779568f1\",\n \"blockNumber\": \"172\",\n \"blockHash\": \"0x09cad4a799360bdf825c3ad70fe374b7fe2df802f8ee37ccb7f26ffc49aa2a3a\",\n \"calldataBytes\": 10372\n }\n ]\n },\n {\n \"id\": \"draw-credit-12-partial\",\n \"shape\": {\n \"kind\": \"draw-credit\",\n \"target\": \"evm\",\n \"capacity\": 12,\n \"noteInputs\": 0,\n \"noteOutputs\": 0,\n \"sourceTrees\": 1,\n \"creditInputs\": 12,\n \"creditOutputs\": 12,\n \"creditRemainders\": 12,\n \"funding\": \"none\",\n \"permit\": false,\n \"deliveryBytes\": 13584\n },\n \"circuit\": {\n \"circuitName\": \"credit_draw_slots12\",\n \"target\": \"evm\",\n \"artifactSha256\": \"dd72b0867fc3be7cd90de263bd2d0892075cb18eb4f6dd671b13111710f10369\",\n \"vkSha256\": \"5e31d771e6294993736078596d9c69f21fe7595eda50e3cce6d7406b65cf1443\"\n },\n \"samples\": [\n {\n \"gasUsed\": \"3102895\",\n \"transactionHash\": \"0x699ba81f296f4af397a8dfaf96adf14d00d0f7dd69c0b09608641fc9b99fc28f\",\n \"blockNumber\": \"172\",\n \"blockHash\": \"0x8d318f563f5563fa5c213617481089f75aab3a6e9d14818db107ac20a8c20ffb\",\n \"calldataBytes\": 30276\n },\n {\n \"gasUsed\": \"3102871\",\n \"transactionHash\": \"0xddfc1c6c505f6c54f4d9aabc96a02eb6b606182e8ad708a578eacd274d885dee\",\n \"blockNumber\": \"172\",\n \"blockHash\": \"0xcc7738fe329a608241615dc43b7d16e075eb62be202ea8aaf4ae27a5278bf438\",\n \"calldataBytes\": 30276\n },\n {\n \"gasUsed\": \"3103171\",\n \"transactionHash\": \"0x6efab6408d927e1877f1f6c33ecd285a128382f7d1dfe6e123927b035781c8aa\",\n \"blockNumber\": \"172\",\n \"blockHash\": \"0xcb4588df9ecdca0d353ccbd226e1d5d07f21e6dc93875e41cdd5f64568859f4d\",\n \"calldataBytes\": 30276\n }\n ]\n },\n {\n \"id\": \"draw-credit-12-full\",\n \"shape\": {\n \"kind\": \"draw-credit\",\n \"target\": \"evm\",\n \"capacity\": 12,\n \"noteInputs\": 0,\n \"noteOutputs\": 0,\n \"sourceTrees\": 1,\n \"creditInputs\": 12,\n \"creditOutputs\": 0,\n \"creditRemainders\": 0,\n \"funding\": \"none\",\n \"permit\": false,\n \"deliveryBytes\": 0\n },\n \"circuit\": {\n \"circuitName\": \"credit_draw_slots12\",\n \"target\": \"evm\",\n \"artifactSha256\": \"dd72b0867fc3be7cd90de263bd2d0892075cb18eb4f6dd671b13111710f10369\",\n \"vkSha256\": \"5e31d771e6294993736078596d9c69f21fe7595eda50e3cce6d7406b65cf1443\"\n },\n \"samples\": [\n {\n \"gasUsed\": \"1536675\",\n \"transactionHash\": \"0xc0d3eef8e6b0e90984d776a5e41bcdce1e0ca0bc6dc3a71616e4768e80c01546\",\n \"blockNumber\": \"172\",\n \"blockHash\": \"0x22dfac3d8e9913a6a1f2ff84faaece4ed59bfe1cb74e06a60131ff28cc6c2f9d\",\n \"calldataBytes\": 15684\n },\n {\n \"gasUsed\": \"1536675\",\n \"transactionHash\": \"0x9879d86a1eaa550a6a6afaeeb0f5f07745d5dcd9caa07b660d7fb512911dc67e\",\n \"blockNumber\": \"172\",\n \"blockHash\": \"0xf88ba9f1b7a0c627338a61bbabe1c650bdfcd7fa1c56433d6853f492135b753d\",\n \"calldataBytes\": 15684\n },\n {\n \"gasUsed\": \"1536711\",\n \"transactionHash\": \"0xbd8f75a021a8ce8dc1900bd2d84d723acc6a64018844050a5aa2f8712cf7fd6b\",\n \"blockNumber\": \"172\",\n \"blockHash\": \"0xa55b539c2ea4e10ce9a9ee8e6de9cf1daa97263b51f32cfef8342c100b663b0f\",\n \"calldataBytes\": 15684\n }\n ]\n },\n {\n \"id\": \"draw-credit-50-partial\",\n \"shape\": {\n \"kind\": \"draw-credit\",\n \"target\": \"evm\",\n \"capacity\": 50,\n \"noteInputs\": 0,\n \"noteOutputs\": 0,\n \"sourceTrees\": 1,\n \"creditInputs\": 50,\n \"creditOutputs\": 50,\n \"creditRemainders\": 50,\n \"funding\": \"none\",\n \"permit\": false,\n \"deliveryBytes\": 56600\n },\n \"circuit\": {\n \"circuitName\": \"credit_draw_slots50\",\n \"target\": \"evm\",\n \"artifactSha256\": \"09c7469866748b4c0c4bbf2b040844771948a170999f6dc7a38fe5c0ecda4054\",\n \"vkSha256\": \"7b613225b6f32a077011d4196c356e836d22dcd116efe687fde53144fbd8db9f\"\n },\n \"samples\": [\n {\n \"gasUsed\": \"8015473\",\n \"transactionHash\": \"0x5dcc0fa08abaf5212424ac6f3e2f3bb8a0bd333f90ef6e421f8d3fe370ca1acf\",\n \"blockNumber\": \"172\",\n \"blockHash\": \"0x3197c523dece3492226c5021f974e7c02db2e686265943d03a5550c6cb96a12e\",\n \"calldataBytes\": 94276\n },\n {\n \"gasUsed\": \"8015449\",\n \"transactionHash\": \"0x6a55f88551a45b3e118cde0607cfff1ef0b6ab15ad9472e838412d9ce714b42a\",\n \"blockNumber\": \"172\",\n \"blockHash\": \"0xea82c8962d45db8361bd67ed326806f21c511bd51550adc453d0c3e5cab3a7ae\",\n \"calldataBytes\": 94276\n },\n {\n \"gasUsed\": \"8015149\",\n \"transactionHash\": \"0x2cc8d474a92abe91f8025109a70cf1f9f081dbec43aa4a475ab9f33222cfc76b\",\n \"blockNumber\": \"172\",\n \"blockHash\": \"0x4398f419da699ccca33867852d4975b5c461a40bb01cd5241a0e6dcacaeb78b3\",\n \"calldataBytes\": 94276\n }\n ]\n },\n {\n \"id\": \"draw-credit-50-full\",\n \"shape\": {\n \"kind\": \"draw-credit\",\n \"target\": \"evm\",\n \"capacity\": 50,\n \"noteInputs\": 0,\n \"noteOutputs\": 0,\n \"sourceTrees\": 1,\n \"creditInputs\": 50,\n \"creditOutputs\": 0,\n \"creditRemainders\": 0,\n \"funding\": \"none\",\n \"permit\": false,\n \"deliveryBytes\": 0\n },\n \"circuit\": {\n \"circuitName\": \"credit_draw_slots50\",\n \"target\": \"evm\",\n \"artifactSha256\": \"09c7469866748b4c0c4bbf2b040844771948a170999f6dc7a38fe5c0ecda4054\",\n \"vkSha256\": \"7b613225b6f32a077011d4196c356e836d22dcd116efe687fde53144fbd8db9f\"\n },\n \"samples\": [\n {\n \"gasUsed\": \"3216708\",\n \"transactionHash\": \"0x16933368d26ea1d7fbe69027c700671df832ad308944eeff42e7c2da40297b06\",\n \"blockNumber\": \"172\",\n \"blockHash\": \"0x0739a6f4188b8bdeae7bd5460960086d04adfea993d07d65b2b3630ad01b8cab\",\n \"calldataBytes\": 33476\n },\n {\n \"gasUsed\": \"3216840\",\n \"transactionHash\": \"0x45dc15a62b1661f54e167cf13b9693770370c926a8a7af959da7354e9bb4aa6e\",\n \"blockNumber\": \"172\",\n \"blockHash\": \"0xf2e294db9af3b11814fed1dec358b8370ea28a99189211f883c9b0012349d677\",\n \"calldataBytes\": 33476\n },\n {\n \"gasUsed\": \"3216744\",\n \"transactionHash\": \"0x2c827753026ea421497534a01bcc2adaca866a7612f570dad3fcf18c660f8590\",\n \"blockNumber\": \"172\",\n \"blockHash\": \"0x3ccd465528ff22e6d1955670220df3565899a16dd683f71c83c9810f2df420b4\",\n \"calldataBytes\": 33476\n }\n ]\n },\n {\n \"id\": \"draw-credit-120-partial\",\n \"shape\": {\n \"kind\": \"draw-credit\",\n \"target\": \"evm\",\n \"capacity\": 120,\n \"noteInputs\": 0,\n \"noteOutputs\": 0,\n \"sourceTrees\": 1,\n \"creditInputs\": 120,\n \"creditOutputs\": 120,\n \"creditRemainders\": 120,\n \"funding\": \"none\",\n \"permit\": false,\n \"deliveryBytes\": 135840\n },\n \"circuit\": {\n \"circuitName\": \"credit_draw_slots120\",\n \"target\": \"evm\",\n \"artifactSha256\": \"6ccd0366a669c50fd5da875c3eae194fe8aa4c36d35a5f9ebfd64636ea599b48\",\n \"vkSha256\": \"d715848afc5c1ecdfcef5ed5026865abef5040a3bc232fd65330a5ffee8475fb\"\n },\n \"samples\": [\n {\n \"gasUsed\": \"17458512\",\n \"transactionHash\": \"0x84dd6bda5f3172a53e899051fd226dc5869edb796bd513a33e7f224bed13f4ae\",\n \"blockNumber\": \"172\",\n \"blockHash\": \"0xfca82de1e112b92319185d8c3f0115e0aa339d0247ea65970eb0d37ba958b08e\",\n \"calldataBytes\": 211140\n },\n {\n \"gasUsed\": \"17458224\",\n \"transactionHash\": \"0xae26838942cf8b5499d43cb5e74681ae87aec77890a8eabddd692ff83830e013\",\n \"blockNumber\": \"172\",\n \"blockHash\": \"0x3e513447e0cfdbb682a95b7a719b0d300ec46b0ee22b518eaae7fb082f6436e7\",\n \"calldataBytes\": 211140\n },\n {\n \"gasUsed\": \"17458524\",\n \"transactionHash\": \"0xeaa07e77fe958f4317e71b07ddb876482ae9c5172fd6d6cefaacc551dbbda7d5\",\n \"blockNumber\": \"172\",\n \"blockHash\": \"0x12b34c1fd2e15480276052842157c2a6355acdd43d7bd01ae7511c3f39e0ecfc\",\n \"calldataBytes\": 211140\n }\n ]\n },\n {\n \"id\": \"draw-credit-120-full\",\n \"shape\": {\n \"kind\": \"draw-credit\",\n \"target\": \"evm\",\n \"capacity\": 120,\n \"noteInputs\": 0,\n \"noteOutputs\": 0,\n \"sourceTrees\": 1,\n \"creditInputs\": 120,\n \"creditOutputs\": 0,\n \"creditRemainders\": 0,\n \"funding\": \"none\",\n \"permit\": false,\n \"deliveryBytes\": 0\n },\n \"circuit\": {\n \"circuitName\": \"credit_draw_slots120\",\n \"target\": \"evm\",\n \"artifactSha256\": \"6ccd0366a669c50fd5da875c3eae194fe8aa4c36d35a5f9ebfd64636ea599b48\",\n \"vkSha256\": \"d715848afc5c1ecdfcef5ed5026865abef5040a3bc232fd65330a5ffee8475fb\"\n },\n \"samples\": [\n {\n \"gasUsed\": \"6289576\",\n \"transactionHash\": \"0xbf11743f7edc5ed5ff334efc5e35634f45e48e4940d33ddd9c87d8fe444dafc5\",\n \"blockNumber\": \"172\",\n \"blockHash\": \"0x774de17971107b73cab2cd20f26b60665f55a37b0cc1147166babf16743e34d5\",\n \"calldataBytes\": 65220\n },\n {\n \"gasUsed\": \"6289768\",\n \"transactionHash\": \"0x651bb13e0645ee8a08657db627f1072f5e964ddaff44f70f829440ed68488dea\",\n \"blockNumber\": \"172\",\n \"blockHash\": \"0xa9795828565fb0ce65bda295073106b8bbdc110bb8317d269839d3db3e312d5b\",\n \"calldataBytes\": 65220\n },\n {\n \"gasUsed\": \"6289720\",\n \"transactionHash\": \"0x2a859d381cb4b50830971b1ffc9789b11569fc96147e130dae6fecd141f5ceb0\",\n \"blockNumber\": \"172\",\n \"blockHash\": \"0x7d990830157bfeff8e5cbe580e9effe97faa7676c9957ce32891b76c83961430\",\n \"calldataBytes\": 65220\n }\n ]\n },\n {\n \"id\": \"top-up-credit-1x1-unchanged-limits\",\n \"shape\": {\n \"kind\": \"top-up-credit\",\n \"target\": \"evm\",\n \"capacity\": 10,\n \"noteInputs\": 1,\n \"noteOutputs\": 1,\n \"sourceTrees\": 2,\n \"creditInputs\": 1,\n \"creditOutputs\": 1,\n \"creditRemainders\": 0,\n \"funding\": \"none\",\n \"permit\": false,\n \"deliveryBytes\": 1360\n },\n \"circuit\": {\n \"circuitName\": \"credit_top_up\",\n \"target\": \"evm\",\n \"artifactSha256\": \"2ffebd5753ec1b0c050204d4f97498765fe61ea01a793a9b2466c2f97536345c\",\n \"vkSha256\": \"40b02a9d2e7eb7b49daaac4b7760328537b7982fd5a225cc065bb74cd5ef44b3\"\n },\n \"samples\": [\n {\n \"gasUsed\": \"1711282\",\n \"transactionHash\": \"0x74d45084bb07bacabbced09ee6ef69d8632a22a4493be783c326c47e929ba0ed\",\n \"blockNumber\": \"172\",\n \"blockHash\": \"0x3503643f7081b52ae20d4754a0e9b11f52034ae48059f5b5298546c2570fa091\",\n \"calldataBytes\": 12292\n },\n {\n \"gasUsed\": \"1711282\",\n \"transactionHash\": \"0x4b5e2432d5571f6b56507b3ab995a8120560ba608959ff100f03b87873e72be6\",\n \"blockNumber\": \"172\",\n \"blockHash\": \"0xca15dc309371a5aa9c7bc5bf1d65c5b325c71528ce7856ba68a118114124fccc\",\n \"calldataBytes\": 12292\n },\n {\n \"gasUsed\": \"1711390\",\n \"transactionHash\": \"0x304f3740b64c80dcc5c894fb30af59080d96a11e08371096ae695cbc46ef2c8b\",\n \"blockNumber\": \"172\",\n \"blockHash\": \"0x9671ed76d6b8e49a36ba229d3609289fcf70756f31277ac5fc0e3f08cd52304f\",\n \"calldataBytes\": 12292\n }\n ]\n },\n {\n \"id\": \"top-up-credit-1x1-changed-limits\",\n \"shape\": {\n \"kind\": \"top-up-credit\",\n \"target\": \"evm\",\n \"capacity\": 10,\n \"noteInputs\": 1,\n \"noteOutputs\": 1,\n \"sourceTrees\": 2,\n \"creditInputs\": 1,\n \"creditOutputs\": 1,\n \"creditRemainders\": 0,\n \"funding\": \"none\",\n \"permit\": false,\n \"deliveryBytes\": 1360\n },\n \"circuit\": {\n \"circuitName\": \"credit_top_up\",\n \"target\": \"evm\",\n \"artifactSha256\": \"2ffebd5753ec1b0c050204d4f97498765fe61ea01a793a9b2466c2f97536345c\",\n \"vkSha256\": \"40b02a9d2e7eb7b49daaac4b7760328537b7982fd5a225cc065bb74cd5ef44b3\"\n },\n \"samples\": [\n {\n \"gasUsed\": \"1711318\",\n \"transactionHash\": \"0x65284df534b42631f8a592fb2a6efc16361a4cc122f1a8dd41418e7b950f48f1\",\n \"blockNumber\": \"172\",\n \"blockHash\": \"0xf198242a1edf5b133961568c9165648c829729e7bfbbf57a1e148551c971b87c\",\n \"calldataBytes\": 12292\n },\n {\n \"gasUsed\": \"1711438\",\n \"transactionHash\": \"0xcee89a81e598974798365c4ebada806fb51196ee602334b0fffdbb25da0afe25\",\n \"blockNumber\": \"172\",\n \"blockHash\": \"0xb506a6fb54cc2f91b803211ed955aac0203fba93e2428f8f52ec0d413c90af09\",\n \"calldataBytes\": 12292\n },\n {\n \"gasUsed\": \"1711342\",\n \"transactionHash\": \"0x957de5c79f365c9b0510b9e125a662317494aad50cb446edceef6f678d561cc7\",\n \"blockNumber\": \"172\",\n \"blockHash\": \"0xb1d5cffd6d6db58ade9d5e16d48b060b9ab2152415966dc809e7e70785472ab8\",\n \"calldataBytes\": 12292\n }\n ]\n },\n {\n \"id\": \"cancel-credit-1\",\n \"shape\": {\n \"kind\": \"cancel-credit\",\n \"target\": \"evm\",\n \"capacity\": 1,\n \"noteInputs\": 0,\n \"noteOutputs\": 0,\n \"sourceTrees\": 1,\n \"creditInputs\": 1,\n \"creditOutputs\": 0,\n \"creditRemainders\": 0,\n \"funding\": \"none\",\n \"permit\": false,\n \"deliveryBytes\": 0\n },\n \"circuit\": {\n \"circuitName\": \"credit_cancel\",\n \"target\": \"evm\",\n \"artifactSha256\": \"b4459c2cf756d096e37291cf4d7cd129866b6d420b6d03c928f383b057112ccb\",\n \"vkSha256\": \"fc8ad196ef15f3328afcc8f01d867a3ebefd15451c2813948442fab1923b73b2\"\n },\n \"samples\": [\n {\n \"gasUsed\": \"985543\",\n \"transactionHash\": \"0x29ca63fbefcc5e92dbc86f67d6280993e567a5dd02ff3defd7f3251ce711865e\",\n \"blockNumber\": \"172\",\n \"blockHash\": \"0xecd7808fe9f7467af917069bd7a82ab0324e3cbab8dcad622b089d6e3eee9a58\",\n \"calldataBytes\": 9540\n },\n {\n \"gasUsed\": \"985795\",\n \"transactionHash\": \"0xaf8bca0769330f89b647363f99b752dbbe6fdbb8b1aae912224f6a3a59f40faa\",\n \"blockNumber\": \"172\",\n \"blockHash\": \"0x58e1358e02f189d57628fa7c504b87fb000fe60eb9f0a0c3c0e58dae876e64da\",\n \"calldataBytes\": 9540\n },\n {\n \"gasUsed\": \"985711\",\n \"transactionHash\": \"0x2c911fd5a422f6f72f2a00b16872b7e46e182d39b8f5bfa9e3b2bf99d3155da7\",\n \"blockNumber\": \"172\",\n \"blockHash\": \"0x9da571cbe63f52232261ee1527d5ed97a9e90e374b4fcda97d04feb25114d18e\",\n \"calldataBytes\": 9540\n }\n ]\n }\n ]\n },\n {\n \"formatVersion\": 1,\n \"id\": \"protocol-92ef274-osaka-real\",\n \"deployment\": {\n \"chainId\": \"31337\",\n \"protocolAddress\": \"0x8870C63A18a9480C7de9B860b849fD293832856D\",\n \"runtimeCodeHash\": \"0x604572c0da90ea139b774cd0d2962a2972fac46e0556c7cec6f6f9aac5deef14\",\n \"tokenAddress\": \"0x4826533B4897376654Bb4d4AD88B7faFD0C98528\"\n },\n \"source\": {\n \"protocolCommit\": \"92ef274c6b36d783507699a33ee20e52192c83c7\",\n \"measuredAt\": \"2026-10-27T08:42:15.991Z\",\n \"chain\": \"Anvil 31337\",\n \"hardfork\": \"osaka\",\n \"token\": \"MockERC20\",\n \"verifier\": \"real\",\n \"assumptions\": [\n \"normal CREATE/Factory deployment; no code or storage injection\",\n \"Solidity 0.8.27 optimizer 200; real BB 5.2.1 verifiers\",\n \"one source tree; two existing leaves; no rollover or screener\",\n \"funding/approval setup excluded; complete transaction receipt gas included\",\n \"exact allowance for caller funding; configured benchmark payout balances\",\n \"observed local samples, not a confidence interval or gas limit\"\n ]\n },\n \"measurements\": [\n {\n \"id\": \"shield-1\",\n \"shape\": {\n \"kind\": \"shield\",\n \"target\": \"evm\",\n \"capacity\": 0,\n \"noteInputs\": 0,\n \"noteOutputs\": 1,\n \"sourceTrees\": 0,\n \"creditInputs\": 0,\n \"creditOutputs\": 0,\n \"creditRemainders\": 0,\n \"funding\": \"caller\",\n \"permit\": false,\n \"deliveryBytes\": 226\n },\n \"circuit\": null,\n \"samples\": [\n {\n \"gasUsed\": \"649286\",\n \"transactionHash\": \"0xcc299d1780ada9a69b1d9f0f3d06a165db15fccbd2b7ff407834f02f5d563a18\",\n \"blockNumber\": \"50\",\n \"blockHash\": \"0xbcb868e781a20588d2fa099a4d7f87c1600044a2e5ec1e369e384d7a5f22f00a\",\n \"calldataBytes\": 1156\n },\n {\n \"gasUsed\": \"649322\",\n \"transactionHash\": \"0x95139dff109725989f0769e3e6fb9bd3e7e1bf581fd475f14e822875eb90fda4\",\n \"blockNumber\": \"50\",\n \"blockHash\": \"0x7ace353fea4fc8c856c0fd45521d200b02619921977709ff4f910e0ff41c06fe\",\n \"calldataBytes\": 1156\n },\n {\n \"gasUsed\": \"649322\",\n \"transactionHash\": \"0xef578bb38dc8ff8bfd47d2e76e3ab4273019ea9a385f5d2fd99add32ceaecb58\",\n \"blockNumber\": \"50\",\n \"blockHash\": \"0xded817f8ef89637e2443e3b626c0837f184ca134fe753be913d5570554c649a6\",\n \"calldataBytes\": 1156\n }\n ]\n },\n {\n \"id\": \"shield-2\",\n \"shape\": {\n \"kind\": \"shield\",\n \"target\": \"evm\",\n \"capacity\": 0,\n \"noteInputs\": 0,\n \"noteOutputs\": 2,\n \"sourceTrees\": 0,\n \"creditInputs\": 0,\n \"creditOutputs\": 0,\n \"creditRemainders\": 0,\n \"funding\": \"caller\",\n \"permit\": false,\n \"deliveryBytes\": 452\n },\n \"circuit\": null,\n \"samples\": [\n {\n \"gasUsed\": \"757063\",\n \"transactionHash\": \"0x024e2dfbd6f50c368e2a4aa347e3029de668f4ebd36b80227aa003bb7ac21c74\",\n \"blockNumber\": \"50\",\n \"blockHash\": \"0x8ed63973c158d706ac54bb646626e4f0db5777b4bd56d179b94503af6c417c50\",\n \"calldataBytes\": 1668\n },\n {\n \"gasUsed\": \"757063\",\n \"transactionHash\": \"0x898d852ab28f68adac4d30b160a3dbfee33fa7ca875f70df9eb7763b6b1cd1f0\",\n \"blockNumber\": \"50\",\n \"blockHash\": \"0x9bb6810de38193933a9f26fa03d3d9bad1ca0151ff5e04544c56520e09da3043\",\n \"calldataBytes\": 1668\n },\n {\n \"gasUsed\": \"757039\",\n \"transactionHash\": \"0x8ff9720e3197aab2d741fbd8d0fa2969203ea8cd051d9649d1e5eb890bcc2be3\",\n \"blockNumber\": \"50\",\n \"blockHash\": \"0x8604c75eb6363aaae774276e638f5b749aae1f8f815eb99ab1183137eef5730e\",\n \"calldataBytes\": 1668\n }\n ]\n },\n {\n \"id\": \"shield-10\",\n \"shape\": {\n \"kind\": \"shield\",\n \"target\": \"evm\",\n \"capacity\": 0,\n \"noteInputs\": 0,\n \"noteOutputs\": 10,\n \"sourceTrees\": 0,\n \"creditInputs\": 0,\n \"creditOutputs\": 0,\n \"creditRemainders\": 0,\n \"funding\": \"caller\",\n \"permit\": false,\n \"deliveryBytes\": 2260\n },\n \"circuit\": null,\n \"samples\": [\n {\n \"gasUsed\": \"1692143\",\n \"transactionHash\": \"0x6c13db8bd8a8599daf5034e56712abefbf406982fafe7647b6d22291ba4199ed\",\n \"blockNumber\": \"50\",\n \"blockHash\": \"0x1ab2ae514f408a79e0c40ca10cee74b2e23d7c8a5f24641b8eea3e1cf58ce700\",\n \"calldataBytes\": 5764\n },\n {\n \"gasUsed\": \"1692083\",\n \"transactionHash\": \"0x5e476c9d3838b782a51332af9bf5c372d29fc411c2168a7af619c52bd5309c7b\",\n \"blockNumber\": \"50\",\n \"blockHash\": \"0x9c62bc72fc90f990c6711b48865ff922a1856ae05c4fef61dad5f4da7d948401\",\n \"calldataBytes\": 5764\n },\n {\n \"gasUsed\": \"1692203\",\n \"transactionHash\": \"0x0092e2d9160fad95279cde586fc6c79c713244f55db8a2060a5abab9d98c176a\",\n \"blockNumber\": \"50\",\n \"blockHash\": \"0xac1bf780b4cc05b4dcc7ee5d741c049ba99ab4af9bdcd25104add730c2a14152\",\n \"calldataBytes\": 5764\n }\n ]\n },\n {\n \"id\": \"transfer-1x2\",\n \"shape\": {\n \"kind\": \"transfer\",\n \"target\": \"evm\",\n \"capacity\": 14,\n \"noteInputs\": 1,\n \"noteOutputs\": 2,\n \"sourceTrees\": 1,\n \"creditInputs\": 0,\n \"creditOutputs\": 0,\n \"creditRemainders\": 0,\n \"funding\": \"none\",\n \"permit\": false,\n \"deliveryBytes\": 452\n },\n \"circuit\": {\n \"circuitName\": \"transact_user_slots14\",\n \"target\": \"evm\",\n \"artifactSha256\": \"2a6a20839e90b88b1ecd629f59a01821bad3ee11dbe04db1fd9cdce7a3de0e84\",\n \"vkSha256\": \"ffe0e1a4e690792ecb4eb1fc1acc9ff60f13d3b5af03cfc6ae6d6bf26e99bdea\"\n },\n \"samples\": [\n {\n \"gasUsed\": \"1617516\",\n \"transactionHash\": \"0xf49ea3d31cc1346472172e2dee84f9360f60a3fe948a3ef6e87f727af6d42f0d\",\n \"blockNumber\": \"49\",\n \"blockHash\": \"0xf59c57e63ec2f03abc36d28f273b0af5290184dc97197df740b23d79a851a887\",\n \"calldataBytes\": 11012\n },\n {\n \"gasUsed\": \"1617516\",\n \"transactionHash\": \"0xf8d11286f1f2a4db006ff6b06900c47d0fbf685984499e1e5d4aea49478ba8e5\",\n \"blockNumber\": \"49\",\n \"blockHash\": \"0xeb5a800190be3534c9e2675c97ac56d0e0be8adef55f60bd32d375776a7d150c\",\n \"calldataBytes\": 11012\n },\n {\n \"gasUsed\": \"1617504\",\n \"transactionHash\": \"0x8939fcea97079a3c5118b9e94325455e2ad1cdb47310ae499a277272654b3eb6\",\n \"blockNumber\": \"49\",\n \"blockHash\": \"0xecffefb593e2fec5d5827cfd39d0cc4d0efb67dbff6f8dbbd0d2db2439a80cf9\",\n \"calldataBytes\": 11012\n }\n ]\n },\n {\n \"id\": \"transfer-1x14\",\n \"shape\": {\n \"kind\": \"transfer\",\n \"target\": \"evm\",\n \"capacity\": 56,\n \"noteInputs\": 1,\n \"noteOutputs\": 14,\n \"sourceTrees\": 1,\n \"creditInputs\": 0,\n \"creditOutputs\": 0,\n \"creditRemainders\": 0,\n \"funding\": \"none\",\n \"permit\": false,\n \"deliveryBytes\": 3164\n },\n \"circuit\": {\n \"circuitName\": \"transact_user_slots56\",\n \"target\": \"evm\",\n \"artifactSha256\": \"ba83ec2f177d16fa88ea04bc54f2e99920f1ac195cdb05b88b9b3bbc245fd953\",\n \"vkSha256\": \"6ad5d3aff0c72a632fb19895658af093a6a92478a9994985e838a71e61237720\"\n },\n \"samples\": [\n {\n \"gasUsed\": \"2489010\",\n \"transactionHash\": \"0x053557acea930a869d6469c91e9bc015d0893607a6ab18d2af684986f7074676\",\n \"blockNumber\": \"49\",\n \"blockHash\": \"0x734873097eb5e4cb66bfc2cdb61fac6753b53a4b9450fb22895281100af3aaf3\",\n \"calldataBytes\": 17156\n },\n {\n \"gasUsed\": \"2489106\",\n \"transactionHash\": \"0xb3990edb994011775e275bc1eb38c527b7206a2bfadf510e8aa53e260f3594b8\",\n \"blockNumber\": \"49\",\n \"blockHash\": \"0xf8cb019ebb0ecd0ec5d6634198292883c63fe93a7c65c34f9f3120c6cc54f1cf\",\n \"calldataBytes\": 17156\n },\n {\n \"gasUsed\": \"2489094\",\n \"transactionHash\": \"0xc97079019567ff8a79d285421351ee4bc48d14092a0e12ff634151719e991088\",\n \"blockNumber\": \"49\",\n \"blockHash\": \"0x5a6947839165c8961eeeb9190331415c40366a78b4a6a5771e7b8954dbb8b3c7\",\n \"calldataBytes\": 17156\n }\n ]\n },\n {\n \"id\": \"transfer-1x56\",\n \"shape\": {\n \"kind\": \"transfer\",\n \"target\": \"evm\",\n \"capacity\": 112,\n \"noteInputs\": 1,\n \"noteOutputs\": 56,\n \"sourceTrees\": 1,\n \"creditInputs\": 0,\n \"creditOutputs\": 0,\n \"creditRemainders\": 0,\n \"funding\": \"none\",\n \"permit\": false,\n \"deliveryBytes\": 12656\n },\n \"circuit\": {\n \"circuitName\": \"transact_user_slots112\",\n \"target\": \"evm\",\n \"artifactSha256\": \"713b78469b6e97711122210f8497942120c1c9d66d3604bc184566c4eba59cc3\",\n \"vkSha256\": \"d6a46e297949c28b9a62fd9aef1f202870fdca97b8bfb15beefd27b9e9f3d86e\"\n },\n \"samples\": [\n {\n \"gasUsed\": \"5389227\",\n \"transactionHash\": \"0xb820d3c358724c1d64422017f232d074e4ff1ffaf1b1ce5ee719409427cf2208\",\n \"blockNumber\": \"49\",\n \"blockHash\": \"0x474bd1e52457801d1a596a9f23aeb6d365a17be028ee0c8cf8fd4758eaa1106b\",\n \"calldataBytes\": 36356\n },\n {\n \"gasUsed\": \"5389095\",\n \"transactionHash\": \"0x16514d8cf1136d7a7f40591859e2ea2d256af66520498e1fc81eb28837db600d\",\n \"blockNumber\": \"49\",\n \"blockHash\": \"0x42314a0d6eb9e765869e1b66b279444c78f919d2c28aed544d9fa7ac3bd2acb4\",\n \"calldataBytes\": 36356\n },\n {\n \"gasUsed\": \"5389203\",\n \"transactionHash\": \"0xee69d565a7eafb60ad7a47afe80a49d4fa40b50660669d9141e7dc6f4c3dbe0d\",\n \"blockNumber\": \"49\",\n \"blockHash\": \"0x0dcdada663ee04dd63e06fcdb79dacc5623201d29b687f63deede2b4762a994e\",\n \"calldataBytes\": 36356\n }\n ]\n },\n {\n \"id\": \"transfer-1x112\",\n \"shape\": {\n \"kind\": \"transfer\",\n \"target\": \"evm\",\n \"capacity\": 168,\n \"noteInputs\": 1,\n \"noteOutputs\": 112,\n \"sourceTrees\": 1,\n \"creditInputs\": 0,\n \"creditOutputs\": 0,\n \"creditRemainders\": 0,\n \"funding\": \"none\",\n \"permit\": false,\n \"deliveryBytes\": 25312\n },\n \"circuit\": {\n \"circuitName\": \"transact_user_slots168\",\n \"target\": \"evm\",\n \"artifactSha256\": \"f7b3b1384e961367702f544299ca3521d8205fac31b7691c45ff84325d5a31c3\",\n \"vkSha256\": \"e00181533d7e35d2307570528f9e7f8f88e2909b6ae338d93373b608dea96881\"\n },\n \"samples\": [\n {\n \"gasUsed\": \"9139842\",\n \"transactionHash\": \"0x09951c4e00b868b6660429d187a482004646e4c84ef341d3b98352c249db6a06\",\n \"blockNumber\": \"49\",\n \"blockHash\": \"0xba9da3c08189335acff1eb33554f5f12475e4a6510324cf6ec9eadf340ce15d2\",\n \"calldataBytes\": 61444\n },\n {\n \"gasUsed\": \"9139650\",\n \"transactionHash\": \"0xb06f69d1c6e5406758918d5d296ab889bab4c3814f616cc581ad312cc7ebb2f3\",\n \"blockNumber\": \"49\",\n \"blockHash\": \"0x5516a76b4b366f2e539a67bb848b7d232c3e6f328d34ca5bd3dba43a14c316bf\",\n \"calldataBytes\": 61444\n },\n {\n \"gasUsed\": \"9139530\",\n \"transactionHash\": \"0x116c4875b7712b7cb51cdb0fcb6e66a95733dca272aa272bc0b1fd265edbe26c\",\n \"blockNumber\": \"49\",\n \"blockHash\": \"0xd36340fddd1eace21b73f785c6589bf73b07bef782f2e78a5e3d3d828b0b607c\",\n \"calldataBytes\": 61444\n }\n ]\n },\n {\n \"id\": \"withdraw-1x1\",\n \"shape\": {\n \"kind\": \"withdraw\",\n \"target\": \"evm\",\n \"capacity\": 14,\n \"noteInputs\": 1,\n \"noteOutputs\": 1,\n \"sourceTrees\": 1,\n \"creditInputs\": 0,\n \"creditOutputs\": 0,\n \"creditRemainders\": 0,\n \"funding\": \"none\",\n \"permit\": false,\n \"deliveryBytes\": 226\n },\n \"circuit\": {\n \"circuitName\": \"transact_user_slots14\",\n \"target\": \"evm\",\n \"artifactSha256\": \"2a6a20839e90b88b1ecd629f59a01821bad3ee11dbe04db1fd9cdce7a3de0e84\",\n \"vkSha256\": \"ffe0e1a4e690792ecb4eb1fc1acc9ff60f13d3b5af03cfc6ae6d6bf26e99bdea\"\n },\n \"samples\": [\n {\n \"gasUsed\": \"1597571\",\n \"transactionHash\": \"0x326892d32146e0bc36b396fd3973151a629312df68ed25a4ffbb6a3da23ba274\",\n \"blockNumber\": \"49\",\n \"blockHash\": \"0x3e0f326cba3dd019b86431b4c22145758a7f10c121a696a81a094746b04495b5\",\n \"calldataBytes\": 10564\n },\n {\n \"gasUsed\": \"1597715\",\n \"transactionHash\": \"0x2e3a15157ac9c07e4717bbd4641481ce3bc0068d26157752815b6ec6b30acdd0\",\n \"blockNumber\": \"49\",\n \"blockHash\": \"0xab7fceac97d55e8702d1202b98d3a05c4b1e0f71e51b6d88d7e80e91cc338596\",\n \"calldataBytes\": 10564\n },\n {\n \"gasUsed\": \"1597595\",\n \"transactionHash\": \"0x5052e94a67520c43416cdcb60a1365a126560861173d0eef46bcbf0a566fe947\",\n \"blockNumber\": \"49\",\n \"blockHash\": \"0x9a64cf76b646b5a07b72fcc61266e87f17365fec891701c331982a93e5ba9b89\",\n \"calldataBytes\": 10564\n }\n ]\n },\n {\n \"id\": \"sweep-1x0\",\n \"shape\": {\n \"kind\": \"sweep\",\n \"target\": \"evm\",\n \"capacity\": 14,\n \"noteInputs\": 1,\n \"noteOutputs\": 0,\n \"sourceTrees\": 1,\n \"creditInputs\": 0,\n \"creditOutputs\": 0,\n \"creditRemainders\": 0,\n \"funding\": \"none\",\n \"permit\": false,\n \"deliveryBytes\": 0\n },\n \"circuit\": {\n \"circuitName\": \"transact_user_slots14\",\n \"target\": \"evm\",\n \"artifactSha256\": \"2a6a20839e90b88b1ecd629f59a01821bad3ee11dbe04db1fd9cdce7a3de0e84\",\n \"vkSha256\": \"ffe0e1a4e690792ecb4eb1fc1acc9ff60f13d3b5af03cfc6ae6d6bf26e99bdea\"\n },\n \"samples\": [\n {\n \"gasUsed\": \"1069308\",\n \"transactionHash\": \"0xb1ab469d05ca5f49659f54a332cc172892dcce37e475342fbf52fa9cfb4d3927\",\n \"blockNumber\": \"49\",\n \"blockHash\": \"0xe5b04579149987198801f1ca19ab771d5262de2aaf9861a6c962d50d1c6baef0\",\n \"calldataBytes\": 10116\n },\n {\n \"gasUsed\": \"1069284\",\n \"transactionHash\": \"0xd6adee997f7e1e19e3918f913f6ee48d94df69c09ed74e333325023089e7f6df\",\n \"blockNumber\": \"49\",\n \"blockHash\": \"0xcb225566f8f1ea6ae8da30158b8f1aef03d50fa4ea352a00aa42b7f41a05d63c\",\n \"calldataBytes\": 10116\n },\n {\n \"gasUsed\": \"1069308\",\n \"transactionHash\": \"0xe06dd7f3a2718bc9a9412c2d6f505960ce225b2e5fe6c1c66bb5b0e8f427006f\",\n \"blockNumber\": \"49\",\n \"blockHash\": \"0x37a08c5918892e1c19df017c746ab0ede03c1bb195c3be593d70c1f9de91897e\",\n \"calldataBytes\": 10116\n }\n ]\n }\n ]\n }\n]\n","import type { Hex } from \"@invisi-labs/core\";\nimport type { TokenProtocol } from \"@invisi-labs/protocol\";\nimport type { OperationPlan } from \"./session/operation-types\";\nimport { operationSources } from \"./session/operation-protocol\";\nimport referenceProfiles from \"./data/gas-benchmarks.json\";\n\nexport interface GasBenchmarkShape {\n kind: OperationPlan[\"kind\"];\n target: string;\n capacity: number;\n noteInputs: number;\n noteOutputs: number;\n sourceTrees: number;\n creditInputs: number;\n creditOutputs: number;\n creditRemainders: number;\n funding: \"none\" | \"caller\" | \"signature\";\n permit: boolean;\n deliveryBytes: number;\n}\nexport interface GasBenchmarkDeployment {\n chainId: string;\n protocolAddress: Hex;\n runtimeCodeHash: Hex | null;\n tokenAddress: Hex;\n}\nexport interface GasBenchmarkCircuit {\n circuitName: string;\n target: string;\n artifactSha256: string;\n vkSha256: string;\n}\nexport interface GasBenchmarkSample {\n gasUsed: string;\n transactionHash: Hex;\n blockNumber: string;\n blockHash: Hex;\n calldataBytes: number;\n}\nexport interface GasBenchmarkProfile {\n formatVersion: 1;\n id: string;\n deployment: GasBenchmarkDeployment;\n source: {\n protocolCommit: string;\n fingerprints?: {\n protocolSourceSha256: string;\n dirtyDiffSha256: string;\n compiledArtifactsSha256: string;\n creditManifestSha256: string;\n userManifestSha256: string;\n sdkSourceSha256: string;\n };\n toolchain?: {\n solidity: string;\n barretenberg: string;\n noir: string;\n evmVersion: string;\n optimizerRuns: number;\n anvil: string;\n };\n blockGasLimit?: string;\n runtimeContracts?: Record<string, { address: Hex; runtimeCodeHash: Hex }>;\n measuredAt: string;\n chain: string;\n hardfork: string;\n token: string;\n verifier: \"real\";\n assumptions: string[];\n };\n measurements: Array<{\n id: string;\n shape: GasBenchmarkShape;\n circuit: GasBenchmarkCircuit | null;\n samples: GasBenchmarkSample[];\n }>;\n}\nexport interface GasEstimateRequest {\n deployment: GasBenchmarkDeployment;\n shape: GasBenchmarkShape;\n circuit: GasBenchmarkCircuit | null;\n}\nexport type BenchmarkGasEstimate = {\n source: \"benchmark\";\n request: GasEstimateRequest;\n} & (\n | {\n available: false;\n reason: \"deployment-not-covered\" | \"shape-not-covered\" | \"recursive-member-only\";\n }\n | {\n available: true;\n gasUnits: bigint;\n range: { min: bigint; max: bigint; kind: \"observed\" };\n samples: number;\n profileId: string;\n measurementId: string;\n evidence: GasBenchmarkProfile[\"source\"];\n }\n);\nconst word = /^0x[0-9a-fA-F]{64}$/;\nconst address = /^0x[0-9a-fA-F]{40}$/;\nconst decimal = /^(0|[1-9][0-9]*)$/;\nconst shapeKeys: Array<keyof GasBenchmarkShape> = [\n \"kind\",\n \"target\",\n \"capacity\",\n \"noteInputs\",\n \"noteOutputs\",\n \"sourceTrees\",\n \"creditInputs\",\n \"creditOutputs\",\n \"creditRemainders\",\n \"funding\",\n \"permit\",\n \"deliveryBytes\",\n];\n\n/** Copy trusted benchmark records; validation checks format, not their publisher's honesty. */\nexport function copyGasBenchmarks(profiles: readonly GasBenchmarkProfile[]): GasBenchmarkProfile[] {\n const copy = structuredClone([...profiles]);\n for (const p of copy) {\n if (\n p.formatVersion !== 1 ||\n !p.id ||\n !decimal.test(p.deployment.chainId) ||\n !address.test(p.deployment.protocolAddress) ||\n !address.test(p.deployment.tokenAddress) ||\n !p.deployment.runtimeCodeHash ||\n !word.test(p.deployment.runtimeCodeHash) ||\n p.source.verifier !== \"real\" ||\n !/^[0-9a-f]{40}$/i.test(p.source.protocolCommit) ||\n !p.source.measuredAt ||\n !Array.isArray(p.source.assumptions) ||\n !p.source.assumptions.every((assumption) => typeof assumption === \"string\") ||\n !p.measurements.length\n )\n throw new Error(\"invalid gas benchmark profile\");\n if (\n p.source.fingerprints &&\n ![\n \"protocolSourceSha256\",\n \"dirtyDiffSha256\",\n \"compiledArtifactsSha256\",\n \"creditManifestSha256\",\n \"userManifestSha256\",\n \"sdkSourceSha256\",\n ].every((key) => {\n const v = (p.source.fingerprints as unknown as Record<string, unknown>)[key];\n return typeof v === \"string\" && /^[a-f0-9]{64}$/i.test(v);\n })\n )\n throw new Error(\"invalid benchmark source fingerprint\");\n if (\n p.source.blockGasLimit !== undefined &&\n (!decimal.test(p.source.blockGasLimit) || BigInt(p.source.blockGasLimit) <= 0n)\n )\n throw new Error(\"invalid benchmark block gas limit\");\n if (\n p.source.runtimeContracts &&\n !Object.values(p.source.runtimeContracts).every(\n (v) => address.test(v.address) && word.test(v.runtimeCodeHash)\n )\n )\n throw new Error(\"invalid benchmark runtime identity\");\n if (\n p.source.toolchain &&\n (![\"solidity\", \"barretenberg\", \"noir\", \"evmVersion\", \"anvil\"].every((key) => {\n const v = (p.source.toolchain as unknown as Record<string, unknown>)[key];\n return typeof v === \"string\" && v.length > 0;\n }) ||\n !Number.isSafeInteger(p.source.toolchain.optimizerRuns) ||\n p.source.toolchain.optimizerRuns < 0)\n )\n throw new Error(\"invalid benchmark toolchain\");\n for (const m of p.measurements) {\n if (\n !m.id ||\n !m.samples.length ||\n ![\"none\", \"caller\", \"signature\"].includes(m.shape.funding) ||\n typeof m.shape.permit !== \"boolean\"\n )\n throw new Error(\"invalid gas benchmark measurement\");\n for (const key of shapeKeys) {\n const value = m.shape[key];\n if (\n ![\"kind\", \"target\", \"funding\", \"permit\"].includes(key) &&\n (!Number.isSafeInteger(value) || Number(value) < 0)\n )\n throw new Error(\"invalid gas benchmark shape\");\n }\n if (\n m.circuit &&\n (![m.circuit.artifactSha256, m.circuit.vkSha256].every((hash) =>\n /^[a-f0-9]{64}$/i.test(hash)\n ) ||\n !m.circuit.circuitName ||\n !m.circuit.target)\n )\n throw new Error(\"invalid gas benchmark circuit identity\");\n const hashes = new Set<string>();\n for (const sample of m.samples) {\n if (\n typeof sample.gasUsed !== \"string\" ||\n !decimal.test(sample.gasUsed) ||\n BigInt(sample.gasUsed) <= 0n ||\n !word.test(sample.transactionHash) ||\n !word.test(sample.blockHash) ||\n !decimal.test(sample.blockNumber) ||\n !Number.isSafeInteger(sample.calldataBytes) ||\n sample.calldataBytes < 0 ||\n hashes.has(sample.transactionHash.toLowerCase())\n )\n throw new Error(\"invalid gas benchmark receipt\");\n hashes.add(sample.transactionHash.toLowerCase());\n }\n }\n }\n return copy;\n}\n/** Parse a trusted, JSON-compatible benchmark catalog. No network access or publisher authentication. */\nexport function defineGasBenchmarks(input: unknown): GasBenchmarkProfile[] {\n if (!Array.isArray(input)) throw new Error(\"invalid gas benchmark catalog\");\n try {\n return copyGasBenchmarks(input as GasBenchmarkProfile[]);\n } catch {\n throw new Error(\"invalid gas benchmark catalog\");\n }\n}\nconst defaultProfiles = defineGasBenchmarks(referenceProfiles);\n\nfunction sameDeployment(a: GasBenchmarkDeployment, b: GasBenchmarkDeployment) {\n return (\n a.chainId === b.chainId &&\n a.protocolAddress.toLowerCase() === b.protocolAddress.toLowerCase() &&\n a.tokenAddress.toLowerCase() === b.tokenAddress.toLowerCase() &&\n a.runtimeCodeHash?.toLowerCase() === b.runtimeCodeHash?.toLowerCase()\n );\n}\nfunction sameCircuit(a: GasBenchmarkCircuit | null, b: GasBenchmarkCircuit | null) {\n return a === null\n ? b === null\n : b !== null &&\n a.circuitName === b.circuitName &&\n a.target === b.target &&\n a.artifactSha256.toLowerCase() === b.artifactSha256.toLowerCase() &&\n a.vkSha256.toLowerCase() === b.vkSha256.toLowerCase();\n}\n\n/** Pure reference lookup. No proof, RPC, current fee price, extrapolation or transaction gas limit. */\nexport function estimateBenchmarkGas(\n plan: OperationPlan,\n protocol: TokenProtocol,\n profiles?: readonly GasBenchmarkProfile[]\n): BenchmarkGasEstimate {\n const credit = plan.credit;\n const deliveries = credit?.deliveries ?? plan.outputs.map((out) => out.delivery);\n const request: GasEstimateRequest = {\n deployment: {\n chainId: plan.context.chainId.toString(),\n protocolAddress: plan.context.protocolAddress,\n runtimeCodeHash: protocol.expectedRuntimeCodeHash ?? null,\n tokenAddress: plan.context.tokenAddress,\n },\n shape: {\n kind: plan.kind,\n target: plan.statement?.target ?? \"evm\",\n capacity: plan.capacity ?? 0,\n noteInputs: plan.inputs.length,\n noteOutputs: plan.outputs.length,\n sourceTrees: operationSources(plan).length,\n creditInputs: credit?.inputs.length ?? 0,\n creditOutputs: credit?.outputs.length ?? 0,\n creditRemainders:\n credit?.draw?.remainderCommitments.filter((hash) => BigInt(hash) !== 0n).length ??\n 0,\n funding: plan.fundingMode,\n permit: (plan.funding.permit?.deadline ?? 0n) !== 0n,\n deliveryBytes: deliveries.reduce(\n (sum, d) => sum + (d.ciphertext.length - 2) / 2 + (d.clue.length - 2) / 2,\n 0\n ),\n },\n circuit: plan.statement\n ? {\n circuitName: plan.statement.circuitName,\n target: plan.statement.target,\n artifactSha256: plan.statement.artifactSha256,\n vkSha256: plan.statement.vkSha256,\n }\n : null,\n };\n const base = { source: \"benchmark\" as const, request };\n if (request.shape.target === \"noir-recursive\")\n return { ...base, available: false, reason: \"recursive-member-only\" };\n const candidates = (profiles ?? defaultProfiles).filter((p) =>\n sameDeployment(p.deployment, request.deployment)\n );\n if (!request.deployment.runtimeCodeHash || !candidates.length)\n return { ...base, available: false, reason: \"deployment-not-covered\" };\n const exact = candidates.flatMap((profile) =>\n profile.measurements\n .filter(\n (m) =>\n shapeKeys.every((key) => m.shape[key] === request.shape[key]) &&\n sameCircuit(m.circuit, request.circuit)\n )\n .map((measurement) => ({ profile, measurement }))\n );\n const mean = (measurement: GasBenchmarkProfile[\"measurements\"][number]) => {\n const count = BigInt(measurement.samples.length);\n return (\n (measurement.samples.reduce((sum, s) => sum + BigInt(s.gasUsed), 0n) + count - 1n) /\n count\n );\n };\n exact.sort((a, b) =>\n mean(a.measurement) > mean(b.measurement)\n ? -1\n : mean(a.measurement) < mean(b.measurement)\n ? 1\n : a.measurement.id.localeCompare(b.measurement.id)\n );\n if (exact.length) {\n const { profile, measurement } = exact[0]!;\n const gas = measurement.samples.map((sample) => BigInt(sample.gasUsed));\n const count = BigInt(gas.length);\n return {\n ...base,\n available: true,\n gasUnits: (gas.reduce((sum, value) => sum + value, 0n) + count - 1n) / count,\n range: {\n min: gas.reduce((a, b) => (a < b ? a : b)),\n max: gas.reduce((a, b) => (a > b ? a : b)),\n kind: \"observed\",\n },\n samples: gas.length,\n profileId: profile.id,\n measurementId: measurement.id,\n evidence: structuredClone(profile.source),\n };\n }\n return { ...base, available: false, reason: \"shape-not-covered\" };\n}\n\n/** Pre-proof reference only; ethers must estimate the final transaction independently. */\nexport interface GasReference {\n gasUnits: bigint;\n}\n\n/** Internal workload envelope for combinations without an exact receipt measurement. */\nexport function estimateShapeGas(\n request: GasEstimateRequest,\n profiles: readonly GasBenchmarkProfile[] = defaultProfiles\n): GasReference {\n if (request.shape.target === \"noir-recursive\") {\n throw new Error(\n \"Estimate gas for the complete aggregate, not an individual recursive member\"\n );\n }\n const measurements = profiles.flatMap((profile) => profile.measurements);\n const matching = measurements.filter(\n (measurement) =>\n measurement.shape.kind === request.shape.kind &&\n measurement.shape.target === request.shape.target &&\n sameCircuit(measurement.circuit, request.circuit)\n );\n const exact = matching.filter((measurement) =>\n shapeKeys.every((key) => measurement.shape[key] === request.shape[key])\n );\n if (exact.length) {\n const means = exact.map((m) => {\n const count = BigInt(m.samples.length);\n return (m.samples.reduce((sum, s) => sum + BigInt(s.gasUsed), 0n) + count - 1n) / count;\n });\n return { gasUnits: means.reduce((max, v) => (v > max ? v : max)) };\n }\n if (\n [\"create-credit\", \"draw-credit\", \"top-up-credit\", \"cancel-credit\"].includes(\n request.shape.kind\n ) &&\n !matching.length\n )\n throw new Error(\"No current Credit gas reference for this artifact and verification key\");\n const candidates = matching.length\n ? matching\n : measurements.filter(\n (measurement) =>\n measurement.shape.kind === request.shape.kind &&\n measurement.shape.target === request.shape.target\n );\n if (!candidates.length) throw new Error(\"No gas reference for this operation kind and target\");\n // Scale upward only. This intentionally overcounts shared verification work rather than\n // claiming a calibrated marginal cost for unmeasured input, tree or authorization paths.\n const dimensions = [\n \"noteInputs\",\n \"noteOutputs\",\n \"sourceTrees\",\n \"creditInputs\",\n \"creditOutputs\",\n \"creditRemainders\",\n \"deliveryBytes\",\n ...(!matching.length ? [\"capacity\"] : []),\n ] as const;\n // Same public shape may have several private-policy variants. Use their worst observed\n // receipt before comparing different workload baselines, so a cheaper variant cannot win.\n const groups = new Map<string, (typeof candidates)[number]>();\n for (const candidate of candidates) {\n const key = JSON.stringify([\n shapeKeys.map((k) => candidate.shape[k]),\n candidate.circuit?.circuitName,\n candidate.circuit?.target,\n candidate.circuit?.artifactSha256.toLowerCase(),\n candidate.circuit?.vkSha256.toLowerCase(),\n ]);\n const previous = groups.get(key);\n groups.set(\n key,\n previous\n ? { ...candidate, samples: [...previous.samples, ...candidate.samples] }\n : candidate\n );\n }\n const estimates = [...groups.values()].map((measurement) => {\n let numerator = 1n;\n let denominator = 1n;\n for (const key of dimensions) {\n const current = BigInt(request.shape[key as keyof GasBenchmarkShape] as number) + 1n;\n const baseline =\n BigInt(measurement.shape[key as keyof GasBenchmarkShape] as number) + 1n;\n if (current * denominator > numerator * baseline) {\n numerator = current;\n denominator = baseline;\n }\n }\n let gas = measurement.samples.reduce(\n (max, sample) => (BigInt(sample.gasUsed) > max ? BigInt(sample.gasUsed) : max),\n 0n\n );\n gas = (gas * numerator + denominator - 1n) / denominator;\n // These external calls were absent from the bundled receipt matrix. Reserve the cost\n // of one complete measured operation for each additional authorization mechanism.\n if (request.shape.funding === \"signature\" && measurement.shape.funding !== \"signature\")\n gas *= 2n;\n if (request.shape.permit && !measurement.shape.permit) gas *= 2n;\n return gas;\n });\n return { gasUnits: estimates.reduce((min, gas) => (gas < min ? gas : min)) };\n}\n\nexport function estimateGasReference(\n plan: OperationPlan,\n protocol: TokenProtocol,\n profiles?: readonly GasBenchmarkProfile[]\n): GasReference {\n const reference = estimateBenchmarkGas(plan, protocol, profiles);\n if (reference.available) return { gasUnits: reference.gasUnits };\n // Team records take priority only for their exact deployment and shape. The built-in\n // reference model is deployment-independent and covers the current SDK operation family.\n return estimateShapeGas(reference.request);\n}\n","import { invisiProtocolAbi } from \"@invisi-labs/protocol/contracts\";\nimport { Interface, type Result } from \"ethers\";\n\nconst protocolInterface = new Interface(invisiProtocolAbi);\n\n/** Decode only canonical protocol receipt bytes before routing events to token wallets. */\nexport function decodeProtocolEvent(log: { data: string; topics: readonly string[] }) {\n const decoded = protocolInterface.parseLog(log);\n if (!decoded) throw new Error(\"Unknown protocol receipt event\");\n const encoded = protocolInterface.encodeEventLog(decoded.fragment, decoded.args);\n if (\n encoded.data.toLowerCase() !== log.data.toLowerCase() ||\n encoded.topics.length !== log.topics.length ||\n encoded.topics.some(\n (topic, index) => topic.toLowerCase() !== log.topics[index]!.toLowerCase()\n )\n )\n throw new Error(\"Noncanonical protocol receipt event\");\n const args = decoded.args.toObject(true);\n // Preserve empty protocol arrays: ethers toObject(true) represents an empty Result as {}.\n for (const key of [\n \"tokens\",\n \"commitments\",\n \"nullifiers\",\n \"outputCommitments\",\n \"leafIndices\",\n \"remainderLeafIndices\",\n ]) {\n const values = decoded.args.getValue(key) as Result | undefined;\n if (values) args[key] = values.toArray(true);\n }\n for (const key of [\"sources\", \"deliveries\"]) {\n const values = decoded.args.getValue(key) as Result[] | undefined;\n if (values) args[key] = values.map((value) => value.toObject(true));\n }\n const params = decoded.args.getValue(\"params\") as Result | undefined;\n if (params) {\n const source = (params.getValue(\"creation\") as Result | undefined) ?? params;\n const target = params.getValue(\"creation\") ? args.params.creation : args.params;\n for (const key of [\"nullifiers\", \"remainderCommitments\", \"expiries\", \"recoveryAmounts\"]) {\n const values = source.getValue(key) as Result | undefined;\n if (values) target[key] = values.toArray(true);\n }\n const sources = source.getValue(\"sources\") as Result[] | undefined;\n if (sources) target.sources = sources.map((value) => value.toObject(true));\n }\n return { eventName: decoded.name, args };\n}\n","import type { Address } from \"@invisi-labs/protocol/contracts\";\nimport type { CanonicalReceipt } from \"@invisi-labs/protocol\";\nimport type { DeliveryEventLog } from \"./discovery\";\nimport { decodeProtocolEvent } from \"./protocol-events\";\n\n/** Decode independently fetched canonical receipt bytes, never normalized service events. */\nexport function readProtocolLogs(\n receipt: CanonicalReceipt,\n protocolAddress: Address\n): DeliveryEventLog[] {\n if (\n receipt.status !== \"success\" ||\n !/^0x[0-9a-fA-F]{64}$/.test(receipt.transactionHash) ||\n typeof receipt.block.number !== \"bigint\" ||\n receipt.block.number < 0n ||\n !/^0x[0-9a-fA-F]{64}$/.test(receipt.block.hash)\n )\n throw new Error(\"Invalid canonical protocol receipt\");\n const seen = new Set<number>();\n return receipt.logs\n .filter((log) => log.address.toLowerCase() === protocolAddress.toLowerCase())\n .map((log) => {\n if (\n log.transactionHash.toLowerCase() !== receipt.transactionHash.toLowerCase() ||\n !Number.isSafeInteger(log.logIndex) ||\n log.logIndex < 0 ||\n seen.has(log.logIndex)\n )\n throw new Error(\"Invalid canonical receipt log identity\");\n seen.add(log.logIndex);\n const decoded = decodeProtocolEvent(log);\n return {\n address: log.address,\n eventName: decoded.eventName,\n args: decoded.args as Record<string, unknown>,\n blockNumber: receipt.block.number,\n blockHash: receipt.block.hash,\n transactionHash: receipt.transactionHash.toLowerCase(),\n logIndex: log.logIndex,\n removed: false,\n } as DeliveryEventLog;\n })\n .sort((a, b) => a.logIndex! - b.logIndex!);\n}\n","import type { Address, Hex } from \"@invisi-labs/protocol/contracts\";\nimport { isAddress } from \"ethers\";\n\nimport {\n decodeAddress,\n ReceivingAddress,\n type CreditDeliveryState,\n type Note,\n type ViewingCapability,\n} from \"@invisi-labs/core\";\nimport { normalizeDelivery } from \"@invisi-labs/protocol\";\n\nexport interface DiscoveryContext {\n chainId: bigint;\n protocolAddress: Address;\n}\n/** Decoded logs from complete canonical transaction receipts, including insertion logs. */\nexport interface DeliveryEventLog {\n address: string;\n eventName: string;\n args?: Record<string, unknown>;\n blockNumber?: bigint | null;\n blockHash?: Hex | null;\n transactionHash?: Hex | null;\n logIndex?: number | null;\n removed?: boolean;\n}\nexport interface DeliveryCandidate {\n tokenAddress: Address;\n treeId: bigint;\n leafIndex: number;\n commitment: Hex;\n role: \"funds\" | \"owner\" | \"spender\";\n delivery: { ciphertext: Hex; clue: Hex };\n blockNumber: bigint;\n blockHash: Hex;\n transactionHash: Hex;\n}\nconst EVENTS = new Set([\n \"CommitmentsInserted\",\n \"BatchOutputs\",\n \"Shield\",\n \"Transact\",\n \"CrossTreeTransact\",\n \"CreditCreated\",\n \"CreditDraw\",\n \"CreditToppedUp\",\n \"CreditCancelled\",\n]);\nfunction check(ok: unknown, message: string): asserts ok {\n if (!ok) throw new Error(message);\n}\nfunction object(value: unknown): Record<string, unknown> {\n check(value && typeof value === \"object\" && !Array.isArray(value), \"invalid event object\");\n return value as Record<string, unknown>;\n}\nfunction array(value: unknown): unknown[] {\n check(Array.isArray(value), \"invalid event array\");\n check(\n Array.from({ length: value.length }, (_, i) => i in value).every(Boolean),\n \"sparse event array\"\n );\n return value;\n}\nfunction integer(value: unknown): bigint {\n check(\n typeof value === \"bigint\" || (typeof value === \"number\" && Number.isSafeInteger(value)),\n \"invalid event integer\"\n );\n const n = BigInt(value);\n check(n >= 0n, \"negative event integer\");\n return n;\n}\nfunction index(value: unknown): number {\n const n = integer(value);\n check(n < 65536n, \"invalid event leaf index\");\n return Number(n);\n}\nfunction hash(value: unknown): Hex {\n check(typeof value === \"string\" && /^0x[0-9a-fA-F]{64}$/.test(value), \"invalid event hash\");\n return value.toLowerCase() as Hex;\n}\nfunction contextCheck(context: DiscoveryContext): void {\n check(context.chainId >= 0n && context.chainId < 1n << 64n, \"invalid discovery chain\");\n check(\n isAddress(context.protocolAddress) && BigInt(context.protocolAddress) !== 0n,\n \"invalid discovery instance/token\"\n );\n}\nconst position = (tree: bigint, at: number) => `${tree}:${at}`;\n\n/** Correlate deliveries with canonical insertion events, never service-supplied balances or positions.\n * The caller selects a confirmed chain/deployment and supplies complete decoded receipts.\n */\nexport function extractDeliveryCandidates(\n logs: readonly DeliveryEventLog[],\n context: DiscoveryContext,\n confirmedThrough: bigint\n): DeliveryCandidate[] {\n contextCheck(context);\n check(confirmedThrough >= 0n, \"invalid confirmed height\");\n const relevant = logs.filter(\n (log) =>\n log.address.toLowerCase() === context.protocolAddress.toLowerCase() &&\n EVENTS.has(log.eventName)\n );\n const insertions = new Map<string, Hex>();\n const metadata = (log: DeliveryEventLog) => {\n check(!log.removed, \"discovery resync required after reorg\");\n check(\n typeof log.blockNumber === \"bigint\" &&\n log.blockNumber >= 0n &&\n log.blockNumber <= confirmedThrough,\n \"event is not confirmed\"\n );\n check(Number.isSafeInteger(log.logIndex) && log.logIndex! >= 0, \"invalid log position\");\n return {\n blockNumber: log.blockNumber,\n blockHash: hash(log.blockHash),\n transactionHash: hash(log.transactionHash),\n };\n };\n const insertionKey = (log: DeliveryEventLog, tree: bigint, at: number) =>\n `${hash(log.transactionHash)}:${position(tree, at)}`;\n for (const log of relevant) {\n metadata(log);\n if (log.eventName !== \"CommitmentsInserted\" && log.eventName !== \"BatchOutputs\") continue;\n const a = object(log.args),\n tree = integer(a.treeId),\n start = index(a.startLeafIndex),\n leaves = array(a.commitments);\n check(tree > 0n && tree < 1n << 64n, \"invalid insertion tree\");\n check(start + leaves.length <= 65536, \"insertion exceeds tree capacity\");\n for (const [i, leaf] of leaves.entries()) {\n const key = insertionKey(log, tree, start + i),\n value = hash(leaf),\n previous = insertions.get(key);\n check(!previous || previous === value, \"conflicting insertion events\");\n insertions.set(key, value);\n }\n }\n const results = new Map<string, DeliveryCandidate>();\n const add = (\n log: DeliveryEventLog,\n tree: bigint,\n at: number,\n commitment: unknown,\n role: DeliveryCandidate[\"role\"],\n wire: unknown,\n token: unknown = log.args?.token ??\n (log.args?.params as { token?: unknown; creation?: { token?: unknown } } | undefined)\n ?.token ??\n (log.args?.params as { creation?: { token?: unknown } } | undefined)?.creation?.token\n ) => {\n check(tree > 0n && tree < 1n << 64n, \"invalid output tree\");\n const inserted = insertions.get(insertionKey(log, tree, at));\n check(inserted, \"delivery has no matching canonical insertion\");\n if (commitment !== undefined)\n check(hash(commitment) === inserted, \"delivery commitment conflicts with insertion\");\n const delivery = normalizeDelivery(wire as never, { credit: role !== \"funds\" });\n check(\n typeof token === \"string\" && isAddress(token) && BigInt(token) !== 0n,\n \"invalid event token\"\n );\n const value = {\n tokenAddress: token as Address,\n treeId: tree,\n leafIndex: at,\n commitment: inserted,\n role,\n delivery,\n ...metadata(log),\n };\n const key = `${insertionKey(log, tree, at)}:${role}`,\n previous = results.get(key);\n check(\n !previous ||\n (previous.tokenAddress.toLowerCase() === token.toLowerCase() &&\n previous.delivery.ciphertext === delivery.ciphertext &&\n previous.delivery.clue === delivery.clue &&\n previous.blockHash === value.blockHash),\n \"conflicting delivery events\"\n );\n results.set(key, value);\n };\n const creation = (\n log: DeliveryEventLog,\n a: Record<string, unknown>,\n fields: Record<string, unknown>\n ) => {\n const tree = integer(a.outputTreeId),\n leaves = array(a.leafIndices),\n ds = array(a.deliveries);\n const change = hash(fields.changeCommitment),\n hasChange = BigInt(change) !== 0n;\n check(\n ds.length === 3 && leaves.length === (hasChange ? 2 : 1),\n \"invalid Credit creation delivery slots\"\n );\n add(log, tree, index(leaves[0]), fields.creditCommitment, \"owner\", ds[0]);\n add(log, tree, index(leaves[0]), fields.creditCommitment, \"spender\", ds[1]);\n if (hasChange) add(log, tree, index(leaves[1]), change, \"funds\", ds[2]);\n else normalizeDelivery(ds[2] as never, { empty: true });\n };\n for (const log of relevant) {\n const a = object(log.args);\n if (log.eventName === \"Shield\") {\n const ds = array(a.deliveries),\n tree = integer(a.treeId),\n start = index(a.startLeafIndex);\n check(start + ds.length <= 65536, \"shield exceeds tree capacity\");\n ds.forEach((d, i) => add(log, tree, start + i, undefined, \"funds\", d));\n } else if (log.eventName === \"Transact\" || log.eventName === \"CrossTreeTransact\") {\n const cs = array(a.outputCommitments),\n ds = array(a.deliveries),\n leaves = array(a.leafIndices),\n tree = integer(a.outputTreeId);\n check(\n cs.length === ds.length && cs.length === leaves.length,\n \"invalid transact delivery slots\"\n );\n cs.forEach((c, i) => add(log, tree, index(leaves[i]), c, \"funds\", ds[i]));\n } else if (log.eventName === \"BatchOutputs\") {\n const tokens = array(a.tokens);\n const cs = array(a.commitments),\n tree = integer(a.treeId),\n start = index(a.startLeafIndex),\n packed = a.packedDeliveries;\n check(\n typeof packed === \"string\" && /^0x(?:[0-9a-fA-F]{2})*$/.test(packed),\n \"invalid packed deliveries\"\n );\n check(tokens.length === cs.length, \"batch token count mismatch\");\n check(start + cs.length <= 65536, \"batch exceeds tree capacity\");\n let offset = 2;\n cs.forEach((c, i) => {\n check(offset + 4 <= packed.length, \"truncated delivery length prefix\");\n const length = Number.parseInt(packed.slice(offset, offset + 4), 16);\n offset += 4;\n check(\n length >= 160 && length <= 416 && offset + length * 2 + 136 <= packed.length,\n \"invalid packed delivery length\"\n );\n const ciphertext = `0x${packed.slice(offset, offset + length * 2)}`;\n offset += length * 2;\n const clue = `0x${packed.slice(offset, offset + 136)}`;\n offset += 136;\n add(log, tree, start + i, c, \"funds\", { ciphertext, clue }, tokens[i]);\n });\n check(offset === packed.length, \"trailing packed delivery bytes\");\n } else if (log.eventName === \"CreditCreated\") creation(log, a, a);\n else if (log.eventName === \"CreditToppedUp\")\n creation(log, a, object(object(a.params).creation));\n else if (log.eventName === \"CreditDraw\") {\n const p = object(a.params),\n cs = array(p.remainderCommitments),\n ds = array(a.deliveries),\n leaves = array(a.remainderLeafIndices),\n tree = integer(a.outputTreeId);\n check(\n ds.length === 2 * cs.length && leaves.length === cs.length,\n \"invalid draw delivery slots\"\n );\n cs.forEach((c, i) => {\n if (BigInt(hash(c)) === 0n) {\n check(integer(leaves[i]) === 0n, \"absent remainder has nonzero position\");\n normalizeDelivery(ds[2 * i] as never, { empty: true });\n normalizeDelivery(ds[2 * i + 1] as never, { empty: true });\n } else {\n add(log, tree, index(leaves[i]), c, \"owner\", ds[2 * i]);\n add(log, tree, index(leaves[i]), c, \"spender\", ds[2 * i + 1]);\n }\n });\n }\n }\n return [...results.values()];\n}\nexport interface DiscoveredNote extends Omit<DeliveryCandidate, \"delivery\" | \"role\"> {\n note: Note;\n}\nexport interface DiscoveredCredit extends Omit<DeliveryCandidate, \"delivery\"> {\n role: \"owner\" | \"spender\";\n state: CreditDeliveryState;\n}\n/** Authenticate private deliveries from a single batch of canonical receipts. */\nexport async function decryptCandidates(\n logs: readonly DeliveryEventLog[],\n options: {\n context: DiscoveryContext;\n viewing: Pick<ViewingCapability, \"walletIdentity\" | \"decryptNote\" | \"decryptCredit\">;\n confirmedThrough: bigint;\n }\n): Promise<{ notes: DiscoveredNote[]; credits: DiscoveredCredit[] }> {\n contextCheck(options.context);\n decodeAddress(ReceivingAddress.fromIdentity(options.viewing.walletIdentity).toString());\n check(\n !logs.some(\n (log) =>\n log.address.toLowerCase() === options.context.protocolAddress.toLowerCase() &&\n log.removed\n ),\n \"discovery resync required after reorg\"\n );\n const candidates = extractDeliveryCandidates(logs, options.context, options.confirmedThrough);\n const positions = new Map<string, DeliveryCandidate>();\n const unique = new Map<string, DeliveryCandidate>();\n for (const candidate of candidates) {\n const key = position(candidate.treeId, candidate.leafIndex);\n const previous = positions.get(key);\n check(\n !previous ||\n (previous.commitment === candidate.commitment &&\n previous.blockHash === candidate.blockHash &&\n previous.transactionHash === candidate.transactionHash &&\n previous.tokenAddress.toLowerCase() === candidate.tokenAddress.toLowerCase()),\n \"conflicting canonical position\"\n );\n positions.set(key, candidate);\n unique.set(`${key}:${candidate.role}`, candidate);\n }\n const notes: DiscoveredNote[] = [];\n const credits: DiscoveredCredit[] = [];\n for (const candidate of unique.values()) {\n const { delivery, role, ...positionData } = candidate;\n const context = {\n chainId: options.context.chainId,\n protocolAddress: BigInt(options.context.protocolAddress),\n tokenAddress: BigInt(candidate.tokenAddress),\n outputCommitment: candidate.commitment,\n };\n // Non-recipient ciphertexts and failed authentication are normal scan outcomes.\n try {\n if (role === \"funds\") {\n const note = await options.viewing.decryptNote(delivery.ciphertext, context);\n notes.push({ ...positionData, note });\n } else {\n const state = await options.viewing.decryptCredit(delivery.ciphertext, {\n ...context,\n role,\n });\n credits.push({ ...positionData, role, state });\n }\n } catch {\n /* Unrelated or invalid output: never add unauthenticated amounts. */\n }\n }\n return { notes, credits };\n}\n","import type { Provider } from \"ethers\";\nimport { EthersChainReader } from \"../integrations/ethers\";\nimport type { Hex } from \"@invisi-labs/protocol/contracts\";\nimport { readProtocolLogs } from \"./receipt-logs\";\n\nimport { Disclosure, type DisclosureOutput, type DisclosureResult } from \"@invisi-labs/core\";\nimport { TokenProtocol, type CanonicalBlock, type ChainReader } from \"@invisi-labs/protocol\";\nimport { extractDeliveryCandidates } from \"./discovery\";\n\nexport interface DisclosureReference {\n transactionHash: Hex;\n treeId: bigint;\n leafIndex: number;\n role: \"funds\" | \"owner\" | \"spender\";\n}\n\nexport type DisclosureReader = Pick<\n ChainReader,\n \"getChainId\" | \"getCode\" | \"getReceipt\" | \"getBlock\" | \"getLatestBlockNumber\"\n>;\n\nexport interface DisclosureVerifierOptions {\n protocol: TokenProtocol;\n reader: DisclosureReader;\n /** Minimum confirmations including the inclusion block; defaults to one. */\n confirmations?: number;\n}\n\nexport interface DisclosureEvidence {\n reference: Readonly<DisclosureReference>;\n block: Readonly<CanonicalBlock>;\n confirmations: bigint;\n output: Readonly<DisclosureOutput>;\n}\n\nexport interface VerifiedDisclosure {\n result: DisclosureResult;\n block: Readonly<CanonicalBlock>;\n confirmations: bigint;\n output: Readonly<DisclosureReference & { commitment: Hex }>;\n}\n\nfunction check(value: unknown, message: string): asserts value {\n if (!value) throw new Error(message);\n}\n\nfunction reference(value: DisclosureReference): DisclosureReference {\n check(/^0x[0-9a-fA-F]{64}$/.test(value.transactionHash), \"invalid disclosure transaction hash\");\n check(\n typeof value.treeId === \"bigint\" && value.treeId > 0n && value.treeId < 1n << 64n,\n \"invalid disclosure tree ID\"\n );\n check(\n Number.isSafeInteger(value.leafIndex) && value.leafIndex >= 0 && value.leafIndex < 65536,\n \"invalid disclosure leaf index\"\n );\n check([\"funds\", \"owner\", \"spender\"].includes(value.role), \"invalid disclosure reference role\");\n return {\n transactionHash: value.transactionHash.toLowerCase() as Hex,\n treeId: value.treeId,\n leafIndex: value.leafIndex,\n role: value.role,\n };\n}\n\n/** Read-only verification against a trusted RPC and authenticated protocol deployment.\n * Results establish output content/inclusion at a block, not payer identity, spent state or wallet completeness.\n */\nexport class DisclosureVerifier {\n readonly #protocol: TokenProtocol;\n readonly #reader: DisclosureReader;\n readonly #confirmations: bigint;\n\n constructor(\n options:\n | DisclosureVerifierOptions\n | (Omit<DisclosureVerifierOptions, \"reader\"> & { provider: Provider })\n ) {\n const confirmations = options.confirmations ?? 1;\n check(\n Number.isSafeInteger(confirmations) && confirmations >= 1,\n \"invalid disclosure confirmations\"\n );\n this.#protocol = options.protocol;\n this.#reader =\n \"provider\" in options ? new EthersChainReader(options.provider) : options.reader;\n this.#confirmations = BigInt(confirmations);\n Object.freeze(this);\n }\n\n private async barrier(block: Readonly<CanonicalBlock>): Promise<bigint> {\n await this.#protocol.validateDeployment(this.#reader);\n const canonical = await this.#reader.getBlock(block.number);\n check(\n canonical.number === block.number &&\n canonical.hash.toLowerCase() === block.hash.toLowerCase(),\n \"disclosure canonical block changed; reorg verification required\"\n );\n const head = await this.#reader.getLatestBlockNumber();\n check(\n head >= block.number && head - block.number + 1n >= this.#confirmations,\n \"insufficient disclosure confirmations\"\n );\n check(\n (await this.#reader.getChainId()) === this.#protocol.context.chainId,\n \"disclosure chain changed during verification\"\n );\n return head - block.number + 1n;\n }\n\n /** Resolve the exact inserted output and its delivery from a successful canonical receipt. */\n async readOutput(value: DisclosureReference): Promise<DisclosureEvidence> {\n const selected = reference(value);\n await this.#protocol.validateDeployment(this.#reader);\n const received = await this.#reader.getReceipt(selected.transactionHash);\n check(received, \"disclosure transaction receipt is unavailable\");\n const receipt = structuredClone(received);\n check(receipt.status === \"success\", \"disclosure requires a successful transaction receipt\");\n check(\n receipt.transactionHash.toLowerCase() === selected.transactionHash,\n \"disclosure receipt transaction mismatch\"\n );\n check(\n typeof receipt.block.number === \"bigint\" &&\n receipt.block.number >= 0n &&\n /^0x[0-9a-fA-F]{64}$/.test(receipt.block.hash),\n \"invalid disclosure receipt block\"\n );\n const { context } = this.#protocol;\n const logs = readProtocolLogs(receipt, context.protocolAddress);\n const candidates = extractDeliveryCandidates(logs, context, receipt.block.number).filter(\n (candidate) =>\n candidate.treeId === selected.treeId &&\n candidate.leafIndex === selected.leafIndex &&\n candidate.role === selected.role &&\n candidate.tokenAddress.toLowerCase() === context.tokenAddress.toLowerCase()\n );\n check(\n candidates.length === 1,\n \"disclosure output has no unique canonical insertion and delivery\"\n );\n const candidate = candidates[0]!;\n const confirmations = await this.barrier(receipt.block);\n return Object.freeze({\n reference: Object.freeze(selected),\n block: Object.freeze({ ...receipt.block }),\n confirmations,\n output: Object.freeze({\n chainId: context.chainId,\n protocolAddress: BigInt(context.protocolAddress),\n tokenAddress: BigInt(context.tokenAddress),\n outputCommitment: candidate.commitment,\n role: selected.role,\n ciphertext: candidate.delivery.ciphertext,\n }),\n });\n }\n\n async verify(disclosure: Disclosure, value: DisclosureReference): Promise<VerifiedDisclosure> {\n const evidence = await this.readOutput(value);\n const result = await disclosure.verify(evidence.output);\n const confirmations = await this.barrier(evidence.block);\n return Object.freeze({\n result: Object.freeze(result),\n block: evidence.block,\n confirmations,\n output: Object.freeze({\n ...evidence.reference,\n commitment: evidence.output.outputCommitment,\n }),\n });\n }\n\n toJSON() {\n return { disclosureVerifier: true, confirmations: this.#confirmations.toString() };\n }\n\n [Symbol.for(\"nodejs.util.inspect.custom\")]() {\n return this.toJSON();\n }\n}\n","import { FIELD_MODULUS, normalizeCreditDeliveryState } from \"@invisi-labs/core\";\nimport { sha256 } from \"@noble/hashes/sha256\";\nimport { bytesToHex, utf8ToBytes } from \"@noble/hashes/utils\";\nimport type { WalletScope, WalletState, WalletStore } from \"./state\";\nimport { creditReservationKey } from \"./state\";\nexport function scopeKey(scope: WalletScope): string {\n if (\n typeof scope.namespace !== \"string\" ||\n !scope.namespace.length ||\n scope.namespace.length > 256\n )\n throw new Error(\"invalid wallet namespace\");\n if (typeof scope.chainId !== \"bigint\" || scope.chainId < 0n || scope.chainId >= 1n << 64n)\n throw new Error(\"invalid scope chain\");\n for (const address of [scope.protocolAddress])\n if (!/^0x[0-9a-fA-F]{40}$/.test(address) || BigInt(address) === 0n)\n throw new Error(\"invalid scope deployment\");\n if (\n !/^0x[0-9a-fA-F]{40}$/.test(scope.walletIdentity) ||\n BigInt(scope.walletIdentity) <= 0n ||\n BigInt(scope.walletIdentity) >= 1n << 160n\n )\n throw new Error(\"invalid scope wallet\");\n return bytesToHex(\n sha256(\n utf8ToBytes(\n \"Invisi.WalletScope.v2:\" +\n JSON.stringify([\n scope.namespace,\n scope.chainId.toString(),\n scope.protocolAddress.toLowerCase(),\n scope.walletIdentity.toLowerCase(),\n ])\n )\n )\n );\n}\nexport function initialState(scope: WalletScope): WalletState {\n scopeKey(scope);\n return {\n schemaVersion: 1,\n scope: { ...scope },\n revision: 0,\n notes: {},\n credits: {},\n reservations: {},\n operations: {},\n };\n}\nexport function validateState(state: WalletState, scope: WalletScope, revision: number): void {\n if (\n !state ||\n state.schemaVersion !== 1 ||\n scopeKey(state.scope) !== scopeKey(scope) ||\n state.revision !== revision\n )\n throw new Error(\"wallet state scope/schema/revision mismatch\");\n if (!Number.isSafeInteger(revision) || revision < 0)\n throw new Error(\"invalid wallet state revision\");\n for (const field of [state.notes, state.credits, state.reservations, state.operations])\n if (!field || typeof field !== \"object\" || Array.isArray(field))\n throw new Error(\"invalid wallet state records\");\n for (const record of Object.values(state.notes)) {\n if (\n typeof record.note.tokenAddress !== \"bigint\" ||\n record.note.tokenAddress <= 0n ||\n record.note.tokenAddress >= 1n << 160n ||\n record.note.chainId !== scope.chainId ||\n record.note.protocolAddress !== BigInt(scope.protocolAddress) ||\n record.note.walletIdentity.toLowerCase() !== scope.walletIdentity.toLowerCase() ||\n typeof record.note.amount !== \"bigint\" ||\n record.note.amount <= 0n ||\n record.note.amount >= 1n << 128n\n )\n throw new Error(\"invalid stored note context or amount\");\n if (![\"unspent\", \"unknown\", \"spent\"].includes(record.spent))\n throw new Error(\"invalid spent state\");\n }\n for (const record of Object.values(state.credits)) {\n const note = normalizeCreditDeliveryState(record.state).note;\n if (\n note.chainId !== scope.chainId ||\n note.protocolAddress !== BigInt(scope.protocolAddress) ||\n ![\"owner\", \"spender\"].includes(record.role) ||\n (record.role === \"owner\"\n ? note.ownerWalletIdentity\n : note.spenderWalletIdentity\n ).toLowerCase() !== scope.walletIdentity.toLowerCase() ||\n ![\"unspent\", \"unknown\", \"spent\"].includes(record.spent)\n )\n throw new Error(\"invalid stored Credit context or role\");\n }\n for (const record of [...Object.values(state.notes), ...Object.values(state.credits)]) {\n if (\n !/^0x[0-9a-fA-F]{64}$/.test(record.commitment) ||\n BigInt(record.commitment) <= 0n ||\n BigInt(record.commitment) >= FIELD_MODULUS ||\n typeof record.treeId !== \"bigint\" ||\n record.treeId < 1n ||\n record.treeId >= 1n << 64n ||\n !Number.isInteger(record.leafIndex) ||\n record.leafIndex < 0 ||\n record.leafIndex >= 65536 ||\n typeof record.blockNumber !== \"bigint\" ||\n record.blockNumber < 0n ||\n !/^0x[0-9a-fA-F]{64}$/.test(record.blockHash)\n )\n throw new Error(\"invalid stored receipt position\");\n }\n for (const [id, operation] of Object.entries(state.reservations))\n if (\n !state.operations[operation] ||\n (!state.notes[id] &&\n !Object.values(state.credits).some(\n (record) => creditReservationKey(record.commitment) === id\n ) &&\n ![\"submitted\", \"uncertain\", \"reorged\"].includes(\n state.operations[operation]!.status\n ))\n )\n throw new Error(\"orphan input reservation\");\n}\n/** A stored encrypted blob and its CAS revision. No private state is exposed to adapters. */\nexport interface AtomicRecord {\n revision: number;\n data: Uint8Array;\n}\nexport interface AtomicRecordStore {\n read(key: string): Promise<AtomicRecord | undefined>;\n compareAndSwap(key: string, previousRevision: number, next: AtomicRecord): Promise<boolean>;\n}\nexport interface WalletRecordCodec {\n encode(value: WalletState, context: { key: string; revision: number }): Promise<Uint8Array>;\n decode(data: Uint8Array, context: { key: string; revision: number }): Promise<WalletState>;\n}\nexport class TransactionalWalletStore implements WalletStore {\n readonly persistent: boolean;\n readonly #records: AtomicRecordStore;\n readonly #codec: WalletRecordCodec;\n constructor(\n records: AtomicRecordStore,\n codec: WalletRecordCodec,\n options: { persistent: boolean }\n ) {\n this.#records = records;\n this.#codec = codec;\n this.persistent = options.persistent;\n }\n async readSnapshot(scope: WalletScope): Promise<WalletState> {\n const key = scopeKey(scope),\n record = await this.#records.read(key);\n if (!record) return initialState(scope);\n const state = await this.#codec.decode(record.data, { key, revision: record.revision });\n validateState(state, scope, record.revision);\n return state;\n }\n async transaction<T>(scope: WalletScope, action: (draft: WalletState) => T): Promise<T> {\n if (action.constructor.name === \"AsyncFunction\")\n throw new Error(\"wallet transaction action must be synchronous\");\n const copied = { ...scope },\n key = scopeKey(copied);\n for (let attempt = 0; attempt < 100; attempt++) {\n const draft = await this.readSnapshot(copied),\n previous = draft.revision;\n const result = action(draft);\n if (result && typeof result === \"object\" && \"then\" in result) {\n Promise.resolve(result).catch(() => {});\n throw new Error(\"wallet transaction action must be synchronous\");\n }\n validateState(draft, copied, previous);\n if (!Number.isSafeInteger(previous + 1))\n throw new Error(\"wallet state revision exhausted\");\n draft.revision = previous + 1;\n const data = await this.#codec.encode(draft, { key, revision: draft.revision });\n if (\n await this.#records.compareAndSwap(key, previous, {\n revision: draft.revision,\n data,\n })\n )\n return result;\n }\n throw new Error(\"wallet transaction contention limit exceeded\");\n }\n toJSON() {\n return { walletStore: true, persistent: this.persistent };\n }\n [Symbol.for(\"nodejs.util.inspect.custom\")]() {\n return this.toJSON();\n }\n}\n/** Explicitly nonpersistent reference storage; data never leaves this process. */\nexport class MemoryAtomicRecords implements AtomicRecordStore {\n readonly #values = new Map<string, AtomicRecord>();\n async read(key: string): Promise<AtomicRecord | undefined> {\n const value = this.#values.get(key);\n return value ? { revision: value.revision, data: Uint8Array.from(value.data) } : undefined;\n }\n async compareAndSwap(\n key: string,\n previousRevision: number,\n next: AtomicRecord\n ): Promise<boolean> {\n if ((this.#values.get(key)?.revision ?? 0) !== previousRevision) return false;\n this.#values.set(key, { revision: next.revision, data: Uint8Array.from(next.data) });\n return true;\n }\n}\n","import { verifyTypedData } from \"ethers\";\nimport {\n computeWalletAuthorizationDigest,\n type AuthorizedStatement,\n type WalletAuthorizationProvider,\n} from \"@invisi-labs/core\";\nimport type { TokenProtocol } from \"@invisi-labs/protocol\";\nimport type { Prover, ProverOptions } from \"@invisi-labs/prover\";\nimport type {\n FundingAuthorizationVerifier,\n FundingSigner,\n OperationPlan,\n SavedOperation,\n} from \"./operation-types\";\nimport {\n authorizationRequest,\n fundingTypedData,\n publicProof,\n witnessFor,\n} from \"./operation-protocol\";\nimport { sameStatement } from \"./proof-integrity\";\n\n/** Both managed and detached handles authorize the same frozen statement. */\nexport async function authorizeOperation(\n plan: OperationPlan,\n provider: WalletAuthorizationProvider\n) {\n if (provider.walletIdentity !== plan.scope.walletIdentity)\n throw new Error(\"wallet authorization capability mismatch\");\n const request = authorizationRequest(plan);\n const digest = computeWalletAuthorizationDigest(request);\n const signed = await provider.authorize(structuredClone(request));\n if (signed.walletIdentity !== plan.scope.walletIdentity || signed.digest !== digest)\n throw new Error(\"wallet authorization statement mismatch\");\n return signed;\n}\n\nexport async function proveOperation(\n protocol: TokenProtocol,\n plan: OperationPlan,\n authorization: AuthorizedStatement | undefined,\n prover: Prover,\n options: ProverOptions\n) {\n const request = await witnessFor(protocol, plan, authorization);\n if (JSON.stringify({ ...request, witness: undefined }) !== JSON.stringify(plan.statement))\n throw new Error(\"prepared proof statement changed\");\n try {\n const proof = publicProof(await prover.prove(request, options));\n sameStatement(proof, plan.statement!);\n if (\n (await prover.verify(\n structuredClone(proof),\n structuredClone(plan.statement!),\n options\n )) !== true\n )\n throw new Error(\"proof verification failed\");\n return proof;\n } catch {\n options.signal?.throwIfAborted();\n throw new Error(\"operation proof generation or verification failed\");\n }\n}\n\nexport async function signOperationFunding(\n saved: SavedOperation,\n signer: FundingSigner,\n verifier?: FundingAuthorizationVerifier\n) {\n const payer = saved.plan.funding.payer!;\n if (signer.address.toLowerCase() !== payer.toLowerCase())\n throw new Error(\"funding signer is not the payer\");\n const typed = await fundingTypedData(saved);\n const signature = await signer.signTypedData(structuredClone(typed));\n const valid = verifier\n ? await verifier.verifyTypedData({\n ...structuredClone(typed),\n address: payer,\n signature,\n })\n : verifyTypedData(\n typed.domain,\n Object.fromEntries(\n Object.entries(typed.types).map(([name, fields]) => [name, [...fields]])\n ),\n typed.message,\n signature\n ).toLowerCase() === payer.toLowerCase();\n if (valid !== true) throw new Error(\"invalid EVM funding signature\");\n return signature;\n}\n","import type { ProofBundle, ProofStatement } from \"@invisi-labs/prover\";\nimport { getBytes } from \"ethers\";\nimport { sha256 } from \"@noble/hashes/sha256\";\nimport { bytesToHex } from \"@noble/hashes/utils\";\nfunction check(ok: unknown, message: string): asserts ok {\n if (!ok) throw new Error(message);\n}\nexport function sameStatement(proof: ProofBundle, expected: ProofStatement): void {\n check(\n proof.formatVersion === 1 &&\n proof.bbVersion === \"6.0.0\" &&\n proof.circuitName === expected.circuitName &&\n proof.target === expected.target &&\n proof.artifactSha256 === expected.artifactSha256 &&\n proof.vkSha256 === expected.vkSha256,\n \"proof release/target mismatch\"\n );\n check(\n proof.publicInputs.length === expected.expectedPublicInputs.length &&\n proof.publicInputs.every((word, i) => word === expected.expectedPublicInputs[i]),\n \"proof public statement mismatch\"\n );\n check(\n /^0x(?:[a-fA-F0-9]{2})+$/.test(proof.proofHex) &&\n bytesToHex(sha256(getBytes(proof.proofHex))) === proof.proofSha256,\n \"proof integrity mismatch\"\n );\n}\n","import type { OperationPlan } from \"./operation-types\";\nimport type { OperationStatus } from \"./state\";\nimport { inputFacts, requiresAuthorization } from \"./operation-protocol\";\nexport function operationPreview(plan: OperationPlan, status: OperationStatus) {\n const p = plan;\n return {\n id: p.id,\n kind: p.kind,\n status,\n context: { ...p.context },\n inputs: inputFacts(p).length,\n creditOutputs: p.credit?.outputs.map((output) => ({\n amount: output.state.note.amount,\n expiry: output.state.note.expiry,\n owner: output.state.note.ownerWalletIdentity,\n spender: output.state.note.spenderWalletIdentity,\n ownerPayout: output.state.note.ownerPayout,\n spenderPayout: output.state.note.spenderPayout,\n })),\n outputs: p.outputs.map((output) => ({\n to: output.address,\n amount: output.note.amount,\n change: output.change,\n })),\n capacity: p.capacity,\n deadline: p.deadline,\n fundingAmount: p.funding.amount ?? 0n,\n fundingPayer: p.funding.payer,\n withdrawalAmount:\n p.params?.withdrawalAmount ??\n p.credit?.draw?.totalAmount ??\n p.credit?.cancel?.amount ??\n 0n,\n withdrawalAddress:\n p.params?.withdrawalAddress ?? p.credit?.draw?.spender ?? p.credit?.cancel?.owner,\n permissions: {\n walletAuthorization: requiresAuthorization(p),\n proof: p.kind !== \"shield\",\n fundingAuthorization: p.fundingMode === \"signature\",\n },\n };\n}\n","import { estimateGasReference } from \"../gas-estimation\";\nimport { authorizeOperation, proveOperation, signOperationFunding } from \"./operation-execution\";\nimport { operationPreview } from \"./operation-preview\";\nimport type { Hex } from \"@invisi-labs/protocol/contracts\";\n\nimport { MissingCapabilityError, type AuthorizedStatement } from \"@invisi-labs/core\";\nimport { normalizeFunding, type TransactionCall } from \"@invisi-labs/protocol\";\nimport type { ProofBundle, ProofStatement, ProverOptions } from \"@invisi-labs/prover\";\nimport { sameStatement } from \"./proof-integrity\";\nimport { confirmOperation, reconcileOperation } from \"./operation-confirmation\";\nimport {\n encodeOperation,\n inputFacts,\n operationExpired,\n operationSources,\n publicProof,\n requiresAuthorization,\n statement,\n} from \"./operation-protocol\";\nimport type {\n OperationAggregateMember,\n OperationPlan,\n OperationRuntime,\n SavedOperation,\n} from \"./operation-types\";\nimport type { OperationRecord, OperationStatus } from \"./state\";\nimport { scopeKey } from \"./store\";\n\nfunction check(ok: unknown, message: string): asserts ok {\n if (!ok) {\n throw new Error(message);\n }\n}\n\n/** Immutable operation handle. No private plan, witness, or transaction is logged implicitly. */\nexport class Operation {\n readonly #runtime: OperationRuntime;\n readonly #saved: SavedOperation;\n readonly #authorization: AuthorizedStatement | undefined;\n readonly status: OperationStatus;\n\n private constructor(\n runtime: OperationRuntime,\n saved: SavedOperation,\n status: OperationStatus,\n authorization?: AuthorizedStatement\n ) {\n this.#runtime = runtime;\n this.#saved = structuredClone(saved);\n this.status = status;\n this.#authorization = authorization;\n Object.freeze(this);\n }\n\n static async prepare(runtime: OperationRuntime, plan: OperationPlan): Promise<Operation> {\n const saved: SavedOperation = { plan: structuredClone(plan), generation: 0 };\n await runtime.store.transaction(runtime.scope, (state) => {\n check(!state.invalidated, \"wallet state requires canonical resync\");\n check(!state.operations[plan.id], \"operation already exists\");\n const facts = inputFacts(plan);\n for (const input of facts) {\n const record = state[input.kind][input.key];\n check(\n record &&\n record.spent === \"unspent\" &&\n !state.reservations[input.reservationKey],\n \"input unavailable or already reserved\"\n );\n }\n state.operations[plan.id] = {\n id: plan.id,\n status: \"prepared\",\n inputs: facts.map((input) => input.reservationKey),\n deadline: plan.deadline,\n payload: saved,\n };\n for (const input of facts) {\n state.reservations[input.reservationKey] = plan.id;\n }\n });\n return new Operation(runtime, saved, \"prepared\");\n }\n\n static async resume(runtime: OperationRuntime, id: string): Promise<Operation> {\n const result = await runtime.store.transaction(runtime.scope, (state) => {\n const record = state.operations[id];\n check(record, \"unknown operation\");\n const saved = record.payload as SavedOperation;\n check(\n saved?.plan?.version === 1 &&\n saved.plan.id === id &&\n Number.isSafeInteger(saved.generation) &&\n saved.generation >= 0 &&\n saved.generation < Number.MAX_SAFE_INTEGER,\n \"invalid operation payload\"\n );\n const context = runtime.options.protocol.context;\n const actual = saved.plan.context;\n check(\n scopeKey(saved.plan.scope) === scopeKey(runtime.scope) &&\n actual.chainId === context.chainId &&\n actual.protocolAddress.toLowerCase() ===\n context.protocolAddress.toLowerCase() &&\n actual.tokenAddress.toLowerCase() === context.tokenAddress.toLowerCase(),\n \"recovered operation scope/deployment context mismatch\"\n );\n if (saved.plan.kind !== \"shield\") {\n statement(saved.plan);\n }\n if (saved.proof) {\n sameStatement(saved.proof, saved.plan.statement!);\n }\n // Explicit recovery fences any former worker. Signing material is never restored from storage.\n saved.generation++;\n delete saved.claim;\n return new Operation(runtime, saved, record.status);\n });\n if (result.#saved.call) {\n const expected = await result.encode(result.#saved);\n check(\n expected.to === result.#saved.call.to &&\n expected.value === result.#saved.call.value &&\n expected.data === result.#saved.call.data,\n \"recovered transaction differs from frozen operation\"\n );\n }\n return result;\n }\n\n get id(): string {\n return this.#saved.plan.id;\n }\n\n get kind(): OperationPlan[\"kind\"] {\n return this.#saved.plan.kind;\n }\n\n estimateGas() {\n return estimateGasReference(\n this.#saved.plan,\n this.#runtime.options.protocol,\n this.#runtime.options.gasBenchmarks\n );\n }\n preview() {\n return operationPreview(this.#saved.plan, this.status);\n }\n\n private current(record: OperationRecord | undefined): SavedOperation {\n check(record, \"unknown operation\");\n const saved = record.payload as SavedOperation;\n check(\n saved.generation === this.#saved.generation && !saved.claim,\n \"stale operation handle or active worker; recover the operation\"\n );\n return saved;\n }\n\n private async stage(\n stage: string,\n allowed: OperationStatus[],\n work: (\n saved: SavedOperation\n ) => Promise<{ status: OperationStatus; authorization?: AuthorizedStatement }>,\n signal?: AbortSignal\n ): Promise<Operation> {\n signal?.throwIfAborted();\n const { store, scope } = this.#runtime;\n const token = crypto.randomUUID();\n const saved = await store.transaction(scope, (state) => {\n check(!state.invalidated, \"wallet requires canonical resync\");\n const record = state.operations[this.id];\n const current = this.current(record);\n check(allowed.includes(record!.status), `invalid operation stage for ${stage}`);\n current.generation++;\n current.claim = { stage, token };\n return structuredClone(current);\n });\n try {\n const next = await work(saved);\n signal?.throwIfAborted();\n await store.transaction(scope, (state) => {\n check(!state.invalidated, \"wallet invalidated during operation\");\n const record = state.operations[this.id];\n const current = record?.payload as SavedOperation;\n check(\n record &&\n current?.generation === saved.generation &&\n current.claim?.token === token &&\n allowed.includes(record.status),\n \"stale operation worker after recovery\"\n );\n delete saved.claim;\n record.status = next.status;\n record.payload = structuredClone(saved);\n });\n return new Operation(\n this.#runtime,\n saved,\n next.status,\n next.authorization ?? this.#authorization\n );\n } catch (error) {\n await store.transaction(scope, (state) => {\n const current = state.operations[this.id]?.payload as SavedOperation | undefined;\n if (current?.claim?.token === token) {\n delete current.claim;\n }\n });\n throw error;\n }\n }\n\n async authorize(options: { signal?: AbortSignal } = {}): Promise<Operation> {\n check(\n requiresAuthorization(this.#saved.plan),\n \"operation does not require wallet authorization\"\n );\n const provider = this.#runtime.authorization();\n check(\n provider.walletIdentity === this.#runtime.scope.walletIdentity,\n \"wallet authorization capability mismatch\"\n );\n return this.stage(\n \"wallet authorization\",\n [\"prepared\", \"authorized\"],\n async (saved) => {\n const authorization = await authorizeOperation(saved.plan, provider);\n return { status: \"authorized\", authorization };\n },\n options.signal\n );\n }\n\n async prove(options: ProverOptions = {}): Promise<Operation> {\n const plan = this.#saved.plan;\n check(plan.kind !== \"shield\", \"shield requires no proof\");\n if (requiresAuthorization(plan)) {\n check(\n this.#authorization,\n \"local wallet authorization required; authorize again after recovery\"\n );\n }\n const prover = this.#runtime.options.prover;\n if (!prover) {\n throw new MissingCapabilityError(\"prover\");\n }\n return this.stage(\n \"proof\",\n requiresAuthorization(plan) ? [\"authorized\"] : [\"prepared\"],\n async (saved) => {\n const p = saved.plan;\n saved.proof = await proveOperation(\n this.#runtime.options.protocol,\n p,\n this.#authorization,\n prover,\n options\n );\n if (p.fundingMode === \"signature\") {\n return { status: \"proved\" };\n }\n if (p.statement?.target !== \"noir-recursive\") {\n saved.call = await this.encode(saved);\n }\n return { status: \"ready\" };\n },\n options.signal\n );\n }\n\n private encode(saved: SavedOperation): Promise<TransactionCall> {\n return encodeOperation(saved);\n }\n\n async authorizeFunding(options: { signal?: AbortSignal } = {}): Promise<Operation> {\n const p = this.#saved.plan;\n check(p.fundingMode === \"signature\", \"operation does not require a funding signature\");\n check(p.kind === \"shield\" || this.#saved.proof, \"proof must precede funding authorization\");\n const signer = this.#runtime.options.fundingSigner;\n if (!signer) {\n throw new MissingCapabilityError(\"EVM funding signer\");\n }\n check(\n signer.address.toLowerCase() === p.funding.payer!.toLowerCase(),\n \"funding signer is not the payer\"\n );\n return this.stage(\n \"funding authorization\",\n p.kind === \"shield\" ? [\"prepared\"] : [\"proved\"],\n async (saved) => {\n saved.plan.funding.signature = await signOperationFunding(\n saved,\n signer,\n this.#runtime.options.fundingVerifier\n );\n if (saved.plan.statement?.target !== \"noir-recursive\") {\n saved.call = await this.encode(saved);\n }\n return { status: \"ready\" };\n },\n options.signal\n );\n }\n\n /** Shield caller funding needs no wallet signing or proof; this step only encodes its frozen request. */\n async ready(): Promise<Operation> {\n check(\n this.kind === \"shield\" && this.#saved.plan.fundingMode === \"caller\",\n \"operation needs authorization or proof first\"\n );\n return this.stage(\"encoding\", [\"prepared\"], async (saved) => {\n saved.call = await this.encode(saved);\n return { status: \"ready\" };\n });\n }\n\n private async validateExport(signal?: AbortSignal): Promise<void> {\n signal?.throwIfAborted();\n const { reader, options: runtimeOptions } = this.#runtime;\n await runtimeOptions.protocol.validateDeployment(reader);\n const head = await reader.getBlock(await reader.getLatestBlockNumber());\n const plan = this.#saved.plan;\n check(!operationExpired(plan, head.timestamp), \"operation has expired\");\n if (plan.fundingMode === \"signature\") {\n check(head.timestamp <= (plan.funding.deadline ?? 0n), \"funding authorization expired\");\n check(\n (await reader.getFundingNonce(plan.context, plan.funding.payer!, head)) ===\n plan.funding.sigNonce,\n \"funding nonce changed; prepare again\"\n );\n }\n for (const source of operationSources(plan)) {\n check(\n await reader.isKnownRoot(plan.context, source.treeId, source.merkleRoot, head),\n \"source root is no longer accepted; prepare again\"\n );\n }\n const nullifiers = inputFacts(plan).map((input) => input.nullifier);\n if (nullifiers.length) {\n const spent = await reader.isSpent(plan.context, nullifiers, head);\n check(\n spent.length === nullifiers.length && spent.every((value) => value === false),\n \"input spent or invalid spent response\"\n );\n }\n signal?.throwIfAborted();\n }\n\n async exportTransaction(options: { signal?: AbortSignal } = {}): Promise<TransactionCall> {\n check(\n this.#saved.plan.statement?.target !== \"noir-recursive\",\n \"recursive operations must be exported as aggregate members\"\n );\n await this.validateExport(options.signal);\n const result = await this.#runtime.store.transaction(this.#runtime.scope, (state) => {\n options.signal?.throwIfAborted();\n const record = state.operations[this.id];\n const saved = this.current(record);\n check(record!.status === \"ready\" && saved.call, \"operation is not ready\");\n saved.externalized = true;\n return structuredClone(saved.call);\n });\n return result;\n }\n\n async exportAggregateMember(): Promise<OperationAggregateMember> {\n return this.#runtime.store.transaction(this.#runtime.scope, (state) => {\n const record = state.operations[this.id];\n const saved = this.current(record);\n const plan = saved.plan;\n check(\n [\"ready\", \"uncertain\"].includes(record!.status) &&\n plan.params &&\n saved.proof &&\n plan.statement?.target === \"noir-recursive\" &&\n plan.statement.circuitName === \"transact_user_slots14\",\n \"operation is not a ready recursive slots14 aggregate member\"\n );\n sameStatement(saved.proof, statement(plan));\n check(\n saved.proof.proofHex.length === 2 + 458 * 64,\n \"recursive member proof must have 458 fields\"\n );\n saved.externalized = true;\n return {\n bundle: publicProof(saved.proof),\n statement: structuredClone(plan.statement),\n context: { ...plan.context },\n request: {\n params: structuredClone(plan.params),\n deliveries: plan.outputs.map((output) => structuredClone(output.delivery)),\n funding: normalizeFunding(plan.funding),\n },\n };\n });\n }\n\n async abandon(): Promise<Operation> {\n const saved = await this.#runtime.store.transaction(this.#runtime.scope, (state) => {\n const record = state.operations[this.id];\n const current = this.current(record);\n check(\n !current.externalized,\n \"externalized or broadcast operation requires chain reconciliation\"\n );\n check(\n ![\"confirmed\", \"reorged\"].includes(record!.status),\n \"operation requires chain reconciliation\"\n );\n for (const id of record!.inputs) {\n if (state.reservations[id] === this.id) {\n delete state.reservations[id];\n }\n }\n record!.status = \"failed\";\n current.generation++;\n return structuredClone(current);\n });\n return new Operation(this.#runtime, saved, \"failed\");\n }\n\n /** Record an application-owned signed/broadcast transaction. This never sends or waits. */\n async trackTransaction(transactionHash: string): Promise<Operation> {\n check(/^0x[a-fA-F0-9]{64}$/.test(transactionHash), \"invalid transaction hash\");\n const saved = await this.#runtime.store.transaction(this.#runtime.scope, (state) => {\n check(!state.invalidated, \"wallet requires canonical resync\");\n const record = state.operations[this.id];\n const current = this.current(record);\n check(\n [\"ready\", \"uncertain\", \"submitted\"].includes(record!.status),\n \"operation is not ready\"\n );\n check(\n current.externalized,\n \"export the transaction or aggregate member before tracking\"\n );\n for (const input of record!.inputs) {\n check(state.reservations[input] === this.id, \"operation input reservation lost\");\n }\n current.generation++;\n current.externalized = true;\n record!.transactionHash = transactionHash as Hex;\n // A hash records an association, not proof that a transaction was broadcast or mined.\n record!.status = \"uncertain\";\n return structuredClone(current);\n });\n return new Operation(this.#runtime, saved, \"uncertain\");\n }\n\n async reconcile(\n options: { transactionHash?: Hex; signal?: AbortSignal } = {}\n ): Promise<Operation> {\n options.signal?.throwIfAborted();\n const state = await this.#runtime.store.readSnapshot(this.#runtime.scope);\n const record = state.operations[this.id];\n this.current(record);\n check(!state.invalidated, \"wallet requires canonical resync\");\n const hash = options.transactionHash ?? record!.transactionHash;\n let outcome: { status: OperationStatus; saved: SavedOperation } | undefined;\n if (hash) {\n outcome = await confirmOperation(\n this.#runtime,\n this.id,\n this.#saved.generation,\n hash,\n options.signal\n );\n }\n outcome ??= await reconcileOperation(\n this.#runtime,\n this.id,\n this.#saved.generation,\n options.signal\n );\n return new Operation(this.#runtime, outcome.saved, outcome.status);\n }\n\n toJSON() {\n return { id: this.id, kind: this.kind, status: this.status };\n }\n\n [Symbol.for(\"nodejs.util.inspect.custom\")]() {\n return this.toJSON();\n }\n}\n","import type { Hex } from \"@invisi-labs/protocol/contracts\";\nimport { readProtocolLogs } from \"./receipt-logs\";\n\nimport { computeCreditNullifier } from \"@invisi-labs/core\";\nimport type { CanonicalBlock, CanonicalReceipt } from \"@invisi-labs/protocol\";\nimport { matchesAggregateTransaction } from \"./aggregate-receipt\";\nimport { creditLeaf } from \"./credit-values\";\nimport { extractDeliveryCandidates } from \"./discovery\";\nimport { verifyMembership } from \"./membership\";\nimport { inputFacts, operationExpired } from \"./operation-protocol\";\nimport type { OperationRuntime, SavedOperation } from \"./operation-types\";\nimport { mergeReceiptRecords, mergeSpentObservation } from \"./receipts\";\nimport type { OperationStatus, StoredCredit, StoredNote, WalletState } from \"./state\";\n\nfunction check(ok: unknown, message: string): asserts ok {\n if (!ok) {\n throw new Error(message);\n }\n}\n\nasync function barrier(\n runtime: OperationRuntime,\n state: WalletState,\n block?: CanonicalBlock\n): Promise<void> {\n const checkpoints = [\n state.observedThrough,\n ...(block ? [{ number: block.number, hash: block.hash }] : []),\n ];\n for (const point of checkpoints) {\n if (point && (await runtime.reader.getBlock(point.number)).hash !== point.hash) {\n await runtime.store.transaction(runtime.scope, (draft) => {\n draft.invalidated = \"Canonical operation checkpoint changed; full resync required\";\n for (const record of [\n ...Object.values(draft.notes),\n ...Object.values(draft.credits),\n ]) {\n record.spent = \"unknown\";\n }\n for (const operation of Object.values(draft.operations)) {\n if (\n [\"failed\", \"expired\"].includes(operation.status) &&\n !(operation.payload as { externalized?: boolean } | undefined)?.externalized\n ) {\n continue;\n }\n operation.status = \"reorged\";\n for (const id of operation.inputs) {\n if (!draft.reservations[id]) {\n draft.reservations[id] = operation.id;\n }\n }\n }\n });\n throw new Error(\"canonical operation checkpoint changed; full resync required\");\n }\n }\n}\n\nfunction current(state: WalletState, id: string, generation: number) {\n check(!state.invalidated, \"wallet requires canonical resync\");\n const record = state.operations[id];\n const saved = record?.payload as SavedOperation;\n check(record && saved.generation === generation && !saved.claim, \"stale operation recovery\");\n return { record, saved };\n}\n\nfunction observe(state: WalletState, block: CanonicalBlock): void {\n if (state.observedThrough?.number === block.number) {\n check(state.observedThrough.hash === block.hash, \"operation checkpoint conflict\");\n }\n if (!state.observedThrough || state.observedThrough.number < block.number) {\n state.observedThrough = { number: block.number, hash: block.hash };\n }\n}\n\nexport async function confirmOperation(\n runtime: OperationRuntime,\n id: string,\n generation: number,\n hash: Hex,\n signal?: AbortSignal\n): Promise<{ status: OperationStatus; saved: SavedOperation } | undefined> {\n const { reader, store, scope, options } = runtime;\n const state = await store.readSnapshot(scope);\n const { saved } = current(state, id, generation);\n const plan = saved.plan;\n await options.protocol.validateDeployment(reader);\n await barrier(runtime, state);\n const receipt = await reader.getReceipt(hash);\n if (!receipt) {\n return undefined;\n }\n check(receipt.transactionHash === hash, \"receipt transaction identity mismatch\");\n await barrier(runtime, state, receipt.block);\n const transaction = await reader.getTransaction(hash);\n check(\n transaction && transaction.transactionHash === hash,\n \"confirmed transaction differs from the frozen operation\"\n );\n\n let matchesRequest: boolean;\n if (plan.statement?.target === \"noir-recursive\") {\n matchesRequest = matchesAggregateTransaction(saved, transaction);\n } else {\n matchesRequest =\n !!saved.call &&\n transaction.to.toLowerCase() === saved.call.to.toLowerCase() &&\n transaction.value === saved.call.value &&\n transaction.data.toLowerCase() === saved.call.data.toLowerCase();\n }\n check(matchesRequest, \"confirmed transaction differs from the frozen operation\");\n\n check(\n receipt.status === \"success\" || receipt.status === \"reverted\",\n \"receipt execution status is missing\"\n );\n // A reverted transaction does not revoke its public authorization.\n if (receipt.status === \"reverted\") {\n return undefined;\n }\n const candidates = extractDeliveryCandidates(\n readProtocolLogs(receipt, plan.context.protocolAddress),\n plan.context,\n receipt.block.number\n );\n const latest = await reader.getLatestBlockNumber();\n const height = [latest, receipt.block.number, state.observedThrough?.number ?? 0n].reduce(\n (a, b) => (a > b ? a : b)\n );\n const spentBlock = await reader.getBlock(height);\n check(spentBlock.number === height, \"spent-state canonical block mismatch\");\n const notes: StoredNote[] = [];\n for (const output of plan.outputs) {\n const candidate = candidates.find(\n (value) => value.role === \"funds\" && value.commitment === output.commitment\n );\n check(candidate, \"confirmed output is missing from canonical receipt\");\n if (output.note.walletIdentity !== scope.walletIdentity) {\n continue;\n }\n const input = {\n treeId: candidate.treeId,\n leafIndex: candidate.leafIndex,\n commitment: candidate.commitment,\n };\n check(options.protocolRpc, \"membership provider required for confirmed owned output\");\n const proof = await options.protocolRpc!.getMembership(plan.context, input, receipt.block);\n await verifyMembership(reader, plan.context, receipt.block, input, proof);\n notes.push({\n ...input,\n note: structuredClone(output.note),\n blockNumber: receipt.block.number,\n blockHash: receipt.block.hash,\n transactionHash: hash,\n spent: \"unknown\",\n });\n }\n const credits: StoredCredit[] = [];\n for (const output of plan.credit?.outputs ?? []) {\n const n = output.state.note;\n for (const role of [\"owner\", \"spender\"] as const) {\n if (\n (role === \"owner\" ? n.ownerWalletIdentity : n.spenderWalletIdentity) !==\n scope.walletIdentity\n ) {\n continue;\n }\n const candidate = candidates.find(\n (value) => value.role === role && value.commitment === output.commitment\n );\n check(candidate, \"confirmed Credit output is missing from canonical receipt\");\n const input = {\n treeId: candidate.treeId,\n leafIndex: candidate.leafIndex,\n commitment: candidate.commitment,\n };\n check(options.protocolRpc, \"membership provider required for confirmed Credit\");\n const proof = await options.protocolRpc!.getMembership(\n plan.context,\n input,\n receipt.block\n );\n await verifyMembership(reader, plan.context, receipt.block, input, proof);\n const index = plan.credit?.draw?.remainderCommitments.indexOf(output.commitment);\n const parent = plan.credit?.topUp\n ? plan.credit.inputs[0]\n : index !== undefined && index >= 0\n ? plan.credit?.inputs[index]\n : undefined;\n const receivingKeySource =\n parent && state.credits[parent.commitment + \":\" + role]\n ? {\n kind: plan.credit?.topUp ? (\"top-up\" as const) : (\"draw\" as const),\n commitment: parent.commitment,\n }\n : undefined;\n credits.push({\n ...input,\n state: structuredClone(output.state),\n role,\n blockNumber: receipt.block.number,\n blockHash: receipt.block.hash,\n transactionHash: hash,\n spent: \"unknown\",\n ...(receivingKeySource ? { receivingKeySource } : {}),\n });\n }\n }\n if (credits.length) {\n const nullifiers = await Promise.all(\n credits.map(async (record) =>\n computeCreditNullifier(\n plan.context.chainId,\n record.state.note.creditSharedKey,\n await creditLeaf(record.state)\n )\n )\n );\n const values = await reader.isSpent(plan.context, nullifiers, spentBlock);\n check(\n values.length === credits.length && values.every((value) => typeof value === \"boolean\"),\n \"invalid Credit spent-state response\"\n );\n credits.forEach((record, i) => {\n record.spent = values[i] ? \"spent\" : \"unspent\";\n record.checkedThrough = { number: spentBlock.number, hash: spentBlock.hash };\n });\n }\n const facts = inputFacts(plan);\n const nfs = facts.map((input) => input.nullifier);\n const spent = nfs.length ? await reader.isSpent(plan.context, nfs, spentBlock) : [];\n check(\n spent.length === nfs.length && spent.every((value) => value === true),\n \"successful operation inputs are not consumed\"\n );\n // Complete recovered note openings determine their consumption markers without signing authority.\n const nullifier = options.wallet.exportNullifier();\n if (notes.length) {\n const values = await reader.isSpent(\n plan.context,\n await Promise.all(\n notes.map((note) =>\n nullifier!.compute(plan.context.chainId, note.commitment, note.note.nonce)\n )\n ),\n spentBlock\n );\n check(\n values.length === notes.length && values.every((value) => typeof value === \"boolean\"),\n \"invalid output spent-state response\"\n );\n notes.forEach((note, i) => {\n note.spent = values[i] ? \"spent\" : \"unspent\";\n note.checkedThrough = { number: spentBlock.number, hash: spentBlock.hash };\n });\n }\n signal?.throwIfAborted();\n await barrier(runtime, state, receipt.block);\n await barrier(runtime, state, spentBlock);\n return store.transaction(scope, (draft) => {\n signal?.throwIfAborted();\n const { record, saved: active } = current(draft, id, generation);\n for (const point of [draft.observedThrough]) {\n check(\n !point ||\n point.number < spentBlock.number ||\n (point.number === spentBlock.number && point.hash === spentBlock.hash),\n \"wallet advanced or changed during confirmation; retry\"\n );\n }\n mergeReceiptRecords(draft, {\n notes,\n credits,\n checkpoint: { number: receipt.block.number, hash: receipt.block.hash },\n });\n for (const fact of facts) {\n const input = draft[fact.kind][fact.key];\n if (input) {\n mergeSpentObservation(input, {\n spent: \"spent\",\n checkedThrough: { number: spentBlock.number, hash: spentBlock.hash },\n });\n }\n if (fact.kind === \"credits\" && input) {\n for (const other of Object.values(draft.credits)) {\n if (other.commitment === input.commitment) {\n mergeSpentObservation(other, {\n spent: \"spent\",\n checkedThrough: { number: spentBlock.number, hash: spentBlock.hash },\n });\n }\n }\n }\n if (draft.reservations[fact.reservationKey] === id) {\n delete draft.reservations[fact.reservationKey];\n }\n }\n observe(draft, spentBlock);\n record.status = \"confirmed\";\n record.transactionHash = hash;\n active.generation++;\n return { status: record.status, saved: structuredClone(active) };\n });\n}\n\nexport async function reconcileOperation(\n runtime: OperationRuntime,\n id: string,\n generation: number,\n signal?: AbortSignal\n): Promise<{ status: OperationStatus; saved: SavedOperation }> {\n const { reader, store, scope, options } = runtime;\n const state = await store.readSnapshot(scope);\n const { record, saved } = current(state, id, generation);\n const plan = saved.plan;\n await options.protocol.validateDeployment(reader);\n await barrier(runtime, state);\n const block = await reader.getBlock(await reader.getLatestBlockNumber());\n const facts = inputFacts(plan);\n const nfs = facts.map((input) => input.nullifier);\n const spent = nfs.length ? await reader.isSpent(plan.context, nfs, block) : [];\n check(\n spent.length === nfs.length && spent.every((value) => typeof value === \"boolean\"),\n \"invalid reconciliation spent-state response\"\n );\n const expired = operationExpired(plan, block.timestamp);\n // Funding grants can be renewed and an unknown root can reappear. Neither revokes the wallet proof.\n const impossible = spent.some((value) => value);\n signal?.throwIfAborted();\n await barrier(runtime, state, block);\n return store.transaction(scope, (draft) => {\n signal?.throwIfAborted();\n const { record: active, saved: next } = current(draft, id, generation);\n for (const point of [\n draft.observedThrough,\n ...facts.map((fact) => draft[fact.kind][fact.key]?.checkedThrough),\n ]) {\n check(\n !point ||\n point.number < block.number ||\n (point.number === block.number && point.hash === block.hash),\n \"wallet advanced or changed during reconciliation; retry\"\n );\n }\n if (expired || impossible) {\n active.status = expired ? \"expired\" : \"failed\";\n facts.forEach((fact, i) => {\n const input = draft[fact.kind][fact.key];\n if (input) {\n mergeSpentObservation(input, {\n spent: spent[i] ? \"spent\" : \"unspent\",\n checkedThrough: { number: block.number, hash: block.hash },\n });\n if (fact.kind === \"credits\") {\n for (const other of Object.values(draft.credits)) {\n if (other.commitment === input.commitment) {\n mergeSpentObservation(other, {\n spent: spent[i] ? \"spent\" : \"unspent\",\n checkedThrough: { number: block.number, hash: block.hash },\n });\n }\n }\n }\n }\n if (draft.reservations[fact.reservationKey] === id) {\n delete draft.reservations[fact.reservationKey];\n }\n });\n observe(draft, block);\n } else if (next.externalized || active.status === \"reorged\") {\n active.status = \"uncertain\";\n }\n next.generation++;\n return { status: active.status, saved: structuredClone(next) };\n });\n}\n","import type { Address } from \"@invisi-labs/protocol/contracts\";\nimport { Interface, type Result } from \"ethers\";\n\nimport { invisiProtocolAbi, type TransactRequest } from \"@invisi-labs/protocol/contracts\";\nimport { buildTransactCalldata, type TransactionCall } from \"@invisi-labs/protocol\";\nimport type { SavedOperation } from \"./operation-types\";\nconst aggregateAbi = invisiProtocolAbi.filter(\n (item) =>\n item.type === \"function\" &&\n item.name === \"transact\" &&\n item.inputs.length === 2 &&\n item.inputs[1]?.type === \"tuple[]\"\n);\n/** Match the whole frozen member, including funding nonce, signature and permit, in one successful aggregate. */\nexport function matchesAggregateTransaction(\n saved: SavedOperation,\n transaction: TransactionCall & { from: Address }\n): boolean {\n const plan = saved.plan;\n if (\n plan.statement?.target !== \"noir-recursive\" ||\n !plan.params ||\n !saved.externalized ||\n transaction.to.toLowerCase() !== plan.context.protocolAddress.toLowerCase() ||\n transaction.value !== 0n\n )\n return false;\n try {\n const decoded = new Interface(aggregateAbi).parseTransaction({ data: transaction.data })!,\n requests = (decoded.args[1] as Result[]).map((request) => {\n const member = request.toObject(true);\n member.params.sources = request.params.sources.map((source: Result) =>\n source.toObject(true)\n );\n member.params.nullifiers = request.params.nullifiers.toArray(true);\n member.params.outputCommitments = request.params.outputCommitments.toArray(true);\n member.deliveries = request.deliveries.map((delivery: Result) =>\n delivery.toObject(true)\n );\n member.funding.permit.v = Number(member.funding.permit.v);\n return {\n params: member.params,\n deliveries: member.deliveries,\n funding: member.funding,\n };\n }) as readonly TransactRequest[];\n if (\n decoded.name !== \"transact\" ||\n !Array.isArray(requests) ||\n ![4, 8, 12].includes(requests.length)\n )\n return false;\n const canonical = (request: TransactRequest) =>\n buildTransactCalldata({\n context: { ...plan.context, tokenAddress: request.params.token },\n proof: \"0x00\",\n params: request.params,\n deliveries: request.deliveries,\n funding: request.funding,\n caller: transaction.from,\n }).data.toLowerCase();\n const expected = buildTransactCalldata({\n context: plan.context,\n proof: \"0x00\",\n params: plan.params,\n deliveries: plan.outputs.map((output) => output.delivery),\n funding: plan.funding,\n caller: transaction.from,\n }).data.toLowerCase();\n return requests.filter((request) => canonical(request) === expected).length === 1;\n } catch {\n return false;\n }\n}\n","import type { Hex } from \"@invisi-labs/protocol/contracts\";\n\nimport {\n computeCreditCommitment,\n computeCreditSharedKeyHash,\n type CreditDeliveryState,\n} from \"@invisi-labs/core\";\nexport async function creditLeaf(state: CreditDeliveryState): Promise<Hex> {\n const n = state.note;\n return computeCreditCommitment(\n n.chainId,\n n.spenderWalletIdentity,\n n.ownerWalletIdentity,\n n.spenderPayout,\n n.ownerPayout,\n n.tokenAddress,\n n.amount,\n n.nonce,\n n.expiry,\n await computeCreditSharedKeyHash(n.creditSharedKey),\n n\n );\n}\n","import type { Hex } from \"@invisi-labs/protocol/contracts\";\n\nimport { FIELD_MODULUS, poseidonHash } from \"@invisi-labs/core\";\nimport type {\n CanonicalBlock,\n ChainReader,\n Membership,\n TransactionContext,\n} from \"@invisi-labs/protocol\";\nexport async function verifyMembership(\n reader: ChainReader,\n context: TransactionContext,\n block: CanonicalBlock,\n input: { treeId: bigint; leafIndex: number; commitment: Hex },\n proof: Membership\n): Promise<void> {\n if (\n proof.block.hash !== block.hash ||\n proof.block.number !== block.number ||\n proof.leaf !== input.commitment ||\n proof.treeId !== input.treeId ||\n proof.leafIndex !== input.leafIndex ||\n proof.path.length !== 16 ||\n !Number.isInteger(input.leafIndex) ||\n input.leafIndex < 0 ||\n input.leafIndex >= 65536 ||\n !(await reader.isKnownRoot(context, input.treeId, proof.root, block))\n )\n throw new Error(\"membership context/root mismatch\");\n let root = BigInt(input.commitment);\n for (let i = 0; i < 16; i++) {\n const sibling = proof.path[i]!;\n if (typeof sibling !== \"bigint\" || sibling < 0n || sibling >= FIELD_MODULUS)\n throw new Error(\"noncanonical membership path\");\n root = BigInt(\n await poseidonHash((input.leafIndex >> i) & 1 ? [sibling, root] : [root, sibling])\n );\n }\n if (root !== BigInt(proof.root))\n throw new Error(\"membership path does not produce canonical root\");\n}\n","import type { Checkpoint, StoredCredit, StoredNote, WalletState } from \"./state\";\n\nexport interface ReceiptRecords {\n notes: readonly StoredNote[];\n credits: readonly StoredCredit[];\n checkpoint: Checkpoint;\n}\n\nfunction canonical(value: unknown): string {\n return JSON.stringify(value, (_, item) => {\n if (typeof item === \"bigint\") {\n return [\"bigint\", item.toString()];\n }\n if (item instanceof Uint8Array) {\n return Array.from(item);\n }\n if (item && typeof item === \"object\" && !Array.isArray(item)) {\n return Object.fromEntries(\n Object.keys(item)\n .sort()\n .map((key) => [key, item[key]])\n );\n }\n return item;\n });\n}\n\nfunction validateInheritance(state: WalletState, record: StoredCredit): boolean {\n const source = record.receivingKeySource;\n if (!source) return false;\n\n const parent = state.credits[source.commitment + \":\" + record.role];\n if (!parent) {\n throw new Error(\"Credit receiving inheritance has no authenticated parent\");\n }\n\n const previous = parent.state;\n const successor = record.state;\n const immutableFields = [\n \"chainId\",\n \"protocolAddress\",\n \"tokenAddress\",\n \"spenderWalletIdentity\",\n \"ownerWalletIdentity\",\n \"spenderPayout\",\n \"ownerPayout\",\n \"creditSharedKey\",\n ] as const;\n if (\n immutableFields.some((field) => previous.note[field] !== successor.note[field]) ||\n canonical(previous.ownerReceivingKeys) !== canonical(successor.ownerReceivingKeys) ||\n canonical(previous.spenderReceivingKeys) !== canonical(successor.spenderReceivingKeys)\n ) {\n throw new Error(\"Credit receiving inheritance changed immutable fields\");\n }\n\n if (source.kind === \"draw\") {\n if (\n successor.note.amount >= previous.note.amount ||\n successor.note.expiry !== previous.note.expiry\n ) {\n throw new Error(\"invalid Credit receiving inheritance\");\n }\n } else if (\n source.kind !== \"top-up\" ||\n successor.note.amount <= previous.note.amount ||\n successor.note.expiry < previous.note.expiry\n ) {\n throw new Error(\"invalid Credit receiving inheritance\");\n }\n return true;\n}\n\n/** Merge canonical spent observations without replacing a newer per-input checkpoint. */\nexport function mergeSpentObservation(\n previous: Pick<StoredNote, \"spent\" | \"checkedThrough\">,\n incoming: Pick<StoredNote, \"spent\" | \"checkedThrough\">\n): void {\n const next = incoming.checkedThrough;\n const old = previous.checkedThrough;\n if (!next || incoming.spent === \"unknown\") {\n return;\n }\n if (old && next.number < old.number) {\n return;\n }\n if (old && next.number === old.number && next.hash !== old.hash) {\n throw new Error(\"canonical spent checkpoint conflict requires resync\");\n }\n if (previous.spent === \"spent\" && incoming.spent !== \"spent\") {\n throw new Error(\"canonical spent observation conflict requires resync\");\n }\n previous.spent = incoming.spent;\n previous.checkedThrough = { ...next };\n}\n\n/** Atomic private inventory update; the caller must authenticate membership and block identity first. */\nexport function mergeReceiptRecords(state: WalletState, batch: ReceiptRecords): void {\n if (state.invalidated) {\n throw new Error(\"wallet inventory is invalidated\");\n }\n const checkpoint = { ...batch.checkpoint };\n for (const record of [...batch.notes, ...batch.credits]) {\n if (record.blockNumber > checkpoint.number) {\n throw new Error(\"receipt exceeds confirmed checkpoint\");\n }\n const atPosition = [...Object.values(state.notes), ...Object.values(state.credits)].filter(\n (existing) =>\n existing.treeId === record.treeId && existing.leafIndex === record.leafIndex\n );\n if (\n atPosition.some(\n (existing) =>\n existing.commitment !== record.commitment ||\n existing.blockHash !== record.blockHash\n )\n ) {\n throw new Error(\"canonical position conflict requires resync\");\n }\n if (\"note\" in record) {\n const previous = state.notes[record.commitment];\n if (previous) {\n if (canonical(previous.note) !== canonical(record.note)) {\n throw new Error(\"canonical note preimage conflict\");\n }\n mergeSpentObservation(previous, record);\n continue;\n }\n state.notes[record.commitment] = record;\n } else {\n const key = record.commitment + \":\" + record.role;\n const previous = state.credits[key];\n const inherited = validateInheritance(state, record);\n if (previous) {\n if (canonical(previous.state.note) !== canonical(record.state.note)) {\n throw new Error(\"canonical Credit preimage conflict\");\n }\n if (canonical(previous.state) !== canonical(record.state)) {\n if (!inherited) {\n if (previous.receivingKeySource) {\n mergeSpentObservation(previous, record);\n continue;\n }\n throw new Error(\"Credit receiving metadata conflict\");\n }\n previous.state = record.state;\n previous.receivingKeySource = record.receivingKeySource!;\n } else if (inherited) {\n previous.receivingKeySource = record.receivingKeySource!;\n }\n mergeSpentObservation(previous, record);\n continue;\n }\n state.credits[key] = record;\n }\n }\n}\n","import { copyGasBenchmarks } from \"../gas-estimation\";\nimport type { Hex } from \"@invisi-labs/protocol/contracts\";\nimport { getAddress, type TransactionRequest, type TransactionResponse } from \"ethers\";\n\nimport { MissingCapabilityError } from \"@invisi-labs/core\";\nimport type { Protocol, TransactionCall } from \"@invisi-labs/protocol\";\nimport { Operation } from \"./Operation\";\nimport type {\n CancelCreditPreparation,\n CreateCreditPreparation,\n DrawCreditPreparation,\n OperationPlan,\n OperationRuntime,\n ShieldPreparation,\n TopUpCreditPreparation,\n TransferPreparation,\n WalletSessionOptions,\n WithdrawalPreparation,\n SweepPreparation,\n} from \"./operation-types\";\nimport { TransactionPreparation } from \"./transaction-preparation\";\nimport { walletBalance, type WalletScope } from \"./state\";\nimport { scopeKey } from \"./store\";\nimport { refreshWallet, type RefreshOptions } from \"./refresh\";\nimport { WalletUpdater } from \"./WalletUpdater\";\n\n/** Native ethers transaction options; the exported business call and session chain remain fixed. */\nexport type SessionTransactionOptions = Omit<\n TransactionRequest,\n \"to\" | \"from\" | \"data\" | \"value\" | \"chainId\"\n>;\n\n/** Wallet state and operations, with infrastructure and permissions explicitly injected. */\nexport class WalletSession {\n readonly #options: WalletSessionOptions;\n #updater: WalletUpdater | undefined;\n readonly #sending = new Set<string>();\n #refreshQueue: Promise<unknown> = Promise.resolve();\n readonly scope: WalletScope;\n readonly protocol: Protocol;\n\n constructor(options: WalletSessionOptions) {\n this.#options = {\n ...options,\n ...(options.gasBenchmarks\n ? { gasBenchmarks: copyGasBenchmarks(options.gasBenchmarks) }\n : {}),\n };\n this.protocol = options.protocol;\n this.scope = Object.freeze({\n namespace: options.namespace ?? \"default\",\n ...options.protocol.context,\n walletIdentity: options.wallet.walletIdentity,\n });\n scopeKey(this.scope);\n Object.freeze(this);\n }\n\n async sendTransaction(\n call: TransactionCall,\n options?: SessionTransactionOptions\n ): Promise<TransactionResponse>;\n async sendTransaction(\n operation: Operation,\n options?: SessionTransactionOptions\n ): Promise<TransactionResponse>;\n /** Delegate sending to ethers; managed operations additionally retain the resulting hash. */\n async sendTransaction(\n input: TransactionCall | Operation,\n options: SessionTransactionOptions = {}\n ): Promise<TransactionResponse> {\n const signer = this.#options.signer;\n if (!signer) throw new MissingCapabilityError(\"ethers signer\");\n const operation = input instanceof Operation ? input : undefined;\n if (operation && this.#sending.has(operation.id))\n throw new Error(\"operation is already being sent by this session\");\n if (operation) this.#sending.add(operation.id);\n // Copy options and plain calldata before the first asynchronous provider check.\n const overrides = { ...options };\n const plain = operation ? undefined : { ...(input as TransactionCall) };\n try {\n if (!signer.provider) throw new MissingCapabilityError(\"connected ethers signer\");\n if ((await signer.provider.getNetwork()).chainId !== this.protocol.context.chainId) {\n throw new Error(\"signer-provider session chain mismatch\");\n }\n if (operation) {\n if (!this.#options.store) throw new MissingCapabilityError(\"wallet store\");\n const state = await this.#options.store.readSnapshot(this.scope);\n if (!state.operations[operation.id])\n throw new Error(\"operation does not belong to this wallet session\");\n }\n const call = operation ? await operation.exportTransaction() : plain!;\n const transaction = await signer.sendTransaction({\n ...overrides,\n to: call.to,\n data: call.data,\n value: call.value,\n chainId: this.protocol.context.chainId,\n });\n if (operation) {\n try {\n await operation.trackTransaction(transaction.hash);\n } catch (cause) {\n throw new Error(\n `Transaction ${transaction.hash} was sent but its operation association could not be saved; resume and reconcile this hash`,\n { cause }\n );\n }\n }\n return transaction;\n } finally {\n if (operation) this.#sending.delete(operation.id);\n }\n }\n\n private runtime(tokenAddress: `0x${string}`): OperationRuntime {\n const options = this.#options;\n if (!options.store) {\n throw new MissingCapabilityError(\"wallet store\");\n }\n if (!options.chainReader) {\n throw new MissingCapabilityError(\"chain reader\");\n }\n return {\n options: { ...options, protocol: options.protocol.forToken(tokenAddress) },\n scope: this.scope,\n store: options.store,\n reader: options.chainReader,\n authorization: () => options.authorization ?? options.wallet.exportAuthorization(),\n };\n }\n\n private updater(): WalletUpdater {\n if (this.#updater) return this.#updater;\n const options = this.#options;\n if (!options.store || !options.chainReader || !options.protocolRpc)\n throw new MissingCapabilityError(\"wallet store, chain reader and Protocol RPC\");\n const viewing = options.viewing ?? options.wallet.getViewer();\n const receivingAddress = options.wallet.getReceivingAddress();\n const receivingKeys =\n receivingAddress.kind === \"long\" ? receivingAddress.getReceivingKeys() : undefined;\n this.#updater = new WalletUpdater({\n protocol: options.protocol,\n scope: this.scope,\n store: options.store,\n reader: options.chainReader,\n viewing,\n protocolRpc: options.protocolRpc,\n ...(receivingKeys ? { receivingKeys } : {}),\n });\n return this.#updater;\n }\n\n async balance(tokenAddress: `0x${string}`) {\n const store = this.#options.store;\n if (!store) {\n throw new MissingCapabilityError(\"wallet store\");\n }\n return walletBalance(await store.readSnapshot(this.scope), getAddress(tokenAddress) as Hex);\n }\n\n /** Pull explicitly selected indexed pages; no chain scanning or public tree reconstruction. */\n async refresh(options: RefreshOptions) {\n const provider = this.#options.protocolRpc;\n const reader = this.#options.chainReader;\n if (!reader) throw new MissingCapabilityError(\"chain reader\");\n if (!provider) throw new MissingCapabilityError(\"Protocol RPC\");\n const updater = this.updater();\n const request = {\n ...options,\n ...(options.detectionKey ? { detectionKey: options.detectionKey.slice() } : {}),\n };\n const task = this.#refreshQueue.then(() =>\n refreshWallet(\n {\n provider,\n reader,\n context: this.protocol.context,\n fromBlock: this.protocol.deployment.protocol.fromBlock,\n apply: (batch, settings) => updater.applyUpdates(batch, settings),\n },\n request\n )\n );\n this.#refreshQueue = task.catch(() => {});\n return task;\n }\n\n private preparation(tokenAddress: Hex): TransactionPreparation<Operation> {\n const runtime = this.runtime(tokenAddress);\n return new TransactionPreparation({\n options: runtime.options,\n scope: runtime.scope,\n reader: runtime.reader,\n authorization: runtime.authorization,\n readInventory: () => runtime.store.readSnapshot(runtime.scope),\n complete: (plan) => Operation.prepare(runtime, plan),\n });\n }\n async prepareTransfer(options: TransferPreparation): Promise<Operation> {\n return this.preparation(options.tokenAddress).prepareTransfer(options);\n }\n async prepareWithdraw(options: WithdrawalPreparation): Promise<Operation> {\n return this.preparation(options.tokenAddress).prepareWithdraw(options);\n }\n async prepareSweep(options: SweepPreparation): Promise<Operation> {\n return this.preparation(options.tokenAddress).prepareSweep(options);\n }\n async prepareShield(options: ShieldPreparation): Promise<Operation> {\n return this.preparation(options.tokenAddress).prepareShield(options);\n }\n async prepareCreateCredit(options: CreateCreditPreparation): Promise<Operation> {\n return this.preparation(options.tokenAddress).prepareCreateCredit(options);\n }\n async prepareDrawCredit(options: DrawCreditPreparation): Promise<Operation> {\n return this.preparation(options.tokenAddress).prepareDrawCredit(options);\n }\n async prepareTopUpCredit(options: TopUpCreditPreparation): Promise<Operation> {\n return this.preparation(options.tokenAddress).prepareTopUpCredit(options);\n }\n async prepareCancelCredit(options: CancelCreditPreparation): Promise<Operation> {\n return this.preparation(options.tokenAddress).prepareCancelCredit(options);\n }\n async resume(operationId: string): Promise<Operation> {\n const store = this.#options.store;\n if (!store) throw new MissingCapabilityError(\"wallet store\");\n const state = await store.readSnapshot(this.scope);\n const saved = state.operations[operationId]?.payload as\n { plan?: OperationPlan } | undefined;\n if (!saved?.plan) throw new Error(\"operation not found\");\n return Operation.resume(this.runtime(saved.plan.context.tokenAddress), operationId);\n }\n\n toJSON() {\n return { walletSession: true, walletIdentity: this.scope.walletIdentity };\n }\n\n [Symbol.for(\"nodejs.util.inspect.custom\")]() {\n return this.toJSON();\n }\n}\n","import type { Hex } from \"@invisi-labs/protocol/contracts\";\nimport { getAddress } from \"ethers\";\nimport {\n normalizeTransactRequest,\n transactUserPublicInputs,\n WitnessBuilder,\n ZERO_ADDRESS,\n} from \"@invisi-labs/protocol\";\nimport type { ProofTarget } from \"@invisi-labs/prover\";\nimport { positiveAmount, Preparation, type PreparationFrame } from \"./prepare-common\";\nimport { CreditPreparation } from \"./prepare-credit\";\nimport type {\n CancelCreditPreparation,\n CreateCreditPreparation,\n DrawCreditPreparation,\n OperationPlan,\n PreparationRuntime,\n PaymentOutput,\n ShieldPreparation,\n TopUpCreditPreparation,\n TransferPreparation,\n WithdrawalPreparation,\n SweepPreparation,\n} from \"./operation-types\";\n\n/** Shared preparation engine for managed sessions and explicitly supplied inputs. */\nexport class TransactionPreparation<Result> {\n constructor(readonly context: PreparationRuntime<Result>) {}\n private runtime(tokenAddress: Hex): PreparationRuntime<Result> {\n if (\n getAddress(tokenAddress) !==\n getAddress(this.context.options.protocol.context.tokenAddress)\n )\n throw new Error(\"preparation token mismatch\");\n return this.context;\n }\n private get scope() {\n return this.context.scope;\n }\n async prepareTransfer(options: TransferPreparation): Promise<Result> {\n const copied = structuredClone(options);\n const preparation = new Preparation(this.runtime(copied.tokenAddress));\n const frame = await preparation.frame(copied.deadline);\n if (copied.outputs.length < 1 || copied.outputs.length > 168) {\n throw new Error(\"transfer requires 1..168 outputs\");\n }\n const total = copied.outputs.reduce(\n (sum, output) => sum + positiveAmount(output.amount),\n 0n\n );\n const funding = await preparation.funding(copied.funding, frame);\n return this.funds(\n \"transfer\",\n copied.outputs,\n total,\n ZERO_ADDRESS,\n 0n,\n frame,\n funding,\n copied.target,\n preparation\n );\n }\n\n async prepareWithdraw(options: WithdrawalPreparation): Promise<Result> {\n const copied = structuredClone(options);\n const preparation = new Preparation(this.runtime(copied.tokenAddress));\n const frame = await preparation.frame(copied.deadline);\n const to = getAddress(copied.to) as Hex;\n positiveAmount(copied.amount);\n if (BigInt(to) === 0n) {\n throw new Error(\"withdrawal destination must be nonzero\");\n }\n return this.funds(\n \"withdraw\",\n [],\n copied.amount,\n to,\n copied.amount,\n frame,\n { funding: {}, fundingMode: \"none\" },\n copied.target,\n preparation\n );\n }\n\n /** Full payout to the note owner; no arbitrary destination, change or spending signature. */\n async prepareSweep(options: SweepPreparation): Promise<Result> {\n const copied = structuredClone(options);\n const runtime = this.runtime(copied.tokenAddress);\n const state = await runtime.readInventory();\n const available = Object.values(state.notes).filter(\n (record) =>\n record.note.tokenAddress === BigInt(copied.tokenAddress) &&\n record.spent === \"unspent\" &&\n !state.reservations[record.commitment]\n );\n const selected = copied.commitments ?? available.map((record) => record.commitment);\n if (selected.length === 0) throw new Error(\"empty sweep input selection\");\n if (new Set(selected).size !== selected.length) throw new Error(\"duplicate sweep inputs\");\n const byId = new Map(available.map((record) => [record.commitment, record]));\n let amount = 0n;\n for (const id of selected) {\n const record = byId.get(id);\n if (!record) throw new Error(\"sweep input unavailable\");\n amount += record.note.amount;\n }\n positiveAmount(amount);\n const preparation = new Preparation({\n ...runtime,\n inputSelection: selected,\n });\n const frame = await preparation.frame(copied.deadline);\n return this.funds(\n \"sweep\",\n [],\n amount,\n this.scope.walletIdentity,\n amount,\n frame,\n { funding: {}, fundingMode: \"none\" },\n copied.target,\n preparation\n );\n }\n\n private async funds(\n kind: \"transfer\" | \"withdraw\" | \"sweep\",\n payments: readonly PaymentOutput[],\n total: bigint,\n withdrawalAddress: `0x${string}`,\n withdrawalAmount: bigint,\n frame: PreparationFrame,\n funding: Pick<OperationPlan, \"funding\" | \"fundingMode\">,\n target: ProofTarget | undefined,\n preparation: Preparation<Result>\n ): Promise<Result> {\n if (total >= 1n << 135n) {\n throw new Error(\"transaction sum exceeds uint135\");\n }\n const { context, block, deadline } = frame;\n const selection = await preparation.selectFunds(\n total - (funding.funding.amount ?? 0n),\n frame\n );\n const outputs = await Promise.all(\n payments.map((payment) => preparation.output(payment, context))\n );\n const change = selection.amount + (funding.funding.amount ?? 0n) - total;\n if (change > 0n) {\n outputs.push(\n await preparation.output(\n {\n to:\n this.context.changeAddress ??\n this.context.options.wallet.getReceivingAddress().toString(),\n amount: change,\n },\n context,\n true\n )\n );\n }\n const params = {\n token: context.tokenAddress,\n sources: selection.sources,\n nullifiers: selection.nullifiers,\n outputCommitments: outputs.map((output) => output.commitment),\n withdrawalAddress,\n withdrawalAmount,\n deadline,\n };\n const deliveries = outputs.map((output) => output.delivery);\n const normalized = normalizeTransactRequest(context, params, deliveries, funding.funding);\n const statement = WitnessBuilder.statement(\n `transact_user_slots${normalized.capacity}`,\n transactUserPublicInputs(context, params, deliveries, funding.funding),\n target ?? \"evm\"\n );\n await preparation.assertBlock(frame);\n return preparation.runtime.complete({\n version: 1,\n id: crypto.randomUUID(),\n kind,\n context,\n scope: this.scope,\n preparedAt: block,\n deadline,\n outputs,\n inputs: selection.inputs,\n ...funding,\n params,\n capacity: normalized.capacity,\n statement,\n });\n }\n\n async prepareShield(options: ShieldPreparation): Promise<Result> {\n const copied = structuredClone(options);\n const preparation = new Preparation(this.runtime(copied.tokenAddress));\n const frame = await preparation.frame(copied.deadline);\n const funding = await preparation.funding(copied.funding, frame);\n if (copied.outputs.length < 1 || copied.outputs.length > 10) {\n throw new Error(\"shield requires 1..10 outputs\");\n }\n const outputs = await Promise.all(\n copied.outputs.map((output) => preparation.output(output, frame.context))\n );\n if (\n outputs.reduce((sum, output) => sum + output.note.amount, 0n) !==\n (funding.funding.amount ?? 0n)\n ) {\n throw new Error(\"shield funding must equal output total\");\n }\n await preparation.assertBlock(frame);\n return preparation.runtime.complete({\n version: 1,\n id: crypto.randomUUID(),\n kind: \"shield\",\n context: frame.context,\n scope: this.scope,\n preparedAt: frame.block,\n deadline: frame.deadline,\n outputs,\n inputs: [],\n ...funding,\n shieldParams: {\n token: frame.context.tokenAddress,\n outputCommitments: outputs.map((output) => output.commitment),\n deadline: frame.deadline,\n },\n shieldOutputs: outputs.map((output) => ({\n identity: output.identity,\n amount: output.note.amount,\n })),\n });\n }\n\n prepareCreateCredit(options: CreateCreditPreparation): Promise<Result> {\n return new CreditPreparation(this.runtime(options.tokenAddress)).create(\n structuredClone(options)\n );\n }\n\n prepareDrawCredit(options: DrawCreditPreparation): Promise<Result> {\n return new CreditPreparation(this.runtime(options.tokenAddress)).draw(\n structuredClone(options)\n );\n }\n\n prepareTopUpCredit(options: TopUpCreditPreparation): Promise<Result> {\n return new CreditPreparation(this.runtime(options.tokenAddress)).topUp(\n structuredClone(options)\n );\n }\n\n prepareCancelCredit(options: CancelCreditPreparation): Promise<Result> {\n return new CreditPreparation(this.runtime(options.tokenAddress)).cancel(\n structuredClone(options)\n );\n }\n}\n","import type { Hex } from \"@invisi-labs/protocol/contracts\";\nimport { getAddress, hexlify } from \"ethers\";\n\nimport {\n encodeMemo,\n MissingCapabilityError,\n ReceivingAddress,\n computeNoteCommitment,\n computeNoteIdentity,\n createClue,\n encryptPrivateTransferNote,\n generateNonce,\n} from \"@invisi-labs/core\";\nimport {\n normalizeFunding,\n type CanonicalBlock,\n type FundingInput,\n type Membership,\n type NoteMembership,\n type TransactionContext,\n} from \"@invisi-labs/protocol\";\nimport { verifyMembership } from \"./membership\";\nimport type {\n FundingSource,\n OperationPlan,\n PreparationRuntime,\n PaymentOutput,\n PreparedOutput,\n} from \"./operation-types\";\nimport { selectNotes, type SelectableNote } from \"./selection\";\nimport type { StoredNote } from \"./state\";\n\nexport interface PreparationFrame {\n context: TransactionContext;\n block: CanonicalBlock;\n deadline: bigint;\n}\n\nexport function positiveAmount(value: bigint, bits = 128): bigint {\n if (typeof value !== \"bigint\" || value <= 0n || value >= 1n << BigInt(bits)) {\n throw new Error(`amount must be a positive uint${bits}`);\n }\n return value;\n}\n\n/** Shared local preparation checks; private witnesses never enter this object's public records. */\nexport class Preparation<Result> {\n readonly #roots = new Map<bigint, Hex>();\n constructor(readonly runtime: PreparationRuntime<Result>) {}\n\n async frame(requested?: bigint): Promise<PreparationFrame> {\n const { reader, options } = this.runtime;\n await options.protocol.validateDeployment(reader);\n const block = await reader.getBlock(await reader.getLatestBlockNumber());\n const deadline = requested ?? block.timestamp + (options.transactionTTL ?? 300n);\n if (typeof deadline !== \"bigint\" || deadline < block.timestamp || deadline >= 1n << 64n) {\n throw new Error(\"invalid transaction deadline\");\n }\n const state = await this.runtime.readInventory();\n if (state.invalidated) {\n throw new Error(\"wallet requires canonical resync\");\n }\n for (const point of [state.observedThrough]) {\n if (point && (await reader.getBlock(point.number)).hash !== point.hash) {\n throw new Error(\"canonical wallet checkpoint changed; resync required\");\n }\n }\n return {\n context: {\n ...options.protocol.context,\n now: block.timestamp,\n timestamp: block.timestamp,\n },\n block,\n deadline,\n };\n }\n\n async assertBlock(frame: PreparationFrame): Promise<void> {\n if ((await this.runtime.reader.getBlock(frame.block.number)).hash !== frame.block.hash) {\n throw new Error(\"canonical block changed while preparing\");\n }\n }\n\n async funding(\n source: FundingSource | undefined,\n frame: PreparationFrame\n ): Promise<{ funding: FundingInput; fundingMode: OperationPlan[\"fundingMode\"] }> {\n if (!source) {\n return { funding: {}, fundingMode: \"none\" };\n }\n positiveAmount(source.amount);\n const payer = getAddress(source.payer) as Hex;\n const mode = source.authorization ?? \"signature\";\n if (BigInt(payer) === 0n) {\n throw new Error(\"funding payer must be nonzero\");\n }\n if (mode !== \"signature\" && mode !== \"caller\") {\n throw new Error(\"invalid funding authorization mode\");\n }\n if (mode === \"caller\" && (source.sigNonce || source.deadline)) {\n throw new Error(\"caller funding uses zero nonce/deadline\");\n }\n const funding = normalizeFunding({\n payer,\n amount: source.amount,\n sigNonce:\n mode === \"caller\"\n ? 0n\n : (source.sigNonce ??\n (await this.runtime.reader.getFundingNonce(\n frame.context,\n payer,\n frame.block\n ))),\n deadline: mode === \"caller\" ? 0n : (source.deadline ?? frame.deadline),\n ...(source.permit ? { permit: structuredClone(source.permit) } : {}),\n });\n if (mode === \"signature\" && funding.deadline < frame.block.timestamp) {\n throw new Error(\"funding authorization deadline has expired\");\n }\n return { funding, fundingMode: mode };\n }\n\n async output(\n payment: PaymentOutput,\n context: TransactionContext,\n change = false\n ): Promise<PreparedOutput> {\n positiveAmount(payment.amount);\n const recipient = await ReceivingAddress.parse(payment.to).resolve(\n this.runtime.options.addressResolver\n );\n const memo = encodeMemo(payment.memo);\n const nonce = generateNonce();\n const identity = await computeNoteIdentity(BigInt(recipient.walletIdentity), nonce);\n const keys = recipient.getReceivingKeys();\n const note = {\n chainId: context.chainId,\n protocolAddress: BigInt(context.protocolAddress),\n tokenAddress: BigInt(context.tokenAddress),\n walletIdentity: recipient.walletIdentity,\n amount: payment.amount,\n ...(memo.length === 0 ? {} : { memo }),\n nonce,\n };\n const commitment = await computeNoteCommitment(\n context.chainId,\n identity,\n note.tokenAddress,\n note.amount\n );\n return {\n note,\n commitment,\n identity,\n address: payment.to,\n change,\n delivery: {\n ciphertext: hexlify(\n await encryptPrivateTransferNote(keys.viewingPublicKey, note, {\n chainId: context.chainId,\n protocolAddress: note.protocolAddress,\n outputCommitment: commitment,\n })\n ) as Hex,\n clue: hexlify(createClue(keys.clueKey)) as Hex,\n },\n };\n }\n\n async membership(\n input: { treeId: bigint; leafIndex: number; commitment: Hex },\n frame: PreparationFrame\n ): Promise<Membership> {\n const { options, reader } = this.runtime;\n if (!options.protocolRpc)\n throw new MissingCapabilityError(\"Protocol RPC membership provider\");\n const root = this.#roots.get(input.treeId);\n const proof = await options.protocolRpc.getMembership(\n frame.context,\n {\n ...input,\n ...(root ? { root } : {}),\n },\n frame.block\n );\n if (root && proof.root !== root)\n throw new Error(\"membership provider changed the pinned source root\");\n await verifyMembership(reader, frame.context, frame.block, input, proof);\n this.#roots.set(input.treeId, proof.root);\n return { ...proof, path: [...proof.path] };\n }\n\n async selectFunds(target: bigint, frame: PreparationFrame, maxInputs = 168) {\n const { scope, options, reader } = this.runtime;\n const state = await this.runtime.readInventory();\n if (state.invalidated) {\n throw new Error(\"wallet requires canonical resync\");\n }\n const need = target > 0n ? target : 0n;\n const nullifier = options.wallet.exportNullifier();\n const reserved = new Set(Object.keys(state.reservations));\n const eligible = Object.values(state.notes).filter(\n (note) =>\n note.note.tokenAddress === BigInt(frame.context.tokenAddress) &&\n note.spent === \"unspent\" &&\n !reserved.has(note.commitment)\n );\n const byId = new Map(eligible.map((note) => [note.commitment, note]));\n const choices = this.runtime.inputSelection\n ? [...this.runtime.inputSelection]\n : this.runtime.explicitInputs\n ? eligible.map((note) => note.commitment)\n : need > 0n && options.coinSelector\n ? await options.coinSelector.select(storedCandidates(eligible), need)\n : selectNotes(eligible, need, reserved).map((note) => note.commitment);\n if (\n !Array.isArray(choices) ||\n new Set(choices).size !== choices.length ||\n choices.some((id) => !byId.has(id))\n ) {\n throw new Error(\"invalid or duplicate coin selection\");\n }\n const selected = choices.map((id) => structuredClone(byId.get(id)!));\n const amount = selected.reduce((sum, input) => sum + input.note.amount, 0n);\n if (amount < need) {\n throw new Error(\"coin selection has insufficient verified funds\");\n }\n if (selected.length > maxInputs || amount >= 1n << 135n) {\n throw new Error(\"coin selection exceeds transaction capacity\");\n }\n const inputs: Array<NoteMembership & { commitment: Hex }> = [];\n const sources = new Map<bigint, Hex>();\n const nullifiers: Hex[] = [];\n for (const input of selected) {\n const note = input.note;\n const c = frame.context;\n if (\n note.walletIdentity !== scope.walletIdentity ||\n note.chainId !== c.chainId ||\n note.protocolAddress !== BigInt(c.protocolAddress) ||\n note.tokenAddress !== BigInt(c.tokenAddress) ||\n (await computeNoteCommitment(\n c.chainId,\n await computeNoteIdentity(BigInt(note.walletIdentity), note.nonce),\n note.tokenAddress,\n note.amount\n )) !== input.commitment\n ) {\n throw new Error(\"selected input preimage/context mismatch\");\n }\n const proof = await this.membership(input, frame);\n const path = [...proof.path];\n const root = proof.root;\n if (sources.has(input.treeId) && sources.get(input.treeId) !== root) {\n throw new Error(\"source roots do not share a canonical snapshot\");\n }\n sources.set(input.treeId, root);\n inputs.push({\n note,\n commitment: input.commitment,\n treeId: input.treeId,\n leafIndex: input.leafIndex,\n path,\n });\n nullifiers.push(\n await nullifier!.compute(c.chainId, input.commitment, input.note.nonce)\n );\n }\n await this.assertUnspent(nullifiers, frame);\n return {\n inputs,\n sources: [...sources]\n .sort(([a], [b]) => (a < b ? -1 : a > b ? 1 : 0))\n .map(([treeId, merkleRoot]) => ({ treeId, merkleRoot })),\n nullifiers,\n amount,\n };\n }\n\n async assertUnspent(nullifiers: readonly Hex[], frame: PreparationFrame): Promise<void> {\n if (nullifiers.length) {\n const spent = await this.runtime.reader.isSpent(frame.context, nullifiers, frame.block);\n if (spent.length !== nullifiers.length || spent.some((value) => value !== false)) {\n throw new Error(\"selected input spent or invalid spent-state response\");\n }\n }\n }\n}\n\n// Managed custom selectors retain access to receipt metadata. Explicit inputs\n// use their own exact selection and never pass fabricated metadata to a selector.\nfunction storedCandidates(inputs: readonly SelectableNote[]): StoredNote[] {\n const records = inputs.filter(\n (input): input is StoredNote =>\n \"blockNumber\" in input &&\n typeof input.blockNumber === \"bigint\" &&\n \"blockHash\" in input &&\n typeof input.blockHash === \"string\"\n );\n if (records.length !== inputs.length)\n throw new Error(\"custom coin selection requires stored receipt metadata\");\n return structuredClone(records);\n}\n","import type { StoredNote } from \"./state\";\n/** Minimal input count by descending amount, with deterministic tree/position/commitment ties. */\nexport type SelectableNote = Pick<\n StoredNote,\n \"note\" | \"commitment\" | \"treeId\" | \"leafIndex\" | \"spent\"\n>;\nexport function selectNotes<T extends SelectableNote>(\n notes: readonly T[],\n target: bigint,\n reserved: ReadonlySet<string>\n): T[] {\n if (typeof target !== \"bigint\" || target < 0n)\n throw new Error(\"selection target must be a nonnegative amount\");\n if (target === 0n) return [];\n const eligible = notes.filter(\n (note) => note.spent === \"unspent\" && !reserved.has(note.commitment)\n );\n for (const record of eligible)\n if (\n typeof record.note.amount !== \"bigint\" ||\n record.note.amount <= 0n ||\n record.note.amount >= 1n << 128n\n )\n throw new Error(\"invalid verified note amount\");\n eligible.sort((a, b) =>\n a.note.amount > b.note.amount\n ? -1\n : a.note.amount < b.note.amount\n ? 1\n : a.treeId < b.treeId\n ? -1\n : a.treeId > b.treeId\n ? 1\n : a.leafIndex - b.leafIndex || a.commitment.localeCompare(b.commitment)\n );\n const selected: T[] = [];\n let total = 0n;\n for (const record of eligible) {\n selected.push(structuredClone(record));\n total += record.note.amount;\n if (total >= target) return selected;\n }\n throw new Error(\"insufficient verified available funds\");\n}\n","import type {\n CreateCreditParams,\n Delivery,\n Hex,\n InputSource,\n} from \"@invisi-labs/protocol/contracts\";\nimport { getAddress, hexlify, toBeHex } from \"ethers\";\n\nimport {\n FIELD_MODULUS,\n normalizeCreditPolicy,\n applyCreditDrawUsage,\n ReceivingAddress,\n computeCreditNullifier,\n computeCreditRecoveryPad,\n createClue,\n deriveRemainderNonce,\n encryptCreditNote,\n generateCreditSharedKey,\n generateNonce,\n normalizeCreditDeliveryState,\n type CreditDeliveryState,\n} from \"@invisi-labs/core\";\nimport {\n WitnessBuilder,\n cancelCreditPublicInputs,\n createCreditPublicInputs,\n creditDrawPublicInputs,\n selectCreditDrawCircuit,\n topUpCreditPublicInputs,\n word,\n} from \"@invisi-labs/protocol\";\nimport type { CircuitName } from \"@invisi-labs/prover\";\nimport { creditLeaf } from \"./credit-values\";\n\nimport type {\n CancelCreditPreparation,\n CreateCreditPreparation,\n DrawCreditPreparation,\n OperationPlan,\n PreparationRuntime,\n PreparedCreditInput,\n PreparedCreditOutput,\n TopUpCreditPreparation,\n} from \"./operation-types\";\nimport { Preparation, positiveAmount, type PreparationFrame } from \"./prepare-common\";\n\nconst EMPTY: Delivery = { ciphertext: \"0x\", clue: \"0x\" };\n\n/** Current Credit roles, payout addresses and receiving snapshots are frozen before authorization. */\nexport class CreditPreparation<Result> {\n readonly #prepare: Preparation<Result>;\n\n constructor(readonly runtime: PreparationRuntime<Result>) {\n this.#prepare = new Preparation(runtime);\n }\n\n private expiry(value: bigint, frame: PreparationFrame): bigint {\n if (typeof value !== \"bigint\" || value <= frame.block.timestamp || value >= 1n << 64n) {\n throw new Error(\"Credit expiry must be a future uint64 timestamp\");\n }\n return value;\n }\n\n private async seal(\n input: CreditDeliveryState,\n frame: PreparationFrame\n ): Promise<PreparedCreditOutput> {\n const state = normalizeCreditDeliveryState(input);\n const commitment = await creditLeaf(state);\n const context = {\n chainId: frame.context.chainId,\n protocolAddress: BigInt(frame.context.protocolAddress),\n outputCommitment: commitment,\n };\n const deliveries = (await Promise.all(\n ([\"owner\", \"spender\"] as const).map(async (role) => {\n const keys =\n role === \"owner\" ? state.ownerReceivingKeys : state.spenderReceivingKeys;\n return {\n ciphertext: hexlify(\n await encryptCreditNote(keys.viewingPublicKey, state, { ...context, role })\n ) as Hex,\n clue: hexlify(createClue(keys.clueKey)) as Hex,\n };\n })\n )) as [Delivery, Delivery];\n return { state, commitment, deliveries };\n }\n\n private async input(\n commitment: Hex,\n role: \"owner\" | \"spender\",\n frame: PreparationFrame\n ): Promise<{ input: PreparedCreditInput; nullifier: Hex; source: InputSource }> {\n const stored = (await this.runtime.readInventory()).credits[commitment + \":\" + role];\n if (!stored || stored.spent !== \"unspent\" || stored.role !== role) {\n throw new Error(`confirmed unspent ${role} Credit is unavailable`);\n }\n const state = normalizeCreditDeliveryState(stored.state);\n const n = state.note;\n if (\n (role === \"owner\" ? n.ownerWalletIdentity : n.spenderWalletIdentity) !==\n this.runtime.scope.walletIdentity ||\n n.chainId !== frame.context.chainId ||\n n.protocolAddress !== BigInt(frame.context.protocolAddress) ||\n n.tokenAddress !== BigInt(frame.context.tokenAddress) ||\n (await creditLeaf(state)) !== commitment\n ) {\n throw new Error(\"Credit role, commitment or deployment mismatch\");\n }\n const proof = await this.#prepare.membership(stored, frame);\n const path = [...proof.path];\n const nullifier = await computeCreditNullifier(n.chainId, n.creditSharedKey, commitment);\n await this.#prepare.assertUnspent([nullifier], frame);\n return {\n input: {\n state,\n commitment,\n role,\n treeId: stored.treeId,\n leafIndex: stored.leafIndex,\n path,\n },\n nullifier,\n source: {\n treeId: stored.treeId,\n merkleRoot: proof.root,\n },\n };\n }\n\n private base(frame: PreparationFrame, kind: OperationPlan[\"kind\"]): OperationPlan {\n return {\n version: 1,\n id: crypto.randomUUID(),\n kind,\n context: frame.context,\n scope: this.runtime.scope,\n preparedAt: frame.block,\n deadline: frame.deadline,\n outputs: [],\n inputs: [],\n funding: {},\n fundingMode: \"none\",\n };\n }\n\n async create(options: CreateCreditPreparation): Promise<Result> {\n positiveAmount(options.amount, 126);\n const frame = await this.#prepare.frame(options.deadline);\n const expiry = this.expiry(options.expiry, frame);\n const spender = await ReceivingAddress.parse(options.spender).resolve(\n this.runtime.options.addressResolver\n );\n const owner = await this.runtime.options.wallet\n .getReceivingAddress()\n .resolve(this.runtime.options.addressResolver);\n const ownerPayout = getAddress(owner.walletIdentity) as Hex;\n const spenderPayout = getAddress(spender.walletIdentity) as Hex;\n if (BigInt(ownerPayout) === 0n || BigInt(spenderPayout) === 0n) {\n throw new Error(\"Credit payouts must be nonzero\");\n }\n const output = await this.seal(\n {\n note: {\n chainId: frame.context.chainId,\n protocolAddress: BigInt(frame.context.protocolAddress),\n tokenAddress: BigInt(frame.context.tokenAddress),\n ownerWalletIdentity: this.runtime.scope.walletIdentity,\n spenderWalletIdentity: spender.walletIdentity,\n ownerPayout: BigInt(ownerPayout),\n spenderPayout: BigInt(spenderPayout),\n ...normalizeCreditPolicy({\n singleLimit: options.singleLimit ?? 0n,\n dailyLimit: options.dailyLimit ?? 0n,\n monthlyLimit: options.monthlyLimit ?? 0n,\n }),\n amount: options.amount,\n ...(options.memo === undefined ? {} : { memo: options.memo }),\n expiry,\n nonce: generateNonce(),\n creditSharedKey: generateCreditSharedKey(),\n },\n ownerReceivingKeys: owner.getReceivingKeys(),\n spenderReceivingKeys: spender.getReceivingKeys(),\n },\n frame\n );\n return this.creation(\n this.base(frame, \"create-credit\"),\n output,\n options.amount,\n options.funding,\n frame\n );\n }\n\n private async creation(\n plan: OperationPlan,\n output: PreparedCreditOutput,\n delta: bigint,\n fundingSource: CreateCreditPreparation[\"funding\"],\n frame: PreparationFrame,\n previous?: Awaited<ReturnType<CreditPreparation<Result>[\"input\"]>>\n ): Promise<Result> {\n const funding = await this.#prepare.funding(fundingSource, frame);\n const selected = await this.#prepare.selectFunds(\n delta - (funding.funding.amount ?? 0n),\n frame,\n 10\n );\n const change = selected.amount + (funding.funding.amount ?? 0n) - delta;\n plan.inputs = selected.inputs;\n Object.assign(plan, funding);\n if (change > 0n) {\n plan.outputs.push(\n await this.#prepare.output(\n {\n to:\n this.runtime.changeAddress ??\n this.runtime.options.wallet.getReceivingAddress().toString(),\n amount: change,\n },\n frame.context,\n true\n )\n );\n }\n const creation: CreateCreditParams = {\n token: frame.context.tokenAddress,\n sources: selected.sources,\n nullifiers: selected.nullifiers,\n creditCommitment: output.commitment,\n changeCommitment: plan.outputs[0]?.commitment ?? word(0n),\n owner: getAddress(toBeHex(output.state.note.ownerPayout, 20) as Hex) as Hex,\n expiry: output.state.note.expiry,\n deadline: frame.deadline,\n };\n const deliveries = [...output.deliveries, plan.outputs[0]?.delivery ?? { ...EMPTY }];\n plan.capacity = 10;\n plan.credit = {\n inputs: previous ? [previous.input] : [],\n outputs: [output],\n deliveries,\n creation,\n };\n if (previous) {\n plan.credit.topUp = {\n creation,\n creditSource: previous.source,\n creditNullifier: previous.nullifier,\n previousExpiry: previous.input.state.note.expiry,\n };\n plan.statement = WitnessBuilder.statement(\n \"credit_top_up\",\n topUpCreditPublicInputs(frame.context, plan.credit.topUp, deliveries, plan.funding)\n );\n } else {\n plan.statement = WitnessBuilder.statement(\n \"create_credit\",\n createCreditPublicInputs(frame.context, creation, deliveries, plan.funding)\n );\n }\n await this.#prepare.assertBlock(frame);\n return this.runtime.complete(plan);\n }\n\n async topUp(options: TopUpCreditPreparation): Promise<Result> {\n positiveAmount(options.additionalAmount, 126);\n const frame = await this.#prepare.frame(options.deadline);\n const previous = await this.input(options.credit, \"owner\", frame);\n const old = previous.input.state;\n if (old.note.expiry <= frame.block.timestamp) {\n throw new Error(\"previous Credit has expired\");\n }\n const expiry = this.expiry(options.expiry ?? old.note.expiry, frame);\n if (expiry < old.note.expiry) {\n throw new Error(\"Credit expiry must not decrease\");\n }\n const amount = positiveAmount(old.note.amount + options.additionalAmount, 126);\n const output = await this.seal(\n {\n ...old,\n note: {\n ...old.note,\n singleLimit: options.singleLimit ?? old.note.singleLimit ?? 0n,\n dailyLimit: options.dailyLimit ?? old.note.dailyLimit ?? 0n,\n monthlyLimit: options.monthlyLimit ?? old.note.monthlyLimit ?? 0n,\n amount,\n expiry,\n nonce: generateNonce(),\n ...(options.memo === undefined ? {} : { memo: options.memo }),\n },\n },\n frame\n );\n return this.creation(\n this.base(frame, \"top-up-credit\"),\n output,\n options.additionalAmount,\n options.funding,\n frame,\n previous\n );\n }\n\n async draw(options: DrawCreditPreparation): Promise<Result> {\n const frame = await this.#prepare.frame(options.deadline);\n const profile = selectCreditDrawCircuit(options.credits.length);\n if (new Set(options.credits.map((value) => value.credit)).size !== options.credits.length) {\n throw new Error(\"duplicate Credit input\");\n }\n const members = await Promise.all(\n options.credits.map((value) => this.input(value.credit, \"spender\", frame))\n );\n const payout = members[0]!.input.state.note.spenderPayout;\n const sources = new Map<bigint, Hex>();\n const outputs: PreparedCreditOutput[] = [];\n const deliveries: Delivery[] = [];\n const recoveryAmounts: Hex[] = [];\n const remainders: Hex[] = [];\n const amounts: bigint[] = [];\n for (const [i, member] of members.entries()) {\n const state = member.input.state;\n const n = state.note;\n const amount = positiveAmount(options.credits[i]!.amount, 126);\n if (n.spenderPayout !== payout) {\n throw new Error(\n \"Credit draw requires separate groups for different public payouts; one call must be atomic\"\n );\n }\n this.expiry(n.expiry, frame);\n if (amount > n.amount) {\n throw new Error(\"Credit draw exceeds remaining amount\");\n }\n if (\n sources.has(member.source.treeId) &&\n sources.get(member.source.treeId) !== member.source.merkleRoot\n ) {\n throw new Error(\"Credit source root mismatch\");\n }\n sources.set(member.source.treeId, member.source.merkleRoot);\n amounts.push(amount);\n const usage = applyCreditDrawUsage(n, amount, frame.block.timestamp);\n const remaining = n.amount - amount;\n if (remaining === 0n) {\n remainders.push(word(0n));\n recoveryAmounts.push(word(0n));\n deliveries.push({ ...EMPTY }, { ...EMPTY });\n continue;\n }\n const args = [\n n.chainId,\n n.protocolAddress,\n n.tokenAddress,\n BigInt(member.nullifier),\n n.creditSharedKey,\n ] as const;\n const output = await this.seal(\n {\n ...state,\n note: {\n ...n,\n ...usage,\n amount: remaining,\n ...(options.credits[i]!.memo === undefined\n ? {}\n : { memo: options.credits[i]!.memo! }),\n nonce: await deriveRemainderNonce(...args),\n },\n },\n frame\n );\n outputs.push(output);\n remainders.push(output.commitment);\n recoveryAmounts.push(\n word((remaining + (await computeCreditRecoveryPad(...args))) % FIELD_MODULUS)\n );\n deliveries.push(...output.deliveries);\n }\n const plan = this.base(frame, \"draw-credit\");\n const params = {\n token: frame.context.tokenAddress,\n sources: [...sources]\n .sort(([a], [b]) => (a < b ? -1 : a > b ? 1 : 0))\n .map(([treeId, merkleRoot]) => ({ treeId, merkleRoot })),\n nullifiers: members.map((member) => member.nullifier),\n remainderCommitments: remainders,\n expiries: members.map((member) => member.input.state.note.expiry),\n recoveryAmounts,\n spender: getAddress(toBeHex(payout, 20) as Hex) as Hex,\n totalAmount: amounts.reduce((sum, amount) => sum + amount, 0n),\n deadline: frame.deadline,\n };\n plan.capacity = profile.maxSize;\n plan.credit = {\n inputs: members.map((member) => member.input),\n outputs,\n deliveries,\n draw: params,\n amounts,\n };\n plan.statement = WitnessBuilder.statement(\n profile.name as CircuitName,\n creditDrawPublicInputs(frame.context, params, deliveries)\n );\n await this.#prepare.assertBlock(frame);\n return this.runtime.complete(plan);\n }\n\n async cancel(options: CancelCreditPreparation): Promise<Result> {\n const frame = await this.#prepare.frame(options.deadline);\n const previous = await this.input(options.credit, \"owner\", frame);\n const n = previous.input.state.note;\n const plan = this.base(frame, \"cancel-credit\");\n const params = {\n token: frame.context.tokenAddress,\n source: previous.source,\n nullifier: previous.nullifier,\n owner: getAddress(toBeHex(n.ownerPayout, 20) as Hex) as Hex,\n amount: n.amount,\n deadline: frame.deadline,\n };\n plan.capacity = 1;\n plan.credit = { inputs: [previous.input], outputs: [], deliveries: [], cancel: params };\n plan.statement = WitnessBuilder.statement(\n \"credit_cancel\",\n cancelCreditPublicInputs(frame.context, params)\n );\n await this.#prepare.assertBlock(frame);\n return this.runtime.complete(plan);\n }\n}\n","import type {\n CanonicalBlock,\n ChainReader,\n DeploymentContext,\n ProtocolDataProvider,\n} from \"@invisi-labs/protocol\";\nimport type { ApplyPageOptions, CandidatePage } from \"./WalletUpdater\";\nimport type { BalanceSnapshot } from \"./state\";\n\nexport interface RefreshResult {\n block: CanonicalBlock;\n notes: number;\n credits: number;\n balances: BalanceSnapshot[];\n}\n\nexport interface RefreshOptions {\n /** Explicit history range; retain the returned block to request the next page later. */\n fromBlock: bigint;\n /** Defaults to the Protocol RPC's indexed head, independently checked against Chain RPC. */\n toBlock?: bigint;\n /** Explicit permission to delegate detection; never provide a viewing or spending key. */\n detectionKey?: Uint8Array;\n /** At most 100 blocks per service request. Reduce this on high-volume deployments. */\n pageSize?: number;\n signal?: AbortSignal;\n /** Rebuild private inventory from these pages while retaining uncertain operations. */\n reset?: boolean;\n}\n\nexport async function refreshWallet(\n runtime: {\n provider: ProtocolDataProvider;\n reader: Pick<ChainReader, \"getBlock\">;\n context: DeploymentContext;\n fromBlock: bigint;\n apply(batch: CandidatePage, options: ApplyPageOptions): Promise<RefreshResult>;\n },\n options: RefreshOptions\n): Promise<RefreshResult> {\n const { signal } = options;\n try {\n signal?.throwIfAborted();\n if (typeof options.fromBlock !== \"bigint\" || options.fromBlock < runtime.fromBlock)\n throw new Error(\"refresh range precedes deployment\");\n const pageSize = options.pageSize ?? 100;\n if (!Number.isInteger(pageSize) || pageSize < 1 || pageSize > 100)\n throw new Error(\"refresh page size must be 1..100\");\n const status = await runtime.provider.getStatus(runtime.context, {\n ...(signal ? { signal } : {}),\n });\n if (!status.indexedHead) throw new Error(\"Protocol RPC has not indexed any blocks\");\n const toBlock = options.toBlock ?? status.indexedHead.number;\n if (\n typeof toBlock !== \"bigint\" ||\n toBlock < options.fromBlock ||\n toBlock > status.indexedHead.number\n )\n throw new Error(\"refresh range is outside indexed history\");\n const target = await runtime.reader.getBlock(toBlock);\n if (target.number !== toBlock)\n throw new Error(\"Chain RPC returned the wrong refresh anchor\");\n let result: RefreshResult | undefined;\n let notes = 0;\n let credits = 0;\n for (let from = options.fromBlock; from <= toBlock; from += BigInt(pageSize)) {\n signal?.throwIfAborted();\n const end = from + BigInt(pageSize) - 1n;\n const page = await runtime.provider.getUpdates(runtime.context, {\n fromBlock: from,\n toBlock: end < toBlock ? end : toBlock,\n ...(options.detectionKey ? { detectionKey: options.detectionKey } : {}),\n ...(signal ? { signal } : {}),\n });\n if (page.block.number !== (end < toBlock ? end : toBlock))\n throw new Error(\"Protocol RPC returned the wrong page anchor\");\n result = await runtime.apply(\n {\n context: runtime.context,\n transactionHashes: page.transactionHashes,\n block: target,\n },\n {\n ...(signal ? { signal } : {}),\n ...(from === options.fromBlock && options.reset ? { reset: true } : {}),\n }\n );\n notes += result.notes;\n credits += result.credits;\n }\n return { ...result!, notes, credits };\n } finally {\n // The caller retains its own key; only this request's copied key is cleared.\n options.detectionKey?.fill(0);\n }\n}\n","import { NullifierCapability } from \"@invisi-labs/core\";\nimport type { Hex } from \"@invisi-labs/protocol/contracts\";\nimport type { CanonicalBlock, ProtocolDataProvider } from \"@invisi-labs/protocol\";\nimport { decryptCandidates, type DeliveryEventLog } from \"./discovery\";\nimport {\n CanonicalConflict,\n CreditMetadataMismatch,\n InventoryProcessor,\n type InventoryOptions,\n} from \"./inventory\";\nimport { mergeReceiptRecords, mergeSpentObservation } from \"./receipts\";\nimport { verifyMembership } from \"./membership\";\nimport type { RefreshResult } from \"./refresh\";\nimport { readProtocolLogs } from \"./receipt-logs\";\nimport { walletBalances, type StoredCredit, type StoredNote } from \"./state\";\n\n/** Internal candidate references from Protocol RPC; never a claim of complete wallet history. */\nexport interface CandidatePage {\n context: { chainId: bigint; protocolAddress: Hex };\n block: CanonicalBlock;\n transactionHashes: readonly Hex[];\n}\nexport interface ApplyPageOptions {\n signal?: AbortSignal;\n /** Rebuild private inventory from supplied history after a reorg; preserves uncertain operations. */\n reset?: boolean;\n}\nconst check: (value: unknown, message: string) => asserts value = (value, message) => {\n if (!value) throw new Error(message);\n};\nconst position = (treeId: bigint, leafIndex: number) => `${treeId}:${leafIndex}`;\n\n/** Authenticates indexed candidates before updating private wallet state. */\nexport class WalletUpdater extends InventoryProcessor {\n readonly #options: InventoryOptions & { protocolRpc: ProtocolDataProvider };\n\n constructor(options: InventoryOptions & { protocolRpc: ProtocolDataProvider }) {\n super(options);\n this.#options = { ...options };\n check(\n options.viewing.walletIdentity === options.scope.walletIdentity,\n \"viewing capability wallet mismatch\"\n );\n }\n\n applyUpdates(batch: CandidatePage, options: ApplyPageOptions = {}): Promise<RefreshResult> {\n return this.run(structuredClone(batch), { ...options });\n }\n\n private async run(batch: CandidatePage, options: ApplyPageOptions): Promise<RefreshResult> {\n const { reader, protocol, scope, store, viewing } = this.#options;\n const nullifier = NullifierCapability.fromIdentity(scope.walletIdentity);\n const { signal, reset } = options;\n signal?.throwIfAborted();\n const context = protocol.context;\n check(\n batch.context.chainId === context.chainId &&\n batch.context.protocolAddress.toLowerCase() ===\n context.protocolAddress.toLowerCase(),\n \"update deployment context mismatch\"\n );\n check(\n batch.block.number >= protocol.deployment.protocol.fromBlock,\n \"update precedes deployment\"\n );\n await protocol.validateDeployment(reader);\n const base = await store.readSnapshot(scope);\n check(reset || !base.invalidated, \"wallet state is invalidated; rebuild required\");\n try {\n if (!reset) {\n for (const cursor of [base.observedThrough]) {\n if (!cursor) continue;\n if ((await reader.getBlock(cursor.number)).hash !== cursor.hash)\n throw new CanonicalConflict(\"Canonical history changed after a reorg\");\n check(\n cursor.number <= batch.block.number,\n \"update target precedes wallet checkpoint\"\n );\n }\n } else {\n base.notes = {};\n base.credits = {};\n }\n const block = await reader.getBlock(batch.block.number);\n check(\n block.hash === batch.block.hash && block.number === batch.block.number,\n \"update target block is not canonical\"\n );\n const receipts = [];\n for (const hash of new Set(batch.transactionHashes)) {\n signal?.throwIfAborted();\n check(/^0x[0-9a-fA-F]{64}$/.test(hash), \"invalid candidate transaction hash\");\n const receipt = await reader.getReceipt(hash);\n check(\n receipt &&\n receipt.status === \"success\" &&\n receipt.transactionHash.toLowerCase() === hash.toLowerCase(),\n \"invalid or unsuccessful candidate receipt\"\n );\n check(\n receipt.block.number >= protocol.deployment.protocol.fromBlock &&\n receipt.block.number <= block.number,\n \"candidate receipt outside update range\"\n );\n if ((await reader.getBlock(receipt.block.number)).hash !== receipt.block.hash)\n throw new CanonicalConflict(\"Candidate receipt disagrees with canonical chain\");\n receipts.push(receipt);\n }\n const logs = receipts.flatMap((receipt) =>\n readProtocolLogs(receipt, context.protocolAddress)\n );\n logs.sort((a, b) =>\n a.blockNumber! < b.blockNumber!\n ? -1\n : a.blockNumber! > b.blockNumber!\n ? 1\n : a.logIndex! - b.logIndex!\n );\n // Positions come from independently obtained canonical receipts, not service metadata.\n const leaves = new Map<string, bigint>();\n for (const event of logs) {\n if (event.eventName !== \"CommitmentsInserted\" && event.eventName !== \"BatchOutputs\")\n continue;\n const { treeId, startLeafIndex, commitments } = event.args as {\n treeId: bigint;\n startLeafIndex: bigint;\n commitments: Hex[];\n };\n for (const [i, commitment] of commitments.entries()) {\n const key = position(treeId, Number(startLeafIndex) + i);\n check(\n !leaves.has(key) || leaves.get(key) === BigInt(commitment),\n \"conflicting canonical insertion\"\n );\n leaves.set(key, BigInt(commitment));\n }\n }\n const getLeaf = (tree: bigint, index: number) => {\n const leaf = leaves.get(position(tree, index));\n check(leaf !== undefined, \"missing canonical insertion\");\n return leaf;\n };\n const decrypted = await decryptCandidates(logs, {\n context,\n viewing,\n confirmedThrough: block.number,\n });\n const notes: StoredNote[] = decrypted.notes.map((record) => ({\n ...record,\n spent: \"unknown\",\n }));\n const incoming: StoredCredit[] = decrypted.credits.map((record) => ({\n ...record,\n spent: \"unknown\",\n }));\n const recovered = await this.recoverCredits(base, incoming, logs, { getLeaf });\n const creditsByKey = new Map(\n incoming.map((record) => [record.commitment + \":\" + record.role, record])\n );\n for (const record of recovered)\n creditsByKey.set(record.commitment + \":\" + record.role, record);\n const credits = [...creditsByKey.values()]\n .filter((record) => {\n try {\n this.checkSnapshotKeys(record);\n return true;\n } catch (error) {\n if (error instanceof CreditMetadataMismatch) return false;\n throw error;\n }\n })\n .sort((a, b) =>\n a.blockNumber < b.blockNumber\n ? -1\n : a.blockNumber > b.blockNumber\n ? 1\n : a.treeId < b.treeId\n ? -1\n : a.treeId > b.treeId\n ? 1\n : a.leafIndex - b.leafIndex\n );\n for (const record of [...notes, ...credits]) {\n signal?.throwIfAborted();\n const proof = await this.#options.protocolRpc.getMembership(context, record, block);\n const tokenAddress =\n \"note\" in record ? record.note.tokenAddress : record.state.note.tokenAddress;\n await verifyMembership(\n reader,\n {\n ...context,\n tokenAddress: `0x${tokenAddress.toString(16).padStart(40, \"0\")}`,\n },\n block,\n record,\n proof\n );\n }\n const allNotes = {\n ...base.notes,\n ...Object.fromEntries(notes.map((record) => [record.commitment, record])),\n };\n const allCredits = {\n ...base.credits,\n ...Object.fromEntries(\n credits.map((record) => [record.commitment + \":\" + record.role, record])\n ),\n };\n const observations: Array<{ kind: \"notes\" | \"credits\"; id: string; nullifier: Hex }> =\n [];\n for (const [id, record] of Object.entries(allNotes))\n observations.push({\n kind: \"notes\",\n id,\n nullifier: await nullifier.compute(\n scope.chainId,\n record.commitment,\n record.note.nonce\n ),\n });\n for (const [id, record] of Object.entries(allCredits))\n observations.push({\n kind: \"credits\",\n id,\n nullifier: await this.creditNullifier(record.state),\n });\n const spent = observations.length\n ? await reader.isSpent(\n context,\n observations.map((item) => item.nullifier),\n block\n )\n : [];\n check(\n spent.length === observations.length &&\n spent.every((value) => typeof value === \"boolean\"),\n \"invalid spent-state response\"\n );\n signal?.throwIfAborted();\n if ((await reader.getBlock(block.number)).hash !== block.hash)\n throw new CanonicalConflict(\"Canonical block changed during update\");\n await store.transaction(scope, (draft) => {\n signal?.throwIfAborted();\n check(draft.revision === base.revision, \"wallet changed during update; retry\");\n if (reset) {\n this.reorgOperations(draft);\n draft.notes = {};\n draft.credits = {};\n delete draft.observedThrough;\n delete draft.invalidated;\n }\n mergeReceiptRecords(draft, { notes, credits, checkpoint: block });\n observations.forEach((item, index) => {\n const record = draft[item.kind][item.id];\n if (record) {\n mergeSpentObservation(record, {\n spent: spent[index] ? \"spent\" : \"unspent\",\n checkedThrough: { number: block.number, hash: block.hash },\n });\n }\n });\n // Candidate processing cannot establish complete or FMD scan coverage.\n draft.observedThrough = { number: block.number, hash: block.hash };\n });\n return {\n block,\n notes: notes.length,\n credits: credits.length,\n balances: walletBalances(await store.readSnapshot(scope)),\n };\n } catch (error) {\n if (error instanceof CanonicalConflict) await this.invalidate();\n throw error;\n }\n }\n}\n","import type { Hex } from \"@invisi-labs/protocol/contracts\";\n\nimport {\n encodeMemo,\n computeCreditCommitment,\n computeCreditNullifier,\n computeCreditSharedKeyHash,\n recoverCreditRemainder,\n type CreditDeliveryState,\n type ReceivingKeys,\n type ViewingCapability,\n} from \"@invisi-labs/core\";\nimport type { Protocol, ChainReader } from \"@invisi-labs/protocol\";\nimport type { DeliveryEventLog, DiscoveredCredit } from \"./discovery\";\nimport type { StoredCredit, WalletScope, WalletState, WalletStore } from \"./state\";\n\nexport class CanonicalConflict extends Error {}\n\nexport class CreditMetadataMismatch extends Error {}\n\nfunction check(value: unknown, message: string): asserts value {\n if (!value) {\n throw new Error(message);\n }\n}\n\nconst clone = <T>(value: T): T => structuredClone(value);\n\nconst hex = (value: bigint): Hex => `0x${value.toString(16).padStart(64, \"0\")}`;\n\nexport interface InventoryOptions {\n protocol: Protocol;\n scope: WalletScope;\n store: WalletStore;\n reader: ChainReader;\n viewing: Pick<ViewingCapability, \"walletIdentity\" | \"decryptNote\" | \"decryptCredit\">;\n receivingKeys?: ReceivingKeys;\n}\n\n/** Authenticated private inventory handling for indexed candidate ingestion. */\nexport abstract class InventoryProcessor {\n readonly #options: InventoryOptions;\n\n constructor(options: InventoryOptions) {\n this.#options = { ...options, scope: Object.freeze({ ...options.scope }) };\n }\n\n protected reorgOperations(state: WalletState): void {\n for (const operation of Object.values(state.operations)) {\n if (\n [\"failed\", \"expired\"].includes(operation.status) &&\n !(operation.payload as { externalized?: boolean } | undefined)?.externalized\n ) {\n continue;\n }\n operation.status = \"reorged\";\n for (const id of operation.inputs) {\n if (!state.reservations[id]) {\n state.reservations[id] = operation.id;\n }\n }\n }\n }\n\n protected async invalidate(): Promise<void> {\n const { store, scope } = this.#options;\n await store.transaction(scope, (state) => {\n state.invalidated = \"Canonical history changed; rebuild inventory from canonical data\";\n for (const record of [...Object.values(state.notes), ...Object.values(state.credits)]) {\n record.spent = \"unknown\";\n }\n this.reorgOperations(state);\n });\n }\n\n protected checkSnapshotKeys(record: DiscoveredCredit | StoredCredit): void {\n const expected = this.#options.receivingKeys;\n const keys =\n record.role === \"owner\"\n ? record.state.ownerReceivingKeys\n : record.state.spenderReceivingKeys;\n if (\n expected &&\n !keys.viewingPublicKey.every((byte, i) => byte === expected.viewingPublicKey[i])\n ) {\n throw new CreditMetadataMismatch(\"Credit receiving key snapshot mismatch\");\n }\n const clue = expected?.clueKey;\n if (clue && !keys.clueKey.every((byte, i) => byte === clue[i])) {\n throw new CreditMetadataMismatch(\"Credit clue key snapshot mismatch\");\n }\n }\n\n protected async creditNullifier(state: CreditDeliveryState): Promise<Hex> {\n const n = state.note;\n return computeCreditNullifier(\n n.chainId,\n n.creditSharedKey,\n await computeCreditCommitment(\n n.chainId,\n n.spenderWalletIdentity,\n n.ownerWalletIdentity,\n n.spenderPayout,\n n.ownerPayout,\n n.tokenAddress,\n n.amount,\n n.nonce,\n n.expiry,\n await computeCreditSharedKeyHash(n.creditSharedKey),\n n\n )\n );\n }\n\n protected async recoverCredits(\n base: WalletState,\n found: readonly StoredCredit[],\n logs: readonly DeliveryEventLog[],\n snapshot: { getLeaf(treeId: bigint, leafIndex: number): bigint | Promise<bigint> }\n ): Promise<StoredCredit[]> {\n const known = new Map<string, StoredCredit>();\n const byNullifier = new Map<Hex, Set<string>>();\n const cachedNullifiers = new Map<Hex, Hex>();\n const recovered: StoredCredit[] = [];\n const foundByKey = new Map(\n found.map((record) => [record.commitment + \":\" + record.role, record])\n );\n const remember = async (record: StoredCredit) => {\n const key = record.commitment + \":\" + record.role;\n let nullifier = cachedNullifiers.get(record.commitment);\n if (!nullifier) {\n nullifier = await this.creditNullifier(record.state);\n cachedNullifiers.set(record.commitment, nullifier);\n }\n known.set(key, record);\n let members = byNullifier.get(nullifier);\n if (!members) {\n members = new Set();\n byNullifier.set(nullifier, members);\n }\n members.add(key);\n };\n const matching = (nullifier: Hex) =>\n [...(byNullifier.get(nullifier) ?? [])].map((key) => known.get(key)!);\n for (const record of Object.values(base.credits)) {\n await remember(record);\n }\n for (const record of found) {\n try {\n this.checkSnapshotKeys(record);\n await remember({ ...record, spent: \"unknown\" });\n } catch (error) {\n if (!(error instanceof CreditMetadataMismatch)) {\n throw error;\n }\n }\n }\n const context = {\n chainId: this.#options.scope.chainId,\n protocolAddress: BigInt(this.#options.scope.protocolAddress),\n };\n for (const event of logs) {\n if (event.eventName === \"CreditDraw\") {\n const block = await this.#options.reader.getBlock(event.blockNumber!);\n if (block.hash !== event.blockHash)\n throw new CanonicalConflict(\"draw block changed during Credit recovery\");\n const args = event.args!;\n const params = args.params as {\n nullifiers: readonly Hex[];\n remainderCommitments: readonly Hex[];\n recoveryAmounts: readonly Hex[];\n expiries: readonly bigint[];\n };\n const indices = args.remainderLeafIndices as readonly number[];\n check(\n Array.isArray(params.nullifiers) &&\n params.nullifiers.length === params.remainderCommitments.length &&\n params.nullifiers.length === params.recoveryAmounts.length &&\n params.nullifiers.length === params.expiries.length &&\n params.nullifiers.length === indices.length,\n \"invalid draw recovery slots\"\n );\n for (const [index, nullifier] of params.nullifiers.entries()) {\n for (const previous of matching(nullifier)) {\n check(\n previous.state.note.expiry === params.expiries[index],\n \"draw recovery expiry mismatch\"\n );\n const remainder = await recoverCreditRemainder(\n context,\n previous.state.note,\n {\n timestamp: block.timestamp,\n creditNullifier: nullifier,\n remainderCommitment: params.remainderCommitments[index]!,\n recoveryAmount: BigInt(params.recoveryAmounts[index]!),\n }\n );\n if (!remainder) {\n continue;\n }\n // Financial recovery alone cannot establish uncommitted child metadata.\n const child = foundByKey.get(\n params.remainderCommitments[index]! + \":\" + previous.role\n );\n const memo = child?.state.note.memo;\n const record: StoredCredit = {\n commitment: params.remainderCommitments[index]!,\n treeId: BigInt(args.outputTreeId as bigint),\n leafIndex: Number(indices[index]),\n blockNumber: event.blockNumber!,\n blockHash: event.blockHash!,\n transactionHash: event.transactionHash!,\n role: previous.role,\n state: {\n ...clone(previous.state),\n note: {\n ...remainder,\n ...(memo === undefined ? {} : { memo: encodeMemo(memo) }),\n },\n },\n receivingKeySource: { kind: \"draw\", commitment: previous.commitment },\n spent: \"unknown\",\n };\n check(\n (await snapshot.getLeaf(record.treeId, record.leafIndex)) ===\n BigInt(record.commitment),\n \"draw recovery canonical leaf mismatch\"\n );\n this.checkSnapshotKeys(record);\n await remember(record);\n recovered.push(record);\n }\n }\n } else if (event.eventName === \"CreditToppedUp\") {\n const params = event.args!.params as {\n creditNullifier: Hex;\n creation: { creditCommitment: Hex };\n };\n for (const previous of matching(params.creditNullifier)) {\n const child = foundByKey.get(\n params.creation.creditCommitment + \":\" + previous.role\n );\n if (!child) {\n continue;\n }\n const old = previous.state.note;\n const next = child.state.note;\n if (\n [\n \"chainId\",\n \"protocolAddress\",\n \"tokenAddress\",\n \"spenderWalletIdentity\",\n \"ownerWalletIdentity\",\n \"spenderPayout\",\n \"ownerPayout\",\n \"creditSharedKey\",\n ].some(\n (field) =>\n old[field as keyof typeof old] !== next[field as keyof typeof next]\n ) ||\n next.amount <= old.amount ||\n next.expiry < old.expiry\n ) {\n continue;\n }\n const repaired: StoredCredit = {\n ...clone(child),\n state: {\n note: clone(next),\n ownerReceivingKeys: clone(previous.state.ownerReceivingKeys),\n spenderReceivingKeys: clone(previous.state.spenderReceivingKeys),\n },\n receivingKeySource: { kind: \"top-up\", commitment: previous.commitment },\n };\n this.checkSnapshotKeys(repaired);\n await remember(repaired);\n recovered.push(repaired);\n }\n }\n }\n return recovered;\n }\n}\n","import type { WalletState } from \"./state\";\nimport type { WalletRecordCodec } from \"./store\";\n// Tagged nodes avoid collisions between application strings/objects and BigInt encodings.\nfunction encode(value: unknown): unknown {\n if (typeof value === \"bigint\") return [\"bigint\", value.toString()];\n if (value instanceof Uint8Array) return [\"bytes\", Array.from(value)];\n if (Array.isArray(value)) return [\"array\", value.map(encode)];\n if (value && typeof value === \"object\")\n return [\"object\", Object.entries(value).map(([key, item]) => [key, encode(item)])];\n if (value === undefined) return [\"undefined\"];\n if (\n value === null ||\n typeof value === \"string\" ||\n typeof value === \"boolean\" ||\n (typeof value === \"number\" && Number.isFinite(value))\n )\n return [\"value\", value];\n throw new Error(\"unsupported wallet record value\");\n}\nfunction decode(node: unknown): unknown {\n if (!Array.isArray(node)) throw new Error(\"invalid wallet record encoding\");\n const [type, value] = node;\n if (type === \"bigint\" && typeof value === \"string\" && /^-?(0|[1-9][0-9]*)$/.test(value))\n return BigInt(value);\n if (\n type === \"bytes\" &&\n Array.isArray(value) &&\n value.every((n) => Number.isInteger(n) && n >= 0 && n < 256)\n )\n return Uint8Array.from(value);\n if (type === \"array\" && Array.isArray(value)) return value.map(decode);\n if (type === \"object\" && Array.isArray(value))\n return Object.fromEntries(\n value.map((pair) => {\n if (!Array.isArray(pair) || pair.length !== 2 || typeof pair[0] !== \"string\")\n throw new Error(\"invalid object record\");\n return [pair[0], decode(pair[1])];\n })\n );\n if (type === \"undefined\" && node.length === 1) return undefined;\n if (\n type === \"value\" &&\n (value === null ||\n typeof value === \"string\" ||\n typeof value === \"boolean\" ||\n (typeof value === \"number\" && Number.isFinite(value)))\n )\n return value;\n throw new Error(\"invalid wallet record node\");\n}\nexport function serializeState(state: WalletState): Uint8Array {\n return new TextEncoder().encode(JSON.stringify(encode(state)));\n}\nexport function deserializeState(data: Uint8Array): WalletState {\n return decode(\n JSON.parse(new TextDecoder(\"utf-8\", { fatal: true }).decode(data))\n ) as WalletState;\n}\n/** Only for explicitly nonpersistent reference storage. Persistent adapters require a caller-selected codec. */\nexport class MemoryRecordCodec implements WalletRecordCodec {\n async encode(state: WalletState) {\n return serializeState(state);\n }\n async decode(data: Uint8Array) {\n return deserializeState(data);\n }\n}\n","export * from \"./codec\";\nexport * from \"./DisclosureVerifier\";\nexport * from \"./receipts\";\nexport * from \"./reservations\";\nexport * from \"./state\";\nexport * from \"./store\";\nimport { MemoryRecordCodec } from \"./codec\";\nimport { MemoryAtomicRecords, TransactionalWalletStore } from \"./store\";\n/** Explicit ephemeral state for demos and applications that choose memory-only operation. */\nexport class MemoryWalletStore extends TransactionalWalletStore {\n constructor() {\n super(new MemoryAtomicRecords(), new MemoryRecordCodec(), { persistent: false });\n }\n}\n\nexport * from \"./Operation\";\nexport type {\n CancelCreditPreparation,\n CoinSelector,\n CreateCreditPreparation,\n DrawCreditPreparation,\n FundingAuthorizationVerifier,\n FundingSigner,\n FundingSource,\n FundingTypedData,\n OperationAggregateMember,\n PaymentOutput,\n ShieldPreparation,\n TopUpCreditPreparation,\n TransferPreparation,\n WalletSessionOptions,\n WithdrawalPreparation,\n SweepPreparation,\n} from \"./operation-types\";\nexport * from \"./WalletSession\";\n\nexport type { RefreshOptions, RefreshResult } from \"./refresh\";\n"],"mappings":";;;;;AAUO,SAAS,qBAAqB,YAA4B;AAC7D,SAAO,YAAY;AACvB;AAmFO,SAAS,cAAc,OAAoB,cAAoC;AAClF,MAAI,iBAAiB;AACrB,MAAI,WAAW;AACf,MAAI,UAAU,CAAC,CAAC,MAAM;AACtB,QAAM,UAAU,OAAO,OAAO,MAAM,KAAK,EAAE;AAAA,IACvC,CAAC,MAAM,EAAE,KAAK,iBAAiB,OAAO,YAAY;AAAA,EACtD;AACA,QAAM,SAAS,QAAQ,IAAI,CAAC,WAAW,OAAO,cAAc;AAC5D,MAAI,iBAAoC;AACxC,MACI,QAAQ,UACR,OAAO,MAAM,CAAC,UAAU,UAAU,MAAS,KAC3C,QAAQ,MAAM,CAAC,WAAW,OAAO,UAAU,SAAS,GACtD;AACE,qBAAiB,OAAO;AAAA,MAAO,CAAC,UAAU,UACtC,MAAO,SAAS,SAAU,SAAS,QAAQ;AAAA,IAC/C;AAAA,EACJ,WAAW,CAAC,QAAQ,QAAQ;AACxB,qBAAiB,MAAM,mBAAmB;AAAA,EAC9C;AACA,MAAI,CAAC,QAAQ,UAAU,CAAC,gBAAgB;AACpC,cAAU;AAAA,EACd;AACA,aAAW,CAAC,IAAI,MAAM,KAAK,OAAO,QAAQ,MAAM,KAAK,GAAG;AACpD,QAAI,OAAO,KAAK,iBAAiB,OAAO,YAAY,EAAG;AACvD,QAAI,OAAO,UAAU,SAAS;AAC1B,wBAAkB,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zDO,IAAM,oBAAN,cAAgC,yBAAyB;AAAA,EAC5D,cAAc;AACV,UAAM,IAAI,oBAAoB,GAAG,IAAI,kBAAkB,GAAG,EAAE,YAAY,MAAM,CAAC;AAAA,EACnF;AACJ;","names":["index","current","hash","current","reference","index","check","canonical","candidate","address","sha256","bytesToHex","check","word","Interface","invisiProtocolAbi","buildTransactCalldata","canonical","FIELD_MODULUS","check","hash","index","check","current","hash","getAddress","MissingCapabilityError","getAddress","transactUserPublicInputs","WitnessBuilder","MissingCapabilityError","ReceivingAddress","normalizeFunding","normalizeFunding","ReceivingAddress","MissingCapabilityError","getAddress","hexlify","FIELD_MODULUS","ReceivingAddress","computeCreditNullifier","createClue","generateNonce","normalizeCreditDeliveryState","WitnessBuilder","cancelCreditPublicInputs","createCreditPublicInputs","creditDrawPublicInputs","topUpCreditPublicInputs","word","normalizeCreditDeliveryState","hexlify","createClue","computeCreditNullifier","ReceivingAddress","getAddress","generateNonce","word","WitnessBuilder","topUpCreditPublicInputs","createCreditPublicInputs","FIELD_MODULUS","creditDrawPublicInputs","cancelCreditPublicInputs","getAddress","statement","WitnessBuilder","transactUserPublicInputs","encodeMemo","computeCreditCommitment","computeCreditNullifier","computeCreditSharedKeyHash","check","computeCreditNullifier","computeCreditCommitment","computeCreditSharedKeyHash","check","index","encodeMemo","check","position","hash","index","MissingCapabilityError","getAddress"]}
|