@thruputchain/client 0.27.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 +120 -22
  2. package/dist/{actions-DK_XBeVy.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-Cu8Qv94_.js → contract-BOlNskwd.js} +235 -87
  15. package/dist/contract-BOlNskwd.js.map +1 -0
  16. package/dist/{contract-DPm2BJTu.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-BcvX_xT4.cjs → dev_wallet-BVChhV6j.cjs} +85 -6
  33. package/dist/dev_wallet-BVChhV6j.cjs.map +1 -0
  34. package/dist/{dev_wallet-B5R5JJaw.js → dev_wallet-D9LuPZ-h.js} +84 -5
  35. package/dist/dev_wallet-D9LuPZ-h.js.map +1 -0
  36. package/dist/{execution-C8oQgpO3.d.cts → execution-pSt6k620.d.cts} +23 -50
  37. package/dist/execution-pSt6k620.d.cts.map +1 -0
  38. package/dist/{execution-DsZzqv_C.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-rrP1HJ2Z.d.cts → index-B1efA-Y_.d.ts} +24 -21
  45. package/dist/index-B1efA-Y_.d.ts.map +1 -0
  46. package/dist/{index-Zaz-e8Sy.d.ts → index-BGmH_Sm7.d.cts} +12 -62
  47. package/dist/index-BGmH_Sm7.d.cts.map +1 -0
  48. package/dist/{index-CHnfHuQo.d.ts → index-BZ5j5P5d.d.ts} +11 -9
  49. package/dist/index-BZ5j5P5d.d.ts.map +1 -0
  50. package/dist/{index-BmQN3jAS.d.cts → index-BfYEEVHm.d.cts} +3 -13
  51. package/dist/index-BfYEEVHm.d.cts.map +1 -0
  52. package/dist/{index-CuzB95QT.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-hqEnT64w.d.ts → index-Btl_jMCT.d.ts} +3 -13
  57. package/dist/index-Btl_jMCT.d.ts.map +1 -0
  58. package/dist/{index-C3qDR1J5.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-CKqC9N4o.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-BOjoJjC5.js → readError-B3Rz7rgs.js} +673 -56
  81. package/dist/readError-B3Rz7rgs.js.map +1 -0
  82. package/dist/{codec-C4LJ0g8v.cjs → readError-COcEDNoZ.cjs} +677 -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-BDUZhfJn.cjs → signedOp-CVyeJ5ig.cjs} +3 -3
  97. package/dist/{signedOp-BDUZhfJn.cjs.map → signedOp-CVyeJ5ig.cjs.map} +1 -1
  98. package/dist/{signedOp-Kx8u8_3I.js → signedOp-D6WYZG9j.js} +3 -3
  99. package/dist/{signedOp-Kx8u8_3I.js.map → signedOp-D6WYZG9j.js.map} +1 -1
  100. package/dist/{signed_op-CAcYYRm6.cjs → signed_op-BBsDKOlD.cjs} +4 -4
  101. package/dist/{signed_op-CAcYYRm6.cjs.map → signed_op-BBsDKOlD.cjs.map} +1 -1
  102. package/dist/{signed_op-BrLxDrDb.d.cts → signed_op-BvbOHWKK.d.ts} +3 -3
  103. package/dist/{signed_op-DbRq3_Hb.d.ts.map → signed_op-BvbOHWKK.d.ts.map} +1 -1
  104. package/dist/{signed_op-DbRq3_Hb.d.ts → signed_op-DoHFpSH4.d.cts} +3 -3
  105. package/dist/{signed_op-BrLxDrDb.d.cts.map → signed_op-DoHFpSH4.d.cts.map} +1 -1
  106. package/dist/{signed_op-Dxn7-lRu.js → signed_op-h9X9-vBL.js} +3 -3
  107. package/dist/{signed_op-Dxn7-lRu.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-5wt9wLG3.js → wallet-NlZiI4-3.js} +161 -77
  125. package/dist/wallet-NlZiI4-3.js.map +1 -0
  126. package/dist/{wallet-Blh7oas7.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-1LmkZcfS.js +0 -430
  134. package/dist/actions-1LmkZcfS.js.map +0 -1
  135. package/dist/actions-DK_XBeVy.cjs.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-DocSdzOL.d.cts +0 -790
  139. package/dist/client-DocSdzOL.d.cts.map +0 -1
  140. package/dist/client-DocSdzOL.d.ts +0 -790
  141. package/dist/client-DocSdzOL.d.ts.map +0 -1
  142. package/dist/codec-BOjoJjC5.js.map +0 -1
  143. package/dist/codec-C4LJ0g8v.cjs.map +0 -1
  144. package/dist/contract-Cu8Qv94_.js.map +0 -1
  145. package/dist/contract-DPm2BJTu.cjs.map +0 -1
  146. package/dist/dev_wallet-B5R5JJaw.js.map +0 -1
  147. package/dist/dev_wallet-BcvX_xT4.cjs.map +0 -1
  148. package/dist/execution-C8oQgpO3.d.cts.map +0 -1
  149. package/dist/execution-DsZzqv_C.d.ts.map +0 -1
  150. package/dist/index-BmQN3jAS.d.cts.map +0 -1
  151. package/dist/index-C3qDR1J5.d.cts.map +0 -1
  152. package/dist/index-CHnfHuQo.d.ts.map +0 -1
  153. package/dist/index-CIHK7Ew9.d.cts +0 -303
  154. package/dist/index-CIHK7Ew9.d.cts.map +0 -1
  155. package/dist/index-CIHK7Ew9.d.ts +0 -303
  156. package/dist/index-CIHK7Ew9.d.ts.map +0 -1
  157. package/dist/index-CKqC9N4o.d.ts.map +0 -1
  158. package/dist/index-CuzB95QT.d.cts.map +0 -1
  159. package/dist/index-Zaz-e8Sy.d.ts.map +0 -1
  160. package/dist/index-hqEnT64w.d.ts.map +0 -1
  161. package/dist/index-rrP1HJ2Z.d.cts.map +0 -1
  162. package/dist/readError-Cz3bveZa.cjs +0 -622
  163. package/dist/readError-Cz3bveZa.cjs.map +0 -1
  164. package/dist/readError-Z5zuylri.js +0 -569
  165. package/dist/readError-Z5zuylri.js.map +0 -1
  166. package/dist/readViews-BvMHbiaF.d.ts +0 -609
  167. package/dist/readViews-BvMHbiaF.d.ts.map +0 -1
  168. package/dist/readViews-CQOY5v4o.d.cts +0 -609
  169. package/dist/readViews-CQOY5v4o.d.cts.map +0 -1
  170. package/dist/sendInvocation-8TEMrJ_M.cjs +0 -661
  171. package/dist/sendInvocation-8TEMrJ_M.cjs.map +0 -1
  172. package/dist/sendInvocation-CkeMyLk1.js +0 -505
  173. package/dist/sendInvocation-CkeMyLk1.js.map +0 -1
  174. package/dist/transport-DqlfAsuH.cjs +0 -279
  175. package/dist/transport-DqlfAsuH.cjs.map +0 -1
  176. package/dist/transport-PstrCcBv.js +0 -261
  177. package/dist/transport-PstrCcBv.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-5wt9wLG3.js.map +0 -1
  181. package/dist/wallet-Blh7oas7.cjs.map +0 -1
@@ -0,0 +1,504 @@
1
+ import { a as isUnsupportedRpcValue, o as ThruputError, s as isThruputError } from "./decimal-CoHOISys.js";
2
+ import { g as toBase58, n as fromHex0x } from "./hex-B8D-jBgz.js";
3
+ import { t as hashSignedTransaction } from "./transactionHash-CO9ajbvU.js";
4
+ import "./readError-B3Rz7rgs.js";
5
+ import { codec, deserialize } from "@thruputchain/protocol";
6
+ //#region src/transport/errors.ts
7
+ /** A JSON-RPC error object. Keep the raw object, including additive fields. */
8
+ function rpcError(code, rpcMessage, data, method, raw) {
9
+ return new ThruputError("rpcError", `${method ? `${method}: ` : ""}${rpcMessage} (RPC ${code})`, { context: {
10
+ code,
11
+ rpcMessage,
12
+ ...data === void 0 ? {} : { data },
13
+ ...method === void 0 ? {} : { method },
14
+ raw: raw ?? {
15
+ code,
16
+ message: rpcMessage,
17
+ ...data === void 0 ? {} : { data }
18
+ }
19
+ } });
20
+ }
21
+ /** An HTTP status that is not successful. */
22
+ function httpResponseError(status, statusText, endpoint, method) {
23
+ return new ThruputError("httpResponseError", `HTTP ${status}: ${statusText}${method ? ` (${method} at ${endpoint})` : ""}`, { context: {
24
+ status,
25
+ statusText,
26
+ ...endpoint === void 0 ? {} : { endpoint },
27
+ ...method === void 0 ? {} : { method }
28
+ } });
29
+ }
30
+ /** A network failure, with the endpoint origin only. */
31
+ function httpRequestFailed(endpoint, method, cause) {
32
+ return new ThruputError("httpRequestFailed", `${method}: request to ${endpoint} failed`, {
33
+ context: {
34
+ endpoint,
35
+ method
36
+ },
37
+ cause
38
+ });
39
+ }
40
+ /** A malformed JSON-RPC reply after dispatch. The write outcome is unknown. */
41
+ function rpcResponseInvalid(message, raw, cause) {
42
+ return new ThruputError("rpcResponseInvalid", message, {
43
+ context: { raw },
44
+ ...cause === void 0 ? {} : { cause }
45
+ });
46
+ }
47
+ //#endregion
48
+ //#region src/transport/httpBatch.ts
49
+ var HttpBatch = class {
50
+ maxSize;
51
+ waitMs;
52
+ send;
53
+ #queue = /* @__PURE__ */ new Set();
54
+ #timer;
55
+ constructor(maxSize, waitMs, send) {
56
+ this.maxSize = maxSize;
57
+ this.waitMs = waitMs;
58
+ this.send = send;
59
+ }
60
+ request(id, body, signal) {
61
+ return new Promise((resolve, reject) => {
62
+ let settled = false;
63
+ const finish = (callback, value) => {
64
+ if (settled) return;
65
+ settled = true;
66
+ signal?.removeEventListener("abort", cancel);
67
+ callback(value);
68
+ };
69
+ const entry = {
70
+ id,
71
+ body,
72
+ resolve: (value) => finish(resolve, value),
73
+ reject: (reason) => finish(reject, reason)
74
+ };
75
+ const cancel = () => {
76
+ this.#queue.delete(entry);
77
+ if (this.#queue.size === 0) this.#clearTimer();
78
+ entry.reject(signal?.reason);
79
+ entry.onCancel?.();
80
+ };
81
+ if (signal?.aborted) {
82
+ entry.reject(signal.reason);
83
+ return;
84
+ }
85
+ signal?.addEventListener("abort", cancel, { once: true });
86
+ this.#queue.add(entry);
87
+ if (this.#queue.size >= this.maxSize) this.#flush();
88
+ else if (this.#timer === void 0) this.#timer = setTimeout(() => void this.#flush(), this.waitMs);
89
+ });
90
+ }
91
+ #clearTimer() {
92
+ if (this.#timer !== void 0) clearTimeout(this.#timer);
93
+ this.#timer = void 0;
94
+ }
95
+ async #flush() {
96
+ this.#clearTimer();
97
+ const entries = [...this.#queue];
98
+ this.#queue.clear();
99
+ if (entries.length === 0) return;
100
+ const controller = new AbortController();
101
+ const active = new Set(entries);
102
+ for (const entry of entries) entry.onCancel = () => {
103
+ active.delete(entry);
104
+ if (active.size === 0) controller.abort();
105
+ };
106
+ try {
107
+ const responses = batchResponses(await this.send(`[${entries.map((entry) => entry.body).join(",")}]`, controller.signal), entries);
108
+ for (const entry of entries) entry.resolve(responses.get(entry.id));
109
+ } catch (error) {
110
+ for (const entry of entries) entry.reject(error);
111
+ } finally {
112
+ for (const entry of entries) entry.onCancel = void 0;
113
+ }
114
+ }
115
+ };
116
+ function batchResponses(json, entries) {
117
+ 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]));
118
+ if (!Array.isArray(json) || json.length !== entries.length) throw rpcResponseInvalid("Invalid JSON-RPC batch response: expected one response per request", json);
119
+ const expected = new Set(entries.map((entry) => entry.id));
120
+ const responses = /* @__PURE__ */ new Map();
121
+ for (const value of json) {
122
+ const response = value;
123
+ 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);
124
+ responses.set(response.id, response);
125
+ }
126
+ return responses;
127
+ }
128
+ //#endregion
129
+ //#region src/transport/http.ts
130
+ /**
131
+ * JSON-RPC 2.0 transport over HTTP POST.
132
+ *
133
+ * `HttpTransport` handles request IDs, JSON-RPC envelopes, optional custom
134
+ * headers, optional timeout cancellation, and conversion of JSON-RPC error
135
+ * responses into `ThruputError` with code `rpcError`. Network failures use
136
+ * `httpRequestFailed`, failed HTTP statuses use `httpResponseError`, and
137
+ * malformed replies use `rpcResponseInvalid`.
138
+ *
139
+ * @example
140
+ * ```ts
141
+ * import { HttpTransport } from "@thruputchain/client/transport";
142
+ *
143
+ * const transport = new HttpTransport("http://127.0.0.1:9545", {
144
+ * timeoutMs: 10_000,
145
+ * });
146
+ *
147
+ * const tip = await transport.request("getChainTip");
148
+ * ```
149
+ */
150
+ var HttpTransport = class {
151
+ #url;
152
+ #headers;
153
+ #fetch;
154
+ #timeoutMs;
155
+ #nextId = 1;
156
+ #batch;
157
+ /** Create an HTTP transport for a Thruput JSON-RPC endpoint URL. */
158
+ constructor(url, options = {}) {
159
+ this.#url = url;
160
+ this.#headers = options.headers;
161
+ this.#fetch = options.fetch ?? globalThis.fetch.bind(globalThis);
162
+ this.#timeoutMs = options.timeoutMs;
163
+ if (options.batch) {
164
+ const batch = options.batch === true ? {} : options.batch;
165
+ const maxSize = batch.maxSize ?? 100;
166
+ const waitMs = batch.waitMs ?? 0;
167
+ if (!Number.isInteger(maxSize) || maxSize < 1 || maxSize > 1e3) throw new RangeError("batch.maxSize must be an integer from 1 to 1000");
168
+ if (!Number.isInteger(waitMs) || waitMs < 0 || waitMs > 2147483647) throw new RangeError("batch.waitMs must be an integer from 0 to 2147483647");
169
+ this.#batch = new HttpBatch(maxSize, waitMs, (body, signal) => this.#post(body, "batch", { signal }));
170
+ }
171
+ }
172
+ /** Send one JSON-RPC request and return the decoded `result` value. */
173
+ async request(method, params, options = {}) {
174
+ options.signal?.throwIfAborted();
175
+ const id = this.#nextId++;
176
+ const body = JSON.stringify({
177
+ jsonrpc: "2.0",
178
+ id,
179
+ method,
180
+ params: params ?? []
181
+ });
182
+ let json;
183
+ if (this.#batch) try {
184
+ json = await this.#batch.request(id, body, options.signal);
185
+ } catch (error) {
186
+ if (options.signal?.aborted) throw options.signal.reason;
187
+ if (isThruputError(error, "httpRequestFailed")) throw httpRequestFailed(error.context.endpoint, method, error.cause);
188
+ if (isThruputError(error, "httpResponseError")) throw httpResponseError(error.context.status, error.context.statusText, error.context.endpoint, method);
189
+ throw error;
190
+ }
191
+ else json = await this.#post(body, method, options);
192
+ return decodeResponse(json, method, this.#batch ? void 0 : id);
193
+ }
194
+ async #post(body, method, options) {
195
+ const abort = this.#timeoutMs ? new AbortController() : void 0;
196
+ const signal = abort && options.signal ? AbortSignal.any([abort.signal, options.signal]) : abort?.signal ?? options.signal;
197
+ const timeout = abort ? setTimeout(() => abort.abort(new DOMException("Request timed out", "TimeoutError")), this.#timeoutMs) : void 0;
198
+ let json;
199
+ try {
200
+ let response;
201
+ try {
202
+ response = await this.#fetch(this.#url, {
203
+ method: "POST",
204
+ headers: {
205
+ "Content-Type": "application/json",
206
+ ...this.#headers
207
+ },
208
+ body,
209
+ signal
210
+ });
211
+ } catch (cause) {
212
+ if (typeof cause === "object" && cause !== null && "name" in cause && (cause.name === "AbortError" || cause.name === "TimeoutError")) throw cause;
213
+ throw httpRequestFailed(new URL(this.#url).origin, method, cause);
214
+ }
215
+ if (!response.ok) throw httpResponseError(response.status, response.statusText, new URL(this.#url).origin, method);
216
+ try {
217
+ json = await response.json();
218
+ } catch (cause) {
219
+ const name = typeof cause === "object" && cause !== null && "name" in cause ? cause.name : void 0;
220
+ if (name === "TypeError") throw httpRequestFailed(new URL(this.#url).origin, method, cause);
221
+ if (name === "SyntaxError") throw rpcResponseInvalid(`${method}: response body is not JSON`, void 0, cause);
222
+ throw cause;
223
+ }
224
+ } catch (cause) {
225
+ if (signal?.aborted) throw signal.reason;
226
+ throw cause;
227
+ } finally {
228
+ if (timeout !== void 0) clearTimeout(timeout);
229
+ }
230
+ return json;
231
+ }
232
+ };
233
+ function decodeResponse(json, method, expectedId) {
234
+ if (!json || typeof json !== "object" || Array.isArray(json)) throw rpcResponseInvalid("Invalid JSON-RPC response", json);
235
+ const envelope = json;
236
+ const frameworkError = envelope.id === null && typeof envelope.error === "object" && envelope.error !== null && "code" in envelope.error && [-32700, -32600].includes(envelope.error.code);
237
+ 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);
238
+ if (envelope.error !== void 0) {
239
+ const error = envelope.error;
240
+ if (!error || typeof error !== "object" || Array.isArray(error)) throw rpcResponseInvalid("Invalid JSON-RPC error response", json);
241
+ const body = error;
242
+ if (typeof body.code !== "number" || !Number.isSafeInteger(body.code) || typeof body.message !== "string") throw rpcResponseInvalid("Invalid JSON-RPC error response", json);
243
+ throw rpcError(body.code, body.message, body.data, method, body);
244
+ }
245
+ if (!Object.prototype.hasOwnProperty.call(envelope, "result")) throw rpcResponseInvalid("Invalid JSON-RPC response", json);
246
+ return envelope.result;
247
+ }
248
+ //#endregion
249
+ //#region src/transport/mock.ts
250
+ const methods = [
251
+ "getVersionInfo",
252
+ "getNetworkInfo",
253
+ "getChainTip",
254
+ "getChainConfig",
255
+ "getServerLimits",
256
+ "getBalance",
257
+ "getRegisteredAuth",
258
+ "getContractDeployment",
259
+ "getEffectiveContract",
260
+ "getContractArtifact",
261
+ "getBlockByHeight",
262
+ "dev_getPendingTransactionCount",
263
+ "simulateInvocation",
264
+ "simulateInvocations",
265
+ "sendTransaction",
266
+ "getTransactionReceipt",
267
+ "getTransactionInput",
268
+ "getTransactionStatus",
269
+ "getTransactionsByRootAddress",
270
+ "getTransactionsByBlock",
271
+ "getEvents",
272
+ "getStorage",
273
+ "faucet_requestAirdrop"
274
+ ];
275
+ /** Deterministic native RPC transport for examples; it does not execute contract code. */
276
+ var MockTransport = class {
277
+ #height = 0n;
278
+ #transactions = /* @__PURE__ */ new Map();
279
+ async request(method, params = {}, options) {
280
+ options?.signal?.throwIfAborted();
281
+ if (Array.isArray(params)) throw new TypeError("Native RPC params must be a named object");
282
+ const stateBlockHeight = this.#height.toString();
283
+ const bounds = {
284
+ oldestIndexedBlockHeight: "0",
285
+ latestIndexedBlockHeight: stateBlockHeight,
286
+ nextCursor: null
287
+ };
288
+ const simulation = {
289
+ output: {
290
+ result: "return",
291
+ returnData: "0x"
292
+ },
293
+ events: [],
294
+ gasUsed: "0"
295
+ };
296
+ let result;
297
+ switch (method) {
298
+ case "getTransactionInput":
299
+ result = { status: "unavailable" };
300
+ break;
301
+ case "getVersionInfo":
302
+ result = {
303
+ wireFormat: "14.4.0",
304
+ implementation: "mock",
305
+ supportedMethods: [...methods]
306
+ };
307
+ break;
308
+ case "getNetworkInfo":
309
+ result = { networkHash: "1".repeat(32) };
310
+ break;
311
+ case "getChainTip":
312
+ result = {
313
+ blockHeight: stateBlockHeight,
314
+ blockHash: this.#blockHash(this.#height)
315
+ };
316
+ break;
317
+ case "getChainConfig":
318
+ result = { stated: { maxNewContractsPerTx: 4 } };
319
+ break;
320
+ case "getServerLimits":
321
+ result = {
322
+ maxSimulationGas: "100000000",
323
+ maxSimulationCalldataBytes: "65536",
324
+ maxEventsPerPage: 200,
325
+ maxTransactionsPerPage: 200,
326
+ maxCursorBytes: "1024",
327
+ simulationBatch: {
328
+ maxInvocations: 16,
329
+ maxCalldataBytes: 65536,
330
+ maxGas: "1600000000",
331
+ maxBackendResponseBytes: 1e6,
332
+ timeoutMs: "3000"
333
+ }
334
+ };
335
+ break;
336
+ case "getBalance":
337
+ result = {
338
+ address: params.address,
339
+ rawBalance: "0",
340
+ stateBlockHeight
341
+ };
342
+ break;
343
+ case "getRegisteredAuth":
344
+ result = {
345
+ address: params.address,
346
+ configuration: null,
347
+ stateBlockHeight
348
+ };
349
+ break;
350
+ case "getStorage":
351
+ result = {
352
+ item: null,
353
+ stateBlockHeight
354
+ };
355
+ break;
356
+ case "getContractDeployment":
357
+ result = {
358
+ address: params.address,
359
+ stateBlockHeight,
360
+ deployment: null
361
+ };
362
+ break;
363
+ case "getEffectiveContract":
364
+ result = {
365
+ address: params.address,
366
+ context: params.context,
367
+ stateBlockHeight,
368
+ selection: null
369
+ };
370
+ break;
371
+ case "getContractArtifact": throw rpcError(-32014, "Contract artifact unavailable", {
372
+ kind: "contractArtifactUnavailable",
373
+ hash: params.hash
374
+ }, method);
375
+ case "dev_getPendingTransactionCount":
376
+ result = { count: "0" };
377
+ break;
378
+ case "simulateInvocation":
379
+ result = {
380
+ ...simulation,
381
+ stateBlockHeight
382
+ };
383
+ break;
384
+ case "simulateInvocations":
385
+ result = {
386
+ stateBlockHeight,
387
+ results: params.invocations.map(() => structuredClone(simulation))
388
+ };
389
+ break;
390
+ case "faucet_requestAirdrop":
391
+ result = {
392
+ attemptStatus: "succeeded",
393
+ recipient: params.recipient,
394
+ rawAmount: "100000000",
395
+ transactionHash: this.#blockHash(this.#height),
396
+ blockHeight: stateBlockHeight,
397
+ execution: {
398
+ result: "return",
399
+ returnData: "0x"
400
+ }
401
+ };
402
+ break;
403
+ case "sendTransaction": {
404
+ const hash = toBase58(hashSignedTransaction(deserialize(fromHex0x(String(params.signedTransaction)), codec.SignedTransaction)));
405
+ if (!this.#transactions.has(hash)) this.#transactions.set(hash, ++this.#height);
406
+ result = {
407
+ transactionHash: hash,
408
+ admission: "accepted"
409
+ };
410
+ break;
411
+ }
412
+ case "getTransactionReceipt": {
413
+ const height = this.#transactions.get(String(params.transactionHash));
414
+ result = height === void 0 ? null : {
415
+ transactionHash: params.transactionHash,
416
+ blockHeight: height.toString(),
417
+ execution: {
418
+ result: "return",
419
+ returnData: "0x"
420
+ },
421
+ events: [],
422
+ gasUsed: "0"
423
+ };
424
+ break;
425
+ }
426
+ case "getTransactionStatus": {
427
+ const height = this.#transactions.get(String(params.transactionHash));
428
+ result = height === void 0 ? { status: "unknown" } : {
429
+ status: "committed",
430
+ blockHeight: height.toString()
431
+ };
432
+ break;
433
+ }
434
+ case "getEvents":
435
+ result = {
436
+ ...bounds,
437
+ events: []
438
+ };
439
+ break;
440
+ case "getTransactionsByRootAddress":
441
+ case "getTransactionsByBlock":
442
+ result = {
443
+ ...bounds,
444
+ transactions: []
445
+ };
446
+ break;
447
+ case "getBlockByHeight": {
448
+ const height = BigInt(String(params.blockHeight));
449
+ result = height <= 0n || height > this.#height ? null : {
450
+ blockHash: this.#blockHash(height),
451
+ protocol: 0,
452
+ networkHash: "1".repeat(32),
453
+ proposer: "1".repeat(32),
454
+ blockTimepoint: "0",
455
+ blockHeight: height.toString(),
456
+ txsHash: this.#blockHash(height),
457
+ storageHash: this.#blockHash(height),
458
+ eventsHash: this.#blockHash(height),
459
+ configHash: this.#blockHash(height),
460
+ prevBlockHash: this.#blockHash(height - 1n),
461
+ proposalTxsHash: this.#blockHash(height),
462
+ upgrades: []
463
+ };
464
+ break;
465
+ }
466
+ default: throw new Error(`MockTransport: method not implemented: ${method}`);
467
+ }
468
+ return result;
469
+ }
470
+ #blockHash(height) {
471
+ const bytes = new Uint8Array(32);
472
+ new DataView(bytes.buffer).setBigUint64(24, height);
473
+ return toBase58(bytes);
474
+ }
475
+ };
476
+ //#endregion
477
+ //#region src/transport/txInvalidDetail.ts
478
+ /** Read known transaction-bound evidence without inferring retry permission. */
479
+ function txInvalidDetail(error) {
480
+ if (!isThruputError(error, "nativeRpcError") || error.context.kind !== "transactionInvalid") return null;
481
+ const detail = error.context.data.detail;
482
+ return !detail || isUnsupportedRpcValue(detail) ? null : detail;
483
+ }
484
+ //#endregion
485
+ //#region src/rpc/errors.ts
486
+ /** Native causes. Codes alone never grant write retry permission. */
487
+ const NativeRpcErrorCode = {
488
+ BackendDataInvalid: -32054,
489
+ BackendTimeout: -32051,
490
+ BackendUnavailable: -32050,
491
+ ContractArtifactUnavailable: -32014,
492
+ FundingAttemptStopped: -32030,
493
+ HistoryUnavailable: -32013,
494
+ InvalidParams: -32602,
495
+ LocalFundingUnresolved: -32031,
496
+ Overloaded: -32053,
497
+ StateHeightUnavailable: -32012,
498
+ TransactionInvalid: -32e3,
499
+ TransactionRejected: -32001
500
+ };
501
+ //#endregion
502
+ export { HttpTransport as i, txInvalidDetail as n, MockTransport as r, NativeRpcErrorCode as t };
503
+
504
+ //# sourceMappingURL=transport-EyDYuibb.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transport-EyDYuibb.js","names":["#queue","#clearTimer","#flush","#timer","#url","#headers","#fetch","#timeoutMs","#batch","#post","#nextId","#height","#blockHash","#transactions"],"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,IAAI,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,IAAI,aACT,qBACA,QAAQ,OAAO,IAAI,aAAa,SAAS,KAAK,OAAO,MAAM,SAAS,KAAK,MACzE,EACE,SAAS;EACP;EACA;EACA,GAAI,aAAa,KAAA,IAAY,CAAC,IAAI,EAAE,SAAS;EAC7C,GAAI,WAAW,KAAA,IAAY,CAAC,IAAI,EAAE,OAAO;CAC3C,EACF,CACF;AACF;;AAGA,SAAgB,kBACd,UACA,QACA,OACmC;CACnC,OAAO,IAAI,aACT,qBACA,GAAG,OAAO,eAAe,SAAS,UAClC;EAAE,SAAS;GAAE;GAAU;EAAO;EAAG;CAAM,CACzC;AACF;;AAGA,SAAgB,mBACd,SACA,KACA,OACoC;CACpC,OAAO,IAAI,aAAa,sBAAsB,SAAS;EACrD,SAAS,EAAE,IAAI;EACf,GAAI,UAAU,KAAA,IAAY,CAAC,IAAI,EAAE,MAAM;CACzC,CAAC;AACH;;;AC9DA,IAAa,YAAb,MAAuB;CAKF;CACA;CACA;CANnB,yBAAS,IAAI,IAAoB;CACjC;C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B;CACpB,6BAA6B;CAC7B,uBAAuB;CACvB,oBAAoB;CACpB,eAAe;CACf,wBAAwB;CACxB,YAAY;CACZ,wBAAwB;CACxB,oBAAoB;CACpB,qBAAqB;AACvB"}
@@ -1,19 +1,12 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_codec = require("./codec-C4LJ0g8v.cjs");
3
- const require_readError = require("./readError-Cz3bveZa.cjs");
4
- const require_transport = require("./transport-DqlfAsuH.cjs");
5
- exports.HttpRequestError = require_readError.HttpRequestError;
6
- exports.HttpResponseError = require_readError.HttpResponseError;
7
- exports.HttpTransport = require_readError.HttpTransport;
8
- exports.JsonRpcError = require_readError.JsonRpcError;
2
+ const require_decimal = require("./decimal-BX7abv5J.cjs");
3
+ const require_readError = require("./readError-COcEDNoZ.cjs");
4
+ const require_transport = require("./transport-BhWZxHcz.cjs");
5
+ exports.HttpTransport = require_transport.HttpTransport;
9
6
  exports.MockTransport = require_transport.MockTransport;
10
- exports.NativeRpcError = require_readError.NativeRpcError;
11
7
  exports.NativeRpcErrorCode = require_transport.NativeRpcErrorCode;
12
- exports.RpcCompatibilityError = require_readError.RpcCompatibilityError;
13
- exports.RpcDecodingError = require_codec.RpcDecodingError;
14
- exports.RpcRequestValidationError = require_codec.RpcRequestValidationError;
15
- exports.RpcResponseError = require_readError.RpcResponseError;
16
- exports.UnsupportedRpcValue = require_codec.UnsupportedRpcValue;
8
+ exports.UnsupportedRpcValue = require_decimal.UnsupportedRpcValue;
17
9
  exports.classifyReadError = require_readError.classifyReadError;
18
10
  exports.createRpcClient = require_readError.createRpcClient;
11
+ exports.isUnsupportedRpcValue = require_decimal.isUnsupportedRpcValue;
19
12
  exports.txInvalidDetail = require_transport.txInvalidDetail;
@@ -1,3 +1,3 @@
1
- import { $ as RpcInvocationResult, A as RpcConflictCode, At as RpcRequestValidationError, B as RpcEffectiveContractResult, C as RpcBlockDriverMode, Ct as RpcTransactionReceipt, D as RpcChainConfig, Dt as RpcTxHash, E as RpcBlockStart, Et as RpcTransactionStatus, F as RpcContractRejectCode, G as RpcExecutionConfig, H as RpcErrorData, I as RpcDecimalTimePoint, J as RpcHistoryStart, K as RpcFailureCause, L as RpcDecimalU64, M as RpcContractArtifactResult, Mt as RpcParams, N as RpcContractDeployment, Nt as Transport, O as RpcChainTip, Ot as RpcVersionInfo, P as RpcContractDeploymentResult, Pt as TransportRequestOptions, Q as RpcInvocationOutput, R as RpcDescendingAnchor, S as RpcBlockClock, St as RpcTransactionInputResult, T as RpcBlockInfo, Tt as RpcTransactionRefPage, U as RpcEventFilter, V as RpcEmittedEvent, W as RpcEventPage, X as RpcInvocation, Y as RpcIdentifiedEvent, Z as RpcInvocationContext, _ as RpcBase58_ContractAddress, _t as RpcSimulationResults, a as RpcMethod, at as RpcPublicKey, b as RpcBase58_SHA256Hash, bt as RpcStorageResult, c as RpcActiveBlockDriverMode, ct as RpcRegisteredAuthResult, d as RpcAirdropExecution, dt as RpcSchedulerError, et as RpcIterationOrder, f as RpcAscendingAnchor, ft as RpcSchedulerErrorSource, g as RpcBalanceResult, gt as RpcSimulationResult, h as RpcAuthSigner, ht as RpcSimulationBatchLimits, i as RpcDiscovery, it as RpcProducedBlocks, j as RpcConflictDiagnostic, jt as UnsupportedRpcValue, k as RpcConfigLimits, kt as RpcDecodingError, l as RpcAdmission, lt as RpcRequests, m as RpcAuthConfiguration, mt as RpcServerLimits, n as RpcClientOptions, nt as RpcPendingTransactionCount, o as RpcMethods, ot as RpcReceiptExecution, p as RpcAssumedAuth, pt as RpcSendTransactionResult, q as RpcFundingSubmission, r as RpcCompatibilityError, rt as RpcProducedBlock, s as createRpcClient, st as RpcRecentAttemptFailure, t as RpcClient, tt as RpcNetworkInfo, u as RpcAirdropAttempt, ut as RpcResults, v as RpcBase58_Ed25519PublicKey, vt as RpcStorageCosts, w as RpcBlockDriverStatus, wt as RpcTransactionRef, x as RpcBase58_ValidatorID, xt as RpcTopicFilter, y as RpcBase58_PublicKeyHash, yt as RpcStorageItem, z as RpcEffectiveContract } from "./client-DocSdzOL.cjs";
2
- import { a as TxInvalidDetail, c as classifyReadError, d as HttpRequestError, f as HttpResponseError, h as JsonRpcError, i as NativeRpcErrorCode, l as MockTransport, m as HttpTransportOptions, n as DecodedRpcError, o as txInvalidDetail, p as HttpTransport, r as NativeRpcError, s as ReadErrorKind, t as RpcResponseError, u as HttpBatchOptions } from "./index-C3qDR1J5.cjs";
3
- export { type DecodedRpcError, type HttpBatchOptions, HttpRequestError, HttpResponseError, HttpTransport, type HttpTransportOptions, JsonRpcError, MockTransport, NativeRpcError, NativeRpcErrorCode, type ReadErrorKind, type RpcActiveBlockDriverMode, type RpcAdmission, type RpcAirdropAttempt, type RpcAirdropExecution, type RpcAscendingAnchor, type RpcAssumedAuth, type RpcAuthConfiguration, type RpcAuthSigner, type RpcBalanceResult, type RpcBase58_ContractAddress, type RpcBase58_Ed25519PublicKey, type RpcBase58_PublicKeyHash, type RpcBase58_SHA256Hash, type RpcBase58_ValidatorID, type RpcBlockClock, type RpcBlockDriverMode, type RpcBlockDriverStatus, type RpcBlockInfo, type RpcBlockStart, type RpcChainConfig, type RpcChainTip, type RpcClient, type RpcClientOptions, RpcCompatibilityError, type RpcConfigLimits, type RpcConflictCode, type RpcConflictDiagnostic, type RpcContractArtifactResult, type RpcContractDeployment, type RpcContractDeploymentResult, type RpcContractRejectCode, type RpcDecimalTimePoint, type RpcDecimalU64, RpcDecodingError, type RpcDescendingAnchor, type RpcDiscovery, type RpcEffectiveContract, type RpcEffectiveContractResult, type RpcEmittedEvent, type RpcErrorData, type RpcEventFilter, type RpcEventPage, type RpcExecutionConfig, type RpcFailureCause, type RpcFundingSubmission, type RpcHistoryStart, type RpcIdentifiedEvent, type RpcInvocation, type RpcInvocationContext, type RpcInvocationOutput, type RpcInvocationResult, type RpcIterationOrder, type RpcMethod, type RpcMethods, type RpcNetworkInfo, type RpcParams, type RpcPendingTransactionCount, type RpcProducedBlock, type RpcProducedBlocks, type RpcPublicKey, type RpcReceiptExecution, type RpcRecentAttemptFailure, type RpcRegisteredAuthResult, RpcRequestValidationError, type RpcRequests, RpcResponseError, type RpcResults, type RpcSchedulerError, type RpcSchedulerErrorSource, type RpcSendTransactionResult, type RpcServerLimits, type RpcSimulationBatchLimits, type RpcSimulationResult, type RpcSimulationResults, type RpcStorageCosts, type RpcStorageItem, type RpcStorageResult, type RpcTopicFilter, type RpcTransactionInputResult, type RpcTransactionReceipt, type RpcTransactionRef, type RpcTransactionRefPage, type RpcTransactionStatus, type RpcTxHash, type RpcVersionInfo, type Transport, type TransportRequestOptions, type TxInvalidDetail, UnsupportedRpcValue, classifyReadError, createRpcClient, txInvalidDetail };
1
+ import { $r as RpcDescendingAnchor, Ai as RpcSimulationBatchLimits, Ar as RpcBalanceResult, Bi as RpcTransactionRefPage, Br as RpcBlockStart, Ci as RpcRegisteredAuthResult, Cr as RpcAdmission, Di as RpcSchedulerErrorSource, Dr as RpcAssumedAuth, Ei as RpcSchedulerError, Er as RpcAscendingAnchor, Fi as RpcStorageResult, Fr as RpcBase58_ValidatorID, Gi as isUnsupportedRpcValue, Gr as RpcConflictCode, Hi as RpcTxHash, Hr as RpcChainConfig, Ii as RpcTopicFilter, Ir as RpcBlockClock, Jr as RpcContractDeployment, Kr as RpcConflictDiagnostic, Li as RpcTransactionInputResult, Lr as RpcBlockDriverMode, Mi as RpcSimulationResults, Mr as RpcBase58_Ed25519PublicKey, Ni as RpcStorageCosts, Nr as RpcBase58_PublicKeyHash, Oi as RpcSendTransactionResult, Or as RpcAuthConfiguration, Pi as RpcStorageItem, Pr as RpcBase58_SHA256Hash, Qr as RpcDecimalU64, Ri as RpcTransactionReceipt, Rr as RpcBlockDriverStatus, Si as RpcRecentAttemptFailure, Sr as RpcActiveBlockDriverMode, Ti as RpcResults, Tr as RpcAirdropExecution, Ui as RpcVersionInfo, Ur as RpcChainTip, Vi as RpcTransactionStatus, Vr as RpcBlockTimeStep, Wi as UnsupportedRpcValue, Wr as RpcConfigLimits, Xr as RpcContractRejectCode, Yr as RpcContractDeploymentResult, Zr as RpcDecimalTimePoint, _i as RpcPendingTransactionCount, a as RpcClientOptions, ai as RpcEventPage, bi as RpcPublicKey, c as RpcMethods, ci as RpcFundingSubmission, cn as TransportRequestOptions, di as RpcInvocation, ei as RpcEffectiveContract, fi as RpcInvocationContext, gi as RpcNetworkInfo, hi as RpcIterationOrder, i as RpcClient, ii as RpcEventFilter, ji as RpcSimulationResult, jr as RpcBase58_ContractAddress, ki as RpcServerLimits, kr as RpcAuthSigner, l as createRpcClient, li as RpcHistoryStart, mi as RpcInvocationResult, ni as RpcEmittedEvent, o as RpcDiscovery, oi as RpcExecutionConfig, on as RpcParams, pi as RpcInvocationOutput, qr as RpcContractArtifactResult, ri as RpcErrorData, s as RpcMethod, si as RpcFailureCause, sn as Transport, ti as RpcEffectiveContractResult, ui as RpcIdentifiedEvent, vi as RpcProducedBlock, wi as RpcRequests, wr as RpcAirdropAttempt, xi as RpcReceiptExecution, yi as RpcProducedBlocks, zi as RpcTransactionRef, zr as RpcBlockInfo } from "./requestAirdrop-T1eVn3l5.cjs";
2
+ import { a as classifyReadError, c as HttpTransport, i as ReadErrorKind, l as HttpTransportOptions, n as TxInvalidDetail, o as MockTransport, r as txInvalidDetail, s as HttpBatchOptions, t as NativeRpcErrorCode } from "./index-BGmH_Sm7.cjs";
3
+ export { type HttpBatchOptions, HttpTransport, type HttpTransportOptions, MockTransport, NativeRpcErrorCode, type ReadErrorKind, type RpcActiveBlockDriverMode, type RpcAdmission, type RpcAirdropAttempt, type RpcAirdropExecution, type RpcAscendingAnchor, type RpcAssumedAuth, type RpcAuthConfiguration, type RpcAuthSigner, type RpcBalanceResult, type RpcBase58_ContractAddress, type RpcBase58_Ed25519PublicKey, type RpcBase58_PublicKeyHash, type RpcBase58_SHA256Hash, type RpcBase58_ValidatorID, type RpcBlockClock, type RpcBlockDriverMode, type RpcBlockDriverStatus, type RpcBlockInfo, type RpcBlockStart, type RpcBlockTimeStep, type RpcChainConfig, type RpcChainTip, type RpcClient, type RpcClientOptions, type RpcConfigLimits, type RpcConflictCode, type RpcConflictDiagnostic, type RpcContractArtifactResult, type RpcContractDeployment, type RpcContractDeploymentResult, type RpcContractRejectCode, type RpcDecimalTimePoint, type RpcDecimalU64, type RpcDescendingAnchor, type RpcDiscovery, type RpcEffectiveContract, type RpcEffectiveContractResult, type RpcEmittedEvent, type RpcErrorData, type RpcEventFilter, type RpcEventPage, type RpcExecutionConfig, type RpcFailureCause, type RpcFundingSubmission, type RpcHistoryStart, type RpcIdentifiedEvent, type RpcInvocation, type RpcInvocationContext, type RpcInvocationOutput, type RpcInvocationResult, type RpcIterationOrder, type RpcMethod, type RpcMethods, type RpcNetworkInfo, type RpcParams, type RpcPendingTransactionCount, type RpcProducedBlock, type RpcProducedBlocks, type RpcPublicKey, type RpcReceiptExecution, type RpcRecentAttemptFailure, type RpcRegisteredAuthResult, type RpcRequests, type RpcResults, type RpcSchedulerError, type RpcSchedulerErrorSource, type RpcSendTransactionResult, type RpcServerLimits, type RpcSimulationBatchLimits, type RpcSimulationResult, type RpcSimulationResults, type RpcStorageCosts, type RpcStorageItem, type RpcStorageResult, type RpcTopicFilter, type RpcTransactionInputResult, type RpcTransactionReceipt, type RpcTransactionRef, type RpcTransactionRefPage, type RpcTransactionStatus, type RpcTxHash, type RpcVersionInfo, type Transport, type TransportRequestOptions, type TxInvalidDetail, UnsupportedRpcValue, classifyReadError, createRpcClient, isUnsupportedRpcValue, txInvalidDetail };