@thruputchain/client 0.28.0 → 0.30.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (184) hide show
  1. package/README.md +113 -18
  2. package/dist/actions-B7htk5FS.js +698 -0
  3. package/dist/actions-B7htk5FS.js.map +1 -0
  4. package/dist/actions-CIaI049y.cjs +788 -0
  5. package/dist/actions-CIaI049y.cjs.map +1 -0
  6. package/dist/actions.cjs +5 -8
  7. package/dist/actions.d.cts +4 -4
  8. package/dist/actions.d.ts +4 -4
  9. package/dist/actions.js +3 -3
  10. package/dist/{contract-D77iA2iY.js → contract-BOlNskwd.js} +235 -87
  11. package/dist/contract-BOlNskwd.js.map +1 -0
  12. package/dist/{contract-DSu2UPPm.cjs → contract-D_vxUudr.cjs} +281 -109
  13. package/dist/contract-D_vxUudr.cjs.map +1 -0
  14. package/dist/contract.cjs +1 -5
  15. package/dist/contract.d.cts +3 -4
  16. package/dist/contract.d.ts +3 -4
  17. package/dist/contract.js +2 -2
  18. package/dist/contracts.cjs +5 -5
  19. package/dist/contracts.d.cts +6 -74
  20. package/dist/contracts.d.cts.map +1 -1
  21. package/dist/contracts.d.ts +6 -74
  22. package/dist/contracts.d.ts.map +1 -1
  23. package/dist/contracts.js +4 -4
  24. package/dist/decimal-BX7abv5J.cjs +171 -0
  25. package/dist/decimal-BX7abv5J.cjs.map +1 -0
  26. package/dist/decimal-CoHOISys.js +124 -0
  27. package/dist/decimal-CoHOISys.js.map +1 -0
  28. package/dist/default_wallet-DkqsCa5C.d.ts +90 -0
  29. package/dist/default_wallet-DkqsCa5C.d.ts.map +1 -0
  30. package/dist/default_wallet-Dqs4_iTD.d.cts +90 -0
  31. package/dist/default_wallet-Dqs4_iTD.d.cts.map +1 -0
  32. package/dist/{dev_wallet-CAbOSrak.cjs → dev_wallet-BVChhV6j.cjs} +85 -6
  33. package/dist/dev_wallet-BVChhV6j.cjs.map +1 -0
  34. package/dist/{dev_wallet-CU3RpQLm.js → dev_wallet-D9LuPZ-h.js} +84 -5
  35. package/dist/dev_wallet-D9LuPZ-h.js.map +1 -0
  36. package/dist/{execution-J5jkXhV1.d.cts → execution-pSt6k620.d.cts} +23 -50
  37. package/dist/execution-pSt6k620.d.cts.map +1 -0
  38. package/dist/{execution-XJ0iwFaX.d.ts → execution-uiuFPV0d.d.ts} +23 -50
  39. package/dist/execution-uiuFPV0d.d.ts.map +1 -0
  40. package/dist/{hex-DIcaALXL.js → hex-B8D-jBgz.js} +2 -2
  41. package/dist/{hex-DIcaALXL.js.map → hex-B8D-jBgz.js.map} +1 -1
  42. package/dist/{hex-DkGpiZ5e.cjs → hex-CSDZ9d6z.cjs} +2 -2
  43. package/dist/{hex-DkGpiZ5e.cjs.map → hex-CSDZ9d6z.cjs.map} +1 -1
  44. package/dist/{index-soFVQX9j.d.cts → index-B1efA-Y_.d.ts} +24 -21
  45. package/dist/index-B1efA-Y_.d.ts.map +1 -0
  46. package/dist/{index-C3HVRvQd.d.ts → index-BGmH_Sm7.d.cts} +12 -62
  47. package/dist/index-BGmH_Sm7.d.cts.map +1 -0
  48. package/dist/{index-DeS1S0m-.d.ts → index-BmOG68Hd.d.ts} +39 -17
  49. package/dist/index-BmOG68Hd.d.ts.map +1 -0
  50. package/dist/{index-B5KqSHeL.d.cts → index-BsvYcU_Y.d.cts} +2 -2
  51. package/dist/{index-B5KqSHeL.d.cts.map → index-BsvYcU_Y.d.cts.map} +1 -1
  52. package/dist/{index-CtjZ61tl.d.cts → index-CG-q0j9w.d.ts} +12 -62
  53. package/dist/index-CG-q0j9w.d.ts.map +1 -0
  54. package/dist/index-CPtBvHE8.d.ts +145 -0
  55. package/dist/index-CPtBvHE8.d.ts.map +1 -0
  56. package/dist/{index-DfmDUk5Y.d.ts → index-DBKsOzCN.d.cts} +24 -21
  57. package/dist/index-DBKsOzCN.d.cts.map +1 -0
  58. package/dist/{index-Bb01ytjJ.d.ts → index-Dtv_GV6M.d.ts} +40 -11
  59. package/dist/index-Dtv_GV6M.d.ts.map +1 -0
  60. package/dist/{index-CtjWsAXV.d.cts → index-JKm4TBlY.d.cts} +40 -11
  61. package/dist/index-JKm4TBlY.d.cts.map +1 -0
  62. package/dist/index-Xre-0Jka.d.cts +145 -0
  63. package/dist/index-Xre-0Jka.d.cts.map +1 -0
  64. package/dist/{index-CedOvhGY.d.cts → index-ozfbEuYI.d.cts} +39 -17
  65. package/dist/index-ozfbEuYI.d.cts.map +1 -0
  66. package/dist/index.cjs +40 -68
  67. package/dist/index.cjs.map +1 -1
  68. package/dist/index.d.cts +11 -17
  69. package/dist/index.d.cts.map +1 -1
  70. package/dist/index.d.ts +11 -17
  71. package/dist/index.d.ts.map +1 -1
  72. package/dist/index.js +27 -38
  73. package/dist/index.js.map +1 -1
  74. package/dist/provider.cjs +3 -3
  75. package/dist/provider.cjs.map +1 -1
  76. package/dist/provider.d.cts +2 -1
  77. package/dist/provider.d.ts +2 -1
  78. package/dist/provider.js +3 -3
  79. package/dist/provider.js.map +1 -1
  80. package/dist/{codec-Bxlt1gKO.js → readError-B3Rz7rgs.js} +359 -56
  81. package/dist/readError-B3Rz7rgs.js.map +1 -0
  82. package/dist/{codec-BcK8ASsg.cjs → readError-COcEDNoZ.cjs} +363 -96
  83. package/dist/readError-COcEDNoZ.cjs.map +1 -0
  84. package/dist/requestAirdrop-DBCOST2B.d.ts +1818 -0
  85. package/dist/requestAirdrop-DBCOST2B.d.ts.map +1 -0
  86. package/dist/requestAirdrop-T1eVn3l5.d.cts +1818 -0
  87. package/dist/requestAirdrop-T1eVn3l5.d.cts.map +1 -0
  88. package/dist/sendInvocation-185ZJrta.cjs +583 -0
  89. package/dist/sendInvocation-185ZJrta.cjs.map +1 -0
  90. package/dist/sendInvocation-DBaNWhr3.js +439 -0
  91. package/dist/sendInvocation-DBaNWhr3.js.map +1 -0
  92. package/dist/signed-op.cjs +2 -2
  93. package/dist/signed-op.d.cts +2 -2
  94. package/dist/signed-op.d.ts +1 -1
  95. package/dist/signed-op.js +2 -2
  96. package/dist/{signedOp-DAucp6xg.cjs → signedOp-CVyeJ5ig.cjs} +3 -3
  97. package/dist/{signedOp-DAucp6xg.cjs.map → signedOp-CVyeJ5ig.cjs.map} +1 -1
  98. package/dist/{signedOp-DpmUpH-e.js → signedOp-D6WYZG9j.js} +3 -3
  99. package/dist/{signedOp-DpmUpH-e.js.map → signedOp-D6WYZG9j.js.map} +1 -1
  100. package/dist/{signed_op-_lR85dn2.cjs → signed_op-BBsDKOlD.cjs} +4 -4
  101. package/dist/{signed_op-_lR85dn2.cjs.map → signed_op-BBsDKOlD.cjs.map} +1 -1
  102. package/dist/{signed_op-zGq4eBo8.d.ts → signed_op-DHb4n2JO.d.cts} +3 -3
  103. package/dist/{signed_op-D2usgASc.d.cts.map → signed_op-DHb4n2JO.d.cts.map} +1 -1
  104. package/dist/{signed_op-D2usgASc.d.cts → signed_op-Dfa8WD0j.d.ts} +3 -3
  105. package/dist/{signed_op-zGq4eBo8.d.ts.map → signed_op-Dfa8WD0j.d.ts.map} +1 -1
  106. package/dist/{signed_op-CwN-_CXw.js → signed_op-h9X9-vBL.js} +3 -3
  107. package/dist/{signed_op-CwN-_CXw.js.map → signed_op-h9X9-vBL.js.map} +1 -1
  108. package/dist/transport-BhWZxHcz.cjs +528 -0
  109. package/dist/transport-BhWZxHcz.cjs.map +1 -0
  110. package/dist/transport-EyDYuibb.js +504 -0
  111. package/dist/transport-EyDYuibb.js.map +1 -0
  112. package/dist/transport.cjs +6 -13
  113. package/dist/transport.d.cts +3 -3
  114. package/dist/transport.d.ts +3 -3
  115. package/dist/transport.js +4 -4
  116. package/dist/types-VYjJcTip.d.cts +161 -0
  117. package/dist/types-VYjJcTip.d.cts.map +1 -0
  118. package/dist/types-VYjJcTip.d.ts +161 -0
  119. package/dist/types-VYjJcTip.d.ts.map +1 -0
  120. package/dist/{validation-eXATmgO0.js → validation-BLQ64Dfh.js} +3 -3
  121. package/dist/validation-BLQ64Dfh.js.map +1 -0
  122. package/dist/{validation-4w-vDGAi.cjs → validation-CZqtmMLJ.cjs} +3 -3
  123. package/dist/validation-CZqtmMLJ.cjs.map +1 -0
  124. package/dist/{wallet-BNKgOXrF.js → wallet-NlZiI4-3.js} +161 -77
  125. package/dist/wallet-NlZiI4-3.js.map +1 -0
  126. package/dist/{wallet-7R5M_7h4.cjs → wallet-UvyXtxh5.cjs} +161 -77
  127. package/dist/wallet-UvyXtxh5.cjs.map +1 -0
  128. package/dist/wallet.cjs +2 -8
  129. package/dist/wallet.d.cts +4 -3
  130. package/dist/wallet.d.ts +4 -3
  131. package/dist/wallet.js +3 -3
  132. package/package.json +5 -5
  133. package/dist/actions-B5-CjpEF.cjs +0 -513
  134. package/dist/actions-B5-CjpEF.cjs.map +0 -1
  135. package/dist/actions-C1SMLWO5.js +0 -430
  136. package/dist/actions-C1SMLWO5.js.map +0 -1
  137. package/dist/artifact-BM_MVzhL.d.cts +0 -35
  138. package/dist/artifact-BM_MVzhL.d.cts.map +0 -1
  139. package/dist/artifact-BM_MVzhL.d.ts +0 -35
  140. package/dist/artifact-BM_MVzhL.d.ts.map +0 -1
  141. package/dist/client-jOZxB8yW.d.cts +0 -798
  142. package/dist/client-jOZxB8yW.d.cts.map +0 -1
  143. package/dist/client-jOZxB8yW.d.ts +0 -798
  144. package/dist/client-jOZxB8yW.d.ts.map +0 -1
  145. package/dist/codec-BcK8ASsg.cjs.map +0 -1
  146. package/dist/codec-Bxlt1gKO.js.map +0 -1
  147. package/dist/contract-D77iA2iY.js.map +0 -1
  148. package/dist/contract-DSu2UPPm.cjs.map +0 -1
  149. package/dist/dev_wallet-CAbOSrak.cjs.map +0 -1
  150. package/dist/dev_wallet-CU3RpQLm.js.map +0 -1
  151. package/dist/execution-J5jkXhV1.d.cts.map +0 -1
  152. package/dist/execution-XJ0iwFaX.d.ts.map +0 -1
  153. package/dist/index-Bb01ytjJ.d.ts.map +0 -1
  154. package/dist/index-C3HVRvQd.d.ts.map +0 -1
  155. package/dist/index-CIHK7Ew9.d.cts +0 -303
  156. package/dist/index-CIHK7Ew9.d.cts.map +0 -1
  157. package/dist/index-CIHK7Ew9.d.ts +0 -303
  158. package/dist/index-CIHK7Ew9.d.ts.map +0 -1
  159. package/dist/index-CedOvhGY.d.cts.map +0 -1
  160. package/dist/index-CtjWsAXV.d.cts.map +0 -1
  161. package/dist/index-CtjZ61tl.d.cts.map +0 -1
  162. package/dist/index-DeS1S0m-.d.ts.map +0 -1
  163. package/dist/index-DfmDUk5Y.d.ts.map +0 -1
  164. package/dist/index-soFVQX9j.d.cts.map +0 -1
  165. package/dist/readError-CCVlmBhj.cjs +0 -624
  166. package/dist/readError-CCVlmBhj.cjs.map +0 -1
  167. package/dist/readError-D1dppovI.js +0 -571
  168. package/dist/readError-D1dppovI.js.map +0 -1
  169. package/dist/readViews-DbWELMMq.d.cts +0 -609
  170. package/dist/readViews-DbWELMMq.d.cts.map +0 -1
  171. package/dist/readViews-nV3jbpYc.d.ts +0 -609
  172. package/dist/readViews-nV3jbpYc.d.ts.map +0 -1
  173. package/dist/sendInvocation-Dsr9ij5P.cjs +0 -661
  174. package/dist/sendInvocation-Dsr9ij5P.cjs.map +0 -1
  175. package/dist/sendInvocation-tBmf8haQ.js +0 -505
  176. package/dist/sendInvocation-tBmf8haQ.js.map +0 -1
  177. package/dist/transport-5FPeNwuv.cjs +0 -279
  178. package/dist/transport-5FPeNwuv.cjs.map +0 -1
  179. package/dist/transport-IrhVlS4w.js +0 -261
  180. package/dist/transport-IrhVlS4w.js.map +0 -1
  181. package/dist/validation-4w-vDGAi.cjs.map +0 -1
  182. package/dist/validation-eXATmgO0.js.map +0 -1
  183. package/dist/wallet-7R5M_7h4.cjs.map +0 -1
  184. package/dist/wallet-BNKgOXrF.js.map +0 -1
@@ -1,4 +1,7 @@
1
- import { g as toBase58, i as toHex0x, n as fromHex0x, s as fixedFromBase58 } from "./hex-DIcaALXL.js";
1
+ import { i as UnsupportedRpcValue, o as ThruputError, s as isThruputError, t as parseDecimal } from "./decimal-CoHOISys.js";
2
+ import { g as toBase58, i as toHex0x, n as fromHex0x, s as fixedFromBase58 } from "./hex-B8D-jBgz.js";
3
+ import { t as hashSignedTransaction } from "./transactionHash-CO9ajbvU.js";
4
+ import { codec, deserialize } from "@thruputchain/protocol";
2
5
  //#region src/rpc/schema.json
3
6
  var schema_default = {
4
7
  schemas: {
@@ -11105,55 +11108,30 @@ var schema_default = {
11105
11108
  }
11106
11109
  };
11107
11110
  //#endregion
11108
- //#region src/actions/decimal.ts
11109
- const I64_MAX = (1n << 63n) - 1n;
11110
- const U64_MAX = (1n << 64n) - 1n;
11111
- /** Parse a canonical, range-checked decimal string. Numeric JSON is never accepted. */
11112
- function parseDecimal(value, field, minimum, maximum) {
11113
- if (typeof value !== "string" || value.length > Math.max(minimum.toString().length, maximum.toString().length) || !/^(0|-?[1-9][0-9]*)(?![\s\S])/.test(value)) throw new Error(`Invalid ${field}: expected a canonical decimal string`);
11114
- const parsed = BigInt(value);
11115
- if (parsed < minimum || parsed > maximum) throw new RangeError(`Invalid ${field}: expected an integer from ${minimum} to ${maximum}`);
11116
- return parsed;
11111
+ //#region src/rpc/localError.ts
11112
+ const localErrors = /* @__PURE__ */ new WeakSet();
11113
+ /** Record an error that the client raised before dispatch. */
11114
+ function markLocalError(error) {
11115
+ localErrors.add(error);
11116
+ return error;
11117
11117
  }
11118
- /** Serialize a caller-owned bigint without passing through a JavaScript number. */
11119
- function serializeHeight(value) {
11120
- if (typeof value !== "bigint" || value < 0n || value > I64_MAX) throw new RangeError("height must be a non-negative int64 bigint");
11121
- return value.toString();
11122
- }
11123
- function serializeU64(value, field) {
11124
- if (typeof value !== "bigint" || value < 0n || value > U64_MAX) throw new RangeError(`${field} must be a uint64 bigint`);
11125
- return value.toString();
11118
+ /** True only for an error recorded by {@link markLocalError}. */
11119
+ function isLocalError(error) {
11120
+ return typeof error === "object" && error !== null && localErrors.has(error);
11126
11121
  }
11127
11122
  //#endregion
11128
11123
  //#region src/rpc/codec.ts
11129
- /** An unfamiliar variant is data, never success, absence, or retry permission. */
11130
- var UnsupportedRpcValue = class {
11131
- raw;
11132
- unsupported = true;
11133
- constructor(raw) {
11134
- this.raw = raw;
11135
- }
11136
- };
11137
11124
  /** Malformed known result data, with the complete original result retained. */
11138
- var RpcDecodingError = class extends Error {
11139
- path;
11140
- raw;
11141
- constructor(path, raw) {
11142
- super(`Invalid native RPC value at ${path}`);
11143
- this.path = path;
11144
- this.raw = raw;
11145
- this.name = "RpcDecodingError";
11146
- }
11147
- };
11125
+ function rpcValueInvalid(path, raw) {
11126
+ return new ThruputError("rpcValueInvalid", `Invalid native RPC value at ${path}`, { context: {
11127
+ path,
11128
+ raw
11129
+ } });
11130
+ }
11148
11131
  /** Invalid local input. The transport was not called; this is not retry permission. */
11149
- var RpcRequestValidationError = class extends Error {
11150
- path;
11151
- constructor(path, message = "Invalid native RPC request") {
11152
- super(`${message} at ${path}`);
11153
- this.path = path;
11154
- this.name = "RpcRequestValidationError";
11155
- }
11156
- };
11132
+ function rpcRequestInvalid(path, message = "Invalid native RPC request") {
11133
+ return markLocalError(new ThruputError("rpcRequestInvalid", `${message} at ${path}`, { context: { path } }));
11134
+ }
11157
11135
  const catalog = schema_default;
11158
11136
  const rpcPageMethods = new Set(Object.entries(catalog.methods).filter(([, m]) => m.paged).map(([name]) => name));
11159
11137
  const patterns = /* @__PURE__ */ new Map();
@@ -11166,13 +11144,20 @@ function matches(pattern, text) {
11166
11144
  return regex.test(text);
11167
11145
  }
11168
11146
  const rpcMethodNames = Object.freeze(Object.keys(catalog.methods));
11169
- function record(value) {
11147
+ function record$1(value) {
11170
11148
  return value !== null && typeof value === "object" && !Array.isArray(value);
11171
11149
  }
11150
+ /** Cheap internal decode failure; each boundary converts it to a `ThruputError` once. */
11151
+ var SchemaMismatch = class {
11152
+ path;
11153
+ constructor(path) {
11154
+ this.path = path;
11155
+ }
11156
+ };
11172
11157
  /** The codec implements only the schema forms emitted by the pinned Rust owner. */
11173
11158
  function convert(s, value, encode, path) {
11174
11159
  const fail = () => {
11175
- throw new RpcDecodingError(path, value);
11160
+ throw new SchemaMismatch(path);
11176
11161
  };
11177
11162
  if (s.$ref) {
11178
11163
  const name = s.$ref.split("/").at(-1);
@@ -11203,7 +11188,7 @@ function convert(s, value, encode, path) {
11203
11188
  if (variants) {
11204
11189
  const tag = s["x-tag"];
11205
11190
  if (tag) {
11206
- if (!record(value) || typeof value[tag] !== "string") return fail();
11191
+ if (!record$1(value) || typeof value[tag] !== "string") return fail();
11207
11192
  const variant = variants.find((v) => v.properties[tag].const === value[tag]);
11208
11193
  if (variant) return convert(variant, value, encode, path);
11209
11194
  if (!encode && s["x-extensible"]) return new UnsupportedRpcValue(value);
@@ -11212,7 +11197,7 @@ function convert(s, value, encode, path) {
11212
11197
  for (const variant of variants) try {
11213
11198
  return convert(variant, value, encode, path);
11214
11199
  } catch (error) {
11215
- if (!(error instanceof RpcDecodingError)) throw error;
11200
+ if (!(error instanceof SchemaMismatch)) throw error;
11216
11201
  }
11217
11202
  if (!encode && s["x-extensible"] && typeof value === "string") return new UnsupportedRpcValue(value);
11218
11203
  return fail();
@@ -11234,7 +11219,7 @@ function convert(s, value, encode, path) {
11234
11219
  }
11235
11220
  if (s.type === "null") return value === null ? null : fail();
11236
11221
  if (s.type === "object") {
11237
- if (!record(value) || value instanceof Uint8Array) return fail();
11222
+ if (!record$1(value) || value instanceof Uint8Array) return fail();
11238
11223
  const properties = s.properties ?? {};
11239
11224
  if (s["x-forbidden"]?.some((k) => Object.hasOwn(value, k))) return fail();
11240
11225
  for (const [field, required] of Object.entries(s.dependencies ?? {})) if (Object.hasOwn(value, field) && required.some((k) => !Object.hasOwn(value, k))) return fail();
@@ -11273,10 +11258,10 @@ function encodeRequest(method, value) {
11273
11258
  if (!entry) throw new Error(`Unknown native RPC method ${method}`);
11274
11259
  try {
11275
11260
  const encoded = convert(entry.params, value, true, "/params");
11276
- if (entry.paged && Object.hasOwn(encoded, "start") === Object.hasOwn(encoded, "cursor")) throw new RpcDecodingError("/params", value);
11261
+ if (entry.paged && Object.hasOwn(encoded, "start") === Object.hasOwn(encoded, "cursor")) throw new SchemaMismatch("/params");
11277
11262
  return encoded;
11278
11263
  } catch (error) {
11279
- if (error instanceof RpcDecodingError) throw new RpcRequestValidationError(error.path);
11264
+ if (error instanceof SchemaMismatch) throw rpcRequestInvalid(error.path);
11280
11265
  throw error;
11281
11266
  }
11282
11267
  }
@@ -11286,17 +11271,335 @@ function decodeResult(method, value) {
11286
11271
  try {
11287
11272
  return convert(entry.result, value, false, "/result");
11288
11273
  } catch (error) {
11289
- if (error instanceof RpcDecodingError) throw new RpcDecodingError(error.path, value);
11274
+ if (error instanceof SchemaMismatch) throw rpcValueInvalid(error.path, value);
11290
11275
  throw error;
11291
11276
  }
11292
11277
  }
11293
11278
  /** Method/code membership and structural evidence; relational identity checks live in the reader. */
11294
11279
  function decodeErrorData(method, code, value) {
11295
11280
  const entry = catalog.errors[method]?.find((entry) => entry.code === code);
11296
- if (!entry) throw new RpcDecodingError("/error", value);
11297
- return convert(entry.schema, value, false, "/error/data");
11281
+ if (!entry) throw rpcValueInvalid("/error", value);
11282
+ try {
11283
+ return convert(entry.schema, value, false, "/error/data");
11284
+ } catch (error) {
11285
+ if (error instanceof SchemaMismatch) throw rpcValueInvalid(error.path, value);
11286
+ throw error;
11287
+ }
11288
+ }
11289
+ //#endregion
11290
+ //#region src/rpc/errorReader.ts
11291
+ const record = (value) => value !== null && typeof value === "object" && !Array.isArray(value);
11292
+ const equal$1 = (a, b) => a.length === b.length && a.every((v, i) => v === b[i]);
11293
+ /**
11294
+ * Classifies method-specific causes without granting retries. Unknown, malformed,
11295
+ * or contradictory evidence stays unclassified with the complete raw error.
11296
+ * Supply the locally computed/requested hash to bind admission or observation evidence.
11297
+ */
11298
+ function decodeRpcError(method, raw, expectedTransactionHash) {
11299
+ const unclassified = () => ({
11300
+ classification: "unclassified",
11301
+ raw
11302
+ });
11303
+ if (!record(raw) || typeof raw.code !== "number" || !Number.isInteger(raw.code) || raw.code < -2147483648 || raw.code > 2147483647 || typeof raw.message !== "string") return unclassified();
11304
+ try {
11305
+ const data = decodeErrorData(method, raw.code, raw.data);
11306
+ if (!validFunding(data)) return unclassified();
11307
+ if (expectedTransactionHash) {
11308
+ if (method === "sendTransaction" && "transactionHash" in data && data.transactionHash && !equal$1(data.transactionHash, expectedTransactionHash)) return unclassified();
11309
+ if (method === "getTransactionReceipt" && "observation" in data && data.observation && !equal$1(data.observation.transactionHash, expectedTransactionHash)) return unclassified();
11310
+ }
11311
+ return {
11312
+ classification: "known",
11313
+ data,
11314
+ raw
11315
+ };
11316
+ } catch (error) {
11317
+ if (isThruputError(error, "rpcValueInvalid")) return unclassified();
11318
+ throw error;
11319
+ }
11320
+ }
11321
+ function validFunding(data) {
11322
+ if (data.kind !== "fundingAttemptStopped" && data.kind !== "localFundingUnresolved") return true;
11323
+ if (data.signedTransaction) try {
11324
+ if (!data.transactionHash || !equal$1(hashSignedTransaction(deserialize(data.signedTransaction, codec.SignedTransaction)), data.transactionHash)) return false;
11325
+ } catch {
11326
+ return false;
11327
+ }
11328
+ if (data.kind === "fundingAttemptStopped") return !data.receipt || !!data.transactionHash && equal$1(data.receipt.transactionHash, data.transactionHash);
11329
+ if (data.cause) {
11330
+ if (!validFunding(data.cause)) return false;
11331
+ if (data.cause.transactionHash && !equal$1(data.cause.transactionHash, data.transactionHash)) return false;
11332
+ if (data.cause.signedTransaction && !equal$1(data.cause.signedTransaction, data.signedTransaction)) return false;
11333
+ }
11334
+ return true;
11335
+ }
11336
+ /**
11337
+ * Wrap a JSON-RPC error from a native method. Keep the complete raw error and a
11338
+ * conservative typed reading; unknown or contradictory evidence is `unrecognized`.
11339
+ */
11340
+ function nativeRpcError(error, method, expectedTransactionHash) {
11341
+ const raw = record(error.raw) ? error.raw : {
11342
+ ...typeof error.code === "number" ? { code: error.code } : {},
11343
+ ...typeof error.rpcMessage === "string" ? { message: error.rpcMessage } : {},
11344
+ ...error.data === void 0 ? {} : { data: error.data }
11345
+ };
11346
+ const decoded = decodeRpcError(method, raw, expectedTransactionHash);
11347
+ return new ThruputError("nativeRpcError", `${method}: ${error.rpcMessage} (RPC ${error.code})`, { context: {
11348
+ code: error.code,
11349
+ rpcMessage: error.rpcMessage,
11350
+ method,
11351
+ raw,
11352
+ ...decoded.classification === "known" ? {
11353
+ kind: decoded.data.kind,
11354
+ data: decoded.data
11355
+ } : { kind: "unrecognized" }
11356
+ } });
11357
+ }
11358
+ //#endregion
11359
+ //#region src/rpc/client.ts
11360
+ /**
11361
+ * The endpoint, network, or method set does not match what the client requires.
11362
+ * Raised by a local check, so it proves that the request was not dispatched.
11363
+ */
11364
+ function rpcIncompatible(kind, message) {
11365
+ return markLocalError(new ThruputError("rpcIncompatible", message, { context: { kind } }));
11366
+ }
11367
+ const equal = (a, b) => a.length === b.length && a.every((v, i) => v === b[i]);
11368
+ /**
11369
+ * Connect a native wire-14 client. This layer reads once or sends once; it does
11370
+ * not sign, poll, retry, refresh discovery on failure, or switch wire formats.
11371
+ * Unknown response variants are UnsupportedRpcValue objects retaining raw data.
11372
+ */
11373
+ async function createRpcClient(options) {
11374
+ const transport = options.transport;
11375
+ const expected = options.expectedNetworkHash ? new Uint8Array(options.expectedNetworkHash) : void 0;
11376
+ if (expected && expected.length !== 32) throw new RangeError("expectedNetworkHash must have 32 bytes");
11377
+ const required = [...options.requiredMethods ?? []];
11378
+ let discovery;
11379
+ let configured = /* @__PURE__ */ new Set();
11380
+ const requireMethods = (methods) => {
11381
+ for (const method of methods) if (!configured.has(method)) throw rpcIncompatible("method", `Endpoint does not advertise ${method}`);
11382
+ };
11383
+ const requestOnce = async (method, params, control, hash) => {
11384
+ try {
11385
+ return await transport.request(method, params, control);
11386
+ } catch (error) {
11387
+ if (isThruputError(error, "rpcError")) throw nativeRpcError(error.context, method, hash);
11388
+ throw error;
11389
+ }
11390
+ };
11391
+ const read = async (method, control) => decodeResult(method, await requestOnce(method, {}, control));
11392
+ const refreshDiscovery = async (control) => {
11393
+ const version = await read("getVersionInfo", control);
11394
+ if (!/^14\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)$/.test(version.wireFormat)) throw rpcIncompatible("wireVersion", `Unsupported RPC wire format ${version.wireFormat}`);
11395
+ const methods = new Set(version.supportedMethods);
11396
+ for (const method of [
11397
+ "getVersionInfo",
11398
+ "getNetworkInfo",
11399
+ ...required
11400
+ ]) if (!methods.has(method)) throw rpcIncompatible("method", `Endpoint does not advertise ${method}`);
11401
+ const network = await read("getNetworkInfo", control);
11402
+ const wanted = expected ?? discovery?.network.networkHash;
11403
+ if (wanted && !equal(wanted, network.networkHash)) throw rpcIncompatible("network", "RPC network identity does not match");
11404
+ const limits = methods.has("getServerLimits") ? await read("getServerLimits", control) : void 0;
11405
+ discovery = {
11406
+ version,
11407
+ network,
11408
+ ...limits ? { limits } : {}
11409
+ };
11410
+ configured = methods;
11411
+ return structuredClone(discovery);
11412
+ };
11413
+ await refreshDiscovery({ signal: options.signal });
11414
+ const methods = Object.fromEntries(rpcMethodNames.map((name) => [name, async (request = {}, control) => {
11415
+ const method = name;
11416
+ control?.signal?.throwIfAborted();
11417
+ requireMethods([method]);
11418
+ const params = encodeRequest(method, request);
11419
+ const input = structuredClone(request);
11420
+ const limits = discovery.limits;
11421
+ checkLimits(method, input, limits);
11422
+ let submittedHash;
11423
+ if (method === "sendTransaction") try {
11424
+ submittedHash = hashSignedTransaction(deserialize(input.signedTransaction, codec.SignedTransaction));
11425
+ } catch {
11426
+ throw rpcRequestInvalid("/params/signedTransaction", "Invalid signed transaction XDR");
11427
+ }
11428
+ const raw = await requestOnce(method, params, control, submittedHash ?? (method === "getTransactionReceipt" ? input.transactionHash : void 0));
11429
+ const result = decodeResult(method, raw);
11430
+ checkResult(method, input, result, raw, submittedHash, limits, discovery.network.networkHash);
11431
+ return result;
11432
+ }]));
11433
+ return Object.defineProperty(Object.assign(methods, {
11434
+ refreshDiscovery,
11435
+ requireMethods
11436
+ }), "discovery", {
11437
+ get: () => structuredClone(discovery),
11438
+ enumerable: true
11439
+ });
11440
+ }
11441
+ function checkLimits(method, input, limits) {
11442
+ if (rpcPageMethods.has(method)) {
11443
+ if (!limits) throw rpcIncompatible("limits", "History calls require advertised server limits");
11444
+ const cap = method === "getEvents" ? limits.maxEventsPerPage : limits.maxTransactionsPerPage;
11445
+ if (input.limit !== void 0 && input.limit > cap) throw rpcRequestInvalid("/params/limit", `limit exceeds endpoint cap ${cap}`);
11446
+ if (typeof input.cursor === "string" && BigInt((input.cursor.length - 2) / 2) > limits.maxCursorBytes) throw rpcRequestInvalid("/params/cursor", "cursor exceeds endpoint cap");
11447
+ }
11448
+ if (method === "simulateInvocation" || method === "simulateInvocations") {
11449
+ if (!limits) throw rpcIncompatible("limits", "Simulation calls require advertised server limits");
11450
+ const calls = method === "simulateInvocation" ? [input] : input.invocations;
11451
+ let gas = 0n, bytes = 0;
11452
+ for (const call of calls) {
11453
+ const callGas = call.gasLimit;
11454
+ if (callGas !== void 0 && callGas > limits.maxSimulationGas) throw rpcRequestInvalid("/params/gasLimit", "gasLimit exceeds endpoint cap");
11455
+ const size = call.calldata.length;
11456
+ if (BigInt(size) > limits.maxSimulationCalldataBytes) throw rpcRequestInvalid("/params/calldata", "calldata exceeds endpoint cap");
11457
+ gas += callGas ?? limits.maxSimulationGas;
11458
+ bytes += size;
11459
+ }
11460
+ if (method === "simulateInvocations") {
11461
+ const batch = limits.simulationBatch;
11462
+ if (!batch) throw rpcIncompatible("limits", "Batch simulation limits are unavailable");
11463
+ if (calls.length > batch.maxInvocations || bytes > batch.maxCalldataBytes || gas > batch.maxGas) throw rpcRequestInvalid("/params/invocations", "simulation batch exceeds endpoint cap");
11464
+ }
11465
+ }
11466
+ }
11467
+ /**
11468
+ * Local block and time results must match their own request: a pinned
11469
+ * timepoint comes back exactly, a multi-block request returns `count`
11470
+ * blocks, a step change reports the requested step (none when cleared), and a
11471
+ * mode change reports the requested mode and interval.
11472
+ */
11473
+ function checkBlockControlResult(method, input, value, invalid) {
11474
+ if (method === "dev_produceBlock") {
11475
+ const block = value;
11476
+ if (block.blockHeight <= 0n || input.blockTimepoint !== void 0 && block.blockTimepoint !== input.blockTimepoint) invalid();
11477
+ }
11478
+ if (method === "dev_produceBlocks" && value.blocks.length !== input.count) invalid();
11479
+ if (method === "dev_setNextBlockTimepoint" && value.nextBlockTimepoint !== input.blockTimepoint) invalid();
11480
+ if (method === "dev_setBlockTimeStep" && value.stepNanoseconds !== input.stepNanoseconds) invalid();
11481
+ if (method === "dev_setBlockDriver") {
11482
+ const status = value;
11483
+ if (typeof status.mode === "string" && status.mode !== input.mode || input.intervalMilliseconds !== void 0 && status.intervalMilliseconds !== input.intervalMilliseconds) invalid();
11484
+ }
11485
+ }
11486
+ function checkResult(method, input, value, raw, submittedHash, limits, networkHash) {
11487
+ const invalid = () => {
11488
+ throw rpcValueInvalid("/result", raw);
11489
+ };
11490
+ if (value === null) return;
11491
+ const result = value;
11492
+ if (method === "getTransactionReceipt" && !equal(result.transactionHash, input.transactionHash) || submittedHash && !equal(result.transactionHash, submittedHash)) invalid();
11493
+ if (method === "getBlockByHeight" && (result.blockHeight <= 0n || result.blockHeight !== input.blockHeight || !equal(result.networkHash, networkHash))) invalid();
11494
+ if ((method === "getBalance" || method === "getRegisteredAuth") && !equal(result.address, input.address)) invalid();
11495
+ if (method === "simulateInvocations" && result.results.length !== input.invocations.length) invalid();
11496
+ if ((method === "simulateInvocation" || method === "simulateInvocations") && input.minStateBlockHeight !== void 0 && result.stateBlockHeight < input.minStateBlockHeight) invalid();
11497
+ if (method === "dev_fundAccount") {
11498
+ const funding = value;
11499
+ try {
11500
+ if (!equal(funding.recipient, input.recipient) || funding.rawAmount !== input.rawAmount || !equal(funding.transactionHash, hashSignedTransaction(deserialize(funding.signedTransaction, codec.SignedTransaction)))) invalid();
11501
+ } catch {
11502
+ invalid();
11503
+ }
11504
+ }
11505
+ checkBlockControlResult(method, input, value, invalid);
11506
+ if (method === "faucet_requestAirdrop" && "recipient" in result && !equal(result.recipient, input.recipient)) invalid();
11507
+ if (!rpcPageMethods.has(method)) return;
11508
+ const page = value;
11509
+ const entries = method === "getEvents" ? page.events : page.transactions;
11510
+ const cap = method === "getEvents" ? limits.maxEventsPerPage : limits.maxTransactionsPerPage;
11511
+ if (page.oldestIndexedBlockHeight > page.latestIndexedBlockHeight || entries.length > (input.limit ?? Math.min(50, cap)) || page.nextCursor !== null && (page.nextCursor === input.cursor || BigInt((page.nextCursor.length - 2) / 2) > limits.maxCursorBytes)) invalid();
11512
+ if (entries.some((entry) => entry.blockHeight < page.oldestIndexedBlockHeight || entry.blockHeight > page.latestIndexedBlockHeight)) invalid();
11513
+ const start = input.start;
11514
+ if (method === "getTransactionsByBlock") {
11515
+ if (page.oldestIndexedBlockHeight < 1n || !entries.length && page.nextCursor !== null || input.cursor !== void 0 && (input.blockHeight < page.oldestIndexedBlockHeight || input.blockHeight > page.latestIndexedBlockHeight) || entries.some((entry) => entry.blockHeight !== input.blockHeight)) invalid();
11516
+ } else if (start?.anchor.kind === "atHeight") {
11517
+ const anchor = start.anchor.blockHeight;
11518
+ if (anchor < page.oldestIndexedBlockHeight || entries.some((entry) => start.order === "ascending" ? entry.blockHeight < anchor : entry.blockHeight > anchor)) invalid();
11519
+ }
11520
+ const identities = /* @__PURE__ */ new Set();
11521
+ const keys = [];
11522
+ for (const [index, entry] of entries.entries()) {
11523
+ const event = method === "getEvents" ? page.events[index] : void 0;
11524
+ const hash = toHex0x(entry.transactionHash);
11525
+ const sequence = event?.sequenceNumber ?? 0;
11526
+ const identity = method === "getEvents" ? `${hash}/${sequence}` : hash;
11527
+ if (identities.has(identity)) invalid();
11528
+ identities.add(identity);
11529
+ keys.push([
11530
+ entry.blockHeight,
11531
+ hash,
11532
+ sequence
11533
+ ]);
11534
+ if (event && !input.filters.some((filter) => filter.addresses.some((address) => equal(address, event.event.address)) && [
11535
+ "topic0",
11536
+ "topic1",
11537
+ "topic2"
11538
+ ].every((key, i) => {
11539
+ const values = filter.topics?.[key];
11540
+ return !values?.length || !!event.event.topics[i] && values.some((topic) => equal(topic, event.event.topics[i]));
11541
+ }))) invalid();
11542
+ }
11543
+ const compare = (left, right) => {
11544
+ for (let i = 0; i < 3; i++) {
11545
+ if (left[i] < right[i]) return -1;
11546
+ if (left[i] > right[i]) return 1;
11547
+ }
11548
+ return 0;
11549
+ };
11550
+ const asc = keys.every((key, i) => i === 0 || compare(keys[i - 1], key) < 0);
11551
+ const desc = keys.every((key, i) => i === 0 || compare(keys[i - 1], key) > 0);
11552
+ if (!(start ? start.order === "ascending" ? asc : desc : asc || desc)) invalid();
11553
+ }
11554
+ //#endregion
11555
+ //#region src/transport/readError.ts
11556
+ /**
11557
+ * Classify an infrastructure read failure without replacing the original error.
11558
+ *
11559
+ * Pass the caller's signal to distinguish explicit cancellation from a transport
11560
+ * timeout. Plain Error wrappers are inspected through their causes; other
11561
+ * `ThruputError` codes and unrecognized failures remain unknown. A bare TypeError
11562
+ * is not evidence of a network failure. Custom transports should throw code
11563
+ * `httpRequestFailed` for that case. Transaction-not-found remains
11564
+ * operation-specific rather than a general retry. This classification never
11565
+ * authorizes transaction resubmission.
11566
+ */
11567
+ function classifyReadError(error, options = {}) {
11568
+ if (options.signal?.aborted) return "cancelled";
11569
+ const seen = /* @__PURE__ */ new Set();
11570
+ while (error !== null && typeof error === "object" && !seen.has(error)) {
11571
+ seen.add(error);
11572
+ if (isThruputError(error, "httpRequestFailed")) return "transient";
11573
+ if (isThruputError(error, "httpResponseError")) return [
11574
+ 408,
11575
+ 429,
11576
+ 500,
11577
+ 502,
11578
+ 503,
11579
+ 504
11580
+ ].includes(error.context.status) ? "transient" : "permanent";
11581
+ if (isThruputError(error, "nativeRpcError")) switch (error.context.kind) {
11582
+ case "backendUnavailable":
11583
+ case "stateHeightUnavailable":
11584
+ case "backendTimeout":
11585
+ case "overloaded": return "transient";
11586
+ case "invalidParams":
11587
+ case "invalidCursor":
11588
+ case "transactionInvalid":
11589
+ case "transactionRejected":
11590
+ case "historyUnavailable": return "permanent";
11591
+ default: return "unknown";
11592
+ }
11593
+ if ("name" in error) {
11594
+ if (error.name === "TimeoutError") return "transient";
11595
+ if (error.name === "AbortError") return "cancelled";
11596
+ }
11597
+ if (!(error instanceof Error) || error.constructor !== Error) return "unknown";
11598
+ error = error.cause;
11599
+ }
11600
+ return "unknown";
11298
11601
  }
11299
11602
  //#endregion
11300
- export { decodeResult as a, rpcPageMethods as c, decodeErrorData as i, serializeHeight as l, RpcRequestValidationError as n, encodeRequest as o, UnsupportedRpcValue as r, rpcMethodNames as s, RpcDecodingError as t, serializeU64 as u };
11603
+ export { isLocalError as i, createRpcClient as n, rpcIncompatible as r, classifyReadError as t };
11301
11604
 
11302
- //# sourceMappingURL=codec-Bxlt1gKO.js.map
11605
+ //# sourceMappingURL=readError-B3Rz7rgs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"readError-B3Rz7rgs.js","names":["schema","record","equal"],"sources":["../src/rpc/schema.json","../src/rpc/localError.ts","../src/rpc/codec.ts","../src/rpc/errorReader.ts","../src/rpc/client.ts","../src/transport/readError.ts"],"sourcesContent":["","// Errors that this copy of the package raised before it dispatched a request.\n// Only these prove that a request was not sent: a transport, or another copy of\n// the package, can throw an error with the same code after it sent one.\nconst localErrors = new WeakSet<object>();\n\n/** Record an error that the client raised before dispatch. */\nexport function markLocalError<T extends object>(error: T): T {\n localErrors.add(error);\n return error;\n}\n\n/** True only for an error recorded by {@link markLocalError}. */\nexport function isLocalError(error: unknown): boolean {\n return typeof error === \"object\" && error !== null && localErrors.has(error);\n}\n","import schema from \"./schema.json\" with { type: \"json\" };\nimport { fixedFromBase58, toBase58 } from \"../encoding.js\";\nimport { fromHex0x, toHex0x } from \"../actions/hex.js\";\nimport { parseDecimal } from \"../actions/decimal.js\";\nimport { ThruputError } from \"../errors/thruputError.js\";\nimport { UnsupportedRpcValue } from \"./unsupported.js\";\nimport { markLocalError } from \"./localError.js\";\n\nexport { UnsupportedRpcValue, isUnsupportedRpcValue } from \"./unsupported.js\";\n\n/** Malformed known result data, with the complete original result retained. */\nexport function rpcValueInvalid(\n path: string,\n raw: unknown,\n): ThruputError<\"rpcValueInvalid\"> {\n return new ThruputError(\n \"rpcValueInvalid\",\n `Invalid native RPC value at ${path}`,\n { context: { path, raw } },\n );\n}\n\n/** Invalid local input. The transport was not called; this is not retry permission. */\nexport function rpcRequestInvalid(\n path: string,\n message = \"Invalid native RPC request\",\n): ThruputError<\"rpcRequestInvalid\"> {\n return markLocalError(\n new ThruputError(\"rpcRequestInvalid\", `${message} at ${path}`, {\n context: { path },\n }),\n );\n}\n\ninterface Schema {\n $ref?: string;\n \"x-tag\"?: string;\n \"x-extensible\"?: boolean;\n \"x-base58-bytes\"?: number;\n \"x-opaque-string\"?: boolean;\n \"x-forbidden\"?: string[];\n dependencies?: Record<string, string[]>;\n const?: unknown;\n enum?: unknown[];\n type?: string;\n properties?: Record<string, Schema>;\n required?: string[];\n additionalProperties?: boolean;\n items?: Schema;\n anyOf?: Schema[];\n oneOf?: Schema[];\n minimum?: number;\n maximum?: number;\n minLength?: number;\n maxLength?: number;\n minItems?: number;\n maxItems?: number;\n pattern?: string;\n \"x-integer-minimum\"?: string;\n \"x-integer-maximum\"?: string;\n}\nconst catalog = schema as unknown as {\n schemas: Record<string, Schema>;\n methods: Record<string, { params: Schema; result: Schema; paged: boolean }>;\n errors: Record<string, { code: number; schema: Schema }[]>;\n};\n\nexport const rpcPageMethods = new Set(\n Object.entries(catalog.methods)\n .filter(([, m]) => m.paged)\n .map(([name]) => name),\n);\nconst patterns = new Map<string, RegExp>();\nfunction matches(pattern: string, text: string) {\n let regex = patterns.get(pattern);\n if (!regex) {\n regex = new RegExp(pattern);\n patterns.set(pattern, regex);\n }\n return regex.test(text);\n}\nexport const rpcMethodNames = Object.freeze(Object.keys(catalog.methods));\n\nfunction record(value: unknown): value is Record<string, unknown> {\n return value !== null && typeof value === \"object\" && !Array.isArray(value);\n}\n\n/** Cheap internal decode failure; each boundary converts it to a `ThruputError` once. */\nclass SchemaMismatch {\n constructor(readonly path: string) {}\n}\n\n/** The codec implements only the schema forms emitted by the pinned Rust owner. */\nfunction convert(\n s: Schema,\n value: unknown,\n encode: boolean,\n path: string,\n): unknown {\n const fail = (): never => {\n throw new SchemaMismatch(path);\n };\n if (s.$ref) {\n const name = s.$ref.split(\"/\").at(-1)!;\n const target = catalog.schemas[name];\n if (!target) throw new Error(`Missing generated RPC schema ${name}`);\n return convert(target, value, encode, path);\n }\n if (s[\"x-base58-bytes\"] !== undefined) {\n if (encode) {\n if (\n !(value instanceof Uint8Array) ||\n value.length !== s[\"x-base58-bytes\"]\n )\n return fail();\n return toBase58(value);\n }\n if (typeof value !== \"string\") return fail();\n try {\n const bytes = fixedFromBase58(value, s[\"x-base58-bytes\"]);\n if (toBase58(bytes) !== value) return fail();\n return bytes;\n } catch {\n return fail();\n }\n }\n if (s.const !== undefined) return value === s.const ? value : fail();\n if (s.enum) {\n if (s.enum.includes(value)) return value;\n return fail();\n }\n const variants = s.oneOf ?? s.anyOf;\n if (variants) {\n const tag = s[\"x-tag\"];\n if (tag) {\n if (!record(value) || typeof value[tag] !== \"string\") return fail();\n const variant = variants.find(\n (v) => v.properties![tag]!.const === value[tag],\n );\n if (variant) return convert(variant, value, encode, path);\n if (!encode && s[\"x-extensible\"]) return new UnsupportedRpcValue(value);\n return fail();\n }\n for (const variant of variants) {\n try {\n return convert(variant, value, encode, path);\n } catch (error) {\n if (!(error instanceof SchemaMismatch)) throw error;\n }\n }\n if (!encode && s[\"x-extensible\"] && typeof value === \"string\")\n return new UnsupportedRpcValue(value);\n return fail();\n }\n if (s[\"x-integer-minimum\"] !== undefined) {\n const minimum = BigInt(s[\"x-integer-minimum\"]);\n const maximum = BigInt(s[\"x-integer-maximum\"]!);\n // A pattern can be stricter than the numeric bounds, such as a positive\n // interval whose minimum is still \"0\". Check both.\n const allowed = (text: string) =>\n s.pattern === undefined || matches(s.pattern, text);\n if (encode) {\n if (\n typeof value !== \"bigint\" ||\n value < minimum ||\n value > maximum ||\n !allowed(value.toString())\n )\n return fail();\n return value.toString();\n }\n if (typeof value === \"string\" && !allowed(value)) return fail();\n try {\n return parseDecimal(value, path, minimum, maximum);\n } catch {\n return fail();\n }\n }\n if (s.type === \"null\") return value === null ? null : fail();\n if (s.type === \"object\") {\n if (!record(value) || value instanceof Uint8Array) return fail();\n const properties = s.properties ?? {};\n if (s[\"x-forbidden\"]?.some((k) => Object.hasOwn(value, k))) return fail();\n for (const [field, required] of Object.entries(s.dependencies ?? {}))\n if (\n Object.hasOwn(value, field) &&\n required.some((k) => !Object.hasOwn(value, k))\n )\n return fail();\n for (const required of s.required ?? [])\n if (!Object.hasOwn(value, required) || value[required] === undefined)\n return fail();\n // Responses retain additive fields. Requests cannot silently ignore typos.\n if (encode && Object.keys(value).some((k) => !Object.hasOwn(properties, k)))\n return fail();\n const result: Record<string, unknown> = encode ? {} : { ...value };\n for (const [k, child] of Object.entries(properties)) {\n if (Object.hasOwn(value, k) && value[k] !== undefined)\n result[k] = convert(child, value[k], encode, `${path}/${k}`);\n }\n return result;\n }\n if (s.type === \"array\") {\n if (\n !Array.isArray(value) ||\n value.length < (s.minItems ?? 0) ||\n value.length > (s.maxItems ?? Infinity)\n )\n return fail();\n return value.map((v, i) => convert(s.items!, v, encode, `${path}/${i}`));\n }\n if (s.type === \"integer\" || s.type === \"number\") {\n if (\n typeof value !== \"number\" ||\n !Number.isSafeInteger(value) ||\n value < (s.minimum ?? -Infinity) ||\n value > (s.maximum ?? Infinity)\n )\n return fail();\n return value;\n }\n if (s.type === \"string\") {\n const hex = s.pattern?.startsWith(\"^0x\");\n const cursor = s[\"x-opaque-string\"];\n let text = value;\n if (encode && hex && !cursor) {\n if (!(value instanceof Uint8Array)) return fail();\n text = toHex0x(value);\n }\n let length = 0;\n if (\n typeof text === \"string\" &&\n (s.minLength !== undefined || s.maxLength !== undefined)\n )\n for (const _ of text) length++;\n if (\n typeof text !== \"string\" ||\n /[\\uD800-\\uDFFF]/u.test(text) ||\n length < (s.minLength ?? 0) ||\n length > (s.maxLength ?? Infinity) ||\n (s.pattern && !matches(s.pattern, text))\n )\n return fail();\n return !encode && hex && !cursor ? fromHex0x(text) : text;\n }\n if (s.type === \"boolean\") return typeof value === \"boolean\" ? value : fail();\n throw new Error(`Unsupported generated RPC schema at ${path}`);\n}\n\nexport function encodeRequest(\n method: string,\n value: unknown,\n): Record<string, unknown> {\n const entry = catalog.methods[method];\n if (!entry) throw new Error(`Unknown native RPC method ${method}`);\n try {\n const encoded = convert(entry.params, value, true, \"/params\") as Record<\n string,\n unknown\n >;\n if (\n entry.paged &&\n Object.hasOwn(encoded, \"start\") === Object.hasOwn(encoded, \"cursor\")\n )\n throw new SchemaMismatch(\"/params\");\n return encoded;\n } catch (error) {\n if (error instanceof SchemaMismatch) throw rpcRequestInvalid(error.path);\n throw error;\n }\n}\n\nexport function decodeResult(method: string, value: unknown): unknown {\n const entry = catalog.methods[method];\n if (!entry) throw new Error(`Unknown native RPC method ${method}`);\n try {\n return convert(entry.result, value, false, \"/result\");\n } catch (error) {\n if (error instanceof SchemaMismatch)\n throw rpcValueInvalid(error.path, value);\n throw error;\n }\n}\n\n/** Method/code membership and structural evidence; relational identity checks live in the reader. */\nexport function decodeErrorData(\n method: string,\n code: number,\n value: unknown,\n): unknown {\n const entry = catalog.errors[method]?.find((entry) => entry.code === code);\n if (!entry) throw rpcValueInvalid(\"/error\", value);\n try {\n return convert(entry.schema, value, false, \"/error/data\");\n } catch (error) {\n if (error instanceof SchemaMismatch)\n throw rpcValueInvalid(error.path, value);\n throw error;\n }\n}\n","import { codec, deserialize } from \"@thruputchain/protocol\";\nimport { hashSignedTransaction } from \"../derivation/transactionHash.js\";\nimport type { RpcErrorFields } from \"../errors/codes.js\";\nimport { isThruputError, ThruputError } from \"../errors/thruputError.js\";\nimport { decodeErrorData } from \"./codec.js\";\nimport type { RpcErrorData } from \"./generated.js\";\n\nexport type DecodedRpcError =\n | { classification: \"known\"; data: RpcErrorData; raw: unknown }\n | { classification: \"unclassified\"; raw: unknown };\n\nconst record = (value: unknown): value is Record<string, unknown> =>\n value !== null && typeof value === \"object\" && !Array.isArray(value);\nconst equal = (a: Uint8Array, b: Uint8Array) =>\n a.length === b.length && a.every((v, i) => v === b[i]);\n\n/**\n * Classifies method-specific causes without granting retries. Unknown, malformed,\n * or contradictory evidence stays unclassified with the complete raw error.\n * Supply the locally computed/requested hash to bind admission or observation evidence.\n */\nexport function decodeRpcError(\n method: string,\n raw: unknown,\n expectedTransactionHash?: Uint8Array,\n): DecodedRpcError {\n const unclassified = (): DecodedRpcError => ({\n classification: \"unclassified\",\n raw,\n });\n if (\n !record(raw) ||\n typeof raw.code !== \"number\" ||\n !Number.isInteger(raw.code) ||\n raw.code < -2147483648 ||\n raw.code > 2147483647 ||\n typeof raw.message !== \"string\"\n )\n return unclassified();\n try {\n const data = decodeErrorData(method, raw.code, raw.data) as RpcErrorData;\n if (!validFunding(data)) return unclassified();\n if (expectedTransactionHash) {\n if (\n method === \"sendTransaction\" &&\n \"transactionHash\" in data &&\n data.transactionHash &&\n !equal(data.transactionHash, expectedTransactionHash)\n )\n return unclassified();\n if (\n method === \"getTransactionReceipt\" &&\n \"observation\" in data &&\n data.observation &&\n !equal(data.observation.transactionHash, expectedTransactionHash)\n )\n return unclassified();\n }\n return { classification: \"known\", data, raw };\n } catch (error) {\n if (isThruputError(error, \"rpcValueInvalid\")) return unclassified();\n throw error;\n }\n}\n\nfunction validFunding(data: RpcErrorData): boolean {\n if (\n data.kind !== \"fundingAttemptStopped\" &&\n data.kind !== \"localFundingUnresolved\"\n )\n return true;\n if (data.signedTransaction) {\n try {\n if (\n !data.transactionHash ||\n !equal(\n hashSignedTransaction(\n deserialize(data.signedTransaction, codec.SignedTransaction),\n ),\n data.transactionHash,\n )\n )\n return false;\n } catch {\n return false;\n }\n }\n if (data.kind === \"fundingAttemptStopped\")\n return (\n !data.receipt ||\n (!!data.transactionHash &&\n equal(data.receipt.transactionHash, data.transactionHash))\n );\n if (data.cause) {\n if (!validFunding(data.cause)) return false;\n if (\n data.cause.transactionHash &&\n !equal(data.cause.transactionHash, data.transactionHash)\n )\n return false;\n if (\n data.cause.signedTransaction &&\n !equal(data.cause.signedTransaction, data.signedTransaction)\n )\n return false;\n }\n return true;\n}\n\n/**\n * Wrap a JSON-RPC error from a native method. Keep the complete raw error and a\n * conservative typed reading; unknown or contradictory evidence is `unrecognized`.\n */\nexport function nativeRpcError(\n error: RpcErrorFields,\n method: string,\n expectedTransactionHash?: Uint8Array,\n): ThruputError<\"nativeRpcError\"> {\n // A custom transport can leave out `raw`; rebuild it from the typed fields.\n const raw = record(error.raw)\n ? error.raw\n : {\n ...(typeof error.code === \"number\" ? { code: error.code } : {}),\n ...(typeof error.rpcMessage === \"string\"\n ? { message: error.rpcMessage }\n : {}),\n ...(error.data === undefined ? {} : { data: error.data }),\n };\n const decoded = decodeRpcError(method, raw, expectedTransactionHash);\n return new ThruputError(\n \"nativeRpcError\",\n `${method}: ${error.rpcMessage} (RPC ${error.code})`,\n {\n context: {\n code: error.code,\n rpcMessage: error.rpcMessage,\n method,\n raw,\n ...(decoded.classification === \"known\"\n ? { kind: decoded.data.kind, data: decoded.data }\n : { kind: \"unrecognized\" }),\n } as ThruputError<\"nativeRpcError\">[\"context\"],\n },\n );\n}\n","import { codec, deserialize } from \"@thruputchain/protocol\";\nimport { hashSignedTransaction } from \"../derivation/transactionHash.js\";\nimport { isThruputError, ThruputError } from \"../errors/thruputError.js\";\nimport { nativeRpcError } from \"./errorReader.js\";\nimport { markLocalError } from \"./localError.js\";\nimport { toHex0x } from \"../actions/hex.js\";\nimport type { Transport, TransportRequestOptions } from \"../transport/types.js\";\nimport type { RpcIncompatibleKind } from \"../errors/codes.js\";\nimport {\n decodeResult,\n encodeRequest,\n rpcMethodNames,\n rpcPageMethods,\n rpcRequestInvalid,\n rpcValueInvalid,\n} from \"./codec.js\";\nimport type {\n RpcRequests,\n RpcResults,\n RpcVersionInfo,\n RpcNetworkInfo,\n RpcServerLimits,\n RpcTransactionRefPage,\n RpcEventPage,\n RpcHistoryStart,\n RpcEventFilter,\n} from \"./generated.js\";\n\nexport type RpcMethod = keyof RpcRequests;\n/**\n * Exact low-level operations. Each accepts one named object; a request whose\n * fields are all optional can be omitted and defaults to {}.\n * Cancellation options are always the second argument, including for empty requests:\n * `client.getChainTip({}, { signal })`.\n */\nexport type RpcMethods = {\n [M in RpcMethod]: {} extends RpcRequests[M]\n ? (\n request?: RpcRequests[M],\n options?: TransportRequestOptions,\n ) => Promise<RpcResults[M]>\n : (\n request: RpcRequests[M],\n options?: TransportRequestOptions,\n ) => Promise<RpcResults[M]>;\n};\nexport interface RpcDiscovery {\n version: RpcVersionInfo;\n network: RpcNetworkInfo;\n limits?: RpcServerLimits;\n}\nexport type RpcClient = RpcMethods & {\n /** Copy of the last explicitly refreshed, validated discovery snapshot. */\n readonly discovery: RpcDiscovery;\n /** Reads discovery again. Never repeats a failed write. */\n refreshDiscovery(options?: TransportRequestOptions): Promise<RpcDiscovery>;\n /** Check the configured methods before composing a multi-call workflow. */\n requireMethods(methods: readonly RpcMethod[]): void;\n};\nexport interface RpcClientOptions {\n transport: Transport;\n /** Required signing network, compared by bytes before the client is returned. */\n expectedNetworkHash?: Uint8Array;\n /** Methods needed by a composed workflow; partial development endpoints are supported. */\n requiredMethods?: readonly RpcMethod[];\n signal?: AbortSignal;\n}\n\n/**\n * The endpoint, network, or method set does not match what the client requires.\n * Raised by a local check, so it proves that the request was not dispatched.\n */\nexport function rpcIncompatible(\n kind: RpcIncompatibleKind,\n message: string,\n): ThruputError<\"rpcIncompatible\"> {\n return markLocalError(\n new ThruputError(\"rpcIncompatible\", message, { context: { kind } }),\n );\n}\n\nconst equal = (a: Uint8Array, b: Uint8Array) =>\n a.length === b.length && a.every((v, i) => v === b[i]);\n\n/**\n * Connect a native wire-14 client. This layer reads once or sends once; it does\n * not sign, poll, retry, refresh discovery on failure, or switch wire formats.\n * Unknown response variants are UnsupportedRpcValue objects retaining raw data.\n */\nexport async function createRpcClient(\n options: RpcClientOptions,\n): Promise<RpcClient> {\n const transport = options.transport;\n const expected = options.expectedNetworkHash\n ? new Uint8Array(options.expectedNetworkHash)\n : undefined;\n if (expected && expected.length !== 32)\n throw new RangeError(\"expectedNetworkHash must have 32 bytes\");\n const required = [...(options.requiredMethods ?? [])];\n let discovery: RpcDiscovery;\n let configured = new Set<string>();\n const requireMethods = (methods: readonly RpcMethod[]) => {\n for (const method of methods)\n if (!configured.has(method))\n throw rpcIncompatible(\n \"method\",\n `Endpoint does not advertise ${method}`,\n );\n };\n const requestOnce = async (\n method: RpcMethod,\n params: Record<string, unknown>,\n control?: TransportRequestOptions,\n hash?: Uint8Array,\n ) => {\n try {\n return await transport.request(method, params, control);\n } catch (error) {\n if (isThruputError(error, \"rpcError\"))\n throw nativeRpcError(error.context, method, hash);\n throw error;\n }\n };\n const read = async <M extends RpcMethod>(\n method: M,\n control?: TransportRequestOptions,\n ): Promise<RpcResults[M]> =>\n decodeResult(\n method,\n await requestOnce(method, {}, control),\n ) as RpcResults[M];\n const refreshDiscovery = async (\n control?: TransportRequestOptions,\n ): Promise<RpcDiscovery> => {\n const version = await read(\"getVersionInfo\", control);\n // Only the wire identity selects codecs. Release and build versions are diagnostics.\n if (!/^14\\.(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)$/.test(version.wireFormat))\n throw rpcIncompatible(\n \"wireVersion\",\n `Unsupported RPC wire format ${version.wireFormat}`,\n );\n const methods = new Set(version.supportedMethods);\n for (const method of [\"getVersionInfo\", \"getNetworkInfo\", ...required])\n if (!methods.has(method))\n throw rpcIncompatible(\n \"method\",\n `Endpoint does not advertise ${method}`,\n );\n const network = await read(\"getNetworkInfo\", control);\n const wanted = expected ?? discovery?.network.networkHash;\n if (wanted && !equal(wanted, network.networkHash))\n throw rpcIncompatible(\"network\", \"RPC network identity does not match\");\n const limits = methods.has(\"getServerLimits\")\n ? await read(\"getServerLimits\", control)\n : undefined;\n discovery = { version, network, ...(limits ? { limits } : {}) };\n configured = methods;\n return structuredClone(discovery);\n };\n await refreshDiscovery({ signal: options.signal });\n const methods = Object.fromEntries(\n rpcMethodNames.map((name) => [\n name,\n async (request: unknown = {}, control?: TransportRequestOptions) => {\n const method = name as RpcMethod;\n control?.signal?.throwIfAborted();\n requireMethods([method]);\n // Serialize before awaiting: callers cannot mutate predicates or signed bytes in flight.\n const params = encodeRequest(method, request);\n const input = structuredClone(request) as Record<string, unknown>;\n const limits = discovery.limits;\n checkLimits(method, input, limits);\n let submittedHash: Uint8Array | undefined;\n if (method === \"sendTransaction\") {\n try {\n submittedHash = hashSignedTransaction(\n deserialize(\n input.signedTransaction as Uint8Array,\n codec.SignedTransaction,\n ),\n );\n } catch {\n throw rpcRequestInvalid(\n \"/params/signedTransaction\",\n \"Invalid signed transaction XDR\",\n );\n }\n }\n const raw = await requestOnce(\n method,\n params,\n control,\n submittedHash ??\n (method === \"getTransactionReceipt\"\n ? (input.transactionHash as Uint8Array)\n : undefined),\n );\n const result = decodeResult(method, raw) as RpcResults[RpcMethod];\n checkResult(\n method,\n input,\n result,\n raw,\n submittedHash,\n limits,\n discovery.network.networkHash,\n );\n return result;\n },\n ]),\n ) as RpcMethods;\n return Object.defineProperty(\n Object.assign(methods, { refreshDiscovery, requireMethods }),\n \"discovery\",\n { get: () => structuredClone(discovery), enumerable: true },\n ) as RpcClient;\n}\n\nfunction checkLimits(\n method: RpcMethod,\n input: Record<string, unknown>,\n limits: RpcServerLimits | undefined,\n) {\n if (rpcPageMethods.has(method)) {\n if (!limits)\n throw rpcIncompatible(\n \"limits\",\n \"History calls require advertised server limits\",\n );\n const cap =\n method === \"getEvents\"\n ? limits.maxEventsPerPage\n : limits.maxTransactionsPerPage;\n if (input.limit !== undefined && (input.limit as number) > cap)\n throw rpcRequestInvalid(\n \"/params/limit\",\n `limit exceeds endpoint cap ${cap}`,\n );\n if (\n typeof input.cursor === \"string\" &&\n BigInt((input.cursor.length - 2) / 2) > limits.maxCursorBytes\n )\n throw rpcRequestInvalid(\"/params/cursor\", \"cursor exceeds endpoint cap\");\n }\n if (method === \"simulateInvocation\" || method === \"simulateInvocations\") {\n if (!limits)\n throw rpcIncompatible(\n \"limits\",\n \"Simulation calls require advertised server limits\",\n );\n const calls =\n method === \"simulateInvocation\"\n ? [input]\n : (input.invocations as Record<string, unknown>[]);\n let gas = 0n,\n bytes = 0;\n for (const call of calls) {\n const callGas = call.gasLimit as bigint | undefined;\n if (callGas !== undefined && callGas > limits.maxSimulationGas)\n throw rpcRequestInvalid(\n \"/params/gasLimit\",\n \"gasLimit exceeds endpoint cap\",\n );\n const size = (call.calldata as Uint8Array).length;\n if (BigInt(size) > limits.maxSimulationCalldataBytes)\n throw rpcRequestInvalid(\n \"/params/calldata\",\n \"calldata exceeds endpoint cap\",\n );\n gas += callGas ?? limits.maxSimulationGas;\n bytes += size;\n }\n if (method === \"simulateInvocations\") {\n const batch = limits.simulationBatch;\n if (!batch)\n throw rpcIncompatible(\n \"limits\",\n \"Batch simulation limits are unavailable\",\n );\n if (\n calls.length > batch.maxInvocations ||\n bytes > batch.maxCalldataBytes ||\n gas > batch.maxGas\n )\n throw rpcRequestInvalid(\n \"/params/invocations\",\n \"simulation batch exceeds endpoint cap\",\n );\n }\n }\n}\n\n/**\n * Local block and time results must match their own request: a pinned\n * timepoint comes back exactly, a multi-block request returns `count`\n * blocks, a step change reports the requested step (none when cleared), and a\n * mode change reports the requested mode and interval.\n */\nfunction checkBlockControlResult(\n method: RpcMethod,\n input: Record<string, unknown>,\n value: unknown,\n invalid: () => never,\n) {\n if (method === \"dev_produceBlock\") {\n const block = value as RpcResults[\"dev_produceBlock\"];\n if (\n block.blockHeight <= 0n ||\n (input.blockTimepoint !== undefined &&\n block.blockTimepoint !== input.blockTimepoint)\n )\n invalid();\n }\n if (\n method === \"dev_produceBlocks\" &&\n (value as RpcResults[\"dev_produceBlocks\"]).blocks.length !== input.count\n )\n invalid();\n if (\n method === \"dev_setNextBlockTimepoint\" &&\n (value as RpcResults[\"dev_setNextBlockTimepoint\"]).nextBlockTimepoint !==\n input.blockTimepoint\n )\n invalid();\n if (\n method === \"dev_setBlockTimeStep\" &&\n (value as RpcResults[\"dev_setBlockTimeStep\"]).stepNanoseconds !==\n input.stepNanoseconds\n )\n invalid();\n if (method === \"dev_setBlockDriver\") {\n const status = value as RpcResults[\"dev_setBlockDriver\"];\n if (\n (typeof status.mode === \"string\" && status.mode !== input.mode) ||\n (input.intervalMilliseconds !== undefined &&\n status.intervalMilliseconds !== input.intervalMilliseconds)\n )\n invalid();\n }\n}\n\nfunction checkResult(\n method: RpcMethod,\n input: Record<string, unknown>,\n value: unknown,\n raw: unknown,\n submittedHash: Uint8Array | undefined,\n limits: RpcServerLimits | undefined,\n networkHash: Uint8Array,\n) {\n const invalid = (): never => {\n throw rpcValueInvalid(\"/result\", raw);\n };\n if (value === null) return;\n const result = value as Record<string, unknown>;\n if (\n (method === \"getTransactionReceipt\" &&\n !equal(\n result.transactionHash as Uint8Array,\n input.transactionHash as Uint8Array,\n )) ||\n (submittedHash &&\n !equal(result.transactionHash as Uint8Array, submittedHash))\n )\n invalid();\n if (\n method === \"getBlockByHeight\" &&\n ((result.blockHeight as bigint) <= 0n ||\n result.blockHeight !== input.blockHeight ||\n !equal(result.networkHash as Uint8Array, networkHash))\n )\n invalid();\n if (\n (method === \"getBalance\" || method === \"getRegisteredAuth\") &&\n !equal(result.address as Uint8Array, input.address as Uint8Array)\n )\n invalid();\n if (\n method === \"simulateInvocations\" &&\n (result.results as unknown[]).length !==\n (input.invocations as unknown[]).length\n )\n invalid();\n if (\n (method === \"simulateInvocation\" || method === \"simulateInvocations\") &&\n input.minStateBlockHeight !== undefined &&\n (result.stateBlockHeight as bigint) < (input.minStateBlockHeight as bigint)\n )\n invalid();\n if (method === \"dev_fundAccount\") {\n const funding = value as RpcResults[\"dev_fundAccount\"];\n try {\n if (\n !equal(funding.recipient, input.recipient as Uint8Array) ||\n funding.rawAmount !== input.rawAmount ||\n !equal(\n funding.transactionHash,\n hashSignedTransaction(\n deserialize(funding.signedTransaction, codec.SignedTransaction),\n ),\n )\n )\n invalid();\n } catch {\n invalid();\n }\n }\n checkBlockControlResult(method, input, value, invalid);\n if (\n method === \"faucet_requestAirdrop\" &&\n \"recipient\" in result &&\n !equal(result.recipient as Uint8Array, input.recipient as Uint8Array)\n )\n invalid();\n if (!rpcPageMethods.has(method)) return;\n const page = value as RpcTransactionRefPage | RpcEventPage;\n const entries =\n method === \"getEvents\"\n ? (page as RpcEventPage).events\n : (page as RpcTransactionRefPage).transactions;\n const cap =\n method === \"getEvents\"\n ? limits!.maxEventsPerPage\n : limits!.maxTransactionsPerPage;\n if (\n page.oldestIndexedBlockHeight > page.latestIndexedBlockHeight ||\n entries.length >\n ((input.limit as number | undefined) ?? Math.min(50, cap)) ||\n (page.nextCursor !== null &&\n (page.nextCursor === input.cursor ||\n BigInt((page.nextCursor.length - 2) / 2) > limits!.maxCursorBytes))\n )\n invalid();\n if (\n entries.some(\n (entry) =>\n entry.blockHeight < page.oldestIndexedBlockHeight ||\n entry.blockHeight > page.latestIndexedBlockHeight,\n )\n )\n invalid();\n const start = input.start as RpcHistoryStart | undefined;\n if (method === \"getTransactionsByBlock\") {\n if (\n page.oldestIndexedBlockHeight < 1n ||\n (!entries.length && page.nextCursor !== null) ||\n (input.cursor !== undefined &&\n ((input.blockHeight as bigint) < page.oldestIndexedBlockHeight ||\n (input.blockHeight as bigint) > page.latestIndexedBlockHeight)) ||\n entries.some((entry) => entry.blockHeight !== input.blockHeight)\n )\n invalid();\n } else if (start?.anchor.kind === \"atHeight\") {\n const anchor = start.anchor.blockHeight;\n if (\n anchor < page.oldestIndexedBlockHeight ||\n entries.some((entry) =>\n start.order === \"ascending\"\n ? entry.blockHeight < anchor\n : entry.blockHeight > anchor,\n )\n )\n invalid();\n }\n const identities = new Set<string>();\n const keys: [bigint, string, number][] = [];\n for (const [index, entry] of entries.entries()) {\n const event =\n method === \"getEvents\" ? (page as RpcEventPage).events[index] : undefined;\n const hash = toHex0x(entry.transactionHash);\n const sequence = event?.sequenceNumber ?? 0;\n const identity = method === \"getEvents\" ? `${hash}/${sequence}` : hash;\n if (identities.has(identity)) invalid();\n identities.add(identity);\n keys.push([entry.blockHeight, hash, sequence]);\n if (\n event &&\n !(input.filters as RpcEventFilter[]).some(\n (filter) =>\n filter.addresses.some((address) =>\n equal(address, event.event.address),\n ) &&\n [\"topic0\", \"topic1\", \"topic2\"].every((key, i) => {\n const values =\n filter.topics?.[key as \"topic0\" | \"topic1\" | \"topic2\"];\n return (\n !values?.length ||\n (!!event.event.topics[i] &&\n values.some((topic) => equal(topic, event.event.topics[i]!)))\n );\n }),\n )\n )\n invalid();\n }\n const compare = (\n left: (typeof keys)[number],\n right: (typeof keys)[number],\n ) => {\n for (let i = 0; i < 3; i++) {\n if (left[i]! < right[i]!) return -1;\n if (left[i]! > right[i]!) return 1;\n }\n return 0;\n };\n const asc = keys.every((key, i) => i === 0 || compare(keys[i - 1]!, key) < 0);\n const desc = keys.every(\n (key, i) => i === 0 || compare(keys[i - 1]!, key) > 0,\n );\n if (!(start ? (start.order === \"ascending\" ? asc : desc) : asc || desc))\n invalid();\n}\n","import { isThruputError } from \"../errors/thruputError.js\";\nimport type { TransportRequestOptions } from \"./types.js\";\n\n/** Infrastructure failure classification; retry budgets remain with the caller. */\nexport type ReadErrorKind = \"transient\" | \"permanent\" | \"cancelled\" | \"unknown\";\n\n/**\n * Classify an infrastructure read failure without replacing the original error.\n *\n * Pass the caller's signal to distinguish explicit cancellation from a transport\n * timeout. Plain Error wrappers are inspected through their causes; other\n * `ThruputError` codes and unrecognized failures remain unknown. A bare TypeError\n * is not evidence of a network failure. Custom transports should throw code\n * `httpRequestFailed` for that case. Transaction-not-found remains\n * operation-specific rather than a general retry. This classification never\n * authorizes transaction resubmission.\n */\nexport function classifyReadError(\n error: unknown,\n options: TransportRequestOptions = {},\n): ReadErrorKind {\n if (options.signal?.aborted) return \"cancelled\";\n const seen = new Set<unknown>();\n while (error !== null && typeof error === \"object\" && !seen.has(error)) {\n seen.add(error);\n if (isThruputError(error, \"httpRequestFailed\")) return \"transient\";\n if (isThruputError(error, \"httpResponseError\")) {\n return [408, 429, 500, 502, 503, 504].includes(error.context.status)\n ? \"transient\"\n : \"permanent\";\n }\n if (isThruputError(error, \"nativeRpcError\")) {\n switch (error.context.kind) {\n case \"backendUnavailable\":\n case \"stateHeightUnavailable\":\n case \"backendTimeout\":\n case \"overloaded\":\n return \"transient\";\n case \"invalidParams\":\n case \"invalidCursor\":\n case \"transactionInvalid\":\n case \"transactionRejected\":\n case \"historyUnavailable\":\n return \"permanent\";\n default:\n return \"unknown\";\n }\n }\n if (\"name\" in error) {\n if (error.name === \"TimeoutError\") return \"transient\";\n if (error.name === \"AbortError\") return \"cancelled\";\n }\n // Do not unwrap contract/decoding errors into infrastructure retries.\n if (!(error instanceof Error) || error.constructor !== Error)\n return \"unknown\";\n error = error.cause;\n }\n return \"unknown\";\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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