@thruputchain/client 0.27.0 → 0.28.0

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.
Files changed (104) hide show
  1. package/README.md +9 -6
  2. package/dist/{actions-DK_XBeVy.cjs → actions-B5-CjpEF.cjs} +6 -6
  3. package/dist/{actions-DK_XBeVy.cjs.map → actions-B5-CjpEF.cjs.map} +1 -1
  4. package/dist/{actions-1LmkZcfS.js → actions-C1SMLWO5.js} +6 -6
  5. package/dist/{actions-1LmkZcfS.js.map → actions-C1SMLWO5.js.map} +1 -1
  6. package/dist/actions.cjs +2 -2
  7. package/dist/actions.d.cts +3 -3
  8. package/dist/actions.d.ts +3 -3
  9. package/dist/actions.js +2 -2
  10. package/dist/{client-DocSdzOL.d.cts → client-jOZxB8yW.d.cts} +10 -2
  11. package/dist/client-jOZxB8yW.d.cts.map +1 -0
  12. package/dist/{client-DocSdzOL.d.ts → client-jOZxB8yW.d.ts} +10 -2
  13. package/dist/client-jOZxB8yW.d.ts.map +1 -0
  14. package/dist/{codec-C4LJ0g8v.cjs → codec-BcK8ASsg.cjs} +315 -1
  15. package/dist/{codec-C4LJ0g8v.cjs.map → codec-BcK8ASsg.cjs.map} +1 -1
  16. package/dist/{codec-BOjoJjC5.js → codec-Bxlt1gKO.js} +315 -1
  17. package/dist/{codec-BOjoJjC5.js.map → codec-Bxlt1gKO.js.map} +1 -1
  18. package/dist/{contract-Cu8Qv94_.js → contract-D77iA2iY.js} +2 -2
  19. package/dist/{contract-Cu8Qv94_.js.map → contract-D77iA2iY.js.map} +1 -1
  20. package/dist/{contract-DPm2BJTu.cjs → contract-DSu2UPPm.cjs} +2 -2
  21. package/dist/{contract-DPm2BJTu.cjs.map → contract-DSu2UPPm.cjs.map} +1 -1
  22. package/dist/contract.cjs +1 -1
  23. package/dist/contract.d.cts +2 -2
  24. package/dist/contract.d.ts +2 -2
  25. package/dist/contract.js +1 -1
  26. package/dist/contracts.cjs +3 -3
  27. package/dist/contracts.d.cts +3 -3
  28. package/dist/contracts.d.ts +3 -3
  29. package/dist/contracts.js +3 -3
  30. package/dist/{dev_wallet-BcvX_xT4.cjs → dev_wallet-CAbOSrak.cjs} +2 -2
  31. package/dist/{dev_wallet-BcvX_xT4.cjs.map → dev_wallet-CAbOSrak.cjs.map} +1 -1
  32. package/dist/{dev_wallet-B5R5JJaw.js → dev_wallet-CU3RpQLm.js} +2 -2
  33. package/dist/{dev_wallet-B5R5JJaw.js.map → dev_wallet-CU3RpQLm.js.map} +1 -1
  34. package/dist/{execution-C8oQgpO3.d.cts → execution-J5jkXhV1.d.cts} +3 -3
  35. package/dist/{execution-C8oQgpO3.d.cts.map → execution-J5jkXhV1.d.cts.map} +1 -1
  36. package/dist/{execution-DsZzqv_C.d.ts → execution-XJ0iwFaX.d.ts} +3 -3
  37. package/dist/{execution-DsZzqv_C.d.ts.map → execution-XJ0iwFaX.d.ts.map} +1 -1
  38. package/dist/{index-CHnfHuQo.d.ts → index-Bb01ytjJ.d.ts} +4 -4
  39. package/dist/{index-CHnfHuQo.d.ts.map → index-Bb01ytjJ.d.ts.map} +1 -1
  40. package/dist/{index-Zaz-e8Sy.d.ts → index-C3HVRvQd.d.ts} +2 -2
  41. package/dist/{index-Zaz-e8Sy.d.ts.map → index-C3HVRvQd.d.ts.map} +1 -1
  42. package/dist/{index-BmQN3jAS.d.cts → index-CedOvhGY.d.cts} +2 -2
  43. package/dist/{index-BmQN3jAS.d.cts.map → index-CedOvhGY.d.cts.map} +1 -1
  44. package/dist/{index-CuzB95QT.d.cts → index-CtjWsAXV.d.cts} +4 -4
  45. package/dist/{index-CuzB95QT.d.cts.map → index-CtjWsAXV.d.cts.map} +1 -1
  46. package/dist/{index-C3qDR1J5.d.cts → index-CtjZ61tl.d.cts} +2 -2
  47. package/dist/{index-C3qDR1J5.d.cts.map → index-CtjZ61tl.d.cts.map} +1 -1
  48. package/dist/{index-hqEnT64w.d.ts → index-DeS1S0m-.d.ts} +2 -2
  49. package/dist/{index-hqEnT64w.d.ts.map → index-DeS1S0m-.d.ts.map} +1 -1
  50. package/dist/{index-CKqC9N4o.d.ts → index-DfmDUk5Y.d.ts} +4 -4
  51. package/dist/{index-CKqC9N4o.d.ts.map → index-DfmDUk5Y.d.ts.map} +1 -1
  52. package/dist/{index-rrP1HJ2Z.d.cts → index-soFVQX9j.d.cts} +4 -4
  53. package/dist/{index-rrP1HJ2Z.d.cts.map → index-soFVQX9j.d.cts.map} +1 -1
  54. package/dist/index.cjs +9 -9
  55. package/dist/index.d.cts +9 -9
  56. package/dist/index.d.ts +9 -9
  57. package/dist/index.js +9 -9
  58. package/dist/{readError-Cz3bveZa.cjs → readError-CCVlmBhj.cjs} +5 -3
  59. package/dist/{readError-Cz3bveZa.cjs.map → readError-CCVlmBhj.cjs.map} +1 -1
  60. package/dist/{readError-Z5zuylri.js → readError-D1dppovI.js} +5 -3
  61. package/dist/{readError-Z5zuylri.js.map → readError-D1dppovI.js.map} +1 -1
  62. package/dist/{readViews-CQOY5v4o.d.cts → readViews-DbWELMMq.d.cts} +2 -2
  63. package/dist/{readViews-CQOY5v4o.d.cts.map → readViews-DbWELMMq.d.cts.map} +1 -1
  64. package/dist/{readViews-BvMHbiaF.d.ts → readViews-nV3jbpYc.d.ts} +2 -2
  65. package/dist/{readViews-BvMHbiaF.d.ts.map → readViews-nV3jbpYc.d.ts.map} +1 -1
  66. package/dist/{sendInvocation-8TEMrJ_M.cjs → sendInvocation-Dsr9ij5P.cjs} +5 -5
  67. package/dist/{sendInvocation-8TEMrJ_M.cjs.map → sendInvocation-Dsr9ij5P.cjs.map} +1 -1
  68. package/dist/{sendInvocation-CkeMyLk1.js → sendInvocation-tBmf8haQ.js} +5 -5
  69. package/dist/{sendInvocation-CkeMyLk1.js.map → sendInvocation-tBmf8haQ.js.map} +1 -1
  70. package/dist/signed-op.cjs +2 -2
  71. package/dist/signed-op.d.cts +1 -1
  72. package/dist/signed-op.d.ts +1 -1
  73. package/dist/signed-op.js +2 -2
  74. package/dist/{signedOp-BDUZhfJn.cjs → signedOp-DAucp6xg.cjs} +3 -3
  75. package/dist/{signedOp-BDUZhfJn.cjs.map → signedOp-DAucp6xg.cjs.map} +1 -1
  76. package/dist/{signedOp-Kx8u8_3I.js → signedOp-DpmUpH-e.js} +3 -3
  77. package/dist/{signedOp-Kx8u8_3I.js.map → signedOp-DpmUpH-e.js.map} +1 -1
  78. package/dist/{signed_op-Dxn7-lRu.js → signed_op-CwN-_CXw.js} +2 -2
  79. package/dist/{signed_op-Dxn7-lRu.js.map → signed_op-CwN-_CXw.js.map} +1 -1
  80. package/dist/{signed_op-BrLxDrDb.d.cts → signed_op-D2usgASc.d.cts} +3 -3
  81. package/dist/{signed_op-BrLxDrDb.d.cts.map → signed_op-D2usgASc.d.cts.map} +1 -1
  82. package/dist/{signed_op-CAcYYRm6.cjs → signed_op-_lR85dn2.cjs} +2 -2
  83. package/dist/{signed_op-CAcYYRm6.cjs.map → signed_op-_lR85dn2.cjs.map} +1 -1
  84. package/dist/{signed_op-DbRq3_Hb.d.ts → signed_op-zGq4eBo8.d.ts} +3 -3
  85. package/dist/{signed_op-DbRq3_Hb.d.ts.map → signed_op-zGq4eBo8.d.ts.map} +1 -1
  86. package/dist/{transport-DqlfAsuH.cjs → transport-5FPeNwuv.cjs} +3 -3
  87. package/dist/{transport-DqlfAsuH.cjs.map → transport-5FPeNwuv.cjs.map} +1 -1
  88. package/dist/{transport-PstrCcBv.js → transport-IrhVlS4w.js} +3 -3
  89. package/dist/{transport-PstrCcBv.js.map → transport-IrhVlS4w.js.map} +1 -1
  90. package/dist/transport.cjs +3 -3
  91. package/dist/transport.d.cts +3 -3
  92. package/dist/transport.d.ts +3 -3
  93. package/dist/transport.js +3 -3
  94. package/dist/{wallet-Blh7oas7.cjs → wallet-7R5M_7h4.cjs} +3 -3
  95. package/dist/{wallet-Blh7oas7.cjs.map → wallet-7R5M_7h4.cjs.map} +1 -1
  96. package/dist/{wallet-5wt9wLG3.js → wallet-BNKgOXrF.js} +3 -3
  97. package/dist/{wallet-5wt9wLG3.js.map → wallet-BNKgOXrF.js.map} +1 -1
  98. package/dist/wallet.cjs +2 -2
  99. package/dist/wallet.d.cts +2 -2
  100. package/dist/wallet.d.ts +2 -2
  101. package/dist/wallet.js +2 -2
  102. package/package.json +1 -1
  103. package/dist/client-DocSdzOL.d.cts.map +0 -1
  104. package/dist/client-DocSdzOL.d.ts.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"sendInvocation-CkeMyLk1.js","names":["bytesEqual","sign"],"sources":["../src/actions/deadline.ts","../src/actions/public/waitForTransactionReceipt.ts","../src/wallet/invocationAdapter.ts","../src/wallet/execution.ts","../src/actions/wallet/prepareTransaction.ts","../src/actions/wallet/sendInvocation.ts"],"sourcesContent":["/** Run one operation within the caller's wall-clock budget and cancellation signal. */\nexport async function beforeDeadline<T>(\n operation: (signal: AbortSignal) => Promise<T>,\n deadline: number,\n caller: AbortSignal | undefined,\n timeout: () => Error,\n): Promise<T> {\n caller?.throwIfAborted();\n if (performance.now() >= deadline) throw timeout();\n const controller = new AbortController();\n const signal = caller\n ? AbortSignal.any([caller, controller.signal])\n : controller.signal;\n let timer: ReturnType<typeof setTimeout> | undefined;\n let onAbort = () => {};\n try {\n return await Promise.race([\n new Promise<T>((_, reject) => {\n onAbort = () => reject(signal.reason);\n signal.addEventListener(\"abort\", onAbort, { once: true });\n timer = setTimeout(\n () => controller.abort(timeout()),\n Math.ceil(Math.max(0, deadline - performance.now())),\n );\n }),\n operation(signal),\n ]);\n } finally {\n if (timer !== undefined) clearTimeout(timer);\n signal.removeEventListener(\"abort\", onAbort);\n controller.abort();\n }\n}\nexport function validateTimer(value: number, field: string): void {\n if (!Number.isFinite(value) || value < 0 || value > 2147483647)\n throw new RangeError(`${field} must be between 0 and 2147483647`);\n}\nexport function waitDelay(delay: number, signal: AbortSignal): Promise<void> {\n return new Promise((resolve, reject) => {\n signal.throwIfAborted();\n const finish = () => {\n signal.removeEventListener(\"abort\", abort);\n resolve();\n };\n const timer = setTimeout(finish, delay);\n const abort = () => {\n clearTimeout(timer);\n signal.removeEventListener(\"abort\", abort);\n reject(signal.reason);\n };\n signal.addEventListener(\"abort\", abort, { once: true });\n });\n}\n","import { toBase58 } from \"../../encoding.js\";\nimport type { RpcClient } from \"../../rpc/client.js\";\nimport { RpcCompatibilityError } from \"../../rpc/client.js\";\nimport { NativeRpcError } from \"../../rpc/errorReader.js\";\nimport {\n UnsupportedRpcValue,\n RpcDecodingError,\n RpcRequestValidationError,\n} from \"../../rpc/codec.js\";\nimport type { TransactionReceipt, TransactionStatus } from \"../../types/rpc.js\";\nimport { classifyReadError } from \"../../transport/readError.js\";\nimport { beforeDeadline, validateTimer, waitDelay } from \"../deadline.js\";\n\nexport interface KnownCommitment {\n readonly networkHash: Uint8Array;\n readonly transactionHash: Uint8Array;\n readonly blockHeight: bigint;\n}\nexport interface WaitForTransactionReceiptOptions {\n signal?: AbortSignal;\n /** Verified before each observation; omission uses discovery's validated network. */\n expectedNetworkHash?: Uint8Array;\n knownCommitment?: KnownCommitment;\n /** Observed status, including optional advisory attempt diagnostics. Never retry permission. */\n onStatus?: (status: TransactionStatus) => void;\n timeoutMs?: number;\n pollingIntervalMs?: number;\n}\n/** Observation stopped; neither timeout nor cancellation proves nonexecution. */\nexport class TransactionReceiptObservationError extends Error {\n constructor(\n readonly transactionHash: Uint8Array,\n readonly knownCommitment: KnownCommitment | undefined,\n readonly lastStatus: TransactionStatus | undefined,\n cause: unknown,\n ) {\n super(`Could not observe transaction ${toBase58(transactionHash)}`, {\n cause,\n });\n this.name = \"TransactionReceiptObservationError\";\n }\n}\nexport class TransactionReceiptTimeoutError extends TransactionReceiptObservationError {\n constructor(\n transactionHash: Uint8Array,\n knownCommitment: KnownCommitment | undefined,\n lastStatus: TransactionStatus | undefined,\n cause?: unknown,\n ) {\n super(transactionHash, knownCommitment, lastStatus, cause);\n this.name = \"TransactionReceiptTimeoutError\";\n this.message = `Timed out waiting for transaction ${toBase58(transactionHash)}`;\n }\n}\nconst equal = (a: Uint8Array, b: Uint8Array) =>\n a.length === b.length && a.every((v, i) => v === b[i]);\n/** Read-only capabilities used by commitment and receipt observation. */\nexport type ReceiptObserver = Pick<\n RpcClient,\n | \"getNetworkInfo\"\n | \"getTransactionReceipt\"\n | \"getTransactionStatus\"\n | \"discovery\"\n | \"requireMethods\"\n>;\n\n/** Return any committed receipt, including failed execution. Never sign or resubmit. */\nexport async function waitForTransactionReceipt(\n client: ReceiptObserver,\n transactionHash: Uint8Array,\n options: WaitForTransactionReceiptOptions = {},\n): Promise<TransactionReceipt> {\n return (await observe(\n client,\n transactionHash,\n options,\n false,\n )) as TransactionReceipt;\n}\n/** Observe commitment independently of receipt availability or execution success. */\nexport async function waitForCommitment(\n client: ReceiptObserver,\n transactionHash: Uint8Array,\n options: WaitForTransactionReceiptOptions = {},\n): Promise<KnownCommitment> {\n return (await observe(\n client,\n transactionHash,\n options,\n true,\n )) as KnownCommitment;\n}\n// Status evidence includes extensible values at arbitrary nested schema positions.\n// structuredClone alone drops their UnsupportedRpcValue class identity.\nfunction snapshotStatus(status: TransactionStatus): TransactionStatus {\n const copy = (value: unknown): unknown => {\n if (value instanceof UnsupportedRpcValue)\n return new UnsupportedRpcValue(structuredClone(value.raw));\n if (Array.isArray(value)) return value.map(copy);\n if (ArrayBuffer.isView(value)) return structuredClone(value);\n if (value !== null && typeof value === \"object\")\n return Object.fromEntries(\n Object.entries(value).map(([key, entry]) => [key, copy(entry)]),\n );\n return value;\n };\n return copy(status) as TransactionStatus;\n}\n\nasync function observe(\n client: ReceiptObserver,\n hash: Uint8Array,\n options: WaitForTransactionReceiptOptions,\n commitmentOnly: boolean,\n): Promise<TransactionReceipt | KnownCommitment> {\n const timeoutMs = options.timeoutMs ?? 30000;\n const interval = options.pollingIntervalMs ?? 250;\n validateTimer(timeoutMs, \"timeoutMs\");\n validateTimer(interval, \"pollingIntervalMs\");\n const transactionHash = new Uint8Array(hash);\n const networkHash = new Uint8Array(\n options.expectedNetworkHash ?? client.discovery.network.networkHash,\n );\n if (transactionHash.length !== 32 || networkHash.length !== 32)\n throw new RangeError(\n \"Transaction and network hashes must contain 32 bytes\",\n );\n let commitment: KnownCommitment | undefined;\n let lastStatus: TransactionStatus | undefined;\n if (options.knownCommitment) {\n const known = options.knownCommitment;\n if (\n !equal(known.transactionHash, transactionHash) ||\n !equal(known.networkHash, networkHash) ||\n typeof known.blockHeight !== \"bigint\" ||\n known.blockHeight < 0n ||\n known.blockHeight > 9223372036854775807n\n )\n throw new RpcCompatibilityError(\n \"Known commitment does not match the transaction/network context\",\n );\n commitment = {\n transactionHash: transactionHash.slice(),\n networkHash: networkHash.slice(),\n blockHeight: known.blockHeight,\n };\n lastStatus = { status: \"committed\", blockHeight: known.blockHeight };\n }\n client.requireMethods([\n \"getNetworkInfo\",\n \"getTransactionReceipt\",\n \"getTransactionStatus\",\n ]);\n const deadline = performance.now() + timeoutMs;\n let lastFailure: unknown;\n let failures = 0;\n const timeout = () =>\n new TransactionReceiptTimeoutError(\n transactionHash.slice(),\n commitment && structuredClone(commitment),\n lastStatus,\n lastFailure,\n );\n const run = <T>(operation: (signal: AbortSignal) => Promise<T>) =>\n beforeDeadline(operation, deadline, options.signal, timeout);\n const retain = (blockHeight: bigint) => {\n if (commitment && commitment.blockHeight !== blockHeight)\n throw new RpcCompatibilityError(\n \"Conflicting commitment heights for the same transaction\",\n );\n commitment = {\n transactionHash: transactionHash.slice(),\n networkHash: networkHash.slice(),\n blockHeight,\n };\n lastStatus = { status: \"committed\", blockHeight };\n };\n try {\n while (true) {\n let retryAfterMs: bigint | undefined;\n let networkVerified = false;\n let failed = false;\n try {\n const network = await run((signal) =>\n client.getNetworkInfo({}, { signal }),\n );\n if (!equal(network.networkHash, networkHash))\n throw new RpcCompatibilityError(\n \"Observation endpoint network changed\",\n );\n networkVerified = true;\n if (commitmentOnly && commitment) return structuredClone(commitment);\n const receipt = await run((signal) =>\n client.getTransactionReceipt({ transactionHash }, { signal }),\n );\n if (receipt) {\n retain(receipt.blockHeight);\n return commitmentOnly ? structuredClone(commitment!) : receipt;\n }\n } catch (cause) {\n lastFailure = cause;\n failed = true;\n if (\n cause instanceof NativeRpcError &&\n cause.decoded.classification === \"known\"\n ) {\n const data = cause.decoded.data;\n if (data.kind === \"backendDataInvalid\" && data.observation) {\n retain(data.observation.blockHeight);\n if (commitmentOnly) return structuredClone(commitment!);\n }\n if (\"retryAfterMs\" in data) retryAfterMs = data.retryAfterMs;\n }\n if (\n options.signal?.aborted ||\n classifyReadError(cause, options) !== \"transient\"\n )\n throw cause;\n }\n // Status failures cannot erase a previously validated commitment.\n let observedStatus: TransactionStatus | undefined;\n if (networkVerified)\n try {\n const status = await run((signal) =>\n client.getTransactionStatus({ transactionHash }, { signal }),\n );\n if (\n !(status instanceof UnsupportedRpcValue) &&\n status.status === \"committed\"\n )\n retain(status.blockHeight);\n else if (!commitment) lastStatus = snapshotStatus(status);\n observedStatus = status;\n } catch (cause) {\n if (\n cause instanceof RpcCompatibilityError ||\n cause instanceof RpcDecodingError ||\n cause instanceof RpcRequestValidationError ||\n classifyReadError(cause, options) === \"permanent\"\n )\n throw cause;\n options.signal?.throwIfAborted();\n lastFailure = cause;\n failed = true;\n if (\n cause instanceof NativeRpcError &&\n cause.decoded.classification === \"known\" &&\n \"retryAfterMs\" in cause.decoded.data\n ) {\n const hint = cause.decoded.data.retryAfterMs;\n if (\n hint !== undefined &&\n (retryAfterMs === undefined || hint > retryAfterMs)\n )\n retryAfterMs = hint;\n }\n }\n if (observedStatus !== undefined) options.onStatus?.(observedStatus);\n if (failed) failures++;\n else {\n failures = 0;\n lastFailure = undefined;\n }\n if (commitmentOnly && commitment) return structuredClone(commitment);\n const backoff = failures\n ? Math.min(\n 5000,\n Math.max(1, interval) * 2 ** Math.min(failures - 1, 8),\n ) *\n (0.5 + Math.random() / 2)\n : interval;\n const remaining = deadline - performance.now();\n if (\n retryAfterMs !== undefined &&\n retryAfterMs > BigInt(Math.max(0, Math.floor(remaining)))\n )\n throw timeout();\n const delay = Math.max(backoff, Number(retryAfterMs ?? 0n));\n await run((signal) =>\n waitDelay(Math.min(delay, Math.max(0, remaining)), signal),\n );\n }\n } catch (cause) {\n if (cause instanceof TransactionReceiptTimeoutError) throw cause;\n throw new TransactionReceiptObservationError(\n transactionHash,\n commitment && structuredClone(commitment),\n lastStatus,\n cause,\n );\n }\n}\n","import {\n codec,\n contractAddress,\n serialize,\n type ContractAddress,\n type GasAmount,\n type Invocation,\n} from \"@thruputchain/protocol\";\nimport { fixedBytes } from \"@thruputchain/xdr\";\nimport { bytesEqual } from \"../contract/event.js\";\nimport { DefaultWallet } from \"../contracts/default_wallet.js\";\nimport { DevWallet } from \"../contracts/dev_wallet.js\";\nimport { MAX_DEFAULT_WALLET_CALLS } from \"../provider/validation.js\";\nimport type { ContractDeployment, DeploymentOptions } from \"./deployment.js\";\nimport type { TransactionReceipt } from \"../types/rpc.js\";\n\n/** Common inputs for wrapping one inner invocation through a wallet contract. */\nexport interface WalletExecutionRequest {\n readonly invocation: Invocation;\n /** Gas available to the wallet's root invocation. */\n readonly gasLimit: GasAmount;\n}\n\n/** Ordered inner calls for one atomic DefaultWallet execution. */\nexport interface WalletBatchExecutionRequest {\n readonly invocations: readonly Invocation[];\n /** Gas available to the complete wallet root, including all calls. */\n readonly gasLimit: GasAmount;\n}\n\n/** Build a root batch directly, copying call bytes before asynchronous work. */\nexport function createDefaultWalletBatchInvocation(\n accountAddress: ContractAddress,\n request: WalletBatchExecutionRequest,\n): Invocation {\n if (\n !Array.isArray(request.invocations) ||\n request.invocations.length < 1 ||\n request.invocations.length > MAX_DEFAULT_WALLET_CALLS\n )\n throw new RangeError(\"DefaultWallet requires 1 to 16 calls\");\n return DefaultWallet.v0_1.execute.invocation(\n contractAddress(new Uint8Array(accountAddress)),\n request.gasLimit,\n {\n calls: request.invocations.map((inner) => ({\n target: contractAddress(new Uint8Array(inner.invoked_address)),\n entrypoint: fixedBytes(new Uint8Array(inner.entrypoint), 8),\n gas_limit: inner.gas_limit,\n calldata: new Uint8Array(inner.calldata),\n })),\n },\n );\n}\n\n/** Converts a wallet-specific execution request into a root invocation. */\nexport interface WalletInvocationAdapter<\n TRequest extends WalletExecutionRequest = WalletExecutionRequest,\n> {\n /** Build a root deployment when supported by this wallet. */\n createDeploymentInvocation?(\n account: ContractAddress,\n deployment: ContractDeployment,\n options: DeploymentOptions,\n ): Invocation;\n /** Decode the address returned by a root deployment. */\n decodeDeploymentReceipt?(receipt: TransactionReceipt): ContractAddress;\n /** Child return buffers in call order, or null when this wallet discards them. */\n decodeExecutionReturns?(\n receipt: TransactionReceipt,\n ): readonly Uint8Array[] | null;\n /** Build one atomic root for multiple calls when this wallet supports it. */\n createBatchRootInvocation?(\n account: ContractAddress,\n request: WalletBatchExecutionRequest,\n ): Invocation;\n createRootInvocation(\n accountAddress: ContractAddress,\n request: TRequest,\n ): Invocation;\n}\n\n/** Define an invocation adapter while preserving its request type. */\nexport function defineWalletInvocationAdapter<\n TRequest extends WalletExecutionRequest,\n>(\n adapter: WalletInvocationAdapter<TRequest>,\n): WalletInvocationAdapter<TRequest> {\n return adapter;\n}\n\n/** Wrap one call through the native-compatible DefaultWallet interface. */\nexport const defaultWalletAdapter = defineWalletInvocationAdapter({\n createBatchRootInvocation: createDefaultWalletBatchInvocation,\n decodeExecutionReturns: (receipt) =>\n DefaultWallet.v0_1.execute.decodeReceipt(receipt).value,\n createDeploymentInvocation(account, deployment, options) {\n if (\n options.initializer &&\n !bytesEqual(options.initializer.invoked_address, deployment.address)\n )\n throw new Error(\n \"Initializer must target the predicted deployment address\",\n );\n // The wallet takes an i128, but a deployment never funds a negative amount.\n if (options.amount < 0n)\n throw new RangeError(\"Deployment amount must not be negative\");\n return DefaultWallet.v0_1.deploy.invocation(account, options.gasLimit, {\n nonce: fixedBytes(deployment.deploymentNonce, 32),\n contractHash: fixedBytes(deployment.contractHash, 32),\n amount: options.amount,\n initializer: options.initializer\n ? {\n entrypoint: fixedBytes(options.initializer.entrypoint, 8),\n gas_limit: options.initializer.gas_limit,\n calldata: options.initializer.calldata,\n }\n : null,\n });\n },\n decodeDeploymentReceipt: (receipt) =>\n DefaultWallet.v0_1.deploy.decodeReceipt(receipt).value,\n createRootInvocation(\n accountAddress: ContractAddress,\n request: WalletExecutionRequest,\n ): Invocation {\n return createDefaultWalletBatchInvocation(accountAddress, {\n invocations: [request.invocation],\n gasLimit: request.gasLimit,\n });\n },\n});\n\n/** Wrap one call through the legacy DevWallet. Unified deployment is unsupported. */\nexport const devWalletAdapter = defineWalletInvocationAdapter({\n decodeExecutionReturns: () => null,\n createRootInvocation(\n accountAddress: ContractAddress,\n request: WalletExecutionRequest,\n ): Invocation {\n return DevWallet.v0_1.doAction.invocation(\n contractAddress(new Uint8Array(accountAddress)),\n request.gasLimit,\n {\n invocationBytes: serialize(request.invocation, codec.Invocation),\n },\n );\n },\n});\n","import { codec, deserialize } from \"@thruputchain/protocol\";\nimport { hashSignedTransaction } from \"../derivation/transactionHash.js\";\nimport { RpcCompatibilityError } from \"../rpc/client.js\";\nimport {\n RpcRequestValidationError,\n UnsupportedRpcValue,\n} from \"../rpc/codec.js\";\nimport { NativeRpcError } from \"../rpc/errorReader.js\";\nimport {\n TransactionReceiptObservationError,\n type KnownCommitment,\n} from \"../actions/public/waitForTransactionReceipt.js\";\nimport { gasAmount, type GasAmount } from \"@thruputchain/protocol\";\nimport type { CoreThruputClient } from \"../client.js\";\nimport type { TransactionReceipt } from \"../types/rpc.js\";\nimport type { WaitForTransactionReceiptOptions } from \"../actions/public/waitForTransactionReceipt.js\";\nimport type { ContractCall } from \"../contract/method.js\";\nimport {\n defaultWalletAdapter,\n type WalletInvocationAdapter,\n} from \"./invocationAdapter.js\";\nimport { beforeDeadline, validateTimer } from \"../actions/deadline.js\";\nimport { toBase58 } from \"../encoding.js\";\nimport type { RpcSendTransactionResult } from \"../rpc/generated.js\";\n\n/** A committed execution failure, retaining the complete native receipt. */\nexport class TransactionExecutionError extends Error {\n constructor(\n readonly receipt: TransactionReceipt,\n readonly submission?: SubmissionEvidence,\n ) {\n super(\n receipt.execution instanceof UnsupportedRpcValue\n ? `Transaction ${toBase58(receipt.transactionHash)} has an unsupported execution outcome`\n : `Transaction ${toBase58(receipt.transactionHash)} execution failed (${receipt.execution.result})`,\n );\n this.name = \"TransactionExecutionError\";\n }\n}\n/** A future execution variant is unsupported, never inferred to be success or failure. */\nexport class UnsupportedTransactionOutcomeError extends TransactionExecutionError {\n constructor(receipt: TransactionReceipt, submission?: SubmissionEvidence) {\n super(receipt, submission);\n this.name = \"UnsupportedTransactionOutcomeError\";\n }\n}\nexport function assertTransactionSuccess(\n receipt: TransactionReceipt,\n submission?: SubmissionEvidence,\n): asserts receipt is TransactionReceipt & {\n execution: { result: \"return\"; returnData: Uint8Array };\n} {\n if (receipt.execution instanceof UnsupportedRpcValue)\n throw new UnsupportedTransactionOutcomeError(receipt, submission);\n if (receipt.execution.result !== \"return\")\n throw new TransactionExecutionError(receipt, submission);\n}\n\n/** A submit response that does not establish the currently supported admission outcome. */\nexport class UnsupportedTransactionAdmissionError extends Error {\n constructor(readonly response: RpcSendTransactionResult) {\n super(\"Transaction submission returned an unsupported admission outcome\");\n this.name = \"UnsupportedTransactionAdmissionError\";\n }\n}\n\n/** Keep low-level future values intact, but never project them into an admitted hash. */\nexport function assertTransactionAdmission(\n response: RpcSendTransactionResult,\n): void {\n if (response.admission !== \"accepted\")\n throw new UnsupportedTransactionAdmissionError(response);\n}\nexport interface SubmissionEvidence {\n readonly signedTransaction: Uint8Array;\n readonly transactionHash: Uint8Array;\n readonly networkHash: Uint8Array;\n}\n/** Snapshot approved bytes before submission; accessor copies protect the retained record. */\nexport function createSubmissionEvidence(\n bytes: Uint8Array,\n network: Uint8Array,\n): SubmissionEvidence {\n const signedTransaction = new Uint8Array(bytes);\n const networkHash = new Uint8Array(network);\n if (networkHash.length !== 32)\n throw new RangeError(\"networkHash must contain 32 bytes\");\n const transactionHash = hashSignedTransaction(\n deserialize(signedTransaction, codec.SignedTransaction),\n );\n return Object.freeze({\n get signedTransaction() {\n return signedTransaction.slice();\n },\n get transactionHash() {\n return transactionHash.slice();\n },\n get networkHash() {\n return networkHash.slice();\n },\n });\n}\nexport interface ExecutionResult {\n transactionHash: Uint8Array;\n receipt: TransactionReceipt;\n submission?: SubmissionEvidence;\n}\n/** Submission or observation stopped, preserving exact approved bytes and commitment. */\nexport class TransactionObservationError extends Error {\n constructor(\n readonly submission: SubmissionEvidence,\n cause: unknown,\n readonly submissionCause?: unknown,\n readonly knownCommitment?: KnownCommitment,\n readonly phase:\n | \"beforeSubmission\"\n | \"submission\"\n | \"observation\" = \"observation\",\n ) {\n super(\n `Could not complete transaction ${toBase58(submission.transactionHash)}`,\n { cause },\n );\n this.name = \"TransactionObservationError\";\n }\n get transactionHash(): Uint8Array {\n return this.submission.transactionHash;\n }\n}\n/** Submit once, then reconcile only by reads. No path replaces or repeats signed bytes. */\nexport async function submitAndObserve(\n client: Pick<CoreThruputClient, \"waitForTransactionReceipt\">,\n evidence: SubmissionEvidence,\n submit: (signal: AbortSignal) => Promise<void>,\n options?: WaitForTransactionReceiptOptions,\n wasDispatched?: () => boolean,\n): Promise<ExecutionResult> {\n const submission = createSubmissionEvidence(\n evidence.signedTransaction,\n evidence.networkHash,\n );\n const timeoutMs = options?.timeoutMs ?? 30000;\n validateTimer(timeoutMs, \"timeoutMs\");\n const deadline = performance.now() + timeoutMs;\n let submissionCause: unknown;\n try {\n options?.signal?.throwIfAborted();\n if (timeoutMs === 0)\n throw new Error(\"Transaction submission timed out before dispatch\");\n } catch (cause) {\n throw new TransactionObservationError(\n submission,\n cause,\n undefined,\n undefined,\n \"beforeSubmission\",\n );\n }\n try {\n await beforeDeadline(\n submit,\n deadline,\n options?.signal,\n () => new Error(\"Transaction submission timed out\"),\n );\n } catch (cause) {\n if (\n wasDispatched?.() === false ||\n cause instanceof RpcRequestValidationError ||\n cause instanceof RpcCompatibilityError\n )\n throw new TransactionObservationError(\n submission,\n cause,\n undefined,\n undefined,\n \"beforeSubmission\",\n );\n if (\n cause instanceof NativeRpcError &&\n cause.decoded.classification === \"known\" &&\n (cause.decoded.data.kind === \"invalidParams\" ||\n cause.decoded.data.kind === \"transactionInvalid\" ||\n cause.decoded.data.kind === \"transactionRejected\")\n )\n throw new TransactionObservationError(\n submission,\n cause,\n undefined,\n undefined,\n \"submission\",\n );\n submissionCause = cause;\n if (options?.signal?.aborted || performance.now() >= deadline)\n throw new TransactionObservationError(\n submission,\n cause,\n submissionCause,\n undefined,\n \"submission\",\n );\n }\n try {\n const receipt = await client.waitForTransactionReceipt(\n submission.transactionHash,\n {\n ...options,\n expectedNetworkHash: submission.networkHash,\n timeoutMs: Math.max(0, deadline - performance.now()),\n },\n );\n return { transactionHash: receipt.transactionHash, receipt, submission };\n } catch (cause) {\n throw new TransactionObservationError(\n submission,\n cause,\n submissionCause,\n cause instanceof TransactionReceiptObservationError\n ? cause.knownCommitment\n : undefined,\n );\n }\n}\n/** Wait for a committed receipt, then require execution success. */\nexport async function waitForExecution(\n client: Pick<CoreThruputClient, \"waitForTransactionReceipt\">,\n hash: Uint8Array,\n options?: WaitForTransactionReceiptOptions,\n): Promise<ExecutionResult> {\n const receipt = await client.waitForTransactionReceipt(hash, options);\n assertTransactionSuccess(receipt);\n return { transactionHash: receipt.transactionHash, receipt };\n}\n\n/** Ordered result types for a tuple of calls. */\nexport type CallResults<T extends readonly ContractCall[]> = {\n [K in keyof T]: T[K] extends ContractCall<infer R> ? R : never;\n};\n\n/**\n * Decode DefaultWallet child returns without modifying the root receipt.\n * Works after disconnect and preserves call order. Supply an adapter for other\n * wallets. Wallets such as DevWallet that discard child return data report\n * unavailable results. Failed wallet receipts are not decoded with a child ABI:\n * even a single child call does not establish where an abort originated.\n */\nexport function decodeExecution<T extends readonly ContractCall[]>(\n receipt: TransactionReceipt,\n calls: T,\n adapter: WalletInvocationAdapter = defaultWalletAdapter,\n submission?: SubmissionEvidence,\n): CallResults<T> {\n // Even one child call can fail in the wallet root; its abort bytes are not a child receipt.\n assertTransactionSuccess(receipt, submission);\n try {\n const buffers = adapter.decodeExecutionReturns?.(receipt);\n if (buffers == null)\n throw new ExecutionReturnUnavailableError(receipt, submission);\n if (buffers.length !== calls.length)\n throw new Error(\n `Returned ${buffers.length} child results; expected ${calls.length}`,\n );\n return calls.map((call, index) =>\n call.method.decodeReturn(buffers[index]!),\n ) as CallResults<T>;\n } catch (cause) {\n if (cause instanceof ExecutionReturnUnavailableError) throw cause;\n throw new ExecutionDecodeError(receipt, cause, submission);\n }\n}\n\n/** A committed successful execution whose return data could not be decoded. */\nexport class ExecutionDecodeError extends Error {\n constructor(\n readonly receipt: TransactionReceipt,\n cause: unknown,\n readonly submission?: SubmissionEvidence,\n ) {\n super(\n `Transaction ${toBase58(receipt.transactionHash)} committed, but result decoding failed: ${cause instanceof Error ? cause.message : String(cause)}`,\n { cause },\n );\n this.name = \"ExecutionDecodeError\";\n }\n}\n\n/** Execution succeeded, but this wallet does not preserve child return buffers. */\nexport class ExecutionReturnUnavailableError extends Error {\n constructor(\n readonly receipt: TransactionReceipt,\n readonly submission?: SubmissionEvidence,\n ) {\n super(\n `Transaction ${toBase58(receipt.transactionHash)} committed successfully, but its wallet does not expose child return data`,\n );\n this.name = \"ExecutionReturnUnavailableError\";\n }\n}\n\n/**\n * Sum explicit child budgets and a calibrated wallet overhead, checking u64 bounds.\n * This is not gas estimation. Calibrate budgets against the target runtime and\n * workload; there is no universally safe wallet overhead. Root gas reserves\n * scheduling capacity against the sender's free native-token balance. Storage\n * deposits are a separate requirement, and funding a target contract does not\n * sponsor root gas.\n */\nexport function walletGasLimit(\n calls: readonly { gas_limit: GasAmount }[],\n overhead: GasAmount,\n): GasAmount {\n const limits = [overhead, ...calls.map((call) => call.gas_limit)];\n if (limits.some((limit) => typeof limit !== \"bigint\" || limit < 0n))\n throw new RangeError(\"Gas budgets must be nonnegative bigint values\");\n const total = limits.reduce((sum, limit) => sum + limit, 0n);\n if (total > 0xffff_ffff_ffff_ffffn)\n throw new RangeError(\"Root gas budget exceeds u64\");\n return gasAmount(total);\n}\n","import {\n blockHeight,\n codec,\n deserialize,\n serialize,\n type BlockHeight,\n type Contract,\n type Invocation,\n type Transaction,\n} from \"@thruputchain/protocol\";\nimport type { CoreThruputClient } from \"../../client.js\";\nimport type { WalletAccount } from \"../../wallet/account.js\";\nimport { createTransaction } from \"../../transaction/build.js\";\n\nconst int64Max = 0x7fff_ffff_ffff_ffffn;\nconst uint64Max = 0xffff_ffff_ffff_ffffn;\nconst defaultExpiryBlocks = 100n;\n\n/** Inputs for preparing one wallet-authorized transaction. */\nexport interface PrepareTransactionRequest {\n /** Explicit root invocation. Smart-wallet wrapping is caller-controlled. */\n readonly invocation: Invocation;\n readonly contractsToDeploy?: readonly Contract[];\n readonly nonce?: bigint;\n readonly blockExpiryHeight?: BlockHeight;\n readonly expiryBlocks?: bigint;\n}\n\n/** Prepare an unsigned transaction for a wallet account. */\nexport async function prepareTransaction(\n client: Pick<CoreThruputClient, \"getChainTip\">,\n account: Pick<WalletAccount, \"address\" | \"authClaim\">,\n request: PrepareTransactionRequest,\n): Promise<Transaction> {\n const invocation = deserialize(\n serialize(request.invocation, codec.Invocation),\n codec.Invocation,\n );\n const contractsToDeploy = (request.contractsToDeploy ?? []).map((contract) =>\n deserialize(serialize(contract, codec.Contract), codec.Contract),\n );\n const authClaim = deserialize(\n serialize(account.authClaim, codec.AuthClaim),\n codec.AuthClaim,\n );\n\n if (!bytesEqual(invocation.invoked_address, account.address)) {\n throw new Error(\"Root invocation address must match the wallet account\");\n }\n if (\n request.blockExpiryHeight !== undefined &&\n request.expiryBlocks !== undefined\n ) {\n throw new Error(\n \"blockExpiryHeight and expiryBlocks are mutually exclusive\",\n );\n }\n\n const nonce = request.nonce ?? randomUint64();\n validateRange(nonce, 0n, uint64Max, \"nonce\");\n\n let expiry: bigint;\n if (request.blockExpiryHeight !== undefined) {\n expiry = request.blockExpiryHeight;\n validateRange(expiry, 0n, int64Max, \"blockExpiryHeight\");\n } else {\n const expiryBlocks = request.expiryBlocks ?? defaultExpiryBlocks;\n validateRange(expiryBlocks, 1n, int64Max, \"expiryBlocks\");\n const tip = await client.getChainTip();\n expiry = tip.blockHeight + expiryBlocks;\n validateRange(expiry, 0n, int64Max, \"blockExpiryHeight\");\n }\n\n return createTransaction({\n invocation,\n uniquifier: {\n block_expiry_height: blockHeight(expiry),\n nonce,\n },\n contracts_to_deploy: contractsToDeploy,\n auth_claim: authClaim,\n });\n}\n\nfunction randomUint64(): bigint {\n const bytes = crypto.getRandomValues(new Uint8Array(8));\n return new DataView(\n bytes.buffer,\n bytes.byteOffset,\n bytes.byteLength,\n ).getBigUint64(0);\n}\n\nfunction validateRange(\n value: bigint,\n min: bigint,\n max: bigint,\n name: string,\n): void {\n if (typeof value !== \"bigint\" || value < min || value > max) {\n throw new RangeError(`${name} must be between ${min} and ${max}`);\n }\n}\n\nfunction bytesEqual(left: Uint8Array, right: Uint8Array): boolean {\n if (left.length !== right.length) return false;\n return left.every((byte, index) => byte === right[index]);\n}\n","import type {\n SHA256Hash,\n SignedTransaction,\n Transaction,\n NetworkHash,\n} from \"@thruputchain/protocol\";\nimport { codec, serialize, sha256Hash } from \"@thruputchain/protocol\";\nimport {\n createSubmissionEvidence,\n assertTransactionAdmission,\n TransactionObservationError,\n type SubmissionEvidence,\n} from \"../../wallet/execution.js\";\nimport { RpcRequestValidationError } from \"../../rpc/codec.js\";\nimport { RpcCompatibilityError } from \"../../rpc/client.js\";\nimport type { CoreThruputClient } from \"../../client.js\";\nimport type { WalletAccount } from \"../../wallet/account.js\";\nimport { signTransaction as sign } from \"../../transaction/sign.js\";\nimport {\n prepareTransaction,\n type PrepareTransactionRequest,\n} from \"./prepareTransaction.js\";\n\n/** Sign a transaction with a wallet account's configured signers. */\nexport function signWalletTransaction(\n account: WalletAccount,\n transaction: Transaction,\n networkHash: NetworkHash,\n): Promise<SignedTransaction> {\n return sign(transaction, account.signers, networkHash);\n}\n\n/** Prepare, sign, and submit one explicit root invocation. */\nexport async function sendInvocation(\n client: Pick<\n CoreThruputClient,\n \"getChainTip\" | \"sendTransaction\" | \"requireMethods\" | \"discovery\"\n >,\n account: WalletAccount,\n networkHash: NetworkHash,\n request: PrepareTransactionRequest,\n controls: {\n signal?: AbortSignal;\n onSigned?: (evidence: SubmissionEvidence) => void | Promise<void>;\n } = {},\n): Promise<SHA256Hash> {\n controls.signal?.throwIfAborted();\n client.requireMethods([\"getChainTip\", \"sendTransaction\"]);\n const signingNetwork = new Uint8Array(networkHash) as NetworkHash;\n const checkNetwork = () => {\n const discovered = client.discovery.network.networkHash;\n if (\n signingNetwork.length !== 32 ||\n discovered.length !== 32 ||\n signingNetwork.some((value, index) => value !== discovered[index])\n )\n throw new RpcCompatibilityError(\n \"Signing network does not match endpoint discovery\",\n );\n };\n checkNetwork();\n const signers = account.signers.map(({ signer, publicKeyId }) => ({\n signer,\n publicKeyId,\n }));\n const transaction = await prepareTransaction(client, account, request);\n checkNetwork();\n const signed = await sign(transaction, signers, signingNetwork);\n const evidence = createSubmissionEvidence(\n serialize(signed, codec.SignedTransaction),\n signingNetwork,\n );\n let phase: \"beforeSubmission\" | \"submission\" = \"beforeSubmission\";\n try {\n await controls.onSigned?.(evidence);\n controls.signal?.throwIfAborted();\n checkNetwork();\n phase = \"submission\";\n const result = await client.sendTransaction(\n { signedTransaction: evidence.signedTransaction },\n { signal: controls.signal },\n );\n assertTransactionAdmission(result);\n return sha256Hash(result.transactionHash);\n } catch (cause) {\n throw new TransactionObservationError(\n evidence,\n cause,\n undefined,\n undefined,\n cause instanceof RpcRequestValidationError ||\n cause instanceof RpcCompatibilityError\n ? \"beforeSubmission\"\n : phase,\n );\n }\n}\n"],"mappings":";;;;;;;;;;;;AACA,eAAsB,eACpB,WACA,UACA,QACA,SACY;CACZ,QAAQ,eAAe;CACvB,IAAI,YAAY,IAAI,KAAK,UAAU,MAAM,QAAQ;CACjD,MAAM,aAAa,IAAI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,eAAe;EAChC,aAAa;EACb,QAAQ;EACR,MAAM,SAAS,MAAM,OAAO,gBAC1B,EAAE,mBAAmB,SAAS,kBAAkB,GAChD,EAAE,QAAQ,SAAS,OAAO,CAC5B;EACA,2BAA2B,MAAM;EACjC,OAAO,WAAW,OAAO,eAAe;CAC1C,SAAS,OAAO;EACd,MAAM,IAAI,4BACR,UACA,OACA,KAAA,GACA,KAAA,GACA,iBAAiB,6BACf,iBAAiB,wBACf,qBACA,KACN;CACF;AACF"}
1
+ {"version":3,"file":"sendInvocation-tBmf8haQ.js","names":["bytesEqual","sign"],"sources":["../src/actions/deadline.ts","../src/actions/public/waitForTransactionReceipt.ts","../src/wallet/invocationAdapter.ts","../src/wallet/execution.ts","../src/actions/wallet/prepareTransaction.ts","../src/actions/wallet/sendInvocation.ts"],"sourcesContent":["/** Run one operation within the caller's wall-clock budget and cancellation signal. */\nexport async function beforeDeadline<T>(\n operation: (signal: AbortSignal) => Promise<T>,\n deadline: number,\n caller: AbortSignal | undefined,\n timeout: () => Error,\n): Promise<T> {\n caller?.throwIfAborted();\n if (performance.now() >= deadline) throw timeout();\n const controller = new AbortController();\n const signal = caller\n ? AbortSignal.any([caller, controller.signal])\n : controller.signal;\n let timer: ReturnType<typeof setTimeout> | undefined;\n let onAbort = () => {};\n try {\n return await Promise.race([\n new Promise<T>((_, reject) => {\n onAbort = () => reject(signal.reason);\n signal.addEventListener(\"abort\", onAbort, { once: true });\n timer = setTimeout(\n () => controller.abort(timeout()),\n Math.ceil(Math.max(0, deadline - performance.now())),\n );\n }),\n operation(signal),\n ]);\n } finally {\n if (timer !== undefined) clearTimeout(timer);\n signal.removeEventListener(\"abort\", onAbort);\n controller.abort();\n }\n}\nexport function validateTimer(value: number, field: string): void {\n if (!Number.isFinite(value) || value < 0 || value > 2147483647)\n throw new RangeError(`${field} must be between 0 and 2147483647`);\n}\nexport function waitDelay(delay: number, signal: AbortSignal): Promise<void> {\n return new Promise((resolve, reject) => {\n signal.throwIfAborted();\n const finish = () => {\n signal.removeEventListener(\"abort\", abort);\n resolve();\n };\n const timer = setTimeout(finish, delay);\n const abort = () => {\n clearTimeout(timer);\n signal.removeEventListener(\"abort\", abort);\n reject(signal.reason);\n };\n signal.addEventListener(\"abort\", abort, { once: true });\n });\n}\n","import { toBase58 } from \"../../encoding.js\";\nimport type { RpcClient } from \"../../rpc/client.js\";\nimport { RpcCompatibilityError } from \"../../rpc/client.js\";\nimport { NativeRpcError } from \"../../rpc/errorReader.js\";\nimport {\n UnsupportedRpcValue,\n RpcDecodingError,\n RpcRequestValidationError,\n} from \"../../rpc/codec.js\";\nimport type { TransactionReceipt, TransactionStatus } from \"../../types/rpc.js\";\nimport { classifyReadError } from \"../../transport/readError.js\";\nimport { beforeDeadline, validateTimer, waitDelay } from \"../deadline.js\";\n\nexport interface KnownCommitment {\n readonly networkHash: Uint8Array;\n readonly transactionHash: Uint8Array;\n readonly blockHeight: bigint;\n}\nexport interface WaitForTransactionReceiptOptions {\n signal?: AbortSignal;\n /** Verified before each observation; omission uses discovery's validated network. */\n expectedNetworkHash?: Uint8Array;\n knownCommitment?: KnownCommitment;\n /** Observed status, including optional advisory attempt diagnostics. Never retry permission. */\n onStatus?: (status: TransactionStatus) => void;\n timeoutMs?: number;\n pollingIntervalMs?: number;\n}\n/** Observation stopped; neither timeout nor cancellation proves nonexecution. */\nexport class TransactionReceiptObservationError extends Error {\n constructor(\n readonly transactionHash: Uint8Array,\n readonly knownCommitment: KnownCommitment | undefined,\n readonly lastStatus: TransactionStatus | undefined,\n cause: unknown,\n ) {\n super(`Could not observe transaction ${toBase58(transactionHash)}`, {\n cause,\n });\n this.name = \"TransactionReceiptObservationError\";\n }\n}\nexport class TransactionReceiptTimeoutError extends TransactionReceiptObservationError {\n constructor(\n transactionHash: Uint8Array,\n knownCommitment: KnownCommitment | undefined,\n lastStatus: TransactionStatus | undefined,\n cause?: unknown,\n ) {\n super(transactionHash, knownCommitment, lastStatus, cause);\n this.name = \"TransactionReceiptTimeoutError\";\n this.message = `Timed out waiting for transaction ${toBase58(transactionHash)}`;\n }\n}\nconst equal = (a: Uint8Array, b: Uint8Array) =>\n a.length === b.length && a.every((v, i) => v === b[i]);\n/** Read-only capabilities used by commitment and receipt observation. */\nexport type ReceiptObserver = Pick<\n RpcClient,\n | \"getNetworkInfo\"\n | \"getTransactionReceipt\"\n | \"getTransactionStatus\"\n | \"discovery\"\n | \"requireMethods\"\n>;\n\n/** Return any committed receipt, including failed execution. Never sign or resubmit. */\nexport async function waitForTransactionReceipt(\n client: ReceiptObserver,\n transactionHash: Uint8Array,\n options: WaitForTransactionReceiptOptions = {},\n): Promise<TransactionReceipt> {\n return (await observe(\n client,\n transactionHash,\n options,\n false,\n )) as TransactionReceipt;\n}\n/** Observe commitment independently of receipt availability or execution success. */\nexport async function waitForCommitment(\n client: ReceiptObserver,\n transactionHash: Uint8Array,\n options: WaitForTransactionReceiptOptions = {},\n): Promise<KnownCommitment> {\n return (await observe(\n client,\n transactionHash,\n options,\n true,\n )) as KnownCommitment;\n}\n// Status evidence includes extensible values at arbitrary nested schema positions.\n// structuredClone alone drops their UnsupportedRpcValue class identity.\nfunction snapshotStatus(status: TransactionStatus): TransactionStatus {\n const copy = (value: unknown): unknown => {\n if (value instanceof UnsupportedRpcValue)\n return new UnsupportedRpcValue(structuredClone(value.raw));\n if (Array.isArray(value)) return value.map(copy);\n if (ArrayBuffer.isView(value)) return structuredClone(value);\n if (value !== null && typeof value === \"object\")\n return Object.fromEntries(\n Object.entries(value).map(([key, entry]) => [key, copy(entry)]),\n );\n return value;\n };\n return copy(status) as TransactionStatus;\n}\n\nasync function observe(\n client: ReceiptObserver,\n hash: Uint8Array,\n options: WaitForTransactionReceiptOptions,\n commitmentOnly: boolean,\n): Promise<TransactionReceipt | KnownCommitment> {\n const timeoutMs = options.timeoutMs ?? 30000;\n const interval = options.pollingIntervalMs ?? 250;\n validateTimer(timeoutMs, \"timeoutMs\");\n validateTimer(interval, \"pollingIntervalMs\");\n const transactionHash = new Uint8Array(hash);\n const networkHash = new Uint8Array(\n options.expectedNetworkHash ?? client.discovery.network.networkHash,\n );\n if (transactionHash.length !== 32 || networkHash.length !== 32)\n throw new RangeError(\n \"Transaction and network hashes must contain 32 bytes\",\n );\n let commitment: KnownCommitment | undefined;\n let lastStatus: TransactionStatus | undefined;\n if (options.knownCommitment) {\n const known = options.knownCommitment;\n if (\n !equal(known.transactionHash, transactionHash) ||\n !equal(known.networkHash, networkHash) ||\n typeof known.blockHeight !== \"bigint\" ||\n known.blockHeight < 0n ||\n known.blockHeight > 9223372036854775807n\n )\n throw new RpcCompatibilityError(\n \"Known commitment does not match the transaction/network context\",\n );\n commitment = {\n transactionHash: transactionHash.slice(),\n networkHash: networkHash.slice(),\n blockHeight: known.blockHeight,\n };\n lastStatus = { status: \"committed\", blockHeight: known.blockHeight };\n }\n client.requireMethods([\n \"getNetworkInfo\",\n \"getTransactionReceipt\",\n \"getTransactionStatus\",\n ]);\n const deadline = performance.now() + timeoutMs;\n let lastFailure: unknown;\n let failures = 0;\n const timeout = () =>\n new TransactionReceiptTimeoutError(\n transactionHash.slice(),\n commitment && structuredClone(commitment),\n lastStatus,\n lastFailure,\n );\n const run = <T>(operation: (signal: AbortSignal) => Promise<T>) =>\n beforeDeadline(operation, deadline, options.signal, timeout);\n const retain = (blockHeight: bigint) => {\n if (commitment && commitment.blockHeight !== blockHeight)\n throw new RpcCompatibilityError(\n \"Conflicting commitment heights for the same transaction\",\n );\n commitment = {\n transactionHash: transactionHash.slice(),\n networkHash: networkHash.slice(),\n blockHeight,\n };\n lastStatus = { status: \"committed\", blockHeight };\n };\n try {\n while (true) {\n let retryAfterMs: bigint | undefined;\n let networkVerified = false;\n let failed = false;\n try {\n const network = await run((signal) =>\n client.getNetworkInfo({}, { signal }),\n );\n if (!equal(network.networkHash, networkHash))\n throw new RpcCompatibilityError(\n \"Observation endpoint network changed\",\n );\n networkVerified = true;\n if (commitmentOnly && commitment) return structuredClone(commitment);\n const receipt = await run((signal) =>\n client.getTransactionReceipt({ transactionHash }, { signal }),\n );\n if (receipt) {\n retain(receipt.blockHeight);\n return commitmentOnly ? structuredClone(commitment!) : receipt;\n }\n } catch (cause) {\n lastFailure = cause;\n failed = true;\n if (\n cause instanceof NativeRpcError &&\n cause.decoded.classification === \"known\"\n ) {\n const data = cause.decoded.data;\n if (data.kind === \"backendDataInvalid\" && data.observation) {\n retain(data.observation.blockHeight);\n if (commitmentOnly) return structuredClone(commitment!);\n }\n if (\"retryAfterMs\" in data) retryAfterMs = data.retryAfterMs;\n }\n if (\n options.signal?.aborted ||\n classifyReadError(cause, options) !== \"transient\"\n )\n throw cause;\n }\n // Status failures cannot erase a previously validated commitment.\n let observedStatus: TransactionStatus | undefined;\n if (networkVerified)\n try {\n const status = await run((signal) =>\n client.getTransactionStatus({ transactionHash }, { signal }),\n );\n if (\n !(status instanceof UnsupportedRpcValue) &&\n status.status === \"committed\"\n )\n retain(status.blockHeight);\n else if (!commitment) lastStatus = snapshotStatus(status);\n observedStatus = status;\n } catch (cause) {\n if (\n cause instanceof RpcCompatibilityError ||\n cause instanceof RpcDecodingError ||\n cause instanceof RpcRequestValidationError ||\n classifyReadError(cause, options) === \"permanent\"\n )\n throw cause;\n options.signal?.throwIfAborted();\n lastFailure = cause;\n failed = true;\n if (\n cause instanceof NativeRpcError &&\n cause.decoded.classification === \"known\" &&\n \"retryAfterMs\" in cause.decoded.data\n ) {\n const hint = cause.decoded.data.retryAfterMs;\n if (\n hint !== undefined &&\n (retryAfterMs === undefined || hint > retryAfterMs)\n )\n retryAfterMs = hint;\n }\n }\n if (observedStatus !== undefined) options.onStatus?.(observedStatus);\n if (failed) failures++;\n else {\n failures = 0;\n lastFailure = undefined;\n }\n if (commitmentOnly && commitment) return structuredClone(commitment);\n const backoff = failures\n ? Math.min(\n 5000,\n Math.max(1, interval) * 2 ** Math.min(failures - 1, 8),\n ) *\n (0.5 + Math.random() / 2)\n : interval;\n const remaining = deadline - performance.now();\n if (\n retryAfterMs !== undefined &&\n retryAfterMs > BigInt(Math.max(0, Math.floor(remaining)))\n )\n throw timeout();\n const delay = Math.max(backoff, Number(retryAfterMs ?? 0n));\n await run((signal) =>\n waitDelay(Math.min(delay, Math.max(0, remaining)), signal),\n );\n }\n } catch (cause) {\n if (cause instanceof TransactionReceiptTimeoutError) throw cause;\n throw new TransactionReceiptObservationError(\n transactionHash,\n commitment && structuredClone(commitment),\n lastStatus,\n cause,\n );\n }\n}\n","import {\n codec,\n contractAddress,\n serialize,\n type ContractAddress,\n type GasAmount,\n type Invocation,\n} from \"@thruputchain/protocol\";\nimport { fixedBytes } from \"@thruputchain/xdr\";\nimport { bytesEqual } from \"../contract/event.js\";\nimport { DefaultWallet } from \"../contracts/default_wallet.js\";\nimport { DevWallet } from \"../contracts/dev_wallet.js\";\nimport { MAX_DEFAULT_WALLET_CALLS } from \"../provider/validation.js\";\nimport type { ContractDeployment, DeploymentOptions } from \"./deployment.js\";\nimport type { TransactionReceipt } from \"../types/rpc.js\";\n\n/** Common inputs for wrapping one inner invocation through a wallet contract. */\nexport interface WalletExecutionRequest {\n readonly invocation: Invocation;\n /** Gas available to the wallet's root invocation. */\n readonly gasLimit: GasAmount;\n}\n\n/** Ordered inner calls for one atomic DefaultWallet execution. */\nexport interface WalletBatchExecutionRequest {\n readonly invocations: readonly Invocation[];\n /** Gas available to the complete wallet root, including all calls. */\n readonly gasLimit: GasAmount;\n}\n\n/** Build a root batch directly, copying call bytes before asynchronous work. */\nexport function createDefaultWalletBatchInvocation(\n accountAddress: ContractAddress,\n request: WalletBatchExecutionRequest,\n): Invocation {\n if (\n !Array.isArray(request.invocations) ||\n request.invocations.length < 1 ||\n request.invocations.length > MAX_DEFAULT_WALLET_CALLS\n )\n throw new RangeError(\"DefaultWallet requires 1 to 16 calls\");\n return DefaultWallet.v0_1.execute.invocation(\n contractAddress(new Uint8Array(accountAddress)),\n request.gasLimit,\n {\n calls: request.invocations.map((inner) => ({\n target: contractAddress(new Uint8Array(inner.invoked_address)),\n entrypoint: fixedBytes(new Uint8Array(inner.entrypoint), 8),\n gas_limit: inner.gas_limit,\n calldata: new Uint8Array(inner.calldata),\n })),\n },\n );\n}\n\n/** Converts a wallet-specific execution request into a root invocation. */\nexport interface WalletInvocationAdapter<\n TRequest extends WalletExecutionRequest = WalletExecutionRequest,\n> {\n /** Build a root deployment when supported by this wallet. */\n createDeploymentInvocation?(\n account: ContractAddress,\n deployment: ContractDeployment,\n options: DeploymentOptions,\n ): Invocation;\n /** Decode the address returned by a root deployment. */\n decodeDeploymentReceipt?(receipt: TransactionReceipt): ContractAddress;\n /** Child return buffers in call order, or null when this wallet discards them. */\n decodeExecutionReturns?(\n receipt: TransactionReceipt,\n ): readonly Uint8Array[] | null;\n /** Build one atomic root for multiple calls when this wallet supports it. */\n createBatchRootInvocation?(\n account: ContractAddress,\n request: WalletBatchExecutionRequest,\n ): Invocation;\n createRootInvocation(\n accountAddress: ContractAddress,\n request: TRequest,\n ): Invocation;\n}\n\n/** Define an invocation adapter while preserving its request type. */\nexport function defineWalletInvocationAdapter<\n TRequest extends WalletExecutionRequest,\n>(\n adapter: WalletInvocationAdapter<TRequest>,\n): WalletInvocationAdapter<TRequest> {\n return adapter;\n}\n\n/** Wrap one call through the native-compatible DefaultWallet interface. */\nexport const defaultWalletAdapter = defineWalletInvocationAdapter({\n createBatchRootInvocation: createDefaultWalletBatchInvocation,\n decodeExecutionReturns: (receipt) =>\n DefaultWallet.v0_1.execute.decodeReceipt(receipt).value,\n createDeploymentInvocation(account, deployment, options) {\n if (\n options.initializer &&\n !bytesEqual(options.initializer.invoked_address, deployment.address)\n )\n throw new Error(\n \"Initializer must target the predicted deployment address\",\n );\n // The wallet takes an i128, but a deployment never funds a negative amount.\n if (options.amount < 0n)\n throw new RangeError(\"Deployment amount must not be negative\");\n return DefaultWallet.v0_1.deploy.invocation(account, options.gasLimit, {\n nonce: fixedBytes(deployment.deploymentNonce, 32),\n contractHash: fixedBytes(deployment.contractHash, 32),\n amount: options.amount,\n initializer: options.initializer\n ? {\n entrypoint: fixedBytes(options.initializer.entrypoint, 8),\n gas_limit: options.initializer.gas_limit,\n calldata: options.initializer.calldata,\n }\n : null,\n });\n },\n decodeDeploymentReceipt: (receipt) =>\n DefaultWallet.v0_1.deploy.decodeReceipt(receipt).value,\n createRootInvocation(\n accountAddress: ContractAddress,\n request: WalletExecutionRequest,\n ): Invocation {\n return createDefaultWalletBatchInvocation(accountAddress, {\n invocations: [request.invocation],\n gasLimit: request.gasLimit,\n });\n },\n});\n\n/** Wrap one call through the legacy DevWallet. Unified deployment is unsupported. */\nexport const devWalletAdapter = defineWalletInvocationAdapter({\n decodeExecutionReturns: () => null,\n createRootInvocation(\n accountAddress: ContractAddress,\n request: WalletExecutionRequest,\n ): Invocation {\n return DevWallet.v0_1.doAction.invocation(\n contractAddress(new Uint8Array(accountAddress)),\n request.gasLimit,\n {\n invocationBytes: serialize(request.invocation, codec.Invocation),\n },\n );\n },\n});\n","import { codec, deserialize } from \"@thruputchain/protocol\";\nimport { hashSignedTransaction } from \"../derivation/transactionHash.js\";\nimport { RpcCompatibilityError } from \"../rpc/client.js\";\nimport {\n RpcRequestValidationError,\n UnsupportedRpcValue,\n} from \"../rpc/codec.js\";\nimport { NativeRpcError } from \"../rpc/errorReader.js\";\nimport {\n TransactionReceiptObservationError,\n type KnownCommitment,\n} from \"../actions/public/waitForTransactionReceipt.js\";\nimport { gasAmount, type GasAmount } from \"@thruputchain/protocol\";\nimport type { CoreThruputClient } from \"../client.js\";\nimport type { TransactionReceipt } from \"../types/rpc.js\";\nimport type { WaitForTransactionReceiptOptions } from \"../actions/public/waitForTransactionReceipt.js\";\nimport type { ContractCall } from \"../contract/method.js\";\nimport {\n defaultWalletAdapter,\n type WalletInvocationAdapter,\n} from \"./invocationAdapter.js\";\nimport { beforeDeadline, validateTimer } from \"../actions/deadline.js\";\nimport { toBase58 } from \"../encoding.js\";\nimport type { RpcSendTransactionResult } from \"../rpc/generated.js\";\n\n/** A committed execution failure, retaining the complete native receipt. */\nexport class TransactionExecutionError extends Error {\n constructor(\n readonly receipt: TransactionReceipt,\n readonly submission?: SubmissionEvidence,\n ) {\n super(\n receipt.execution instanceof UnsupportedRpcValue\n ? `Transaction ${toBase58(receipt.transactionHash)} has an unsupported execution outcome`\n : `Transaction ${toBase58(receipt.transactionHash)} execution failed (${receipt.execution.result})`,\n );\n this.name = \"TransactionExecutionError\";\n }\n}\n/** A future execution variant is unsupported, never inferred to be success or failure. */\nexport class UnsupportedTransactionOutcomeError extends TransactionExecutionError {\n constructor(receipt: TransactionReceipt, submission?: SubmissionEvidence) {\n super(receipt, submission);\n this.name = \"UnsupportedTransactionOutcomeError\";\n }\n}\nexport function assertTransactionSuccess(\n receipt: TransactionReceipt,\n submission?: SubmissionEvidence,\n): asserts receipt is TransactionReceipt & {\n execution: { result: \"return\"; returnData: Uint8Array };\n} {\n if (receipt.execution instanceof UnsupportedRpcValue)\n throw new UnsupportedTransactionOutcomeError(receipt, submission);\n if (receipt.execution.result !== \"return\")\n throw new TransactionExecutionError(receipt, submission);\n}\n\n/** A submit response that does not establish the currently supported admission outcome. */\nexport class UnsupportedTransactionAdmissionError extends Error {\n constructor(readonly response: RpcSendTransactionResult) {\n super(\"Transaction submission returned an unsupported admission outcome\");\n this.name = \"UnsupportedTransactionAdmissionError\";\n }\n}\n\n/** Keep low-level future values intact, but never project them into an admitted hash. */\nexport function assertTransactionAdmission(\n response: RpcSendTransactionResult,\n): void {\n if (response.admission !== \"accepted\")\n throw new UnsupportedTransactionAdmissionError(response);\n}\nexport interface SubmissionEvidence {\n readonly signedTransaction: Uint8Array;\n readonly transactionHash: Uint8Array;\n readonly networkHash: Uint8Array;\n}\n/** Snapshot approved bytes before submission; accessor copies protect the retained record. */\nexport function createSubmissionEvidence(\n bytes: Uint8Array,\n network: Uint8Array,\n): SubmissionEvidence {\n const signedTransaction = new Uint8Array(bytes);\n const networkHash = new Uint8Array(network);\n if (networkHash.length !== 32)\n throw new RangeError(\"networkHash must contain 32 bytes\");\n const transactionHash = hashSignedTransaction(\n deserialize(signedTransaction, codec.SignedTransaction),\n );\n return Object.freeze({\n get signedTransaction() {\n return signedTransaction.slice();\n },\n get transactionHash() {\n return transactionHash.slice();\n },\n get networkHash() {\n return networkHash.slice();\n },\n });\n}\nexport interface ExecutionResult {\n transactionHash: Uint8Array;\n receipt: TransactionReceipt;\n submission?: SubmissionEvidence;\n}\n/** Submission or observation stopped, preserving exact approved bytes and commitment. */\nexport class TransactionObservationError extends Error {\n constructor(\n readonly submission: SubmissionEvidence,\n cause: unknown,\n readonly submissionCause?: unknown,\n readonly knownCommitment?: KnownCommitment,\n readonly phase:\n | \"beforeSubmission\"\n | \"submission\"\n | \"observation\" = \"observation\",\n ) {\n super(\n `Could not complete transaction ${toBase58(submission.transactionHash)}`,\n { cause },\n );\n this.name = \"TransactionObservationError\";\n }\n get transactionHash(): Uint8Array {\n return this.submission.transactionHash;\n }\n}\n/** Submit once, then reconcile only by reads. No path replaces or repeats signed bytes. */\nexport async function submitAndObserve(\n client: Pick<CoreThruputClient, \"waitForTransactionReceipt\">,\n evidence: SubmissionEvidence,\n submit: (signal: AbortSignal) => Promise<void>,\n options?: WaitForTransactionReceiptOptions,\n wasDispatched?: () => boolean,\n): Promise<ExecutionResult> {\n const submission = createSubmissionEvidence(\n evidence.signedTransaction,\n evidence.networkHash,\n );\n const timeoutMs = options?.timeoutMs ?? 30000;\n validateTimer(timeoutMs, \"timeoutMs\");\n const deadline = performance.now() + timeoutMs;\n let submissionCause: unknown;\n try {\n options?.signal?.throwIfAborted();\n if (timeoutMs === 0)\n throw new Error(\"Transaction submission timed out before dispatch\");\n } catch (cause) {\n throw new TransactionObservationError(\n submission,\n cause,\n undefined,\n undefined,\n \"beforeSubmission\",\n );\n }\n try {\n await beforeDeadline(\n submit,\n deadline,\n options?.signal,\n () => new Error(\"Transaction submission timed out\"),\n );\n } catch (cause) {\n if (\n wasDispatched?.() === false ||\n cause instanceof RpcRequestValidationError ||\n cause instanceof RpcCompatibilityError\n )\n throw new TransactionObservationError(\n submission,\n cause,\n undefined,\n undefined,\n \"beforeSubmission\",\n );\n if (\n cause instanceof NativeRpcError &&\n cause.decoded.classification === \"known\" &&\n (cause.decoded.data.kind === \"invalidParams\" ||\n cause.decoded.data.kind === \"transactionInvalid\" ||\n cause.decoded.data.kind === \"transactionRejected\")\n )\n throw new TransactionObservationError(\n submission,\n cause,\n undefined,\n undefined,\n \"submission\",\n );\n submissionCause = cause;\n if (options?.signal?.aborted || performance.now() >= deadline)\n throw new TransactionObservationError(\n submission,\n cause,\n submissionCause,\n undefined,\n \"submission\",\n );\n }\n try {\n const receipt = await client.waitForTransactionReceipt(\n submission.transactionHash,\n {\n ...options,\n expectedNetworkHash: submission.networkHash,\n timeoutMs: Math.max(0, deadline - performance.now()),\n },\n );\n return { transactionHash: receipt.transactionHash, receipt, submission };\n } catch (cause) {\n throw new TransactionObservationError(\n submission,\n cause,\n submissionCause,\n cause instanceof TransactionReceiptObservationError\n ? cause.knownCommitment\n : undefined,\n );\n }\n}\n/** Wait for a committed receipt, then require execution success. */\nexport async function waitForExecution(\n client: Pick<CoreThruputClient, \"waitForTransactionReceipt\">,\n hash: Uint8Array,\n options?: WaitForTransactionReceiptOptions,\n): Promise<ExecutionResult> {\n const receipt = await client.waitForTransactionReceipt(hash, options);\n assertTransactionSuccess(receipt);\n return { transactionHash: receipt.transactionHash, receipt };\n}\n\n/** Ordered result types for a tuple of calls. */\nexport type CallResults<T extends readonly ContractCall[]> = {\n [K in keyof T]: T[K] extends ContractCall<infer R> ? R : never;\n};\n\n/**\n * Decode DefaultWallet child returns without modifying the root receipt.\n * Works after disconnect and preserves call order. Supply an adapter for other\n * wallets. Wallets such as DevWallet that discard child return data report\n * unavailable results. Failed wallet receipts are not decoded with a child ABI:\n * even a single child call does not establish where an abort originated.\n */\nexport function decodeExecution<T extends readonly ContractCall[]>(\n receipt: TransactionReceipt,\n calls: T,\n adapter: WalletInvocationAdapter = defaultWalletAdapter,\n submission?: SubmissionEvidence,\n): CallResults<T> {\n // Even one child call can fail in the wallet root; its abort bytes are not a child receipt.\n assertTransactionSuccess(receipt, submission);\n try {\n const buffers = adapter.decodeExecutionReturns?.(receipt);\n if (buffers == null)\n throw new ExecutionReturnUnavailableError(receipt, submission);\n if (buffers.length !== calls.length)\n throw new Error(\n `Returned ${buffers.length} child results; expected ${calls.length}`,\n );\n return calls.map((call, index) =>\n call.method.decodeReturn(buffers[index]!),\n ) as CallResults<T>;\n } catch (cause) {\n if (cause instanceof ExecutionReturnUnavailableError) throw cause;\n throw new ExecutionDecodeError(receipt, cause, submission);\n }\n}\n\n/** A committed successful execution whose return data could not be decoded. */\nexport class ExecutionDecodeError extends Error {\n constructor(\n readonly receipt: TransactionReceipt,\n cause: unknown,\n readonly submission?: SubmissionEvidence,\n ) {\n super(\n `Transaction ${toBase58(receipt.transactionHash)} committed, but result decoding failed: ${cause instanceof Error ? cause.message : String(cause)}`,\n { cause },\n );\n this.name = \"ExecutionDecodeError\";\n }\n}\n\n/** Execution succeeded, but this wallet does not preserve child return buffers. */\nexport class ExecutionReturnUnavailableError extends Error {\n constructor(\n readonly receipt: TransactionReceipt,\n readonly submission?: SubmissionEvidence,\n ) {\n super(\n `Transaction ${toBase58(receipt.transactionHash)} committed successfully, but its wallet does not expose child return data`,\n );\n this.name = \"ExecutionReturnUnavailableError\";\n }\n}\n\n/**\n * Sum explicit child budgets and a calibrated wallet overhead, checking u64 bounds.\n * This is not gas estimation. Calibrate budgets against the target runtime and\n * workload; there is no universally safe wallet overhead. Root gas reserves\n * scheduling capacity against the sender's free native-token balance. Storage\n * deposits are a separate requirement, and funding a target contract does not\n * sponsor root gas.\n */\nexport function walletGasLimit(\n calls: readonly { gas_limit: GasAmount }[],\n overhead: GasAmount,\n): GasAmount {\n const limits = [overhead, ...calls.map((call) => call.gas_limit)];\n if (limits.some((limit) => typeof limit !== \"bigint\" || limit < 0n))\n throw new RangeError(\"Gas budgets must be nonnegative bigint values\");\n const total = limits.reduce((sum, limit) => sum + limit, 0n);\n if (total > 0xffff_ffff_ffff_ffffn)\n throw new RangeError(\"Root gas budget exceeds u64\");\n return gasAmount(total);\n}\n","import {\n blockHeight,\n codec,\n deserialize,\n serialize,\n type BlockHeight,\n type Contract,\n type Invocation,\n type Transaction,\n} from \"@thruputchain/protocol\";\nimport type { CoreThruputClient } from \"../../client.js\";\nimport type { WalletAccount } from \"../../wallet/account.js\";\nimport { createTransaction } from \"../../transaction/build.js\";\n\nconst int64Max = 0x7fff_ffff_ffff_ffffn;\nconst uint64Max = 0xffff_ffff_ffff_ffffn;\nconst defaultExpiryBlocks = 100n;\n\n/** Inputs for preparing one wallet-authorized transaction. */\nexport interface PrepareTransactionRequest {\n /** Explicit root invocation. Smart-wallet wrapping is caller-controlled. */\n readonly invocation: Invocation;\n readonly contractsToDeploy?: readonly Contract[];\n readonly nonce?: bigint;\n readonly blockExpiryHeight?: BlockHeight;\n readonly expiryBlocks?: bigint;\n}\n\n/** Prepare an unsigned transaction for a wallet account. */\nexport async function prepareTransaction(\n client: Pick<CoreThruputClient, \"getChainTip\">,\n account: Pick<WalletAccount, \"address\" | \"authClaim\">,\n request: PrepareTransactionRequest,\n): Promise<Transaction> {\n const invocation = deserialize(\n serialize(request.invocation, codec.Invocation),\n codec.Invocation,\n );\n const contractsToDeploy = (request.contractsToDeploy ?? []).map((contract) =>\n deserialize(serialize(contract, codec.Contract), codec.Contract),\n );\n const authClaim = deserialize(\n serialize(account.authClaim, codec.AuthClaim),\n codec.AuthClaim,\n );\n\n if (!bytesEqual(invocation.invoked_address, account.address)) {\n throw new Error(\"Root invocation address must match the wallet account\");\n }\n if (\n request.blockExpiryHeight !== undefined &&\n request.expiryBlocks !== undefined\n ) {\n throw new Error(\n \"blockExpiryHeight and expiryBlocks are mutually exclusive\",\n );\n }\n\n const nonce = request.nonce ?? randomUint64();\n validateRange(nonce, 0n, uint64Max, \"nonce\");\n\n let expiry: bigint;\n if (request.blockExpiryHeight !== undefined) {\n expiry = request.blockExpiryHeight;\n validateRange(expiry, 0n, int64Max, \"blockExpiryHeight\");\n } else {\n const expiryBlocks = request.expiryBlocks ?? defaultExpiryBlocks;\n validateRange(expiryBlocks, 1n, int64Max, \"expiryBlocks\");\n const tip = await client.getChainTip();\n expiry = tip.blockHeight + expiryBlocks;\n validateRange(expiry, 0n, int64Max, \"blockExpiryHeight\");\n }\n\n return createTransaction({\n invocation,\n uniquifier: {\n block_expiry_height: blockHeight(expiry),\n nonce,\n },\n contracts_to_deploy: contractsToDeploy,\n auth_claim: authClaim,\n });\n}\n\nfunction randomUint64(): bigint {\n const bytes = crypto.getRandomValues(new Uint8Array(8));\n return new DataView(\n bytes.buffer,\n bytes.byteOffset,\n bytes.byteLength,\n ).getBigUint64(0);\n}\n\nfunction validateRange(\n value: bigint,\n min: bigint,\n max: bigint,\n name: string,\n): void {\n if (typeof value !== \"bigint\" || value < min || value > max) {\n throw new RangeError(`${name} must be between ${min} and ${max}`);\n }\n}\n\nfunction bytesEqual(left: Uint8Array, right: Uint8Array): boolean {\n if (left.length !== right.length) return false;\n return left.every((byte, index) => byte === right[index]);\n}\n","import type {\n SHA256Hash,\n SignedTransaction,\n Transaction,\n NetworkHash,\n} from \"@thruputchain/protocol\";\nimport { codec, serialize, sha256Hash } from \"@thruputchain/protocol\";\nimport {\n createSubmissionEvidence,\n assertTransactionAdmission,\n TransactionObservationError,\n type SubmissionEvidence,\n} from \"../../wallet/execution.js\";\nimport { RpcRequestValidationError } from \"../../rpc/codec.js\";\nimport { RpcCompatibilityError } from \"../../rpc/client.js\";\nimport type { CoreThruputClient } from \"../../client.js\";\nimport type { WalletAccount } from \"../../wallet/account.js\";\nimport { signTransaction as sign } from \"../../transaction/sign.js\";\nimport {\n prepareTransaction,\n type PrepareTransactionRequest,\n} from \"./prepareTransaction.js\";\n\n/** Sign a transaction with a wallet account's configured signers. */\nexport function signWalletTransaction(\n account: WalletAccount,\n transaction: Transaction,\n networkHash: NetworkHash,\n): Promise<SignedTransaction> {\n return sign(transaction, account.signers, networkHash);\n}\n\n/** Prepare, sign, and submit one explicit root invocation. */\nexport async function sendInvocation(\n client: Pick<\n CoreThruputClient,\n \"getChainTip\" | \"sendTransaction\" | \"requireMethods\" | \"discovery\"\n >,\n account: WalletAccount,\n networkHash: NetworkHash,\n request: PrepareTransactionRequest,\n controls: {\n signal?: AbortSignal;\n onSigned?: (evidence: SubmissionEvidence) => void | Promise<void>;\n } = {},\n): Promise<SHA256Hash> {\n controls.signal?.throwIfAborted();\n client.requireMethods([\"getChainTip\", \"sendTransaction\"]);\n const signingNetwork = new Uint8Array(networkHash) as NetworkHash;\n const checkNetwork = () => {\n const discovered = client.discovery.network.networkHash;\n if (\n signingNetwork.length !== 32 ||\n discovered.length !== 32 ||\n signingNetwork.some((value, index) => value !== discovered[index])\n )\n throw new RpcCompatibilityError(\n \"Signing network does not match endpoint discovery\",\n );\n };\n checkNetwork();\n const signers = account.signers.map(({ signer, publicKeyId }) => ({\n signer,\n publicKeyId,\n }));\n const transaction = await prepareTransaction(client, account, request);\n checkNetwork();\n const signed = await sign(transaction, signers, signingNetwork);\n const evidence = createSubmissionEvidence(\n serialize(signed, codec.SignedTransaction),\n signingNetwork,\n );\n let phase: \"beforeSubmission\" | \"submission\" = \"beforeSubmission\";\n try {\n await controls.onSigned?.(evidence);\n controls.signal?.throwIfAborted();\n checkNetwork();\n phase = \"submission\";\n const result = await client.sendTransaction(\n { signedTransaction: evidence.signedTransaction },\n { signal: controls.signal },\n );\n assertTransactionAdmission(result);\n return sha256Hash(result.transactionHash);\n } catch (cause) {\n throw new TransactionObservationError(\n evidence,\n cause,\n undefined,\n undefined,\n cause instanceof RpcRequestValidationError ||\n cause instanceof RpcCompatibilityError\n ? \"beforeSubmission\"\n : phase,\n );\n }\n}\n"],"mappings":";;;;;;;;;;;;AACA,eAAsB,eACpB,WACA,UACA,QACA,SACY;CACZ,QAAQ,eAAe;CACvB,IAAI,YAAY,IAAI,KAAK,UAAU,MAAM,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WAAW,QAAQ;EAClC,SAAS,QAAQ,eAAe;EAChC,aAAa;EACb,QAAQ;EACR,MAAM,SAAS,MAAM,OAAO,gBAC1B,EAAE,mBAAmB,SAAS,kBAAkB,GAChD,EAAE,QAAQ,SAAS,OAAO,CAC5B;EACA,2BAA2B,MAAM;EACjC,OAAO,WAAW,OAAO,eAAe;CAC1C,SAAS,OAAO;EACd,MAAM,IAAI,4BACR,UACA,OACA,KAAA,GACA,KAAA,GACA,iBAAiB,6BACf,iBAAiB,wBACf,qBACA,KACN;CACF;AACF"}
@@ -1,6 +1,6 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_signedOp = require("./signedOp-BDUZhfJn.cjs");
3
- const require_signed_op = require("./signed_op-CAcYYRm6.cjs");
2
+ const require_signedOp = require("./signedOp-DAucp6xg.cjs");
3
+ const require_signed_op = require("./signed_op-_lR85dn2.cjs");
4
4
  exports.SignedOp = require_signed_op.SignedOp;
5
5
  exports.SignedOpSpec = require_signed_op.spec;
6
6
  exports.defineSignedOperation = require_signedOp.defineSignedOperation;
@@ -1,3 +1,3 @@
1
- import { n as spec, r as thruput_signed_op_if, t as SignedOp } from "./signed_op-BrLxDrDb.cjs";
1
+ import { n as spec, r as thruput_signed_op_if, t as SignedOp } from "./signed_op-D2usgASc.cjs";
2
2
  import { a as Operation, c as SignedOperationType, i as DefineSignedOperationOptions, l as defineSignedOperation, n as signedOperationPreimage, o as SignedOperation, r as ContractTypeSelector, s as SignedOperationRequest, t as SignedOperationPreimage, u as randomNonce } from "./index-B5KqSHeL.cjs";
3
3
  export { type ContractTypeSelector, type DefineSignedOperationOptions, type Operation, SignedOp, spec as SignedOpSpec, type SignedOperation, type SignedOperationPreimage, type SignedOperationRequest, type SignedOperationType, defineSignedOperation, randomNonce, signedOperationPreimage, thruput_signed_op_if };
@@ -1,3 +1,3 @@
1
- import { n as spec, r as thruput_signed_op_if, t as SignedOp } from "./signed_op-DbRq3_Hb.js";
1
+ import { n as spec, r as thruput_signed_op_if, t as SignedOp } from "./signed_op-zGq4eBo8.js";
2
2
  import { a as Operation, c as SignedOperationType, i as DefineSignedOperationOptions, l as defineSignedOperation, n as signedOperationPreimage, o as SignedOperation, r as ContractTypeSelector, s as SignedOperationRequest, t as SignedOperationPreimage, u as randomNonce } from "./index--5LsCotr.js";
3
3
  export { type ContractTypeSelector, type DefineSignedOperationOptions, type Operation, SignedOp, spec as SignedOpSpec, type SignedOperation, type SignedOperationPreimage, type SignedOperationRequest, type SignedOperationType, defineSignedOperation, randomNonce, signedOperationPreimage, thruput_signed_op_if };
package/dist/signed-op.js CHANGED
@@ -1,3 +1,3 @@
1
- import { n as randomNonce, r as signedOperationPreimage, t as defineSignedOperation } from "./signedOp-Kx8u8_3I.js";
2
- import { n as spec, r as thruput_signed_op_if, t as SignedOp } from "./signed_op-Dxn7-lRu.js";
1
+ import { n as randomNonce, r as signedOperationPreimage, t as defineSignedOperation } from "./signedOp-DpmUpH-e.js";
2
+ import { n as spec, r as thruput_signed_op_if, t as SignedOp } from "./signed_op-CwN-_CXw.js";
3
3
  export { SignedOp, spec as SignedOpSpec, defineSignedOperation, randomNonce, signedOperationPreimage, thruput_signed_op_if };
@@ -1,6 +1,6 @@
1
1
  const require_domainSeparator = require("./domainSeparator-B_vU_zUD.cjs");
2
- const require_contract = require("./contract-DPm2BJTu.cjs");
3
- require("./signed_op-CAcYYRm6.cjs");
2
+ const require_contract = require("./contract-DSu2UPPm.cjs");
3
+ require("./signed_op-_lR85dn2.cjs");
4
4
  let _thruputchain_protocol = require("@thruputchain/protocol");
5
5
  let _thruputchain_contract_spec = require("@thruputchain/contract-spec");
6
6
  let _noble_hashes_utils_js = require("@noble/hashes/utils.js");
@@ -180,4 +180,4 @@ Object.defineProperty(exports, "signedOperationPreimage", {
180
180
  }
181
181
  });
182
182
 
183
- //# sourceMappingURL=signedOp-BDUZhfJn.cjs.map
183
+ //# sourceMappingURL=signedOp-DAucp6xg.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"signedOp-BDUZhfJn.cjs","names":["CxsWriter","SIGNED_OP","createContractCodec","createContractCodecContext","ContractTypeKind","formatSpecId","CryptographicScheme","ContractTypeDefKind"],"sources":["../src/signedOp/preimage.ts","../src/signedOp/operation.ts"],"sourcesContent":["import type {\n BlockHeight,\n ContractAddress,\n NetworkHash,\n} from \"@thruputchain/protocol\";\nimport { CxsWriter, codec } from \"@thruputchain/protocol\";\nimport {\n codec as contractSpecCodec,\n type ContractTypeDef,\n} from \"@thruputchain/contract-spec\";\nimport { SIGNED_OP } from \"../derivation/domainSeparator.js\";\n\n/** Everything a signed-operation signature commits to. */\nexport interface SignedOperationPreimage {\n /** Hash of the network the operation is valid on. */\n readonly network: NetworkHash;\n /** Address of the contract entitled to act on the operation. */\n readonly verifyingContract: ContractAddress;\n /**\n * Spec definition of the payload type, as a generated binding ships it in\n * `spec.type_defs`. Part of the signed bytes, so a signature over one\n * payload type is never a signature over another with the same encoding.\n */\n readonly typeDef: ContractTypeDef;\n /** Last block height (inclusive) at which the operation may execute. */\n readonly blockExpiryHeight: BlockHeight;\n /**\n * Signer-chosen value that, with `blockExpiryHeight`, the verifying\n * contract consumes exactly once.\n */\n readonly nonce: bigint;\n /** CXS encoding of the payload value. */\n readonly body: Uint8Array;\n}\n\n/**\n * The message a signed-operation signature covers:\n *\n * ```text\n * cxs(DomainSeparator(\"SignedOp\")) || network || verifyingContract\n * || cxs(typeDef) || cxs(uniquifier) || body\n * ```\n *\n * where `cxs(uniquifier)` is `cxs(blockExpiryHeight) || cxs(nonce)`: the\n * chain's own `Uniquifier` encoding, so the replay pair is spelled the way a\n * transaction spells its own. The result is signed directly, like\n * {@link transactionSignaturePreimage}; Ed25519 does its own hashing. It must\n * match the Rust `thruput_domain_separator::SignedOp::preimage` byte for\n * byte, or the verifying contract rejects the signature. Only the first 74\n * bytes are fixed-width: the uniquifier's two fields are CXS varints.\n *\n * {@link defineSignedOperation} calls this after encoding the payload; reach\n * for it directly only when the payload is already CXS bytes.\n */\nexport function signedOperationPreimage(\n preimage: SignedOperationPreimage,\n): Uint8Array {\n const writer = new CxsWriter();\n writer.writeFixedOpaque(preimage.network, 32);\n writer.writeFixedOpaque(preimage.verifyingContract, 32);\n contractSpecCodec.ContractTypeDef.encode(writer, preimage.typeDef);\n codec.Uniquifier.encode(writer, {\n block_expiry_height: preimage.blockExpiryHeight,\n nonce: preimage.nonce,\n });\n writer.writeFixedOpaque(preimage.body, preimage.body.length);\n const payload = writer.finish();\n\n const prefix = SIGNED_OP.bytes;\n const message = new Uint8Array(prefix.length + payload.length);\n message.set(prefix, 0);\n message.set(payload, prefix.length);\n return message;\n}\n","import type { ContractAddress, NetworkHash } from \"@thruputchain/protocol\";\nimport {\n CryptographicScheme,\n blockHeight,\n ed25519Signature,\n} from \"@thruputchain/protocol\";\nimport {\n ContractTypeDefKind,\n ContractTypeKind,\n type ContractSpecId,\n type ContractTypeDef,\n} from \"@thruputchain/contract-spec\";\nimport type { FixedBytes } from \"@thruputchain/xdr\";\nimport { randomBytes } from \"@noble/hashes/utils.js\";\nimport {\n createContractCodec,\n createContractCodecContext,\n} from \"../contract/codec.js\";\nimport { formatSpecId } from \"../contract/spec.js\";\nimport type { Signer } from \"../signers/types.js\";\nimport { signedOperationPreimage } from \"./preimage.js\";\n\n/**\n * Wire form of a signed operation: the `Operation` struct of the\n * `thruput-signed-op-if` interface, in the shape generated bindings give it.\n *\n * The network hash, the verifying contract, and the signing key are covered\n * by the signature but deliberately absent here. The verifying contract\n * supplies the first two from its own syscalls and checks the signature\n * against the key it holds, so a submitter can name neither the network or\n * contract a signature was meant for nor the key it is checked against.\n *\n * `block_expiry_height` and `nonce` are the chain's `Uniquifier`, in its\n * field order, so their encoding is byte for byte a transaction's.\n */\nexport interface Operation {\n /** Last block height (inclusive) at which the operation may execute. */\n block_expiry_height: bigint;\n /**\n * Chosen by the signer: any value, as long as the pair\n * `(nonce, block_expiry_height)` has not been consumed at the verifying\n * contract. There is no ordering. Consumed pairs are the contract's, not\n * the key's, so where several keys sign for one contract, draw nonces at\n * random ({@link randomNonce}) rather than counting; a lone key may do\n * either.\n */\n nonce: bigint;\n /** CXS encoding of the payload value. */\n body: Uint8Array;\n}\n\n/** An {@link Operation} and the Ed25519 signature over its preimage. */\nexport interface SignedOperation {\n readonly op: Operation;\n readonly signature: FixedBytes<64>;\n}\n\n/** What a signer supplies to produce one operation. */\nexport interface SignedOperationRequest<TBody> {\n /** Hash of the network the operation is valid on. */\n readonly network: NetworkHash;\n /** Address of the contract that will verify and act on the operation. */\n readonly verifyingContract: ContractAddress;\n /** Last block height (inclusive) at which the operation may execute. */\n readonly blockExpiryHeight: bigint;\n /**\n * Signer-chosen replay guard; see {@link Operation.nonce}. Nothing on\n * chain needs reading to pick one: {@link randomNonce} is always safe.\n */\n readonly nonce: bigint;\n /** The payload value, in the field shape generated bindings use. */\n readonly body: TBody;\n}\n\n/** Signing helpers bound to one payload type. */\nexport interface SignedOperationType<TBody> {\n /**\n * Declared name of the payload type: the `declared` segment of its spec id.\n * {@link SignedOperationType.typeDef} carries the full id.\n */\n readonly typeName: string;\n /** The payload type's spec definition, as bound into every preimage. */\n readonly typeDef: ContractTypeDef;\n /** CXS-encode a payload value the way the contract decodes it. */\n encodeBody(body: TBody): Uint8Array;\n /** The bytes a signature over `request` covers. */\n preimage(request: SignedOperationRequest<TBody>): Uint8Array;\n /** Encode, sign, and package `request` for the verifying contract. */\n sign(\n signer: Signer,\n request: SignedOperationRequest<TBody>,\n ): Promise<SignedOperation>;\n}\n\n/** Options for {@link defineSignedOperation}. */\nexport interface DefineSignedOperationOptions {\n /**\n * Type definitions the payload type is resolved against: a generated\n * binding's `spec.type_defs`, which carries the payload type and every type\n * it references.\n */\n readonly typeDefs: readonly ContractTypeDef[];\n /**\n * The payload type: either its name as declared with `#[contract_type]`\n * (the `declared` segment of its spec id), which must name exactly one of\n * `typeDefs`, or its full spec id, which selects one type even when another\n * crate or module declares the same name.\n */\n readonly typeName: string | ContractTypeSelector;\n}\n\n/**\n * Every segment of a payload type's spec id, as plain strings. A\n * `ContractSpecId` taken from a generated spec is assignable to it.\n */\nexport interface ContractTypeSelector {\n readonly crate_name: string;\n readonly major: string;\n readonly module_path: string;\n readonly declared: string;\n}\n\n/**\n * A uniformly random `u64` for {@link Operation.nonce}.\n *\n * Consumed `(nonce, block_expiry_height)` pairs are scoped to the verifying\n * contract, not to the signing key, so a random nonce is the choice that\n * stays safe when several keys sign for one contract; a lone key may count\n * instead. Draws from the platform's `crypto.getRandomValues`.\n */\nexport function randomNonce(): bigint {\n let nonce = 0n;\n for (const byte of randomBytes(8)) {\n nonce = (nonce << 8n) | BigInt(byte);\n }\n return nonce;\n}\n\n/**\n * Bind signing helpers to a `#[contract_type]` payload.\n *\n * A signed operation authorizes an on-chain action off-chain, so the signer\n * need not submit the transaction: the pattern behind permits, session keys,\n * and delegated wallet actions. The verifying contract embeds\n * `thruput_signed_op::SignedOpReplayCache` and checks the operation with\n * `consume::<Payload>` against the key it holds; this is the client half,\n * producing the `Operation` and signature that contract expects.\n *\n * @example\n * ```ts\n * import {\n * defineSignedOperation,\n * randomNonce,\n * } from \"@thruputchain/client/signed-op\";\n * import { spec, MyWallet, type my_wallet } from \"./generated/my_wallet.js\";\n *\n * const transfer = defineSignedOperation<my_wallet.v0_1.Transfer>({\n * typeDefs: spec.type_defs,\n * typeName: \"Transfer\",\n * });\n * const { op, signature } = await transfer.sign(signer, {\n * network: networkHash,\n * verifyingContract: walletAddress,\n * blockExpiryHeight: currentHeight + 100n,\n * nonce: randomNonce(),\n * body: { to: recipient, amount: 42n },\n * });\n * // `op` and `signature` are the arguments of the contract's submit entrypoint.\n * const invocation = MyWallet.v0_1.submit.invocation(walletAddress, gasLimit, {\n * op,\n * signature,\n * });\n * ```\n *\n * @throws If `typeName` selects none, or more than one, of `typeDefs`.\n */\nexport function defineSignedOperation<TBody>(\n options: DefineSignedOperationOptions,\n): SignedOperationType<TBody> {\n // Snapshot once: the codec context clones what it is given, so the\n // definition bound into every preimage must come from the same frozen copy\n // or a later mutation of the caller's array would split the two.\n const typeDefs = structuredClone([...options.typeDefs]);\n const typeDef = deepFreeze(findTypeDef(typeDefs, options.typeName));\n const id = typeDefId(typeDef);\n const context = createContractCodecContext(typeDefs);\n const bodyCodec = createContractCodec<TBody>(\n context,\n { v: ContractTypeKind.Named, named: id },\n `${formatSpecId(id)} payload`,\n );\n\n const preimageOf = (\n request: SignedOperationRequest<TBody>,\n blockExpiryHeight: bigint,\n nonce: bigint,\n body: Uint8Array,\n ): Uint8Array =>\n signedOperationPreimage({\n network: request.network,\n verifyingContract: request.verifyingContract,\n typeDef,\n blockExpiryHeight: blockHeight(blockExpiryHeight),\n nonce,\n body,\n });\n\n return {\n typeName: id.declared,\n typeDef,\n encodeBody: (body) => bodyCodec.encode(body),\n preimage: (request) =>\n preimageOf(\n request,\n request.blockExpiryHeight,\n request.nonce,\n bodyCodec.encode(request.body),\n ),\n async sign(signer, request) {\n if (signer.publicKey.scheme !== CryptographicScheme.Ed25519) {\n throw new Error(\"Signed operations require an Ed25519 signer\");\n }\n // Everything the returned operation carries is taken before the signer\n // is awaited, so a request mutated while a wallet prompt is pending\n // cannot make the operation disagree with the message that was signed.\n // The signature bytes are copied for the same reason, and the\n // constructor rejects any length but the 64 the wire struct's fixed\n // array encodes.\n const blockExpiryHeight = request.blockExpiryHeight;\n const nonce = request.nonce;\n const body = bodyCodec.encode(request.body);\n const message = preimageOf(request, blockExpiryHeight, nonce, body);\n const signature = await signer.sign(message);\n if (signature.scheme !== CryptographicScheme.Ed25519) {\n throw new Error(\"Signer did not return an Ed25519 signature\");\n }\n return {\n op: { block_expiry_height: blockExpiryHeight, nonce, body },\n signature: ed25519Signature(new Uint8Array(signature.ed25519)),\n };\n },\n };\n}\n\nfunction deepFreeze<T>(value: T): T {\n if (typeof value === \"object\" && value !== null && !Object.isFrozen(value)) {\n Object.freeze(value);\n for (const inner of Object.values(value as object)) {\n deepFreeze(inner);\n }\n }\n return value;\n}\n\nfunction typeDefId(typeDef: ContractTypeDef): ContractSpecId {\n switch (typeDef.v) {\n case ContractTypeDefKind.TypeDefStruct:\n return typeDef.struct_def.name;\n case ContractTypeDefKind.TypeDefEnum:\n return typeDef.enum_def.name;\n case ContractTypeDefKind.TypeDefUnion:\n return typeDef.union_def.name;\n }\n}\n\nfunction findTypeDef(\n typeDefs: readonly ContractTypeDef[],\n selector: string | ContractTypeSelector,\n): ContractTypeDef {\n const selects =\n typeof selector === \"string\"\n ? (id: ContractSpecId) => id.declared === selector\n : (id: ContractSpecId) =>\n id.crate_name === selector.crate_name &&\n id.major === selector.major &&\n id.module_path === selector.module_path &&\n id.declared === selector.declared;\n const label =\n typeof selector === \"string\" ? `\"${selector}\"` : formatSpecId(selector);\n const matches = typeDefs.filter((def) => selects(typeDefId(def)));\n const [typeDef] = matches;\n if (typeDef === undefined) {\n throw new Error(\n `Contract type ${label} is not defined in the given type definitions`,\n );\n }\n if (matches.length > 1) {\n const ids = matches.map((def) => formatSpecId(typeDefId(def)));\n throw new Error(\n `Contract type ${label} is ambiguous in the given type definitions: ${ids.join(\", \")}; select one by its full spec id`,\n );\n }\n return typeDef;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAsDA,SAAgB,wBACd,UACY;CACZ,MAAM,SAAS,IAAIA,uBAAAA,UAAU;CAC7B,OAAO,iBAAiB,SAAS,SAAS,EAAE;CAC5C,OAAO,iBAAiB,SAAS,mBAAmB,EAAE;CACtD,4BAAA,MAAkB,gBAAgB,OAAO,QAAQ,SAAS,OAAO;CACjE,uBAAA,MAAM,WAAW,OAAO,QAAQ;EAC9B,qBAAqB,SAAS;EAC9B,OAAO,SAAS;CAClB,CAAC;CACD,OAAO,iBAAiB,SAAS,MAAM,SAAS,KAAK,MAAM;CAC3D,MAAM,UAAU,OAAO,OAAO;CAE9B,MAAM,SAASC,wBAAAA,UAAU;CACzB,MAAM,UAAU,IAAI,WAAW,OAAO,SAAS,QAAQ,MAAM;CAC7D,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AAI,MACR,iBAAiB,MAAM,+CAA+C,IAAI,KAAK,IAAI,EAAE,iCACvF;CACF;CACA,OAAO;AACT"}
1
+ {"version":3,"file":"signedOp-DAucp6xg.cjs","names":["CxsWriter","SIGNED_OP","createContractCodec","createContractCodecContext","ContractTypeKind","formatSpecId","CryptographicScheme","ContractTypeDefKind"],"sources":["../src/signedOp/preimage.ts","../src/signedOp/operation.ts"],"sourcesContent":["import type {\n BlockHeight,\n ContractAddress,\n NetworkHash,\n} from \"@thruputchain/protocol\";\nimport { CxsWriter, codec } from \"@thruputchain/protocol\";\nimport {\n codec as contractSpecCodec,\n type ContractTypeDef,\n} from \"@thruputchain/contract-spec\";\nimport { SIGNED_OP } from \"../derivation/domainSeparator.js\";\n\n/** Everything a signed-operation signature commits to. */\nexport interface SignedOperationPreimage {\n /** Hash of the network the operation is valid on. */\n readonly network: NetworkHash;\n /** Address of the contract entitled to act on the operation. */\n readonly verifyingContract: ContractAddress;\n /**\n * Spec definition of the payload type, as a generated binding ships it in\n * `spec.type_defs`. Part of the signed bytes, so a signature over one\n * payload type is never a signature over another with the same encoding.\n */\n readonly typeDef: ContractTypeDef;\n /** Last block height (inclusive) at which the operation may execute. */\n readonly blockExpiryHeight: BlockHeight;\n /**\n * Signer-chosen value that, with `blockExpiryHeight`, the verifying\n * contract consumes exactly once.\n */\n readonly nonce: bigint;\n /** CXS encoding of the payload value. */\n readonly body: Uint8Array;\n}\n\n/**\n * The message a signed-operation signature covers:\n *\n * ```text\n * cxs(DomainSeparator(\"SignedOp\")) || network || verifyingContract\n * || cxs(typeDef) || cxs(uniquifier) || body\n * ```\n *\n * where `cxs(uniquifier)` is `cxs(blockExpiryHeight) || cxs(nonce)`: the\n * chain's own `Uniquifier` encoding, so the replay pair is spelled the way a\n * transaction spells its own. The result is signed directly, like\n * {@link transactionSignaturePreimage}; Ed25519 does its own hashing. It must\n * match the Rust `thruput_domain_separator::SignedOp::preimage` byte for\n * byte, or the verifying contract rejects the signature. Only the first 74\n * bytes are fixed-width: the uniquifier's two fields are CXS varints.\n *\n * {@link defineSignedOperation} calls this after encoding the payload; reach\n * for it directly only when the payload is already CXS bytes.\n */\nexport function signedOperationPreimage(\n preimage: SignedOperationPreimage,\n): Uint8Array {\n const writer = new CxsWriter();\n writer.writeFixedOpaque(preimage.network, 32);\n writer.writeFixedOpaque(preimage.verifyingContract, 32);\n contractSpecCodec.ContractTypeDef.encode(writer, preimage.typeDef);\n codec.Uniquifier.encode(writer, {\n block_expiry_height: preimage.blockExpiryHeight,\n nonce: preimage.nonce,\n });\n writer.writeFixedOpaque(preimage.body, preimage.body.length);\n const payload = writer.finish();\n\n const prefix = SIGNED_OP.bytes;\n const message = new Uint8Array(prefix.length + payload.length);\n message.set(prefix, 0);\n message.set(payload, prefix.length);\n return message;\n}\n","import type { ContractAddress, NetworkHash } from \"@thruputchain/protocol\";\nimport {\n CryptographicScheme,\n blockHeight,\n ed25519Signature,\n} from \"@thruputchain/protocol\";\nimport {\n ContractTypeDefKind,\n ContractTypeKind,\n type ContractSpecId,\n type ContractTypeDef,\n} from \"@thruputchain/contract-spec\";\nimport type { FixedBytes } from \"@thruputchain/xdr\";\nimport { randomBytes } from \"@noble/hashes/utils.js\";\nimport {\n createContractCodec,\n createContractCodecContext,\n} from \"../contract/codec.js\";\nimport { formatSpecId } from \"../contract/spec.js\";\nimport type { Signer } from \"../signers/types.js\";\nimport { signedOperationPreimage } from \"./preimage.js\";\n\n/**\n * Wire form of a signed operation: the `Operation` struct of the\n * `thruput-signed-op-if` interface, in the shape generated bindings give it.\n *\n * The network hash, the verifying contract, and the signing key are covered\n * by the signature but deliberately absent here. The verifying contract\n * supplies the first two from its own syscalls and checks the signature\n * against the key it holds, so a submitter can name neither the network or\n * contract a signature was meant for nor the key it is checked against.\n *\n * `block_expiry_height` and `nonce` are the chain's `Uniquifier`, in its\n * field order, so their encoding is byte for byte a transaction's.\n */\nexport interface Operation {\n /** Last block height (inclusive) at which the operation may execute. */\n block_expiry_height: bigint;\n /**\n * Chosen by the signer: any value, as long as the pair\n * `(nonce, block_expiry_height)` has not been consumed at the verifying\n * contract. There is no ordering. Consumed pairs are the contract's, not\n * the key's, so where several keys sign for one contract, draw nonces at\n * random ({@link randomNonce}) rather than counting; a lone key may do\n * either.\n */\n nonce: bigint;\n /** CXS encoding of the payload value. */\n body: Uint8Array;\n}\n\n/** An {@link Operation} and the Ed25519 signature over its preimage. */\nexport interface SignedOperation {\n readonly op: Operation;\n readonly signature: FixedBytes<64>;\n}\n\n/** What a signer supplies to produce one operation. */\nexport interface SignedOperationRequest<TBody> {\n /** Hash of the network the operation is valid on. */\n readonly network: NetworkHash;\n /** Address of the contract that will verify and act on the operation. */\n readonly verifyingContract: ContractAddress;\n /** Last block height (inclusive) at which the operation may execute. */\n readonly blockExpiryHeight: bigint;\n /**\n * Signer-chosen replay guard; see {@link Operation.nonce}. Nothing on\n * chain needs reading to pick one: {@link randomNonce} is always safe.\n */\n readonly nonce: bigint;\n /** The payload value, in the field shape generated bindings use. */\n readonly body: TBody;\n}\n\n/** Signing helpers bound to one payload type. */\nexport interface SignedOperationType<TBody> {\n /**\n * Declared name of the payload type: the `declared` segment of its spec id.\n * {@link SignedOperationType.typeDef} carries the full id.\n */\n readonly typeName: string;\n /** The payload type's spec definition, as bound into every preimage. */\n readonly typeDef: ContractTypeDef;\n /** CXS-encode a payload value the way the contract decodes it. */\n encodeBody(body: TBody): Uint8Array;\n /** The bytes a signature over `request` covers. */\n preimage(request: SignedOperationRequest<TBody>): Uint8Array;\n /** Encode, sign, and package `request` for the verifying contract. */\n sign(\n signer: Signer,\n request: SignedOperationRequest<TBody>,\n ): Promise<SignedOperation>;\n}\n\n/** Options for {@link defineSignedOperation}. */\nexport interface DefineSignedOperationOptions {\n /**\n * Type definitions the payload type is resolved against: a generated\n * binding's `spec.type_defs`, which carries the payload type and every type\n * it references.\n */\n readonly typeDefs: readonly ContractTypeDef[];\n /**\n * The payload type: either its name as declared with `#[contract_type]`\n * (the `declared` segment of its spec id), which must name exactly one of\n * `typeDefs`, or its full spec id, which selects one type even when another\n * crate or module declares the same name.\n */\n readonly typeName: string | ContractTypeSelector;\n}\n\n/**\n * Every segment of a payload type's spec id, as plain strings. A\n * `ContractSpecId` taken from a generated spec is assignable to it.\n */\nexport interface ContractTypeSelector {\n readonly crate_name: string;\n readonly major: string;\n readonly module_path: string;\n readonly declared: string;\n}\n\n/**\n * A uniformly random `u64` for {@link Operation.nonce}.\n *\n * Consumed `(nonce, block_expiry_height)` pairs are scoped to the verifying\n * contract, not to the signing key, so a random nonce is the choice that\n * stays safe when several keys sign for one contract; a lone key may count\n * instead. Draws from the platform's `crypto.getRandomValues`.\n */\nexport function randomNonce(): bigint {\n let nonce = 0n;\n for (const byte of randomBytes(8)) {\n nonce = (nonce << 8n) | BigInt(byte);\n }\n return nonce;\n}\n\n/**\n * Bind signing helpers to a `#[contract_type]` payload.\n *\n * A signed operation authorizes an on-chain action off-chain, so the signer\n * need not submit the transaction: the pattern behind permits, session keys,\n * and delegated wallet actions. The verifying contract embeds\n * `thruput_signed_op::SignedOpReplayCache` and checks the operation with\n * `consume::<Payload>` against the key it holds; this is the client half,\n * producing the `Operation` and signature that contract expects.\n *\n * @example\n * ```ts\n * import {\n * defineSignedOperation,\n * randomNonce,\n * } from \"@thruputchain/client/signed-op\";\n * import { spec, MyWallet, type my_wallet } from \"./generated/my_wallet.js\";\n *\n * const transfer = defineSignedOperation<my_wallet.v0_1.Transfer>({\n * typeDefs: spec.type_defs,\n * typeName: \"Transfer\",\n * });\n * const { op, signature } = await transfer.sign(signer, {\n * network: networkHash,\n * verifyingContract: walletAddress,\n * blockExpiryHeight: currentHeight + 100n,\n * nonce: randomNonce(),\n * body: { to: recipient, amount: 42n },\n * });\n * // `op` and `signature` are the arguments of the contract's submit entrypoint.\n * const invocation = MyWallet.v0_1.submit.invocation(walletAddress, gasLimit, {\n * op,\n * signature,\n * });\n * ```\n *\n * @throws If `typeName` selects none, or more than one, of `typeDefs`.\n */\nexport function defineSignedOperation<TBody>(\n options: DefineSignedOperationOptions,\n): SignedOperationType<TBody> {\n // Snapshot once: the codec context clones what it is given, so the\n // definition bound into every preimage must come from the same frozen copy\n // or a later mutation of the caller's array would split the two.\n const typeDefs = structuredClone([...options.typeDefs]);\n const typeDef = deepFreeze(findTypeDef(typeDefs, options.typeName));\n const id = typeDefId(typeDef);\n const context = createContractCodecContext(typeDefs);\n const bodyCodec = createContractCodec<TBody>(\n context,\n { v: ContractTypeKind.Named, named: id },\n `${formatSpecId(id)} payload`,\n );\n\n const preimageOf = (\n request: SignedOperationRequest<TBody>,\n blockExpiryHeight: bigint,\n nonce: bigint,\n body: Uint8Array,\n ): Uint8Array =>\n signedOperationPreimage({\n network: request.network,\n verifyingContract: request.verifyingContract,\n typeDef,\n blockExpiryHeight: blockHeight(blockExpiryHeight),\n nonce,\n body,\n });\n\n return {\n typeName: id.declared,\n typeDef,\n encodeBody: (body) => bodyCodec.encode(body),\n preimage: (request) =>\n preimageOf(\n request,\n request.blockExpiryHeight,\n request.nonce,\n bodyCodec.encode(request.body),\n ),\n async sign(signer, request) {\n if (signer.publicKey.scheme !== CryptographicScheme.Ed25519) {\n throw new Error(\"Signed operations require an Ed25519 signer\");\n }\n // Everything the returned operation carries is taken before the signer\n // is awaited, so a request mutated while a wallet prompt is pending\n // cannot make the operation disagree with the message that was signed.\n // The signature bytes are copied for the same reason, and the\n // constructor rejects any length but the 64 the wire struct's fixed\n // array encodes.\n const blockExpiryHeight = request.blockExpiryHeight;\n const nonce = request.nonce;\n const body = bodyCodec.encode(request.body);\n const message = preimageOf(request, blockExpiryHeight, nonce, body);\n const signature = await signer.sign(message);\n if (signature.scheme !== CryptographicScheme.Ed25519) {\n throw new Error(\"Signer did not return an Ed25519 signature\");\n }\n return {\n op: { block_expiry_height: blockExpiryHeight, nonce, body },\n signature: ed25519Signature(new Uint8Array(signature.ed25519)),\n };\n },\n };\n}\n\nfunction deepFreeze<T>(value: T): T {\n if (typeof value === \"object\" && value !== null && !Object.isFrozen(value)) {\n Object.freeze(value);\n for (const inner of Object.values(value as object)) {\n deepFreeze(inner);\n }\n }\n return value;\n}\n\nfunction typeDefId(typeDef: ContractTypeDef): ContractSpecId {\n switch (typeDef.v) {\n case ContractTypeDefKind.TypeDefStruct:\n return typeDef.struct_def.name;\n case ContractTypeDefKind.TypeDefEnum:\n return typeDef.enum_def.name;\n case ContractTypeDefKind.TypeDefUnion:\n return typeDef.union_def.name;\n }\n}\n\nfunction findTypeDef(\n typeDefs: readonly ContractTypeDef[],\n selector: string | ContractTypeSelector,\n): ContractTypeDef {\n const selects =\n typeof selector === \"string\"\n ? (id: ContractSpecId) => id.declared === selector\n : (id: ContractSpecId) =>\n id.crate_name === selector.crate_name &&\n id.major === selector.major &&\n id.module_path === selector.module_path &&\n id.declared === selector.declared;\n const label =\n typeof selector === \"string\" ? `\"${selector}\"` : formatSpecId(selector);\n const matches = typeDefs.filter((def) => selects(typeDefId(def)));\n const [typeDef] = matches;\n if (typeDef === undefined) {\n throw new Error(\n `Contract type ${label} is not defined in the given type definitions`,\n );\n }\n if (matches.length > 1) {\n const ids = matches.map((def) => formatSpecId(typeDefId(def)));\n throw new Error(\n `Contract type ${label} is ambiguous in the given type definitions: ${ids.join(\", \")}; select one by its full spec id`,\n );\n }\n return typeDef;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAsDA,SAAgB,wBACd,UACY;CACZ,MAAM,SAAS,IAAIA,uBAAAA,UAAU;CAC7B,OAAO,iBAAiB,SAAS,SAAS,EAAE;CAC5C,OAAO,iBAAiB,SAAS,mBAAmB,EAAE;CACtD,4BAAA,MAAkB,gBAAgB,OAAO,QAAQ,SAAS,OAAO;CACjE,uBAAA,MAAM,WAAW,OAAO,QAAQ;EAC9B,qBAAqB,SAAS;EAC9B,OAAO,SAAS;CAClB,CAAC;CACD,OAAO,iBAAiB,SAAS,MAAM,SAAS,KAAK,MAAM;CAC3D,MAAM,UAAU,OAAO,OAAO;CAE9B,M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B,MAAM,MAAM,QAAQ,KAAK,QAAQA,iBAAAA,aAAa,UAAU,GAAG,CAAC,CAAC;EAC7D,MAAM,IAAI,MACR,iBAAiB,MAAM,+CAA+C,IAAI,KAAK,IAAI,EAAE,iCACvF;CACF;CACA,OAAO;AACT"}
@@ -1,6 +1,6 @@
1
1
  import { r as SIGNED_OP } from "./domainSeparator-CBCvxIj-.js";
2
- import { g as createContractCodecContext, h as createContractCodec, j as formatSpecId } from "./contract-Cu8Qv94_.js";
3
- import "./signed_op-Dxn7-lRu.js";
2
+ import { g as createContractCodecContext, h as createContractCodec, j as formatSpecId } from "./contract-D77iA2iY.js";
3
+ import "./signed_op-CwN-_CXw.js";
4
4
  import { CryptographicScheme, CxsWriter, blockHeight, codec, ed25519Signature } from "@thruputchain/protocol";
5
5
  import { ContractTypeDefKind, ContractTypeKind, codec as codec$1 } from "@thruputchain/contract-spec";
6
6
  import { randomBytes } from "@noble/hashes/utils.js";
@@ -163,4 +163,4 @@ function findTypeDef(typeDefs, selector) {
163
163
  //#endregion
164
164
  export { randomNonce as n, signedOperationPreimage as r, defineSignedOperation as t };
165
165
 
166
- //# sourceMappingURL=signedOp-Kx8u8_3I.js.map
166
+ //# sourceMappingURL=signedOp-DpmUpH-e.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"signedOp-Kx8u8_3I.js","names":[],"sources":["../src/signedOp/preimage.ts","../src/signedOp/operation.ts"],"sourcesContent":["import type {\n BlockHeight,\n ContractAddress,\n NetworkHash,\n} from \"@thruputchain/protocol\";\nimport { CxsWriter, codec } from \"@thruputchain/protocol\";\nimport {\n codec as contractSpecCodec,\n type ContractTypeDef,\n} from \"@thruputchain/contract-spec\";\nimport { SIGNED_OP } from \"../derivation/domainSeparator.js\";\n\n/** Everything a signed-operation signature commits to. */\nexport interface SignedOperationPreimage {\n /** Hash of the network the operation is valid on. */\n readonly network: NetworkHash;\n /** Address of the contract entitled to act on the operation. */\n readonly verifyingContract: ContractAddress;\n /**\n * Spec definition of the payload type, as a generated binding ships it in\n * `spec.type_defs`. Part of the signed bytes, so a signature over one\n * payload type is never a signature over another with the same encoding.\n */\n readonly typeDef: ContractTypeDef;\n /** Last block height (inclusive) at which the operation may execute. */\n readonly blockExpiryHeight: BlockHeight;\n /**\n * Signer-chosen value that, with `blockExpiryHeight`, the verifying\n * contract consumes exactly once.\n */\n readonly nonce: bigint;\n /** CXS encoding of the payload value. */\n readonly body: Uint8Array;\n}\n\n/**\n * The message a signed-operation signature covers:\n *\n * ```text\n * cxs(DomainSeparator(\"SignedOp\")) || network || verifyingContract\n * || cxs(typeDef) || cxs(uniquifier) || body\n * ```\n *\n * where `cxs(uniquifier)` is `cxs(blockExpiryHeight) || cxs(nonce)`: the\n * chain's own `Uniquifier` encoding, so the replay pair is spelled the way a\n * transaction spells its own. The result is signed directly, like\n * {@link transactionSignaturePreimage}; Ed25519 does its own hashing. It must\n * match the Rust `thruput_domain_separator::SignedOp::preimage` byte for\n * byte, or the verifying contract rejects the signature. Only the first 74\n * bytes are fixed-width: the uniquifier's two fields are CXS varints.\n *\n * {@link defineSignedOperation} calls this after encoding the payload; reach\n * for it directly only when the payload is already CXS bytes.\n */\nexport function signedOperationPreimage(\n preimage: SignedOperationPreimage,\n): Uint8Array {\n const writer = new CxsWriter();\n writer.writeFixedOpaque(preimage.network, 32);\n writer.writeFixedOpaque(preimage.verifyingContract, 32);\n contractSpecCodec.ContractTypeDef.encode(writer, preimage.typeDef);\n codec.Uniquifier.encode(writer, {\n block_expiry_height: preimage.blockExpiryHeight,\n nonce: preimage.nonce,\n });\n writer.writeFixedOpaque(preimage.body, preimage.body.length);\n const payload = writer.finish();\n\n const prefix = SIGNED_OP.bytes;\n const message = new Uint8Array(prefix.length + payload.length);\n message.set(prefix, 0);\n message.set(payload, prefix.length);\n return message;\n}\n","import type { ContractAddress, NetworkHash } from \"@thruputchain/protocol\";\nimport {\n CryptographicScheme,\n blockHeight,\n ed25519Signature,\n} from \"@thruputchain/protocol\";\nimport {\n ContractTypeDefKind,\n ContractTypeKind,\n type ContractSpecId,\n type ContractTypeDef,\n} from \"@thruputchain/contract-spec\";\nimport type { FixedBytes } from \"@thruputchain/xdr\";\nimport { randomBytes } from \"@noble/hashes/utils.js\";\nimport {\n createContractCodec,\n createContractCodecContext,\n} from \"../contract/codec.js\";\nimport { formatSpecId } from \"../contract/spec.js\";\nimport type { Signer } from \"../signers/types.js\";\nimport { signedOperationPreimage } from \"./preimage.js\";\n\n/**\n * Wire form of a signed operation: the `Operation` struct of the\n * `thruput-signed-op-if` interface, in the shape generated bindings give it.\n *\n * The network hash, the verifying contract, and the signing key are covered\n * by the signature but deliberately absent here. The verifying contract\n * supplies the first two from its own syscalls and checks the signature\n * against the key it holds, so a submitter can name neither the network or\n * contract a signature was meant for nor the key it is checked against.\n *\n * `block_expiry_height` and `nonce` are the chain's `Uniquifier`, in its\n * field order, so their encoding is byte for byte a transaction's.\n */\nexport interface Operation {\n /** Last block height (inclusive) at which the operation may execute. */\n block_expiry_height: bigint;\n /**\n * Chosen by the signer: any value, as long as the pair\n * `(nonce, block_expiry_height)` has not been consumed at the verifying\n * contract. There is no ordering. Consumed pairs are the contract's, not\n * the key's, so where several keys sign for one contract, draw nonces at\n * random ({@link randomNonce}) rather than counting; a lone key may do\n * either.\n */\n nonce: bigint;\n /** CXS encoding of the payload value. */\n body: Uint8Array;\n}\n\n/** An {@link Operation} and the Ed25519 signature over its preimage. */\nexport interface SignedOperation {\n readonly op: Operation;\n readonly signature: FixedBytes<64>;\n}\n\n/** What a signer supplies to produce one operation. */\nexport interface SignedOperationRequest<TBody> {\n /** Hash of the network the operation is valid on. */\n readonly network: NetworkHash;\n /** Address of the contract that will verify and act on the operation. */\n readonly verifyingContract: ContractAddress;\n /** Last block height (inclusive) at which the operation may execute. */\n readonly blockExpiryHeight: bigint;\n /**\n * Signer-chosen replay guard; see {@link Operation.nonce}. Nothing on\n * chain needs reading to pick one: {@link randomNonce} is always safe.\n */\n readonly nonce: bigint;\n /** The payload value, in the field shape generated bindings use. */\n readonly body: TBody;\n}\n\n/** Signing helpers bound to one payload type. */\nexport interface SignedOperationType<TBody> {\n /**\n * Declared name of the payload type: the `declared` segment of its spec id.\n * {@link SignedOperationType.typeDef} carries the full id.\n */\n readonly typeName: string;\n /** The payload type's spec definition, as bound into every preimage. */\n readonly typeDef: ContractTypeDef;\n /** CXS-encode a payload value the way the contract decodes it. */\n encodeBody(body: TBody): Uint8Array;\n /** The bytes a signature over `request` covers. */\n preimage(request: SignedOperationRequest<TBody>): Uint8Array;\n /** Encode, sign, and package `request` for the verifying contract. */\n sign(\n signer: Signer,\n request: SignedOperationRequest<TBody>,\n ): Promise<SignedOperation>;\n}\n\n/** Options for {@link defineSignedOperation}. */\nexport interface DefineSignedOperationOptions {\n /**\n * Type definitions the payload type is resolved against: a generated\n * binding's `spec.type_defs`, which carries the payload type and every type\n * it references.\n */\n readonly typeDefs: readonly ContractTypeDef[];\n /**\n * The payload type: either its name as declared with `#[contract_type]`\n * (the `declared` segment of its spec id), which must name exactly one of\n * `typeDefs`, or its full spec id, which selects one type even when another\n * crate or module declares the same name.\n */\n readonly typeName: string | ContractTypeSelector;\n}\n\n/**\n * Every segment of a payload type's spec id, as plain strings. A\n * `ContractSpecId` taken from a generated spec is assignable to it.\n */\nexport interface ContractTypeSelector {\n readonly crate_name: string;\n readonly major: string;\n readonly module_path: string;\n readonly declared: string;\n}\n\n/**\n * A uniformly random `u64` for {@link Operation.nonce}.\n *\n * Consumed `(nonce, block_expiry_height)` pairs are scoped to the verifying\n * contract, not to the signing key, so a random nonce is the choice that\n * stays safe when several keys sign for one contract; a lone key may count\n * instead. Draws from the platform's `crypto.getRandomValues`.\n */\nexport function randomNonce(): bigint {\n let nonce = 0n;\n for (const byte of randomBytes(8)) {\n nonce = (nonce << 8n) | BigInt(byte);\n }\n return nonce;\n}\n\n/**\n * Bind signing helpers to a `#[contract_type]` payload.\n *\n * A signed operation authorizes an on-chain action off-chain, so the signer\n * need not submit the transaction: the pattern behind permits, session keys,\n * and delegated wallet actions. The verifying contract embeds\n * `thruput_signed_op::SignedOpReplayCache` and checks the operation with\n * `consume::<Payload>` against the key it holds; this is the client half,\n * producing the `Operation` and signature that contract expects.\n *\n * @example\n * ```ts\n * import {\n * defineSignedOperation,\n * randomNonce,\n * } from \"@thruputchain/client/signed-op\";\n * import { spec, MyWallet, type my_wallet } from \"./generated/my_wallet.js\";\n *\n * const transfer = defineSignedOperation<my_wallet.v0_1.Transfer>({\n * typeDefs: spec.type_defs,\n * typeName: \"Transfer\",\n * });\n * const { op, signature } = await transfer.sign(signer, {\n * network: networkHash,\n * verifyingContract: walletAddress,\n * blockExpiryHeight: currentHeight + 100n,\n * nonce: randomNonce(),\n * body: { to: recipient, amount: 42n },\n * });\n * // `op` and `signature` are the arguments of the contract's submit entrypoint.\n * const invocation = MyWallet.v0_1.submit.invocation(walletAddress, gasLimit, {\n * op,\n * signature,\n * });\n * ```\n *\n * @throws If `typeName` selects none, or more than one, of `typeDefs`.\n */\nexport function defineSignedOperation<TBody>(\n options: DefineSignedOperationOptions,\n): SignedOperationType<TBody> {\n // Snapshot once: the codec context clones what it is given, so the\n // definition bound into every preimage must come from the same frozen copy\n // or a later mutation of the caller's array would split the two.\n const typeDefs = structuredClone([...options.typeDefs]);\n const typeDef = deepFreeze(findTypeDef(typeDefs, options.typeName));\n const id = typeDefId(typeDef);\n const context = createContractCodecContext(typeDefs);\n const bodyCodec = createContractCodec<TBody>(\n context,\n { v: ContractTypeKind.Named, named: id },\n `${formatSpecId(id)} payload`,\n );\n\n const preimageOf = (\n request: SignedOperationRequest<TBody>,\n blockExpiryHeight: bigint,\n nonce: bigint,\n body: Uint8Array,\n ): Uint8Array =>\n signedOperationPreimage({\n network: request.network,\n verifyingContract: request.verifyingContract,\n typeDef,\n blockExpiryHeight: blockHeight(blockExpiryHeight),\n nonce,\n body,\n });\n\n return {\n typeName: id.declared,\n typeDef,\n encodeBody: (body) => bodyCodec.encode(body),\n preimage: (request) =>\n preimageOf(\n request,\n request.blockExpiryHeight,\n request.nonce,\n bodyCodec.encode(request.body),\n ),\n async sign(signer, request) {\n if (signer.publicKey.scheme !== CryptographicScheme.Ed25519) {\n throw new Error(\"Signed operations require an Ed25519 signer\");\n }\n // Everything the returned operation carries is taken before the signer\n // is awaited, so a request mutated while a wallet prompt is pending\n // cannot make the operation disagree with the message that was signed.\n // The signature bytes are copied for the same reason, and the\n // constructor rejects any length but the 64 the wire struct's fixed\n // array encodes.\n const blockExpiryHeight = request.blockExpiryHeight;\n const nonce = request.nonce;\n const body = bodyCodec.encode(request.body);\n const message = preimageOf(request, blockExpiryHeight, nonce, body);\n const signature = await signer.sign(message);\n if (signature.scheme !== CryptographicScheme.Ed25519) {\n throw new Error(\"Signer did not return an Ed25519 signature\");\n }\n return {\n op: { block_expiry_height: blockExpiryHeight, nonce, body },\n signature: ed25519Signature(new Uint8Array(signature.ed25519)),\n };\n },\n };\n}\n\nfunction deepFreeze<T>(value: T): T {\n if (typeof value === \"object\" && value !== null && !Object.isFrozen(value)) {\n Object.freeze(value);\n for (const inner of Object.values(value as object)) {\n deepFreeze(inner);\n }\n }\n return value;\n}\n\nfunction typeDefId(typeDef: ContractTypeDef): ContractSpecId {\n switch (typeDef.v) {\n case ContractTypeDefKind.TypeDefStruct:\n return typeDef.struct_def.name;\n case ContractTypeDefKind.TypeDefEnum:\n return typeDef.enum_def.name;\n case ContractTypeDefKind.TypeDefUnion:\n return typeDef.union_def.name;\n }\n}\n\nfunction findTypeDef(\n typeDefs: readonly ContractTypeDef[],\n selector: string | ContractTypeSelector,\n): ContractTypeDef {\n const selects =\n typeof selector === \"string\"\n ? (id: ContractSpecId) => id.declared === selector\n : (id: ContractSpecId) =>\n id.crate_name === selector.crate_name &&\n id.major === selector.major &&\n id.module_path === selector.module_path &&\n id.declared === selector.declared;\n const label =\n typeof selector === \"string\" ? `\"${selector}\"` : formatSpecId(selector);\n const matches = typeDefs.filter((def) => selects(typeDefId(def)));\n const [typeDef] = matches;\n if (typeDef === undefined) {\n throw new Error(\n `Contract type ${label} is not defined in the given type definitions`,\n );\n }\n if (matches.length > 1) {\n const ids = matches.map((def) => formatSpecId(typeDefId(def)));\n throw new Error(\n `Contract type ${label} is ambiguous in the given type definitions: ${ids.join(\", \")}; select one by its full spec id`,\n );\n }\n return typeDef;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAsDA,SAAgB,wBACd,UACY;CACZ,MAAM,SAAS,IAAI,UAAU;CAC7B,OAAO,iBAAiB,SAAS,SAAS,EAAE;CAC5C,OAAO,iBAAiB,SAAS,mBAAmB,EAAE;CACtD,QAAkB,gBAAgB,OAAO,QAAQ,SAAS,OAAO;CACjE,MAAM,WAAW,OAAO,QAAQ;EAC9B,qBAAqB,SAAS;EAC9B,OAAO,SAAS;CAClB,CAAC;CACD,OAAO,iBAAiB,SAAS,MAAM,SAAS,KAAK,MAAM;CAC3D,MAAM,UAAU,OAAO,OAAO;CAE9B,MAAM,SAAS,UAAU;CACzB,MAAM,UAAU,IAAI,WAAW,OAAO,SAAS,QAAQ,MAAM;CAC7D,QAAQ,IAAI,QAAQ,CAAC;CACrB,QAAQ,IAAI,SAAS,OAAO,MAAM;CAClC,OAAO;AACT;;;;;;;;;;;ACyDA,SAAgB,cAAsB;CACpC,IAAI,QAAQ;CACZ,KAAK,MAAM,QAAQ,YAAY,CAAC,GAC9B,QAAS,SAAS,KAAM,OAAO,IAAI;CAErC,OAAO;AACT;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwCA,SAAgB,sBACd,SAC4B;CAI5B,MAAM,WAAW,gBAAgB,CAAC,GAAG,QAAQ,QAAQ,CAAC;CACtD,MAAM,UAAU,WAAW,YAAY,UAAU,QAAQ,QAAQ,CAAC;CAClE,MAAM,KAAK,UAAU,OAAO;CAE5B,MAAM,YAAY,oBADF,2BAA2B,QAEnC,GACN;EAAE,GAAG,iBAAiB;EAAO,OAAO;CAAG,GACvC,GAAG,aAAa,EAAE,E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,UACA,UACiB;CACjB,MAAM,UACJ,OAAO,aAAa,YACf,OAAuB,GAAG,aAAa,YACvC,OACC,GAAG,eAAe,SAAS,cAC3B,GAAG,UAAU,SAAS,SACtB,GAAG,gBAAgB,SAAS,eAC5B,GAAG,aAAa,SAAS;CACjC,MAAM,QACJ,OAAO,aAAa,WAAW,IAAI,SAAS,KAAK,aAAa,QAAQ;CACxE,MAAM,UAAU,SAAS,QAAQ,QAAQ,QAAQ,UAAU,GAAG,CAAC,CAAC;CAChE,MAAM,CAAC,WAAW;CAClB,IAAI,YAAY,KAAA,GACd,MAAM,IAAI,MACR,iBAAiB,MAAM,8CACzB;CAEF,IAAI,QAAQ,SAAS,GAAG;EACtB,MAAM,MAAM,QAAQ,KAAK,QAAQ,aAAa,UAAU,GAAG,CAAC,CAAC;EAC7D,MAAM,IAAI,MACR,iBAAiB,MAAM,+CAA+C,IAAI,KAAK,IAAI,EAAE,iCACvF;CACF;CACA,OAAO;AACT"}
1
+ {"version":3,"file":"signedOp-DpmUpH-e.js","names":[],"sources":["../src/signedOp/preimage.ts","../src/signedOp/operation.ts"],"sourcesContent":["import type {\n BlockHeight,\n ContractAddress,\n NetworkHash,\n} from \"@thruputchain/protocol\";\nimport { CxsWriter, codec } from \"@thruputchain/protocol\";\nimport {\n codec as contractSpecCodec,\n type ContractTypeDef,\n} from \"@thruputchain/contract-spec\";\nimport { SIGNED_OP } from \"../derivation/domainSeparator.js\";\n\n/** Everything a signed-operation signature commits to. */\nexport interface SignedOperationPreimage {\n /** Hash of the network the operation is valid on. */\n readonly network: NetworkHash;\n /** Address of the contract entitled to act on the operation. */\n readonly verifyingContract: ContractAddress;\n /**\n * Spec definition of the payload type, as a generated binding ships it in\n * `spec.type_defs`. Part of the signed bytes, so a signature over one\n * payload type is never a signature over another with the same encoding.\n */\n readonly typeDef: ContractTypeDef;\n /** Last block height (inclusive) at which the operation may execute. */\n readonly blockExpiryHeight: BlockHeight;\n /**\n * Signer-chosen value that, with `blockExpiryHeight`, the verifying\n * contract consumes exactly once.\n */\n readonly nonce: bigint;\n /** CXS encoding of the payload value. */\n readonly body: Uint8Array;\n}\n\n/**\n * The message a signed-operation signature covers:\n *\n * ```text\n * cxs(DomainSeparator(\"SignedOp\")) || network || verifyingContract\n * || cxs(typeDef) || cxs(uniquifier) || body\n * ```\n *\n * where `cxs(uniquifier)` is `cxs(blockExpiryHeight) || cxs(nonce)`: the\n * chain's own `Uniquifier` encoding, so the replay pair is spelled the way a\n * transaction spells its own. The result is signed directly, like\n * {@link transactionSignaturePreimage}; Ed25519 does its own hashing. It must\n * match the Rust `thruput_domain_separator::SignedOp::preimage` byte for\n * byte, or the verifying contract rejects the signature. Only the first 74\n * bytes are fixed-width: the uniquifier's two fields are CXS varints.\n *\n * {@link defineSignedOperation} calls this after encoding the payload; reach\n * for it directly only when the payload is already CXS bytes.\n */\nexport function signedOperationPreimage(\n preimage: SignedOperationPreimage,\n): Uint8Array {\n const writer = new CxsWriter();\n writer.writeFixedOpaque(preimage.network, 32);\n writer.writeFixedOpaque(preimage.verifyingContract, 32);\n contractSpecCodec.ContractTypeDef.encode(writer, preimage.typeDef);\n codec.Uniquifier.encode(writer, {\n block_expiry_height: preimage.blockExpiryHeight,\n nonce: preimage.nonce,\n });\n writer.writeFixedOpaque(preimage.body, preimage.body.length);\n const payload = writer.finish();\n\n const prefix = SIGNED_OP.bytes;\n const message = new Uint8Array(prefix.length + payload.length);\n message.set(prefix, 0);\n message.set(payload, prefix.length);\n return message;\n}\n","import type { ContractAddress, NetworkHash } from \"@thruputchain/protocol\";\nimport {\n CryptographicScheme,\n blockHeight,\n ed25519Signature,\n} from \"@thruputchain/protocol\";\nimport {\n ContractTypeDefKind,\n ContractTypeKind,\n type ContractSpecId,\n type ContractTypeDef,\n} from \"@thruputchain/contract-spec\";\nimport type { FixedBytes } from \"@thruputchain/xdr\";\nimport { randomBytes } from \"@noble/hashes/utils.js\";\nimport {\n createContractCodec,\n createContractCodecContext,\n} from \"../contract/codec.js\";\nimport { formatSpecId } from \"../contract/spec.js\";\nimport type { Signer } from \"../signers/types.js\";\nimport { signedOperationPreimage } from \"./preimage.js\";\n\n/**\n * Wire form of a signed operation: the `Operation` struct of the\n * `thruput-signed-op-if` interface, in the shape generated bindings give it.\n *\n * The network hash, the verifying contract, and the signing key are covered\n * by the signature but deliberately absent here. The verifying contract\n * supplies the first two from its own syscalls and checks the signature\n * against the key it holds, so a submitter can name neither the network or\n * contract a signature was meant for nor the key it is checked against.\n *\n * `block_expiry_height` and `nonce` are the chain's `Uniquifier`, in its\n * field order, so their encoding is byte for byte a transaction's.\n */\nexport interface Operation {\n /** Last block height (inclusive) at which the operation may execute. */\n block_expiry_height: bigint;\n /**\n * Chosen by the signer: any value, as long as the pair\n * `(nonce, block_expiry_height)` has not been consumed at the verifying\n * contract. There is no ordering. Consumed pairs are the contract's, not\n * the key's, so where several keys sign for one contract, draw nonces at\n * random ({@link randomNonce}) rather than counting; a lone key may do\n * either.\n */\n nonce: bigint;\n /** CXS encoding of the payload value. */\n body: Uint8Array;\n}\n\n/** An {@link Operation} and the Ed25519 signature over its preimage. */\nexport interface SignedOperation {\n readonly op: Operation;\n readonly signature: FixedBytes<64>;\n}\n\n/** What a signer supplies to produce one operation. */\nexport interface SignedOperationRequest<TBody> {\n /** Hash of the network the operation is valid on. */\n readonly network: NetworkHash;\n /** Address of the contract that will verify and act on the operation. */\n readonly verifyingContract: ContractAddress;\n /** Last block height (inclusive) at which the operation may execute. */\n readonly blockExpiryHeight: bigint;\n /**\n * Signer-chosen replay guard; see {@link Operation.nonce}. Nothing on\n * chain needs reading to pick one: {@link randomNonce} is always safe.\n */\n readonly nonce: bigint;\n /** The payload value, in the field shape generated bindings use. */\n readonly body: TBody;\n}\n\n/** Signing helpers bound to one payload type. */\nexport interface SignedOperationType<TBody> {\n /**\n * Declared name of the payload type: the `declared` segment of its spec id.\n * {@link SignedOperationType.typeDef} carries the full id.\n */\n readonly typeName: string;\n /** The payload type's spec definition, as bound into every preimage. */\n readonly typeDef: ContractTypeDef;\n /** CXS-encode a payload value the way the contract decodes it. */\n encodeBody(body: TBody): Uint8Array;\n /** The bytes a signature over `request` covers. */\n preimage(request: SignedOperationRequest<TBody>): Uint8Array;\n /** Encode, sign, and package `request` for the verifying contract. */\n sign(\n signer: Signer,\n request: SignedOperationRequest<TBody>,\n ): Promise<SignedOperation>;\n}\n\n/** Options for {@link defineSignedOperation}. */\nexport interface DefineSignedOperationOptions {\n /**\n * Type definitions the payload type is resolved against: a generated\n * binding's `spec.type_defs`, which carries the payload type and every type\n * it references.\n */\n readonly typeDefs: readonly ContractTypeDef[];\n /**\n * The payload type: either its name as declared with `#[contract_type]`\n * (the `declared` segment of its spec id), which must name exactly one of\n * `typeDefs`, or its full spec id, which selects one type even when another\n * crate or module declares the same name.\n */\n readonly typeName: string | ContractTypeSelector;\n}\n\n/**\n * Every segment of a payload type's spec id, as plain strings. A\n * `ContractSpecId` taken from a generated spec is assignable to it.\n */\nexport interface ContractTypeSelector {\n readonly crate_name: string;\n readonly major: string;\n readonly module_path: string;\n readonly declared: string;\n}\n\n/**\n * A uniformly random `u64` for {@link Operation.nonce}.\n *\n * Consumed `(nonce, block_expiry_height)` pairs are scoped to the verifying\n * contract, not to the signing key, so a random nonce is the choice that\n * stays safe when several keys sign for one contract; a lone key may count\n * instead. Draws from the platform's `crypto.getRandomValues`.\n */\nexport function randomNonce(): bigint {\n let nonce = 0n;\n for (const byte of randomBytes(8)) {\n nonce = (nonce << 8n) | BigInt(byte);\n }\n return nonce;\n}\n\n/**\n * Bind signing helpers to a `#[contract_type]` payload.\n *\n * A signed operation authorizes an on-chain action off-chain, so the signer\n * need not submit the transaction: the pattern behind permits, session keys,\n * and delegated wallet actions. The verifying contract embeds\n * `thruput_signed_op::SignedOpReplayCache` and checks the operation with\n * `consume::<Payload>` against the key it holds; this is the client half,\n * producing the `Operation` and signature that contract expects.\n *\n * @example\n * ```ts\n * import {\n * defineSignedOperation,\n * randomNonce,\n * } from \"@thruputchain/client/signed-op\";\n * import { spec, MyWallet, type my_wallet } from \"./generated/my_wallet.js\";\n *\n * const transfer = defineSignedOperation<my_wallet.v0_1.Transfer>({\n * typeDefs: spec.type_defs,\n * typeName: \"Transfer\",\n * });\n * const { op, signature } = await transfer.sign(signer, {\n * network: networkHash,\n * verifyingContract: walletAddress,\n * blockExpiryHeight: currentHeight + 100n,\n * nonce: randomNonce(),\n * body: { to: recipient, amount: 42n },\n * });\n * // `op` and `signature` are the arguments of the contract's submit entrypoint.\n * const invocation = MyWallet.v0_1.submit.invocation(walletAddress, gasLimit, {\n * op,\n * signature,\n * });\n * ```\n *\n * @throws If `typeName` selects none, or more than one, of `typeDefs`.\n */\nexport function defineSignedOperation<TBody>(\n options: DefineSignedOperationOptions,\n): SignedOperationType<TBody> {\n // Snapshot once: the codec context clones what it is given, so the\n // definition bound into every preimage must come from the same frozen copy\n // or a later mutation of the caller's array would split the two.\n const typeDefs = structuredClone([...options.typeDefs]);\n const typeDef = deepFreeze(findTypeDef(typeDefs, options.typeName));\n const id = typeDefId(typeDef);\n const context = createContractCodecContext(typeDefs);\n const bodyCodec = createContractCodec<TBody>(\n context,\n { v: ContractTypeKind.Named, named: id },\n `${formatSpecId(id)} payload`,\n );\n\n const preimageOf = (\n request: SignedOperationRequest<TBody>,\n blockExpiryHeight: bigint,\n nonce: bigint,\n body: Uint8Array,\n ): Uint8Array =>\n signedOperationPreimage({\n network: request.network,\n verifyingContract: request.verifyingContract,\n typeDef,\n blockExpiryHeight: blockHeight(blockExpiryHeight),\n nonce,\n body,\n });\n\n return {\n typeName: id.declared,\n typeDef,\n encodeBody: (body) => bodyCodec.encode(body),\n preimage: (request) =>\n preimageOf(\n request,\n request.blockExpiryHeight,\n request.nonce,\n bodyCodec.encode(request.body),\n ),\n async sign(signer, request) {\n if (signer.publicKey.scheme !== CryptographicScheme.Ed25519) {\n throw new Error(\"Signed operations require an Ed25519 signer\");\n }\n // Everything the returned operation carries is taken before the signer\n // is awaited, so a request mutated while a wallet prompt is pending\n // cannot make the operation disagree with the message that was signed.\n // The signature bytes are copied for the same reason, and the\n // constructor rejects any length but the 64 the wire struct's fixed\n // array encodes.\n const blockExpiryHeight = request.blockExpiryHeight;\n const nonce = request.nonce;\n const body = bodyCodec.encode(request.body);\n const message = preimageOf(request, blockExpiryHeight, nonce, body);\n const signature = await signer.sign(message);\n if (signature.scheme !== CryptographicScheme.Ed25519) {\n throw new Error(\"Signer did not return an Ed25519 signature\");\n }\n return {\n op: { block_expiry_height: blockExpiryHeight, nonce, body },\n signature: ed25519Signature(new Uint8Array(signature.ed25519)),\n };\n },\n };\n}\n\nfunction deepFreeze<T>(value: T): T {\n if (typeof value === \"object\" && value !== null && !Object.isFrozen(value)) {\n Object.freeze(value);\n for (const inner of Object.values(value as object)) {\n deepFreeze(inner);\n }\n }\n return value;\n}\n\nfunction typeDefId(typeDef: ContractTypeDef): ContractSpecId {\n switch (typeDef.v) {\n case ContractTypeDefKind.TypeDefStruct:\n return typeDef.struct_def.name;\n case ContractTypeDefKind.TypeDefEnum:\n return typeDef.enum_def.name;\n case ContractTypeDefKind.TypeDefUnion:\n return typeDef.union_def.name;\n }\n}\n\nfunction findTypeDef(\n typeDefs: readonly ContractTypeDef[],\n selector: string | ContractTypeSelector,\n): ContractTypeDef {\n const selects =\n typeof selector === \"string\"\n ? (id: ContractSpecId) => id.declared === selector\n : (id: ContractSpecId) =>\n id.crate_name === selector.crate_name &&\n id.major === selector.major &&\n id.module_path === selector.module_path &&\n id.declared === selector.declared;\n const label =\n typeof selector === \"string\" ? `\"${selector}\"` : formatSpecId(selector);\n const matches = typeDefs.filter((def) => selects(typeDefId(def)));\n const [typeDef] = matches;\n if (typeDef === undefined) {\n throw new Error(\n `Contract type ${label} is not defined in the given type definitions`,\n );\n }\n if (matches.length > 1) {\n const ids = matches.map((def) => formatSpecId(typeDefId(def)));\n throw new Error(\n `Contract type ${label} is ambiguous in the given type definitions: ${ids.join(\", \")}; select one by its full spec id`,\n );\n }\n return typ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OAAO,aAAa,WAAW,IAAI,SAAS,KAAK,aAAa,QAAQ;CACxE,MAAM,UAAU,SAAS,QAAQ,QAAQ,QAAQ,UAAU,GAAG,CAAC,CAAC;CAChE,MAAM,CAAC,WAAW;CAClB,IAAI,YAAY,KAAA,GACd,MAAM,IAAI,MACR,iBAAiB,MAAM,8CACzB;CAEF,IAAI,QAAQ,SAAS,GAAG;EACtB,MAAM,MAAM,QAAQ,KAAK,QAAQ,aAAa,UAAU,GAAG,CAAC,CAAC;EAC7D,MAAM,IAAI,MACR,iBAAiB,MAAM,+CAA+C,IAAI,KAAK,IAAI,EAAE,iCACvF;CACF;CACA,OAAO;AACT"}
@@ -1,4 +1,4 @@
1
- import { g as createContractCodecContext, m as defineContractMethod } from "./contract-Cu8Qv94_.js";
1
+ import { g as createContractCodecContext, m as defineContractMethod } from "./contract-D77iA2iY.js";
2
2
  import * as __gh_protocol from "@thruputchain/protocol";
3
3
  import * as __gh_contract_spec from "@thruputchain/contract-spec";
4
4
  import * as __gh_protocol_utils from "@thruputchain/protocol/utils";
@@ -151,4 +151,4 @@ const thruput_signed_op_if = { v0_1: { error: { SignedOpError: {
151
151
  //#endregion
152
152
  export { spec as n, thruput_signed_op_if as r, SignedOp as t };
153
153
 
154
- //# sourceMappingURL=signed_op-Dxn7-lRu.js.map
154
+ //# sourceMappingURL=signed_op-CwN-_CXw.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"signed_op-Dxn7-lRu.js","names":["__gh_client_contract.createContractCodecContext","__gh_client_contract.defineContractMethod"],"sources":["../src/contracts/signed_op.ts"],"sourcesContent":["// Generated from signed_op.spec.xdr - SignedOp interface v0.1.68\n// DO NOT EDIT. Re-run codegen to update.\n\nimport * as __gh_protocol from \"@thruputchain/protocol\";\nimport * as __gh_protocol_utils from \"@thruputchain/protocol/utils\";\nimport * as __gh_contract_spec from \"@thruputchain/contract-spec\";\nimport * as __gh_client_contract from \"../contract/index.js\";\n\nconst __gh_s = __gh_contract_spec.contractSpecString;\n\nconst __gh_entrypoints = {\n SignedOp: {\n v0_1: {\n executeSignedOp: __gh_protocol.contractEntrypointID(\n __gh_protocol_utils.fromHex(\"c281dc2ffb5eeb1e\"),\n ),\n },\n },\n} as const;\n\nexport namespace thruput_signed_op_if {\n export namespace v0_1 {\n export interface Operation {\n block_expiry_height: bigint;\n nonce: bigint;\n body: globalThis.Uint8Array;\n }\n\n export namespace error {\n export type SignedOpError = 1n | 2n | 3n | 4n | 5n;\n }\n }\n}\n\nexport namespace SignedOp {\n export namespace v0_1 {\n export interface ExecuteSignedOpArgs {\n op: __gh_codegen.thruput_signed_op_if$v0_1$Operation;\n signature: __gh_client_contract.FixedBytes<64>;\n }\n export type ExecuteSignedOpResult = __gh_client_contract.SignedToken;\n\n export type DeclaredException = {\n kind: \"declared\";\n name: \"SignedOpError\";\n selector: 0xd7c6325a55793b51n;\n value: __gh_codegen.thruput_signed_op_if$v0_1$error$SignedOpError;\n };\n export type Exception =\n __gh_client_contract.ContractException<DeclaredException>;\n }\n}\n\nexport const spec: __gh_client_contract.ContractSpec = {\n interfaces: [\n {\n name: __gh_s(\"SignedOp\"),\n vers: __gh_s(\"0.1.68\"),\n throws: [\n {\n selector: 0xd7c6325a55793b51n,\n ty: {\n v: __gh_contract_spec.ContractTypeKind.Named,\n named: {\n crate_name: __gh_s(\"thruput-signed-op-if\"),\n major: __gh_s(\"0.1\"),\n module_path: __gh_s(\"thruput_signed_op_if::error\"),\n declared: __gh_s(\"SignedOpError\"),\n },\n },\n },\n ],\n methods: [\n {\n name: __gh_s(\"execute_signed_op\"),\n args: [\n {\n name: __gh_s(\"op\"),\n ty: {\n v: __gh_contract_spec.ContractTypeKind.Named,\n named: {\n crate_name: __gh_s(\"thruput-signed-op-if\"),\n major: __gh_s(\"0.1\"),\n module_path: __gh_s(\"thruput_signed_op_if\"),\n declared: __gh_s(\"Operation\"),\n },\n },\n },\n {\n name: __gh_s(\"signature\"),\n ty: {\n v: __gh_contract_spec.ContractTypeKind.Array,\n array: {\n element: { v: __gh_contract_spec.ContractTypeKind.U8 },\n len: 64n,\n },\n },\n },\n ],\n return_type: {\n v: __gh_contract_spec.ContractTypeKind.SignedToken,\n signed_token_preimage: { preimage_type: null },\n },\n effect: null,\n },\n ],\n },\n ],\n type_defs: [\n {\n v: __gh_contract_spec.ContractTypeDefKind.TypeDefStruct,\n struct_def: {\n name: {\n crate_name: __gh_s(\"thruput-signed-op-if\"),\n major: __gh_s(\"0.1\"),\n module_path: __gh_s(\"thruput_signed_op_if\"),\n declared: __gh_s(\"Operation\"),\n },\n fields: [\n {\n name: __gh_s(\"block_expiry_height\"),\n ty: { v: __gh_contract_spec.ContractTypeKind.I64 },\n },\n {\n name: __gh_s(\"nonce\"),\n ty: { v: __gh_contract_spec.ContractTypeKind.U64 },\n },\n {\n name: __gh_s(\"body\"),\n ty: {\n v: __gh_contract_spec.ContractTypeKind.Vector,\n vector: {\n element: { v: __gh_contract_spec.ContractTypeKind.U8 },\n max_len: 4294967295n,\n },\n },\n },\n ],\n },\n },\n {\n v: __gh_contract_spec.ContractTypeDefKind.TypeDefEnum,\n enum_def: {\n name: {\n crate_name: __gh_s(\"thruput-signed-op-if\"),\n major: __gh_s(\"0.1\"),\n module_path: __gh_s(\"thruput_signed_op_if::error\"),\n declared: __gh_s(\"SignedOpError\"),\n },\n variants: [\n { name: __gh_s(\"InvalidSignature\"), value: 1n },\n { name: __gh_s(\"Expired\"), value: 2n },\n { name: __gh_s(\"AlreadyConsumed\"), value: 3n },\n { name: __gh_s(\"MalformedBody\"), value: 4n },\n { name: __gh_s(\"NotYetExpired\"), value: 5n },\n ],\n },\n },\n ],\n events: [],\n};\n\nconst __gh_codecs = __gh_client_contract.createContractCodecContext(\n spec.type_defs,\n);\n\nexport const SignedOp = {\n v0_1: {\n executeSignedOp: __gh_client_contract.defineContractMethod<\n SignedOp.v0_1.ExecuteSignedOpArgs,\n SignedOp.v0_1.ExecuteSignedOpResult,\n SignedOp.v0_1.DeclaredException\n >({\n interfaceName: \"SignedOp\",\n interfaceVersion: \"0.1.68\",\n abiName: \"execute_signed_op\",\n publicName: \"executeSignedOp\",\n entrypoint: __gh_entrypoints.SignedOp.v0_1.executeSignedOp,\n effect: spec.interfaces[0]!.methods[0]!.effect,\n args: [\n {\n abiName: \"op\",\n publicName: \"op\",\n type: spec.interfaces[0]!.methods[0]!.args[0]!.ty,\n },\n {\n abiName: \"signature\",\n publicName: \"signature\",\n type: spec.interfaces[0]!.methods[0]!.args[1]!.ty,\n },\n ],\n returnType: spec.interfaces[0]!.methods[0]!.return_type,\n throws: [\n {\n selector: 0xd7c6325a55793b51n,\n name: \"SignedOpError\",\n type: spec.interfaces[0]!.throws[0]!.ty,\n },\n ],\n codecs: __gh_codecs,\n }),\n },\n} as const;\n\nexport const thruput_signed_op_if = {\n v0_1: {\n error: {\n SignedOpError: {\n InvalidSignature: 1n,\n Expired: 2n,\n AlreadyConsumed: 3n,\n MalformedBody: 4n,\n NotYetExpired: 5n,\n },\n },\n },\n} as const;\n\n// The types the namespaces above refer to, under names no declaration can capture.\nexport namespace __gh_codegen {\n export type thruput_signed_op_if$v0_1$Operation =\n thruput_signed_op_if.v0_1.Operation;\n export type thruput_signed_op_if$v0_1$error$SignedOpError =\n thruput_signed_op_if.v0_1.error.SignedOpError;\n}\n"],"mappings":";;;;;AAQA,MAAM,SAAS,mBAAmB;AAElC,MAAM,mBAAmB,EACvB,UAAU,EACR,MAAM,EACJ,iBAAiB,cAAc,qBAC7B,oBAAoB,QAAQ,kBAAkB,CAChD,EACF,EACF,EACF;AAmCA,MAAa,OAA0C;CACrD,YAAY,CACV;EACE,MAAM,OAAO,UAAU;EACvB,MAAM,OAAO,QAAQ;EACrB,QAAQ,CACN;GACE,UAAU;GACV,IAAI;IACF,GAAG,mBAAmB,iBAAiB;IACvC,OAAO;KACL,YAAY,OAAO,sBAAsB;KACzC,OAAO,OAAO,KAAK;KACnB,aAAa,OAAO,6BAA6B;KACjD,UAAU,OAAO,eAAe;IAClC;GACF;E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AAM,OAAO,kBAAkB;KAAG,OAAO;IAAG;IAC9C;KAAE,MAAM,OAAO,SAAS;KAAG,OAAO;IAAG;IACrC;KAAE,MAAM,OAAO,iBAAiB;KAAG,OAAO;IAAG;IAC7C;KAAE,MAAM,OAAO,eAAe;KAAG,OAAO;IAAG;IAC3C;KAAE,MAAM,OAAO,eAAe;KAAG,OAAO;IAAG;GAC7C;EACF;CACF,CACF;CACA,QAAQ,CAAC;AACX;AAEA,MAAM,cAAcA,2BAClB,KAAK,SACP;AAEA,MAAa,WAAW,EACtB,MAAM,EACJ,iBAAiBC,qBAIf;CACA,eAAe;CACf,kBAAkB;CAClB,SAAS;CACT,YAAY;CACZ,YAAY,iBAAiB,SAAS,KAAK;CAC3C,QAAQ,KAAK,WAAW,EAAE,CAAE,QAAQ,EAAE,CAAE;CACxC,MAAM,CACJ;EACE,SAAS;EACT,YAAY;EACZ,MAAM,KAAK,WAAW,EAAE,CAAE,QAAQ,EAAE,CAAE,KAAK,EAAE,CAAE;CACjD,GACA;EACE,SAAS;EACT,YAAY;EACZ,MAAM,KAAK,WAAW,EAAE,CAAE,QAAQ,EAAE,CAAE,KAAK,EAAE,CAAE;CACjD,CACF;CACA,YAAY,KAAK,WAAW,EAAE,CAAE,QAAQ,EAAE,CAAE;CAC5C,QAAQ,CACN;EACE,UAAU;EACV,MAAM;EACN,MAAM,KAAK,WAAW,EAAE,CAAE,OAAO,EAAE,CAAE;CACvC,CACF;CACA,QAAQ;AACV,CAAC,EACH,EACF;AAEA,MAAa,uBAAuB,EAClC,MAAM,EACJ,OAAO,EACL,eAAe;CACb,kBAAkB;CAClB,SAAS;CACT,iBAAiB;CACjB,eAAe;CACf,eAAe;AACjB,EACF,EACF,EACF"}
1
+ {"version":3,"file":"signed_op-CwN-_CXw.js","names":["__gh_client_contract.createContractCodecContext","__gh_client_contract.defineContractMethod"],"sources":["../src/contracts/signed_op.ts"],"sourcesContent":["// Generated from signed_op.spec.xdr - SignedOp interface v0.1.68\n// DO NOT EDIT. Re-run codegen to update.\n\nimport * as __gh_protocol from \"@thruputchain/protocol\";\nimport * as __gh_protocol_utils from \"@thruputchain/protocol/utils\";\nimport * as __gh_contract_spec from \"@thruputchain/contract-spec\";\nimport * as __gh_client_contract from \"../contract/index.js\";\n\nconst __gh_s = __gh_contract_spec.contractSpecString;\n\nconst __gh_entrypoints = {\n SignedOp: {\n v0_1: {\n executeSignedOp: __gh_protocol.contractEntrypointID(\n __gh_protocol_utils.fromHex(\"c281dc2ffb5eeb1e\"),\n ),\n },\n },\n} as const;\n\nexport namespace thruput_signed_op_if {\n export namespace v0_1 {\n export interface Operation {\n block_expiry_height: bigint;\n nonce: bigint;\n body: globalThis.Uint8Array;\n }\n\n export namespace error {\n export type SignedOpError = 1n | 2n | 3n | 4n | 5n;\n }\n }\n}\n\nexport namespace SignedOp {\n export namespace v0_1 {\n export interface ExecuteSignedOpArgs {\n op: __gh_codegen.thruput_signed_op_if$v0_1$Operation;\n signature: __gh_client_contract.FixedBytes<64>;\n }\n export type ExecuteSignedOpResult = __gh_client_contract.SignedToken;\n\n export type DeclaredException = {\n kind: \"declared\";\n name: \"SignedOpError\";\n selector: 0xd7c6325a55793b51n;\n value: __gh_codegen.thruput_signed_op_if$v0_1$error$SignedOpError;\n };\n export type Exception =\n __gh_client_contract.ContractException<DeclaredException>;\n }\n}\n\nexport const spec: __gh_client_contract.ContractSpec = {\n interfaces: [\n {\n name: __gh_s(\"SignedOp\"),\n vers: __gh_s(\"0.1.68\"),\n throws: [\n {\n selector: 0xd7c6325a55793b51n,\n ty: {\n v: __gh_contract_spec.ContractTypeKind.Named,\n named: {\n crate_name: __gh_s(\"thruput-signed-op-if\"),\n major: __gh_s(\"0.1\"),\n module_path: __gh_s(\"thruput_signed_op_if::error\"),\n declared: __gh_s(\"SignedOpError\"),\n },\n },\n },\n ],\n methods: [\n {\n name: __gh_s(\"execute_signed_op\"),\n args: [\n {\n name: __gh_s(\"op\"),\n ty: {\n v: __gh_contract_spec.ContractTypeKind.Named,\n named: {\n crate_name: __gh_s(\"thruput-signed-op-if\"),\n major: __gh_s(\"0.1\"),\n module_path: __gh_s(\"thruput_signed_op_if\"),\n declared: __gh_s(\"Operation\"),\n },\n },\n },\n {\n name: __gh_s(\"signature\"),\n ty: {\n v: __gh_contract_spec.ContractTypeKind.Array,\n array: {\n element: { v: __gh_contract_spec.ContractTypeKind.U8 },\n len: 64n,\n },\n },\n },\n ],\n return_type: {\n v: __gh_contract_spec.ContractTypeKind.SignedToken,\n signed_token_preimage: { preimage_type: null },\n },\n effect: null,\n },\n ],\n },\n ],\n type_defs: [\n {\n v: __gh_contract_spec.ContractTypeDefKind.TypeDefStruct,\n struct_def: {\n name: {\n crate_name: __gh_s(\"thruput-signed-op-if\"),\n major: __gh_s(\"0.1\"),\n module_path: __gh_s(\"thruput_signed_op_if\"),\n declared: __gh_s(\"Operation\"),\n },\n fields: [\n {\n name: __gh_s(\"block_expiry_height\"),\n ty: { v: __gh_contract_spec.ContractTypeKind.I64 },\n },\n {\n name: __gh_s(\"nonce\"),\n ty: { v: __gh_contract_spec.ContractTypeKind.U64 },\n },\n {\n name: __gh_s(\"body\"),\n ty: {\n v: __gh_contract_spec.ContractTypeKind.Vector,\n vector: {\n element: { v: __gh_contract_spec.ContractTypeKind.U8 },\n max_len: 4294967295n,\n },\n },\n },\n ],\n },\n },\n {\n v: __gh_contract_spec.ContractTypeDefKind.TypeDefEnum,\n enum_def: {\n name: {\n crate_name: __gh_s(\"thruput-signed-op-if\"),\n major: __gh_s(\"0.1\"),\n module_path: __gh_s(\"thruput_signed_op_if::error\"),\n declared: __gh_s(\"SignedOpError\"),\n },\n variants: [\n { name: __gh_s(\"InvalidSignature\"), value: 1n },\n { name: __gh_s(\"Expired\"), value: 2n },\n { name: __gh_s(\"AlreadyConsumed\"), value: 3n },\n { name: __gh_s(\"MalformedBody\"), value: 4n },\n { name: __gh_s(\"NotYetExpired\"), value: 5n },\n ],\n },\n },\n ],\n events: [],\n};\n\nconst __gh_codecs = __gh_client_contract.createContractCodecContext(\n spec.type_defs,\n);\n\nexport const SignedOp = {\n v0_1: {\n executeSignedOp: __gh_client_contract.defineContractMethod<\n SignedOp.v0_1.ExecuteSignedOpArgs,\n SignedOp.v0_1.ExecuteSignedOpResult,\n SignedOp.v0_1.DeclaredException\n >({\n interfaceName: \"SignedOp\",\n interfaceVersion: \"0.1.68\",\n abiName: \"execute_signed_op\",\n publicName: \"executeSignedOp\",\n entrypoint: __gh_entrypoints.SignedOp.v0_1.executeSignedOp,\n effect: spec.interfaces[0]!.methods[0]!.effect,\n args: [\n {\n abiName: \"op\",\n publicName: \"op\",\n type: spec.interfaces[0]!.methods[0]!.args[0]!.ty,\n },\n {\n abiName: \"signature\",\n publicName: \"signature\",\n type: spec.interfaces[0]!.methods[0]!.args[1]!.ty,\n },\n ],\n returnType: spec.interfaces[0]!.methods[0]!.return_type,\n throws: [\n {\n selector: 0xd7c6325a55793b51n,\n name: \"SignedOpError\",\n type: spec.interfaces[0]!.throws[0]!.ty,\n },\n ],\n codecs: __gh_codecs,\n }),\n },\n} as const;\n\nexport const thruput_signed_op_if = {\n v0_1: {\n error: {\n SignedOpError: {\n InvalidSignature: 1n,\n Expired: 2n,\n AlreadyConsumed: 3n,\n MalformedBody: 4n,\n NotYetExpired: 5n,\n },\n },\n },\n} as const;\n\n// The types the namespaces above refer to, under names no declaration can capture.\nexport namespace __gh_codegen {\n export type thruput_signed_op_if$v0_1$Operation =\n thruput_signed_op_if.v0_1.Operation;\n export type thruput_signed_op_if$v0_1$error$SignedOpError =\n thruput_signed_op_if.v0_1.error.SignedOpError;\n}\n"],"mappings":";;;;;AAQA,MAAM,SAAS,mBAAmB;AAElC,MAAM,mBAAmB,EACvB,UAAU,EACR,MAAM,EACJ,iBAAiB,cAAc,qBAC7B,oBAAoB,QAAQ,kBAAkB,CAChD,EACF,EACF,EACF;AAmCA,MAAa,OAA0C;CACrD,YAAY,CACV;EACE,MAAM,OAAO,UAAU;EACvB,MAAM,OA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AAe;CACf,eAAe;AACjB,EACF,EACF,EACF"}
@@ -1,5 +1,5 @@
1
- import { Ot as ContractSpec, l as ContractMethod, s as ContractException } from "./readViews-CQOY5v4o.cjs";
2
- import { c as SignedToken, n as FixedBytes } from "./index-BmQN3jAS.cjs";
1
+ import { Ot as ContractSpec, l as ContractMethod, s as ContractException } from "./readViews-DbWELMMq.cjs";
2
+ import { c as SignedToken, n as FixedBytes } from "./index-CedOvhGY.cjs";
3
3
 
4
4
  //#region src/contracts/signed_op.d.ts
5
5
  declare namespace thruput_signed_op_if {
@@ -55,4 +55,4 @@ declare namespace __gh_codegen {
55
55
  }
56
56
  //#endregion
57
57
  export { spec as n, thruput_signed_op_if as r, SignedOp as t };
58
- //# sourceMappingURL=signed_op-BrLxDrDb.d.cts.map
58
+ //# sourceMappingURL=signed_op-D2usgASc.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"signed_op-BrLxDrDb.d.cts","names":[],"sources":["../src/contracts/signed_op.ts"],"mappings":";;;;kBAoBiB,oBAAA;EAAA,UACE,IAAA;IAAA,UACE,SAAA;MACf,mBAAA;MACA,KAAA;MACA,IAAA,EAAM,UAAA,CAAW,UAAU;IAAA;IAAA,UAGZ,KAAA;MAAA,KACH,aAAA;IAAA;EAAA;AAAA;AAAA,kBAKD,QAAA;EAAA,UACE,IAAA;IAAA,UACE,mBAAA;MACf,EAAA,EAAI,YAAA,CAAa,mCAAA;MACjB,SAAA,EAAW,UAAA;IAAA;IAAA,KAED,qBAAA,GAAwB,WAAA;IAAA,KAExB,iBAAA;MACV,IAAA;MACA,IAAA;MACA,QAAA;MACA,KAAA,EAAO,YAAA,CAAa,6CAAA;IAAA;IAAA,KAEV,SAAA,GACV,iBAAA,CAAuC,iBAAA;EAAA;AAAA;AAAA,cAIhC,IAAA,EAAM,YA2GlB;AAAA,cAMY,QAAA;EAAA;;;;cAsCA,oBAAA;EAAA;;;;;;;;;;;;kBAeI,YAAA;EAAA,KACH,mCAAA,GACV,oBAAA,CAAqB,IAAA,CAAK,SAAA;EAAA,KAChB,6CAAA,GACV,oBAAA,CAAqB,IAAA,CAAK,KAAA,CAAM,aAAa;AAAA"}
1
+ {"version":3,"file":"signed_op-D2usgASc.d.cts","names":[],"sources":["../src/contracts/signed_op.ts"],"mappings":";;;;kBAoBiB,oBAAA;EAAA,UACE,IAAA;IAAA,UACE,SAAA;MACf,mBAAA;MACA,KAAA;MACA,IAAA,EAAM,UAAA,CAAW,UAAU;IAAA;IAAA,UAGZ,KAAA;MAAA,KACH,aAAA;IAAA;EAAA;AAAA;AAAA,kBAKD,QAAA;EAAA,UACE,IAAA;IAAA,UACE,mBAAA;MACf,EAAA,EAAI,YAAA,CAAa,mCAAA;MACjB,SAAA,EAAW,UAAA;IAAA;IAAA,KAED,qBAAA,GAAwB,WAAA;IAAA,KAExB,iBAAA;MACV,IAAA;MACA,IAAA;MACA,QAAA;MACA,KAAA,EAAO,YAAA,CAAa,6CAAA;IAAA;IAAA,KAEV,SAAA,GACV,iBAAA,CAAuC,iBAAA;EAAA;AAAA;AAAA,cAIhC,IAAA,EAAM,YA2GlB;AAAA,cAMY,QAAA;EAAA;;;;cAsCA,oBAAA;EAAA;;;;;;;;;;;;kBAeI,YAAA;EAAA,KACH,mCAAA,GACV,oBAAA,CAAqB,IAAA,CAAK,SAAA;EAAA,KAChB,6CAAA,GACV,oBAAA,CAAqB,IAAA,CAAK,KAAA,CAAM,aAAa;AAAA"}
@@ -1,5 +1,5 @@
1
1
  const require_rolldown_runtime = require("./rolldown-runtime-D6vf50IK.cjs");
2
- const require_contract = require("./contract-DPm2BJTu.cjs");
2
+ const require_contract = require("./contract-DSu2UPPm.cjs");
3
3
  let _thruputchain_protocol = require("@thruputchain/protocol");
4
4
  _thruputchain_protocol = require_rolldown_runtime.__toESM(_thruputchain_protocol, 1);
5
5
  let _thruputchain_contract_spec = require("@thruputchain/contract-spec");
@@ -172,4 +172,4 @@ Object.defineProperty(exports, "thruput_signed_op_if", {
172
172
  }
173
173
  });
174
174
 
175
- //# sourceMappingURL=signed_op-CAcYYRm6.cjs.map
175
+ //# sourceMappingURL=signed_op-_lR85dn2.cjs.map