@waku/rln 0.0.1 → 0.0.2-ce9a6ae.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 (405) hide show
  1. package/README.md +12 -108
  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 -10
  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/@iden3/js-crypto/dist/browser/esm/index.js +7 -0
  111. package/bundle/node_modules/@multiformats/multiaddr/dist/src/convert.js +15 -0
  112. package/bundle/node_modules/@multiformats/multiaddr/dist/src/multiaddr.js +20 -0
  113. package/bundle/node_modules/@multiformats/multiaddr/dist/src/protocols-table.js +92 -0
  114. package/bundle/node_modules/@noble/hashes/esm/_assert.js +37 -0
  115. package/bundle/node_modules/@noble/hashes/esm/_md.js +132 -0
  116. package/bundle/node_modules/@noble/hashes/esm/_u64.js +29 -0
  117. package/bundle/node_modules/@noble/hashes/esm/sha256.js +113 -0
  118. package/bundle/node_modules/@noble/hashes/esm/sha3.js +210 -0
  119. package/bundle/node_modules/@noble/hashes/esm/utils.js +144 -0
  120. package/bundle/node_modules/@stablelib/binary/lib/binary.js +22 -0
  121. package/bundle/node_modules/@stablelib/chacha/lib/chacha.js +245 -0
  122. package/bundle/node_modules/@stablelib/wipe/lib/wipe.js +26 -0
  123. package/bundle/node_modules/@waku/zerokit-rln-wasm/rln_wasm.js +756 -0
  124. package/bundle/node_modules/bech32/index.js +187 -0
  125. package/bundle/node_modules/bn.js/lib/bn.js +3361 -0
  126. package/bundle/node_modules/debug/src/browser.js +283 -0
  127. package/bundle/node_modules/debug/src/common.js +295 -0
  128. package/bundle/node_modules/ethereum-cryptography/esm/keccak.js +10 -0
  129. package/bundle/node_modules/ethereum-cryptography/esm/sha256.js +6 -0
  130. package/bundle/node_modules/ethereum-cryptography/esm/utils.js +24 -0
  131. package/bundle/node_modules/hash.js/lib/hash/common.js +97 -0
  132. package/bundle/node_modules/hash.js/lib/hash/hmac.js +51 -0
  133. package/bundle/node_modules/hash.js/lib/hash/ripemd.js +152 -0
  134. package/bundle/node_modules/hash.js/lib/hash/sha/1.js +81 -0
  135. package/bundle/node_modules/hash.js/lib/hash/sha/224.js +33 -0
  136. package/bundle/node_modules/hash.js/lib/hash/sha/256.js +113 -0
  137. package/bundle/node_modules/hash.js/lib/hash/sha/384.js +39 -0
  138. package/bundle/node_modules/hash.js/lib/hash/sha/512.js +336 -0
  139. package/bundle/node_modules/hash.js/lib/hash/sha/common.js +53 -0
  140. package/bundle/node_modules/hash.js/lib/hash/sha.js +14 -0
  141. package/bundle/node_modules/hash.js/lib/hash/utils.js +282 -0
  142. package/bundle/node_modules/hash.js/lib/hash.js +33 -0
  143. package/bundle/node_modules/inherits/inherits_browser.js +33 -0
  144. package/bundle/node_modules/it-length-prefixed/dist/src/decode.js +6 -0
  145. package/bundle/node_modules/lodash/lodash.js +17207 -0
  146. package/bundle/node_modules/minimalistic-assert/index.js +13 -0
  147. package/bundle/node_modules/ms/index.js +172 -0
  148. package/bundle/node_modules/multiformats/dist/src/bases/base.js +205 -0
  149. package/bundle/node_modules/multiformats/dist/src/bases/base10.js +9 -0
  150. package/bundle/node_modules/multiformats/dist/src/bases/base16.js +16 -0
  151. package/bundle/node_modules/multiformats/dist/src/bases/base2.js +10 -0
  152. package/bundle/node_modules/multiformats/dist/src/bases/base256emoji.js +41 -0
  153. package/bundle/node_modules/multiformats/dist/src/bases/base32.js +58 -0
  154. package/bundle/node_modules/multiformats/dist/src/bases/base36.js +14 -0
  155. package/bundle/node_modules/multiformats/dist/src/bases/base58.js +14 -0
  156. package/bundle/node_modules/multiformats/dist/src/bases/base64.js +28 -0
  157. package/bundle/node_modules/multiformats/dist/src/bases/base8.js +10 -0
  158. package/bundle/node_modules/multiformats/dist/src/bases/identity.js +11 -0
  159. package/bundle/node_modules/multiformats/dist/src/basics.js +15 -0
  160. package/bundle/node_modules/multiformats/dist/src/bytes.js +18 -0
  161. package/bundle/node_modules/multiformats/dist/src/codecs/json.js +2 -0
  162. package/bundle/node_modules/multiformats/dist/src/vendor/base-x.js +170 -0
  163. package/bundle/node_modules/protons-runtime/dist/src/codec.js +20 -0
  164. package/bundle/node_modules/protons-runtime/dist/src/codecs/enum.js +24 -0
  165. package/bundle/node_modules/protons-runtime/dist/src/codecs/message.js +7 -0
  166. package/bundle/node_modules/protons-runtime/dist/src/decode.js +8 -0
  167. package/bundle/node_modules/protons-runtime/dist/src/encode.js +11 -0
  168. package/bundle/node_modules/protons-runtime/dist/src/index.js +30 -0
  169. package/bundle/node_modules/protons-runtime/dist/src/utils/float.js +54 -0
  170. package/bundle/node_modules/protons-runtime/dist/src/utils/longbits.js +175 -0
  171. package/bundle/node_modules/protons-runtime/dist/src/utils/pool.js +28 -0
  172. package/bundle/node_modules/protons-runtime/dist/src/utils/reader.js +367 -0
  173. package/bundle/node_modules/protons-runtime/dist/src/utils/utf8.js +99 -0
  174. package/bundle/node_modules/protons-runtime/dist/src/utils/writer.js +438 -0
  175. package/bundle/node_modules/uint8-varint/dist/src/index.js +124 -0
  176. package/bundle/node_modules/uint8arrays/dist/src/alloc.js +17 -0
  177. package/bundle/node_modules/uint8arrays/dist/src/from-string.js +19 -0
  178. package/bundle/node_modules/uint8arrays/dist/src/util/bases.js +49 -0
  179. package/bundle/packages/core/dist/lib/connection_manager/connection_manager.js +21 -0
  180. package/bundle/packages/core/dist/lib/connection_manager/keep_alive_manager.js +18 -0
  181. package/bundle/packages/core/dist/lib/filter/filter.js +27 -0
  182. package/bundle/packages/core/dist/lib/light_push/light_push.js +27 -0
  183. package/bundle/packages/core/dist/lib/message/version_0.js +154 -0
  184. package/bundle/packages/core/dist/lib/metadata/metadata.js +27 -0
  185. package/bundle/packages/core/dist/lib/store/store.js +27 -0
  186. package/bundle/packages/interfaces/dist/connection_manager.js +19 -0
  187. package/bundle/packages/interfaces/dist/constants.js +6 -0
  188. package/bundle/packages/interfaces/dist/health_indicator.js +12 -0
  189. package/bundle/packages/interfaces/dist/protocols.js +97 -0
  190. package/bundle/packages/proto/dist/generated/filter.js +445 -0
  191. package/bundle/packages/proto/dist/generated/filter_v2.js +424 -0
  192. package/bundle/packages/proto/dist/generated/light_push.js +389 -0
  193. package/bundle/packages/proto/dist/generated/message.js +213 -0
  194. package/bundle/packages/proto/dist/generated/metadata.js +130 -0
  195. package/bundle/packages/proto/dist/generated/peer_exchange.js +209 -0
  196. package/bundle/packages/proto/dist/generated/sds_message.js +105 -0
  197. package/bundle/packages/proto/dist/generated/store_v3.js +490 -0
  198. package/bundle/packages/proto/dist/generated/topic_only_message.js +61 -0
  199. package/bundle/packages/rln/dist/codec.js +93 -0
  200. package/bundle/packages/rln/dist/contract/abi/rlnv2.js +394 -0
  201. package/bundle/packages/rln/dist/contract/constants.js +33 -0
  202. package/bundle/packages/rln/dist/contract/rln_contract.js +427 -0
  203. package/bundle/packages/rln/dist/create.js +9 -0
  204. package/bundle/packages/rln/dist/identity.js +76 -0
  205. package/bundle/packages/rln/dist/keystore/cipher.js +31 -0
  206. package/bundle/packages/rln/dist/keystore/credential_validation_generated.js +119 -0
  207. package/bundle/packages/rln/dist/keystore/keystore.js +223 -0
  208. package/bundle/packages/rln/dist/keystore/keystore_validation_generated.js +74 -0
  209. package/bundle/packages/rln/dist/keystore/schema_validator.js +20 -0
  210. package/bundle/packages/rln/dist/message.js +51 -0
  211. package/bundle/packages/rln/dist/proof.js +54 -0
  212. package/bundle/packages/rln/dist/resources/verification_key.js +112 -0
  213. package/bundle/packages/rln/dist/resources/witness_calculator.js +330 -0
  214. package/bundle/packages/rln/dist/rln.js +204 -0
  215. package/bundle/packages/rln/dist/root_tracker.js +76 -0
  216. package/bundle/packages/rln/dist/utils/bytes.js +65 -0
  217. package/bundle/packages/rln/dist/utils/epoch.js +39 -0
  218. package/bundle/packages/rln/dist/utils/hash.js +10 -0
  219. package/bundle/packages/rln/dist/utils/metamask.js +14 -0
  220. package/bundle/packages/rln/dist/zerokit.js +122 -0
  221. package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/lib/checksum.js +52 -0
  222. package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/lib/cipher.js +65 -0
  223. package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/lib/class.js +99 -0
  224. package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/lib/functional.js +103 -0
  225. package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/lib/index.js +28 -0
  226. package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/lib/kdf.js +78 -0
  227. package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/lib/password.js +17 -0
  228. package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/lib/schema-validation-generated.js +1253 -0
  229. package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/lib/schema-validation.js +40 -0
  230. package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/lib/types.js +5 -0
  231. package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/node_modules/ethereum-cryptography/aes.js +103 -0
  232. package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/node_modules/ethereum-cryptography/pbkdf2.js +41 -0
  233. package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/node_modules/ethereum-cryptography/random.js +17 -0
  234. package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/node_modules/ethereum-cryptography/scrypt.js +23 -0
  235. package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/node_modules/ethereum-cryptography/sha256.js +12 -0
  236. package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/node_modules/ethereum-cryptography/utils.js +77 -0
  237. package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/node_modules/uuid/dist/esm-browser/index.js +9 -0
  238. package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/node_modules/uuid/dist/esm-browser/md5.js +215 -0
  239. package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/node_modules/uuid/dist/esm-browser/nil.js +3 -0
  240. package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/node_modules/uuid/dist/esm-browser/parse.js +35 -0
  241. package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/node_modules/uuid/dist/esm-browser/regex.js +3 -0
  242. package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/node_modules/uuid/dist/esm-browser/rng.js +21 -0
  243. package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/node_modules/uuid/dist/esm-browser/sha1.js +96 -0
  244. package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/node_modules/uuid/dist/esm-browser/stringify.js +31 -0
  245. package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/node_modules/uuid/dist/esm-browser/v1.js +96 -0
  246. package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/node_modules/uuid/dist/esm-browser/v3.js +6 -0
  247. package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/node_modules/uuid/dist/esm-browser/v35.js +66 -0
  248. package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/node_modules/uuid/dist/esm-browser/v4.js +24 -0
  249. package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/node_modules/uuid/dist/esm-browser/v5.js +6 -0
  250. package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/node_modules/uuid/dist/esm-browser/validate.js +7 -0
  251. package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/node_modules/uuid/dist/esm-browser/version.js +11 -0
  252. package/bundle/packages/rln/node_modules/@noble/hashes/_assert.js +52 -0
  253. package/bundle/packages/rln/node_modules/@noble/hashes/_sha2.js +124 -0
  254. package/bundle/packages/rln/node_modules/@noble/hashes/_u64.js +71 -0
  255. package/bundle/packages/rln/node_modules/@noble/hashes/cryptoBrowser.js +10 -0
  256. package/bundle/packages/rln/node_modules/@noble/hashes/hmac.js +88 -0
  257. package/bundle/packages/rln/node_modules/@noble/hashes/pbkdf2.js +99 -0
  258. package/bundle/packages/rln/node_modules/@noble/hashes/scrypt.js +233 -0
  259. package/bundle/packages/rln/node_modules/@noble/hashes/sha256.js +133 -0
  260. package/bundle/packages/rln/node_modules/@noble/hashes/sha512.js +243 -0
  261. package/bundle/packages/rln/node_modules/@noble/hashes/utils.js +167 -0
  262. package/bundle/packages/rln/node_modules/uuid/dist/esm-browser/native.js +4 -0
  263. package/bundle/packages/rln/node_modules/uuid/dist/esm-browser/rng.js +13 -0
  264. package/bundle/packages/rln/node_modules/uuid/dist/esm-browser/stringify.js +28 -0
  265. package/bundle/packages/rln/node_modules/uuid/dist/esm-browser/v4.js +19 -0
  266. package/bundle/packages/utils/dist/bytes/index.js +44 -0
  267. package/bundle/packages/utils/dist/common/sharding/index.js +91 -0
  268. package/bundle/packages/utils/dist/logger/index.js +31 -0
  269. package/bundle/resources/rln.wasm +0 -0
  270. package/bundle/resources/rln_final.zkey +0 -0
  271. package/bundle/resources/verification_key.d.ts +13 -0
  272. package/bundle/resources/verification_key.js +112 -0
  273. package/bundle/resources/witness_calculator.d.ts +11 -0
  274. package/bundle/resources/witness_calculator.js +328 -0
  275. package/dist/.tsbuildinfo +1 -1
  276. package/dist/__tests__/identity.test.d.ts +1 -0
  277. package/dist/__tests__/identity.test.js +40 -0
  278. package/dist/__tests__/identity.test.js.map +1 -0
  279. package/dist/codec.d.ts +39 -0
  280. package/dist/codec.js +77 -0
  281. package/dist/codec.js.map +1 -0
  282. package/dist/contract/abi/rlnv2.d.ts +42 -0
  283. package/dist/contract/abi/rlnv2.js +393 -0
  284. package/dist/contract/abi/rlnv2.js.map +1 -0
  285. package/dist/contract/constants.d.ts +68 -0
  286. package/dist/contract/constants.js +31 -0
  287. package/dist/contract/constants.js.map +1 -0
  288. package/dist/contract/index.d.ts +2 -0
  289. package/dist/contract/index.js +3 -0
  290. package/dist/contract/index.js.map +1 -0
  291. package/dist/contract/rln_contract.d.ts +119 -0
  292. package/dist/contract/rln_contract.js +421 -0
  293. package/dist/contract/rln_contract.js.map +1 -0
  294. package/dist/create.d.ts +2 -0
  295. package/dist/create.js +8 -0
  296. package/dist/create.js.map +1 -0
  297. package/dist/identity.d.ts +16 -0
  298. package/dist/identity.js +73 -0
  299. package/dist/identity.js.map +1 -0
  300. package/dist/index.d.ts +11 -2
  301. package/dist/index.js +11 -8
  302. package/dist/index.js.map +1 -1
  303. package/dist/keystore/cipher.d.ts +4 -0
  304. package/dist/keystore/cipher.js +28 -0
  305. package/dist/keystore/cipher.js.map +1 -0
  306. package/dist/keystore/credential_validation_generated.d.ts +8 -0
  307. package/dist/keystore/credential_validation_generated.js +121 -0
  308. package/dist/keystore/credential_validation_generated.js.map +1 -0
  309. package/dist/keystore/index.d.ts +4 -0
  310. package/dist/keystore/index.js +3 -0
  311. package/dist/keystore/index.js.map +1 -0
  312. package/dist/keystore/keystore.d.ts +50 -0
  313. package/dist/keystore/keystore.js +205 -0
  314. package/dist/keystore/keystore.js.map +1 -0
  315. package/dist/keystore/keystore_validation_generated.d.ts +8 -0
  316. package/dist/keystore/keystore_validation_generated.js +75 -0
  317. package/dist/keystore/keystore_validation_generated.js.map +1 -0
  318. package/dist/keystore/schema_validator.d.ts +2 -0
  319. package/dist/keystore/schema_validator.js +18 -0
  320. package/dist/keystore/schema_validator.js.map +1 -0
  321. package/dist/keystore/types.d.ts +29 -0
  322. package/dist/keystore/types.js +2 -0
  323. package/dist/keystore/types.js.map +1 -0
  324. package/dist/message.d.ts +18 -0
  325. package/dist/message.js +49 -0
  326. package/dist/message.js.map +1 -0
  327. package/dist/proof.d.ts +21 -0
  328. package/dist/proof.js +50 -0
  329. package/dist/proof.js.map +1 -0
  330. package/dist/resources/rln.wasm +0 -0
  331. package/dist/resources/rln_final.zkey +0 -0
  332. package/dist/resources/verification_key.d.ts +13 -0
  333. package/dist/resources/verification_key.js +112 -0
  334. package/dist/resources/witness_calculator.d.ts +11 -0
  335. package/dist/resources/witness_calculator.js +328 -0
  336. package/dist/rln.d.ts +59 -13
  337. package/dist/rln.js +164 -81
  338. package/dist/rln.js.map +1 -1
  339. package/dist/root_tracker.d.ts +10 -0
  340. package/dist/root_tracker.js +75 -0
  341. package/dist/root_tracker.js.map +1 -0
  342. package/dist/utils/bytes.d.ts +20 -0
  343. package/dist/utils/bytes.js +64 -0
  344. package/dist/utils/bytes.js.map +1 -0
  345. package/dist/utils/epoch.d.ts +3 -0
  346. package/dist/utils/epoch.js +23 -0
  347. package/dist/utils/epoch.js.map +1 -0
  348. package/dist/utils/hash.d.ts +2 -0
  349. package/dist/utils/hash.js +13 -0
  350. package/dist/utils/hash.js.map +1 -0
  351. package/dist/utils/index.d.ts +4 -0
  352. package/dist/utils/index.js +5 -0
  353. package/dist/utils/index.js.map +1 -0
  354. package/dist/utils/metamask.d.ts +2 -0
  355. package/dist/utils/metamask.js +12 -0
  356. package/dist/utils/metamask.js.map +1 -0
  357. package/dist/zerokit.d.ts +19 -0
  358. package/dist/zerokit.js +119 -0
  359. package/dist/zerokit.js.map +1 -0
  360. package/package.json +1 -126
  361. package/src/__tests__/identity.test.ts +50 -0
  362. package/src/codec.ts +134 -0
  363. package/src/contract/abi/rlnv2.ts +392 -0
  364. package/src/contract/constants.ts +35 -0
  365. package/src/contract/index.ts +2 -0
  366. package/src/contract/rln_contract.ts +673 -0
  367. package/src/create.ts +9 -0
  368. package/src/identity.ts +101 -0
  369. package/src/index.ts +24 -10
  370. package/src/keystore/cipher.ts +54 -0
  371. package/src/keystore/credential_validation_generated.ts +7 -0
  372. package/src/keystore/index.ts +5 -0
  373. package/src/keystore/keystore.ts +330 -0
  374. package/src/keystore/keystore_validation_generated.ts +7 -0
  375. package/src/keystore/schema_validator.ts +34 -0
  376. package/src/keystore/types.ts +36 -0
  377. package/src/message.ts +70 -0
  378. package/src/proof.ts +69 -0
  379. package/src/resources/verification_key.d.ts +13 -0
  380. package/src/resources/witness_calculator.d.ts +11 -0
  381. package/src/rln.ts +270 -106
  382. package/src/root_tracker.ts +92 -0
  383. package/src/utils/bytes.ts +84 -0
  384. package/src/utils/epoch.ts +30 -0
  385. package/src/utils/hash.ts +15 -0
  386. package/src/utils/index.ts +9 -0
  387. package/src/utils/metamask.ts +17 -0
  388. package/src/zerokit.ts +214 -0
  389. package/bundle/02bce7e5f3bcf834.wasm +0 -0
  390. package/bundle/rln-f87f6dbe.js +0 -563
  391. package/dist/resources.d.ts +0 -4
  392. package/dist/resources.js +0 -5
  393. package/dist/resources.js.map +0 -1
  394. package/dist/witness_calculator.d.ts +0 -16
  395. package/dist/witness_calculator.js +0 -291
  396. package/dist/witness_calculator.js.map +0 -1
  397. package/dist/zerokit/rln_wasm.d.ts +0 -1
  398. package/dist/zerokit/rln_wasm.js +0 -2
  399. package/dist/zerokit/rln_wasm.js.map +0 -1
  400. package/dist/zerokit/rln_wasm_bg.d.ts +0 -108
  401. package/dist/zerokit/rln_wasm_bg.js +0 -592
  402. package/dist/zerokit/rln_wasm_bg.js.map +0 -1
  403. package/dist/zerokit/rln_wasm_bg.wasm +0 -0
  404. package/src/resources.ts +0 -10
  405. package/src/witness_calculator.d.ts +0 -4
@@ -0,0 +1,352 @@
1
+ import { version } from './_version.js';
2
+
3
+ let _permanentCensorErrors = false;
4
+ let _censorErrors = false;
5
+ const LogLevels = { debug: 1, "default": 2, info: 2, warning: 3, error: 4, off: 5 };
6
+ let _logLevel = LogLevels["default"];
7
+ let _globalLogger = null;
8
+ function _checkNormalize() {
9
+ try {
10
+ const missing = [];
11
+ // Make sure all forms of normalization are supported
12
+ ["NFD", "NFC", "NFKD", "NFKC"].forEach((form) => {
13
+ try {
14
+ if ("test".normalize(form) !== "test") {
15
+ throw new Error("bad normalize");
16
+ }
17
+ ;
18
+ }
19
+ catch (error) {
20
+ missing.push(form);
21
+ }
22
+ });
23
+ if (missing.length) {
24
+ throw new Error("missing " + missing.join(", "));
25
+ }
26
+ if (String.fromCharCode(0xe9).normalize("NFD") !== String.fromCharCode(0x65, 0x0301)) {
27
+ throw new Error("broken implementation");
28
+ }
29
+ }
30
+ catch (error) {
31
+ return error.message;
32
+ }
33
+ return null;
34
+ }
35
+ const _normalizeError = _checkNormalize();
36
+ var LogLevel;
37
+ (function (LogLevel) {
38
+ LogLevel["DEBUG"] = "DEBUG";
39
+ LogLevel["INFO"] = "INFO";
40
+ LogLevel["WARNING"] = "WARNING";
41
+ LogLevel["ERROR"] = "ERROR";
42
+ LogLevel["OFF"] = "OFF";
43
+ })(LogLevel || (LogLevel = {}));
44
+ var ErrorCode;
45
+ (function (ErrorCode) {
46
+ ///////////////////
47
+ // Generic Errors
48
+ // Unknown Error
49
+ ErrorCode["UNKNOWN_ERROR"] = "UNKNOWN_ERROR";
50
+ // Not Implemented
51
+ ErrorCode["NOT_IMPLEMENTED"] = "NOT_IMPLEMENTED";
52
+ // Unsupported Operation
53
+ // - operation
54
+ ErrorCode["UNSUPPORTED_OPERATION"] = "UNSUPPORTED_OPERATION";
55
+ // Network Error (i.e. Ethereum Network, such as an invalid chain ID)
56
+ // - event ("noNetwork" is not re-thrown in provider.ready; otherwise thrown)
57
+ ErrorCode["NETWORK_ERROR"] = "NETWORK_ERROR";
58
+ // Some sort of bad response from the server
59
+ ErrorCode["SERVER_ERROR"] = "SERVER_ERROR";
60
+ // Timeout
61
+ ErrorCode["TIMEOUT"] = "TIMEOUT";
62
+ ///////////////////
63
+ // Operational Errors
64
+ // Buffer Overrun
65
+ ErrorCode["BUFFER_OVERRUN"] = "BUFFER_OVERRUN";
66
+ // Numeric Fault
67
+ // - operation: the operation being executed
68
+ // - fault: the reason this faulted
69
+ ErrorCode["NUMERIC_FAULT"] = "NUMERIC_FAULT";
70
+ ///////////////////
71
+ // Argument Errors
72
+ // Missing new operator to an object
73
+ // - name: The name of the class
74
+ ErrorCode["MISSING_NEW"] = "MISSING_NEW";
75
+ // Invalid argument (e.g. value is incompatible with type) to a function:
76
+ // - argument: The argument name that was invalid
77
+ // - value: The value of the argument
78
+ ErrorCode["INVALID_ARGUMENT"] = "INVALID_ARGUMENT";
79
+ // Missing argument to a function:
80
+ // - count: The number of arguments received
81
+ // - expectedCount: The number of arguments expected
82
+ ErrorCode["MISSING_ARGUMENT"] = "MISSING_ARGUMENT";
83
+ // Too many arguments
84
+ // - count: The number of arguments received
85
+ // - expectedCount: The number of arguments expected
86
+ ErrorCode["UNEXPECTED_ARGUMENT"] = "UNEXPECTED_ARGUMENT";
87
+ ///////////////////
88
+ // Blockchain Errors
89
+ // Call exception
90
+ // - transaction: the transaction
91
+ // - address?: the contract address
92
+ // - args?: The arguments passed into the function
93
+ // - method?: The Solidity method signature
94
+ // - errorSignature?: The EIP848 error signature
95
+ // - errorArgs?: The EIP848 error parameters
96
+ // - reason: The reason (only for EIP848 "Error(string)")
97
+ ErrorCode["CALL_EXCEPTION"] = "CALL_EXCEPTION";
98
+ // Insufficient funds (< value + gasLimit * gasPrice)
99
+ // - transaction: the transaction attempted
100
+ ErrorCode["INSUFFICIENT_FUNDS"] = "INSUFFICIENT_FUNDS";
101
+ // Nonce has already been used
102
+ // - transaction: the transaction attempted
103
+ ErrorCode["NONCE_EXPIRED"] = "NONCE_EXPIRED";
104
+ // The replacement fee for the transaction is too low
105
+ // - transaction: the transaction attempted
106
+ ErrorCode["REPLACEMENT_UNDERPRICED"] = "REPLACEMENT_UNDERPRICED";
107
+ // The gas limit could not be estimated
108
+ // - transaction: the transaction passed to estimateGas
109
+ ErrorCode["UNPREDICTABLE_GAS_LIMIT"] = "UNPREDICTABLE_GAS_LIMIT";
110
+ // The transaction was replaced by one with a higher gas price
111
+ // - reason: "cancelled", "replaced" or "repriced"
112
+ // - cancelled: true if reason == "cancelled" or reason == "replaced")
113
+ // - hash: original transaction hash
114
+ // - replacement: the full TransactionsResponse for the replacement
115
+ // - receipt: the receipt of the replacement
116
+ ErrorCode["TRANSACTION_REPLACED"] = "TRANSACTION_REPLACED";
117
+ ///////////////////
118
+ // Interaction Errors
119
+ // The user rejected the action, such as signing a message or sending
120
+ // a transaction
121
+ ErrorCode["ACTION_REJECTED"] = "ACTION_REJECTED";
122
+ })(ErrorCode || (ErrorCode = {}));
123
+ const HEX = "0123456789abcdef";
124
+ class Logger {
125
+ constructor(version) {
126
+ Object.defineProperty(this, "version", {
127
+ enumerable: true,
128
+ value: version,
129
+ writable: false
130
+ });
131
+ }
132
+ _log(logLevel, args) {
133
+ const level = logLevel.toLowerCase();
134
+ if (LogLevels[level] == null) {
135
+ this.throwArgumentError("invalid log level name", "logLevel", logLevel);
136
+ }
137
+ if (_logLevel > LogLevels[level]) {
138
+ return;
139
+ }
140
+ console.log.apply(console, args);
141
+ }
142
+ debug(...args) {
143
+ this._log(Logger.levels.DEBUG, args);
144
+ }
145
+ info(...args) {
146
+ this._log(Logger.levels.INFO, args);
147
+ }
148
+ warn(...args) {
149
+ this._log(Logger.levels.WARNING, args);
150
+ }
151
+ makeError(message, code, params) {
152
+ // Errors are being censored
153
+ if (_censorErrors) {
154
+ return this.makeError("censored error", code, {});
155
+ }
156
+ if (!code) {
157
+ code = Logger.errors.UNKNOWN_ERROR;
158
+ }
159
+ if (!params) {
160
+ params = {};
161
+ }
162
+ const messageDetails = [];
163
+ Object.keys(params).forEach((key) => {
164
+ const value = params[key];
165
+ try {
166
+ if (value instanceof Uint8Array) {
167
+ let hex = "";
168
+ for (let i = 0; i < value.length; i++) {
169
+ hex += HEX[value[i] >> 4];
170
+ hex += HEX[value[i] & 0x0f];
171
+ }
172
+ messageDetails.push(key + "=Uint8Array(0x" + hex + ")");
173
+ }
174
+ else {
175
+ messageDetails.push(key + "=" + JSON.stringify(value));
176
+ }
177
+ }
178
+ catch (error) {
179
+ messageDetails.push(key + "=" + JSON.stringify(params[key].toString()));
180
+ }
181
+ });
182
+ messageDetails.push(`code=${code}`);
183
+ messageDetails.push(`version=${this.version}`);
184
+ const reason = message;
185
+ let url = "";
186
+ switch (code) {
187
+ case ErrorCode.NUMERIC_FAULT: {
188
+ url = "NUMERIC_FAULT";
189
+ const fault = message;
190
+ switch (fault) {
191
+ case "overflow":
192
+ case "underflow":
193
+ case "division-by-zero":
194
+ url += "-" + fault;
195
+ break;
196
+ case "negative-power":
197
+ case "negative-width":
198
+ url += "-unsupported";
199
+ break;
200
+ case "unbound-bitwise-result":
201
+ url += "-unbound-result";
202
+ break;
203
+ }
204
+ break;
205
+ }
206
+ case ErrorCode.CALL_EXCEPTION:
207
+ case ErrorCode.INSUFFICIENT_FUNDS:
208
+ case ErrorCode.MISSING_NEW:
209
+ case ErrorCode.NONCE_EXPIRED:
210
+ case ErrorCode.REPLACEMENT_UNDERPRICED:
211
+ case ErrorCode.TRANSACTION_REPLACED:
212
+ case ErrorCode.UNPREDICTABLE_GAS_LIMIT:
213
+ url = code;
214
+ break;
215
+ }
216
+ if (url) {
217
+ message += " [ See: https:/\/links.ethers.org/v5-errors-" + url + " ]";
218
+ }
219
+ if (messageDetails.length) {
220
+ message += " (" + messageDetails.join(", ") + ")";
221
+ }
222
+ // @TODO: Any??
223
+ const error = new Error(message);
224
+ error.reason = reason;
225
+ error.code = code;
226
+ Object.keys(params).forEach(function (key) {
227
+ error[key] = params[key];
228
+ });
229
+ return error;
230
+ }
231
+ throwError(message, code, params) {
232
+ throw this.makeError(message, code, params);
233
+ }
234
+ throwArgumentError(message, name, value) {
235
+ return this.throwError(message, Logger.errors.INVALID_ARGUMENT, {
236
+ argument: name,
237
+ value: value
238
+ });
239
+ }
240
+ assert(condition, message, code, params) {
241
+ if (!!condition) {
242
+ return;
243
+ }
244
+ this.throwError(message, code, params);
245
+ }
246
+ assertArgument(condition, message, name, value) {
247
+ if (!!condition) {
248
+ return;
249
+ }
250
+ this.throwArgumentError(message, name, value);
251
+ }
252
+ checkNormalize(message) {
253
+ if (_normalizeError) {
254
+ this.throwError("platform missing String.prototype.normalize", Logger.errors.UNSUPPORTED_OPERATION, {
255
+ operation: "String.prototype.normalize", form: _normalizeError
256
+ });
257
+ }
258
+ }
259
+ checkSafeUint53(value, message) {
260
+ if (typeof (value) !== "number") {
261
+ return;
262
+ }
263
+ if (message == null) {
264
+ message = "value not safe";
265
+ }
266
+ if (value < 0 || value >= 0x1fffffffffffff) {
267
+ this.throwError(message, Logger.errors.NUMERIC_FAULT, {
268
+ operation: "checkSafeInteger",
269
+ fault: "out-of-safe-range",
270
+ value: value
271
+ });
272
+ }
273
+ if (value % 1) {
274
+ this.throwError(message, Logger.errors.NUMERIC_FAULT, {
275
+ operation: "checkSafeInteger",
276
+ fault: "non-integer",
277
+ value: value
278
+ });
279
+ }
280
+ }
281
+ checkArgumentCount(count, expectedCount, message) {
282
+ if (message) {
283
+ message = ": " + message;
284
+ }
285
+ else {
286
+ message = "";
287
+ }
288
+ if (count < expectedCount) {
289
+ this.throwError("missing argument" + message, Logger.errors.MISSING_ARGUMENT, {
290
+ count: count,
291
+ expectedCount: expectedCount
292
+ });
293
+ }
294
+ if (count > expectedCount) {
295
+ this.throwError("too many arguments" + message, Logger.errors.UNEXPECTED_ARGUMENT, {
296
+ count: count,
297
+ expectedCount: expectedCount
298
+ });
299
+ }
300
+ }
301
+ checkNew(target, kind) {
302
+ if (target === Object || target == null) {
303
+ this.throwError("missing new", Logger.errors.MISSING_NEW, { name: kind.name });
304
+ }
305
+ }
306
+ checkAbstract(target, kind) {
307
+ if (target === kind) {
308
+ this.throwError("cannot instantiate abstract class " + JSON.stringify(kind.name) + " directly; use a sub-class", Logger.errors.UNSUPPORTED_OPERATION, { name: target.name, operation: "new" });
309
+ }
310
+ else if (target === Object || target == null) {
311
+ this.throwError("missing new", Logger.errors.MISSING_NEW, { name: kind.name });
312
+ }
313
+ }
314
+ static globalLogger() {
315
+ if (!_globalLogger) {
316
+ _globalLogger = new Logger(version);
317
+ }
318
+ return _globalLogger;
319
+ }
320
+ static setCensorship(censorship, permanent) {
321
+ if (!censorship && permanent) {
322
+ this.globalLogger().throwError("cannot permanently disable censorship", Logger.errors.UNSUPPORTED_OPERATION, {
323
+ operation: "setCensorship"
324
+ });
325
+ }
326
+ if (_permanentCensorErrors) {
327
+ if (!censorship) {
328
+ return;
329
+ }
330
+ this.globalLogger().throwError("error censorship permanent", Logger.errors.UNSUPPORTED_OPERATION, {
331
+ operation: "setCensorship"
332
+ });
333
+ }
334
+ _censorErrors = !!censorship;
335
+ _permanentCensorErrors = !!permanent;
336
+ }
337
+ static setLogLevel(logLevel) {
338
+ const level = LogLevels[logLevel.toLowerCase()];
339
+ if (level == null) {
340
+ Logger.globalLogger().warn("invalid log level - " + logLevel);
341
+ return;
342
+ }
343
+ _logLevel = level;
344
+ }
345
+ static from(version) {
346
+ return new Logger(version);
347
+ }
348
+ }
349
+ Logger.errors = ErrorCode;
350
+ Logger.levels = LogLevel;
351
+
352
+ export { ErrorCode, LogLevel, Logger };
@@ -0,0 +1,3 @@
1
+ const version = "networks/5.7.1";
2
+
3
+ export { version };
@@ -0,0 +1,248 @@
1
+ import { Logger } from '../../logger/lib.esm/index.js';
2
+ import { version } from './_version.js';
3
+
4
+ const logger = new Logger(version);
5
+ function isRenetworkable(value) {
6
+ return (value && typeof (value.renetwork) === "function");
7
+ }
8
+ function ethDefaultProvider(network) {
9
+ const func = function (providers, options) {
10
+ if (options == null) {
11
+ options = {};
12
+ }
13
+ const providerList = [];
14
+ if (providers.InfuraProvider && options.infura !== "-") {
15
+ try {
16
+ providerList.push(new providers.InfuraProvider(network, options.infura));
17
+ }
18
+ catch (error) { }
19
+ }
20
+ if (providers.EtherscanProvider && options.etherscan !== "-") {
21
+ try {
22
+ providerList.push(new providers.EtherscanProvider(network, options.etherscan));
23
+ }
24
+ catch (error) { }
25
+ }
26
+ if (providers.AlchemyProvider && options.alchemy !== "-") {
27
+ try {
28
+ providerList.push(new providers.AlchemyProvider(network, options.alchemy));
29
+ }
30
+ catch (error) { }
31
+ }
32
+ if (providers.PocketProvider && options.pocket !== "-") {
33
+ // These networks are currently faulty on Pocket as their
34
+ // network does not handle the Berlin hardfork, which is
35
+ // live on these ones.
36
+ // @TODO: This goes away once Pocket has upgraded their nodes
37
+ const skip = ["goerli", "ropsten", "rinkeby", "sepolia"];
38
+ try {
39
+ const provider = new providers.PocketProvider(network, options.pocket);
40
+ if (provider.network && skip.indexOf(provider.network.name) === -1) {
41
+ providerList.push(provider);
42
+ }
43
+ }
44
+ catch (error) { }
45
+ }
46
+ if (providers.CloudflareProvider && options.cloudflare !== "-") {
47
+ try {
48
+ providerList.push(new providers.CloudflareProvider(network));
49
+ }
50
+ catch (error) { }
51
+ }
52
+ if (providers.AnkrProvider && options.ankr !== "-") {
53
+ try {
54
+ const skip = ["ropsten"];
55
+ const provider = new providers.AnkrProvider(network, options.ankr);
56
+ if (provider.network && skip.indexOf(provider.network.name) === -1) {
57
+ providerList.push(provider);
58
+ }
59
+ }
60
+ catch (error) { }
61
+ }
62
+ if (providerList.length === 0) {
63
+ return null;
64
+ }
65
+ if (providers.FallbackProvider) {
66
+ let quorum = 1;
67
+ if (options.quorum != null) {
68
+ quorum = options.quorum;
69
+ }
70
+ else if (network === "homestead") {
71
+ quorum = 2;
72
+ }
73
+ return new providers.FallbackProvider(providerList, quorum);
74
+ }
75
+ return providerList[0];
76
+ };
77
+ func.renetwork = function (network) {
78
+ return ethDefaultProvider(network);
79
+ };
80
+ return func;
81
+ }
82
+ function etcDefaultProvider(url, network) {
83
+ const func = function (providers, options) {
84
+ if (providers.JsonRpcProvider) {
85
+ return new providers.JsonRpcProvider(url, network);
86
+ }
87
+ return null;
88
+ };
89
+ func.renetwork = function (network) {
90
+ return etcDefaultProvider(url, network);
91
+ };
92
+ return func;
93
+ }
94
+ const homestead = {
95
+ chainId: 1,
96
+ ensAddress: "0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e",
97
+ name: "homestead",
98
+ _defaultProvider: ethDefaultProvider("homestead")
99
+ };
100
+ const ropsten = {
101
+ chainId: 3,
102
+ ensAddress: "0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e",
103
+ name: "ropsten",
104
+ _defaultProvider: ethDefaultProvider("ropsten")
105
+ };
106
+ const classicMordor = {
107
+ chainId: 63,
108
+ name: "classicMordor",
109
+ _defaultProvider: etcDefaultProvider("https://www.ethercluster.com/mordor", "classicMordor")
110
+ };
111
+ // See: https://chainlist.org
112
+ const networks = {
113
+ unspecified: { chainId: 0, name: "unspecified" },
114
+ homestead: homestead,
115
+ mainnet: homestead,
116
+ morden: { chainId: 2, name: "morden" },
117
+ ropsten: ropsten,
118
+ testnet: ropsten,
119
+ rinkeby: {
120
+ chainId: 4,
121
+ ensAddress: "0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e",
122
+ name: "rinkeby",
123
+ _defaultProvider: ethDefaultProvider("rinkeby")
124
+ },
125
+ kovan: {
126
+ chainId: 42,
127
+ name: "kovan",
128
+ _defaultProvider: ethDefaultProvider("kovan")
129
+ },
130
+ goerli: {
131
+ chainId: 5,
132
+ ensAddress: "0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e",
133
+ name: "goerli",
134
+ _defaultProvider: ethDefaultProvider("goerli")
135
+ },
136
+ kintsugi: { chainId: 1337702, name: "kintsugi" },
137
+ sepolia: {
138
+ chainId: 11155111,
139
+ name: "sepolia",
140
+ _defaultProvider: ethDefaultProvider("sepolia")
141
+ },
142
+ // ETC (See: #351)
143
+ classic: {
144
+ chainId: 61,
145
+ name: "classic",
146
+ _defaultProvider: etcDefaultProvider("https:/\/www.ethercluster.com/etc", "classic")
147
+ },
148
+ classicMorden: { chainId: 62, name: "classicMorden" },
149
+ classicMordor: classicMordor,
150
+ classicTestnet: classicMordor,
151
+ classicKotti: {
152
+ chainId: 6,
153
+ name: "classicKotti",
154
+ _defaultProvider: etcDefaultProvider("https:/\/www.ethercluster.com/kotti", "classicKotti")
155
+ },
156
+ xdai: { chainId: 100, name: "xdai" },
157
+ matic: {
158
+ chainId: 137,
159
+ name: "matic",
160
+ _defaultProvider: ethDefaultProvider("matic")
161
+ },
162
+ maticmum: { chainId: 80001, name: "maticmum" },
163
+ optimism: {
164
+ chainId: 10,
165
+ name: "optimism",
166
+ _defaultProvider: ethDefaultProvider("optimism")
167
+ },
168
+ "optimism-kovan": { chainId: 69, name: "optimism-kovan" },
169
+ "optimism-goerli": { chainId: 420, name: "optimism-goerli" },
170
+ arbitrum: { chainId: 42161, name: "arbitrum" },
171
+ "arbitrum-rinkeby": { chainId: 421611, name: "arbitrum-rinkeby" },
172
+ "arbitrum-goerli": { chainId: 421613, name: "arbitrum-goerli" },
173
+ bnb: { chainId: 56, name: "bnb" },
174
+ bnbt: { chainId: 97, name: "bnbt" },
175
+ };
176
+ /**
177
+ * getNetwork
178
+ *
179
+ * Converts a named common networks or chain ID (network ID) to a Network
180
+ * and verifies a network is a valid Network..
181
+ */
182
+ function getNetwork(network) {
183
+ // No network (null)
184
+ if (network == null) {
185
+ return null;
186
+ }
187
+ if (typeof (network) === "number") {
188
+ for (const name in networks) {
189
+ const standard = networks[name];
190
+ if (standard.chainId === network) {
191
+ return {
192
+ name: standard.name,
193
+ chainId: standard.chainId,
194
+ ensAddress: (standard.ensAddress || null),
195
+ _defaultProvider: (standard._defaultProvider || null)
196
+ };
197
+ }
198
+ }
199
+ return {
200
+ chainId: network,
201
+ name: "unknown"
202
+ };
203
+ }
204
+ if (typeof (network) === "string") {
205
+ const standard = networks[network];
206
+ if (standard == null) {
207
+ return null;
208
+ }
209
+ return {
210
+ name: standard.name,
211
+ chainId: standard.chainId,
212
+ ensAddress: standard.ensAddress,
213
+ _defaultProvider: (standard._defaultProvider || null)
214
+ };
215
+ }
216
+ const standard = networks[network.name];
217
+ // Not a standard network; check that it is a valid network in general
218
+ if (!standard) {
219
+ if (typeof (network.chainId) !== "number") {
220
+ logger.throwArgumentError("invalid network chainId", "network", network);
221
+ }
222
+ return network;
223
+ }
224
+ // Make sure the chainId matches the expected network chainId (or is 0; disable EIP-155)
225
+ if (network.chainId !== 0 && network.chainId !== standard.chainId) {
226
+ logger.throwArgumentError("network chainId mismatch", "network", network);
227
+ }
228
+ // @TODO: In the next major version add an attach function to a defaultProvider
229
+ // class and move the _defaultProvider internal to this file (extend Network)
230
+ let defaultProvider = network._defaultProvider || null;
231
+ if (defaultProvider == null && standard._defaultProvider) {
232
+ if (isRenetworkable(standard._defaultProvider)) {
233
+ defaultProvider = standard._defaultProvider.renetwork(network);
234
+ }
235
+ else {
236
+ defaultProvider = standard._defaultProvider;
237
+ }
238
+ }
239
+ // Standard Network (allow overriding the ENS address)
240
+ return {
241
+ name: network.name,
242
+ chainId: standard.chainId,
243
+ ensAddress: (network.ensAddress || standard.ensAddress || null),
244
+ _defaultProvider: defaultProvider
245
+ };
246
+ }
247
+
248
+ export { getNetwork };
@@ -0,0 +1,3 @@
1
+ const version = "properties/5.7.0";
2
+
3
+ export { version };