@thruputchain/client 0.0.0-stage → 0.25.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 (182) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +935 -2
  3. package/dist/actions-CdFSUTO2.js +298 -0
  4. package/dist/actions-CdFSUTO2.js.map +1 -0
  5. package/dist/actions-DxJZ3yIv.cjs +357 -0
  6. package/dist/actions-DxJZ3yIv.cjs.map +1 -0
  7. package/dist/actions.cjs +19 -0
  8. package/dist/actions.d.cts +4 -0
  9. package/dist/actions.d.ts +4 -0
  10. package/dist/actions.js +3 -0
  11. package/dist/client-BxB6ktQd.d.cts +690 -0
  12. package/dist/client-BxB6ktQd.d.cts.map +1 -0
  13. package/dist/client-BxB6ktQd.d.ts +690 -0
  14. package/dist/client-BxB6ktQd.d.ts.map +1 -0
  15. package/dist/codec-B7HJjMzI.cjs +8190 -0
  16. package/dist/codec-B7HJjMzI.cjs.map +1 -0
  17. package/dist/codec-CX-19jac.js +8130 -0
  18. package/dist/codec-CX-19jac.js.map +1 -0
  19. package/dist/contract-BpxjDMHw.js +1105 -0
  20. package/dist/contract-BpxjDMHw.js.map +1 -0
  21. package/dist/contract-D0wCFcAN.cjs +1219 -0
  22. package/dist/contract-D0wCFcAN.cjs.map +1 -0
  23. package/dist/contract.cjs +58 -0
  24. package/dist/contract.d.cts +3 -0
  25. package/dist/contract.d.ts +3 -0
  26. package/dist/contract.js +2 -0
  27. package/dist/contracts.cjs +1050 -0
  28. package/dist/contracts.cjs.map +1 -0
  29. package/dist/contracts.d.cts +397 -0
  30. package/dist/contracts.d.cts.map +1 -0
  31. package/dist/contracts.d.ts +397 -0
  32. package/dist/contracts.d.ts.map +1 -0
  33. package/dist/contracts.js +1030 -0
  34. package/dist/contracts.js.map +1 -0
  35. package/dist/dev_wallet-BXWK5KR6.cjs +530 -0
  36. package/dist/dev_wallet-BXWK5KR6.cjs.map +1 -0
  37. package/dist/dev_wallet-C9eMQROk.js +497 -0
  38. package/dist/dev_wallet-C9eMQROk.js.map +1 -0
  39. package/dist/domainSeparator-B_vU_zUD.cjs +102 -0
  40. package/dist/domainSeparator-B_vU_zUD.cjs.map +1 -0
  41. package/dist/domainSeparator-CBCvxIj-.js +79 -0
  42. package/dist/domainSeparator-CBCvxIj-.js.map +1 -0
  43. package/dist/execution-CRDyKu45.d.ts +227 -0
  44. package/dist/execution-CRDyKu45.d.ts.map +1 -0
  45. package/dist/execution-DyxaIG4v.d.cts +227 -0
  46. package/dist/execution-DyxaIG4v.d.cts.map +1 -0
  47. package/dist/hex-DIcaALXL.js +112 -0
  48. package/dist/hex-DIcaALXL.js.map +1 -0
  49. package/dist/hex-DkGpiZ5e.cjs +189 -0
  50. package/dist/hex-DkGpiZ5e.cjs.map +1 -0
  51. package/dist/index--5LsCotr.d.ts +192 -0
  52. package/dist/index--5LsCotr.d.ts.map +1 -0
  53. package/dist/index-B5KqSHeL.d.cts +192 -0
  54. package/dist/index-B5KqSHeL.d.cts.map +1 -0
  55. package/dist/index-BZ0O5jZG.d.cts +163 -0
  56. package/dist/index-BZ0O5jZG.d.cts.map +1 -0
  57. package/dist/index-BuPQcAK2.d.ts +23 -0
  58. package/dist/index-BuPQcAK2.d.ts.map +1 -0
  59. package/dist/index-ByNNqY7S.d.cts +83 -0
  60. package/dist/index-ByNNqY7S.d.cts.map +1 -0
  61. package/dist/index-C-M-4jMR.d.cts +263 -0
  62. package/dist/index-C-M-4jMR.d.cts.map +1 -0
  63. package/dist/index-C97zw2rk.d.ts +137 -0
  64. package/dist/index-C97zw2rk.d.ts.map +1 -0
  65. package/dist/index-CIHK7Ew9.d.cts +303 -0
  66. package/dist/index-CIHK7Ew9.d.cts.map +1 -0
  67. package/dist/index-CIHK7Ew9.d.ts +303 -0
  68. package/dist/index-CIHK7Ew9.d.ts.map +1 -0
  69. package/dist/index-CXuO2Zjx.d.ts +263 -0
  70. package/dist/index-CXuO2Zjx.d.ts.map +1 -0
  71. package/dist/index-DOEBWXY2.d.cts +137 -0
  72. package/dist/index-DOEBWXY2.d.cts.map +1 -0
  73. package/dist/index-DzrLv3EA.d.cts +82 -0
  74. package/dist/index-DzrLv3EA.d.cts.map +1 -0
  75. package/dist/index-DzrLv3EA.d.ts +82 -0
  76. package/dist/index-DzrLv3EA.d.ts.map +1 -0
  77. package/dist/index-fdTURpBk.d.ts +83 -0
  78. package/dist/index-fdTURpBk.d.ts.map +1 -0
  79. package/dist/index-sAzHHayu.d.ts +163 -0
  80. package/dist/index-sAzHHayu.d.ts.map +1 -0
  81. package/dist/index-uQqRk9Ww.d.cts +23 -0
  82. package/dist/index-uQqRk9Ww.d.cts.map +1 -0
  83. package/dist/index.cjs +478 -0
  84. package/dist/index.cjs.map +1 -0
  85. package/dist/index.d.cts +173 -0
  86. package/dist/index.d.cts.map +1 -0
  87. package/dist/index.d.ts +173 -0
  88. package/dist/index.d.ts.map +1 -0
  89. package/dist/index.js +231 -0
  90. package/dist/index.js.map +1 -0
  91. package/dist/provider.cjs +101 -0
  92. package/dist/provider.cjs.map +1 -0
  93. package/dist/provider.d.cts +2 -0
  94. package/dist/provider.d.ts +2 -0
  95. package/dist/provider.js +76 -0
  96. package/dist/provider.js.map +1 -0
  97. package/dist/readError-BVbfTMLv.cjs +604 -0
  98. package/dist/readError-BVbfTMLv.cjs.map +1 -0
  99. package/dist/readError-Dn_XN98x.js +551 -0
  100. package/dist/readError-Dn_XN98x.js.map +1 -0
  101. package/dist/readViews-BKJtE5J3.d.cts +594 -0
  102. package/dist/readViews-BKJtE5J3.d.cts.map +1 -0
  103. package/dist/readViews-C_FX8wby.d.ts +594 -0
  104. package/dist/readViews-C_FX8wby.d.ts.map +1 -0
  105. package/dist/rolldown-runtime-D6vf50IK.cjs +28 -0
  106. package/dist/sendInvocation-2EZanZZr.cjs +661 -0
  107. package/dist/sendInvocation-2EZanZZr.cjs.map +1 -0
  108. package/dist/sendInvocation-C4ruTC-9.js +505 -0
  109. package/dist/sendInvocation-C4ruTC-9.js.map +1 -0
  110. package/dist/sign-BewmV_EL.cjs +139 -0
  111. package/dist/sign-BewmV_EL.cjs.map +1 -0
  112. package/dist/sign-DVIRyW8Y.js +122 -0
  113. package/dist/sign-DVIRyW8Y.js.map +1 -0
  114. package/dist/sign-Ve0eetRO.d.ts +48 -0
  115. package/dist/sign-Ve0eetRO.d.ts.map +1 -0
  116. package/dist/sign-eUT0iGQG.d.cts +48 -0
  117. package/dist/sign-eUT0iGQG.d.cts.map +1 -0
  118. package/dist/signed-op.cjs +9 -0
  119. package/dist/signed-op.d.cts +3 -0
  120. package/dist/signed-op.d.ts +3 -0
  121. package/dist/signed-op.js +3 -0
  122. package/dist/signedOp-Bluo0OAd.cjs +183 -0
  123. package/dist/signedOp-Bluo0OAd.cjs.map +1 -0
  124. package/dist/signedOp-x4fakrr4.js +166 -0
  125. package/dist/signedOp-x4fakrr4.js.map +1 -0
  126. package/dist/signed_op-BzVbBgv4.js +154 -0
  127. package/dist/signed_op-BzVbBgv4.js.map +1 -0
  128. package/dist/signed_op-DFgQ2yFj.d.ts +58 -0
  129. package/dist/signed_op-DFgQ2yFj.d.ts.map +1 -0
  130. package/dist/signed_op-LwxrDud8.d.cts +58 -0
  131. package/dist/signed_op-LwxrDud8.d.cts.map +1 -0
  132. package/dist/signed_op-z_8fqAi1.cjs +175 -0
  133. package/dist/signed_op-z_8fqAi1.cjs.map +1 -0
  134. package/dist/signers-BFP84wJP.cjs +137 -0
  135. package/dist/signers-BFP84wJP.cjs.map +1 -0
  136. package/dist/signers-CzOSedwJ.js +120 -0
  137. package/dist/signers-CzOSedwJ.js.map +1 -0
  138. package/dist/signers.cjs +5 -0
  139. package/dist/signers.d.cts +3 -0
  140. package/dist/signers.d.ts +3 -0
  141. package/dist/signers.js +2 -0
  142. package/dist/size-506oTE28.js +91 -0
  143. package/dist/size-506oTE28.js.map +1 -0
  144. package/dist/size-OAFfOthl.cjs +108 -0
  145. package/dist/size-OAFfOthl.cjs.map +1 -0
  146. package/dist/transaction-CwkQxQOx.js +24 -0
  147. package/dist/transaction-CwkQxQOx.js.map +1 -0
  148. package/dist/transaction-DrSrCJ5y.cjs +47 -0
  149. package/dist/transaction-DrSrCJ5y.cjs.map +1 -0
  150. package/dist/transaction.cjs +13 -0
  151. package/dist/transaction.d.cts +3 -0
  152. package/dist/transaction.d.ts +3 -0
  153. package/dist/transaction.js +4 -0
  154. package/dist/transactionHash-CO9ajbvU.js +24 -0
  155. package/dist/transactionHash-CO9ajbvU.js.map +1 -0
  156. package/dist/transactionHash-D5yf4KoL.cjs +29 -0
  157. package/dist/transactionHash-D5yf4KoL.cjs.map +1 -0
  158. package/dist/transport-B-P16rs6.cjs +252 -0
  159. package/dist/transport-B-P16rs6.cjs.map +1 -0
  160. package/dist/transport-DqyoNtUy.js +234 -0
  161. package/dist/transport-DqyoNtUy.js.map +1 -0
  162. package/dist/transport.cjs +19 -0
  163. package/dist/transport.d.cts +3 -0
  164. package/dist/transport.d.ts +3 -0
  165. package/dist/transport.js +4 -0
  166. package/dist/types-BE40oD_Q.d.cts +18 -0
  167. package/dist/types-BE40oD_Q.d.cts.map +1 -0
  168. package/dist/types-BE40oD_Q.d.ts +18 -0
  169. package/dist/types-BE40oD_Q.d.ts.map +1 -0
  170. package/dist/validation-4w-vDGAi.cjs +543 -0
  171. package/dist/validation-4w-vDGAi.cjs.map +1 -0
  172. package/dist/validation-eXATmgO0.js +411 -0
  173. package/dist/validation-eXATmgO0.js.map +1 -0
  174. package/dist/wallet-Bthapk8i.cjs +709 -0
  175. package/dist/wallet-Bthapk8i.cjs.map +1 -0
  176. package/dist/wallet-CwWPYoHF.js +667 -0
  177. package/dist/wallet-CwWPYoHF.js.map +1 -0
  178. package/dist/wallet.cjs +27 -0
  179. package/dist/wallet.d.cts +3 -0
  180. package/dist/wallet.d.ts +3 -0
  181. package/dist/wallet.js +3 -0
  182. package/package.json +122 -4
@@ -0,0 +1 @@
1
+ {"version":3,"file":"size-506oTE28.js","names":[],"sources":["../src/derivation/publicKeyHash.ts","../src/transaction/preimage.ts","../src/transaction/size.ts"],"sourcesContent":["import { codec, publicKeyHash } from \"@thruputchain/protocol\";\nimport type { PublicKey, PublicKeyHash } from \"@thruputchain/protocol\";\nimport { PUBLIC_KEY } from \"./domainSeparator.js\";\n\n/**\n * Hashes a public key, scheme included:\n * `sha256( cxs(DomainSeparator(\"PublicKey\")) || cxs(pubkey) )`.\n *\n * A pubkey account names its key by this hash, so an Ed25519 key and an\n * ML-DSA-65 key can never share an account even if their bytes overlap. The\n * signed envelope carries the key itself as `pubkey_claim_key`, which the chain\n * checks against this hash.\n *\n * @example\n * ```ts\n * import { derivePublicKeyHash } from \"@thruputchain/client\";\n *\n * const hash = derivePublicKeyHash(signer.publicKey);\n * ```\n */\nexport function derivePublicKeyHash(pubkey: PublicKey): PublicKeyHash {\n return publicKeyHash(PUBLIC_KEY.hashObject(pubkey, codec.PublicKey));\n}\n","import type { NetworkHash, Transaction } from \"@thruputchain/protocol\";\nimport { codec, serialize } from \"@thruputchain/protocol\";\nimport { TRANSACTION } from \"../derivation/domainSeparator.js\";\n\n/**\n * The message every transaction signature covers:\n *\n * ```text\n * cxs(DomainSeparator(\"Transaction\")) || networkHash || txs(tx)\n * ```\n *\n * The domain separator keeps a transaction signature from being reinterpreted\n * as a signature over some other object whose encoding a transaction could be\n * made to imitate. The network hash binds the signature to a single network, so\n * a transaction signed for one chain cannot be replayed on another that happens\n * to carry the same address with the same auth data.\n *\n * Note the two encodings: the prefix is CXS, which is how a `DomainSeparator`\n * is encoded everywhere, while the transaction itself is classic XDR. The\n * network hash is a fixed 32-byte opaque, whose CXS and XDR encodings are\n * identical, so it is written verbatim.\n *\n * The result is signed directly — Ed25519 does its own hashing, so there is no\n * pre-hash here. It must match the C++ validator's\n * `hogd::transaction_signature_preimage` and the Rust\n * `thruput_domain_separator::transaction_signature_preimage` byte for byte,\n * or every signature is rejected.\n *\n * {@link signTransaction} calls this; reach for it directly only when handing\n * bytes to a signer this package does not drive.\n */\nexport function transactionSignaturePreimage(\n networkHash: NetworkHash,\n tx: Transaction,\n): Uint8Array {\n const prefix = TRANSACTION.bytes;\n const payload = serialize(tx, codec.Transaction);\n\n const preimage = new Uint8Array(\n prefix.length + networkHash.length + payload.length,\n );\n preimage.set(prefix, 0);\n preimage.set(networkHash, prefix.length);\n preimage.set(payload, prefix.length + networkHash.length);\n return preimage;\n}\n","import { CryptographicScheme } from \"@thruputchain/protocol\";\n\n/** XDR bytes of a `Signature` union value: discriminant plus padded opaque. */\nconst signatureBytes: Record<CryptographicScheme, number> = {\n [CryptographicScheme.Ed25519]: 4 + 64,\n // 3309 bytes, padded to a 4-byte boundary.\n [CryptographicScheme.MlDsa65]: 4 + 3312,\n};\n\n/** XDR bytes of a `PublicKey` union value: discriminant plus opaque. */\nconst publicKeyBytes: Record<CryptographicScheme, number> = {\n [CryptographicScheme.Ed25519]: 4 + 32,\n [CryptographicScheme.MlDsa65]: 4 + 1952,\n};\n\n/**\n * Bytes a `kPubkeySignature` signed envelope adds to the unsigned transaction:\n * the one-entry signature vector (count, key ID, signature) and the present\n * `pubkey_claim_key` option holding the key.\n *\n * Reserve this much when bounding an unsigned transaction against a\n * signed-transaction size limit: 116 bytes for Ed25519 and 5,284 bytes for\n * ML-DSA-65 (a 3,309-byte signature and a 1,952-byte key).\n */\nexport function pubkeySignatureEnvelopeBytes(\n scheme: CryptographicScheme,\n): number {\n const signature = signatureBytes[scheme];\n const publicKey = publicKeyBytes[scheme];\n if (signature === undefined || publicKey === undefined) {\n throw new RangeError(`Unsupported cryptographic scheme: ${scheme}`);\n }\n // Vector count, public-key ID, signature, option flag, key.\n return 4 + 4 + signature + 4 + publicKey;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAoBA,SAAgB,oBAAoB,QAAkC;CACpE,OAAO,cAAc,WAAW,WAAW,QAAQ,MAAM,SAAS,CAAC;AACrE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACSA,SAAgB,6BACd,aACA,IACY;CACZ,MAAM,SAAS,YAAY;CAC3B,MAAM,UAAU,UAAU,IAAI,MAAM,WAAW;CAE/C,MAAM,WAAW,IAAI,WACnB,OAAO,SAAS,YAAY,SAAS,QAAQ,MAC/C;CACA,SAAS,IAAI,QAAQ,CAAC;CACtB,SAAS,IAAI,aAAa,OAAO,MAAM;CACvC,SAAS,IAAI,SAAS,OAAO,SAAS,YAAY,MAAM;CACxD,OAAO;AACT;;;;AC1CA,MAAM,iBAAsD;EACzD,oBAAoB,UAAU;EAE9B,oBAAoB,UAAU;AACjC;;AAGA,MAAM,iBAAsD;EACzD,oBAAoB,UAAU;EAC9B,oBAAoB,UAAU;AACjC;;;;;;;;;;AAWA,SAAgB,6BACd,QACQ;CACR,MAAM,YAAY,eAAe;CACjC,MAAM,YAAY,eAAe;CACjC,IAAI,cAAc,KAAA,KAAa,cAAc,KAAA,GAC3C,MAAM,IAAI,WAAW,qCAAqC,QAAQ;CAGpE,OAAO,IAAQ,YAAY,IAAI;AACjC"}
@@ -0,0 +1,108 @@
1
+ const require_domainSeparator = require("./domainSeparator-B_vU_zUD.cjs");
2
+ let _thruputchain_protocol = require("@thruputchain/protocol");
3
+ //#region src/derivation/publicKeyHash.ts
4
+ /**
5
+ * Hashes a public key, scheme included:
6
+ * `sha256( cxs(DomainSeparator("PublicKey")) || cxs(pubkey) )`.
7
+ *
8
+ * A pubkey account names its key by this hash, so an Ed25519 key and an
9
+ * ML-DSA-65 key can never share an account even if their bytes overlap. The
10
+ * signed envelope carries the key itself as `pubkey_claim_key`, which the chain
11
+ * checks against this hash.
12
+ *
13
+ * @example
14
+ * ```ts
15
+ * import { derivePublicKeyHash } from "@thruputchain/client";
16
+ *
17
+ * const hash = derivePublicKeyHash(signer.publicKey);
18
+ * ```
19
+ */
20
+ function derivePublicKeyHash(pubkey) {
21
+ return (0, _thruputchain_protocol.publicKeyHash)(require_domainSeparator.PUBLIC_KEY.hashObject(pubkey, _thruputchain_protocol.codec.PublicKey));
22
+ }
23
+ //#endregion
24
+ //#region src/transaction/preimage.ts
25
+ /**
26
+ * The message every transaction signature covers:
27
+ *
28
+ * ```text
29
+ * cxs(DomainSeparator("Transaction")) || networkHash || txs(tx)
30
+ * ```
31
+ *
32
+ * The domain separator keeps a transaction signature from being reinterpreted
33
+ * as a signature over some other object whose encoding a transaction could be
34
+ * made to imitate. The network hash binds the signature to a single network, so
35
+ * a transaction signed for one chain cannot be replayed on another that happens
36
+ * to carry the same address with the same auth data.
37
+ *
38
+ * Note the two encodings: the prefix is CXS, which is how a `DomainSeparator`
39
+ * is encoded everywhere, while the transaction itself is classic XDR. The
40
+ * network hash is a fixed 32-byte opaque, whose CXS and XDR encodings are
41
+ * identical, so it is written verbatim.
42
+ *
43
+ * The result is signed directly — Ed25519 does its own hashing, so there is no
44
+ * pre-hash here. It must match the C++ validator's
45
+ * `hogd::transaction_signature_preimage` and the Rust
46
+ * `thruput_domain_separator::transaction_signature_preimage` byte for byte,
47
+ * or every signature is rejected.
48
+ *
49
+ * {@link signTransaction} calls this; reach for it directly only when handing
50
+ * bytes to a signer this package does not drive.
51
+ */
52
+ function transactionSignaturePreimage(networkHash, tx) {
53
+ const prefix = require_domainSeparator.TRANSACTION.bytes;
54
+ const payload = (0, _thruputchain_protocol.serialize)(tx, _thruputchain_protocol.codec.Transaction);
55
+ const preimage = new Uint8Array(prefix.length + networkHash.length + payload.length);
56
+ preimage.set(prefix, 0);
57
+ preimage.set(networkHash, prefix.length);
58
+ preimage.set(payload, prefix.length + networkHash.length);
59
+ return preimage;
60
+ }
61
+ //#endregion
62
+ //#region src/transaction/size.ts
63
+ /** XDR bytes of a `Signature` union value: discriminant plus padded opaque. */
64
+ const signatureBytes = {
65
+ [_thruputchain_protocol.CryptographicScheme.Ed25519]: 68,
66
+ [_thruputchain_protocol.CryptographicScheme.MlDsa65]: 3316
67
+ };
68
+ /** XDR bytes of a `PublicKey` union value: discriminant plus opaque. */
69
+ const publicKeyBytes = {
70
+ [_thruputchain_protocol.CryptographicScheme.Ed25519]: 36,
71
+ [_thruputchain_protocol.CryptographicScheme.MlDsa65]: 1956
72
+ };
73
+ /**
74
+ * Bytes a `kPubkeySignature` signed envelope adds to the unsigned transaction:
75
+ * the one-entry signature vector (count, key ID, signature) and the present
76
+ * `pubkey_claim_key` option holding the key.
77
+ *
78
+ * Reserve this much when bounding an unsigned transaction against a
79
+ * signed-transaction size limit: 116 bytes for Ed25519 and 5,284 bytes for
80
+ * ML-DSA-65 (a 3,309-byte signature and a 1,952-byte key).
81
+ */
82
+ function pubkeySignatureEnvelopeBytes(scheme) {
83
+ const signature = signatureBytes[scheme];
84
+ const publicKey = publicKeyBytes[scheme];
85
+ if (signature === void 0 || publicKey === void 0) throw new RangeError(`Unsupported cryptographic scheme: ${scheme}`);
86
+ return 8 + signature + 4 + publicKey;
87
+ }
88
+ //#endregion
89
+ Object.defineProperty(exports, "derivePublicKeyHash", {
90
+ enumerable: true,
91
+ get: function() {
92
+ return derivePublicKeyHash;
93
+ }
94
+ });
95
+ Object.defineProperty(exports, "pubkeySignatureEnvelopeBytes", {
96
+ enumerable: true,
97
+ get: function() {
98
+ return pubkeySignatureEnvelopeBytes;
99
+ }
100
+ });
101
+ Object.defineProperty(exports, "transactionSignaturePreimage", {
102
+ enumerable: true,
103
+ get: function() {
104
+ return transactionSignaturePreimage;
105
+ }
106
+ });
107
+
108
+ //# sourceMappingURL=size-OAFfOthl.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"size-OAFfOthl.cjs","names":["PUBLIC_KEY","codec","TRANSACTION","codec","CryptographicScheme"],"sources":["../src/derivation/publicKeyHash.ts","../src/transaction/preimage.ts","../src/transaction/size.ts"],"sourcesContent":["import { codec, publicKeyHash } from \"@thruputchain/protocol\";\nimport type { PublicKey, PublicKeyHash } from \"@thruputchain/protocol\";\nimport { PUBLIC_KEY } from \"./domainSeparator.js\";\n\n/**\n * Hashes a public key, scheme included:\n * `sha256( cxs(DomainSeparator(\"PublicKey\")) || cxs(pubkey) )`.\n *\n * A pubkey account names its key by this hash, so an Ed25519 key and an\n * ML-DSA-65 key can never share an account even if their bytes overlap. The\n * signed envelope carries the key itself as `pubkey_claim_key`, which the chain\n * checks against this hash.\n *\n * @example\n * ```ts\n * import { derivePublicKeyHash } from \"@thruputchain/client\";\n *\n * const hash = derivePublicKeyHash(signer.publicKey);\n * ```\n */\nexport function derivePublicKeyHash(pubkey: PublicKey): PublicKeyHash {\n return publicKeyHash(PUBLIC_KEY.hashObject(pubkey, codec.PublicKey));\n}\n","import type { NetworkHash, Transaction } from \"@thruputchain/protocol\";\nimport { codec, serialize } from \"@thruputchain/protocol\";\nimport { TRANSACTION } from \"../derivation/domainSeparator.js\";\n\n/**\n * The message every transaction signature covers:\n *\n * ```text\n * cxs(DomainSeparator(\"Transaction\")) || networkHash || txs(tx)\n * ```\n *\n * The domain separator keeps a transaction signature from being reinterpreted\n * as a signature over some other object whose encoding a transaction could be\n * made to imitate. The network hash binds the signature to a single network, so\n * a transaction signed for one chain cannot be replayed on another that happens\n * to carry the same address with the same auth data.\n *\n * Note the two encodings: the prefix is CXS, which is how a `DomainSeparator`\n * is encoded everywhere, while the transaction itself is classic XDR. The\n * network hash is a fixed 32-byte opaque, whose CXS and XDR encodings are\n * identical, so it is written verbatim.\n *\n * The result is signed directly — Ed25519 does its own hashing, so there is no\n * pre-hash here. It must match the C++ validator's\n * `hogd::transaction_signature_preimage` and the Rust\n * `thruput_domain_separator::transaction_signature_preimage` byte for byte,\n * or every signature is rejected.\n *\n * {@link signTransaction} calls this; reach for it directly only when handing\n * bytes to a signer this package does not drive.\n */\nexport function transactionSignaturePreimage(\n networkHash: NetworkHash,\n tx: Transaction,\n): Uint8Array {\n const prefix = TRANSACTION.bytes;\n const payload = serialize(tx, codec.Transaction);\n\n const preimage = new Uint8Array(\n prefix.length + networkHash.length + payload.length,\n );\n preimage.set(prefix, 0);\n preimage.set(networkHash, prefix.length);\n preimage.set(payload, prefix.length + networkHash.length);\n return preimage;\n}\n","import { CryptographicScheme } from \"@thruputchain/protocol\";\n\n/** XDR bytes of a `Signature` union value: discriminant plus padded opaque. */\nconst signatureBytes: Record<CryptographicScheme, number> = {\n [CryptographicScheme.Ed25519]: 4 + 64,\n // 3309 bytes, padded to a 4-byte boundary.\n [CryptographicScheme.MlDsa65]: 4 + 3312,\n};\n\n/** XDR bytes of a `PublicKey` union value: discriminant plus opaque. */\nconst publicKeyBytes: Record<CryptographicScheme, number> = {\n [CryptographicScheme.Ed25519]: 4 + 32,\n [CryptographicScheme.MlDsa65]: 4 + 1952,\n};\n\n/**\n * Bytes a `kPubkeySignature` signed envelope adds to the unsigned transaction:\n * the one-entry signature vector (count, key ID, signature) and the present\n * `pubkey_claim_key` option holding the key.\n *\n * Reserve this much when bounding an unsigned transaction against a\n * signed-transaction size limit: 116 bytes for Ed25519 and 5,284 bytes for\n * ML-DSA-65 (a 3,309-byte signature and a 1,952-byte key).\n */\nexport function pubkeySignatureEnvelopeBytes(\n scheme: CryptographicScheme,\n): number {\n const signature = signatureBytes[scheme];\n const publicKey = publicKeyBytes[scheme];\n if (signature === undefined || publicKey === undefined) {\n throw new RangeError(`Unsupported cryptographic scheme: ${scheme}`);\n }\n // Vector count, public-key ID, signature, option flag, key.\n return 4 + 4 + signature + 4 + publicKey;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAoBA,SAAgB,oBAAoB,QAAkC;CACpE,QAAA,GAAA,uBAAA,cAAA,CAAqBA,wBAAAA,WAAW,WAAW,QAAQC,uBAAAA,MAAM,SAAS,CAAC;AACrE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACSA,SAAgB,6BACd,aACA,IACY;CACZ,MAAM,SAASC,wBAAAA,YAAY;CAC3B,MAAM,WAAA,GAAA,uBAAA,UAAA,CAAoB,IAAIC,uBAAAA,MAAM,WAAW;CAE/C,MAAM,WAAW,IAAI,WACnB,OAAO,SAAS,YAAY,SAAS,QAAQ,MAC/C;CACA,SAAS,IAAI,QAAQ,CAAC;CACtB,SAAS,IAAI,aAAa,OAAO,MAAM;CACvC,SAAS,IAAI,SAAS,OAAO,SAAS,YAAY,MAAM;CACxD,OAAO;AACT;;;;AC1CA,MAAM,iBAAsD;EACzDC,uBAAAA,oBAAoB,UAAU;EAE9BA,uBAAAA,oBAAoB,UAAU;AACjC;;AAGA,MAAM,iBAAsD;EACzDA,uBAAAA,oBAAoB,UAAU;EAC9BA,uBAAAA,oBAAoB,UAAU;AACjC;;;;;;;;;;AAWA,SAAgB,6BACd,QACQ;CACR,MAAM,YAAY,eAAe;CACjC,MAAM,YAAY,eAAe;CACjC,IAAI,cAAc,KAAA,KAAa,cAAc,KAAA,GAC3C,MAAM,IAAI,WAAW,qCAAqC,QAAQ;CAGpE,OAAO,IAAQ,YAAY,IAAI;AACjC"}
@@ -0,0 +1,24 @@
1
+ import "./sign-DVIRyW8Y.js";
2
+ import "./size-506oTE28.js";
3
+ import { codec, deserialize, serialize } from "@thruputchain/protocol";
4
+ //#region src/transaction/serialize.ts
5
+ /** Serialize an unsigned transaction to its canonical protocol bytes. */
6
+ function serializeTransaction(tx) {
7
+ return serialize(tx, codec.Transaction);
8
+ }
9
+ /** Decode an unsigned transaction from canonical protocol bytes. */
10
+ function deserializeTransaction(data) {
11
+ return deserialize(data, codec.Transaction);
12
+ }
13
+ /** Serialize a signed transaction to the bytes accepted by the JSON-RPC API. */
14
+ function serializeSignedTransaction(stx) {
15
+ return serialize(stx, codec.SignedTransaction);
16
+ }
17
+ /** Decode a signed transaction from canonical protocol bytes. */
18
+ function deserializeSignedTransaction(data) {
19
+ return deserialize(data, codec.SignedTransaction);
20
+ }
21
+ //#endregion
22
+ export { serializeTransaction as i, deserializeTransaction as n, serializeSignedTransaction as r, deserializeSignedTransaction as t };
23
+
24
+ //# sourceMappingURL=transaction-CwkQxQOx.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transaction-CwkQxQOx.js","names":[],"sources":["../src/transaction/serialize.ts"],"sourcesContent":["import type { Transaction, SignedTransaction } from \"@thruputchain/protocol\";\nimport { serialize, deserialize, codec } from \"@thruputchain/protocol\";\n\n/** Serialize an unsigned transaction to its canonical protocol bytes. */\nexport function serializeTransaction(tx: Transaction): Uint8Array {\n return serialize(tx, codec.Transaction);\n}\n\n/** Decode an unsigned transaction from canonical protocol bytes. */\nexport function deserializeTransaction(data: Uint8Array): Transaction {\n return deserialize(data, codec.Transaction);\n}\n\n/** Serialize a signed transaction to the bytes accepted by the JSON-RPC API. */\nexport function serializeSignedTransaction(stx: SignedTransaction): Uint8Array {\n return serialize(stx, codec.SignedTransaction);\n}\n\n/** Decode a signed transaction from canonical protocol bytes. */\nexport function deserializeSignedTransaction(\n data: Uint8Array,\n): SignedTransaction {\n return deserialize(data, codec.SignedTransaction);\n}\n"],"mappings":";;;;;AAIA,SAAgB,qBAAqB,IAA6B;CAChE,OAAO,UAAU,IAAI,MAAM,WAAW;AACxC;;AAGA,SAAgB,uBAAuB,MAA+B;CACpE,OAAO,YAAY,MAAM,MAAM,WAAW;AAC5C;;AAGA,SAAgB,2BAA2B,KAAoC;CAC7E,OAAO,UAAU,KAAK,MAAM,iBAAiB;AAC/C;;AAGA,SAAgB,6BACd,MACmB;CACnB,OAAO,YAAY,MAAM,MAAM,iBAAiB;AAClD"}
@@ -0,0 +1,47 @@
1
+ require("./sign-BewmV_EL.cjs");
2
+ require("./size-OAFfOthl.cjs");
3
+ let _thruputchain_protocol = require("@thruputchain/protocol");
4
+ //#region src/transaction/serialize.ts
5
+ /** Serialize an unsigned transaction to its canonical protocol bytes. */
6
+ function serializeTransaction(tx) {
7
+ return (0, _thruputchain_protocol.serialize)(tx, _thruputchain_protocol.codec.Transaction);
8
+ }
9
+ /** Decode an unsigned transaction from canonical protocol bytes. */
10
+ function deserializeTransaction(data) {
11
+ return (0, _thruputchain_protocol.deserialize)(data, _thruputchain_protocol.codec.Transaction);
12
+ }
13
+ /** Serialize a signed transaction to the bytes accepted by the JSON-RPC API. */
14
+ function serializeSignedTransaction(stx) {
15
+ return (0, _thruputchain_protocol.serialize)(stx, _thruputchain_protocol.codec.SignedTransaction);
16
+ }
17
+ /** Decode a signed transaction from canonical protocol bytes. */
18
+ function deserializeSignedTransaction(data) {
19
+ return (0, _thruputchain_protocol.deserialize)(data, _thruputchain_protocol.codec.SignedTransaction);
20
+ }
21
+ //#endregion
22
+ Object.defineProperty(exports, "deserializeSignedTransaction", {
23
+ enumerable: true,
24
+ get: function() {
25
+ return deserializeSignedTransaction;
26
+ }
27
+ });
28
+ Object.defineProperty(exports, "deserializeTransaction", {
29
+ enumerable: true,
30
+ get: function() {
31
+ return deserializeTransaction;
32
+ }
33
+ });
34
+ Object.defineProperty(exports, "serializeSignedTransaction", {
35
+ enumerable: true,
36
+ get: function() {
37
+ return serializeSignedTransaction;
38
+ }
39
+ });
40
+ Object.defineProperty(exports, "serializeTransaction", {
41
+ enumerable: true,
42
+ get: function() {
43
+ return serializeTransaction;
44
+ }
45
+ });
46
+
47
+ //# sourceMappingURL=transaction-DrSrCJ5y.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transaction-DrSrCJ5y.cjs","names":["codec"],"sources":["../src/transaction/serialize.ts"],"sourcesContent":["import type { Transaction, SignedTransaction } from \"@thruputchain/protocol\";\nimport { serialize, deserialize, codec } from \"@thruputchain/protocol\";\n\n/** Serialize an unsigned transaction to its canonical protocol bytes. */\nexport function serializeTransaction(tx: Transaction): Uint8Array {\n return serialize(tx, codec.Transaction);\n}\n\n/** Decode an unsigned transaction from canonical protocol bytes. */\nexport function deserializeTransaction(data: Uint8Array): Transaction {\n return deserialize(data, codec.Transaction);\n}\n\n/** Serialize a signed transaction to the bytes accepted by the JSON-RPC API. */\nexport function serializeSignedTransaction(stx: SignedTransaction): Uint8Array {\n return serialize(stx, codec.SignedTransaction);\n}\n\n/** Decode a signed transaction from canonical protocol bytes. */\nexport function deserializeSignedTransaction(\n data: Uint8Array,\n): SignedTransaction {\n return deserialize(data, codec.SignedTransaction);\n}\n"],"mappings":";;;;;AAIA,SAAgB,qBAAqB,IAA6B;CAChE,QAAA,GAAA,uBAAA,UAAA,CAAiB,IAAIA,uBAAAA,MAAM,WAAW;AACxC;;AAGA,SAAgB,uBAAuB,MAA+B;CACpE,QAAA,GAAA,uBAAA,YAAA,CAAmB,MAAMA,uBAAAA,MAAM,WAAW;AAC5C;;AAGA,SAAgB,2BAA2B,KAAoC;CAC7E,QAAA,GAAA,uBAAA,UAAA,CAAiB,KAAKA,uBAAAA,MAAM,iBAAiB;AAC/C;;AAGA,SAAgB,6BACd,MACmB;CACnB,QAAA,GAAA,uBAAA,YAAA,CAAmB,MAAMA,uBAAAA,MAAM,iBAAiB;AAClD"}
@@ -0,0 +1,13 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_sign = require("./sign-BewmV_EL.cjs");
3
+ const require_transaction = require("./transaction-DrSrCJ5y.cjs");
4
+ const require_size = require("./size-OAFfOthl.cjs");
5
+ exports.createInvocation = require_sign.createInvocation;
6
+ exports.createTransaction = require_sign.createTransaction;
7
+ exports.deserializeSignedTransaction = require_transaction.deserializeSignedTransaction;
8
+ exports.deserializeTransaction = require_transaction.deserializeTransaction;
9
+ exports.pubkeySignatureEnvelopeBytes = require_size.pubkeySignatureEnvelopeBytes;
10
+ exports.serializeSignedTransaction = require_transaction.serializeSignedTransaction;
11
+ exports.serializeTransaction = require_transaction.serializeTransaction;
12
+ exports.signTransaction = require_sign.signTransaction;
13
+ exports.transactionSignaturePreimage = require_size.transactionSignaturePreimage;
@@ -0,0 +1,3 @@
1
+ import { n as signTransaction, t as SignerEntry } from "./sign-eUT0iGQG.cjs";
2
+ import { a as serializeSignedTransaction, c as createTransaction, i as deserializeTransaction, n as transactionSignaturePreimage, o as serializeTransaction, r as deserializeSignedTransaction, s as createInvocation, t as pubkeySignatureEnvelopeBytes } from "./index-DzrLv3EA.cjs";
3
+ export { type SignerEntry, createInvocation, createTransaction, deserializeSignedTransaction, deserializeTransaction, pubkeySignatureEnvelopeBytes, serializeSignedTransaction, serializeTransaction, signTransaction, transactionSignaturePreimage };
@@ -0,0 +1,3 @@
1
+ import { n as signTransaction, t as SignerEntry } from "./sign-Ve0eetRO.js";
2
+ import { a as serializeSignedTransaction, c as createTransaction, i as deserializeTransaction, n as transactionSignaturePreimage, o as serializeTransaction, r as deserializeSignedTransaction, s as createInvocation, t as pubkeySignatureEnvelopeBytes } from "./index-DzrLv3EA.js";
3
+ export { type SignerEntry, createInvocation, createTransaction, deserializeSignedTransaction, deserializeTransaction, pubkeySignatureEnvelopeBytes, serializeSignedTransaction, serializeTransaction, signTransaction, transactionSignaturePreimage };
@@ -0,0 +1,4 @@
1
+ import { n as createInvocation, r as createTransaction, t as signTransaction } from "./sign-DVIRyW8Y.js";
2
+ import { i as serializeTransaction, n as deserializeTransaction, r as serializeSignedTransaction, t as deserializeSignedTransaction } from "./transaction-CwkQxQOx.js";
3
+ import { n as transactionSignaturePreimage, t as pubkeySignatureEnvelopeBytes } from "./size-506oTE28.js";
4
+ export { createInvocation, createTransaction, deserializeSignedTransaction, deserializeTransaction, pubkeySignatureEnvelopeBytes, serializeSignedTransaction, serializeTransaction, signTransaction, transactionSignaturePreimage };
@@ -0,0 +1,24 @@
1
+ import { codec, serialize, sha256Hash } from "@thruputchain/protocol";
2
+ import { sha256 } from "@noble/hashes/sha2.js";
3
+ //#region src/derivation/transactionHash.ts
4
+ /**
5
+ * The transaction's network-wide identifier: `sha256(txs(stx.tx))`.
6
+ *
7
+ * The hash covers the {@link https://github.com/thruputchain/thruput-protocol | protocol}
8
+ * `Transaction` only — deliberately not the signatures wrapped around it. That
9
+ * keeps the identifier stable under signature malleability, so a third party
10
+ * cannot change the identity of an in-flight transaction by re-encoding its
11
+ * signatures, and it matches what the chain uses to index transactions.
12
+ *
13
+ * Not to be confused with the signature preimage, which is a different message
14
+ * and does carry a domain separator and the network hash — see
15
+ * {@link transactionSignaturePreimage}. This is what you look a transaction up
16
+ * by; that is what you sign.
17
+ */
18
+ function hashSignedTransaction(stx) {
19
+ return sha256Hash(sha256(serialize(stx.tx, codec.Transaction)));
20
+ }
21
+ //#endregion
22
+ export { hashSignedTransaction as t };
23
+
24
+ //# sourceMappingURL=transactionHash-CO9ajbvU.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transactionHash-CO9ajbvU.js","names":[],"sources":["../src/derivation/transactionHash.ts"],"sourcesContent":["import { sha256 } from \"@noble/hashes/sha2.js\";\nimport { codec, serialize, sha256Hash } from \"@thruputchain/protocol\";\nimport type { SHA256Hash, SignedTransaction } from \"@thruputchain/protocol\";\n\n/**\n * The transaction's network-wide identifier: `sha256(txs(stx.tx))`.\n *\n * The hash covers the {@link https://github.com/thruputchain/thruput-protocol | protocol}\n * `Transaction` only — deliberately not the signatures wrapped around it. That\n * keeps the identifier stable under signature malleability, so a third party\n * cannot change the identity of an in-flight transaction by re-encoding its\n * signatures, and it matches what the chain uses to index transactions.\n *\n * Not to be confused with the signature preimage, which is a different message\n * and does carry a domain separator and the network hash — see\n * {@link transactionSignaturePreimage}. This is what you look a transaction up\n * by; that is what you sign.\n */\nexport function hashSignedTransaction(stx: SignedTransaction): SHA256Hash {\n const bytes = serialize(stx.tx, codec.Transaction);\n return sha256Hash(sha256(bytes));\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAkBA,SAAgB,sBAAsB,KAAoC;CAExE,OAAO,WAAW,OADJ,UAAU,IAAI,IAAI,MAAM,WACT,CAAC,CAAC;AACjC"}
@@ -0,0 +1,29 @@
1
+ let _thruputchain_protocol = require("@thruputchain/protocol");
2
+ let _noble_hashes_sha2_js = require("@noble/hashes/sha2.js");
3
+ //#region src/derivation/transactionHash.ts
4
+ /**
5
+ * The transaction's network-wide identifier: `sha256(txs(stx.tx))`.
6
+ *
7
+ * The hash covers the {@link https://github.com/thruputchain/thruput-protocol | protocol}
8
+ * `Transaction` only — deliberately not the signatures wrapped around it. That
9
+ * keeps the identifier stable under signature malleability, so a third party
10
+ * cannot change the identity of an in-flight transaction by re-encoding its
11
+ * signatures, and it matches what the chain uses to index transactions.
12
+ *
13
+ * Not to be confused with the signature preimage, which is a different message
14
+ * and does carry a domain separator and the network hash — see
15
+ * {@link transactionSignaturePreimage}. This is what you look a transaction up
16
+ * by; that is what you sign.
17
+ */
18
+ function hashSignedTransaction(stx) {
19
+ return (0, _thruputchain_protocol.sha256Hash)((0, _noble_hashes_sha2_js.sha256)((0, _thruputchain_protocol.serialize)(stx.tx, _thruputchain_protocol.codec.Transaction)));
20
+ }
21
+ //#endregion
22
+ Object.defineProperty(exports, "hashSignedTransaction", {
23
+ enumerable: true,
24
+ get: function() {
25
+ return hashSignedTransaction;
26
+ }
27
+ });
28
+
29
+ //# sourceMappingURL=transactionHash-D5yf4KoL.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transactionHash-D5yf4KoL.cjs","names":["codec"],"sources":["../src/derivation/transactionHash.ts"],"sourcesContent":["import { sha256 } from \"@noble/hashes/sha2.js\";\nimport { codec, serialize, sha256Hash } from \"@thruputchain/protocol\";\nimport type { SHA256Hash, SignedTransaction } from \"@thruputchain/protocol\";\n\n/**\n * The transaction's network-wide identifier: `sha256(txs(stx.tx))`.\n *\n * The hash covers the {@link https://github.com/thruputchain/thruput-protocol | protocol}\n * `Transaction` only — deliberately not the signatures wrapped around it. That\n * keeps the identifier stable under signature malleability, so a third party\n * cannot change the identity of an in-flight transaction by re-encoding its\n * signatures, and it matches what the chain uses to index transactions.\n *\n * Not to be confused with the signature preimage, which is a different message\n * and does carry a domain separator and the network hash — see\n * {@link transactionSignaturePreimage}. This is what you look a transaction up\n * by; that is what you sign.\n */\nexport function hashSignedTransaction(stx: SignedTransaction): SHA256Hash {\n const bytes = serialize(stx.tx, codec.Transaction);\n return sha256Hash(sha256(bytes));\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAkBA,SAAgB,sBAAsB,KAAoC;CAExE,QAAA,GAAA,uBAAA,WAAA,EAAA,GAAA,sBAAA,OAAA,EAAA,GAAA,uBAAA,UAAA,CADwB,IAAI,IAAIA,uBAAAA,MAAM,WACT,CAAC,CAAC;AACjC"}
@@ -0,0 +1,252 @@
1
+ const require_codec = require("./codec-B7HJjMzI.cjs");
2
+ const require_hex = require("./hex-DkGpiZ5e.cjs");
3
+ const require_transactionHash = require("./transactionHash-D5yf4KoL.cjs");
4
+ const require_readError = require("./readError-BVbfTMLv.cjs");
5
+ let _thruputchain_protocol = require("@thruputchain/protocol");
6
+ let _thruputchain_protocol_utils = require("@thruputchain/protocol/utils");
7
+ //#region src/transport/mock.ts
8
+ const methods = [
9
+ "getVersionInfo",
10
+ "getNetworkInfo",
11
+ "getChainTip",
12
+ "getChainConfig",
13
+ "getServerLimits",
14
+ "getBalance",
15
+ "getRegisteredAuth",
16
+ "getBlockByHeight",
17
+ "dev_getPendingTransactionCount",
18
+ "simulateInvocation",
19
+ "simulateInvocations",
20
+ "sendTransaction",
21
+ "getTransactionReceipt",
22
+ "getTransactionStatus",
23
+ "getTransactionsByRootAddress",
24
+ "getTransactionsByBlock",
25
+ "getEvents",
26
+ "getStorage",
27
+ "faucet_requestAirdrop"
28
+ ];
29
+ /** Deterministic native RPC transport for examples; it does not execute contract code. */
30
+ var MockTransport = class {
31
+ #height = 0n;
32
+ #transactions = /* @__PURE__ */ new Map();
33
+ async request(method, params = {}, options) {
34
+ options?.signal?.throwIfAborted();
35
+ if (Array.isArray(params)) throw new TypeError("Native RPC params must be a named object");
36
+ const stateBlockHeight = this.#height.toString();
37
+ const bounds = {
38
+ oldestIndexedBlockHeight: "0",
39
+ latestIndexedBlockHeight: stateBlockHeight,
40
+ nextCursor: null
41
+ };
42
+ const simulation = {
43
+ output: {
44
+ result: "return",
45
+ returnData: "0x"
46
+ },
47
+ events: [],
48
+ gasUsed: "0"
49
+ };
50
+ let result;
51
+ switch (method) {
52
+ case "getVersionInfo":
53
+ result = {
54
+ wireFormat: "14.1.1",
55
+ implementation: "mock",
56
+ supportedMethods: [...methods]
57
+ };
58
+ break;
59
+ case "getNetworkInfo":
60
+ result = { networkHash: "1".repeat(32) };
61
+ break;
62
+ case "getChainTip":
63
+ result = {
64
+ blockHeight: stateBlockHeight,
65
+ blockHash: this.#blockHash(this.#height)
66
+ };
67
+ break;
68
+ case "getChainConfig":
69
+ result = { stated: { maxNewContractsPerTx: 4 } };
70
+ break;
71
+ case "getServerLimits":
72
+ result = {
73
+ maxSimulationGas: "100000000",
74
+ maxSimulationCalldataBytes: "65536",
75
+ maxEventsPerPage: 200,
76
+ maxTransactionsPerPage: 200,
77
+ maxCursorBytes: "1024",
78
+ simulationBatch: {
79
+ maxInvocations: 16,
80
+ maxCalldataBytes: 65536,
81
+ maxGas: "1600000000",
82
+ maxBackendResponseBytes: 1e6,
83
+ timeoutMs: "3000"
84
+ }
85
+ };
86
+ break;
87
+ case "getBalance":
88
+ result = {
89
+ address: params.address,
90
+ rawBalance: "0",
91
+ stateBlockHeight
92
+ };
93
+ break;
94
+ case "getRegisteredAuth":
95
+ result = {
96
+ address: params.address,
97
+ configuration: null,
98
+ stateBlockHeight
99
+ };
100
+ break;
101
+ case "getStorage":
102
+ result = {
103
+ item: null,
104
+ stateBlockHeight
105
+ };
106
+ break;
107
+ case "dev_getPendingTransactionCount":
108
+ result = { count: "0" };
109
+ break;
110
+ case "simulateInvocation":
111
+ result = {
112
+ ...simulation,
113
+ stateBlockHeight
114
+ };
115
+ break;
116
+ case "simulateInvocations":
117
+ result = {
118
+ stateBlockHeight,
119
+ results: params.invocations.map(() => structuredClone(simulation))
120
+ };
121
+ break;
122
+ case "faucet_requestAirdrop":
123
+ result = {
124
+ attemptStatus: "succeeded",
125
+ recipient: params.recipient,
126
+ rawAmount: "100000000",
127
+ transactionHash: this.#blockHash(this.#height),
128
+ blockHeight: stateBlockHeight,
129
+ execution: {
130
+ result: "return",
131
+ returnData: "0x"
132
+ }
133
+ };
134
+ break;
135
+ case "sendTransaction": {
136
+ const hash = (0, _thruputchain_protocol_utils.toBase58)(require_transactionHash.hashSignedTransaction((0, _thruputchain_protocol.deserialize)(require_hex.fromHex0x(String(params.signedTransaction)), _thruputchain_protocol.codec.SignedTransaction)));
137
+ if (!this.#transactions.has(hash)) this.#transactions.set(hash, ++this.#height);
138
+ result = {
139
+ transactionHash: hash,
140
+ admission: "accepted"
141
+ };
142
+ break;
143
+ }
144
+ case "getTransactionReceipt": {
145
+ const height = this.#transactions.get(String(params.transactionHash));
146
+ result = height === void 0 ? null : {
147
+ transactionHash: params.transactionHash,
148
+ blockHeight: height.toString(),
149
+ execution: {
150
+ result: "return",
151
+ returnData: "0x"
152
+ },
153
+ events: [],
154
+ gasUsed: "0"
155
+ };
156
+ break;
157
+ }
158
+ case "getTransactionStatus": {
159
+ const height = this.#transactions.get(String(params.transactionHash));
160
+ result = height === void 0 ? { status: "unknown" } : {
161
+ status: "committed",
162
+ blockHeight: height.toString()
163
+ };
164
+ break;
165
+ }
166
+ case "getEvents":
167
+ result = {
168
+ ...bounds,
169
+ events: []
170
+ };
171
+ break;
172
+ case "getTransactionsByRootAddress":
173
+ case "getTransactionsByBlock":
174
+ result = {
175
+ ...bounds,
176
+ transactions: []
177
+ };
178
+ break;
179
+ case "getBlockByHeight": {
180
+ const height = BigInt(String(params.blockHeight));
181
+ result = height <= 0n || height > this.#height ? null : {
182
+ blockHash: this.#blockHash(height),
183
+ protocol: 0,
184
+ networkHash: "1".repeat(32),
185
+ proposer: "1".repeat(32),
186
+ blockTimepoint: "0",
187
+ blockHeight: height.toString(),
188
+ txsHash: this.#blockHash(height),
189
+ storageHash: this.#blockHash(height),
190
+ eventsHash: this.#blockHash(height),
191
+ configHash: this.#blockHash(height),
192
+ prevBlockHash: this.#blockHash(height - 1n),
193
+ proposalTxsHash: this.#blockHash(height),
194
+ upgrades: []
195
+ };
196
+ break;
197
+ }
198
+ default: throw new Error(`MockTransport: method not implemented: ${method}`);
199
+ }
200
+ return result;
201
+ }
202
+ #blockHash(height) {
203
+ const bytes = new Uint8Array(32);
204
+ new DataView(bytes.buffer).setBigUint64(24, height);
205
+ return (0, _thruputchain_protocol_utils.toBase58)(bytes);
206
+ }
207
+ };
208
+ //#endregion
209
+ //#region src/transport/txInvalidDetail.ts
210
+ /** Read known transaction-bound evidence without inferring retry permission. */
211
+ function txInvalidDetail(error) {
212
+ if (!(error instanceof require_readError.NativeRpcError) || error.decoded.classification !== "known" || error.decoded.data.kind !== "transactionInvalid") return null;
213
+ const detail = error.decoded.data.detail;
214
+ return !detail || detail instanceof require_codec.UnsupportedRpcValue ? null : detail;
215
+ }
216
+ //#endregion
217
+ //#region src/rpc/errors.ts
218
+ /** Native causes. Codes alone never grant write retry permission. */
219
+ const NativeRpcErrorCode = {
220
+ BackendDataInvalid: -32054,
221
+ BackendTimeout: -32051,
222
+ BackendUnavailable: -32050,
223
+ FundingAttemptStopped: -32030,
224
+ HistoryUnavailable: -32013,
225
+ InvalidParams: -32602,
226
+ LocalFundingUnresolved: -32031,
227
+ Overloaded: -32053,
228
+ StateHeightUnavailable: -32012,
229
+ TransactionInvalid: -32e3,
230
+ TransactionRejected: -32001
231
+ };
232
+ //#endregion
233
+ Object.defineProperty(exports, "MockTransport", {
234
+ enumerable: true,
235
+ get: function() {
236
+ return MockTransport;
237
+ }
238
+ });
239
+ Object.defineProperty(exports, "NativeRpcErrorCode", {
240
+ enumerable: true,
241
+ get: function() {
242
+ return NativeRpcErrorCode;
243
+ }
244
+ });
245
+ Object.defineProperty(exports, "txInvalidDetail", {
246
+ enumerable: true,
247
+ get: function() {
248
+ return txInvalidDetail;
249
+ }
250
+ });
251
+
252
+ //# sourceMappingURL=transport-B-P16rs6.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transport-B-P16rs6.cjs","names":["#height","#blockHash","hashSignedTransaction","fromHex0x","codec","#transactions","NativeRpcError","UnsupportedRpcValue"],"sources":["../src/transport/mock.ts","../src/transport/txInvalidDetail.ts","../src/rpc/errors.ts"],"sourcesContent":["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\";\n\nconst methods = [\n \"getVersionInfo\",\n \"getNetworkInfo\",\n \"getChainTip\",\n \"getChainConfig\",\n \"getServerLimits\",\n \"getBalance\",\n \"getRegisteredAuth\",\n \"getBlockByHeight\",\n \"dev_getPendingTransactionCount\",\n \"simulateInvocation\",\n \"simulateInvocations\",\n \"sendTransaction\",\n \"getTransactionReceipt\",\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 \"getVersionInfo\":\n result = {\n wireFormat: \"14.1.1\",\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 \"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 { NativeRpcError } from \"../rpc/errorReader.js\";\nimport { UnsupportedRpcValue } from \"../rpc/codec.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 !(error instanceof NativeRpcError) ||\n error.decoded.classification !== \"known\" ||\n error.decoded.data.kind !== \"transactionInvalid\"\n )\n return null;\n const detail = error.decoded.data.detail;\n return !detail || detail instanceof UnsupportedRpcValue ? 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 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":";;;;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