@thruputchain/client 0.28.0 → 0.30.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 (184) hide show
  1. package/README.md +113 -18
  2. package/dist/actions-B7htk5FS.js +698 -0
  3. package/dist/actions-B7htk5FS.js.map +1 -0
  4. package/dist/actions-CIaI049y.cjs +788 -0
  5. package/dist/actions-CIaI049y.cjs.map +1 -0
  6. package/dist/actions.cjs +5 -8
  7. package/dist/actions.d.cts +4 -4
  8. package/dist/actions.d.ts +4 -4
  9. package/dist/actions.js +3 -3
  10. package/dist/{contract-D77iA2iY.js → contract-BOlNskwd.js} +235 -87
  11. package/dist/contract-BOlNskwd.js.map +1 -0
  12. package/dist/{contract-DSu2UPPm.cjs → contract-D_vxUudr.cjs} +281 -109
  13. package/dist/contract-D_vxUudr.cjs.map +1 -0
  14. package/dist/contract.cjs +1 -5
  15. package/dist/contract.d.cts +3 -4
  16. package/dist/contract.d.ts +3 -4
  17. package/dist/contract.js +2 -2
  18. package/dist/contracts.cjs +5 -5
  19. package/dist/contracts.d.cts +6 -74
  20. package/dist/contracts.d.cts.map +1 -1
  21. package/dist/contracts.d.ts +6 -74
  22. package/dist/contracts.d.ts.map +1 -1
  23. package/dist/contracts.js +4 -4
  24. package/dist/decimal-BX7abv5J.cjs +171 -0
  25. package/dist/decimal-BX7abv5J.cjs.map +1 -0
  26. package/dist/decimal-CoHOISys.js +124 -0
  27. package/dist/decimal-CoHOISys.js.map +1 -0
  28. package/dist/default_wallet-DkqsCa5C.d.ts +90 -0
  29. package/dist/default_wallet-DkqsCa5C.d.ts.map +1 -0
  30. package/dist/default_wallet-Dqs4_iTD.d.cts +90 -0
  31. package/dist/default_wallet-Dqs4_iTD.d.cts.map +1 -0
  32. package/dist/{dev_wallet-CAbOSrak.cjs → dev_wallet-BVChhV6j.cjs} +85 -6
  33. package/dist/dev_wallet-BVChhV6j.cjs.map +1 -0
  34. package/dist/{dev_wallet-CU3RpQLm.js → dev_wallet-D9LuPZ-h.js} +84 -5
  35. package/dist/dev_wallet-D9LuPZ-h.js.map +1 -0
  36. package/dist/{execution-J5jkXhV1.d.cts → execution-pSt6k620.d.cts} +23 -50
  37. package/dist/execution-pSt6k620.d.cts.map +1 -0
  38. package/dist/{execution-XJ0iwFaX.d.ts → execution-uiuFPV0d.d.ts} +23 -50
  39. package/dist/execution-uiuFPV0d.d.ts.map +1 -0
  40. package/dist/{hex-DIcaALXL.js → hex-B8D-jBgz.js} +2 -2
  41. package/dist/{hex-DIcaALXL.js.map → hex-B8D-jBgz.js.map} +1 -1
  42. package/dist/{hex-DkGpiZ5e.cjs → hex-CSDZ9d6z.cjs} +2 -2
  43. package/dist/{hex-DkGpiZ5e.cjs.map → hex-CSDZ9d6z.cjs.map} +1 -1
  44. package/dist/{index-soFVQX9j.d.cts → index-B1efA-Y_.d.ts} +24 -21
  45. package/dist/index-B1efA-Y_.d.ts.map +1 -0
  46. package/dist/{index-C3HVRvQd.d.ts → index-BGmH_Sm7.d.cts} +12 -62
  47. package/dist/index-BGmH_Sm7.d.cts.map +1 -0
  48. package/dist/{index-DeS1S0m-.d.ts → index-BmOG68Hd.d.ts} +39 -17
  49. package/dist/index-BmOG68Hd.d.ts.map +1 -0
  50. package/dist/{index-B5KqSHeL.d.cts → index-BsvYcU_Y.d.cts} +2 -2
  51. package/dist/{index-B5KqSHeL.d.cts.map → index-BsvYcU_Y.d.cts.map} +1 -1
  52. package/dist/{index-CtjZ61tl.d.cts → index-CG-q0j9w.d.ts} +12 -62
  53. package/dist/index-CG-q0j9w.d.ts.map +1 -0
  54. package/dist/index-CPtBvHE8.d.ts +145 -0
  55. package/dist/index-CPtBvHE8.d.ts.map +1 -0
  56. package/dist/{index-DfmDUk5Y.d.ts → index-DBKsOzCN.d.cts} +24 -21
  57. package/dist/index-DBKsOzCN.d.cts.map +1 -0
  58. package/dist/{index-Bb01ytjJ.d.ts → index-Dtv_GV6M.d.ts} +40 -11
  59. package/dist/index-Dtv_GV6M.d.ts.map +1 -0
  60. package/dist/{index-CtjWsAXV.d.cts → index-JKm4TBlY.d.cts} +40 -11
  61. package/dist/index-JKm4TBlY.d.cts.map +1 -0
  62. package/dist/index-Xre-0Jka.d.cts +145 -0
  63. package/dist/index-Xre-0Jka.d.cts.map +1 -0
  64. package/dist/{index-CedOvhGY.d.cts → index-ozfbEuYI.d.cts} +39 -17
  65. package/dist/index-ozfbEuYI.d.cts.map +1 -0
  66. package/dist/index.cjs +40 -68
  67. package/dist/index.cjs.map +1 -1
  68. package/dist/index.d.cts +11 -17
  69. package/dist/index.d.cts.map +1 -1
  70. package/dist/index.d.ts +11 -17
  71. package/dist/index.d.ts.map +1 -1
  72. package/dist/index.js +27 -38
  73. package/dist/index.js.map +1 -1
  74. package/dist/provider.cjs +3 -3
  75. package/dist/provider.cjs.map +1 -1
  76. package/dist/provider.d.cts +2 -1
  77. package/dist/provider.d.ts +2 -1
  78. package/dist/provider.js +3 -3
  79. package/dist/provider.js.map +1 -1
  80. package/dist/{codec-Bxlt1gKO.js → readError-B3Rz7rgs.js} +359 -56
  81. package/dist/readError-B3Rz7rgs.js.map +1 -0
  82. package/dist/{codec-BcK8ASsg.cjs → readError-COcEDNoZ.cjs} +363 -96
  83. package/dist/readError-COcEDNoZ.cjs.map +1 -0
  84. package/dist/requestAirdrop-DBCOST2B.d.ts +1818 -0
  85. package/dist/requestAirdrop-DBCOST2B.d.ts.map +1 -0
  86. package/dist/requestAirdrop-T1eVn3l5.d.cts +1818 -0
  87. package/dist/requestAirdrop-T1eVn3l5.d.cts.map +1 -0
  88. package/dist/sendInvocation-185ZJrta.cjs +583 -0
  89. package/dist/sendInvocation-185ZJrta.cjs.map +1 -0
  90. package/dist/sendInvocation-DBaNWhr3.js +439 -0
  91. package/dist/sendInvocation-DBaNWhr3.js.map +1 -0
  92. package/dist/signed-op.cjs +2 -2
  93. package/dist/signed-op.d.cts +2 -2
  94. package/dist/signed-op.d.ts +1 -1
  95. package/dist/signed-op.js +2 -2
  96. package/dist/{signedOp-DAucp6xg.cjs → signedOp-CVyeJ5ig.cjs} +3 -3
  97. package/dist/{signedOp-DAucp6xg.cjs.map → signedOp-CVyeJ5ig.cjs.map} +1 -1
  98. package/dist/{signedOp-DpmUpH-e.js → signedOp-D6WYZG9j.js} +3 -3
  99. package/dist/{signedOp-DpmUpH-e.js.map → signedOp-D6WYZG9j.js.map} +1 -1
  100. package/dist/{signed_op-_lR85dn2.cjs → signed_op-BBsDKOlD.cjs} +4 -4
  101. package/dist/{signed_op-_lR85dn2.cjs.map → signed_op-BBsDKOlD.cjs.map} +1 -1
  102. package/dist/{signed_op-zGq4eBo8.d.ts → signed_op-DHb4n2JO.d.cts} +3 -3
  103. package/dist/{signed_op-D2usgASc.d.cts.map → signed_op-DHb4n2JO.d.cts.map} +1 -1
  104. package/dist/{signed_op-D2usgASc.d.cts → signed_op-Dfa8WD0j.d.ts} +3 -3
  105. package/dist/{signed_op-zGq4eBo8.d.ts.map → signed_op-Dfa8WD0j.d.ts.map} +1 -1
  106. package/dist/{signed_op-CwN-_CXw.js → signed_op-h9X9-vBL.js} +3 -3
  107. package/dist/{signed_op-CwN-_CXw.js.map → signed_op-h9X9-vBL.js.map} +1 -1
  108. package/dist/transport-BhWZxHcz.cjs +528 -0
  109. package/dist/transport-BhWZxHcz.cjs.map +1 -0
  110. package/dist/transport-EyDYuibb.js +504 -0
  111. package/dist/transport-EyDYuibb.js.map +1 -0
  112. package/dist/transport.cjs +6 -13
  113. package/dist/transport.d.cts +3 -3
  114. package/dist/transport.d.ts +3 -3
  115. package/dist/transport.js +4 -4
  116. package/dist/types-VYjJcTip.d.cts +161 -0
  117. package/dist/types-VYjJcTip.d.cts.map +1 -0
  118. package/dist/types-VYjJcTip.d.ts +161 -0
  119. package/dist/types-VYjJcTip.d.ts.map +1 -0
  120. package/dist/{validation-eXATmgO0.js → validation-BLQ64Dfh.js} +3 -3
  121. package/dist/validation-BLQ64Dfh.js.map +1 -0
  122. package/dist/{validation-4w-vDGAi.cjs → validation-CZqtmMLJ.cjs} +3 -3
  123. package/dist/validation-CZqtmMLJ.cjs.map +1 -0
  124. package/dist/{wallet-BNKgOXrF.js → wallet-NlZiI4-3.js} +161 -77
  125. package/dist/wallet-NlZiI4-3.js.map +1 -0
  126. package/dist/{wallet-7R5M_7h4.cjs → wallet-UvyXtxh5.cjs} +161 -77
  127. package/dist/wallet-UvyXtxh5.cjs.map +1 -0
  128. package/dist/wallet.cjs +2 -8
  129. package/dist/wallet.d.cts +4 -3
  130. package/dist/wallet.d.ts +4 -3
  131. package/dist/wallet.js +3 -3
  132. package/package.json +5 -5
  133. package/dist/actions-B5-CjpEF.cjs +0 -513
  134. package/dist/actions-B5-CjpEF.cjs.map +0 -1
  135. package/dist/actions-C1SMLWO5.js +0 -430
  136. package/dist/actions-C1SMLWO5.js.map +0 -1
  137. package/dist/artifact-BM_MVzhL.d.cts +0 -35
  138. package/dist/artifact-BM_MVzhL.d.cts.map +0 -1
  139. package/dist/artifact-BM_MVzhL.d.ts +0 -35
  140. package/dist/artifact-BM_MVzhL.d.ts.map +0 -1
  141. package/dist/client-jOZxB8yW.d.cts +0 -798
  142. package/dist/client-jOZxB8yW.d.cts.map +0 -1
  143. package/dist/client-jOZxB8yW.d.ts +0 -798
  144. package/dist/client-jOZxB8yW.d.ts.map +0 -1
  145. package/dist/codec-BcK8ASsg.cjs.map +0 -1
  146. package/dist/codec-Bxlt1gKO.js.map +0 -1
  147. package/dist/contract-D77iA2iY.js.map +0 -1
  148. package/dist/contract-DSu2UPPm.cjs.map +0 -1
  149. package/dist/dev_wallet-CAbOSrak.cjs.map +0 -1
  150. package/dist/dev_wallet-CU3RpQLm.js.map +0 -1
  151. package/dist/execution-J5jkXhV1.d.cts.map +0 -1
  152. package/dist/execution-XJ0iwFaX.d.ts.map +0 -1
  153. package/dist/index-Bb01ytjJ.d.ts.map +0 -1
  154. package/dist/index-C3HVRvQd.d.ts.map +0 -1
  155. package/dist/index-CIHK7Ew9.d.cts +0 -303
  156. package/dist/index-CIHK7Ew9.d.cts.map +0 -1
  157. package/dist/index-CIHK7Ew9.d.ts +0 -303
  158. package/dist/index-CIHK7Ew9.d.ts.map +0 -1
  159. package/dist/index-CedOvhGY.d.cts.map +0 -1
  160. package/dist/index-CtjWsAXV.d.cts.map +0 -1
  161. package/dist/index-CtjZ61tl.d.cts.map +0 -1
  162. package/dist/index-DeS1S0m-.d.ts.map +0 -1
  163. package/dist/index-DfmDUk5Y.d.ts.map +0 -1
  164. package/dist/index-soFVQX9j.d.cts.map +0 -1
  165. package/dist/readError-CCVlmBhj.cjs +0 -624
  166. package/dist/readError-CCVlmBhj.cjs.map +0 -1
  167. package/dist/readError-D1dppovI.js +0 -571
  168. package/dist/readError-D1dppovI.js.map +0 -1
  169. package/dist/readViews-DbWELMMq.d.cts +0 -609
  170. package/dist/readViews-DbWELMMq.d.cts.map +0 -1
  171. package/dist/readViews-nV3jbpYc.d.ts +0 -609
  172. package/dist/readViews-nV3jbpYc.d.ts.map +0 -1
  173. package/dist/sendInvocation-Dsr9ij5P.cjs +0 -661
  174. package/dist/sendInvocation-Dsr9ij5P.cjs.map +0 -1
  175. package/dist/sendInvocation-tBmf8haQ.js +0 -505
  176. package/dist/sendInvocation-tBmf8haQ.js.map +0 -1
  177. package/dist/transport-5FPeNwuv.cjs +0 -279
  178. package/dist/transport-5FPeNwuv.cjs.map +0 -1
  179. package/dist/transport-IrhVlS4w.js +0 -261
  180. package/dist/transport-IrhVlS4w.js.map +0 -1
  181. package/dist/validation-4w-vDGAi.cjs.map +0 -1
  182. package/dist/validation-eXATmgO0.js.map +0 -1
  183. package/dist/wallet-7R5M_7h4.cjs.map +0 -1
  184. package/dist/wallet-BNKgOXrF.js.map +0 -1
@@ -0,0 +1,788 @@
1
+ const require_decimal = require("./decimal-BX7abv5J.cjs");
2
+ const require_hex = require("./hex-CSDZ9d6z.cjs");
3
+ const require_contract = require("./contract-D_vxUudr.cjs");
4
+ const require_readError = require("./readError-COcEDNoZ.cjs");
5
+ const require_sendInvocation = require("./sendInvocation-185ZJrta.cjs");
6
+ const require_dev_wallet = require("./dev_wallet-BVChhV6j.cjs");
7
+ let _thruputchain_protocol = require("@thruputchain/protocol");
8
+ let _noble_hashes_sha2_js = require("@noble/hashes/sha2.js");
9
+ let _thruputchain_protocol_utils = require("@thruputchain/protocol/utils");
10
+ //#region src/actions/public/waitForTransactionReceipt.ts
11
+ /**
12
+ * Observation stopped: code `transactionOutcomeUnknown`. Neither a timeout nor
13
+ * cancellation proves that the transaction did not execute.
14
+ */
15
+ function outcomeUnknown(transactionHash, reason, timedOut, cause, knownCommitment, lastStatus) {
16
+ return new require_decimal.ThruputError("transactionOutcomeUnknown", timedOut ? `Timed out waiting for transaction ${(0, _thruputchain_protocol_utils.toBase58)(transactionHash)}` : `Could not observe transaction ${(0, _thruputchain_protocol_utils.toBase58)(transactionHash)}`, {
17
+ context: {
18
+ ...knownCommitment ? { knownCommitment } : {},
19
+ ...lastStatus ? { lastStatus } : {}
20
+ },
21
+ ...cause === void 0 ? {} : { cause },
22
+ transaction: {
23
+ hash: transactionHash,
24
+ outcome: "unknown",
25
+ reason
26
+ }
27
+ });
28
+ }
29
+ /** The observation deadline. Private, so read-error handling never retries it. */
30
+ var ObservationTimeout = class extends Error {};
31
+ /** The reason for a timeout: the last read failure or node status, when known. */
32
+ function timeoutReason(lastFailure, lastStatus) {
33
+ if (lastFailure !== void 0) return "disconnected";
34
+ if (lastStatus === void 0) return "timeout";
35
+ if (lastStatus instanceof require_decimal.UnsupportedRpcValue) return "statusUnknown";
36
+ if (lastStatus.status === "unknown" || lastStatus.status === "other") return "statusUnknown";
37
+ if (lastStatus.status === "recentFailure") return "recentFailure";
38
+ return "timeout";
39
+ }
40
+ const equal = (a, b) => a.length === b.length && a.every((v, i) => v === b[i]);
41
+ /**
42
+ * Return any committed receipt, including failed execution. Never sign or resubmit.
43
+ * When observation stops, throws code `transactionOutcomeUnknown` with
44
+ * `transaction.reason` set to why it stopped.
45
+ */
46
+ async function waitForTransactionReceipt(client, transactionHash, options = {}) {
47
+ return await observe(client, transactionHash, options, false);
48
+ }
49
+ /** Observe commitment independently of receipt availability or execution success. */
50
+ async function waitForCommitment(client, transactionHash, options = {}) {
51
+ return await observe(client, transactionHash, options, true);
52
+ }
53
+ function snapshotStatus(status) {
54
+ const copy = (value) => {
55
+ if (value instanceof require_decimal.UnsupportedRpcValue) return new require_decimal.UnsupportedRpcValue(structuredClone(value.raw));
56
+ if (Array.isArray(value)) return value.map(copy);
57
+ if (ArrayBuffer.isView(value)) return structuredClone(value);
58
+ if (value !== null && typeof value === "object") return Object.fromEntries(Object.entries(value).map(([key, entry]) => [key, copy(entry)]));
59
+ return value;
60
+ };
61
+ return copy(status);
62
+ }
63
+ async function observe(client, hash, options, commitmentOnly) {
64
+ const timeoutMs = options.timeoutMs ?? 3e4;
65
+ const interval = options.pollingIntervalMs ?? 250;
66
+ require_sendInvocation.validateTimer(timeoutMs, "timeoutMs");
67
+ require_sendInvocation.validateTimer(interval, "pollingIntervalMs");
68
+ const transactionHash = new Uint8Array(hash);
69
+ const networkHash = new Uint8Array(options.expectedNetworkHash ?? client.discovery.network.networkHash);
70
+ if (transactionHash.length !== 32 || networkHash.length !== 32) throw new RangeError("Transaction and network hashes must contain 32 bytes");
71
+ let commitment;
72
+ let lastStatus;
73
+ if (options.knownCommitment) {
74
+ const known = options.knownCommitment;
75
+ if (!equal(known.transactionHash, transactionHash) || !equal(known.networkHash, networkHash) || typeof known.blockHeight !== "bigint" || known.blockHeight < 0n || known.blockHeight > 9223372036854775807n) throw new TypeError("knownCommitment does not match the transaction hash and network");
76
+ commitment = {
77
+ transactionHash: transactionHash.slice(),
78
+ networkHash: networkHash.slice(),
79
+ blockHeight: known.blockHeight
80
+ };
81
+ lastStatus = {
82
+ status: "committed",
83
+ blockHeight: known.blockHeight
84
+ };
85
+ }
86
+ client.requireMethods([
87
+ "getNetworkInfo",
88
+ "getTransactionReceipt",
89
+ "getTransactionStatus"
90
+ ]);
91
+ const deadline = performance.now() + timeoutMs;
92
+ let lastFailure;
93
+ let failures = 0;
94
+ let timedOut = false;
95
+ let stopReason;
96
+ const stop = (reason, error) => {
97
+ stopReason = reason;
98
+ return error;
99
+ };
100
+ const timeout = () => {
101
+ timedOut = true;
102
+ return new ObservationTimeout("Transaction observation timed out");
103
+ };
104
+ const run = (operation) => require_sendInvocation.beforeDeadline(operation, deadline, options.signal, timeout);
105
+ const retain = (blockHeight) => {
106
+ if (commitment && commitment.blockHeight !== blockHeight) throw stop("commitmentConflict", require_readError.rpcIncompatible("commitment", "Conflicting commitment heights for the same transaction"));
107
+ commitment = {
108
+ transactionHash: transactionHash.slice(),
109
+ networkHash: networkHash.slice(),
110
+ blockHeight
111
+ };
112
+ lastStatus = {
113
+ status: "committed",
114
+ blockHeight
115
+ };
116
+ };
117
+ try {
118
+ while (true) {
119
+ let retryAfterMs;
120
+ let networkVerified = false;
121
+ let failed = false;
122
+ try {
123
+ if (!equal((await run((signal) => client.getNetworkInfo({}, { signal }))).networkHash, networkHash)) throw stop("networkChanged", require_readError.rpcIncompatible("network", "Observation endpoint network changed"));
124
+ networkVerified = true;
125
+ if (commitmentOnly && commitment) return structuredClone(commitment);
126
+ const receipt = await run((signal) => client.getTransactionReceipt({ transactionHash }, { signal }));
127
+ if (receipt) {
128
+ retain(receipt.blockHeight);
129
+ return commitmentOnly ? structuredClone(commitment) : receipt;
130
+ }
131
+ } catch (cause) {
132
+ if (cause instanceof ObservationTimeout || options.signal?.aborted) throw cause;
133
+ lastFailure = cause;
134
+ failed = true;
135
+ if (require_decimal.isThruputError(cause, "nativeRpcError") && cause.context.data) {
136
+ const data = cause.context.data;
137
+ if (data.kind === "backendDataInvalid" && data.observation) {
138
+ retain(data.observation.blockHeight);
139
+ if (commitmentOnly) return structuredClone(commitment);
140
+ }
141
+ if ("retryAfterMs" in data) retryAfterMs = data.retryAfterMs;
142
+ }
143
+ if (options.signal?.aborted || require_readError.classifyReadError(cause, options) !== "transient") throw cause;
144
+ }
145
+ let observedStatus;
146
+ if (networkVerified) try {
147
+ const status = await run((signal) => client.getTransactionStatus({ transactionHash }, { signal }));
148
+ if (!(status instanceof require_decimal.UnsupportedRpcValue) && status.status === "committed") retain(status.blockHeight);
149
+ else if (!commitment) lastStatus = snapshotStatus(status);
150
+ observedStatus = status;
151
+ } catch (cause) {
152
+ if (cause instanceof ObservationTimeout || require_decimal.isThruputError(cause, "rpcIncompatible") || require_decimal.isThruputError(cause, "rpcValueInvalid") || require_decimal.isThruputError(cause, "rpcRequestInvalid") || require_readError.classifyReadError(cause, options) === "permanent") throw cause;
153
+ options.signal?.throwIfAborted();
154
+ lastFailure = cause;
155
+ failed = true;
156
+ if (require_decimal.isThruputError(cause, "nativeRpcError") && cause.context.data && "retryAfterMs" in cause.context.data) {
157
+ const hint = cause.context.data.retryAfterMs;
158
+ if (hint !== void 0 && (retryAfterMs === void 0 || hint > retryAfterMs)) retryAfterMs = hint;
159
+ }
160
+ }
161
+ if (observedStatus !== void 0) options.onStatus?.(observedStatus);
162
+ if (failed) failures++;
163
+ else {
164
+ failures = 0;
165
+ lastFailure = void 0;
166
+ }
167
+ if (commitmentOnly && commitment) return structuredClone(commitment);
168
+ const backoff = failures ? Math.min(5e3, Math.max(1, interval) * 2 ** Math.min(failures - 1, 8)) * (.5 + Math.random() / 2) : interval;
169
+ const remaining = deadline - performance.now();
170
+ if (retryAfterMs !== void 0 && retryAfterMs > BigInt(Math.max(0, Math.floor(remaining)))) throw timeout();
171
+ const delay = Math.max(backoff, Number(retryAfterMs ?? 0n));
172
+ await run((signal) => require_sendInvocation.waitDelay(Math.min(delay, Math.max(0, remaining)), signal));
173
+ }
174
+ } catch (cause) {
175
+ const reason = options.signal?.aborted ? "cancelled" : timedOut ? timeoutReason(lastFailure, lastStatus) : stopReason ?? "observationFailed";
176
+ throw outcomeUnknown(transactionHash, reason, timedOut && reason !== "cancelled", cause instanceof ObservationTimeout ? lastFailure : cause, commitment && structuredClone(commitment), lastStatus);
177
+ }
178
+ }
179
+ //#endregion
180
+ //#region src/actions/public/requestAirdrop.ts
181
+ /** Perform exactly one faucet call. It neither polls nor repeats an ambiguous attempt. */
182
+ async function requestAirdropAttempt(client, request, options = {}) {
183
+ return client.faucet_requestAirdrop(request, options);
184
+ }
185
+ /**
186
+ * Call the faucet once, then observe a returned pending hash using read-only calls.
187
+ * When funding stops, throws code `fundingStopped` without permission to call the
188
+ * faucet again. `transaction` is present when the faucet identified a
189
+ * transaction; reconcile with `context.request.clientNonce`.
190
+ */
191
+ async function requestAirdrop(client, options) {
192
+ const timeoutMs = options.timeoutMs ?? 6e4;
193
+ require_sendInvocation.validateTimer(timeoutMs, "timeoutMs");
194
+ const request = {
195
+ recipient: new Uint8Array(options.recipient),
196
+ clientNonce: options.clientNonce ? new Uint8Array(options.clientNonce) : crypto.getRandomValues(new Uint8Array(16)),
197
+ networkHash: new Uint8Array(options.expectedNetworkHash ?? client.discovery.network.networkHash)
198
+ };
199
+ if (request.recipient.length !== 32 || request.networkHash.length !== 32 || request.clientNonce.length < 1 || request.clientNonce.length > 32) throw new RangeError("Funding requires 32-byte addresses/hashes and a 1–32 byte nonce");
200
+ client.requireMethods([
201
+ "faucet_requestAirdrop",
202
+ "getNetworkInfo",
203
+ "getTransactionReceipt",
204
+ "getTransactionStatus"
205
+ ]);
206
+ const deadline = performance.now() + timeoutMs;
207
+ let lastResponse;
208
+ let timedOut = false;
209
+ const timeout = () => {
210
+ timedOut = true;
211
+ return new DOMException("Funding observation timed out", "TimeoutError");
212
+ };
213
+ const run = (operation) => require_sendInvocation.beforeDeadline(operation, deadline, options.signal, timeout);
214
+ let phase = "network";
215
+ try {
216
+ if ((await run((signal) => client.getNetworkInfo({}, { signal }))).networkHash.some((v, i) => v !== request.networkHash[i])) throw require_readError.rpcIncompatible("network", "Funding endpoint network does not match");
217
+ phase = "faucet";
218
+ lastResponse = await run((signal) => requestAirdropAttempt(client, {
219
+ recipient: request.recipient,
220
+ clientNonce: request.clientNonce
221
+ }, { signal }));
222
+ if (require_decimal.isUnsupportedRpcValue(lastResponse)) throw unsupported("Unsupported faucet response", lastResponse);
223
+ if (lastResponse.attemptStatus === "succeeded") {
224
+ if (require_decimal.isUnsupportedRpcValue(lastResponse.execution)) throw unsupported("Unsupported faucet execution outcome", lastResponse.execution);
225
+ return lastResponse;
226
+ }
227
+ if (!lastResponse.transactionHash) throw new Error("The faucet attempt is pending without a transaction");
228
+ phase = "observe";
229
+ const receipt = await waitForTransactionReceipt(client, lastResponse.transactionHash, {
230
+ expectedNetworkHash: request.networkHash,
231
+ timeoutMs: Math.max(0, deadline - performance.now()),
232
+ signal: options.signal
233
+ });
234
+ require_sendInvocation.assertTransactionSuccess(receipt);
235
+ return {
236
+ attemptStatus: "succeeded",
237
+ recipient: lastResponse.recipient,
238
+ rawAmount: lastResponse.rawAmount,
239
+ transactionHash: receipt.transactionHash,
240
+ blockHeight: receipt.blockHeight,
241
+ execution: receipt.execution
242
+ };
243
+ } catch (cause) {
244
+ const cancelled = require_sendInvocation.isCancellation(cause, options.signal);
245
+ const response = require_decimal.isUnsupportedRpcValue(lastResponse) ? void 0 : lastResponse;
246
+ const native = !cancelled && phase === "faucet" && require_decimal.isThruputError(cause, "nativeRpcError") ? cause.context.data : void 0;
247
+ const observed = !cancelled && phase === "observe" && require_decimal.isThruputError(cause) && cause.transaction && response?.transactionHash && bytesEqual(cause.transaction.hash, response.transactionHash) ? cause.transaction : void 0;
248
+ const receipt = observed?.receipt ?? (native && "receipt" in native ? native.receipt : void 0);
249
+ const hash = receipt?.transactionHash ?? observed?.hash ?? (native && "transactionHash" in native ? native.transactionHash : void 0) ?? response?.transactionHash;
250
+ const signed = native && "signedTransaction" in native ? native.signedTransaction : void 0;
251
+ const submission = signed && hash ? fundingSubmission(signed, request.networkHash, hash) : void 0;
252
+ const reason = options.signal?.aborted ? "cancelled" : timedOut ? "timeout" : native ? require_readError.classifyReadError(cause) === "transient" ? "disconnected" : "nodeRejected" : "observationFailed";
253
+ const extra = submission ? { submission } : {};
254
+ const transaction = receipt ? {
255
+ ...require_contract.receiptFacts(receipt, reason),
256
+ ...extra
257
+ } : observed ? {
258
+ hash: observed.hash,
259
+ outcome: observed.outcome,
260
+ reason: observed.reason
261
+ } : hash ? {
262
+ hash,
263
+ outcome: "unknown",
264
+ reason: response?.attemptStatus === "succeeded" ? "outcomeUnsupported" : reason,
265
+ ...extra
266
+ } : void 0;
267
+ const committed = receipt ?? (response?.attemptStatus === "succeeded" ? response : void 0);
268
+ const knownCommitment = observed && require_decimal.isThruputError(cause, "transactionOutcomeUnknown") ? cause.context.knownCommitment : committed ? {
269
+ networkHash: request.networkHash.slice(),
270
+ transactionHash: new Uint8Array(committed.transactionHash),
271
+ blockHeight: committed.blockHeight
272
+ } : void 0;
273
+ throw new require_decimal.ThruputError("fundingStopped", "Funding observation stopped", {
274
+ context: {
275
+ request,
276
+ ...lastResponse === void 0 ? {} : { lastResponse },
277
+ ...knownCommitment ? { knownCommitment } : {}
278
+ },
279
+ cause,
280
+ ...transaction ? { transaction } : {}
281
+ });
282
+ }
283
+ }
284
+ /** Signed faucet bytes as submission evidence, when they match the hash. */
285
+ function fundingSubmission(signedTransaction, networkHash, hash) {
286
+ try {
287
+ const evidence = require_sendInvocation.createSubmissionEvidence(signedTransaction, networkHash);
288
+ return bytesEqual(evidence.transactionHash, hash) ? evidence : void 0;
289
+ } catch {
290
+ return;
291
+ }
292
+ }
293
+ function bytesEqual(left, right) {
294
+ return left.length === right.length && left.every((byte, i) => byte === right[i]);
295
+ }
296
+ function unsupported(message, value) {
297
+ return new require_decimal.ThruputError("rpcValueUnsupported", message, { context: { value } });
298
+ }
299
+ //#endregion
300
+ //#region src/actions/public/getContractEvents.ts
301
+ /**
302
+ * Fetch exactly one page using a generated event's filter and decoder.
303
+ *
304
+ * No additional pages are fetched. Pass the returned cursor into the next call
305
+ * with the same filters. Malformed events and unexpected signatures throw
306
+ * code `contractDecodeFailed` rather than silently disappearing from the page.
307
+ *
308
+ * @example
309
+ * ```ts
310
+ * const page = await getContractEvents(client, {
311
+ * event: thruput_erc20_if.v0_1.events.TransferEvent,
312
+ * addresses: [tokenAddress],
313
+ * topics: { to: accountAddress },
314
+ * start: { order: "ascending", anchor: { kind: "atBeginning" } },
315
+ * limit: 20,
316
+ * }, { signal });
317
+ * ```
318
+ */
319
+ async function getContractEvents(client, query, options) {
320
+ options?.signal?.throwIfAborted();
321
+ const { event, addresses, topics, ...pageQuery } = query;
322
+ const page = await client.getEvents({
323
+ ...pageQuery,
324
+ filters: [event.filter({
325
+ addresses,
326
+ topics
327
+ })]
328
+ }, options);
329
+ return {
330
+ ...page,
331
+ events: page.events.map(({ event: raw, ...identity }) => {
332
+ const decoded = event.decode(raw);
333
+ if (decoded === null) throw require_contract.contractDecodeFailed("Event query returned an unexpected event signature");
334
+ return {
335
+ ...decoded,
336
+ ...identity,
337
+ address: raw.address
338
+ };
339
+ })
340
+ };
341
+ }
342
+ //#endregion
343
+ //#region src/actions/public/historyWalk.ts
344
+ const compare = (a, b) => {
345
+ for (let i = 0; i < 3; i++) {
346
+ if (a[i] < b[i]) return -1;
347
+ if (a[i] > b[i]) return 1;
348
+ }
349
+ return 0;
350
+ };
351
+ /** Shared cross-page checks; single-page shape, filter and identity checks belong to RpcClient. */
352
+ async function* walkHistory(fetch, kind, scope, options) {
353
+ const order = "start" in scope ? scope.start.order : scope.order;
354
+ let cursor, watermark, lowerBound, upperBound, last;
355
+ const cursors = /* @__PURE__ */ new Set(), identities = /* @__PURE__ */ new Set();
356
+ for (;;) {
357
+ options.signal?.throwIfAborted();
358
+ const page = await fetch(cursor);
359
+ options.signal?.throwIfAborted();
360
+ const fail = (message) => {
361
+ throw new require_decimal.ThruputError("historyWalkFailed", message, { context: { page } });
362
+ };
363
+ const rows = kind === "events" ? page.events : page.transactions;
364
+ if (watermark === void 0) {
365
+ watermark = page.latestIndexedBlockHeight;
366
+ lowerBound = "start" in scope && order === "ascending" && scope.start.anchor.kind === "atHeight" ? scope.start.anchor.blockHeight : page.oldestIndexedBlockHeight;
367
+ upperBound = "start" in scope && order === "descending" && scope.start.anchor.kind === "atHeight" && scope.start.anchor.blockHeight < watermark ? scope.start.anchor.blockHeight : watermark;
368
+ }
369
+ if ("blockHeight" in scope) {
370
+ if (scope.blockHeight < page.oldestIndexedBlockHeight || scope.blockHeight > page.latestIndexedBlockHeight) fail("Requested block is outside current indexed coverage");
371
+ } else {
372
+ if (page.latestIndexedBlockHeight < watermark) fail("History coverage regressed below the initial watermark");
373
+ if (page.oldestIndexedBlockHeight > lowerBound) fail("History retention no longer covers the requested range");
374
+ }
375
+ for (const row of rows) {
376
+ if ("blockHeight" in scope ? row.blockHeight !== scope.blockHeight : row.blockHeight > upperBound || row.blockHeight < lowerBound) fail("History row is outside the fixed walk scope");
377
+ const hash = require_hex.toHex0x(row.transactionHash), sequence = kind === "events" ? row.sequenceNumber : 0;
378
+ const identity = kind === "events" ? `${hash}/${sequence}` : hash;
379
+ if (identities.has(identity)) fail("History returned a duplicate identity across pages");
380
+ const key = [
381
+ row.blockHeight,
382
+ hash,
383
+ sequence
384
+ ];
385
+ if (last && (order === "ascending" ? compare(last, key) >= 0 : compare(last, key) <= 0)) fail("History order did not advance across pages");
386
+ identities.add(identity);
387
+ last = key;
388
+ }
389
+ const next = page.nextCursor;
390
+ if (next !== null) {
391
+ if (cursors.has(next)) fail("History returned a repeated pagination cursor");
392
+ cursors.add(next);
393
+ }
394
+ yield page;
395
+ if (next === null) {
396
+ options.signal?.throwIfAborted();
397
+ if ("blockHeight" in scope) return;
398
+ return {
399
+ watermarkBlockHeight: watermark,
400
+ ...order === "ascending" && lowerBound <= watermark ? { completedThroughBlockHeight: watermark } : {}
401
+ };
402
+ }
403
+ cursor = next;
404
+ }
405
+ }
406
+ //#endregion
407
+ //#region src/actions/public/iterateEventPages.ts
408
+ /** Start a fixed event range. Saved opaque cursors remain available through getEvents. */
409
+ function iterateEventPages(client, query, options = {}) {
410
+ const snapshot = structuredClone(query);
411
+ if (!snapshot.start || snapshot.cursor !== void 0) throw new TypeError("Event walks require an explicit start");
412
+ return walkHistory((cursor) => client.getEvents(cursor === void 0 ? snapshot : {
413
+ filters: snapshot.filters,
414
+ limit: snapshot.limit,
415
+ cursor
416
+ }, options), "events", { start: snapshot.start }, options);
417
+ }
418
+ //#endregion
419
+ //#region src/actions/public/readViews.ts
420
+ /**
421
+ * Read generated method requests against one shared committed snapshot.
422
+ * Contract aborts and faults are outcomes. Transport, freshness, and decoding
423
+ * failures reject the group. Calls are never split or emulated with separate views.
424
+ *
425
+ * @example
426
+ * ```ts
427
+ * const result = await client.readViews({ calls: [
428
+ * ERC20.v0_1.totalSupply.viewRequest({ address: token }),
429
+ * ERC20.v0_1.getBalanceOf.viewRequest({ address: token, args: { addr: owner } }),
430
+ * ] });
431
+ * ```
432
+ */
433
+ async function readViews(client, request, options) {
434
+ options?.signal?.throwIfAborted();
435
+ const calls = request.calls.map((call) => {
436
+ if ("minStateBlockHeight" in call) throw new TypeError("Set minStateBlockHeight on readViews, not on a prepared call");
437
+ return {
438
+ request: call.request,
439
+ name: call.method.name,
440
+ decode: call.method.decodeViewOutcome
441
+ };
442
+ });
443
+ const response = await client.simulateInvocations({
444
+ invocations: calls.map((call) => call.request),
445
+ ...request.minStateBlockHeight === void 0 ? {} : { minStateBlockHeight: request.minStateBlockHeight }
446
+ }, options);
447
+ const results = calls.map((call, index) => {
448
+ try {
449
+ return call.decode({
450
+ ...response.results[index],
451
+ stateBlockHeight: response.stateBlockHeight
452
+ });
453
+ } catch (cause) {
454
+ throw require_contract.contractDecodeFailed(`Failed to decode readViews result ${index} (${call.name})`, { cause });
455
+ }
456
+ });
457
+ return {
458
+ stateBlockHeight: response.stateBlockHeight,
459
+ results
460
+ };
461
+ }
462
+ //#endregion
463
+ //#region src/actions/public/iterateTransactionPages.ts
464
+ /** Transactions sent by this root address; incoming transfers use token events. */
465
+ function iterateTransactionsByRootAddress(client, query, options = {}) {
466
+ const snapshot = structuredClone(query);
467
+ if (!snapshot.start || snapshot.cursor !== void 0) throw new TypeError("Root-address walks require an explicit start");
468
+ return walkHistory((cursor) => client.getTransactionsByRootAddress(cursor === void 0 ? snapshot : {
469
+ address: snapshot.address,
470
+ limit: snapshot.limit,
471
+ cursor
472
+ }, options), "transactions", { start: snapshot.start }, options);
473
+ }
474
+ /** Walk one covered block. Completion never establishes a whole-chain checkpoint. */
475
+ function iterateTransactionsByBlock(client, query, options = {}) {
476
+ const snapshot = structuredClone(query);
477
+ if (!snapshot.start || snapshot.cursor !== void 0) throw new TypeError("Block walks require an explicit start");
478
+ return walkHistory((cursor) => client.getTransactionsByBlock(cursor === void 0 ? snapshot : {
479
+ blockHeight: snapshot.blockHeight,
480
+ limit: snapshot.limit,
481
+ cursor
482
+ }, options), "transactions", {
483
+ blockHeight: snapshot.blockHeight,
484
+ order: snapshot.start.order
485
+ }, options);
486
+ }
487
+ //#endregion
488
+ //#region src/actions/public/getContractSpec.ts
489
+ /**
490
+ * Resolve a current deployment and verify its embedded spec against its hash.
491
+ * Missing artifacts and invalid responses throw; neither means no deployment.
492
+ * The snapshot does not establish which implementation produced historical events.
493
+ */
494
+ async function getContractSpec(client, request, options) {
495
+ client.requireMethods(["getContractDeployment", "getContractArtifact"]);
496
+ const address = new Uint8Array(request.address);
497
+ const result = await client.getContractDeployment({ address }, options);
498
+ if (!require_contract.bytesEqual(address, result.address)) throw require_contract.contractVerificationFailed("Contract deployment address mismatch");
499
+ if (result.deployment === null) return {
500
+ ...result,
501
+ artifactSpec: null
502
+ };
503
+ return {
504
+ ...result,
505
+ artifactSpec: await readDeploymentSpec(client, result.deployment, options)
506
+ };
507
+ }
508
+ /** Shared identity validation for explicit deployments and effective contract selection. */
509
+ async function readDeploymentSpec(client, deployment, options) {
510
+ const artifact = await client.getContractArtifact({ hash: deployment.hash }, options);
511
+ if (!require_contract.bytesEqual(artifact.hash, deployment.hash)) throw require_contract.contractVerificationFailed("Contract artifact response hash mismatch");
512
+ const artifactSpec = require_contract.readContractArtifactSpec(artifact.contractXdr, (0, _thruputchain_protocol.sha256Hash)(deployment.hash));
513
+ const contract = (0, _thruputchain_protocol.deserialize)(artifact.contractXdr, _thruputchain_protocol.codec.Contract);
514
+ const size = contract.contract_type === _thruputchain_protocol.ContractType.kRv32 ? contract.rv32_contract.data.length : 0;
515
+ if (contract.contract_type !== deployment.contractType || size !== deployment.size) throw require_contract.contractVerificationFailed("Contract artifact does not match deployment metadata");
516
+ return artifactSpec;
517
+ }
518
+ //#endregion
519
+ //#region src/actions/public/getEffectiveContractSpec.ts
520
+ const nativeWalletHash = require_contract.hashContract({
521
+ contract_type: _thruputchain_protocol.ContractType.kNative,
522
+ native_contract_id: _thruputchain_protocol.HogexecPrecompiledNativeContracts.kNativeContractDefaultWallet
523
+ });
524
+ /**
525
+ * Discover current contract selection without inferring authorization or historical identity.
526
+ * Root context allows the chain-configured fallback; nested excludes that fallback.
527
+ * Transaction-local deployments are outside this committed-state reading.
528
+ */
529
+ async function getEffectiveContractSpec(client, request, options) {
530
+ client.requireMethods(["getEffectiveContract", "getContractArtifact"]);
531
+ const address = new Uint8Array(request.address);
532
+ const context = request.context;
533
+ const result = await client.getEffectiveContract({
534
+ address,
535
+ context
536
+ }, options);
537
+ if (!require_contract.bytesEqual(address, result.address) || result.context !== context) throw require_contract.contractVerificationFailed("Effective contract request identity mismatch");
538
+ if (result.selection instanceof require_decimal.UnsupportedRpcValue) throw new require_decimal.ThruputError("rpcValueUnsupported", "Unsupported effective contract selection", { context: { value: result.selection } });
539
+ if (result.selection === null) return {
540
+ ...result,
541
+ artifactSpec: null,
542
+ nativeInterface: null
543
+ };
544
+ if (context === "nested" && result.selection.source === "networkDefault") throw require_contract.contractVerificationFailed("Network default cannot apply to a nested invocation");
545
+ const contract = result.selection.contract;
546
+ const artifactSpec = await readDeploymentSpec(client, contract, options);
547
+ const nativeInterface = artifactSpec.kind === "native" && require_contract.bytesEqual(contract.hash, nativeWalletHash) ? {
548
+ name: "DefaultWallet",
549
+ spec: require_dev_wallet.spec$1
550
+ } : null;
551
+ return {
552
+ ...result,
553
+ artifactSpec,
554
+ nativeInterface
555
+ };
556
+ }
557
+ //#endregion
558
+ //#region src/actions/public/decodeWalletRequests.ts
559
+ /**
560
+ * Describe the grants and calls in a known DefaultWallet root before execution.
561
+ * The caller must establish wallet identity. An unknown selector returns null;
562
+ * malformed wrapper calldata throws. An unreadable mint retains its bytes and
563
+ * position. Token references describe requests; they do not establish that a
564
+ * token exists or will be returned.
565
+ */
566
+ function describeDefaultWalletRequests(root) {
567
+ const requests = readWalletRequests(root);
568
+ if (!requests) return null;
569
+ return {
570
+ ...requests,
571
+ mints: requests.mints.map(decodeMint)
572
+ };
573
+ }
574
+ function decodeMint(bytes) {
575
+ try {
576
+ return {
577
+ kind: "decoded",
578
+ node: (0, _thruputchain_protocol.deserialize)(bytes, _thruputchain_protocol.codec.AuthTokenNode)
579
+ };
580
+ } catch {
581
+ return {
582
+ kind: "unreadable",
583
+ bytes
584
+ };
585
+ }
586
+ }
587
+ /**
588
+ * Interpret a known DefaultWallet root using built-in binding descriptors.
589
+ * Call only after identifying the root as DefaultWallet; matching selectors
590
+ * alone do not establish wallet identity. Malformed recognized inputs throw,
591
+ * as does an `execute` that mints or forwards auth tokens. To read grants,
592
+ * use {@link describeDefaultWalletRequests}.
593
+ */
594
+ function decodeDefaultWalletRequests(root) {
595
+ const requests = readWalletRequests(root);
596
+ if (!requests) return null;
597
+ if (requests.mints.length > 0 || requests.calls.some((call) => call.tokens.length > 0)) throw new Error("DefaultWallet.execute mints or forwards auth tokens, which requested calls cannot represent");
598
+ return {
599
+ wrapper: requests.wrapper,
600
+ requestedCalls: requests.calls.map((call) => call.invocation)
601
+ };
602
+ }
603
+ function readWalletRequests(root) {
604
+ if (require_contract.bytesEqual(root.entrypoint, require_dev_wallet.DefaultWallet.v0_1.execute.entrypoint)) {
605
+ const { mints, calls } = require_dev_wallet.DefaultWallet.v0_1.execute.decodeArgs(root.calldata);
606
+ return {
607
+ wrapper: "DefaultWallet.execute",
608
+ mints,
609
+ calls: calls.map((call) => ({
610
+ invocation: {
611
+ invoked_address: call.target,
612
+ entrypoint: (0, _thruputchain_protocol.contractEntrypointID)(call.entrypoint),
613
+ gas_limit: (0, _thruputchain_protocol.gasAmount)(call.gas_limit),
614
+ calldata: (0, _thruputchain_protocol.calldata)(call.calldata)
615
+ },
616
+ tokens: call.tokens
617
+ }))
618
+ };
619
+ }
620
+ if (require_contract.bytesEqual(root.entrypoint, require_dev_wallet.DefaultWallet.v0_1.deploy.entrypoint)) {
621
+ const args = require_dev_wallet.DefaultWallet.v0_1.deploy.decodeArgs(root.calldata);
622
+ const init = args.initializer;
623
+ return {
624
+ wrapper: "DefaultWallet.deploy",
625
+ mints: [],
626
+ calls: init ? [{
627
+ invocation: {
628
+ invoked_address: require_contract.deriveContractAddress(root.invoked_address, (0, _thruputchain_protocol.sha256Hash)(args.nonce), (0, _thruputchain_protocol.sha256Hash)(args.contractHash)),
629
+ entrypoint: (0, _thruputchain_protocol.contractEntrypointID)(init.entrypoint),
630
+ gas_limit: (0, _thruputchain_protocol.gasAmount)(init.gas_limit),
631
+ calldata: (0, _thruputchain_protocol.calldata)(init.calldata)
632
+ },
633
+ tokens: []
634
+ }] : []
635
+ };
636
+ }
637
+ return null;
638
+ }
639
+ //#endregion
640
+ //#region src/actions/public/readTransactionInput.ts
641
+ /**
642
+ * Read and authenticate a retained Transaction, including its root invocation.
643
+ * Unavailable does not prove nonexecution. A matching body hash authenticates
644
+ * neither signatures nor the reported block height, and does not imply success.
645
+ */
646
+ async function readTransactionInput(client, request, options) {
647
+ client.requireMethods(["getTransactionInput"]);
648
+ const hash = new Uint8Array(request.transactionHash);
649
+ const result = await client.getTransactionInput({ transactionHash: hash }, options);
650
+ if (result instanceof require_decimal.UnsupportedRpcValue || result.status === "unavailable") return result;
651
+ try {
652
+ if (result.transactionXdr.length > 4 * 1024 * 1024) throw new Error("Transaction input exceeds 4 MiB");
653
+ if (!require_contract.bytesEqual(result.transactionHash, hash) || !require_contract.bytesEqual((0, _noble_hashes_sha2_js.sha256)(result.transactionXdr), hash)) throw new Error("Retained transaction input hash mismatch");
654
+ const transaction = (0, _thruputchain_protocol.deserialize)(result.transactionXdr, _thruputchain_protocol.codec.Transaction);
655
+ if (!require_contract.bytesEqual((0, _thruputchain_protocol.serialize)(transaction, _thruputchain_protocol.codec.Transaction), result.transactionXdr)) throw new Error("Noncanonical Transaction XDR");
656
+ return {
657
+ ...result,
658
+ transaction
659
+ };
660
+ } catch (cause) {
661
+ throw require_contract.contractVerificationFailed(require_contract.errorText(cause) ?? "Invalid transaction input", { cause });
662
+ }
663
+ }
664
+ //#endregion
665
+ //#region src/actions/wallet/sendTransaction.ts
666
+ /**
667
+ * Serialize and submit once through the native RPC boundary.
668
+ * Every failure has `transaction` facts with the signed bytes and destination
669
+ * discovery network; that network does not prove the signing network of an
670
+ * already-signed envelope. Unknown admission throws code
671
+ * `transactionAdmissionUnsupported`. RPC and transport failures keep their
672
+ * code, with outcome `unknown`, or `notSubmitted` for a local request error.
673
+ */
674
+ async function sendTransaction(client, signedTx, options) {
675
+ const evidence = require_sendInvocation.createSubmissionEvidence((0, _thruputchain_protocol.serialize)(signedTx, _thruputchain_protocol.codec.SignedTransaction), client.discovery.network.networkHash);
676
+ if (options?.signal?.aborted) throw require_sendInvocation.transactionNotSubmitted(evidence, "cancelled", options.signal.reason);
677
+ let result;
678
+ try {
679
+ result = await client.sendTransaction({ signedTransaction: evidence.signedTransaction }, options);
680
+ } catch (cause) {
681
+ const signal = options?.signal;
682
+ if (require_sendInvocation.isCancellation(cause, signal)) throw require_sendInvocation.transactionOutcomeUnknown(evidence, "cancelled", cause);
683
+ const local = require_sendInvocation.isLocalRequestError(cause, signal);
684
+ const reason = local ? "requestInvalid" : require_sendInvocation.reasonAfterDispatch(cause, signal);
685
+ if (!require_decimal.isThruputError(cause)) throw require_sendInvocation.transactionOutcomeUnknown(evidence, reason, cause);
686
+ throw require_contract.withTransactionFacts(cause, {
687
+ hash: evidence.transactionHash,
688
+ outcome: local ? "notSubmitted" : "unknown",
689
+ reason,
690
+ submission: evidence
691
+ });
692
+ }
693
+ require_sendInvocation.assertTransactionAdmission(result, evidence);
694
+ return (0, _thruputchain_protocol.sha256Hash)(result.transactionHash);
695
+ }
696
+ //#endregion
697
+ Object.defineProperty(exports, "decodeDefaultWalletRequests", {
698
+ enumerable: true,
699
+ get: function() {
700
+ return decodeDefaultWalletRequests;
701
+ }
702
+ });
703
+ Object.defineProperty(exports, "describeDefaultWalletRequests", {
704
+ enumerable: true,
705
+ get: function() {
706
+ return describeDefaultWalletRequests;
707
+ }
708
+ });
709
+ Object.defineProperty(exports, "getContractEvents", {
710
+ enumerable: true,
711
+ get: function() {
712
+ return getContractEvents;
713
+ }
714
+ });
715
+ Object.defineProperty(exports, "getContractSpec", {
716
+ enumerable: true,
717
+ get: function() {
718
+ return getContractSpec;
719
+ }
720
+ });
721
+ Object.defineProperty(exports, "getEffectiveContractSpec", {
722
+ enumerable: true,
723
+ get: function() {
724
+ return getEffectiveContractSpec;
725
+ }
726
+ });
727
+ Object.defineProperty(exports, "iterateEventPages", {
728
+ enumerable: true,
729
+ get: function() {
730
+ return iterateEventPages;
731
+ }
732
+ });
733
+ Object.defineProperty(exports, "iterateTransactionsByBlock", {
734
+ enumerable: true,
735
+ get: function() {
736
+ return iterateTransactionsByBlock;
737
+ }
738
+ });
739
+ Object.defineProperty(exports, "iterateTransactionsByRootAddress", {
740
+ enumerable: true,
741
+ get: function() {
742
+ return iterateTransactionsByRootAddress;
743
+ }
744
+ });
745
+ Object.defineProperty(exports, "readTransactionInput", {
746
+ enumerable: true,
747
+ get: function() {
748
+ return readTransactionInput;
749
+ }
750
+ });
751
+ Object.defineProperty(exports, "readViews", {
752
+ enumerable: true,
753
+ get: function() {
754
+ return readViews;
755
+ }
756
+ });
757
+ Object.defineProperty(exports, "requestAirdrop", {
758
+ enumerable: true,
759
+ get: function() {
760
+ return requestAirdrop;
761
+ }
762
+ });
763
+ Object.defineProperty(exports, "requestAirdropAttempt", {
764
+ enumerable: true,
765
+ get: function() {
766
+ return requestAirdropAttempt;
767
+ }
768
+ });
769
+ Object.defineProperty(exports, "sendTransaction", {
770
+ enumerable: true,
771
+ get: function() {
772
+ return sendTransaction;
773
+ }
774
+ });
775
+ Object.defineProperty(exports, "waitForCommitment", {
776
+ enumerable: true,
777
+ get: function() {
778
+ return waitForCommitment;
779
+ }
780
+ });
781
+ Object.defineProperty(exports, "waitForTransactionReceipt", {
782
+ enumerable: true,
783
+ get: function() {
784
+ return waitForTransactionReceipt;
785
+ }
786
+ });
787
+
788
+ //# sourceMappingURL=actions-CIaI049y.cjs.map