@thruputchain/client 0.28.0 → 0.29.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 (181) hide show
  1. package/README.md +112 -17
  2. package/dist/{actions-B5-CjpEF.cjs → actions-B2gV8Vzr.cjs} +297 -73
  3. package/dist/actions-B2gV8Vzr.cjs.map +1 -0
  4. package/dist/actions-UEYKD22C.js +653 -0
  5. package/dist/actions-UEYKD22C.js.map +1 -0
  6. package/dist/actions.cjs +4 -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/{artifact-BM_MVzhL.d.ts → artifact-RIAPVmVX.d.cts} +4 -3
  11. package/dist/artifact-RIAPVmVX.d.cts.map +1 -0
  12. package/dist/{artifact-BM_MVzhL.d.cts → artifact-RIAPVmVX.d.ts} +4 -3
  13. package/dist/artifact-RIAPVmVX.d.ts.map +1 -0
  14. package/dist/{contract-D77iA2iY.js → contract-BOlNskwd.js} +235 -87
  15. package/dist/contract-BOlNskwd.js.map +1 -0
  16. package/dist/{contract-DSu2UPPm.cjs → contract-D_vxUudr.cjs} +281 -109
  17. package/dist/contract-D_vxUudr.cjs.map +1 -0
  18. package/dist/contract.cjs +1 -5
  19. package/dist/contract.d.cts +4 -4
  20. package/dist/contract.d.ts +4 -4
  21. package/dist/contract.js +2 -2
  22. package/dist/contracts.cjs +5 -5
  23. package/dist/contracts.d.cts +19 -4
  24. package/dist/contracts.d.cts.map +1 -1
  25. package/dist/contracts.d.ts +19 -4
  26. package/dist/contracts.d.ts.map +1 -1
  27. package/dist/contracts.js +4 -4
  28. package/dist/decimal-BX7abv5J.cjs +171 -0
  29. package/dist/decimal-BX7abv5J.cjs.map +1 -0
  30. package/dist/decimal-CoHOISys.js +124 -0
  31. package/dist/decimal-CoHOISys.js.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-Bb01ytjJ.d.ts → index-BZ5j5P5d.d.ts} +11 -9
  49. package/dist/index-BZ5j5P5d.d.ts.map +1 -0
  50. package/dist/{index-CedOvhGY.d.cts → index-BfYEEVHm.d.cts} +3 -13
  51. package/dist/index-BfYEEVHm.d.cts.map +1 -0
  52. package/dist/{index-CtjWsAXV.d.cts → index-BhOeIyrZ.d.cts} +11 -9
  53. package/dist/index-BhOeIyrZ.d.cts.map +1 -0
  54. package/dist/{index-B5KqSHeL.d.cts → index-BsvYcU_Y.d.cts} +2 -2
  55. package/dist/{index-B5KqSHeL.d.cts.map → index-BsvYcU_Y.d.cts.map} +1 -1
  56. package/dist/{index-DeS1S0m-.d.ts → index-Btl_jMCT.d.ts} +3 -13
  57. package/dist/index-Btl_jMCT.d.ts.map +1 -0
  58. package/dist/{index-CtjZ61tl.d.cts → index-CG-q0j9w.d.ts} +12 -62
  59. package/dist/index-CG-q0j9w.d.ts.map +1 -0
  60. package/dist/index-CPtBvHE8.d.ts +145 -0
  61. package/dist/index-CPtBvHE8.d.ts.map +1 -0
  62. package/dist/{index-DfmDUk5Y.d.ts → index-DBKsOzCN.d.cts} +24 -21
  63. package/dist/index-DBKsOzCN.d.cts.map +1 -0
  64. package/dist/index-Xre-0Jka.d.cts +145 -0
  65. package/dist/index-Xre-0Jka.d.cts.map +1 -0
  66. package/dist/index.cjs +39 -68
  67. package/dist/index.cjs.map +1 -1
  68. package/dist/index.d.cts +12 -17
  69. package/dist/index.d.cts.map +1 -1
  70. package/dist/index.d.ts +12 -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-D2usgASc.d.cts → signed_op-BvbOHWKK.d.ts} +3 -3
  103. package/dist/{signed_op-zGq4eBo8.d.ts.map → signed_op-BvbOHWKK.d.ts.map} +1 -1
  104. package/dist/{signed_op-zGq4eBo8.d.ts → signed_op-DoHFpSH4.d.cts} +3 -3
  105. package/dist/{signed_op-D2usgASc.d.cts.map → signed_op-DoHFpSH4.d.cts.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 +2 -2
  133. package/dist/actions-B5-CjpEF.cjs.map +0 -1
  134. package/dist/actions-C1SMLWO5.js +0 -430
  135. package/dist/actions-C1SMLWO5.js.map +0 -1
  136. package/dist/artifact-BM_MVzhL.d.cts.map +0 -1
  137. package/dist/artifact-BM_MVzhL.d.ts.map +0 -1
  138. package/dist/client-jOZxB8yW.d.cts +0 -798
  139. package/dist/client-jOZxB8yW.d.cts.map +0 -1
  140. package/dist/client-jOZxB8yW.d.ts +0 -798
  141. package/dist/client-jOZxB8yW.d.ts.map +0 -1
  142. package/dist/codec-BcK8ASsg.cjs.map +0 -1
  143. package/dist/codec-Bxlt1gKO.js.map +0 -1
  144. package/dist/contract-D77iA2iY.js.map +0 -1
  145. package/dist/contract-DSu2UPPm.cjs.map +0 -1
  146. package/dist/dev_wallet-CAbOSrak.cjs.map +0 -1
  147. package/dist/dev_wallet-CU3RpQLm.js.map +0 -1
  148. package/dist/execution-J5jkXhV1.d.cts.map +0 -1
  149. package/dist/execution-XJ0iwFaX.d.ts.map +0 -1
  150. package/dist/index-Bb01ytjJ.d.ts.map +0 -1
  151. package/dist/index-C3HVRvQd.d.ts.map +0 -1
  152. package/dist/index-CIHK7Ew9.d.cts +0 -303
  153. package/dist/index-CIHK7Ew9.d.cts.map +0 -1
  154. package/dist/index-CIHK7Ew9.d.ts +0 -303
  155. package/dist/index-CIHK7Ew9.d.ts.map +0 -1
  156. package/dist/index-CedOvhGY.d.cts.map +0 -1
  157. package/dist/index-CtjWsAXV.d.cts.map +0 -1
  158. package/dist/index-CtjZ61tl.d.cts.map +0 -1
  159. package/dist/index-DeS1S0m-.d.ts.map +0 -1
  160. package/dist/index-DfmDUk5Y.d.ts.map +0 -1
  161. package/dist/index-soFVQX9j.d.cts.map +0 -1
  162. package/dist/readError-CCVlmBhj.cjs +0 -624
  163. package/dist/readError-CCVlmBhj.cjs.map +0 -1
  164. package/dist/readError-D1dppovI.js +0 -571
  165. package/dist/readError-D1dppovI.js.map +0 -1
  166. package/dist/readViews-DbWELMMq.d.cts +0 -609
  167. package/dist/readViews-DbWELMMq.d.cts.map +0 -1
  168. package/dist/readViews-nV3jbpYc.d.ts +0 -609
  169. package/dist/readViews-nV3jbpYc.d.ts.map +0 -1
  170. package/dist/sendInvocation-Dsr9ij5P.cjs +0 -661
  171. package/dist/sendInvocation-Dsr9ij5P.cjs.map +0 -1
  172. package/dist/sendInvocation-tBmf8haQ.js +0 -505
  173. package/dist/sendInvocation-tBmf8haQ.js.map +0 -1
  174. package/dist/transport-5FPeNwuv.cjs +0 -279
  175. package/dist/transport-5FPeNwuv.cjs.map +0 -1
  176. package/dist/transport-IrhVlS4w.js +0 -261
  177. package/dist/transport-IrhVlS4w.js.map +0 -1
  178. package/dist/validation-4w-vDGAi.cjs.map +0 -1
  179. package/dist/validation-eXATmgO0.js.map +0 -1
  180. package/dist/wallet-7R5M_7h4.cjs.map +0 -1
  181. package/dist/wallet-BNKgOXrF.js.map +0 -1
@@ -0,0 +1,528 @@
1
+ const require_decimal = require("./decimal-BX7abv5J.cjs");
2
+ const require_hex = require("./hex-CSDZ9d6z.cjs");
3
+ const require_transactionHash = require("./transactionHash-D5yf4KoL.cjs");
4
+ require("./readError-COcEDNoZ.cjs");
5
+ let _thruputchain_protocol = require("@thruputchain/protocol");
6
+ let _thruputchain_protocol_utils = require("@thruputchain/protocol/utils");
7
+ //#region src/transport/errors.ts
8
+ /** A JSON-RPC error object. Keep the raw object, including additive fields. */
9
+ function rpcError(code, rpcMessage, data, method, raw) {
10
+ return new require_decimal.ThruputError("rpcError", `${method ? `${method}: ` : ""}${rpcMessage} (RPC ${code})`, { context: {
11
+ code,
12
+ rpcMessage,
13
+ ...data === void 0 ? {} : { data },
14
+ ...method === void 0 ? {} : { method },
15
+ raw: raw ?? {
16
+ code,
17
+ message: rpcMessage,
18
+ ...data === void 0 ? {} : { data }
19
+ }
20
+ } });
21
+ }
22
+ /** An HTTP status that is not successful. */
23
+ function httpResponseError(status, statusText, endpoint, method) {
24
+ return new require_decimal.ThruputError("httpResponseError", `HTTP ${status}: ${statusText}${method ? ` (${method} at ${endpoint})` : ""}`, { context: {
25
+ status,
26
+ statusText,
27
+ ...endpoint === void 0 ? {} : { endpoint },
28
+ ...method === void 0 ? {} : { method }
29
+ } });
30
+ }
31
+ /** A network failure, with the endpoint origin only. */
32
+ function httpRequestFailed(endpoint, method, cause) {
33
+ return new require_decimal.ThruputError("httpRequestFailed", `${method}: request to ${endpoint} failed`, {
34
+ context: {
35
+ endpoint,
36
+ method
37
+ },
38
+ cause
39
+ });
40
+ }
41
+ /** A malformed JSON-RPC reply after dispatch. The write outcome is unknown. */
42
+ function rpcResponseInvalid(message, raw, cause) {
43
+ return new require_decimal.ThruputError("rpcResponseInvalid", message, {
44
+ context: { raw },
45
+ ...cause === void 0 ? {} : { cause }
46
+ });
47
+ }
48
+ //#endregion
49
+ //#region src/transport/httpBatch.ts
50
+ var HttpBatch = class {
51
+ maxSize;
52
+ waitMs;
53
+ send;
54
+ #queue = /* @__PURE__ */ new Set();
55
+ #timer;
56
+ constructor(maxSize, waitMs, send) {
57
+ this.maxSize = maxSize;
58
+ this.waitMs = waitMs;
59
+ this.send = send;
60
+ }
61
+ request(id, body, signal) {
62
+ return new Promise((resolve, reject) => {
63
+ let settled = false;
64
+ const finish = (callback, value) => {
65
+ if (settled) return;
66
+ settled = true;
67
+ signal?.removeEventListener("abort", cancel);
68
+ callback(value);
69
+ };
70
+ const entry = {
71
+ id,
72
+ body,
73
+ resolve: (value) => finish(resolve, value),
74
+ reject: (reason) => finish(reject, reason)
75
+ };
76
+ const cancel = () => {
77
+ this.#queue.delete(entry);
78
+ if (this.#queue.size === 0) this.#clearTimer();
79
+ entry.reject(signal?.reason);
80
+ entry.onCancel?.();
81
+ };
82
+ if (signal?.aborted) {
83
+ entry.reject(signal.reason);
84
+ return;
85
+ }
86
+ signal?.addEventListener("abort", cancel, { once: true });
87
+ this.#queue.add(entry);
88
+ if (this.#queue.size >= this.maxSize) this.#flush();
89
+ else if (this.#timer === void 0) this.#timer = setTimeout(() => void this.#flush(), this.waitMs);
90
+ });
91
+ }
92
+ #clearTimer() {
93
+ if (this.#timer !== void 0) clearTimeout(this.#timer);
94
+ this.#timer = void 0;
95
+ }
96
+ async #flush() {
97
+ this.#clearTimer();
98
+ const entries = [...this.#queue];
99
+ this.#queue.clear();
100
+ if (entries.length === 0) return;
101
+ const controller = new AbortController();
102
+ const active = new Set(entries);
103
+ for (const entry of entries) entry.onCancel = () => {
104
+ active.delete(entry);
105
+ if (active.size === 0) controller.abort();
106
+ };
107
+ try {
108
+ const responses = batchResponses(await this.send(`[${entries.map((entry) => entry.body).join(",")}]`, controller.signal), entries);
109
+ for (const entry of entries) entry.resolve(responses.get(entry.id));
110
+ } catch (error) {
111
+ for (const entry of entries) entry.reject(error);
112
+ } finally {
113
+ for (const entry of entries) entry.onCancel = void 0;
114
+ }
115
+ }
116
+ };
117
+ function batchResponses(json, entries) {
118
+ if (json !== null && typeof json === "object" && !Array.isArray(json) && "jsonrpc" in json && json.jsonrpc === "2.0" && "id" in json && json.id === null && "error" in json && !Object.hasOwn(json, "result")) return new Map(entries.map((entry) => [entry.id, json]));
119
+ if (!Array.isArray(json) || json.length !== entries.length) throw rpcResponseInvalid("Invalid JSON-RPC batch response: expected one response per request", json);
120
+ const expected = new Set(entries.map((entry) => entry.id));
121
+ const responses = /* @__PURE__ */ new Map();
122
+ for (const value of json) {
123
+ const response = value;
124
+ if (!response || typeof response !== "object" || Array.isArray(response) || response.jsonrpc !== "2.0" || typeof response.id !== "number" || !expected.has(response.id) || responses.has(response.id) || Object.hasOwn(response, "result") === Object.hasOwn(response, "error")) throw rpcResponseInvalid("Invalid JSON-RPC batch response: invalid envelope or request ID", json);
125
+ responses.set(response.id, response);
126
+ }
127
+ return responses;
128
+ }
129
+ //#endregion
130
+ //#region src/transport/http.ts
131
+ /**
132
+ * JSON-RPC 2.0 transport over HTTP POST.
133
+ *
134
+ * `HttpTransport` handles request IDs, JSON-RPC envelopes, optional custom
135
+ * headers, optional timeout cancellation, and conversion of JSON-RPC error
136
+ * responses into `ThruputError` with code `rpcError`. Network failures use
137
+ * `httpRequestFailed`, failed HTTP statuses use `httpResponseError`, and
138
+ * malformed replies use `rpcResponseInvalid`.
139
+ *
140
+ * @example
141
+ * ```ts
142
+ * import { HttpTransport } from "@thruputchain/client/transport";
143
+ *
144
+ * const transport = new HttpTransport("http://127.0.0.1:9545", {
145
+ * timeoutMs: 10_000,
146
+ * });
147
+ *
148
+ * const tip = await transport.request("getChainTip");
149
+ * ```
150
+ */
151
+ var HttpTransport = class {
152
+ #url;
153
+ #headers;
154
+ #fetch;
155
+ #timeoutMs;
156
+ #nextId = 1;
157
+ #batch;
158
+ /** Create an HTTP transport for a Thruput JSON-RPC endpoint URL. */
159
+ constructor(url, options = {}) {
160
+ this.#url = url;
161
+ this.#headers = options.headers;
162
+ this.#fetch = options.fetch ?? globalThis.fetch.bind(globalThis);
163
+ this.#timeoutMs = options.timeoutMs;
164
+ if (options.batch) {
165
+ const batch = options.batch === true ? {} : options.batch;
166
+ const maxSize = batch.maxSize ?? 100;
167
+ const waitMs = batch.waitMs ?? 0;
168
+ if (!Number.isInteger(maxSize) || maxSize < 1 || maxSize > 1e3) throw new RangeError("batch.maxSize must be an integer from 1 to 1000");
169
+ if (!Number.isInteger(waitMs) || waitMs < 0 || waitMs > 2147483647) throw new RangeError("batch.waitMs must be an integer from 0 to 2147483647");
170
+ this.#batch = new HttpBatch(maxSize, waitMs, (body, signal) => this.#post(body, "batch", { signal }));
171
+ }
172
+ }
173
+ /** Send one JSON-RPC request and return the decoded `result` value. */
174
+ async request(method, params, options = {}) {
175
+ options.signal?.throwIfAborted();
176
+ const id = this.#nextId++;
177
+ const body = JSON.stringify({
178
+ jsonrpc: "2.0",
179
+ id,
180
+ method,
181
+ params: params ?? []
182
+ });
183
+ let json;
184
+ if (this.#batch) try {
185
+ json = await this.#batch.request(id, body, options.signal);
186
+ } catch (error) {
187
+ if (options.signal?.aborted) throw options.signal.reason;
188
+ if (require_decimal.isThruputError(error, "httpRequestFailed")) throw httpRequestFailed(error.context.endpoint, method, error.cause);
189
+ if (require_decimal.isThruputError(error, "httpResponseError")) throw httpResponseError(error.context.status, error.context.statusText, error.context.endpoint, method);
190
+ throw error;
191
+ }
192
+ else json = await this.#post(body, method, options);
193
+ return decodeResponse(json, method, this.#batch ? void 0 : id);
194
+ }
195
+ async #post(body, method, options) {
196
+ const abort = this.#timeoutMs ? new AbortController() : void 0;
197
+ const signal = abort && options.signal ? AbortSignal.any([abort.signal, options.signal]) : abort?.signal ?? options.signal;
198
+ const timeout = abort ? setTimeout(() => abort.abort(new DOMException("Request timed out", "TimeoutError")), this.#timeoutMs) : void 0;
199
+ let json;
200
+ try {
201
+ let response;
202
+ try {
203
+ response = await this.#fetch(this.#url, {
204
+ method: "POST",
205
+ headers: {
206
+ "Content-Type": "application/json",
207
+ ...this.#headers
208
+ },
209
+ body,
210
+ signal
211
+ });
212
+ } catch (cause) {
213
+ if (typeof cause === "object" && cause !== null && "name" in cause && (cause.name === "AbortError" || cause.name === "TimeoutError")) throw cause;
214
+ throw httpRequestFailed(new URL(this.#url).origin, method, cause);
215
+ }
216
+ if (!response.ok) throw httpResponseError(response.status, response.statusText, new URL(this.#url).origin, method);
217
+ try {
218
+ json = await response.json();
219
+ } catch (cause) {
220
+ const name = typeof cause === "object" && cause !== null && "name" in cause ? cause.name : void 0;
221
+ if (name === "TypeError") throw httpRequestFailed(new URL(this.#url).origin, method, cause);
222
+ if (name === "SyntaxError") throw rpcResponseInvalid(`${method}: response body is not JSON`, void 0, cause);
223
+ throw cause;
224
+ }
225
+ } catch (cause) {
226
+ if (signal?.aborted) throw signal.reason;
227
+ throw cause;
228
+ } finally {
229
+ if (timeout !== void 0) clearTimeout(timeout);
230
+ }
231
+ return json;
232
+ }
233
+ };
234
+ function decodeResponse(json, method, expectedId) {
235
+ if (!json || typeof json !== "object" || Array.isArray(json)) throw rpcResponseInvalid("Invalid JSON-RPC response", json);
236
+ const envelope = json;
237
+ const frameworkError = envelope.id === null && typeof envelope.error === "object" && envelope.error !== null && "code" in envelope.error && [-32700, -32600].includes(envelope.error.code);
238
+ if (envelope.jsonrpc !== "2.0" || expectedId !== void 0 && envelope.id !== expectedId && !frameworkError || Object.hasOwn(envelope, "result") === Object.hasOwn(envelope, "error")) throw rpcResponseInvalid("Invalid JSON-RPC response envelope or request ID", json);
239
+ if (envelope.error !== void 0) {
240
+ const error = envelope.error;
241
+ if (!error || typeof error !== "object" || Array.isArray(error)) throw rpcResponseInvalid("Invalid JSON-RPC error response", json);
242
+ const body = error;
243
+ if (typeof body.code !== "number" || !Number.isSafeInteger(body.code) || typeof body.message !== "string") throw rpcResponseInvalid("Invalid JSON-RPC error response", json);
244
+ throw rpcError(body.code, body.message, body.data, method, body);
245
+ }
246
+ if (!Object.prototype.hasOwnProperty.call(envelope, "result")) throw rpcResponseInvalid("Invalid JSON-RPC response", json);
247
+ return envelope.result;
248
+ }
249
+ //#endregion
250
+ //#region src/transport/mock.ts
251
+ const methods = [
252
+ "getVersionInfo",
253
+ "getNetworkInfo",
254
+ "getChainTip",
255
+ "getChainConfig",
256
+ "getServerLimits",
257
+ "getBalance",
258
+ "getRegisteredAuth",
259
+ "getContractDeployment",
260
+ "getEffectiveContract",
261
+ "getContractArtifact",
262
+ "getBlockByHeight",
263
+ "dev_getPendingTransactionCount",
264
+ "simulateInvocation",
265
+ "simulateInvocations",
266
+ "sendTransaction",
267
+ "getTransactionReceipt",
268
+ "getTransactionInput",
269
+ "getTransactionStatus",
270
+ "getTransactionsByRootAddress",
271
+ "getTransactionsByBlock",
272
+ "getEvents",
273
+ "getStorage",
274
+ "faucet_requestAirdrop"
275
+ ];
276
+ /** Deterministic native RPC transport for examples; it does not execute contract code. */
277
+ var MockTransport = class {
278
+ #height = 0n;
279
+ #transactions = /* @__PURE__ */ new Map();
280
+ async request(method, params = {}, options) {
281
+ options?.signal?.throwIfAborted();
282
+ if (Array.isArray(params)) throw new TypeError("Native RPC params must be a named object");
283
+ const stateBlockHeight = this.#height.toString();
284
+ const bounds = {
285
+ oldestIndexedBlockHeight: "0",
286
+ latestIndexedBlockHeight: stateBlockHeight,
287
+ nextCursor: null
288
+ };
289
+ const simulation = {
290
+ output: {
291
+ result: "return",
292
+ returnData: "0x"
293
+ },
294
+ events: [],
295
+ gasUsed: "0"
296
+ };
297
+ let result;
298
+ switch (method) {
299
+ case "getTransactionInput":
300
+ result = { status: "unavailable" };
301
+ break;
302
+ case "getVersionInfo":
303
+ result = {
304
+ wireFormat: "14.4.0",
305
+ implementation: "mock",
306
+ supportedMethods: [...methods]
307
+ };
308
+ break;
309
+ case "getNetworkInfo":
310
+ result = { networkHash: "1".repeat(32) };
311
+ break;
312
+ case "getChainTip":
313
+ result = {
314
+ blockHeight: stateBlockHeight,
315
+ blockHash: this.#blockHash(this.#height)
316
+ };
317
+ break;
318
+ case "getChainConfig":
319
+ result = { stated: { maxNewContractsPerTx: 4 } };
320
+ break;
321
+ case "getServerLimits":
322
+ result = {
323
+ maxSimulationGas: "100000000",
324
+ maxSimulationCalldataBytes: "65536",
325
+ maxEventsPerPage: 200,
326
+ maxTransactionsPerPage: 200,
327
+ maxCursorBytes: "1024",
328
+ simulationBatch: {
329
+ maxInvocations: 16,
330
+ maxCalldataBytes: 65536,
331
+ maxGas: "1600000000",
332
+ maxBackendResponseBytes: 1e6,
333
+ timeoutMs: "3000"
334
+ }
335
+ };
336
+ break;
337
+ case "getBalance":
338
+ result = {
339
+ address: params.address,
340
+ rawBalance: "0",
341
+ stateBlockHeight
342
+ };
343
+ break;
344
+ case "getRegisteredAuth":
345
+ result = {
346
+ address: params.address,
347
+ configuration: null,
348
+ stateBlockHeight
349
+ };
350
+ break;
351
+ case "getStorage":
352
+ result = {
353
+ item: null,
354
+ stateBlockHeight
355
+ };
356
+ break;
357
+ case "getContractDeployment":
358
+ result = {
359
+ address: params.address,
360
+ stateBlockHeight,
361
+ deployment: null
362
+ };
363
+ break;
364
+ case "getEffectiveContract":
365
+ result = {
366
+ address: params.address,
367
+ context: params.context,
368
+ stateBlockHeight,
369
+ selection: null
370
+ };
371
+ break;
372
+ case "getContractArtifact": throw rpcError(-32014, "Contract artifact unavailable", {
373
+ kind: "contractArtifactUnavailable",
374
+ hash: params.hash
375
+ }, method);
376
+ case "dev_getPendingTransactionCount":
377
+ result = { count: "0" };
378
+ break;
379
+ case "simulateInvocation":
380
+ result = {
381
+ ...simulation,
382
+ stateBlockHeight
383
+ };
384
+ break;
385
+ case "simulateInvocations":
386
+ result = {
387
+ stateBlockHeight,
388
+ results: params.invocations.map(() => structuredClone(simulation))
389
+ };
390
+ break;
391
+ case "faucet_requestAirdrop":
392
+ result = {
393
+ attemptStatus: "succeeded",
394
+ recipient: params.recipient,
395
+ rawAmount: "100000000",
396
+ transactionHash: this.#blockHash(this.#height),
397
+ blockHeight: stateBlockHeight,
398
+ execution: {
399
+ result: "return",
400
+ returnData: "0x"
401
+ }
402
+ };
403
+ break;
404
+ case "sendTransaction": {
405
+ const hash = (0, _thruputchain_protocol_utils.toBase58)(require_transactionHash.hashSignedTransaction((0, _thruputchain_protocol.deserialize)(require_hex.fromHex0x(String(params.signedTransaction)), _thruputchain_protocol.codec.SignedTransaction)));
406
+ if (!this.#transactions.has(hash)) this.#transactions.set(hash, ++this.#height);
407
+ result = {
408
+ transactionHash: hash,
409
+ admission: "accepted"
410
+ };
411
+ break;
412
+ }
413
+ case "getTransactionReceipt": {
414
+ const height = this.#transactions.get(String(params.transactionHash));
415
+ result = height === void 0 ? null : {
416
+ transactionHash: params.transactionHash,
417
+ blockHeight: height.toString(),
418
+ execution: {
419
+ result: "return",
420
+ returnData: "0x"
421
+ },
422
+ events: [],
423
+ gasUsed: "0"
424
+ };
425
+ break;
426
+ }
427
+ case "getTransactionStatus": {
428
+ const height = this.#transactions.get(String(params.transactionHash));
429
+ result = height === void 0 ? { status: "unknown" } : {
430
+ status: "committed",
431
+ blockHeight: height.toString()
432
+ };
433
+ break;
434
+ }
435
+ case "getEvents":
436
+ result = {
437
+ ...bounds,
438
+ events: []
439
+ };
440
+ break;
441
+ case "getTransactionsByRootAddress":
442
+ case "getTransactionsByBlock":
443
+ result = {
444
+ ...bounds,
445
+ transactions: []
446
+ };
447
+ break;
448
+ case "getBlockByHeight": {
449
+ const height = BigInt(String(params.blockHeight));
450
+ result = height <= 0n || height > this.#height ? null : {
451
+ blockHash: this.#blockHash(height),
452
+ protocol: 0,
453
+ networkHash: "1".repeat(32),
454
+ proposer: "1".repeat(32),
455
+ blockTimepoint: "0",
456
+ blockHeight: height.toString(),
457
+ txsHash: this.#blockHash(height),
458
+ storageHash: this.#blockHash(height),
459
+ eventsHash: this.#blockHash(height),
460
+ configHash: this.#blockHash(height),
461
+ prevBlockHash: this.#blockHash(height - 1n),
462
+ proposalTxsHash: this.#blockHash(height),
463
+ upgrades: []
464
+ };
465
+ break;
466
+ }
467
+ default: throw new Error(`MockTransport: method not implemented: ${method}`);
468
+ }
469
+ return result;
470
+ }
471
+ #blockHash(height) {
472
+ const bytes = new Uint8Array(32);
473
+ new DataView(bytes.buffer).setBigUint64(24, height);
474
+ return (0, _thruputchain_protocol_utils.toBase58)(bytes);
475
+ }
476
+ };
477
+ //#endregion
478
+ //#region src/transport/txInvalidDetail.ts
479
+ /** Read known transaction-bound evidence without inferring retry permission. */
480
+ function txInvalidDetail(error) {
481
+ if (!require_decimal.isThruputError(error, "nativeRpcError") || error.context.kind !== "transactionInvalid") return null;
482
+ const detail = error.context.data.detail;
483
+ return !detail || require_decimal.isUnsupportedRpcValue(detail) ? null : detail;
484
+ }
485
+ //#endregion
486
+ //#region src/rpc/errors.ts
487
+ /** Native causes. Codes alone never grant write retry permission. */
488
+ const NativeRpcErrorCode = {
489
+ BackendDataInvalid: -32054,
490
+ BackendTimeout: -32051,
491
+ BackendUnavailable: -32050,
492
+ ContractArtifactUnavailable: -32014,
493
+ FundingAttemptStopped: -32030,
494
+ HistoryUnavailable: -32013,
495
+ InvalidParams: -32602,
496
+ LocalFundingUnresolved: -32031,
497
+ Overloaded: -32053,
498
+ StateHeightUnavailable: -32012,
499
+ TransactionInvalid: -32e3,
500
+ TransactionRejected: -32001
501
+ };
502
+ //#endregion
503
+ Object.defineProperty(exports, "HttpTransport", {
504
+ enumerable: true,
505
+ get: function() {
506
+ return HttpTransport;
507
+ }
508
+ });
509
+ Object.defineProperty(exports, "MockTransport", {
510
+ enumerable: true,
511
+ get: function() {
512
+ return MockTransport;
513
+ }
514
+ });
515
+ Object.defineProperty(exports, "NativeRpcErrorCode", {
516
+ enumerable: true,
517
+ get: function() {
518
+ return NativeRpcErrorCode;
519
+ }
520
+ });
521
+ Object.defineProperty(exports, "txInvalidDetail", {
522
+ enumerable: true,
523
+ get: function() {
524
+ return txInvalidDetail;
525
+ }
526
+ });
527
+
528
+ //# sourceMappingURL=transport-BhWZxHcz.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transport-BhWZxHcz.cjs","names":["ThruputError","#queue","#clearTimer","#flush","#timer","#url","#headers","#fetch","#timeoutMs","#batch","#post","#nextId","isThruputError","#height","#blockHash","hashSignedTransaction","fromHex0x","codec","#transactions","isThruputError","isUnsupportedRpcValue"],"sources":["../src/transport/errors.ts","../src/transport/httpBatch.ts","../src/transport/http.ts","../src/transport/mock.ts","../src/transport/txInvalidDetail.ts","../src/rpc/errors.ts"],"sourcesContent":["import { ThruputError } from \"../errors/thruputError.js\";\n\n/** A JSON-RPC error object. Keep the raw object, including additive fields. */\nexport function rpcError(\n code: number,\n rpcMessage: string,\n data?: unknown,\n method?: string,\n raw?: unknown,\n): ThruputError<\"rpcError\"> {\n return new ThruputError(\n \"rpcError\",\n `${method ? `${method}: ` : \"\"}${rpcMessage} (RPC ${code})`,\n {\n context: {\n code,\n rpcMessage,\n ...(data === undefined ? {} : { data }),\n ...(method === undefined ? {} : { method }),\n raw: raw ?? {\n code,\n message: rpcMessage,\n ...(data === undefined ? {} : { data }),\n },\n },\n },\n );\n}\n\n/** An HTTP status that is not successful. */\nexport function httpResponseError(\n status: number,\n statusText: string,\n endpoint?: string,\n method?: string,\n): ThruputError<\"httpResponseError\"> {\n return new ThruputError(\n \"httpResponseError\",\n `HTTP ${status}: ${statusText}${method ? ` (${method} at ${endpoint})` : \"\"}`,\n {\n context: {\n status,\n statusText,\n ...(endpoint === undefined ? {} : { endpoint }),\n ...(method === undefined ? {} : { method }),\n },\n },\n );\n}\n\n/** A network failure, with the endpoint origin only. */\nexport function httpRequestFailed(\n endpoint: string,\n method: string,\n cause: unknown,\n): ThruputError<\"httpRequestFailed\"> {\n return new ThruputError(\n \"httpRequestFailed\",\n `${method}: request to ${endpoint} failed`,\n { context: { endpoint, method }, cause },\n );\n}\n\n/** A malformed JSON-RPC reply after dispatch. The write outcome is unknown. */\nexport function rpcResponseInvalid(\n message: string,\n raw: unknown,\n cause?: unknown,\n): ThruputError<\"rpcResponseInvalid\"> {\n return new ThruputError(\"rpcResponseInvalid\", message, {\n context: { raw },\n ...(cause === undefined ? {} : { cause }),\n });\n}\n","import { rpcResponseInvalid } from \"./errors.js\";\n\n/** Scheduling and cancellation for one transport's JSON-RPC arrays. */\ninterface PendingRequest {\n id: number;\n body: string;\n resolve: (value: unknown) => void;\n reject: (reason: unknown) => void;\n onCancel?: () => void;\n}\n\nexport class HttpBatch {\n #queue = new Set<PendingRequest>();\n #timer?: ReturnType<typeof setTimeout>;\n\n constructor(\n private readonly maxSize: number,\n private readonly waitMs: number,\n private readonly send: (\n body: string,\n signal: AbortSignal,\n ) => Promise<unknown>,\n ) {}\n\n request(id: number, body: string, signal?: AbortSignal): Promise<unknown> {\n return new Promise((resolve, reject) => {\n let settled = false;\n const finish = (callback: (value: unknown) => void, value: unknown) => {\n if (settled) return;\n settled = true;\n signal?.removeEventListener(\"abort\", cancel);\n callback(value);\n };\n const entry: PendingRequest = {\n id,\n body,\n resolve: (value) => finish(resolve, value),\n reject: (reason) => finish(reject, reason),\n };\n const cancel = () => {\n this.#queue.delete(entry);\n if (this.#queue.size === 0) this.#clearTimer();\n entry.reject(signal?.reason);\n entry.onCancel?.();\n };\n if (signal?.aborted) {\n entry.reject(signal.reason);\n return;\n }\n signal?.addEventListener(\"abort\", cancel, { once: true });\n this.#queue.add(entry);\n if (this.#queue.size >= this.maxSize) {\n void this.#flush();\n } else if (this.#timer === undefined) {\n this.#timer = setTimeout(() => void this.#flush(), this.waitMs);\n }\n });\n }\n\n #clearTimer(): void {\n if (this.#timer !== undefined) clearTimeout(this.#timer);\n this.#timer = undefined;\n }\n\n async #flush(): Promise<void> {\n this.#clearTimer();\n const entries = [...this.#queue];\n this.#queue.clear();\n if (entries.length === 0) return;\n\n const controller = new AbortController();\n const active = new Set(entries);\n for (const entry of entries) {\n entry.onCancel = () => {\n active.delete(entry);\n if (active.size === 0) controller.abort();\n };\n }\n try {\n const json = await this.send(\n `[${entries.map((entry) => entry.body).join(\",\")}]`,\n controller.signal,\n );\n // Validate all IDs before delivering any result. Cancelled calls still\n // belong to the wire request and must be included in the response.\n const responses = batchResponses(json, entries);\n for (const entry of entries) entry.resolve(responses.get(entry.id));\n } catch (error) {\n for (const entry of entries) entry.reject(error);\n } finally {\n for (const entry of entries) entry.onCancel = undefined;\n }\n }\n}\n\nfunction batchResponses(\n json: unknown,\n entries: readonly PendingRequest[],\n): Map<number, unknown> {\n // Servers can reject an entire array (for example, an entry-count limit)\n // with one JSON-RPC error whose ID is null.\n if (\n json !== null &&\n typeof json === \"object\" &&\n !Array.isArray(json) &&\n \"jsonrpc\" in json &&\n json.jsonrpc === \"2.0\" &&\n \"id\" in json &&\n json.id === null &&\n \"error\" in json &&\n !Object.hasOwn(json, \"result\")\n )\n return new Map(entries.map((entry) => [entry.id, json]));\n\n if (!Array.isArray(json) || json.length !== entries.length)\n throw rpcResponseInvalid(\n \"Invalid JSON-RPC batch response: expected one response per request\",\n json,\n );\n const expected = new Set(entries.map((entry) => entry.id));\n const responses = new Map<number, unknown>();\n for (const value of json as unknown[]) {\n const response = value as Record<string, unknown> | null;\n if (\n !response ||\n typeof response !== \"object\" ||\n Array.isArray(response) ||\n response.jsonrpc !== \"2.0\" ||\n typeof response.id !== \"number\" ||\n !expected.has(response.id) ||\n responses.has(response.id) ||\n Object.hasOwn(response, \"result\") === Object.hasOwn(response, \"error\")\n )\n throw rpcResponseInvalid(\n \"Invalid JSON-RPC batch response: invalid envelope or request ID\",\n json,\n );\n responses.set(response.id, response);\n }\n return responses;\n}\n","import type { Transport, TransportRequestOptions, RpcParams } from \"./types.js\";\nimport { isThruputError } from \"../errors/thruputError.js\";\nimport {\n httpRequestFailed,\n httpResponseError,\n rpcError,\n rpcResponseInvalid,\n} from \"./errors.js\";\nimport { HttpBatch } from \"./httpBatch.js\";\n\n/** Limits for opt-in HTTP JSON-RPC batching. */\nexport interface HttpBatchOptions {\n /** Maximum calls per HTTP request (1–1,000). Defaults to 100. Full batches send immediately. */\n maxSize?: number;\n /** Scheduling window in milliseconds (0–2,147,483,647). Defaults to a zero-delay timer. */\n waitMs?: number;\n}\n\n/** Options for {@link HttpTransport}. */\nexport interface HttpTransportOptions {\n /** Additional HTTP headers to include with each JSON-RPC request. */\n headers?: Record<string, string>;\n\n /** Custom `fetch` implementation, useful for tests or non-standard runtimes. */\n fetch?: typeof fetch;\n\n /** Abort the request, including response-body reading, with a TimeoutError after this many milliseconds. */\n timeoutMs?: number;\n\n /**\n * Group concurrent calls into JSON-RPC arrays. Disabled by default.\n * `true` uses 100 calls and a zero-delay scheduling window.\n *\n * Requires an endpoint that accepts JSON-RPC arrays. Even one queued call\n * is sent as an array. Responses are matched by ID, not response order.\n * RPC errors reject their own calls; HTTP failures affect the whole batch.\n * No retries or fallback requests are made, including for submissions.\n *\n * Batching provides no shared snapshot, execution order, or atomicity.\n * Await dependent calls separately. Slow calls can delay other results.\n * Cancelling one call rejects it without cancelling its peers; cancelling\n * every call aborts the HTTP request. Cancellation cannot undo submitted work.\n * `timeoutMs` starts at dispatch and covers reading the response body;\n * the scheduling window is additional to that timeout.\n */\n batch?: boolean | HttpBatchOptions;\n}\n\n/**\n * JSON-RPC 2.0 transport over HTTP POST.\n *\n * `HttpTransport` handles request IDs, JSON-RPC envelopes, optional custom\n * headers, optional timeout cancellation, and conversion of JSON-RPC error\n * responses into `ThruputError` with code `rpcError`. Network failures use\n * `httpRequestFailed`, failed HTTP statuses use `httpResponseError`, and\n * malformed replies use `rpcResponseInvalid`.\n *\n * @example\n * ```ts\n * import { HttpTransport } from \"@thruputchain/client/transport\";\n *\n * const transport = new HttpTransport(\"http://127.0.0.1:9545\", {\n * timeoutMs: 10_000,\n * });\n *\n * const tip = await transport.request(\"getChainTip\");\n * ```\n */\nexport class HttpTransport implements Transport {\n #url: string;\n #headers?: Record<string, string>;\n #fetch: typeof fetch;\n #timeoutMs?: number;\n #nextId = 1;\n #batch?: HttpBatch;\n\n /** Create an HTTP transport for a Thruput JSON-RPC endpoint URL. */\n constructor(url: string, options: HttpTransportOptions = {}) {\n this.#url = url;\n this.#headers = options.headers;\n this.#fetch = options.fetch ?? globalThis.fetch.bind(globalThis);\n this.#timeoutMs = options.timeoutMs;\n if (options.batch) {\n const batch = options.batch === true ? {} : options.batch;\n const maxSize = batch.maxSize ?? 100;\n const waitMs = batch.waitMs ?? 0;\n if (!Number.isInteger(maxSize) || maxSize < 1 || maxSize > 1_000)\n throw new RangeError(\"batch.maxSize must be an integer from 1 to 1000\");\n if (!Number.isInteger(waitMs) || waitMs < 0 || waitMs > 2_147_483_647)\n throw new RangeError(\n \"batch.waitMs must be an integer from 0 to 2147483647\",\n );\n this.#batch = new HttpBatch(maxSize, waitMs, (body, signal) =>\n this.#post(body, \"batch\", { signal }),\n );\n }\n }\n\n /** Send one JSON-RPC request and return the decoded `result` value. */\n async request<T = unknown>(\n method: string,\n params?: RpcParams,\n options: TransportRequestOptions = {},\n ): Promise<T> {\n options.signal?.throwIfAborted();\n const id = this.#nextId++;\n const body = JSON.stringify({\n jsonrpc: \"2.0\",\n id,\n method,\n params: params ?? [],\n });\n\n let json: unknown;\n if (this.#batch) {\n try {\n json = await this.#batch.request(id, body, options.signal);\n } catch (error) {\n if (options.signal?.aborted) throw options.signal.reason;\n // Keep the original method on shared HTTP failures for each caller.\n if (isThruputError(error, \"httpRequestFailed\"))\n throw httpRequestFailed(error.context.endpoint, method, error.cause);\n if (isThruputError(error, \"httpResponseError\"))\n throw httpResponseError(\n error.context.status,\n error.context.statusText,\n error.context.endpoint,\n method,\n );\n throw error;\n }\n } else {\n json = await this.#post(body, method, options);\n }\n return decodeResponse(json, method, this.#batch ? undefined : id) as T;\n }\n\n async #post(\n body: string,\n method: string,\n options: TransportRequestOptions,\n ): Promise<unknown> {\n const abort = this.#timeoutMs ? new AbortController() : undefined;\n const signal =\n abort && options.signal\n ? AbortSignal.any([abort.signal, options.signal])\n : (abort?.signal ?? options.signal);\n const timeout = abort\n ? setTimeout(\n () =>\n abort.abort(new DOMException(\"Request timed out\", \"TimeoutError\")),\n this.#timeoutMs,\n )\n : undefined;\n let json: unknown;\n try {\n let response: Response;\n try {\n response = await this.#fetch(this.#url, {\n method: \"POST\",\n headers: { \"Content-Type\": \"application/json\", ...this.#headers },\n body,\n signal,\n });\n } catch (cause) {\n // A custom fetch may compose its own lifecycle signal outside this transport.\n if (\n typeof cause === \"object\" &&\n cause !== null &&\n \"name\" in cause &&\n (cause.name === \"AbortError\" || cause.name === \"TimeoutError\")\n )\n throw cause;\n throw httpRequestFailed(new URL(this.#url).origin, method, cause);\n }\n\n if (!response.ok) {\n throw httpResponseError(\n response.status,\n response.statusText,\n new URL(this.#url).origin,\n method,\n );\n }\n try {\n json = await response.json();\n } catch (cause) {\n // Fetch reports interrupted body reads as TypeError, a transient\n // failure. A body that is not JSON is a malformed reply after dispatch.\n const name =\n typeof cause === \"object\" && cause !== null && \"name\" in cause\n ? cause.name\n : undefined;\n if (name === \"TypeError\")\n throw httpRequestFailed(new URL(this.#url).origin, method, cause);\n if (name === \"SyntaxError\")\n throw rpcResponseInvalid(\n `${method}: response body is not JSON`,\n undefined,\n cause,\n );\n throw cause;\n }\n } catch (cause) {\n // Body reads can reject with AbortError rather than the supplied reason.\n if (signal?.aborted) throw signal.reason;\n throw cause;\n } finally {\n if (timeout !== undefined) clearTimeout(timeout);\n }\n\n return json;\n }\n}\n\nfunction decodeResponse(\n json: unknown,\n method: string,\n expectedId?: number,\n): unknown {\n if (!json || typeof json !== \"object\" || Array.isArray(json)) {\n throw rpcResponseInvalid(\"Invalid JSON-RPC response\", json);\n }\n\n const envelope = json as Record<string, unknown>;\n const frameworkError =\n envelope.id === null &&\n typeof envelope.error === \"object\" &&\n envelope.error !== null &&\n \"code\" in envelope.error &&\n [-32700, -32600].includes(envelope.error.code as number);\n if (\n envelope.jsonrpc !== \"2.0\" ||\n (expectedId !== undefined &&\n envelope.id !== expectedId &&\n !frameworkError) ||\n Object.hasOwn(envelope, \"result\") === Object.hasOwn(envelope, \"error\")\n ) {\n throw rpcResponseInvalid(\n \"Invalid JSON-RPC response envelope or request ID\",\n json,\n );\n }\n if (envelope.error !== undefined) {\n const error = envelope.error;\n if (!error || typeof error !== \"object\" || Array.isArray(error)) {\n throw rpcResponseInvalid(\"Invalid JSON-RPC error response\", json);\n }\n const body = error as Record<string, unknown>;\n if (\n typeof body.code !== \"number\" ||\n !Number.isSafeInteger(body.code) ||\n typeof body.message !== \"string\"\n ) {\n throw rpcResponseInvalid(\"Invalid JSON-RPC error response\", json);\n }\n throw rpcError(body.code, body.message, body.data, method, body);\n }\n\n if (!Object.prototype.hasOwnProperty.call(envelope, \"result\")) {\n throw rpcResponseInvalid(\"Invalid JSON-RPC response\", json);\n }\n return envelope.result;\n}\n","import type { Transport, RpcParams, TransportRequestOptions } from \"./types.js\";\nimport { codec, deserialize } from \"@thruputchain/protocol\";\nimport { toBase58 } from \"../encoding.js\";\nimport { fromHex0x } from \"../actions/hex.js\";\nimport { hashSignedTransaction } from \"../derivation/transactionHash.js\";\nimport { rpcError } from \"./errors.js\";\n\nconst methods = [\n \"getVersionInfo\",\n \"getNetworkInfo\",\n \"getChainTip\",\n \"getChainConfig\",\n \"getServerLimits\",\n \"getBalance\",\n \"getRegisteredAuth\",\n \"getContractDeployment\",\n \"getEffectiveContract\",\n \"getContractArtifact\",\n \"getBlockByHeight\",\n \"dev_getPendingTransactionCount\",\n \"simulateInvocation\",\n \"simulateInvocations\",\n \"sendTransaction\",\n \"getTransactionReceipt\",\n \"getTransactionInput\",\n \"getTransactionStatus\",\n \"getTransactionsByRootAddress\",\n \"getTransactionsByBlock\",\n \"getEvents\",\n \"getStorage\",\n \"faucet_requestAirdrop\",\n];\n/** Deterministic native RPC transport for examples; it does not execute contract code. */\nexport class MockTransport implements Transport {\n #height = 0n;\n #transactions = new Map<string, bigint>();\n async request<T = unknown>(\n method: string,\n params: RpcParams = {},\n options?: TransportRequestOptions,\n ): Promise<T> {\n options?.signal?.throwIfAborted();\n if (Array.isArray(params))\n throw new TypeError(\"Native RPC params must be a named object\");\n const stateBlockHeight = this.#height.toString();\n const bounds = {\n oldestIndexedBlockHeight: \"0\",\n latestIndexedBlockHeight: stateBlockHeight,\n nextCursor: null,\n };\n const simulation = {\n output: { result: \"return\", returnData: \"0x\" },\n events: [],\n gasUsed: \"0\",\n };\n let result: unknown;\n switch (method) {\n case \"getTransactionInput\":\n result = { status: \"unavailable\" };\n break;\n case \"getVersionInfo\":\n result = {\n wireFormat: \"14.4.0\",\n implementation: \"mock\",\n supportedMethods: [...methods],\n };\n break;\n case \"getNetworkInfo\":\n result = { networkHash: \"1\".repeat(32) };\n break;\n case \"getChainTip\":\n result = {\n blockHeight: stateBlockHeight,\n blockHash: this.#blockHash(this.#height),\n };\n break;\n case \"getChainConfig\":\n result = { stated: { maxNewContractsPerTx: 4 } };\n break;\n case \"getServerLimits\":\n result = {\n maxSimulationGas: \"100000000\",\n maxSimulationCalldataBytes: \"65536\",\n maxEventsPerPage: 200,\n maxTransactionsPerPage: 200,\n maxCursorBytes: \"1024\",\n simulationBatch: {\n maxInvocations: 16,\n maxCalldataBytes: 65536,\n maxGas: \"1600000000\",\n maxBackendResponseBytes: 1000000,\n timeoutMs: \"3000\",\n },\n };\n break;\n case \"getBalance\":\n result = { address: params.address, rawBalance: \"0\", stateBlockHeight };\n break;\n case \"getRegisteredAuth\":\n result = {\n address: params.address,\n configuration: null,\n stateBlockHeight,\n };\n break;\n case \"getStorage\":\n result = { item: null, stateBlockHeight };\n break;\n case \"getContractDeployment\":\n result = {\n address: params.address,\n stateBlockHeight,\n deployment: null,\n };\n break;\n case \"getEffectiveContract\":\n result = {\n address: params.address,\n context: params.context,\n stateBlockHeight,\n selection: null,\n };\n break;\n case \"getContractArtifact\":\n throw rpcError(\n -32014,\n \"Contract artifact unavailable\",\n {\n kind: \"contractArtifactUnavailable\",\n hash: params.hash,\n },\n method,\n );\n case \"dev_getPendingTransactionCount\":\n result = { count: \"0\" };\n break;\n case \"simulateInvocation\":\n result = { ...simulation, stateBlockHeight };\n break;\n case \"simulateInvocations\":\n result = {\n stateBlockHeight,\n results: (params.invocations as unknown[]).map(() =>\n structuredClone(simulation),\n ),\n };\n break;\n case \"faucet_requestAirdrop\":\n result = {\n attemptStatus: \"succeeded\",\n recipient: params.recipient,\n rawAmount: \"100000000\",\n transactionHash: this.#blockHash(this.#height),\n blockHeight: stateBlockHeight,\n execution: { result: \"return\", returnData: \"0x\" },\n };\n break;\n case \"sendTransaction\": {\n const signed = deserialize(\n fromHex0x(String(params.signedTransaction)),\n codec.SignedTransaction,\n );\n const hash = toBase58(hashSignedTransaction(signed));\n if (!this.#transactions.has(hash))\n this.#transactions.set(hash, ++this.#height);\n result = { transactionHash: hash, admission: \"accepted\" };\n break;\n }\n case \"getTransactionReceipt\": {\n const height = this.#transactions.get(String(params.transactionHash));\n result =\n height === undefined\n ? null\n : {\n transactionHash: params.transactionHash,\n blockHeight: height.toString(),\n execution: { result: \"return\", returnData: \"0x\" },\n events: [],\n gasUsed: \"0\",\n };\n break;\n }\n case \"getTransactionStatus\": {\n const height = this.#transactions.get(String(params.transactionHash));\n result =\n height === undefined\n ? { status: \"unknown\" }\n : { status: \"committed\", blockHeight: height.toString() };\n break;\n }\n case \"getEvents\":\n result = { ...bounds, events: [] };\n break;\n case \"getTransactionsByRootAddress\":\n case \"getTransactionsByBlock\":\n result = { ...bounds, transactions: [] };\n break;\n case \"getBlockByHeight\": {\n const height = BigInt(String(params.blockHeight));\n result =\n height <= 0n || height > this.#height\n ? null\n : {\n blockHash: this.#blockHash(height),\n protocol: 0,\n networkHash: \"1\".repeat(32),\n proposer: \"1\".repeat(32),\n blockTimepoint: \"0\",\n blockHeight: height.toString(),\n txsHash: this.#blockHash(height),\n storageHash: this.#blockHash(height),\n eventsHash: this.#blockHash(height),\n configHash: this.#blockHash(height),\n prevBlockHash: this.#blockHash(height - 1n),\n proposalTxsHash: this.#blockHash(height),\n upgrades: [],\n };\n break;\n }\n default:\n throw new Error(`MockTransport: method not implemented: ${method}`);\n }\n return result as T;\n }\n #blockHash(height: bigint): string {\n const bytes = new Uint8Array(32);\n new DataView(bytes.buffer).setBigUint64(24, height);\n return toBase58(bytes);\n }\n}\n","import { isThruputError } from \"../errors/thruputError.js\";\nimport {\n isUnsupportedRpcValue,\n type UnsupportedRpcValue,\n} from \"../rpc/unsupported.js\";\nimport type { RpcErrorData } from \"../rpc/generated.js\";\n/** A validated native admission bound violation. Unknown details remain on the raw error. */\nexport type TxInvalidDetail = Exclude<\n NonNullable<Extract<RpcErrorData, { kind: \"transactionInvalid\" }>[\"detail\"]>,\n UnsupportedRpcValue\n>;\n/** Read known transaction-bound evidence without inferring retry permission. */\nexport function txInvalidDetail(error: unknown): TxInvalidDetail | null {\n if (\n !isThruputError(error, \"nativeRpcError\") ||\n error.context.kind !== \"transactionInvalid\"\n )\n return null;\n const detail = error.context.data.detail;\n return !detail || isUnsupportedRpcValue(detail) ? null : detail;\n}\n","// Generated from the Rust-owned native OpenRPC fixture. Do not edit.\n/** Native causes. Codes alone never grant write retry permission. */\nexport const NativeRpcErrorCode = {\n BackendDataInvalid: -32054,\n BackendTimeout: -32051,\n BackendUnavailable: -32050,\n ContractArtifactUnavailable: -32014,\n FundingAttemptStopped: -32030,\n HistoryUnavailable: -32013,\n InvalidParams: -32602,\n LocalFundingUnresolved: -32031,\n Overloaded: -32053,\n StateHeightUnavailable: -32012,\n TransactionInvalid: -32000,\n TransactionRejected: -32001,\n} as const;\n"],"mappings":";;;;;;;;AAGA,SAAgB,SACd,MACA,YACA,MACA,QACA,KAC0B;CAC1B,OAAO,IAAIA,gBAAAA,aACT,YACA,GAAG,SAAS,GAAG,OAAO,MAAM,KAAK,WAAW,QAAQ,KAAK,IACzD,EACE,SAAS;EACP;EACA;EACA,GAAI,SAAS,KAAA,IAAY,CAAC,IAAI,EAAE,KAAK;EACrC,GAAI,WAAW,KAAA,IAAY,CAAC,IAAI,EAAE,OAAO;EACzC,KAAK,OAAO;GACV;GACA,SAAS;GACT,GAAI,SAAS,KAAA,IAAY,CAAC,IAAI,EAAE,KAAK;EACvC;CACF,EACF,CACF;AACF;;AAGA,SAAgB,kBACd,QACA,YACA,UACA,QACmC;CACnC,OAAO,IAAIA,gBAAAA,aACT,qBACA,QAAQ,OAAO,IAAI,aAAa,SAAS,KAAK,OAAO,MAAM,SAAS,KAAK,MACzE,EACE,SAAS;EACP;EACA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