@waku/rln 0.1.3-f6d5deb → 0.1.4-d27db21.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 (341) hide show
  1. package/README.md +10 -186
  2. package/bundle/_virtual/__node-resolve_empty.js +6 -0
  3. package/bundle/_virtual/_assert.js +3 -0
  4. package/bundle/_virtual/_commonjs-dynamic-modules.js +5 -0
  5. package/bundle/_virtual/_commonjsHelpers.js +32 -0
  6. package/bundle/_virtual/_node-resolve_empty.js +3 -0
  7. package/bundle/_virtual/_sha2.js +3 -0
  8. package/bundle/_virtual/_u64.js +3 -0
  9. package/bundle/_virtual/aes.js +3 -0
  10. package/bundle/_virtual/bn.js +3 -0
  11. package/bundle/_virtual/browser.js +3 -0
  12. package/bundle/_virtual/checksum.js +3 -0
  13. package/bundle/_virtual/cipher.js +3 -0
  14. package/bundle/_virtual/class.js +3 -0
  15. package/bundle/_virtual/common.js +3 -0
  16. package/bundle/_virtual/common2.js +3 -0
  17. package/bundle/_virtual/cryptoBrowser.js +3 -0
  18. package/bundle/_virtual/functional.js +3 -0
  19. package/bundle/_virtual/hash.js +3 -0
  20. package/bundle/_virtual/hmac.js +3 -0
  21. package/bundle/_virtual/index.js +3 -0
  22. package/bundle/_virtual/index2.js +6 -0
  23. package/bundle/_virtual/inherits_browser.js +3 -0
  24. package/bundle/_virtual/kdf.js +3 -0
  25. package/bundle/_virtual/lodash.js +3 -0
  26. package/bundle/_virtual/password.js +3 -0
  27. package/bundle/_virtual/pbkdf2.js +3 -0
  28. package/bundle/_virtual/pbkdf22.js +3 -0
  29. package/bundle/_virtual/random.js +3 -0
  30. package/bundle/_virtual/ripemd.js +3 -0
  31. package/bundle/_virtual/schema-validation-generated.js +3 -0
  32. package/bundle/_virtual/schema-validation.js +3 -0
  33. package/bundle/_virtual/scrypt.js +3 -0
  34. package/bundle/_virtual/scrypt2.js +3 -0
  35. package/bundle/_virtual/sha.js +3 -0
  36. package/bundle/_virtual/sha256.js +3 -0
  37. package/bundle/_virtual/sha2562.js +3 -0
  38. package/bundle/_virtual/sha3.js +3 -0
  39. package/bundle/_virtual/sha512.js +3 -0
  40. package/bundle/_virtual/types.js +3 -0
  41. package/bundle/_virtual/utils.js +3 -0
  42. package/bundle/_virtual/utils2.js +3 -0
  43. package/bundle/_virtual/utils3.js +3 -0
  44. package/bundle/index.js +12 -74804
  45. package/bundle/node_modules/@ethersproject/abi/lib.esm/_version.js +3 -0
  46. package/bundle/node_modules/@ethersproject/abi/lib.esm/abi-coder.js +96 -0
  47. package/bundle/node_modules/@ethersproject/abi/lib.esm/coders/abstract-coder.js +148 -0
  48. package/bundle/node_modules/@ethersproject/abi/lib.esm/coders/address.js +26 -0
  49. package/bundle/node_modules/@ethersproject/abi/lib.esm/coders/anonymous.js +20 -0
  50. package/bundle/node_modules/@ethersproject/abi/lib.esm/coders/array.js +210 -0
  51. package/bundle/node_modules/@ethersproject/abi/lib.esm/coders/boolean.js +18 -0
  52. package/bundle/node_modules/@ethersproject/abi/lib.esm/coders/bytes.js +30 -0
  53. package/bundle/node_modules/@ethersproject/abi/lib.esm/coders/fixed-bytes.js +26 -0
  54. package/bundle/node_modules/@ethersproject/abi/lib.esm/coders/null.js +22 -0
  55. package/bundle/node_modules/@ethersproject/abi/lib.esm/coders/number.js +43 -0
  56. package/bundle/node_modules/@ethersproject/abi/lib.esm/coders/string.js +19 -0
  57. package/bundle/node_modules/@ethersproject/abi/lib.esm/coders/tuple.js +58 -0
  58. package/bundle/node_modules/@ethersproject/abi/lib.esm/fragments.js +854 -0
  59. package/bundle/node_modules/@ethersproject/abi/lib.esm/interface.js +609 -0
  60. package/bundle/node_modules/@ethersproject/abstract-provider/lib.esm/_version.js +3 -0
  61. package/bundle/node_modules/@ethersproject/abstract-provider/lib.esm/index.js +66 -0
  62. package/bundle/node_modules/@ethersproject/abstract-signer/lib.esm/_version.js +3 -0
  63. package/bundle/node_modules/@ethersproject/abstract-signer/lib.esm/index.js +302 -0
  64. package/bundle/node_modules/@ethersproject/address/lib.esm/_version.js +3 -0
  65. package/bundle/node_modules/@ethersproject/address/lib.esm/index.js +110 -0
  66. package/bundle/node_modules/@ethersproject/base64/lib.esm/base64.js +20 -0
  67. package/bundle/node_modules/@ethersproject/basex/lib.esm/index.js +120 -0
  68. package/bundle/node_modules/@ethersproject/bignumber/lib.esm/_version.js +3 -0
  69. package/bundle/node_modules/@ethersproject/bignumber/lib.esm/bignumber.js +287 -0
  70. package/bundle/node_modules/@ethersproject/bytes/lib.esm/_version.js +3 -0
  71. package/bundle/node_modules/@ethersproject/bytes/lib.esm/index.js +402 -0
  72. package/bundle/node_modules/@ethersproject/constants/lib.esm/addresses.js +3 -0
  73. package/bundle/node_modules/@ethersproject/constants/lib.esm/bignumbers.js +8 -0
  74. package/bundle/node_modules/@ethersproject/constants/lib.esm/hashes.js +3 -0
  75. package/bundle/node_modules/@ethersproject/contracts/lib.esm/_version.js +3 -0
  76. package/bundle/node_modules/@ethersproject/contracts/lib.esm/index.js +893 -0
  77. package/bundle/node_modules/@ethersproject/hash/lib.esm/_version.js +3 -0
  78. package/bundle/node_modules/@ethersproject/hash/lib.esm/ens-normalize/decoder.js +256 -0
  79. package/bundle/node_modules/@ethersproject/hash/lib.esm/ens-normalize/include.js +36 -0
  80. package/bundle/node_modules/@ethersproject/hash/lib.esm/ens-normalize/lib.js +135 -0
  81. package/bundle/node_modules/@ethersproject/hash/lib.esm/id.js +8 -0
  82. package/bundle/node_modules/@ethersproject/hash/lib.esm/namehash.js +64 -0
  83. package/bundle/node_modules/@ethersproject/hash/lib.esm/typed-data.js +443 -0
  84. package/bundle/node_modules/@ethersproject/keccak256/lib.esm/index.js +8 -0
  85. package/bundle/node_modules/@ethersproject/keccak256/node_modules/js-sha3/src/sha3.js +660 -0
  86. package/bundle/node_modules/@ethersproject/logger/lib.esm/_version.js +3 -0
  87. package/bundle/node_modules/@ethersproject/logger/lib.esm/index.js +352 -0
  88. package/bundle/node_modules/@ethersproject/networks/lib.esm/_version.js +3 -0
  89. package/bundle/node_modules/@ethersproject/networks/lib.esm/index.js +248 -0
  90. package/bundle/node_modules/@ethersproject/properties/lib.esm/_version.js +3 -0
  91. package/bundle/node_modules/@ethersproject/properties/lib.esm/index.js +127 -0
  92. package/bundle/node_modules/@ethersproject/providers/lib.esm/_version.js +3 -0
  93. package/bundle/node_modules/@ethersproject/providers/lib.esm/base-provider.js +2007 -0
  94. package/bundle/node_modules/@ethersproject/providers/lib.esm/formatter.js +422 -0
  95. package/bundle/node_modules/@ethersproject/providers/lib.esm/json-rpc-provider.js +674 -0
  96. package/bundle/node_modules/@ethersproject/providers/lib.esm/web3-provider.js +132 -0
  97. package/bundle/node_modules/@ethersproject/rlp/lib.esm/_version.js +3 -0
  98. package/bundle/node_modules/@ethersproject/rlp/lib.esm/index.js +120 -0
  99. package/bundle/node_modules/@ethersproject/sha2/lib.esm/sha2.js +8 -0
  100. package/bundle/node_modules/@ethersproject/signing-key/lib.esm/_version.js +3 -0
  101. package/bundle/node_modules/@ethersproject/signing-key/lib.esm/elliptic.js +2430 -0
  102. package/bundle/node_modules/@ethersproject/signing-key/lib.esm/index.js +76 -0
  103. package/bundle/node_modules/@ethersproject/strings/lib.esm/_version.js +3 -0
  104. package/bundle/node_modules/@ethersproject/strings/lib.esm/utf8.js +219 -0
  105. package/bundle/node_modules/@ethersproject/transactions/lib.esm/_version.js +3 -0
  106. package/bundle/node_modules/@ethersproject/transactions/lib.esm/index.js +279 -0
  107. package/bundle/node_modules/@ethersproject/web/lib.esm/_version.js +3 -0
  108. package/bundle/node_modules/@ethersproject/web/lib.esm/geturl.js +69 -0
  109. package/bundle/node_modules/@ethersproject/web/lib.esm/index.js +404 -0
  110. package/bundle/node_modules/@multiformats/multiaddr/dist/src/convert.js +15 -0
  111. package/bundle/node_modules/@multiformats/multiaddr/dist/src/multiaddr.js +20 -0
  112. package/bundle/node_modules/@multiformats/multiaddr/dist/src/protocols-table.js +92 -0
  113. package/bundle/node_modules/@noble/hashes/esm/_assert.js +37 -0
  114. package/bundle/node_modules/@noble/hashes/esm/_md.js +132 -0
  115. package/bundle/node_modules/@noble/hashes/esm/_u64.js +29 -0
  116. package/bundle/node_modules/@noble/hashes/esm/sha256.js +113 -0
  117. package/bundle/node_modules/@noble/hashes/esm/sha3.js +210 -0
  118. package/bundle/node_modules/@noble/hashes/esm/utils.js +144 -0
  119. package/bundle/node_modules/@waku/zerokit-rln-wasm/rln_wasm.js +756 -0
  120. package/bundle/node_modules/bech32/index.js +187 -0
  121. package/bundle/node_modules/bn.js/lib/bn.js +3361 -0
  122. package/bundle/node_modules/debug/src/browser.js +283 -0
  123. package/bundle/node_modules/debug/src/common.js +295 -0
  124. package/bundle/node_modules/ethereum-cryptography/esm/keccak.js +10 -0
  125. package/bundle/node_modules/ethereum-cryptography/esm/sha256.js +6 -0
  126. package/bundle/node_modules/ethereum-cryptography/esm/utils.js +24 -0
  127. package/bundle/node_modules/hash.js/lib/hash/common.js +97 -0
  128. package/bundle/node_modules/hash.js/lib/hash/hmac.js +51 -0
  129. package/bundle/node_modules/hash.js/lib/hash/ripemd.js +152 -0
  130. package/bundle/node_modules/hash.js/lib/hash/sha/1.js +81 -0
  131. package/bundle/node_modules/hash.js/lib/hash/sha/224.js +33 -0
  132. package/bundle/node_modules/hash.js/lib/hash/sha/256.js +113 -0
  133. package/bundle/node_modules/hash.js/lib/hash/sha/384.js +39 -0
  134. package/bundle/node_modules/hash.js/lib/hash/sha/512.js +336 -0
  135. package/bundle/node_modules/hash.js/lib/hash/sha/common.js +53 -0
  136. package/bundle/node_modules/hash.js/lib/hash/sha.js +14 -0
  137. package/bundle/node_modules/hash.js/lib/hash/utils.js +282 -0
  138. package/bundle/node_modules/hash.js/lib/hash.js +33 -0
  139. package/bundle/node_modules/inherits/inherits_browser.js +33 -0
  140. package/bundle/node_modules/it-length-prefixed/dist/src/decode.js +6 -0
  141. package/bundle/node_modules/lodash/lodash.js +17207 -0
  142. package/bundle/node_modules/minimalistic-assert/index.js +13 -0
  143. package/bundle/node_modules/ms/index.js +172 -0
  144. package/bundle/node_modules/multiformats/dist/src/bases/base.js +205 -0
  145. package/bundle/node_modules/multiformats/dist/src/bases/base10.js +9 -0
  146. package/bundle/node_modules/multiformats/dist/src/bases/base16.js +16 -0
  147. package/bundle/node_modules/multiformats/dist/src/bases/base2.js +10 -0
  148. package/bundle/node_modules/multiformats/dist/src/bases/base256emoji.js +41 -0
  149. package/bundle/node_modules/multiformats/dist/src/bases/base32.js +58 -0
  150. package/bundle/node_modules/multiformats/dist/src/bases/base36.js +14 -0
  151. package/bundle/node_modules/multiformats/dist/src/bases/base58.js +14 -0
  152. package/bundle/node_modules/multiformats/dist/src/bases/base64.js +28 -0
  153. package/bundle/node_modules/multiformats/dist/src/bases/base8.js +10 -0
  154. package/bundle/node_modules/multiformats/dist/src/bases/identity.js +11 -0
  155. package/bundle/node_modules/multiformats/dist/src/basics.js +15 -0
  156. package/bundle/node_modules/multiformats/dist/src/bytes.js +18 -0
  157. package/bundle/node_modules/multiformats/dist/src/codecs/json.js +2 -0
  158. package/bundle/node_modules/multiformats/dist/src/vendor/base-x.js +170 -0
  159. package/bundle/node_modules/protons-runtime/dist/src/codec.js +20 -0
  160. package/bundle/node_modules/protons-runtime/dist/src/codecs/enum.js +24 -0
  161. package/bundle/node_modules/protons-runtime/dist/src/codecs/message.js +7 -0
  162. package/bundle/node_modules/protons-runtime/dist/src/decode.js +8 -0
  163. package/bundle/node_modules/protons-runtime/dist/src/encode.js +11 -0
  164. package/bundle/node_modules/protons-runtime/dist/src/index.js +30 -0
  165. package/bundle/node_modules/protons-runtime/dist/src/utils/float.js +54 -0
  166. package/bundle/node_modules/protons-runtime/dist/src/utils/longbits.js +175 -0
  167. package/bundle/node_modules/protons-runtime/dist/src/utils/pool.js +28 -0
  168. package/bundle/node_modules/protons-runtime/dist/src/utils/reader.js +367 -0
  169. package/bundle/node_modules/protons-runtime/dist/src/utils/utf8.js +99 -0
  170. package/bundle/node_modules/protons-runtime/dist/src/utils/writer.js +438 -0
  171. package/bundle/node_modules/uint8-varint/dist/src/index.js +124 -0
  172. package/bundle/node_modules/uint8arrays/dist/src/alloc.js +17 -0
  173. package/bundle/node_modules/uint8arrays/dist/src/from-string.js +19 -0
  174. package/bundle/node_modules/uint8arrays/dist/src/util/bases.js +49 -0
  175. package/bundle/packages/core/dist/lib/connection_manager/connection_manager.js +21 -0
  176. package/bundle/packages/core/dist/lib/connection_manager/keep_alive_manager.js +18 -0
  177. package/bundle/packages/core/dist/lib/filter/filter.js +27 -0
  178. package/bundle/packages/core/dist/lib/light_push/light_push.js +27 -0
  179. package/bundle/packages/core/dist/lib/message/version_0.js +154 -0
  180. package/bundle/packages/core/dist/lib/metadata/metadata.js +27 -0
  181. package/bundle/packages/core/dist/lib/store/store.js +27 -0
  182. package/bundle/packages/interfaces/dist/connection_manager.js +19 -0
  183. package/bundle/packages/interfaces/dist/constants.js +6 -0
  184. package/bundle/packages/interfaces/dist/health_indicator.js +12 -0
  185. package/bundle/packages/interfaces/dist/protocols.js +92 -0
  186. package/bundle/packages/proto/dist/generated/filter.js +445 -0
  187. package/bundle/packages/proto/dist/generated/filter_v2.js +424 -0
  188. package/bundle/packages/proto/dist/generated/light_push.js +389 -0
  189. package/bundle/packages/proto/dist/generated/message.js +213 -0
  190. package/bundle/packages/proto/dist/generated/metadata.js +130 -0
  191. package/bundle/packages/proto/dist/generated/peer_exchange.js +209 -0
  192. package/bundle/packages/proto/dist/generated/sds_message.js +105 -0
  193. package/bundle/packages/proto/dist/generated/store_v3.js +490 -0
  194. package/bundle/packages/proto/dist/generated/topic_only_message.js +61 -0
  195. package/bundle/packages/rln/dist/codec.js +93 -0
  196. package/bundle/packages/rln/dist/contract/abi.js +394 -0
  197. package/bundle/packages/rln/dist/contract/constants.js +27 -0
  198. package/bundle/packages/rln/dist/contract/rln_contract.js +438 -0
  199. package/bundle/packages/rln/dist/create.js +9 -0
  200. package/bundle/packages/rln/dist/identity.js +30 -0
  201. package/bundle/packages/rln/dist/keystore/cipher.js +31 -0
  202. package/bundle/packages/rln/dist/keystore/credential_validation_generated.js +119 -0
  203. package/bundle/packages/rln/dist/keystore/keystore.js +223 -0
  204. package/bundle/packages/rln/dist/keystore/keystore_validation_generated.js +74 -0
  205. package/bundle/packages/rln/dist/keystore/schema_validator.js +20 -0
  206. package/bundle/packages/rln/dist/message.js +51 -0
  207. package/bundle/packages/rln/dist/proof.js +54 -0
  208. package/bundle/packages/rln/dist/resources/verification_key.js +112 -0
  209. package/bundle/packages/rln/dist/resources/witness_calculator.js +330 -0
  210. package/bundle/packages/rln/dist/rln.js +220 -0
  211. package/bundle/packages/rln/dist/root_tracker.js +76 -0
  212. package/bundle/packages/rln/dist/utils/bytes.js +65 -0
  213. package/bundle/packages/rln/dist/utils/epoch.js +39 -0
  214. package/bundle/packages/rln/dist/utils/hash.js +10 -0
  215. package/bundle/packages/rln/dist/utils/metamask.js +14 -0
  216. package/bundle/packages/rln/dist/zerokit.js +128 -0
  217. package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/lib/checksum.js +52 -0
  218. package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/lib/cipher.js +65 -0
  219. package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/lib/class.js +99 -0
  220. package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/lib/functional.js +103 -0
  221. package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/lib/index.js +28 -0
  222. package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/lib/kdf.js +78 -0
  223. package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/lib/password.js +17 -0
  224. package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/lib/schema-validation-generated.js +1253 -0
  225. package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/lib/schema-validation.js +40 -0
  226. package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/lib/types.js +5 -0
  227. package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/node_modules/ethereum-cryptography/aes.js +103 -0
  228. package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/node_modules/ethereum-cryptography/pbkdf2.js +41 -0
  229. package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/node_modules/ethereum-cryptography/random.js +17 -0
  230. package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/node_modules/ethereum-cryptography/scrypt.js +23 -0
  231. package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/node_modules/ethereum-cryptography/sha256.js +12 -0
  232. package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/node_modules/ethereum-cryptography/utils.js +77 -0
  233. package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/node_modules/uuid/dist/esm-browser/index.js +9 -0
  234. package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/node_modules/uuid/dist/esm-browser/md5.js +215 -0
  235. package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/node_modules/uuid/dist/esm-browser/nil.js +3 -0
  236. package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/node_modules/uuid/dist/esm-browser/parse.js +35 -0
  237. package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/node_modules/uuid/dist/esm-browser/regex.js +3 -0
  238. package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/node_modules/uuid/dist/esm-browser/rng.js +21 -0
  239. package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/node_modules/uuid/dist/esm-browser/sha1.js +96 -0
  240. package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/node_modules/uuid/dist/esm-browser/stringify.js +31 -0
  241. package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/node_modules/uuid/dist/esm-browser/v1.js +96 -0
  242. package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/node_modules/uuid/dist/esm-browser/v3.js +6 -0
  243. package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/node_modules/uuid/dist/esm-browser/v35.js +66 -0
  244. package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/node_modules/uuid/dist/esm-browser/v4.js +24 -0
  245. package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/node_modules/uuid/dist/esm-browser/v5.js +6 -0
  246. package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/node_modules/uuid/dist/esm-browser/validate.js +7 -0
  247. package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/node_modules/uuid/dist/esm-browser/version.js +11 -0
  248. package/bundle/packages/rln/node_modules/@noble/hashes/_assert.js +52 -0
  249. package/bundle/packages/rln/node_modules/@noble/hashes/_sha2.js +124 -0
  250. package/bundle/packages/rln/node_modules/@noble/hashes/_u64.js +71 -0
  251. package/bundle/packages/rln/node_modules/@noble/hashes/cryptoBrowser.js +10 -0
  252. package/bundle/packages/rln/node_modules/@noble/hashes/hmac.js +88 -0
  253. package/bundle/packages/rln/node_modules/@noble/hashes/pbkdf2.js +99 -0
  254. package/bundle/packages/rln/node_modules/@noble/hashes/scrypt.js +233 -0
  255. package/bundle/packages/rln/node_modules/@noble/hashes/sha256.js +133 -0
  256. package/bundle/packages/rln/node_modules/@noble/hashes/sha512.js +243 -0
  257. package/bundle/packages/rln/node_modules/@noble/hashes/utils.js +167 -0
  258. package/bundle/packages/rln/node_modules/uuid/dist/esm-browser/native.js +4 -0
  259. package/bundle/packages/rln/node_modules/uuid/dist/esm-browser/rng.js +13 -0
  260. package/bundle/packages/rln/node_modules/uuid/dist/esm-browser/stringify.js +28 -0
  261. package/bundle/packages/rln/node_modules/uuid/dist/esm-browser/v4.js +19 -0
  262. package/bundle/packages/utils/dist/bytes/index.js +44 -0
  263. package/bundle/packages/utils/dist/common/sharding/index.js +91 -0
  264. package/bundle/packages/utils/dist/logger/index.js +31 -0
  265. package/bundle/resources/verification_key.d.ts +13 -0
  266. package/bundle/resources/verification_key.js +112 -0
  267. package/bundle/resources/witness_calculator.d.ts +11 -0
  268. package/bundle/resources/witness_calculator.js +328 -0
  269. package/dist/.tsbuildinfo +1 -0
  270. package/dist/codec.d.ts +5 -5
  271. package/dist/codec.js +6 -6
  272. package/dist/codec.js.map +1 -1
  273. package/dist/contract/abi.d.ts +42 -0
  274. package/dist/contract/abi.js +393 -0
  275. package/dist/contract/abi.js.map +1 -0
  276. package/dist/contract/constants.d.ts +59 -3
  277. package/dist/contract/constants.js +21 -63
  278. package/dist/contract/constants.js.map +1 -1
  279. package/dist/contract/rln_contract.d.ts +98 -17
  280. package/dist/contract/rln_contract.js +292 -71
  281. package/dist/contract/rln_contract.js.map +1 -1
  282. package/dist/identity.js +5 -2
  283. package/dist/identity.js.map +1 -1
  284. package/dist/index.d.ts +3 -3
  285. package/dist/index.js +3 -3
  286. package/dist/index.js.map +1 -1
  287. package/dist/keystore/cipher.js +3 -3
  288. package/dist/keystore/cipher.js.map +1 -1
  289. package/dist/keystore/credential_validation_generated.js.map +1 -1
  290. package/dist/keystore/keystore.js +4 -4
  291. package/dist/keystore/keystore.js.map +1 -1
  292. package/dist/keystore/keystore_validation_generated.js.map +1 -1
  293. package/dist/message.js +3 -3
  294. package/dist/message.js.map +1 -1
  295. package/dist/proof.js +3 -2
  296. package/dist/proof.js.map +1 -1
  297. package/dist/resources/verification_key.d.ts +12 -11
  298. package/dist/resources/verification_key.js +103 -103
  299. package/dist/resources/witness_calculator.d.ts +10 -15
  300. package/dist/resources/witness_calculator.js +302 -265
  301. package/dist/rln.d.ts +5 -1
  302. package/dist/rln.js +56 -28
  303. package/dist/rln.js.map +1 -1
  304. package/dist/root_tracker.js.map +1 -1
  305. package/dist/utils/epoch.js +5 -5
  306. package/dist/utils/epoch.js.map +1 -1
  307. package/dist/zerokit.d.ts +13 -9
  308. package/dist/zerokit.js +40 -20
  309. package/dist/zerokit.js.map +1 -1
  310. package/package.json +1 -146
  311. package/src/codec.ts +26 -22
  312. package/src/contract/abi.ts +392 -0
  313. package/src/contract/constants.ts +28 -0
  314. package/src/contract/index.ts +2 -0
  315. package/src/contract/rln_contract.ts +686 -0
  316. package/src/identity.ts +8 -4
  317. package/src/index.ts +4 -9
  318. package/src/keystore/cipher.ts +54 -0
  319. package/src/keystore/credential_validation_generated.ts +7 -0
  320. package/src/keystore/index.ts +5 -0
  321. package/src/keystore/keystore.ts +330 -0
  322. package/src/keystore/keystore_validation_generated.ts +7 -0
  323. package/src/keystore/schema_validator.ts +34 -0
  324. package/src/keystore/types.ts +36 -0
  325. package/src/message.ts +10 -10
  326. package/src/proof.ts +13 -11
  327. package/src/resources/verification_key.d.ts +13 -0
  328. package/src/resources/witness_calculator.d.ts +11 -0
  329. package/src/rln.ts +76 -31
  330. package/src/root_tracker.ts +7 -6
  331. package/src/utils/bytes.ts +84 -0
  332. package/src/utils/epoch.ts +30 -0
  333. package/src/utils/hash.ts +15 -0
  334. package/src/utils/index.ts +9 -0
  335. package/src/utils/metamask.ts +17 -0
  336. package/src/zerokit.ts +95 -33
  337. package/bundle/assets/rln_wasm_bg-a503e304.wasm +0 -0
  338. package/dist/resources/verification_key.js.map +0 -1
  339. package/dist/resources/witness_calculator.js.map +0 -1
  340. /package/bundle/{assets/rln-6ded2896.wasm → resources/rln.wasm} +0 -0
  341. /package/bundle/{assets/rln_final-8b299152.zkey → resources/rln_final.zkey} +0 -0
@@ -0,0 +1,76 @@
1
+ import { EC as EC$1 } from './elliptic.js';
2
+ import { splitSignature, arrayify, hexlify, hexDataLength, hexZeroPad } from '../../bytes/lib.esm/index.js';
3
+ import { defineReadOnly } from '../../properties/lib.esm/index.js';
4
+ import { Logger } from '../../logger/lib.esm/index.js';
5
+ import { version } from './_version.js';
6
+
7
+ const logger = new Logger(version);
8
+ let _curve = null;
9
+ function getCurve() {
10
+ if (!_curve) {
11
+ _curve = new EC$1("secp256k1");
12
+ }
13
+ return _curve;
14
+ }
15
+ class SigningKey {
16
+ constructor(privateKey) {
17
+ defineReadOnly(this, "curve", "secp256k1");
18
+ defineReadOnly(this, "privateKey", hexlify(privateKey));
19
+ if (hexDataLength(this.privateKey) !== 32) {
20
+ logger.throwArgumentError("invalid private key", "privateKey", "[[ REDACTED ]]");
21
+ }
22
+ const keyPair = getCurve().keyFromPrivate(arrayify(this.privateKey));
23
+ defineReadOnly(this, "publicKey", "0x" + keyPair.getPublic(false, "hex"));
24
+ defineReadOnly(this, "compressedPublicKey", "0x" + keyPair.getPublic(true, "hex"));
25
+ defineReadOnly(this, "_isSigningKey", true);
26
+ }
27
+ _addPoint(other) {
28
+ const p0 = getCurve().keyFromPublic(arrayify(this.publicKey));
29
+ const p1 = getCurve().keyFromPublic(arrayify(other));
30
+ return "0x" + p0.pub.add(p1.pub).encodeCompressed("hex");
31
+ }
32
+ signDigest(digest) {
33
+ const keyPair = getCurve().keyFromPrivate(arrayify(this.privateKey));
34
+ const digestBytes = arrayify(digest);
35
+ if (digestBytes.length !== 32) {
36
+ logger.throwArgumentError("bad digest length", "digest", digest);
37
+ }
38
+ const signature = keyPair.sign(digestBytes, { canonical: true });
39
+ return splitSignature({
40
+ recoveryParam: signature.recoveryParam,
41
+ r: hexZeroPad("0x" + signature.r.toString(16), 32),
42
+ s: hexZeroPad("0x" + signature.s.toString(16), 32),
43
+ });
44
+ }
45
+ computeSharedSecret(otherKey) {
46
+ const keyPair = getCurve().keyFromPrivate(arrayify(this.privateKey));
47
+ const otherKeyPair = getCurve().keyFromPublic(arrayify(computePublicKey(otherKey)));
48
+ return hexZeroPad("0x" + keyPair.derive(otherKeyPair.getPublic()).toString(16), 32);
49
+ }
50
+ static isSigningKey(value) {
51
+ return !!(value && value._isSigningKey);
52
+ }
53
+ }
54
+ function recoverPublicKey(digest, signature) {
55
+ const sig = splitSignature(signature);
56
+ const rs = { r: arrayify(sig.r), s: arrayify(sig.s) };
57
+ return "0x" + getCurve().recoverPubKey(arrayify(digest), rs, sig.recoveryParam).encode("hex", false);
58
+ }
59
+ function computePublicKey(key, compressed) {
60
+ const bytes = arrayify(key);
61
+ if (bytes.length === 32) {
62
+ const signingKey = new SigningKey(bytes);
63
+ return signingKey.publicKey;
64
+ }
65
+ else if (bytes.length === 33) {
66
+ return "0x" + getCurve().keyFromPublic(bytes).getPublic(false, "hex");
67
+ }
68
+ else if (bytes.length === 65) {
69
+ {
70
+ return hexlify(bytes);
71
+ }
72
+ }
73
+ return logger.throwArgumentError("invalid public or private key", "key", "[REDACTED]");
74
+ }
75
+
76
+ export { SigningKey, computePublicKey, recoverPublicKey };
@@ -0,0 +1,3 @@
1
+ const version = "strings/5.7.0";
2
+
3
+ export { version };
@@ -0,0 +1,219 @@
1
+ import { arrayify } from '../../bytes/lib.esm/index.js';
2
+ import { Logger } from '../../logger/lib.esm/index.js';
3
+ import { version } from './_version.js';
4
+
5
+ const logger = new Logger(version);
6
+ ///////////////////////////////
7
+ var UnicodeNormalizationForm;
8
+ (function (UnicodeNormalizationForm) {
9
+ UnicodeNormalizationForm["current"] = "";
10
+ UnicodeNormalizationForm["NFC"] = "NFC";
11
+ UnicodeNormalizationForm["NFD"] = "NFD";
12
+ UnicodeNormalizationForm["NFKC"] = "NFKC";
13
+ UnicodeNormalizationForm["NFKD"] = "NFKD";
14
+ })(UnicodeNormalizationForm || (UnicodeNormalizationForm = {}));
15
+ var Utf8ErrorReason;
16
+ (function (Utf8ErrorReason) {
17
+ // A continuation byte was present where there was nothing to continue
18
+ // - offset = the index the codepoint began in
19
+ Utf8ErrorReason["UNEXPECTED_CONTINUE"] = "unexpected continuation byte";
20
+ // An invalid (non-continuation) byte to start a UTF-8 codepoint was found
21
+ // - offset = the index the codepoint began in
22
+ Utf8ErrorReason["BAD_PREFIX"] = "bad codepoint prefix";
23
+ // The string is too short to process the expected codepoint
24
+ // - offset = the index the codepoint began in
25
+ Utf8ErrorReason["OVERRUN"] = "string overrun";
26
+ // A missing continuation byte was expected but not found
27
+ // - offset = the index the continuation byte was expected at
28
+ Utf8ErrorReason["MISSING_CONTINUE"] = "missing continuation byte";
29
+ // The computed code point is outside the range for UTF-8
30
+ // - offset = start of this codepoint
31
+ // - badCodepoint = the computed codepoint; outside the UTF-8 range
32
+ Utf8ErrorReason["OUT_OF_RANGE"] = "out of UTF-8 range";
33
+ // UTF-8 strings may not contain UTF-16 surrogate pairs
34
+ // - offset = start of this codepoint
35
+ // - badCodepoint = the computed codepoint; inside the UTF-16 surrogate range
36
+ Utf8ErrorReason["UTF16_SURROGATE"] = "UTF-16 surrogate";
37
+ // The string is an overlong representation
38
+ // - offset = start of this codepoint
39
+ // - badCodepoint = the computed codepoint; already bounds checked
40
+ Utf8ErrorReason["OVERLONG"] = "overlong representation";
41
+ })(Utf8ErrorReason || (Utf8ErrorReason = {}));
42
+ function errorFunc(reason, offset, bytes, output, badCodepoint) {
43
+ return logger.throwArgumentError(`invalid codepoint at offset ${offset}; ${reason}`, "bytes", bytes);
44
+ }
45
+ function ignoreFunc(reason, offset, bytes, output, badCodepoint) {
46
+ // If there is an invalid prefix (including stray continuation), skip any additional continuation bytes
47
+ if (reason === Utf8ErrorReason.BAD_PREFIX || reason === Utf8ErrorReason.UNEXPECTED_CONTINUE) {
48
+ let i = 0;
49
+ for (let o = offset + 1; o < bytes.length; o++) {
50
+ if (bytes[o] >> 6 !== 0x02) {
51
+ break;
52
+ }
53
+ i++;
54
+ }
55
+ return i;
56
+ }
57
+ // This byte runs us past the end of the string, so just jump to the end
58
+ // (but the first byte was read already read and therefore skipped)
59
+ if (reason === Utf8ErrorReason.OVERRUN) {
60
+ return bytes.length - offset - 1;
61
+ }
62
+ // Nothing to skip
63
+ return 0;
64
+ }
65
+ function replaceFunc(reason, offset, bytes, output, badCodepoint) {
66
+ // Overlong representations are otherwise "valid" code points; just non-deistingtished
67
+ if (reason === Utf8ErrorReason.OVERLONG) {
68
+ output.push(badCodepoint);
69
+ return 0;
70
+ }
71
+ // Put the replacement character into the output
72
+ output.push(0xfffd);
73
+ // Otherwise, process as if ignoring errors
74
+ return ignoreFunc(reason, offset, bytes);
75
+ }
76
+ // Common error handing strategies
77
+ const Utf8ErrorFuncs = Object.freeze({
78
+ error: errorFunc,
79
+ ignore: ignoreFunc,
80
+ replace: replaceFunc
81
+ });
82
+ // http://stackoverflow.com/questions/13356493/decode-utf-8-with-javascript#13691499
83
+ function getUtf8CodePoints(bytes, onError) {
84
+ if (onError == null) {
85
+ onError = Utf8ErrorFuncs.error;
86
+ }
87
+ bytes = arrayify(bytes);
88
+ const result = [];
89
+ let i = 0;
90
+ // Invalid bytes are ignored
91
+ while (i < bytes.length) {
92
+ const c = bytes[i++];
93
+ // 0xxx xxxx
94
+ if (c >> 7 === 0) {
95
+ result.push(c);
96
+ continue;
97
+ }
98
+ // Multibyte; how many bytes left for this character?
99
+ let extraLength = null;
100
+ let overlongMask = null;
101
+ // 110x xxxx 10xx xxxx
102
+ if ((c & 0xe0) === 0xc0) {
103
+ extraLength = 1;
104
+ overlongMask = 0x7f;
105
+ // 1110 xxxx 10xx xxxx 10xx xxxx
106
+ }
107
+ else if ((c & 0xf0) === 0xe0) {
108
+ extraLength = 2;
109
+ overlongMask = 0x7ff;
110
+ // 1111 0xxx 10xx xxxx 10xx xxxx 10xx xxxx
111
+ }
112
+ else if ((c & 0xf8) === 0xf0) {
113
+ extraLength = 3;
114
+ overlongMask = 0xffff;
115
+ }
116
+ else {
117
+ if ((c & 0xc0) === 0x80) {
118
+ i += onError(Utf8ErrorReason.UNEXPECTED_CONTINUE, i - 1, bytes, result);
119
+ }
120
+ else {
121
+ i += onError(Utf8ErrorReason.BAD_PREFIX, i - 1, bytes, result);
122
+ }
123
+ continue;
124
+ }
125
+ // Do we have enough bytes in our data?
126
+ if (i - 1 + extraLength >= bytes.length) {
127
+ i += onError(Utf8ErrorReason.OVERRUN, i - 1, bytes, result);
128
+ continue;
129
+ }
130
+ // Remove the length prefix from the char
131
+ let res = c & ((1 << (8 - extraLength - 1)) - 1);
132
+ for (let j = 0; j < extraLength; j++) {
133
+ let nextChar = bytes[i];
134
+ // Invalid continuation byte
135
+ if ((nextChar & 0xc0) != 0x80) {
136
+ i += onError(Utf8ErrorReason.MISSING_CONTINUE, i, bytes, result);
137
+ res = null;
138
+ break;
139
+ }
140
+ res = (res << 6) | (nextChar & 0x3f);
141
+ i++;
142
+ }
143
+ // See above loop for invalid continuation byte
144
+ if (res === null) {
145
+ continue;
146
+ }
147
+ // Maximum code point
148
+ if (res > 0x10ffff) {
149
+ i += onError(Utf8ErrorReason.OUT_OF_RANGE, i - 1 - extraLength, bytes, result, res);
150
+ continue;
151
+ }
152
+ // Reserved for UTF-16 surrogate halves
153
+ if (res >= 0xd800 && res <= 0xdfff) {
154
+ i += onError(Utf8ErrorReason.UTF16_SURROGATE, i - 1 - extraLength, bytes, result, res);
155
+ continue;
156
+ }
157
+ // Check for overlong sequences (more bytes than needed)
158
+ if (res <= overlongMask) {
159
+ i += onError(Utf8ErrorReason.OVERLONG, i - 1 - extraLength, bytes, result, res);
160
+ continue;
161
+ }
162
+ result.push(res);
163
+ }
164
+ return result;
165
+ }
166
+ // http://stackoverflow.com/questions/18729405/how-to-convert-utf8-string-to-byte-array
167
+ function toUtf8Bytes(str, form = UnicodeNormalizationForm.current) {
168
+ if (form != UnicodeNormalizationForm.current) {
169
+ logger.checkNormalize();
170
+ str = str.normalize(form);
171
+ }
172
+ let result = [];
173
+ for (let i = 0; i < str.length; i++) {
174
+ const c = str.charCodeAt(i);
175
+ if (c < 0x80) {
176
+ result.push(c);
177
+ }
178
+ else if (c < 0x800) {
179
+ result.push((c >> 6) | 0xc0);
180
+ result.push((c & 0x3f) | 0x80);
181
+ }
182
+ else if ((c & 0xfc00) == 0xd800) {
183
+ i++;
184
+ const c2 = str.charCodeAt(i);
185
+ if (i >= str.length || (c2 & 0xfc00) !== 0xdc00) {
186
+ throw new Error("invalid utf-8 string");
187
+ }
188
+ // Surrogate Pair
189
+ const pair = 0x10000 + ((c & 0x03ff) << 10) + (c2 & 0x03ff);
190
+ result.push((pair >> 18) | 0xf0);
191
+ result.push(((pair >> 12) & 0x3f) | 0x80);
192
+ result.push(((pair >> 6) & 0x3f) | 0x80);
193
+ result.push((pair & 0x3f) | 0x80);
194
+ }
195
+ else {
196
+ result.push((c >> 12) | 0xe0);
197
+ result.push(((c >> 6) & 0x3f) | 0x80);
198
+ result.push((c & 0x3f) | 0x80);
199
+ }
200
+ }
201
+ return arrayify(result);
202
+ }
203
+ function _toUtf8String(codePoints) {
204
+ return codePoints.map((codePoint) => {
205
+ if (codePoint <= 0xffff) {
206
+ return String.fromCharCode(codePoint);
207
+ }
208
+ codePoint -= 0x10000;
209
+ return String.fromCharCode((((codePoint >> 10) & 0x3ff) + 0xd800), ((codePoint & 0x3ff) + 0xdc00));
210
+ }).join("");
211
+ }
212
+ function toUtf8String(bytes, onError) {
213
+ return _toUtf8String(getUtf8CodePoints(bytes, onError));
214
+ }
215
+ function toUtf8CodePoints(str, form = UnicodeNormalizationForm.current) {
216
+ return getUtf8CodePoints(toUtf8Bytes(str, form));
217
+ }
218
+
219
+ export { UnicodeNormalizationForm, Utf8ErrorFuncs, Utf8ErrorReason, _toUtf8String, toUtf8Bytes, toUtf8CodePoints, toUtf8String };
@@ -0,0 +1,3 @@
1
+ const version = "transactions/5.7.0";
2
+
3
+ export { version };
@@ -0,0 +1,279 @@
1
+ import { getAddress } from '../../address/lib.esm/index.js';
2
+ import { hexDataLength, arrayify, hexlify, hexZeroPad, hexDataSlice, splitSignature, stripZeros, hexConcat } from '../../bytes/lib.esm/index.js';
3
+ import { keccak256 } from '../../keccak256/lib.esm/index.js';
4
+ import { decode, encode } from '../../rlp/lib.esm/index.js';
5
+ import { recoverPublicKey, computePublicKey } from '../../signing-key/lib.esm/index.js';
6
+ import { Logger } from '../../logger/lib.esm/index.js';
7
+ import { version } from './_version.js';
8
+ import { BigNumber } from '../../bignumber/lib.esm/bignumber.js';
9
+ import { Zero } from '../../constants/lib.esm/bignumbers.js';
10
+
11
+ const logger = new Logger(version);
12
+ var TransactionTypes;
13
+ (function (TransactionTypes) {
14
+ TransactionTypes[TransactionTypes["legacy"] = 0] = "legacy";
15
+ TransactionTypes[TransactionTypes["eip2930"] = 1] = "eip2930";
16
+ TransactionTypes[TransactionTypes["eip1559"] = 2] = "eip1559";
17
+ })(TransactionTypes || (TransactionTypes = {}));
18
+ ///////////////////////////////
19
+ function handleAddress(value) {
20
+ if (value === "0x") {
21
+ return null;
22
+ }
23
+ return getAddress(value);
24
+ }
25
+ function handleNumber(value) {
26
+ if (value === "0x") {
27
+ return Zero;
28
+ }
29
+ return BigNumber.from(value);
30
+ }
31
+ function computeAddress(key) {
32
+ const publicKey = computePublicKey(key);
33
+ return getAddress(hexDataSlice(keccak256(hexDataSlice(publicKey, 1)), 12));
34
+ }
35
+ function recoverAddress(digest, signature) {
36
+ return computeAddress(recoverPublicKey(arrayify(digest), signature));
37
+ }
38
+ function formatNumber(value, name) {
39
+ const result = stripZeros(BigNumber.from(value).toHexString());
40
+ if (result.length > 32) {
41
+ logger.throwArgumentError("invalid length for " + name, ("transaction:" + name), value);
42
+ }
43
+ return result;
44
+ }
45
+ function accessSetify(addr, storageKeys) {
46
+ return {
47
+ address: getAddress(addr),
48
+ storageKeys: (storageKeys || []).map((storageKey, index) => {
49
+ if (hexDataLength(storageKey) !== 32) {
50
+ logger.throwArgumentError("invalid access list storageKey", `accessList[${addr}:${index}]`, storageKey);
51
+ }
52
+ return storageKey.toLowerCase();
53
+ })
54
+ };
55
+ }
56
+ function accessListify(value) {
57
+ if (Array.isArray(value)) {
58
+ return value.map((set, index) => {
59
+ if (Array.isArray(set)) {
60
+ if (set.length > 2) {
61
+ logger.throwArgumentError("access list expected to be [ address, storageKeys[] ]", `value[${index}]`, set);
62
+ }
63
+ return accessSetify(set[0], set[1]);
64
+ }
65
+ return accessSetify(set.address, set.storageKeys);
66
+ });
67
+ }
68
+ const result = Object.keys(value).map((addr) => {
69
+ const storageKeys = value[addr].reduce((accum, storageKey) => {
70
+ accum[storageKey] = true;
71
+ return accum;
72
+ }, {});
73
+ return accessSetify(addr, Object.keys(storageKeys).sort());
74
+ });
75
+ result.sort((a, b) => (a.address.localeCompare(b.address)));
76
+ return result;
77
+ }
78
+ function formatAccessList(value) {
79
+ return accessListify(value).map((set) => [set.address, set.storageKeys]);
80
+ }
81
+ function _serializeEip1559(transaction, signature) {
82
+ // If there is an explicit gasPrice, make sure it matches the
83
+ // EIP-1559 fees; otherwise they may not understand what they
84
+ // think they are setting in terms of fee.
85
+ if (transaction.gasPrice != null) {
86
+ const gasPrice = BigNumber.from(transaction.gasPrice);
87
+ const maxFeePerGas = BigNumber.from(transaction.maxFeePerGas || 0);
88
+ if (!gasPrice.eq(maxFeePerGas)) {
89
+ logger.throwArgumentError("mismatch EIP-1559 gasPrice != maxFeePerGas", "tx", {
90
+ gasPrice, maxFeePerGas
91
+ });
92
+ }
93
+ }
94
+ const fields = [
95
+ formatNumber(transaction.chainId || 0, "chainId"),
96
+ formatNumber(transaction.nonce || 0, "nonce"),
97
+ formatNumber(transaction.maxPriorityFeePerGas || 0, "maxPriorityFeePerGas"),
98
+ formatNumber(transaction.maxFeePerGas || 0, "maxFeePerGas"),
99
+ formatNumber(transaction.gasLimit || 0, "gasLimit"),
100
+ ((transaction.to != null) ? getAddress(transaction.to) : "0x"),
101
+ formatNumber(transaction.value || 0, "value"),
102
+ (transaction.data || "0x"),
103
+ (formatAccessList(transaction.accessList || []))
104
+ ];
105
+ if (signature) {
106
+ const sig = splitSignature(signature);
107
+ fields.push(formatNumber(sig.recoveryParam, "recoveryParam"));
108
+ fields.push(stripZeros(sig.r));
109
+ fields.push(stripZeros(sig.s));
110
+ }
111
+ return hexConcat(["0x02", encode(fields)]);
112
+ }
113
+ function _serializeEip2930(transaction, signature) {
114
+ const fields = [
115
+ formatNumber(transaction.chainId || 0, "chainId"),
116
+ formatNumber(transaction.nonce || 0, "nonce"),
117
+ formatNumber(transaction.gasPrice || 0, "gasPrice"),
118
+ formatNumber(transaction.gasLimit || 0, "gasLimit"),
119
+ ((transaction.to != null) ? getAddress(transaction.to) : "0x"),
120
+ formatNumber(transaction.value || 0, "value"),
121
+ (transaction.data || "0x"),
122
+ (formatAccessList(transaction.accessList || []))
123
+ ];
124
+ if (signature) {
125
+ const sig = splitSignature(signature);
126
+ fields.push(formatNumber(sig.recoveryParam, "recoveryParam"));
127
+ fields.push(stripZeros(sig.r));
128
+ fields.push(stripZeros(sig.s));
129
+ }
130
+ return hexConcat(["0x01", encode(fields)]);
131
+ }
132
+ function _parseEipSignature(tx, fields, serialize) {
133
+ try {
134
+ const recid = handleNumber(fields[0]).toNumber();
135
+ if (recid !== 0 && recid !== 1) {
136
+ throw new Error("bad recid");
137
+ }
138
+ tx.v = recid;
139
+ }
140
+ catch (error) {
141
+ logger.throwArgumentError("invalid v for transaction type: 1", "v", fields[0]);
142
+ }
143
+ tx.r = hexZeroPad(fields[1], 32);
144
+ tx.s = hexZeroPad(fields[2], 32);
145
+ try {
146
+ const digest = keccak256(serialize(tx));
147
+ tx.from = recoverAddress(digest, { r: tx.r, s: tx.s, recoveryParam: tx.v });
148
+ }
149
+ catch (error) { }
150
+ }
151
+ function _parseEip1559(payload) {
152
+ const transaction = decode(payload.slice(1));
153
+ if (transaction.length !== 9 && transaction.length !== 12) {
154
+ logger.throwArgumentError("invalid component count for transaction type: 2", "payload", hexlify(payload));
155
+ }
156
+ const maxPriorityFeePerGas = handleNumber(transaction[2]);
157
+ const maxFeePerGas = handleNumber(transaction[3]);
158
+ const tx = {
159
+ type: 2,
160
+ chainId: handleNumber(transaction[0]).toNumber(),
161
+ nonce: handleNumber(transaction[1]).toNumber(),
162
+ maxPriorityFeePerGas: maxPriorityFeePerGas,
163
+ maxFeePerGas: maxFeePerGas,
164
+ gasPrice: null,
165
+ gasLimit: handleNumber(transaction[4]),
166
+ to: handleAddress(transaction[5]),
167
+ value: handleNumber(transaction[6]),
168
+ data: transaction[7],
169
+ accessList: accessListify(transaction[8]),
170
+ };
171
+ // Unsigned EIP-1559 Transaction
172
+ if (transaction.length === 9) {
173
+ return tx;
174
+ }
175
+ tx.hash = keccak256(payload);
176
+ _parseEipSignature(tx, transaction.slice(9), _serializeEip1559);
177
+ return tx;
178
+ }
179
+ function _parseEip2930(payload) {
180
+ const transaction = decode(payload.slice(1));
181
+ if (transaction.length !== 8 && transaction.length !== 11) {
182
+ logger.throwArgumentError("invalid component count for transaction type: 1", "payload", hexlify(payload));
183
+ }
184
+ const tx = {
185
+ type: 1,
186
+ chainId: handleNumber(transaction[0]).toNumber(),
187
+ nonce: handleNumber(transaction[1]).toNumber(),
188
+ gasPrice: handleNumber(transaction[2]),
189
+ gasLimit: handleNumber(transaction[3]),
190
+ to: handleAddress(transaction[4]),
191
+ value: handleNumber(transaction[5]),
192
+ data: transaction[6],
193
+ accessList: accessListify(transaction[7])
194
+ };
195
+ // Unsigned EIP-2930 Transaction
196
+ if (transaction.length === 8) {
197
+ return tx;
198
+ }
199
+ tx.hash = keccak256(payload);
200
+ _parseEipSignature(tx, transaction.slice(8), _serializeEip2930);
201
+ return tx;
202
+ }
203
+ // Legacy Transactions and EIP-155
204
+ function _parse(rawTransaction) {
205
+ const transaction = decode(rawTransaction);
206
+ if (transaction.length !== 9 && transaction.length !== 6) {
207
+ logger.throwArgumentError("invalid raw transaction", "rawTransaction", rawTransaction);
208
+ }
209
+ const tx = {
210
+ nonce: handleNumber(transaction[0]).toNumber(),
211
+ gasPrice: handleNumber(transaction[1]),
212
+ gasLimit: handleNumber(transaction[2]),
213
+ to: handleAddress(transaction[3]),
214
+ value: handleNumber(transaction[4]),
215
+ data: transaction[5],
216
+ chainId: 0
217
+ };
218
+ // Legacy unsigned transaction
219
+ if (transaction.length === 6) {
220
+ return tx;
221
+ }
222
+ try {
223
+ tx.v = BigNumber.from(transaction[6]).toNumber();
224
+ }
225
+ catch (error) {
226
+ // @TODO: What makes snese to do? The v is too big
227
+ return tx;
228
+ }
229
+ tx.r = hexZeroPad(transaction[7], 32);
230
+ tx.s = hexZeroPad(transaction[8], 32);
231
+ if (BigNumber.from(tx.r).isZero() && BigNumber.from(tx.s).isZero()) {
232
+ // EIP-155 unsigned transaction
233
+ tx.chainId = tx.v;
234
+ tx.v = 0;
235
+ }
236
+ else {
237
+ // Signed Transaction
238
+ tx.chainId = Math.floor((tx.v - 35) / 2);
239
+ if (tx.chainId < 0) {
240
+ tx.chainId = 0;
241
+ }
242
+ let recoveryParam = tx.v - 27;
243
+ const raw = transaction.slice(0, 6);
244
+ if (tx.chainId !== 0) {
245
+ raw.push(hexlify(tx.chainId));
246
+ raw.push("0x");
247
+ raw.push("0x");
248
+ recoveryParam -= tx.chainId * 2 + 8;
249
+ }
250
+ const digest = keccak256(encode(raw));
251
+ try {
252
+ tx.from = recoverAddress(digest, { r: hexlify(tx.r), s: hexlify(tx.s), recoveryParam: recoveryParam });
253
+ }
254
+ catch (error) { }
255
+ tx.hash = keccak256(rawTransaction);
256
+ }
257
+ tx.type = null;
258
+ return tx;
259
+ }
260
+ function parse(rawTransaction) {
261
+ const payload = arrayify(rawTransaction);
262
+ // Legacy and EIP-155 Transactions
263
+ if (payload[0] > 0x7f) {
264
+ return _parse(payload);
265
+ }
266
+ // Typed Transaction (EIP-2718)
267
+ switch (payload[0]) {
268
+ case 1:
269
+ return _parseEip2930(payload);
270
+ case 2:
271
+ return _parseEip1559(payload);
272
+ }
273
+ return logger.throwError(`unsupported transaction type: ${payload[0]}`, Logger.errors.UNSUPPORTED_OPERATION, {
274
+ operation: "parseTransaction",
275
+ transactionType: payload[0]
276
+ });
277
+ }
278
+
279
+ export { TransactionTypes, accessListify, computeAddress, parse, recoverAddress };
@@ -0,0 +1,3 @@
1
+ const version = "web/5.7.1";
2
+
3
+ export { version };
@@ -0,0 +1,69 @@
1
+ import { arrayify } from '../../bytes/lib.esm/index.js';
2
+
3
+ var __awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
4
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
5
+ return new (P || (P = Promise))(function (resolve, reject) {
6
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
7
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
8
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
9
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
10
+ });
11
+ };
12
+ function getUrl(href, options) {
13
+ return __awaiter(this, undefined, undefined, function* () {
14
+ if (options == null) {
15
+ options = {};
16
+ }
17
+ const request = {
18
+ method: (options.method || "GET"),
19
+ headers: (options.headers || {}),
20
+ body: (options.body || undefined),
21
+ };
22
+ if (options.skipFetchSetup !== true) {
23
+ request.mode = "cors"; // no-cors, cors, *same-origin
24
+ request.cache = "no-cache"; // *default, no-cache, reload, force-cache, only-if-cached
25
+ request.credentials = "same-origin"; // include, *same-origin, omit
26
+ request.redirect = "follow"; // manual, *follow, error
27
+ request.referrer = "client"; // no-referrer, *client
28
+ }
29
+ if (options.fetchOptions != null) {
30
+ const opts = options.fetchOptions;
31
+ if (opts.mode) {
32
+ request.mode = (opts.mode);
33
+ }
34
+ if (opts.cache) {
35
+ request.cache = (opts.cache);
36
+ }
37
+ if (opts.credentials) {
38
+ request.credentials = (opts.credentials);
39
+ }
40
+ if (opts.redirect) {
41
+ request.redirect = (opts.redirect);
42
+ }
43
+ if (opts.referrer) {
44
+ request.referrer = opts.referrer;
45
+ }
46
+ }
47
+ const response = yield fetch(href, request);
48
+ const body = yield response.arrayBuffer();
49
+ const headers = {};
50
+ if (response.headers.forEach) {
51
+ response.headers.forEach((value, key) => {
52
+ headers[key.toLowerCase()] = value;
53
+ });
54
+ }
55
+ else {
56
+ ((response.headers).keys)().forEach((key) => {
57
+ headers[key.toLowerCase()] = response.headers.get(key);
58
+ });
59
+ }
60
+ return {
61
+ headers: headers,
62
+ statusCode: response.status,
63
+ statusMessage: response.statusText,
64
+ body: arrayify(new Uint8Array(body)),
65
+ };
66
+ });
67
+ }
68
+
69
+ export { getUrl };