@waku/rln 0.1.3-f6d5deb → 0.1.4-29a4c3f.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.
- package/README.md +10 -186
- package/bundle/_virtual/__node-resolve_empty.js +6 -0
- package/bundle/_virtual/_assert.js +3 -0
- package/bundle/_virtual/_commonjs-dynamic-modules.js +5 -0
- package/bundle/_virtual/_commonjsHelpers.js +32 -0
- package/bundle/_virtual/_node-resolve_empty.js +3 -0
- package/bundle/_virtual/_sha2.js +3 -0
- package/bundle/_virtual/_u64.js +3 -0
- package/bundle/_virtual/aes.js +3 -0
- package/bundle/_virtual/bn.js +3 -0
- package/bundle/_virtual/browser.js +3 -0
- package/bundle/_virtual/checksum.js +3 -0
- package/bundle/_virtual/cipher.js +3 -0
- package/bundle/_virtual/class.js +3 -0
- package/bundle/_virtual/common.js +3 -0
- package/bundle/_virtual/common2.js +3 -0
- package/bundle/_virtual/cryptoBrowser.js +3 -0
- package/bundle/_virtual/functional.js +3 -0
- package/bundle/_virtual/hash.js +3 -0
- package/bundle/_virtual/hmac.js +3 -0
- package/bundle/_virtual/index.js +3 -0
- package/bundle/_virtual/index2.js +6 -0
- package/bundle/_virtual/inherits_browser.js +3 -0
- package/bundle/_virtual/kdf.js +3 -0
- package/bundle/_virtual/lodash.js +3 -0
- package/bundle/_virtual/password.js +3 -0
- package/bundle/_virtual/pbkdf2.js +3 -0
- package/bundle/_virtual/pbkdf22.js +3 -0
- package/bundle/_virtual/random.js +3 -0
- package/bundle/_virtual/ripemd.js +3 -0
- package/bundle/_virtual/schema-validation-generated.js +3 -0
- package/bundle/_virtual/schema-validation.js +3 -0
- package/bundle/_virtual/scrypt.js +3 -0
- package/bundle/_virtual/scrypt2.js +3 -0
- package/bundle/_virtual/sha.js +3 -0
- package/bundle/_virtual/sha256.js +3 -0
- package/bundle/_virtual/sha2562.js +3 -0
- package/bundle/_virtual/sha3.js +3 -0
- package/bundle/_virtual/sha512.js +3 -0
- package/bundle/_virtual/types.js +3 -0
- package/bundle/_virtual/utils.js +3 -0
- package/bundle/_virtual/utils2.js +3 -0
- package/bundle/_virtual/utils3.js +3 -0
- package/bundle/index.js +12 -74804
- package/bundle/node_modules/@ethersproject/abi/lib.esm/_version.js +3 -0
- package/bundle/node_modules/@ethersproject/abi/lib.esm/abi-coder.js +96 -0
- package/bundle/node_modules/@ethersproject/abi/lib.esm/coders/abstract-coder.js +148 -0
- package/bundle/node_modules/@ethersproject/abi/lib.esm/coders/address.js +26 -0
- package/bundle/node_modules/@ethersproject/abi/lib.esm/coders/anonymous.js +20 -0
- package/bundle/node_modules/@ethersproject/abi/lib.esm/coders/array.js +210 -0
- package/bundle/node_modules/@ethersproject/abi/lib.esm/coders/boolean.js +18 -0
- package/bundle/node_modules/@ethersproject/abi/lib.esm/coders/bytes.js +30 -0
- package/bundle/node_modules/@ethersproject/abi/lib.esm/coders/fixed-bytes.js +26 -0
- package/bundle/node_modules/@ethersproject/abi/lib.esm/coders/null.js +22 -0
- package/bundle/node_modules/@ethersproject/abi/lib.esm/coders/number.js +43 -0
- package/bundle/node_modules/@ethersproject/abi/lib.esm/coders/string.js +19 -0
- package/bundle/node_modules/@ethersproject/abi/lib.esm/coders/tuple.js +58 -0
- package/bundle/node_modules/@ethersproject/abi/lib.esm/fragments.js +854 -0
- package/bundle/node_modules/@ethersproject/abi/lib.esm/interface.js +609 -0
- package/bundle/node_modules/@ethersproject/abstract-provider/lib.esm/_version.js +3 -0
- package/bundle/node_modules/@ethersproject/abstract-provider/lib.esm/index.js +66 -0
- package/bundle/node_modules/@ethersproject/abstract-signer/lib.esm/_version.js +3 -0
- package/bundle/node_modules/@ethersproject/abstract-signer/lib.esm/index.js +302 -0
- package/bundle/node_modules/@ethersproject/address/lib.esm/_version.js +3 -0
- package/bundle/node_modules/@ethersproject/address/lib.esm/index.js +110 -0
- package/bundle/node_modules/@ethersproject/base64/lib.esm/base64.js +20 -0
- package/bundle/node_modules/@ethersproject/basex/lib.esm/index.js +120 -0
- package/bundle/node_modules/@ethersproject/bignumber/lib.esm/_version.js +3 -0
- package/bundle/node_modules/@ethersproject/bignumber/lib.esm/bignumber.js +287 -0
- package/bundle/node_modules/@ethersproject/bytes/lib.esm/_version.js +3 -0
- package/bundle/node_modules/@ethersproject/bytes/lib.esm/index.js +402 -0
- package/bundle/node_modules/@ethersproject/constants/lib.esm/addresses.js +3 -0
- package/bundle/node_modules/@ethersproject/constants/lib.esm/bignumbers.js +8 -0
- package/bundle/node_modules/@ethersproject/constants/lib.esm/hashes.js +3 -0
- package/bundle/node_modules/@ethersproject/contracts/lib.esm/_version.js +3 -0
- package/bundle/node_modules/@ethersproject/contracts/lib.esm/index.js +893 -0
- package/bundle/node_modules/@ethersproject/hash/lib.esm/_version.js +3 -0
- package/bundle/node_modules/@ethersproject/hash/lib.esm/ens-normalize/decoder.js +256 -0
- package/bundle/node_modules/@ethersproject/hash/lib.esm/ens-normalize/include.js +36 -0
- package/bundle/node_modules/@ethersproject/hash/lib.esm/ens-normalize/lib.js +135 -0
- package/bundle/node_modules/@ethersproject/hash/lib.esm/id.js +8 -0
- package/bundle/node_modules/@ethersproject/hash/lib.esm/namehash.js +64 -0
- package/bundle/node_modules/@ethersproject/hash/lib.esm/typed-data.js +443 -0
- package/bundle/node_modules/@ethersproject/keccak256/lib.esm/index.js +8 -0
- package/bundle/node_modules/@ethersproject/keccak256/node_modules/js-sha3/src/sha3.js +660 -0
- package/bundle/node_modules/@ethersproject/logger/lib.esm/_version.js +3 -0
- package/bundle/node_modules/@ethersproject/logger/lib.esm/index.js +352 -0
- package/bundle/node_modules/@ethersproject/networks/lib.esm/_version.js +3 -0
- package/bundle/node_modules/@ethersproject/networks/lib.esm/index.js +248 -0
- package/bundle/node_modules/@ethersproject/properties/lib.esm/_version.js +3 -0
- package/bundle/node_modules/@ethersproject/properties/lib.esm/index.js +127 -0
- package/bundle/node_modules/@ethersproject/providers/lib.esm/_version.js +3 -0
- package/bundle/node_modules/@ethersproject/providers/lib.esm/base-provider.js +2007 -0
- package/bundle/node_modules/@ethersproject/providers/lib.esm/formatter.js +422 -0
- package/bundle/node_modules/@ethersproject/providers/lib.esm/json-rpc-provider.js +674 -0
- package/bundle/node_modules/@ethersproject/providers/lib.esm/web3-provider.js +132 -0
- package/bundle/node_modules/@ethersproject/rlp/lib.esm/_version.js +3 -0
- package/bundle/node_modules/@ethersproject/rlp/lib.esm/index.js +120 -0
- package/bundle/node_modules/@ethersproject/sha2/lib.esm/sha2.js +8 -0
- package/bundle/node_modules/@ethersproject/signing-key/lib.esm/_version.js +3 -0
- package/bundle/node_modules/@ethersproject/signing-key/lib.esm/elliptic.js +2430 -0
- package/bundle/node_modules/@ethersproject/signing-key/lib.esm/index.js +76 -0
- package/bundle/node_modules/@ethersproject/strings/lib.esm/_version.js +3 -0
- package/bundle/node_modules/@ethersproject/strings/lib.esm/utf8.js +219 -0
- package/bundle/node_modules/@ethersproject/transactions/lib.esm/_version.js +3 -0
- package/bundle/node_modules/@ethersproject/transactions/lib.esm/index.js +279 -0
- package/bundle/node_modules/@ethersproject/web/lib.esm/_version.js +3 -0
- package/bundle/node_modules/@ethersproject/web/lib.esm/geturl.js +69 -0
- package/bundle/node_modules/@ethersproject/web/lib.esm/index.js +404 -0
- package/bundle/node_modules/@multiformats/multiaddr/dist/src/convert.js +15 -0
- package/bundle/node_modules/@multiformats/multiaddr/dist/src/multiaddr.js +20 -0
- package/bundle/node_modules/@multiformats/multiaddr/dist/src/protocols-table.js +92 -0
- package/bundle/node_modules/@noble/hashes/esm/_assert.js +37 -0
- package/bundle/node_modules/@noble/hashes/esm/_md.js +132 -0
- package/bundle/node_modules/@noble/hashes/esm/_u64.js +29 -0
- package/bundle/node_modules/@noble/hashes/esm/sha256.js +113 -0
- package/bundle/node_modules/@noble/hashes/esm/sha3.js +210 -0
- package/bundle/node_modules/@noble/hashes/esm/utils.js +144 -0
- package/bundle/node_modules/@waku/zerokit-rln-wasm/rln_wasm.js +756 -0
- package/bundle/node_modules/bech32/index.js +187 -0
- package/bundle/node_modules/bn.js/lib/bn.js +3361 -0
- package/bundle/node_modules/debug/src/browser.js +283 -0
- package/bundle/node_modules/debug/src/common.js +295 -0
- package/bundle/node_modules/ethereum-cryptography/esm/keccak.js +10 -0
- package/bundle/node_modules/ethereum-cryptography/esm/sha256.js +6 -0
- package/bundle/node_modules/ethereum-cryptography/esm/utils.js +24 -0
- package/bundle/node_modules/hash.js/lib/hash/common.js +97 -0
- package/bundle/node_modules/hash.js/lib/hash/hmac.js +51 -0
- package/bundle/node_modules/hash.js/lib/hash/ripemd.js +152 -0
- package/bundle/node_modules/hash.js/lib/hash/sha/1.js +81 -0
- package/bundle/node_modules/hash.js/lib/hash/sha/224.js +33 -0
- package/bundle/node_modules/hash.js/lib/hash/sha/256.js +113 -0
- package/bundle/node_modules/hash.js/lib/hash/sha/384.js +39 -0
- package/bundle/node_modules/hash.js/lib/hash/sha/512.js +336 -0
- package/bundle/node_modules/hash.js/lib/hash/sha/common.js +53 -0
- package/bundle/node_modules/hash.js/lib/hash/sha.js +14 -0
- package/bundle/node_modules/hash.js/lib/hash/utils.js +282 -0
- package/bundle/node_modules/hash.js/lib/hash.js +33 -0
- package/bundle/node_modules/inherits/inherits_browser.js +33 -0
- package/bundle/node_modules/it-length-prefixed/dist/src/decode.js +6 -0
- package/bundle/node_modules/lodash/lodash.js +17207 -0
- package/bundle/node_modules/minimalistic-assert/index.js +13 -0
- package/bundle/node_modules/ms/index.js +172 -0
- package/bundle/node_modules/multiformats/dist/src/bases/base.js +205 -0
- package/bundle/node_modules/multiformats/dist/src/bases/base10.js +9 -0
- package/bundle/node_modules/multiformats/dist/src/bases/base16.js +16 -0
- package/bundle/node_modules/multiformats/dist/src/bases/base2.js +10 -0
- package/bundle/node_modules/multiformats/dist/src/bases/base256emoji.js +41 -0
- package/bundle/node_modules/multiformats/dist/src/bases/base32.js +58 -0
- package/bundle/node_modules/multiformats/dist/src/bases/base36.js +14 -0
- package/bundle/node_modules/multiformats/dist/src/bases/base58.js +14 -0
- package/bundle/node_modules/multiformats/dist/src/bases/base64.js +28 -0
- package/bundle/node_modules/multiformats/dist/src/bases/base8.js +10 -0
- package/bundle/node_modules/multiformats/dist/src/bases/identity.js +11 -0
- package/bundle/node_modules/multiformats/dist/src/basics.js +15 -0
- package/bundle/node_modules/multiformats/dist/src/bytes.js +18 -0
- package/bundle/node_modules/multiformats/dist/src/codecs/json.js +2 -0
- package/bundle/node_modules/multiformats/dist/src/vendor/base-x.js +170 -0
- package/bundle/node_modules/protons-runtime/dist/src/codec.js +20 -0
- package/bundle/node_modules/protons-runtime/dist/src/codecs/enum.js +24 -0
- package/bundle/node_modules/protons-runtime/dist/src/codecs/message.js +7 -0
- package/bundle/node_modules/protons-runtime/dist/src/decode.js +8 -0
- package/bundle/node_modules/protons-runtime/dist/src/encode.js +11 -0
- package/bundle/node_modules/protons-runtime/dist/src/index.js +30 -0
- package/bundle/node_modules/protons-runtime/dist/src/utils/float.js +54 -0
- package/bundle/node_modules/protons-runtime/dist/src/utils/longbits.js +175 -0
- package/bundle/node_modules/protons-runtime/dist/src/utils/pool.js +28 -0
- package/bundle/node_modules/protons-runtime/dist/src/utils/reader.js +367 -0
- package/bundle/node_modules/protons-runtime/dist/src/utils/utf8.js +99 -0
- package/bundle/node_modules/protons-runtime/dist/src/utils/writer.js +438 -0
- package/bundle/node_modules/uint8-varint/dist/src/index.js +124 -0
- package/bundle/node_modules/uint8arrays/dist/src/alloc.js +17 -0
- package/bundle/node_modules/uint8arrays/dist/src/from-string.js +19 -0
- package/bundle/node_modules/uint8arrays/dist/src/util/bases.js +49 -0
- package/bundle/packages/core/dist/lib/connection_manager/connection_manager.js +21 -0
- package/bundle/packages/core/dist/lib/connection_manager/keep_alive_manager.js +18 -0
- package/bundle/packages/core/dist/lib/filter/filter.js +27 -0
- package/bundle/packages/core/dist/lib/light_push/light_push.js +27 -0
- package/bundle/packages/core/dist/lib/message/version_0.js +154 -0
- package/bundle/packages/core/dist/lib/metadata/metadata.js +27 -0
- package/bundle/packages/core/dist/lib/store/store.js +27 -0
- package/bundle/packages/interfaces/dist/connection_manager.js +19 -0
- package/bundle/packages/interfaces/dist/constants.js +6 -0
- package/bundle/packages/interfaces/dist/health_indicator.js +12 -0
- package/bundle/packages/interfaces/dist/protocols.js +92 -0
- package/bundle/packages/proto/dist/generated/filter.js +445 -0
- package/bundle/packages/proto/dist/generated/filter_v2.js +424 -0
- package/bundle/packages/proto/dist/generated/light_push.js +389 -0
- package/bundle/packages/proto/dist/generated/message.js +213 -0
- package/bundle/packages/proto/dist/generated/metadata.js +130 -0
- package/bundle/packages/proto/dist/generated/peer_exchange.js +209 -0
- package/bundle/packages/proto/dist/generated/sds_message.js +105 -0
- package/bundle/packages/proto/dist/generated/store_v3.js +490 -0
- package/bundle/packages/proto/dist/generated/topic_only_message.js +61 -0
- package/bundle/packages/rln/dist/codec.js +93 -0
- package/bundle/packages/rln/dist/contract/abi.js +394 -0
- package/bundle/packages/rln/dist/contract/constants.js +27 -0
- package/bundle/packages/rln/dist/contract/rln_contract.js +438 -0
- package/bundle/packages/rln/dist/create.js +9 -0
- package/bundle/packages/rln/dist/identity.js +30 -0
- package/bundle/packages/rln/dist/keystore/cipher.js +31 -0
- package/bundle/packages/rln/dist/keystore/credential_validation_generated.js +119 -0
- package/bundle/packages/rln/dist/keystore/keystore.js +223 -0
- package/bundle/packages/rln/dist/keystore/keystore_validation_generated.js +74 -0
- package/bundle/packages/rln/dist/keystore/schema_validator.js +20 -0
- package/bundle/packages/rln/dist/message.js +51 -0
- package/bundle/packages/rln/dist/proof.js +54 -0
- package/bundle/packages/rln/dist/resources/verification_key.js +112 -0
- package/bundle/packages/rln/dist/resources/witness_calculator.js +330 -0
- package/bundle/packages/rln/dist/rln.js +220 -0
- package/bundle/packages/rln/dist/root_tracker.js +76 -0
- package/bundle/packages/rln/dist/utils/bytes.js +65 -0
- package/bundle/packages/rln/dist/utils/epoch.js +39 -0
- package/bundle/packages/rln/dist/utils/hash.js +10 -0
- package/bundle/packages/rln/dist/utils/metamask.js +14 -0
- package/bundle/packages/rln/dist/zerokit.js +128 -0
- package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/lib/checksum.js +52 -0
- package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/lib/cipher.js +65 -0
- package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/lib/class.js +99 -0
- package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/lib/functional.js +103 -0
- package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/lib/index.js +28 -0
- package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/lib/kdf.js +78 -0
- package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/lib/password.js +17 -0
- package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/lib/schema-validation-generated.js +1253 -0
- package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/lib/schema-validation.js +40 -0
- package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/lib/types.js +5 -0
- package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/node_modules/ethereum-cryptography/aes.js +103 -0
- package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/node_modules/ethereum-cryptography/pbkdf2.js +41 -0
- package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/node_modules/ethereum-cryptography/random.js +17 -0
- package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/node_modules/ethereum-cryptography/scrypt.js +23 -0
- package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/node_modules/ethereum-cryptography/sha256.js +12 -0
- package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/node_modules/ethereum-cryptography/utils.js +77 -0
- package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/node_modules/uuid/dist/esm-browser/index.js +9 -0
- package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/node_modules/uuid/dist/esm-browser/md5.js +215 -0
- package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/node_modules/uuid/dist/esm-browser/nil.js +3 -0
- package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/node_modules/uuid/dist/esm-browser/parse.js +35 -0
- package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/node_modules/uuid/dist/esm-browser/regex.js +3 -0
- package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/node_modules/uuid/dist/esm-browser/rng.js +21 -0
- package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/node_modules/uuid/dist/esm-browser/sha1.js +96 -0
- package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/node_modules/uuid/dist/esm-browser/stringify.js +31 -0
- package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/node_modules/uuid/dist/esm-browser/v1.js +96 -0
- package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/node_modules/uuid/dist/esm-browser/v3.js +6 -0
- package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/node_modules/uuid/dist/esm-browser/v35.js +66 -0
- package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/node_modules/uuid/dist/esm-browser/v4.js +24 -0
- package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/node_modules/uuid/dist/esm-browser/v5.js +6 -0
- package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/node_modules/uuid/dist/esm-browser/validate.js +7 -0
- package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/node_modules/uuid/dist/esm-browser/version.js +11 -0
- package/bundle/packages/rln/node_modules/@noble/hashes/_assert.js +52 -0
- package/bundle/packages/rln/node_modules/@noble/hashes/_sha2.js +124 -0
- package/bundle/packages/rln/node_modules/@noble/hashes/_u64.js +71 -0
- package/bundle/packages/rln/node_modules/@noble/hashes/cryptoBrowser.js +10 -0
- package/bundle/packages/rln/node_modules/@noble/hashes/hmac.js +88 -0
- package/bundle/packages/rln/node_modules/@noble/hashes/pbkdf2.js +99 -0
- package/bundle/packages/rln/node_modules/@noble/hashes/scrypt.js +233 -0
- package/bundle/packages/rln/node_modules/@noble/hashes/sha256.js +133 -0
- package/bundle/packages/rln/node_modules/@noble/hashes/sha512.js +243 -0
- package/bundle/packages/rln/node_modules/@noble/hashes/utils.js +167 -0
- package/bundle/packages/rln/node_modules/uuid/dist/esm-browser/native.js +4 -0
- package/bundle/packages/rln/node_modules/uuid/dist/esm-browser/rng.js +13 -0
- package/bundle/packages/rln/node_modules/uuid/dist/esm-browser/stringify.js +28 -0
- package/bundle/packages/rln/node_modules/uuid/dist/esm-browser/v4.js +19 -0
- package/bundle/packages/utils/dist/bytes/index.js +44 -0
- package/bundle/packages/utils/dist/common/sharding/index.js +91 -0
- package/bundle/packages/utils/dist/logger/index.js +31 -0
- package/bundle/resources/verification_key.d.ts +13 -0
- package/bundle/resources/verification_key.js +112 -0
- package/bundle/resources/witness_calculator.d.ts +11 -0
- package/bundle/resources/witness_calculator.js +328 -0
- package/dist/.tsbuildinfo +1 -0
- package/dist/codec.d.ts +5 -5
- package/dist/codec.js +6 -6
- package/dist/codec.js.map +1 -1
- package/dist/contract/abi.d.ts +42 -0
- package/dist/contract/abi.js +393 -0
- package/dist/contract/abi.js.map +1 -0
- package/dist/contract/constants.d.ts +59 -3
- package/dist/contract/constants.js +21 -63
- package/dist/contract/constants.js.map +1 -1
- package/dist/contract/rln_contract.d.ts +98 -17
- package/dist/contract/rln_contract.js +292 -71
- package/dist/contract/rln_contract.js.map +1 -1
- package/dist/identity.js +5 -2
- package/dist/identity.js.map +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.js +3 -3
- package/dist/index.js.map +1 -1
- package/dist/keystore/cipher.js +3 -3
- package/dist/keystore/cipher.js.map +1 -1
- package/dist/keystore/credential_validation_generated.js.map +1 -1
- package/dist/keystore/keystore.js +4 -4
- package/dist/keystore/keystore.js.map +1 -1
- package/dist/keystore/keystore_validation_generated.js.map +1 -1
- package/dist/message.js +3 -3
- package/dist/message.js.map +1 -1
- package/dist/proof.js +3 -2
- package/dist/proof.js.map +1 -1
- package/dist/resources/verification_key.d.ts +12 -11
- package/dist/resources/verification_key.js +103 -103
- package/dist/resources/witness_calculator.d.ts +10 -15
- package/dist/resources/witness_calculator.js +302 -265
- package/dist/rln.d.ts +5 -1
- package/dist/rln.js +56 -28
- package/dist/rln.js.map +1 -1
- package/dist/root_tracker.js.map +1 -1
- package/dist/utils/epoch.js +5 -5
- package/dist/utils/epoch.js.map +1 -1
- package/dist/zerokit.d.ts +13 -9
- package/dist/zerokit.js +40 -20
- package/dist/zerokit.js.map +1 -1
- package/package.json +1 -146
- package/src/codec.ts +26 -22
- package/src/contract/abi.ts +392 -0
- package/src/contract/constants.ts +28 -0
- package/src/contract/index.ts +2 -0
- package/src/contract/rln_contract.ts +686 -0
- package/src/identity.ts +8 -4
- package/src/index.ts +4 -9
- package/src/keystore/cipher.ts +54 -0
- package/src/keystore/credential_validation_generated.ts +7 -0
- package/src/keystore/index.ts +5 -0
- package/src/keystore/keystore.ts +330 -0
- package/src/keystore/keystore_validation_generated.ts +7 -0
- package/src/keystore/schema_validator.ts +34 -0
- package/src/keystore/types.ts +36 -0
- package/src/message.ts +10 -10
- package/src/proof.ts +13 -11
- package/src/resources/verification_key.d.ts +13 -0
- package/src/resources/witness_calculator.d.ts +11 -0
- package/src/rln.ts +76 -31
- package/src/root_tracker.ts +7 -6
- package/src/utils/bytes.ts +84 -0
- package/src/utils/epoch.ts +30 -0
- package/src/utils/hash.ts +15 -0
- package/src/utils/index.ts +9 -0
- package/src/utils/metamask.ts +17 -0
- package/src/zerokit.ts +95 -33
- package/bundle/assets/rln_wasm_bg-a503e304.wasm +0 -0
- package/dist/resources/verification_key.js.map +0 -1
- package/dist/resources/witness_calculator.js.map +0 -1
- /package/bundle/{assets/rln-6ded2896.wasm → resources/rln.wasm} +0 -0
- /package/bundle/{assets/rln_final-8b299152.zkey → resources/rln_final.zkey} +0 -0
@@ -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,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 };
|