@hfunlabs/hyperliquid 0.30.0-hfunlabs.1 → 0.30.2-hfunlabs.2

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 (397) hide show
  1. package/esm/_dnt.shims.d.ts +2 -0
  2. package/esm/_dnt.shims.d.ts.map +1 -0
  3. package/esm/_dnt.shims.js +58 -0
  4. package/esm/_dnt.shims.js.map +1 -0
  5. package/esm/deps/jsr.io/@noble/curves/2.0.1/src/abstract/curve.d.ts +195 -0
  6. package/esm/deps/jsr.io/@noble/curves/2.0.1/src/abstract/curve.d.ts.map +1 -0
  7. package/esm/deps/jsr.io/@noble/curves/2.0.1/src/abstract/curve.js +457 -0
  8. package/esm/deps/jsr.io/@noble/curves/2.0.1/src/abstract/curve.js.map +1 -0
  9. package/esm/deps/jsr.io/@noble/curves/2.0.1/src/abstract/hash-to-curve.d.ts +90 -0
  10. package/esm/deps/jsr.io/@noble/curves/2.0.1/src/abstract/hash-to-curve.d.ts.map +1 -0
  11. package/esm/deps/jsr.io/@noble/curves/2.0.1/src/abstract/hash-to-curve.js +207 -0
  12. package/esm/deps/jsr.io/@noble/curves/2.0.1/src/abstract/hash-to-curve.js.map +1 -0
  13. package/esm/deps/jsr.io/@noble/curves/2.0.1/src/abstract/modular.d.ts +159 -0
  14. package/esm/deps/jsr.io/@noble/curves/2.0.1/src/abstract/modular.d.ts.map +1 -0
  15. package/esm/deps/jsr.io/@noble/curves/2.0.1/src/abstract/modular.js +555 -0
  16. package/esm/deps/jsr.io/@noble/curves/2.0.1/src/abstract/modular.js.map +1 -0
  17. package/esm/deps/jsr.io/@noble/curves/2.0.1/src/abstract/weierstrass.d.ts +325 -0
  18. package/esm/deps/jsr.io/@noble/curves/2.0.1/src/abstract/weierstrass.d.ts.map +1 -0
  19. package/esm/deps/jsr.io/@noble/curves/2.0.1/src/abstract/weierstrass.js +1222 -0
  20. package/esm/deps/jsr.io/@noble/curves/2.0.1/src/abstract/weierstrass.js.map +1 -0
  21. package/esm/deps/jsr.io/@noble/curves/2.0.1/src/secp256k1.d.ts +76 -0
  22. package/esm/deps/jsr.io/@noble/curves/2.0.1/src/secp256k1.d.ts.map +1 -0
  23. package/esm/deps/jsr.io/@noble/curves/2.0.1/src/secp256k1.js +283 -0
  24. package/esm/deps/jsr.io/@noble/curves/2.0.1/src/secp256k1.js.map +1 -0
  25. package/esm/deps/jsr.io/@noble/curves/2.0.1/src/utils.d.ts +103 -0
  26. package/esm/deps/jsr.io/@noble/curves/2.0.1/src/utils.d.ts.map +1 -0
  27. package/esm/deps/jsr.io/@noble/curves/2.0.1/src/utils.js +241 -0
  28. package/esm/deps/jsr.io/@noble/curves/2.0.1/src/utils.js.map +1 -0
  29. package/esm/deps/jsr.io/@noble/hashes/2.0.1/src/_md.d.ts +49 -0
  30. package/esm/deps/jsr.io/@noble/hashes/2.0.1/src/_md.d.ts.map +1 -0
  31. package/esm/deps/jsr.io/@noble/hashes/2.0.1/src/_md.js +147 -0
  32. package/esm/deps/jsr.io/@noble/hashes/2.0.1/src/_md.js.map +1 -0
  33. package/esm/deps/jsr.io/@noble/hashes/2.0.1/src/_u64.d.ts +55 -0
  34. package/esm/deps/jsr.io/@noble/hashes/2.0.1/src/_u64.d.ts.map +1 -0
  35. package/esm/deps/jsr.io/@noble/hashes/2.0.1/src/_u64.js +67 -0
  36. package/esm/deps/jsr.io/@noble/hashes/2.0.1/src/_u64.js.map +1 -0
  37. package/esm/deps/jsr.io/@noble/hashes/2.0.1/src/hmac.d.ts +36 -0
  38. package/esm/deps/jsr.io/@noble/hashes/2.0.1/src/hmac.d.ts.map +1 -0
  39. package/esm/deps/jsr.io/@noble/hashes/2.0.1/src/hmac.js +90 -0
  40. package/esm/deps/jsr.io/@noble/hashes/2.0.1/src/hmac.js.map +1 -0
  41. package/esm/deps/jsr.io/@noble/hashes/2.0.1/src/sha2.d.ts +199 -0
  42. package/esm/deps/jsr.io/@noble/hashes/2.0.1/src/sha2.d.ts.map +1 -0
  43. package/esm/deps/jsr.io/@noble/hashes/2.0.1/src/sha2.js +397 -0
  44. package/esm/deps/jsr.io/@noble/hashes/2.0.1/src/sha2.js.map +1 -0
  45. package/esm/deps/jsr.io/@noble/hashes/2.0.1/src/sha3.d.ts +58 -0
  46. package/esm/deps/jsr.io/@noble/hashes/2.0.1/src/sha3.d.ts.map +1 -0
  47. package/esm/deps/jsr.io/@noble/hashes/2.0.1/src/sha3.js +254 -0
  48. package/esm/deps/jsr.io/@noble/hashes/2.0.1/src/sha3.js.map +1 -0
  49. package/esm/deps/jsr.io/@noble/hashes/2.0.1/src/utils.d.ts +124 -0
  50. package/esm/deps/jsr.io/@noble/hashes/2.0.1/src/utils.d.ts.map +1 -0
  51. package/esm/deps/jsr.io/@noble/hashes/2.0.1/src/utils.js +243 -0
  52. package/esm/deps/jsr.io/@noble/hashes/2.0.1/src/utils.js.map +1 -0
  53. package/esm/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/advanced/abi-mapper.d.ts +44 -0
  54. package/esm/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/advanced/abi-mapper.d.ts.map +1 -0
  55. package/esm/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/advanced/abi-mapper.js +144 -0
  56. package/esm/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/advanced/abi-mapper.js.map +1 -0
  57. package/esm/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/core/address.d.ts +38 -0
  58. package/esm/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/core/address.d.ts.map +1 -0
  59. package/esm/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/core/address.js +96 -0
  60. package/esm/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/core/address.js.map +1 -0
  61. package/esm/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/core/rlp.d.ts +23 -0
  62. package/esm/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/core/rlp.d.ts.map +1 -0
  63. package/esm/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/core/rlp.js +98 -0
  64. package/esm/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/core/rlp.js.map +1 -0
  65. package/esm/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/core/tx-internal.d.ts +300 -0
  66. package/esm/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/core/tx-internal.d.ts.map +1 -0
  67. package/esm/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/core/tx-internal.js +535 -0
  68. package/esm/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/core/tx-internal.js.map +1 -0
  69. package/esm/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/core/tx.d.ts +98 -0
  70. package/esm/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/core/tx.d.ts.map +1 -0
  71. package/esm/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/core/tx.js +207 -0
  72. package/esm/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/core/tx.js.map +1 -0
  73. package/esm/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/core/typed-data.d.ts +78 -0
  74. package/esm/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/core/typed-data.d.ts.map +1 -0
  75. package/esm/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/core/typed-data.js +298 -0
  76. package/esm/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/core/typed-data.js.map +1 -0
  77. package/esm/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/index.d.ts +6 -0
  78. package/esm/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/index.d.ts.map +1 -0
  79. package/esm/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/index.js +6 -0
  80. package/esm/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/index.js.map +1 -0
  81. package/esm/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/utils.d.ts +66 -0
  82. package/esm/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/utils.d.ts.map +1 -0
  83. package/esm/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/utils.js +180 -0
  84. package/esm/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/utils.js.map +1 -0
  85. package/esm/deps/jsr.io/@paulmillr/micro-packed/0.8.0/src/index.d.ts +877 -0
  86. package/esm/deps/jsr.io/@paulmillr/micro-packed/0.8.0/src/index.d.ts.map +1 -0
  87. package/esm/deps/jsr.io/@paulmillr/micro-packed/0.8.0/src/index.js +2001 -0
  88. package/esm/deps/jsr.io/@paulmillr/micro-packed/0.8.0/src/index.js.map +1 -0
  89. package/esm/deps/jsr.io/@scure/base/2.0.0/index.d.ts +294 -0
  90. package/esm/deps/jsr.io/@scure/base/2.0.0/index.d.ts.map +1 -0
  91. package/esm/deps/jsr.io/@scure/base/2.0.0/index.js +704 -0
  92. package/esm/deps/jsr.io/@scure/base/2.0.0/index.js.map +1 -0
  93. package/esm/deps/jsr.io/@std/async/1.0.16/unstable_semaphore.d.ts +93 -0
  94. package/esm/deps/jsr.io/@std/async/1.0.16/unstable_semaphore.d.ts.map +1 -0
  95. package/esm/deps/jsr.io/@std/async/1.0.16/unstable_semaphore.js +137 -0
  96. package/esm/deps/jsr.io/@std/async/1.0.16/unstable_semaphore.js.map +1 -0
  97. package/esm/src/api/exchange/_methods/_base/_nonce.d.ts +3 -2
  98. package/esm/src/api/exchange/_methods/_base/_nonce.d.ts.map +1 -1
  99. package/esm/src/api/exchange/_methods/_base/_nonce.js +3 -2
  100. package/esm/src/api/exchange/_methods/_base/_nonce.js.map +1 -1
  101. package/esm/src/api/exchange/_methods/_base/_semaphore.d.ts +7 -6
  102. package/esm/src/api/exchange/_methods/_base/_semaphore.d.ts.map +1 -1
  103. package/esm/src/api/exchange/_methods/_base/_semaphore.js +34 -47
  104. package/esm/src/api/exchange/_methods/_base/_semaphore.js.map +1 -1
  105. package/esm/src/api/exchange/_methods/_base/execute.d.ts +14 -3
  106. package/esm/src/api/exchange/_methods/_base/execute.d.ts.map +1 -1
  107. package/esm/src/api/exchange/_methods/_base/execute.js +44 -10
  108. package/esm/src/api/exchange/_methods/_base/execute.js.map +1 -1
  109. package/esm/src/api/exchange/_methods/batchModify.d.ts +6 -6
  110. package/esm/src/api/exchange/_methods/createVault.d.ts +5 -5
  111. package/esm/src/api/exchange/_methods/modify.d.ts +5 -5
  112. package/esm/src/api/exchange/_methods/order.d.ts +13 -13
  113. package/esm/src/api/exchange/_methods/order.d.ts.map +1 -1
  114. package/esm/src/api/exchange/_methods/order.js +4 -2
  115. package/esm/src/api/exchange/_methods/order.js.map +1 -1
  116. package/esm/src/api/exchange/client.d.ts +1 -1
  117. package/esm/src/api/exchange/client.d.ts.map +1 -1
  118. package/esm/src/api/exchange/client.js.map +1 -1
  119. package/esm/src/api/exchange/mod.d.ts +1 -1
  120. package/esm/src/api/exchange/mod.d.ts.map +1 -1
  121. package/esm/src/api/exchange/mod.js.map +1 -1
  122. package/esm/src/api/info/_methods/_base/commonSchemas.d.ts +8 -8
  123. package/esm/src/api/info/_methods/frontendOpenOrders.d.ts +3 -3
  124. package/esm/src/api/info/_methods/historicalOrders.d.ts +4 -4
  125. package/esm/src/api/info/_methods/l3Orders.d.ts +11 -11
  126. package/esm/src/api/info/_methods/l4Orders.d.ts +6 -6
  127. package/esm/src/api/info/_methods/openOrders.d.ts +3 -3
  128. package/esm/src/api/info/_methods/orderStatus.d.ts +5 -5
  129. package/esm/src/api/info/_methods/recentTrades.d.ts +2 -2
  130. package/esm/src/api/info/_methods/twapHistory.d.ts +4 -4
  131. package/esm/src/api/info/_methods/userFills.d.ts +3 -3
  132. package/esm/src/api/info/_methods/userFillsByTime.d.ts +4 -4
  133. package/esm/src/api/info/_methods/userFunding.d.ts +3 -3
  134. package/esm/src/api/info/_methods/userFunding.js +2 -2
  135. package/esm/src/api/info/_methods/userFunding.js.map +1 -1
  136. package/esm/src/api/info/_methods/userTwapSliceFills.d.ts +4 -4
  137. package/esm/src/api/info/_methods/userTwapSliceFillsByTime.d.ts +5 -5
  138. package/esm/src/api/info/_methods/webData2.d.ts +9 -9
  139. package/esm/src/api/subscription/_methods/assetCtxs.d.ts +2 -0
  140. package/esm/src/api/subscription/_methods/assetCtxs.d.ts.map +1 -1
  141. package/esm/src/api/subscription/_methods/assetCtxs.js.map +1 -1
  142. package/esm/src/api/subscription/_methods/clearinghouseState.d.ts +2 -0
  143. package/esm/src/api/subscription/_methods/clearinghouseState.d.ts.map +1 -1
  144. package/esm/src/api/subscription/_methods/clearinghouseState.js +2 -0
  145. package/esm/src/api/subscription/_methods/clearinghouseState.js.map +1 -1
  146. package/esm/src/api/subscription/_methods/explorerBlock.d.ts +2 -0
  147. package/esm/src/api/subscription/_methods/explorerBlock.d.ts.map +1 -1
  148. package/esm/src/api/subscription/_methods/explorerBlock.js +2 -0
  149. package/esm/src/api/subscription/_methods/explorerBlock.js.map +1 -1
  150. package/esm/src/api/subscription/_methods/explorerTxs.d.ts +2 -0
  151. package/esm/src/api/subscription/_methods/explorerTxs.d.ts.map +1 -1
  152. package/esm/src/api/subscription/_methods/explorerTxs.js +2 -0
  153. package/esm/src/api/subscription/_methods/explorerTxs.js.map +1 -1
  154. package/esm/src/api/subscription/_methods/openOrders.d.ts +5 -5
  155. package/esm/src/api/subscription/_methods/orderUpdates.d.ts +4 -4
  156. package/esm/src/api/subscription/_methods/trades.d.ts +3 -3
  157. package/esm/src/api/subscription/_methods/twapStates.d.ts +9 -4
  158. package/esm/src/api/subscription/_methods/twapStates.d.ts.map +1 -1
  159. package/esm/src/api/subscription/_methods/twapStates.js +6 -1
  160. package/esm/src/api/subscription/_methods/twapStates.js.map +1 -1
  161. package/esm/src/api/subscription/_methods/userEvents.d.ts +17 -17
  162. package/esm/src/api/subscription/_methods/userFills.d.ts +5 -5
  163. package/esm/src/api/subscription/_methods/userHistoricalOrders.d.ts +6 -6
  164. package/esm/src/api/subscription/_methods/userTwapHistory.d.ts +6 -6
  165. package/esm/src/api/subscription/_methods/userTwapSliceFills.d.ts +6 -6
  166. package/esm/src/api/subscription/_methods/webData2.d.ts +11 -11
  167. package/esm/src/signing/_privateKeySigner.js +1 -1
  168. package/esm/src/signing/_privateKeySigner.js.map +1 -1
  169. package/esm/src/signing/mod.js +1 -1
  170. package/esm/src/signing/mod.js.map +1 -1
  171. package/package.json +2 -3
  172. package/script/_dnt.shims.d.ts +2 -0
  173. package/script/_dnt.shims.d.ts.map +1 -0
  174. package/script/_dnt.shims.js +61 -0
  175. package/script/_dnt.shims.js.map +1 -0
  176. package/script/deps/jsr.io/@noble/curves/2.0.1/src/abstract/curve.d.ts +195 -0
  177. package/script/deps/jsr.io/@noble/curves/2.0.1/src/abstract/curve.d.ts.map +1 -0
  178. package/script/deps/jsr.io/@noble/curves/2.0.1/src/abstract/curve.js +468 -0
  179. package/script/deps/jsr.io/@noble/curves/2.0.1/src/abstract/curve.js.map +1 -0
  180. package/script/deps/jsr.io/@noble/curves/2.0.1/src/abstract/hash-to-curve.d.ts +90 -0
  181. package/script/deps/jsr.io/@noble/curves/2.0.1/src/abstract/hash-to-curve.d.ts.map +1 -0
  182. package/script/deps/jsr.io/@noble/curves/2.0.1/src/abstract/hash-to-curve.js +215 -0
  183. package/script/deps/jsr.io/@noble/curves/2.0.1/src/abstract/hash-to-curve.js.map +1 -0
  184. package/script/deps/jsr.io/@noble/curves/2.0.1/src/abstract/modular.d.ts +159 -0
  185. package/script/deps/jsr.io/@noble/curves/2.0.1/src/abstract/modular.d.ts.map +1 -0
  186. package/script/deps/jsr.io/@noble/curves/2.0.1/src/abstract/modular.js +578 -0
  187. package/script/deps/jsr.io/@noble/curves/2.0.1/src/abstract/modular.js.map +1 -0
  188. package/script/deps/jsr.io/@noble/curves/2.0.1/src/abstract/weierstrass.d.ts +325 -0
  189. package/script/deps/jsr.io/@noble/curves/2.0.1/src/abstract/weierstrass.d.ts.map +1 -0
  190. package/script/deps/jsr.io/@noble/curves/2.0.1/src/abstract/weierstrass.js +1232 -0
  191. package/script/deps/jsr.io/@noble/curves/2.0.1/src/abstract/weierstrass.js.map +1 -0
  192. package/script/deps/jsr.io/@noble/curves/2.0.1/src/secp256k1.d.ts +76 -0
  193. package/script/deps/jsr.io/@noble/curves/2.0.1/src/secp256k1.d.ts.map +1 -0
  194. package/script/deps/jsr.io/@noble/curves/2.0.1/src/secp256k1.js +286 -0
  195. package/script/deps/jsr.io/@noble/curves/2.0.1/src/secp256k1.js.map +1 -0
  196. package/script/deps/jsr.io/@noble/curves/2.0.1/src/utils.d.ts +103 -0
  197. package/script/deps/jsr.io/@noble/curves/2.0.1/src/utils.d.ts.map +1 -0
  198. package/script/deps/jsr.io/@noble/curves/2.0.1/src/utils.js +273 -0
  199. package/script/deps/jsr.io/@noble/curves/2.0.1/src/utils.js.map +1 -0
  200. package/script/deps/jsr.io/@noble/hashes/2.0.1/src/_md.d.ts +49 -0
  201. package/script/deps/jsr.io/@noble/hashes/2.0.1/src/_md.d.ts.map +1 -0
  202. package/script/deps/jsr.io/@noble/hashes/2.0.1/src/_md.js +153 -0
  203. package/script/deps/jsr.io/@noble/hashes/2.0.1/src/_md.js.map +1 -0
  204. package/script/deps/jsr.io/@noble/hashes/2.0.1/src/_u64.d.ts +55 -0
  205. package/script/deps/jsr.io/@noble/hashes/2.0.1/src/_u64.d.ts.map +1 -0
  206. package/script/deps/jsr.io/@noble/hashes/2.0.1/src/_u64.js +90 -0
  207. package/script/deps/jsr.io/@noble/hashes/2.0.1/src/_u64.js.map +1 -0
  208. package/script/deps/jsr.io/@noble/hashes/2.0.1/src/hmac.d.ts +36 -0
  209. package/script/deps/jsr.io/@noble/hashes/2.0.1/src/hmac.d.ts.map +1 -0
  210. package/script/deps/jsr.io/@noble/hashes/2.0.1/src/hmac.js +95 -0
  211. package/script/deps/jsr.io/@noble/hashes/2.0.1/src/hmac.js.map +1 -0
  212. package/script/deps/jsr.io/@noble/hashes/2.0.1/src/sha2.d.ts +199 -0
  213. package/script/deps/jsr.io/@noble/hashes/2.0.1/src/sha2.d.ts.map +1 -0
  214. package/script/deps/jsr.io/@noble/hashes/2.0.1/src/sha2.js +439 -0
  215. package/script/deps/jsr.io/@noble/hashes/2.0.1/src/sha2.js.map +1 -0
  216. package/script/deps/jsr.io/@noble/hashes/2.0.1/src/sha3.d.ts +58 -0
  217. package/script/deps/jsr.io/@noble/hashes/2.0.1/src/sha3.d.ts.map +1 -0
  218. package/script/deps/jsr.io/@noble/hashes/2.0.1/src/sha3.js +259 -0
  219. package/script/deps/jsr.io/@noble/hashes/2.0.1/src/sha3.js.map +1 -0
  220. package/script/deps/jsr.io/@noble/hashes/2.0.1/src/utils.d.ts +124 -0
  221. package/script/deps/jsr.io/@noble/hashes/2.0.1/src/utils.d.ts.map +1 -0
  222. package/script/deps/jsr.io/@noble/hashes/2.0.1/src/utils.js +304 -0
  223. package/script/deps/jsr.io/@noble/hashes/2.0.1/src/utils.js.map +1 -0
  224. package/script/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/advanced/abi-mapper.d.ts +44 -0
  225. package/script/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/advanced/abi-mapper.d.ts.map +1 -0
  226. package/script/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/advanced/abi-mapper.js +182 -0
  227. package/script/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/advanced/abi-mapper.js.map +1 -0
  228. package/script/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/core/address.d.ts +38 -0
  229. package/script/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/core/address.d.ts.map +1 -0
  230. package/script/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/core/address.js +99 -0
  231. package/script/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/core/address.js.map +1 -0
  232. package/script/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/core/rlp.d.ts +23 -0
  233. package/script/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/core/rlp.d.ts.map +1 -0
  234. package/script/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/core/rlp.js +134 -0
  235. package/script/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/core/rlp.js.map +1 -0
  236. package/script/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/core/tx-internal.d.ts +300 -0
  237. package/script/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/core/tx-internal.d.ts.map +1 -0
  238. package/script/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/core/tx-internal.js +576 -0
  239. package/script/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/core/tx-internal.js.map +1 -0
  240. package/script/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/core/tx.d.ts +98 -0
  241. package/script/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/core/tx.d.ts.map +1 -0
  242. package/script/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/core/tx.js +211 -0
  243. package/script/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/core/tx.js.map +1 -0
  244. package/script/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/core/typed-data.d.ts +78 -0
  245. package/script/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/core/typed-data.d.ts.map +1 -0
  246. package/script/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/core/typed-data.js +308 -0
  247. package/script/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/core/typed-data.js.map +1 -0
  248. package/script/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/index.d.ts +6 -0
  249. package/script/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/index.d.ts.map +1 -0
  250. package/script/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/index.js +21 -0
  251. package/script/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/index.js.map +1 -0
  252. package/script/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/utils.d.ts +66 -0
  253. package/script/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/utils.d.ts.map +1 -0
  254. package/script/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/utils.js +195 -0
  255. package/script/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/utils.js.map +1 -0
  256. package/script/deps/jsr.io/@paulmillr/micro-packed/0.8.0/src/index.d.ts +877 -0
  257. package/script/deps/jsr.io/@paulmillr/micro-packed/0.8.0/src/index.d.ts.map +1 -0
  258. package/script/deps/jsr.io/@paulmillr/micro-packed/0.8.0/src/index.js +2032 -0
  259. package/script/deps/jsr.io/@paulmillr/micro-packed/0.8.0/src/index.js.map +1 -0
  260. package/script/deps/jsr.io/@scure/base/2.0.0/index.d.ts +294 -0
  261. package/script/deps/jsr.io/@scure/base/2.0.0/index.d.ts.map +1 -0
  262. package/script/deps/jsr.io/@scure/base/2.0.0/index.js +710 -0
  263. package/script/deps/jsr.io/@scure/base/2.0.0/index.js.map +1 -0
  264. package/script/deps/jsr.io/@std/async/1.0.16/unstable_semaphore.d.ts +93 -0
  265. package/script/deps/jsr.io/@std/async/1.0.16/unstable_semaphore.d.ts.map +1 -0
  266. package/script/deps/jsr.io/@std/async/1.0.16/unstable_semaphore.js +141 -0
  267. package/script/deps/jsr.io/@std/async/1.0.16/unstable_semaphore.js.map +1 -0
  268. package/script/src/api/exchange/_methods/_base/_nonce.d.ts +3 -2
  269. package/script/src/api/exchange/_methods/_base/_nonce.d.ts.map +1 -1
  270. package/script/src/api/exchange/_methods/_base/_nonce.js +4 -3
  271. package/script/src/api/exchange/_methods/_base/_nonce.js.map +1 -1
  272. package/script/src/api/exchange/_methods/_base/_semaphore.d.ts +7 -6
  273. package/script/src/api/exchange/_methods/_base/_semaphore.d.ts.map +1 -1
  274. package/script/src/api/exchange/_methods/_base/_semaphore.js +35 -50
  275. package/script/src/api/exchange/_methods/_base/_semaphore.js.map +1 -1
  276. package/script/src/api/exchange/_methods/_base/execute.d.ts +14 -3
  277. package/script/src/api/exchange/_methods/_base/execute.d.ts.map +1 -1
  278. package/script/src/api/exchange/_methods/_base/execute.js +43 -9
  279. package/script/src/api/exchange/_methods/_base/execute.js.map +1 -1
  280. package/script/src/api/exchange/_methods/batchModify.d.ts +6 -6
  281. package/script/src/api/exchange/_methods/createVault.d.ts +5 -5
  282. package/script/src/api/exchange/_methods/modify.d.ts +5 -5
  283. package/script/src/api/exchange/_methods/order.d.ts +13 -13
  284. package/script/src/api/exchange/_methods/order.d.ts.map +1 -1
  285. package/script/src/api/exchange/_methods/order.js +4 -2
  286. package/script/src/api/exchange/_methods/order.js.map +1 -1
  287. package/script/src/api/exchange/client.d.ts +1 -1
  288. package/script/src/api/exchange/client.d.ts.map +1 -1
  289. package/script/src/api/exchange/client.js.map +1 -1
  290. package/script/src/api/exchange/mod.d.ts +1 -1
  291. package/script/src/api/exchange/mod.d.ts.map +1 -1
  292. package/script/src/api/exchange/mod.js.map +1 -1
  293. package/script/src/api/info/_methods/_base/commonSchemas.d.ts +8 -8
  294. package/script/src/api/info/_methods/frontendOpenOrders.d.ts +3 -3
  295. package/script/src/api/info/_methods/historicalOrders.d.ts +4 -4
  296. package/script/src/api/info/_methods/l3Orders.d.ts +11 -11
  297. package/script/src/api/info/_methods/l4Orders.d.ts +6 -6
  298. package/script/src/api/info/_methods/openOrders.d.ts +3 -3
  299. package/script/src/api/info/_methods/orderStatus.d.ts +5 -5
  300. package/script/src/api/info/_methods/recentTrades.d.ts +2 -2
  301. package/script/src/api/info/_methods/twapHistory.d.ts +4 -4
  302. package/script/src/api/info/_methods/userFills.d.ts +3 -3
  303. package/script/src/api/info/_methods/userFillsByTime.d.ts +4 -4
  304. package/script/src/api/info/_methods/userFunding.d.ts +3 -3
  305. package/script/src/api/info/_methods/userFunding.js +2 -2
  306. package/script/src/api/info/_methods/userFunding.js.map +1 -1
  307. package/script/src/api/info/_methods/userTwapSliceFills.d.ts +4 -4
  308. package/script/src/api/info/_methods/userTwapSliceFillsByTime.d.ts +5 -5
  309. package/script/src/api/info/_methods/webData2.d.ts +9 -9
  310. package/script/src/api/subscription/_methods/assetCtxs.d.ts +2 -0
  311. package/script/src/api/subscription/_methods/assetCtxs.d.ts.map +1 -1
  312. package/script/src/api/subscription/_methods/assetCtxs.js.map +1 -1
  313. package/script/src/api/subscription/_methods/clearinghouseState.d.ts +2 -0
  314. package/script/src/api/subscription/_methods/clearinghouseState.d.ts.map +1 -1
  315. package/script/src/api/subscription/_methods/clearinghouseState.js +2 -0
  316. package/script/src/api/subscription/_methods/clearinghouseState.js.map +1 -1
  317. package/script/src/api/subscription/_methods/explorerBlock.d.ts +2 -0
  318. package/script/src/api/subscription/_methods/explorerBlock.d.ts.map +1 -1
  319. package/script/src/api/subscription/_methods/explorerBlock.js +2 -0
  320. package/script/src/api/subscription/_methods/explorerBlock.js.map +1 -1
  321. package/script/src/api/subscription/_methods/explorerTxs.d.ts +2 -0
  322. package/script/src/api/subscription/_methods/explorerTxs.d.ts.map +1 -1
  323. package/script/src/api/subscription/_methods/explorerTxs.js +2 -0
  324. package/script/src/api/subscription/_methods/explorerTxs.js.map +1 -1
  325. package/script/src/api/subscription/_methods/openOrders.d.ts +5 -5
  326. package/script/src/api/subscription/_methods/orderUpdates.d.ts +4 -4
  327. package/script/src/api/subscription/_methods/trades.d.ts +3 -3
  328. package/script/src/api/subscription/_methods/twapStates.d.ts +9 -4
  329. package/script/src/api/subscription/_methods/twapStates.d.ts.map +1 -1
  330. package/script/src/api/subscription/_methods/twapStates.js +6 -1
  331. package/script/src/api/subscription/_methods/twapStates.js.map +1 -1
  332. package/script/src/api/subscription/_methods/userEvents.d.ts +17 -17
  333. package/script/src/api/subscription/_methods/userFills.d.ts +5 -5
  334. package/script/src/api/subscription/_methods/userHistoricalOrders.d.ts +6 -6
  335. package/script/src/api/subscription/_methods/userTwapHistory.d.ts +6 -6
  336. package/script/src/api/subscription/_methods/userTwapSliceFills.d.ts +6 -6
  337. package/script/src/api/subscription/_methods/webData2.d.ts +11 -11
  338. package/script/src/signing/_privateKeySigner.js +3 -3
  339. package/script/src/signing/_privateKeySigner.js.map +1 -1
  340. package/script/src/signing/mod.js +2 -2
  341. package/script/src/signing/mod.js.map +1 -1
  342. package/src/_dnt.shims.ts +60 -0
  343. package/src/deps/jsr.io/@noble/curves/2.0.1/src/abstract/curve.ts +633 -0
  344. package/src/deps/jsr.io/@noble/curves/2.0.1/src/abstract/hash-to-curve.ts +292 -0
  345. package/src/deps/jsr.io/@noble/curves/2.0.1/src/abstract/modular.ts +621 -0
  346. package/src/deps/jsr.io/@noble/curves/2.0.1/src/abstract/weierstrass.ts +1562 -0
  347. package/src/deps/jsr.io/@noble/curves/2.0.1/src/secp256k1.ts +327 -0
  348. package/src/deps/jsr.io/@noble/curves/2.0.1/src/utils.ts +306 -0
  349. package/src/deps/jsr.io/@noble/hashes/2.0.1/src/_md.ts +156 -0
  350. package/src/deps/jsr.io/@noble/hashes/2.0.1/src/_u64.ts +91 -0
  351. package/src/deps/jsr.io/@noble/hashes/2.0.1/src/hmac.ts +94 -0
  352. package/src/deps/jsr.io/@noble/hashes/2.0.1/src/sha2.ts +469 -0
  353. package/src/deps/jsr.io/@noble/hashes/2.0.1/src/sha3.ts +295 -0
  354. package/src/deps/jsr.io/@noble/hashes/2.0.1/src/utils.ts +340 -0
  355. package/src/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/advanced/abi-mapper.ts +212 -0
  356. package/src/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/core/address.ts +100 -0
  357. package/src/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/core/rlp.ts +104 -0
  358. package/src/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/core/tx-internal.ts +626 -0
  359. package/src/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/core/tx.ts +274 -0
  360. package/src/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/core/typed-data.ts +391 -0
  361. package/src/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/index.ts +12 -0
  362. package/src/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/utils.ts +233 -0
  363. package/src/deps/jsr.io/@paulmillr/micro-packed/0.8.0/src/index.ts +2196 -0
  364. package/src/deps/jsr.io/@scure/base/2.0.0/index.ts +857 -0
  365. package/src/deps/jsr.io/@std/async/1.0.16/unstable_semaphore.ts +146 -0
  366. package/src/src/api/exchange/_methods/_base/_nonce.ts +3 -2
  367. package/src/src/api/exchange/_methods/_base/_semaphore.ts +34 -59
  368. package/src/src/api/exchange/_methods/_base/execute.ts +60 -12
  369. package/src/src/api/exchange/_methods/order.ts +5 -3
  370. package/src/src/api/exchange/client.ts +5 -1
  371. package/src/src/api/exchange/mod.ts +5 -1
  372. package/src/src/api/info/_methods/userFunding.ts +2 -2
  373. package/src/src/api/subscription/_methods/assetCtxs.ts +2 -0
  374. package/src/src/api/subscription/_methods/clearinghouseState.ts +2 -0
  375. package/src/src/api/subscription/_methods/explorerBlock.ts +2 -0
  376. package/src/src/api/subscription/_methods/explorerTxs.ts +2 -0
  377. package/src/src/api/subscription/_methods/twapStates.ts +9 -1
  378. package/src/src/signing/_privateKeySigner.ts +1 -1
  379. package/src/src/signing/mod.ts +1 -1
  380. package/esm/deps/jsr.io/@std/msgpack/1.0.3/decode.d.ts +0 -21
  381. package/esm/deps/jsr.io/@std/msgpack/1.0.3/decode.d.ts.map +0 -1
  382. package/esm/deps/jsr.io/@std/msgpack/1.0.3/decode.js +0 -292
  383. package/esm/deps/jsr.io/@std/msgpack/1.0.3/decode.js.map +0 -1
  384. package/esm/deps/jsr.io/@std/msgpack/1.0.3/mod.d.ts +0 -44
  385. package/esm/deps/jsr.io/@std/msgpack/1.0.3/mod.d.ts.map +0 -1
  386. package/esm/deps/jsr.io/@std/msgpack/1.0.3/mod.js +0 -46
  387. package/esm/deps/jsr.io/@std/msgpack/1.0.3/mod.js.map +0 -1
  388. package/script/deps/jsr.io/@std/msgpack/1.0.3/decode.d.ts +0 -21
  389. package/script/deps/jsr.io/@std/msgpack/1.0.3/decode.d.ts.map +0 -1
  390. package/script/deps/jsr.io/@std/msgpack/1.0.3/decode.js +0 -295
  391. package/script/deps/jsr.io/@std/msgpack/1.0.3/decode.js.map +0 -1
  392. package/script/deps/jsr.io/@std/msgpack/1.0.3/mod.d.ts +0 -44
  393. package/script/deps/jsr.io/@std/msgpack/1.0.3/mod.d.ts.map +0 -1
  394. package/script/deps/jsr.io/@std/msgpack/1.0.3/mod.js +0 -62
  395. package/script/deps/jsr.io/@std/msgpack/1.0.3/mod.js.map +0 -1
  396. package/src/deps/jsr.io/@std/msgpack/1.0.3/decode.ts +0 -391
  397. package/src/deps/jsr.io/@std/msgpack/1.0.3/mod.ts +0 -47
@@ -0,0 +1,877 @@
1
+ import { type Coder as BaseCoder } from '../../../../@scure/base/2.0.0/index.js';
2
+ /**
3
+ * Define complex binary structures using composable primitives.
4
+ * Main ideas:
5
+ * - Encode / decode can be chained, same as in `scure-base`
6
+ * - A complex structure can be created from an array and struct of primitive types
7
+ * - Strings / bytes are arrays with specific optimizations: we can just read bytes directly
8
+ * without creating plain array first and reading each byte separately.
9
+ * - Types are inferred from definition
10
+ * @module
11
+ * @example
12
+ * import * as P from 'micro-packed';
13
+ * const s = P.struct({
14
+ * field1: P.U32BE, // 32-bit unsigned big-endian integer
15
+ * field2: P.string(P.U8), // String with U8 length prefix
16
+ * field3: P.bytes(32), // 32 bytes
17
+ * field4: P.array(P.U16BE, P.struct({ // Array of structs with U16BE length
18
+ * subField1: P.U64BE, // 64-bit unsigned big-endian integer
19
+ * subField2: P.string(10) // 10-byte string
20
+ * }))
21
+ * });
22
+ */
23
+ /** Shortcut to zero-length (empty) byte array */
24
+ export declare const EMPTY: Uint8Array;
25
+ /** Shortcut to one-element (element is 0) byte array */
26
+ export declare const NULL: Uint8Array;
27
+ /** Checks if two Uint8Arrays are equal. Not constant-time. */
28
+ declare function equalBytes(a: Uint8Array, b: Uint8Array): boolean;
29
+ /** Checks if the given value is a Uint8Array. */
30
+ declare function isBytes(a: unknown): a is Bytes;
31
+ /**
32
+ * Concatenates multiple Uint8Arrays.
33
+ * Engines limit functions to 65K+ arguments.
34
+ * @param arrays Array of Uint8Array elements
35
+ * @returns Concatenated Uint8Array
36
+ */
37
+ declare function concatBytes(...arrays: Uint8Array[]): Uint8Array;
38
+ /**
39
+ * Checks if the provided value is a plain object, not created from any class or special constructor.
40
+ * Array, Uint8Array and others are not plain objects.
41
+ * @param obj - The value to be checked.
42
+ */
43
+ declare function isPlainObject(obj: any): boolean;
44
+ export declare const utils: {
45
+ equalBytes: typeof equalBytes;
46
+ isBytes: typeof isBytes;
47
+ isCoder: typeof isCoder;
48
+ checkBounds: typeof checkBounds;
49
+ concatBytes: typeof concatBytes;
50
+ createView: (arr: Uint8Array) => DataView;
51
+ isPlainObject: typeof isPlainObject;
52
+ };
53
+ export type Bytes = Uint8Array;
54
+ export type Option<T> = T | undefined;
55
+ /**
56
+ * Coder encodes and decodes between two types.
57
+ * @property {(from: F) => T} encode - Encodes (converts) F to T
58
+ * @property {(to: T) => F} decode - Decodes (converts) T to F
59
+ */
60
+ export interface Coder<F, T> {
61
+ encode(from: F): T;
62
+ decode(to: T): F;
63
+ }
64
+ /**
65
+ * BytesCoder converts value between a type and a byte array
66
+ * @property {number} [size] - Size hint for the element.
67
+ * @property {(data: T) => Bytes} encode - Encodes a value of type T to a byte array
68
+ * @property {(data: Bytes, opts?: ReaderOpts) => T} decode - Decodes a byte array to a value of type T
69
+ */
70
+ export interface BytesCoder<T> extends Coder<T, Bytes> {
71
+ size?: number;
72
+ encode: (data: T) => Bytes;
73
+ decode: (data: Bytes, opts?: ReaderOpts) => T;
74
+ }
75
+ /**
76
+ * BytesCoderStream converts value between a type and a byte array, using streams.
77
+ * @property {number} [size] - Size hint for the element.
78
+ * @property {(w: Writer, value: T) => void} encodeStream - Encodes a value of type T to a byte array using a Writer stream.
79
+ * @property {(r: Reader) => T} decodeStream - Decodes a byte array to a value of type T using a Reader stream.
80
+ */
81
+ export interface BytesCoderStream<T> {
82
+ size?: number;
83
+ encodeStream: (w: Writer, value: T) => void;
84
+ decodeStream: (r: Reader) => T;
85
+ }
86
+ export type CoderType<T> = BytesCoderStream<T> & BytesCoder<T>;
87
+ export type Sized<T> = CoderType<T> & {
88
+ size: number;
89
+ };
90
+ export type UnwrapCoder<T> = T extends CoderType<infer U> ? U : T;
91
+ /**
92
+ * Validation function. Should return value after validation.
93
+ * Can be used to narrow types
94
+ */
95
+ export type Validate<T> = (elm: T) => T;
96
+ export type Length = CoderType<number> | CoderType<bigint> | number | Bytes | string | null;
97
+ type ArrLike<T> = Array<T> | ReadonlyArray<T>;
98
+ export type TypedArray = Uint8Array | Int8Array | Uint8ClampedArray | Uint16Array | Int16Array | Uint32Array | Int32Array;
99
+ /** Writable version of a type, where readonly properties are made writable. */
100
+ export type Writable<T> = T extends {} ? T extends TypedArray ? T : {
101
+ -readonly [P in keyof T]: Writable<T[P]>;
102
+ } : T;
103
+ export type Values<T> = T[keyof T];
104
+ export type NonUndefinedKey<T, K extends keyof T> = T[K] extends undefined ? never : K;
105
+ export type NullableKey<T, K extends keyof T> = T[K] extends NonNullable<T[K]> ? never : K;
106
+ export type OptKey<T, K extends keyof T> = NullableKey<T, K> & NonUndefinedKey<T, K>;
107
+ export type ReqKey<T, K extends keyof T> = T[K] extends NonNullable<T[K]> ? K : never;
108
+ export type OptKeys<T> = Pick<T, {
109
+ [K in keyof T]: OptKey<T, K>;
110
+ }[keyof T]>;
111
+ export type ReqKeys<T> = Pick<T, {
112
+ [K in keyof T]: ReqKey<T, K>;
113
+ }[keyof T]>;
114
+ export type StructInput<T extends Record<string, any>> = {
115
+ [P in keyof ReqKeys<T>]: T[P];
116
+ } & {
117
+ [P in keyof OptKeys<T>]?: T[P];
118
+ };
119
+ export type StructRecord<T extends Record<string, any>> = {
120
+ [P in keyof T]: CoderType<T[P]>;
121
+ };
122
+ export type StructOut = Record<string, any>;
123
+ /** Padding function that takes an index and returns a padding value. */
124
+ export type PadFn = (i: number) => number;
125
+ /** Path related utils (internal) */
126
+ type Path = {
127
+ obj: StructOut;
128
+ field?: string;
129
+ };
130
+ type PathStack = Path[];
131
+ export type _PathObjFn = (cb: (field: string, fieldFn: Function) => void) => void;
132
+ declare const Path: {
133
+ /**
134
+ * Internal method for handling stack of paths (debug, errors, dynamic fields via path)
135
+ * This is looks ugly (callback), but allows us to force stack cleaning by construction (.pop always after function).
136
+ * Also, this makes impossible:
137
+ * - pushing field when stack is empty
138
+ * - pushing field inside of field (real bug)
139
+ * NOTE: we don't want to do '.pop' on error!
140
+ */
141
+ pushObj: (stack: PathStack, obj: StructOut, objFn: _PathObjFn) => void;
142
+ path: (stack: PathStack) => string;
143
+ err: (name: string, stack: PathStack, msg: string | Error) => Error;
144
+ resolve: (stack: PathStack, path: string) => StructOut | undefined;
145
+ };
146
+ /**
147
+ * Options for the Reader class.
148
+ * @property {boolean} [allowUnreadBytes: false] - If there are remaining unparsed bytes, the decoding is probably wrong.
149
+ * @property {boolean} [allowMultipleReads: false] - The check enforces parser termination. If pointers can read the same region of memory multiple times, you can cause combinatorial explosion by creating an array of pointers to the same address and cause DoS.
150
+ */
151
+ export type ReaderOpts = {
152
+ allowUnreadBytes?: boolean;
153
+ allowMultipleReads?: boolean;
154
+ };
155
+ export type Reader = {
156
+ /** Current position in the buffer. */
157
+ readonly pos: number;
158
+ /** Number of bytes left in the buffer. */
159
+ readonly leftBytes: number;
160
+ /** Total number of bytes in the buffer. */
161
+ readonly totalBytes: number;
162
+ /** Checks if the end of the buffer has been reached. */
163
+ isEnd(): boolean;
164
+ /**
165
+ * Creates an error with the given message. Adds information about current field path.
166
+ * If Error object provided, saves original stack trace.
167
+ * @param msg - The error message or an Error object.
168
+ * @returns The created Error object.
169
+ */
170
+ err(msg: string | Error): Error;
171
+ /**
172
+ * Reads a specified number of bytes from the buffer.
173
+ *
174
+ * WARNING: Uint8Array is subarray of original buffer. Do not modify.
175
+ * @param n - The number of bytes to read.
176
+ * @param peek - If `true`, the bytes are read without advancing the position.
177
+ * @returns The read bytes as a Uint8Array.
178
+ */
179
+ bytes(n: number, peek?: boolean): Uint8Array;
180
+ /**
181
+ * Reads a single byte from the buffer.
182
+ * @param peek - If `true`, the byte is read without advancing the position.
183
+ * @returns The read byte as a number.
184
+ */
185
+ byte(peek?: boolean): number;
186
+ /**
187
+ * Reads a specified number of bits from the buffer.
188
+ * @param bits - The number of bits to read.
189
+ * @returns The read bits as a number.
190
+ */
191
+ bits(bits: number): number;
192
+ /**
193
+ * Finds the first occurrence of a needle in the buffer.
194
+ * @param needle - The needle to search for.
195
+ * @param pos - The starting position for the search.
196
+ * @returns The position of the first occurrence of the needle, or `undefined` if not found.
197
+ */
198
+ find(needle: Bytes, pos?: number): number | undefined;
199
+ /**
200
+ * Creates a new Reader instance at the specified offset.
201
+ * Complex and unsafe API: currently only used in eth ABI parsing of pointers.
202
+ * Required to break pointer boundaries inside arrays for complex structure.
203
+ * Please use only if absolutely necessary!
204
+ * @param n - The offset to create the new Reader at.
205
+ * @returns A new Reader instance at the specified offset.
206
+ */
207
+ offsetReader(n: number): Reader;
208
+ };
209
+ export type Writer = {
210
+ /**
211
+ * Creates an error with the given message. Adds information about current field path.
212
+ * If Error object provided, saves original stack trace.
213
+ * @param msg - The error message or an Error object.
214
+ * @returns The created Error object.
215
+ */
216
+ err(msg: string | Error): Error;
217
+ /**
218
+ * Writes a byte array to the buffer.
219
+ * @param b - The byte array to write.
220
+ */
221
+ bytes(b: Bytes): void;
222
+ /**
223
+ * Writes a single byte to the buffer.
224
+ * @param b - The byte to write.
225
+ */
226
+ byte(b: number): void;
227
+ /**
228
+ * Writes a specified number of bits to the buffer.
229
+ * @param value - The value to write.
230
+ * @param bits - The number of bits to write.
231
+ */
232
+ bits(value: number, bits: number): void;
233
+ };
234
+ /**
235
+ * Internal structure. Reader class for reading from a byte array.
236
+ * `stack` is internal: for debugger and logging
237
+ * @class Reader
238
+ */
239
+ declare class _Reader implements Reader {
240
+ pos: number;
241
+ readonly data: Bytes;
242
+ readonly opts: ReaderOpts;
243
+ readonly stack: PathStack;
244
+ private parent;
245
+ private parentOffset;
246
+ private bitBuf;
247
+ private bitPos;
248
+ private bs;
249
+ private view;
250
+ constructor(data: Bytes, opts?: ReaderOpts, stack?: PathStack, parent?: _Reader | undefined, parentOffset?: number);
251
+ /** Internal method for pointers. */
252
+ _enablePointers(): void;
253
+ private markBytesBS;
254
+ private markBytes;
255
+ pushObj(obj: StructOut, objFn: _PathObjFn): void;
256
+ readView(n: number, fn: (view: DataView, pos: number) => number): number;
257
+ absBytes(n: number): Uint8Array;
258
+ finish(): void;
259
+ err(msg: string | Error): Error;
260
+ offsetReader(n: number): _Reader;
261
+ bytes(n: number, peek?: boolean): Uint8Array;
262
+ byte(peek?: boolean): number;
263
+ get leftBytes(): number;
264
+ get totalBytes(): number;
265
+ isEnd(): boolean;
266
+ bits(bits: number): number;
267
+ find(needle: Bytes, pos?: number): number | undefined;
268
+ }
269
+ /**
270
+ * Internal structure. Writer class for writing to a byte array.
271
+ * The `stack` argument of constructor is internal, for debugging and logs.
272
+ * @class Writer
273
+ */
274
+ declare class _Writer implements Writer {
275
+ pos: number;
276
+ readonly stack: PathStack;
277
+ private buffers;
278
+ ptrs: {
279
+ pos: number;
280
+ ptr: CoderType<number>;
281
+ buffer: Bytes;
282
+ }[];
283
+ private bitBuf;
284
+ private bitPos;
285
+ private viewBuf;
286
+ private view;
287
+ private finished;
288
+ constructor(stack?: PathStack);
289
+ pushObj(obj: StructOut, objFn: _PathObjFn): void;
290
+ writeView(len: number, fn: (view: DataView) => void): void;
291
+ err(msg: string | Error): Error;
292
+ bytes(b: Bytes): void;
293
+ byte(b: number): void;
294
+ finish(clean?: boolean): Bytes;
295
+ bits(value: number, bits: number): void;
296
+ }
297
+ /** Internal function for checking bit bounds of bigint in signed/unsinged form */
298
+ declare function checkBounds(value: bigint, bits: bigint, signed: boolean): void;
299
+ /**
300
+ * Validates a value before encoding and after decoding using a provided function.
301
+ * @param inner - The inner CoderType.
302
+ * @param fn - The validation function.
303
+ * @returns CoderType which check value with validation function.
304
+ * @example
305
+ * const val = (n: number) => {
306
+ * if (n > 10) throw new Error(`${n} > 10`);
307
+ * return n;
308
+ * };
309
+ *
310
+ * const RangedInt = P.validate(P.U32LE, val); // Will check if value is <= 10 during encoding and decoding
311
+ */
312
+ export declare function validate<T>(inner: CoderType<T>, fn: Validate<T>): CoderType<T>;
313
+ /**
314
+ * Wraps a stream encoder into a generic encoder and optionally validation function
315
+ * @param {inner} inner BytesCoderStream & { validate?: Validate<T> }.
316
+ * @returns The wrapped CoderType.
317
+ * @example
318
+ * const U8 = P.wrap({
319
+ * encodeStream: (w: Writer, value: number) => w.byte(value),
320
+ * decodeStream: (r: Reader): number => r.byte()
321
+ * });
322
+ * const checkedU8 = P.wrap({
323
+ * encodeStream: (w: Writer, value: number) => w.byte(value),
324
+ * decodeStream: (r: Reader): number => r.byte()
325
+ * validate: (n: number) => {
326
+ * if (n > 10) throw new Error(`${n} > 10`);
327
+ * return n;
328
+ * }
329
+ * });
330
+ */
331
+ export declare const wrap: <T>(inner: BytesCoderStream<T> & {
332
+ validate?: Validate<T>;
333
+ }) => CoderType<T>;
334
+ /**
335
+ * Checks if the given value is a CoderType.
336
+ * @param elm - The value to check.
337
+ * @returns True if the value is a CoderType, false otherwise.
338
+ */
339
+ export declare function isCoder<T>(elm: any): elm is CoderType<T>;
340
+ /**
341
+ * Base coder for working with dictionaries (records, objects, key-value map)
342
+ * Dictionary is dynamic type like: `[key: string, value: any][]`
343
+ * @returns base coder that encodes/decodes between arrays of key-value tuples and dictionaries.
344
+ * @example
345
+ * const dict: P.CoderType<Record<string, number>> = P.apply(
346
+ * P.array(P.U16BE, P.tuple([P.cstring, P.U32LE] as const)),
347
+ * P.coders.dict()
348
+ * );
349
+ */
350
+ declare function dict<T>(): BaseCoder<[string, T][], Record<string, T>>;
351
+ type Enum = {
352
+ [k: string]: number | string;
353
+ } & {
354
+ [k: number]: string;
355
+ };
356
+ type EnumKeys<T extends Enum> = keyof T;
357
+ /**
358
+ * Base coder for working with TypeScript enums.
359
+ * @param e - TypeScript enum.
360
+ * @returns base coder that encodes/decodes between numbers and enum keys.
361
+ * @example
362
+ * enum Color { Red, Green, Blue }
363
+ * const colorCoder = P.coders.tsEnum(Color);
364
+ * colorCoder.encode(Color.Red); // 'Red'
365
+ * colorCoder.decode('Green'); // 1
366
+ */
367
+ declare function tsEnum<T extends Enum>(e: T): BaseCoder<number, EnumKeys<T>>;
368
+ /**
369
+ * Base coder for working with decimal numbers.
370
+ * @param precision - Number of decimal places.
371
+ * @param round - Round fraction part if bigger than precision (throws error by default)
372
+ * @returns base coder that encodes/decodes between bigints and decimal strings.
373
+ * @example
374
+ * const decimal8 = P.coders.decimal(8);
375
+ * decimal8.encode(630880845n); // '6.30880845'
376
+ * decimal8.decode('6.30880845'); // 630880845n
377
+ */
378
+ declare function decimal(precision: number, round?: boolean): Coder<bigint, string>;
379
+ type BaseInput<F> = F extends BaseCoder<infer T, any> ? T : never;
380
+ type BaseOutput<F> = F extends BaseCoder<any, infer T> ? T : never;
381
+ /**
382
+ * Combines multiple coders into a single coder, allowing conditional encoding/decoding based on input.
383
+ * Acts as a parser combinator, splitting complex conditional coders into smaller parts.
384
+ *
385
+ * `encode = [Ae, Be]; decode = [Ad, Bd]`
386
+ * ->
387
+ * `match([{encode: Ae, decode: Ad}, {encode: Be; decode: Bd}])`
388
+ *
389
+ * @param lst - Array of coders to match.
390
+ * @returns Combined coder for conditional encoding/decoding.
391
+ */
392
+ declare function match<L extends BaseCoder<unknown | undefined, unknown | undefined>[], I = {
393
+ [K in keyof L]: NonNullable<BaseInput<L[K]>>;
394
+ }[number], O = {
395
+ [K in keyof L]: NonNullable<BaseOutput<L[K]>>;
396
+ }[number]>(lst: L): BaseCoder<I, O>;
397
+ export declare const coders: {
398
+ dict: typeof dict;
399
+ numberBigint: BaseCoder<bigint, number>;
400
+ tsEnum: typeof tsEnum;
401
+ decimal: typeof decimal;
402
+ match: typeof match;
403
+ reverse: <F, T>(coder: Coder<F, T>) => Coder<T, F>;
404
+ };
405
+ /**
406
+ * CoderType for parsing individual bits.
407
+ * NOTE: Structure should parse whole amount of bytes before it can start parsing byte-level elements.
408
+ * @param len - Number of bits to parse.
409
+ * @returns CoderType representing the parsed bits.
410
+ * @example
411
+ * const s = P.struct({ magic: P.bits(1), version: P.bits(1), tag: P.bits(4), len: P.bits(2) });
412
+ */
413
+ export declare const bits: (len: number) => CoderType<number>;
414
+ /**
415
+ * CoderType for working with bigint values.
416
+ * Unsized bigint values should be wrapped in a container (e.g., bytes or string).
417
+ *
418
+ * `0n = Uint8Array.of()`
419
+ *
420
+ * `1n = new Uint8Array([1n])`
421
+ *
422
+ * Please open issue, if you need different behavior for zero.
423
+ *
424
+ * @param size - Size of the bigint in bytes.
425
+ * @param le - Whether to use little-endian byte order.
426
+ * @param signed - Whether the bigint is signed.
427
+ * @param sized - Whether the bigint should have a fixed size.
428
+ * @returns CoderType representing the bigint value.
429
+ * @example
430
+ * const U512BE = P.bigint(64, false, true, true); // Define a CoderType for a 512-bit unsigned big-endian integer
431
+ */
432
+ export declare const bigint: (size: number, le?: boolean, signed?: boolean, sized?: boolean) => CoderType<bigint>;
433
+ /** Unsigned 256-bit little-endian integer CoderType. */
434
+ export declare const U256LE: CoderType<bigint>;
435
+ /** Unsigned 256-bit big-endian integer CoderType. */
436
+ export declare const U256BE: CoderType<bigint>;
437
+ /** Signed 256-bit little-endian integer CoderType. */
438
+ export declare const I256LE: CoderType<bigint>;
439
+ /** Signed 256-bit big-endian integer CoderType. */
440
+ export declare const I256BE: CoderType<bigint>;
441
+ /** Unsigned 128-bit little-endian integer CoderType. */
442
+ export declare const U128LE: CoderType<bigint>;
443
+ /** Unsigned 128-bit big-endian integer CoderType. */
444
+ export declare const U128BE: CoderType<bigint>;
445
+ /** Signed 128-bit little-endian integer CoderType. */
446
+ export declare const I128LE: CoderType<bigint>;
447
+ /** Signed 128-bit big-endian integer CoderType. */
448
+ export declare const I128BE: CoderType<bigint>;
449
+ /** Unsigned 64-bit little-endian integer CoderType. */
450
+ export declare const U64LE: CoderType<bigint>;
451
+ /** Unsigned 64-bit big-endian integer CoderType. */
452
+ export declare const U64BE: CoderType<bigint>;
453
+ /** Signed 64-bit little-endian integer CoderType. */
454
+ export declare const I64LE: CoderType<bigint>;
455
+ /** Signed 64-bit big-endian integer CoderType. */
456
+ export declare const I64BE: CoderType<bigint>;
457
+ /**
458
+ * CoderType for working with numbber values (up to 6 bytes/48 bits).
459
+ * Unsized int values should be wrapped in a container (e.g., bytes or string).
460
+ *
461
+ * `0 = Uint8Array.of()`
462
+ *
463
+ * `1 = new Uint8Array([1n])`
464
+ *
465
+ * Please open issue, if you need different behavior for zero.
466
+ *
467
+ * @param size - Size of the number in bytes.
468
+ * @param le - Whether to use little-endian byte order.
469
+ * @param signed - Whether the number is signed.
470
+ * @param sized - Whether the number should have a fixed size.
471
+ * @returns CoderType representing the number value.
472
+ * @example
473
+ * const uint64BE = P.bigint(8, false, true); // Define a CoderType for a 64-bit unsigned big-endian integer
474
+ */
475
+ export declare const int: (size: number, le?: boolean, signed?: boolean, sized?: boolean) => CoderType<number>;
476
+ /** Unsigned 32-bit little-endian integer CoderType. */
477
+ export declare const U32LE: CoderType<number>;
478
+ /** Unsigned 32-bit big-endian integer CoderType. */
479
+ export declare const U32BE: CoderType<number>;
480
+ /** Signed 32-bit little-endian integer CoderType. */
481
+ export declare const I32LE: CoderType<number>;
482
+ /** Signed 32-bit big-endian integer CoderType. */
483
+ export declare const I32BE: CoderType<number>;
484
+ /** Unsigned 16-bit little-endian integer CoderType. */
485
+ export declare const U16LE: CoderType<number>;
486
+ /** Unsigned 16-bit big-endian integer CoderType. */
487
+ export declare const U16BE: CoderType<number>;
488
+ /** Signed 16-bit little-endian integer CoderType. */
489
+ export declare const I16LE: CoderType<number>;
490
+ /** Signed 16-bit big-endian integer CoderType. */
491
+ export declare const I16BE: CoderType<number>;
492
+ /** Unsigned 8-bit integer CoderType. */
493
+ export declare const U8: CoderType<number>;
494
+ /** Signed 8-bit integer CoderType. */
495
+ export declare const I8: CoderType<number>;
496
+ /** 32-bit big-endian floating point CoderType ("binary32", IEEE 754-2008). */
497
+ export declare const F32BE: CoderType<number>;
498
+ /** 32-bit little-endian floating point CoderType ("binary32", IEEE 754-2008). */
499
+ export declare const F32LE: CoderType<number>;
500
+ /** A 64-bit big-endian floating point type ("binary64", IEEE 754-2008). Any JS number can be encoded. */
501
+ export declare const F64BE: CoderType<number>;
502
+ /** A 64-bit little-endian floating point type ("binary64", IEEE 754-2008). Any JS number can be encoded. */
503
+ export declare const F64LE: CoderType<number>;
504
+ /** Boolean CoderType. */
505
+ export declare const bool: CoderType<boolean>;
506
+ /**
507
+ * Bytes CoderType with a specified length and endianness.
508
+ * The bytes can have:
509
+ * - Dynamic size (prefixed with a length CoderType like U16BE)
510
+ * - Fixed size (specified by a number)
511
+ * - Unknown size (null, will parse until end of buffer)
512
+ * - Zero-terminated (terminator can be any Uint8Array)
513
+ * @param len - CoderType, number, Uint8Array (terminator) or null
514
+ * @param le - Whether to use little-endian byte order.
515
+ * @returns CoderType representing the bytes.
516
+ * @example
517
+ * // Dynamic size bytes (prefixed with P.U16BE number of bytes length)
518
+ * const dynamicBytes = P.bytes(P.U16BE, false);
519
+ * const fixedBytes = P.bytes(32, false); // Fixed size bytes
520
+ * const unknownBytes = P.bytes(null, false); // Unknown size bytes, will parse until end of buffer
521
+ * const zeroTerminatedBytes = P.bytes(Uint8Array.of(0), false); // Zero-terminated bytes
522
+ */
523
+ declare const createBytes: (len: Length, le?: boolean) => CoderType<Bytes>;
524
+ export { createBytes as bytes, createHex as hex };
525
+ /**
526
+ * Prefix-encoded value using a length prefix and an inner CoderType.
527
+ * The prefix can have:
528
+ * - Dynamic size (prefixed with a length CoderType like U16BE)
529
+ * - Fixed size (specified by a number)
530
+ * - Unknown size (null, will parse until end of buffer)
531
+ * - Zero-terminated (terminator can be any Uint8Array)
532
+ * @param len - Length CoderType (dynamic size), number (fixed size), Uint8Array (for terminator), or null (will parse until end of buffer)
533
+ * @param inner - CoderType for the actual value to be prefix-encoded.
534
+ * @returns CoderType representing the prefix-encoded value.
535
+ * @example
536
+ * const dynamicPrefix = P.prefix(P.U16BE, P.bytes(null)); // Dynamic size prefix (prefixed with P.U16BE number of bytes length)
537
+ * const fixedPrefix = P.prefix(10, P.bytes(null)); // Fixed size prefix (always 10 bytes)
538
+ */
539
+ export declare function prefix<T>(len: Length, inner: CoderType<T>): CoderType<T>;
540
+ /**
541
+ * String CoderType with a specified length and endianness.
542
+ * The string can be:
543
+ * - Dynamic size (prefixed with a length CoderType like U16BE)
544
+ * - Fixed size (specified by a number)
545
+ * - Unknown size (null, will parse until end of buffer)
546
+ * - Zero-terminated (terminator can be any Uint8Array)
547
+ * @param len - Length CoderType (dynamic size), number (fixed size), Uint8Array (for terminator), or null (will parse until end of buffer)
548
+ * @param le - Whether to use little-endian byte order.
549
+ * @returns CoderType representing the string.
550
+ * @example
551
+ * const dynamicString = P.string(P.U16BE, false); // Dynamic size string (prefixed with P.U16BE number of string length)
552
+ * const fixedString = P.string(10, false); // Fixed size string
553
+ * const unknownString = P.string(null, false); // Unknown size string, will parse until end of buffer
554
+ * const nullTerminatedString = P.cstring; // NUL-terminated string
555
+ * const _cstring = P.string(Uint8Array.of(0)); // Same thing
556
+ */
557
+ export declare const string: (len: Length, le?: boolean) => CoderType<string>;
558
+ /** NUL-terminated string CoderType. */
559
+ export declare const cstring: CoderType<string>;
560
+ type HexOpts = {
561
+ isLE?: boolean;
562
+ with0x?: boolean;
563
+ };
564
+ /**
565
+ * Hexadecimal string CoderType with a specified length, endianness, and optional 0x prefix.
566
+ * @param len - Length CoderType (dynamic size), number (fixed size), Uint8Array (for terminator), or null (will parse until end of buffer)
567
+ * @param le - Whether to use little-endian byte order.
568
+ * @param withZero - Whether to include the 0x prefix.
569
+ * @returns CoderType representing the hexadecimal string.
570
+ * @example
571
+ * const dynamicHex = P.hex(P.U16BE, {isLE: false, with0x: true}); // Hex string with 0x prefix and U16BE length
572
+ * const fixedHex = P.hex(32, {isLE: false, with0x: false}); // Fixed-length 32-byte hex string without 0x prefix
573
+ */
574
+ declare const createHex: (len: Length, options?: HexOpts) => CoderType<string>;
575
+ /**
576
+ * Applies a base coder to a CoderType.
577
+ * @param inner - The inner CoderType.
578
+ * @param b - The base coder to apply.
579
+ * @returns CoderType representing the transformed value.
580
+ * @example
581
+ * import { hex } from '@scure/base';
582
+ * const hex = P.apply(P.bytes(32), hex); // will decode bytes into a hex string
583
+ */
584
+ export declare function apply<T, F>(inner: CoderType<T>, base: BaseCoder<T, F>): CoderType<F>;
585
+ /**
586
+ * Lazy CoderType that is evaluated at runtime.
587
+ * @param fn - A function that returns the CoderType.
588
+ * @returns CoderType representing the lazy value.
589
+ * @example
590
+ * type Tree = { name: string; children: Tree[] };
591
+ * const tree = P.struct({
592
+ * name: P.cstring,
593
+ * children: P.array(
594
+ * P.U16BE,
595
+ * P.lazy((): P.CoderType<Tree> => tree)
596
+ * ),
597
+ * });
598
+ */
599
+ export declare function lazy<T>(fn: () => CoderType<T>): CoderType<T>;
600
+ /**
601
+ * Flag CoderType that encodes/decodes a boolean value based on the presence of a marker.
602
+ * @param flagValue - Marker value.
603
+ * @param xor - Whether to invert the flag behavior.
604
+ * @returns CoderType representing the flag value.
605
+ * @example
606
+ * const flag = P.flag(new Uint8Array([0x01, 0x02])); // Encodes true as u8a([0x01, 0x02]), false as u8a([])
607
+ * const flagXor = P.flag(new Uint8Array([0x01, 0x02]), true); // Encodes true as u8a([]), false as u8a([0x01, 0x02])
608
+ * // Conditional encoding with flagged
609
+ * const s = P.struct({ f: P.flag(new Uint8Array([0x0, 0x1])), f2: P.flagged('f', P.U32BE) });
610
+ */
611
+ export declare const flag: (flagValue: Bytes, xor?: boolean) => CoderType<boolean | undefined>;
612
+ /**
613
+ * Conditional CoderType that encodes/decodes a value only if a flag is present.
614
+ * @param path - Path to the flag value or a CoderType for the flag.
615
+ * @param inner - Inner CoderType for the value.
616
+ * @param def - Optional default value to use if the flag is not present.
617
+ * @returns CoderType representing the conditional value.
618
+ * @example
619
+ * const s = P.struct({
620
+ * f: P.flag(new Uint8Array([0x0, 0x1])),
621
+ * f2: P.flagged('f', P.U32BE)
622
+ * });
623
+ *
624
+ * @example
625
+ * const s2 = P.struct({
626
+ * f: P.flag(new Uint8Array([0x0, 0x1])),
627
+ * f2: P.flagged('f', P.U32BE, 123)
628
+ * });
629
+ */
630
+ export declare function flagged<T>(path: string | CoderType<boolean>, inner: CoderType<T>, def?: T): CoderType<Option<T>>;
631
+ /**
632
+ * Optional CoderType that encodes/decodes a value based on a flag.
633
+ * @param flag - CoderType for the flag value.
634
+ * @param inner - Inner CoderType for the value.
635
+ * @param def - Optional default value to use if the flag is not present.
636
+ * @returns CoderType representing the optional value.
637
+ * @example
638
+ * // Will decode into P.U32BE only if flag present
639
+ * const optional = P.optional(P.flag(new Uint8Array([0x0, 0x1])), P.U32BE);
640
+ *
641
+ * @example
642
+ * // If no flag present, will decode into default value
643
+ * const optionalWithDefault = P.optional(P.flag(new Uint8Array([0x0, 0x1])), P.U32BE, 123);
644
+ */
645
+ export declare function optional<T>(flag: CoderType<boolean>, inner: CoderType<T>, def?: T): CoderType<Option<T>>;
646
+ /**
647
+ * Magic value CoderType that encodes/decodes a constant value.
648
+ * This can be used to check for a specific magic value or sequence of bytes at the beginning of a data structure.
649
+ * @param inner - Inner CoderType for the value.
650
+ * @param constant - Constant value.
651
+ * @param check - Whether to check the decoded value against the constant.
652
+ * @returns CoderType representing the magic value.
653
+ * @example
654
+ * // Always encodes constant as bytes using inner CoderType, throws if encoded value is not present
655
+ * const magicU8 = P.magic(P.U8, 0x42);
656
+ */
657
+ export declare function magic<T>(inner: CoderType<T>, constant: T, check?: boolean): CoderType<undefined>;
658
+ /**
659
+ * Magic bytes CoderType that encodes/decodes a constant byte array or string.
660
+ * @param constant - Constant byte array or string.
661
+ * @returns CoderType representing the magic bytes.
662
+ * @example
663
+ * // Always encodes undefined into byte representation of string 'MAGIC'
664
+ * const magicBytes = P.magicBytes('MAGIC');
665
+ */
666
+ export declare const magicBytes: (constant: Bytes | string) => CoderType<undefined>;
667
+ /**
668
+ * Creates a CoderType for a constant value. The function enforces this value during encoding,
669
+ * ensuring it matches the provided constant. During decoding, it always returns the constant value.
670
+ * The actual value is not written to or read from any byte stream; it's used only for validation.
671
+ *
672
+ * @param c - Constant value.
673
+ * @returns CoderType representing the constant value.
674
+ * @example
675
+ * // Always return 123 on decode, throws on encoding anything other than 123
676
+ * const constantU8 = P.constant(123);
677
+ */
678
+ export declare function constant<T>(c: T): CoderType<T>;
679
+ /**
680
+ * Structure of composable primitives (C/Rust struct)
681
+ * @param fields - Object mapping field names to CoderTypes.
682
+ * @returns CoderType representing the structure.
683
+ * @example
684
+ * // Define a structure with a 32-bit big-endian unsigned integer, a string, and a nested structure
685
+ * const myStruct = P.struct({
686
+ * id: P.U32BE,
687
+ * name: P.string(P.U8),
688
+ * nested: P.struct({
689
+ * flag: P.bool,
690
+ * value: P.I16LE
691
+ * })
692
+ * });
693
+ */
694
+ export declare function struct<T extends Record<string, any>>(fields: StructRecord<T>): CoderType<StructInput<T>>;
695
+ /**
696
+ * Tuple (unnamed structure) of CoderTypes. Same as struct but with unnamed fields.
697
+ * @param fields - Array of CoderTypes.
698
+ * @returns CoderType representing the tuple.
699
+ * @example
700
+ * const myTuple = P.tuple([P.U8, P.U16LE, P.string(P.U8)]);
701
+ */
702
+ export declare function tuple<T extends ArrLike<CoderType<any>>, O = Writable<{
703
+ [K in keyof T]: UnwrapCoder<T[K]>;
704
+ }>>(fields: T): CoderType<O>;
705
+ /**
706
+ * Array of items (inner type) with a specified length.
707
+ * @param len - Length CoderType (dynamic size), number (fixed size), Uint8Array (for terminator), or null (will parse until end of buffer)
708
+ * @param inner - CoderType for encoding/decoding each array item.
709
+ * @returns CoderType representing the array.
710
+ * @example
711
+ * const a1 = P.array(P.U16BE, child); // Dynamic size array (prefixed with P.U16BE number of array length)
712
+ * const a2 = P.array(4, child); // Fixed size array
713
+ * const a3 = P.array(null, child); // Unknown size array, will parse until end of buffer
714
+ * const a4 = P.array(Uint8Array.of(0), child); // zero-terminated array (NOTE: terminator can be any buffer)
715
+ */
716
+ export declare function array<T>(len: Length, inner: CoderType<T>): CoderType<T[]>;
717
+ /**
718
+ * Mapping between encoded values and string representations.
719
+ * @param inner - CoderType for encoded values.
720
+ * @param variants - Object mapping string representations to encoded values.
721
+ * @returns CoderType representing the mapping.
722
+ * @example
723
+ * // Map between numbers and strings
724
+ * const numberMap = P.map(P.U8, {
725
+ * 'one': 1,
726
+ * 'two': 2,
727
+ * 'three': 3
728
+ * });
729
+ *
730
+ * // Map between byte arrays and strings
731
+ * const byteMap = P.map(P.bytes(2, false), {
732
+ * 'ab': Uint8Array.from([0x61, 0x62]),
733
+ * 'cd': Uint8Array.from([0x63, 0x64])
734
+ * });
735
+ */
736
+ export declare function map<T>(inner: CoderType<T>, variants: Record<string, T>): CoderType<string>;
737
+ /**
738
+ * Tagged union of CoderTypes, where the tag value determines which CoderType to use.
739
+ * The decoded value will have the structure `{ TAG: number, data: ... }`.
740
+ * @param tag - CoderType for the tag value.
741
+ * @param variants - Object mapping tag values to CoderTypes.
742
+ * @returns CoderType representing the tagged union.
743
+ * @example
744
+ * // Tagged union of array, string, and number
745
+ * // Depending on the value of the first byte, it will be decoded as an array, string, or number.
746
+ * const taggedUnion = P.tag(P.U8, {
747
+ * 0x01: P.array(P.U16LE, P.U8),
748
+ * 0x02: P.string(P.U8),
749
+ * 0x03: P.U32BE
750
+ * });
751
+ *
752
+ * const encoded = taggedUnion.encode({ TAG: 0x01, data: 'hello' }); // Encodes the string 'hello' with tag 0x01
753
+ * const decoded = taggedUnion.decode(encoded); // Decodes the encoded value back to { TAG: 0x01, data: 'hello' }
754
+ */
755
+ export declare function tag<T extends Values<{
756
+ [P in keyof Variants]: {
757
+ TAG: P;
758
+ data: UnwrapCoder<Variants[P]>;
759
+ };
760
+ }>, TagValue extends string | number, Variants extends Record<TagValue, CoderType<any>>>(tag: CoderType<TagValue>, variants: Variants): CoderType<T>;
761
+ /**
762
+ * Mapping between encoded values, string representations, and CoderTypes using a tag CoderType.
763
+ * @param tagCoder - CoderType for the tag value.
764
+ * @param variants - Object mapping string representations to [tag value, CoderType] pairs.
765
+ * * @returns CoderType representing the mapping.
766
+ * @example
767
+ * const cborValue: P.CoderType<CborValue> = P.mappedTag(P.bits(3), {
768
+ * uint: [0, cborUint], // An unsigned integer in the range 0..264-1 inclusive.
769
+ * negint: [1, cborNegint], // A negative integer in the range -264..-1 inclusive
770
+ * bytes: [2, P.lazy(() => cborLength(P.bytes, cborValue))], // A byte string.
771
+ * string: [3, P.lazy(() => cborLength(P.string, cborValue))], // A text string (utf8)
772
+ * array: [4, cborArrLength(P.lazy(() => cborValue))], // An array of data items
773
+ * map: [5, P.lazy(() => cborArrLength(P.tuple([cborValue, cborValue])))], // A map of pairs of data items
774
+ * tag: [6, P.tuple([cborUint, P.lazy(() => cborValue)] as const)], // A tagged data item ("tag") whose tag number
775
+ * simple: [7, cborSimple], // Floating-point numbers and simple values, as well as the "break" stop code
776
+ * });
777
+ */
778
+ export declare function mappedTag<T extends Values<{
779
+ [P in keyof Variants]: {
780
+ TAG: P;
781
+ data: UnwrapCoder<Variants[P][1]>;
782
+ };
783
+ }>, TagValue extends string | number, Variants extends Record<string, [TagValue, CoderType<any>]>>(tagCoder: CoderType<TagValue>, variants: Variants): CoderType<T>;
784
+ /**
785
+ * Bitset of boolean values with optional padding.
786
+ * @param names - An array of string names for the bitset values.
787
+ * @param pad - Whether to pad the bitset to a multiple of 8 bits.
788
+ * @returns CoderType representing the bitset.
789
+ * @template Names
790
+ * @example
791
+ * const myBitset = P.bitset(['flag1', 'flag2', 'flag3', 'flag4'], true);
792
+ */
793
+ export declare function bitset<Names extends readonly string[]>(names: Names, pad?: boolean): CoderType<Record<Names[number], boolean>>;
794
+ /** Padding function which always returns zero */
795
+ export declare const ZeroPad: PadFn;
796
+ /**
797
+ * Pads a CoderType with a specified block size and padding function on the left side.
798
+ * @param blockSize - Block size for padding (positive safe integer).
799
+ * @param inner - Inner CoderType to pad.
800
+ * @param padFn - Padding function to use. If not provided, zero padding is used.
801
+ * @returns CoderType representing the padded value.
802
+ * @example
803
+ * // Pad a U32BE with a block size of 4 and zero padding
804
+ * const paddedU32BE = P.padLeft(4, P.U32BE);
805
+ *
806
+ * // Pad a string with a block size of 16 and custom padding
807
+ * const paddedString = P.padLeft(16, P.string(P.U8), (i) => i + 1);
808
+ */
809
+ export declare function padLeft<T>(blockSize: number, inner: CoderType<T>, padFn: Option<PadFn>): CoderType<T>;
810
+ /**
811
+ * Pads a CoderType with a specified block size and padding function on the right side.
812
+ * @param blockSize - Block size for padding (positive safe integer).
813
+ * @param inner - Inner CoderType to pad.
814
+ * @param padFn - Padding function to use. If not provided, zero padding is used.
815
+ * @returns CoderType representing the padded value.
816
+ * @example
817
+ * // Pad a U16BE with a block size of 2 and zero padding
818
+ * const paddedU16BE = P.padRight(2, P.U16BE);
819
+ *
820
+ * // Pad a bytes with a block size of 8 and custom padding
821
+ * const paddedBytes = P.padRight(8, P.bytes(null), (i) => i + 1);
822
+ */
823
+ export declare function padRight<T>(blockSize: number, inner: CoderType<T>, padFn: Option<PadFn>): CoderType<T>;
824
+ /**
825
+ * Pointer to a value using a pointer CoderType and an inner CoderType.
826
+ * Pointers are scoped, and the next pointer in the dereference chain is offset by the previous one.
827
+ * By default (if no 'allowMultipleReads' in ReaderOpts is set) is safe, since
828
+ * same region of memory cannot be read multiple times.
829
+ * @param ptr - CoderType for the pointer value.
830
+ * @param inner - CoderType for encoding/decoding the pointed value.
831
+ * @param sized - Whether the pointer should have a fixed size.
832
+ * @returns CoderType representing the pointer to the value.
833
+ * @example
834
+ * const pointerToU8 = P.pointer(P.U16BE, P.U8); // Pointer to a single U8 value
835
+ */
836
+ export declare function pointer<T>(ptr: CoderType<number>, inner: CoderType<T>, sized?: boolean): CoderType<T>;
837
+ export declare const _TEST: {
838
+ _bitset: {
839
+ BITS: number;
840
+ FULL_MASK: number;
841
+ len: (len: number) => number;
842
+ create: (len: number) => Uint32Array;
843
+ clean: (bs: Uint32Array) => Uint32Array;
844
+ debug: (bs: Uint32Array) => string[];
845
+ checkLen: (bs: Uint32Array, len: number) => void;
846
+ chunkLen: (bsLen: number, pos: number, len: number) => void;
847
+ set: (bs: Uint32Array, chunk: number, value: number, allowRewrite?: boolean) => boolean;
848
+ pos: (pos: number, i: number) => {
849
+ chunk: number;
850
+ mask: number;
851
+ };
852
+ indices: (bs: Uint32Array, len: number, invert?: boolean) => number[];
853
+ range: (arr: number[]) => {
854
+ pos: number;
855
+ length: number;
856
+ }[];
857
+ rangeDebug: (bs: Uint32Array, len: number, invert?: boolean) => string;
858
+ setRange: (bs: Uint32Array, bsLen: number, pos: number, len: number, allowRewrite?: boolean) => boolean;
859
+ };
860
+ _Reader: typeof _Reader;
861
+ _Writer: typeof _Writer;
862
+ Path: {
863
+ /**
864
+ * Internal method for handling stack of paths (debug, errors, dynamic fields via path)
865
+ * This is looks ugly (callback), but allows us to force stack cleaning by construction (.pop always after function).
866
+ * Also, this makes impossible:
867
+ * - pushing field when stack is empty
868
+ * - pushing field inside of field (real bug)
869
+ * NOTE: we don't want to do '.pop' on error!
870
+ */
871
+ pushObj: (stack: PathStack, obj: StructOut, objFn: _PathObjFn) => void;
872
+ path: (stack: PathStack) => string;
873
+ err(name: string, stack: PathStack, msg: string | Error): Error;
874
+ resolve: (stack: PathStack, path: string) => StructOut | undefined;
875
+ };
876
+ };
877
+ //# sourceMappingURL=index.d.ts.map