@waku/rln 0.0.1 → 0.0.2-09108d9.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 +12 -108
- 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 +11 -10
- 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/constants.js +68 -0
- package/bundle/packages/rln/dist/contract/rln_contract.js +218 -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 +206 -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 +108 -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/rln.wasm +0 -0
- package/bundle/resources/rln_final.zkey +0 -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 -1
- package/dist/codec.d.ts +39 -0
- package/dist/codec.js +77 -0
- package/dist/codec.js.map +1 -0
- package/dist/contract/constants.d.ts +7 -0
- package/dist/contract/constants.js +67 -0
- package/dist/contract/constants.js.map +1 -0
- package/dist/contract/index.d.ts +2 -0
- package/dist/contract/index.js +3 -0
- package/dist/contract/index.js.map +1 -0
- package/dist/contract/rln_contract.d.ts +46 -0
- package/dist/contract/rln_contract.js +211 -0
- package/dist/contract/rln_contract.js.map +1 -0
- package/dist/create.d.ts +2 -0
- package/dist/create.js +8 -0
- package/dist/create.js.map +1 -0
- package/dist/identity.d.ts +9 -0
- package/dist/identity.js +27 -0
- package/dist/identity.js.map +1 -0
- package/dist/index.d.ts +11 -2
- package/dist/index.js +11 -8
- package/dist/index.js.map +1 -1
- package/dist/keystore/cipher.d.ts +4 -0
- package/dist/keystore/cipher.js +28 -0
- package/dist/keystore/cipher.js.map +1 -0
- package/dist/keystore/credential_validation_generated.d.ts +8 -0
- package/dist/keystore/credential_validation_generated.js +121 -0
- package/dist/keystore/credential_validation_generated.js.map +1 -0
- package/dist/keystore/index.d.ts +4 -0
- package/dist/keystore/index.js +3 -0
- package/dist/keystore/index.js.map +1 -0
- package/dist/keystore/keystore.d.ts +50 -0
- package/dist/keystore/keystore.js +205 -0
- package/dist/keystore/keystore.js.map +1 -0
- package/dist/keystore/keystore_validation_generated.d.ts +8 -0
- package/dist/keystore/keystore_validation_generated.js +75 -0
- package/dist/keystore/keystore_validation_generated.js.map +1 -0
- package/dist/keystore/schema_validator.d.ts +2 -0
- package/dist/keystore/schema_validator.js +18 -0
- package/dist/keystore/schema_validator.js.map +1 -0
- package/dist/keystore/types.d.ts +29 -0
- package/dist/keystore/types.js +2 -0
- package/dist/keystore/types.js.map +1 -0
- package/dist/message.d.ts +18 -0
- package/dist/message.js +49 -0
- package/dist/message.js.map +1 -0
- package/dist/proof.d.ts +21 -0
- package/dist/proof.js +50 -0
- package/dist/proof.js.map +1 -0
- package/dist/resources/rln.wasm +0 -0
- package/dist/resources/rln_final.zkey +0 -0
- package/dist/resources/verification_key.d.ts +13 -0
- package/dist/resources/verification_key.js +112 -0
- package/dist/resources/witness_calculator.d.ts +11 -0
- package/dist/resources/witness_calculator.js +328 -0
- package/dist/rln.d.ts +55 -13
- package/dist/rln.js +164 -79
- package/dist/rln.js.map +1 -1
- package/dist/root_tracker.d.ts +10 -0
- package/dist/root_tracker.js +75 -0
- package/dist/root_tracker.js.map +1 -0
- package/dist/utils/bytes.d.ts +20 -0
- package/dist/utils/bytes.js +64 -0
- package/dist/utils/bytes.js.map +1 -0
- package/dist/utils/epoch.d.ts +3 -0
- package/dist/utils/epoch.js +23 -0
- package/dist/utils/epoch.js.map +1 -0
- package/dist/utils/hash.d.ts +2 -0
- package/dist/utils/hash.js +13 -0
- package/dist/utils/hash.js.map +1 -0
- package/dist/utils/index.d.ts +4 -0
- package/dist/utils/index.js +5 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/metamask.d.ts +2 -0
- package/dist/utils/metamask.js +12 -0
- package/dist/utils/metamask.js.map +1 -0
- package/dist/zerokit.d.ts +19 -0
- package/dist/zerokit.js +105 -0
- package/dist/zerokit.js.map +1 -0
- package/package.json +1 -126
- package/src/codec.ts +134 -0
- package/src/contract/constants.ts +68 -0
- package/src/contract/index.ts +2 -0
- package/src/contract/rln_contract.ts +353 -0
- package/src/create.ts +9 -0
- package/src/identity.ts +31 -0
- package/src/index.ts +29 -10
- 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 +70 -0
- package/src/proof.ts +69 -0
- package/src/resources/verification_key.d.ts +13 -0
- package/src/resources/witness_calculator.d.ts +11 -0
- package/src/rln.ts +266 -104
- package/src/root_tracker.ts +92 -0
- 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 +184 -0
- package/bundle/02bce7e5f3bcf834.wasm +0 -0
- package/bundle/rln-f87f6dbe.js +0 -563
- package/dist/resources.d.ts +0 -4
- package/dist/resources.js +0 -5
- package/dist/resources.js.map +0 -1
- package/dist/witness_calculator.d.ts +0 -16
- package/dist/witness_calculator.js +0 -291
- package/dist/witness_calculator.js.map +0 -1
- package/dist/zerokit/rln_wasm.d.ts +0 -1
- package/dist/zerokit/rln_wasm.js +0 -2
- package/dist/zerokit/rln_wasm.js.map +0 -1
- package/dist/zerokit/rln_wasm_bg.d.ts +0 -108
- package/dist/zerokit/rln_wasm_bg.js +0 -592
- package/dist/zerokit/rln_wasm_bg.js.map +0 -1
- package/dist/zerokit/rln_wasm_bg.wasm +0 -0
- package/src/resources.ts +0 -10
- package/src/witness_calculator.d.ts +0 -4
@@ -0,0 +1,609 @@
|
|
1
|
+
import { getAddress } from '../../address/lib.esm/index.js';
|
2
|
+
import { hexDataSlice, isHexString, arrayify, hexlify, concat, hexZeroPad } from '../../bytes/lib.esm/index.js';
|
3
|
+
import { id } from '../../hash/lib.esm/id.js';
|
4
|
+
import { keccak256 } from '../../keccak256/lib.esm/index.js';
|
5
|
+
import { Description, defineReadOnly, getStatic } from '../../properties/lib.esm/index.js';
|
6
|
+
import { defaultAbiCoder } from './abi-coder.js';
|
7
|
+
import { Fragment, ConstructorFragment, FormatTypes, FunctionFragment, EventFragment, ParamType } from './fragments.js';
|
8
|
+
import { Logger } from '../../logger/lib.esm/index.js';
|
9
|
+
import { version } from './_version.js';
|
10
|
+
import { BigNumber } from '../../bignumber/lib.esm/bignumber.js';
|
11
|
+
|
12
|
+
const logger = new Logger(version);
|
13
|
+
class LogDescription extends Description {
|
14
|
+
}
|
15
|
+
class TransactionDescription extends Description {
|
16
|
+
}
|
17
|
+
class ErrorDescription extends Description {
|
18
|
+
}
|
19
|
+
class Indexed extends Description {
|
20
|
+
static isIndexed(value) {
|
21
|
+
return !!(value && value._isIndexed);
|
22
|
+
}
|
23
|
+
}
|
24
|
+
const BuiltinErrors = {
|
25
|
+
"0x08c379a0": { signature: "Error(string)", name: "Error", inputs: ["string"], reason: true },
|
26
|
+
"0x4e487b71": { signature: "Panic(uint256)", name: "Panic", inputs: ["uint256"] }
|
27
|
+
};
|
28
|
+
function wrapAccessError(property, error) {
|
29
|
+
const wrap = new Error(`deferred error during ABI decoding triggered accessing ${property}`);
|
30
|
+
wrap.error = error;
|
31
|
+
return wrap;
|
32
|
+
}
|
33
|
+
/*
|
34
|
+
function checkNames(fragment: Fragment, type: "input" | "output", params: Array<ParamType>): void {
|
35
|
+
params.reduce((accum, param) => {
|
36
|
+
if (param.name) {
|
37
|
+
if (accum[param.name]) {
|
38
|
+
logger.throwArgumentError(`duplicate ${ type } parameter ${ JSON.stringify(param.name) } in ${ fragment.format("full") }`, "fragment", fragment);
|
39
|
+
}
|
40
|
+
accum[param.name] = true;
|
41
|
+
}
|
42
|
+
return accum;
|
43
|
+
}, <{ [ name: string ]: boolean }>{ });
|
44
|
+
}
|
45
|
+
*/
|
46
|
+
class Interface {
|
47
|
+
constructor(fragments) {
|
48
|
+
let abi = [];
|
49
|
+
if (typeof (fragments) === "string") {
|
50
|
+
abi = JSON.parse(fragments);
|
51
|
+
}
|
52
|
+
else {
|
53
|
+
abi = fragments;
|
54
|
+
}
|
55
|
+
defineReadOnly(this, "fragments", abi.map((fragment) => {
|
56
|
+
return Fragment.from(fragment);
|
57
|
+
}).filter((fragment) => (fragment != null)));
|
58
|
+
defineReadOnly(this, "_abiCoder", getStatic(new.target, "getAbiCoder")());
|
59
|
+
defineReadOnly(this, "functions", {});
|
60
|
+
defineReadOnly(this, "errors", {});
|
61
|
+
defineReadOnly(this, "events", {});
|
62
|
+
defineReadOnly(this, "structs", {});
|
63
|
+
// Add all fragments by their signature
|
64
|
+
this.fragments.forEach((fragment) => {
|
65
|
+
let bucket = null;
|
66
|
+
switch (fragment.type) {
|
67
|
+
case "constructor":
|
68
|
+
if (this.deploy) {
|
69
|
+
logger.warn("duplicate definition - constructor");
|
70
|
+
return;
|
71
|
+
}
|
72
|
+
//checkNames(fragment, "input", fragment.inputs);
|
73
|
+
defineReadOnly(this, "deploy", fragment);
|
74
|
+
return;
|
75
|
+
case "function":
|
76
|
+
//checkNames(fragment, "input", fragment.inputs);
|
77
|
+
//checkNames(fragment, "output", (<FunctionFragment>fragment).outputs);
|
78
|
+
bucket = this.functions;
|
79
|
+
break;
|
80
|
+
case "event":
|
81
|
+
//checkNames(fragment, "input", fragment.inputs);
|
82
|
+
bucket = this.events;
|
83
|
+
break;
|
84
|
+
case "error":
|
85
|
+
bucket = this.errors;
|
86
|
+
break;
|
87
|
+
default:
|
88
|
+
return;
|
89
|
+
}
|
90
|
+
let signature = fragment.format();
|
91
|
+
if (bucket[signature]) {
|
92
|
+
logger.warn("duplicate definition - " + signature);
|
93
|
+
return;
|
94
|
+
}
|
95
|
+
bucket[signature] = fragment;
|
96
|
+
});
|
97
|
+
// If we do not have a constructor add a default
|
98
|
+
if (!this.deploy) {
|
99
|
+
defineReadOnly(this, "deploy", ConstructorFragment.from({
|
100
|
+
payable: false,
|
101
|
+
type: "constructor"
|
102
|
+
}));
|
103
|
+
}
|
104
|
+
defineReadOnly(this, "_isInterface", true);
|
105
|
+
}
|
106
|
+
format(format) {
|
107
|
+
if (!format) {
|
108
|
+
format = FormatTypes.full;
|
109
|
+
}
|
110
|
+
if (format === FormatTypes.sighash) {
|
111
|
+
logger.throwArgumentError("interface does not support formatting sighash", "format", format);
|
112
|
+
}
|
113
|
+
const abi = this.fragments.map((fragment) => fragment.format(format));
|
114
|
+
// We need to re-bundle the JSON fragments a bit
|
115
|
+
if (format === FormatTypes.json) {
|
116
|
+
return JSON.stringify(abi.map((j) => JSON.parse(j)));
|
117
|
+
}
|
118
|
+
return abi;
|
119
|
+
}
|
120
|
+
// Sub-classes can override these to handle other blockchains
|
121
|
+
static getAbiCoder() {
|
122
|
+
return defaultAbiCoder;
|
123
|
+
}
|
124
|
+
static getAddress(address) {
|
125
|
+
return getAddress(address);
|
126
|
+
}
|
127
|
+
static getSighash(fragment) {
|
128
|
+
return hexDataSlice(id(fragment.format()), 0, 4);
|
129
|
+
}
|
130
|
+
static getEventTopic(eventFragment) {
|
131
|
+
return id(eventFragment.format());
|
132
|
+
}
|
133
|
+
// Find a function definition by any means necessary (unless it is ambiguous)
|
134
|
+
getFunction(nameOrSignatureOrSighash) {
|
135
|
+
if (isHexString(nameOrSignatureOrSighash)) {
|
136
|
+
for (const name in this.functions) {
|
137
|
+
if (nameOrSignatureOrSighash === this.getSighash(name)) {
|
138
|
+
return this.functions[name];
|
139
|
+
}
|
140
|
+
}
|
141
|
+
logger.throwArgumentError("no matching function", "sighash", nameOrSignatureOrSighash);
|
142
|
+
}
|
143
|
+
// It is a bare name, look up the function (will return null if ambiguous)
|
144
|
+
if (nameOrSignatureOrSighash.indexOf("(") === -1) {
|
145
|
+
const name = nameOrSignatureOrSighash.trim();
|
146
|
+
const matching = Object.keys(this.functions).filter((f) => (f.split("(" /* fix:) */)[0] === name));
|
147
|
+
if (matching.length === 0) {
|
148
|
+
logger.throwArgumentError("no matching function", "name", name);
|
149
|
+
}
|
150
|
+
else if (matching.length > 1) {
|
151
|
+
logger.throwArgumentError("multiple matching functions", "name", name);
|
152
|
+
}
|
153
|
+
return this.functions[matching[0]];
|
154
|
+
}
|
155
|
+
// Normalize the signature and lookup the function
|
156
|
+
const result = this.functions[FunctionFragment.fromString(nameOrSignatureOrSighash).format()];
|
157
|
+
if (!result) {
|
158
|
+
logger.throwArgumentError("no matching function", "signature", nameOrSignatureOrSighash);
|
159
|
+
}
|
160
|
+
return result;
|
161
|
+
}
|
162
|
+
// Find an event definition by any means necessary (unless it is ambiguous)
|
163
|
+
getEvent(nameOrSignatureOrTopic) {
|
164
|
+
if (isHexString(nameOrSignatureOrTopic)) {
|
165
|
+
const topichash = nameOrSignatureOrTopic.toLowerCase();
|
166
|
+
for (const name in this.events) {
|
167
|
+
if (topichash === this.getEventTopic(name)) {
|
168
|
+
return this.events[name];
|
169
|
+
}
|
170
|
+
}
|
171
|
+
logger.throwArgumentError("no matching event", "topichash", topichash);
|
172
|
+
}
|
173
|
+
// It is a bare name, look up the function (will return null if ambiguous)
|
174
|
+
if (nameOrSignatureOrTopic.indexOf("(") === -1) {
|
175
|
+
const name = nameOrSignatureOrTopic.trim();
|
176
|
+
const matching = Object.keys(this.events).filter((f) => (f.split("(" /* fix:) */)[0] === name));
|
177
|
+
if (matching.length === 0) {
|
178
|
+
logger.throwArgumentError("no matching event", "name", name);
|
179
|
+
}
|
180
|
+
else if (matching.length > 1) {
|
181
|
+
logger.throwArgumentError("multiple matching events", "name", name);
|
182
|
+
}
|
183
|
+
return this.events[matching[0]];
|
184
|
+
}
|
185
|
+
// Normalize the signature and lookup the function
|
186
|
+
const result = this.events[EventFragment.fromString(nameOrSignatureOrTopic).format()];
|
187
|
+
if (!result) {
|
188
|
+
logger.throwArgumentError("no matching event", "signature", nameOrSignatureOrTopic);
|
189
|
+
}
|
190
|
+
return result;
|
191
|
+
}
|
192
|
+
// Find a function definition by any means necessary (unless it is ambiguous)
|
193
|
+
getError(nameOrSignatureOrSighash) {
|
194
|
+
if (isHexString(nameOrSignatureOrSighash)) {
|
195
|
+
const getSighash = getStatic(this.constructor, "getSighash");
|
196
|
+
for (const name in this.errors) {
|
197
|
+
const error = this.errors[name];
|
198
|
+
if (nameOrSignatureOrSighash === getSighash(error)) {
|
199
|
+
return this.errors[name];
|
200
|
+
}
|
201
|
+
}
|
202
|
+
logger.throwArgumentError("no matching error", "sighash", nameOrSignatureOrSighash);
|
203
|
+
}
|
204
|
+
// It is a bare name, look up the function (will return null if ambiguous)
|
205
|
+
if (nameOrSignatureOrSighash.indexOf("(") === -1) {
|
206
|
+
const name = nameOrSignatureOrSighash.trim();
|
207
|
+
const matching = Object.keys(this.errors).filter((f) => (f.split("(" /* fix:) */)[0] === name));
|
208
|
+
if (matching.length === 0) {
|
209
|
+
logger.throwArgumentError("no matching error", "name", name);
|
210
|
+
}
|
211
|
+
else if (matching.length > 1) {
|
212
|
+
logger.throwArgumentError("multiple matching errors", "name", name);
|
213
|
+
}
|
214
|
+
return this.errors[matching[0]];
|
215
|
+
}
|
216
|
+
// Normalize the signature and lookup the function
|
217
|
+
const result = this.errors[FunctionFragment.fromString(nameOrSignatureOrSighash).format()];
|
218
|
+
if (!result) {
|
219
|
+
logger.throwArgumentError("no matching error", "signature", nameOrSignatureOrSighash);
|
220
|
+
}
|
221
|
+
return result;
|
222
|
+
}
|
223
|
+
// Get the sighash (the bytes4 selector) used by Solidity to identify a function
|
224
|
+
getSighash(fragment) {
|
225
|
+
if (typeof (fragment) === "string") {
|
226
|
+
try {
|
227
|
+
fragment = this.getFunction(fragment);
|
228
|
+
}
|
229
|
+
catch (error) {
|
230
|
+
try {
|
231
|
+
fragment = this.getError(fragment);
|
232
|
+
}
|
233
|
+
catch (_) {
|
234
|
+
throw error;
|
235
|
+
}
|
236
|
+
}
|
237
|
+
}
|
238
|
+
return getStatic(this.constructor, "getSighash")(fragment);
|
239
|
+
}
|
240
|
+
// Get the topic (the bytes32 hash) used by Solidity to identify an event
|
241
|
+
getEventTopic(eventFragment) {
|
242
|
+
if (typeof (eventFragment) === "string") {
|
243
|
+
eventFragment = this.getEvent(eventFragment);
|
244
|
+
}
|
245
|
+
return getStatic(this.constructor, "getEventTopic")(eventFragment);
|
246
|
+
}
|
247
|
+
_decodeParams(params, data) {
|
248
|
+
return this._abiCoder.decode(params, data);
|
249
|
+
}
|
250
|
+
_encodeParams(params, values) {
|
251
|
+
return this._abiCoder.encode(params, values);
|
252
|
+
}
|
253
|
+
encodeDeploy(values) {
|
254
|
+
return this._encodeParams(this.deploy.inputs, values || []);
|
255
|
+
}
|
256
|
+
decodeErrorResult(fragment, data) {
|
257
|
+
if (typeof (fragment) === "string") {
|
258
|
+
fragment = this.getError(fragment);
|
259
|
+
}
|
260
|
+
const bytes = arrayify(data);
|
261
|
+
if (hexlify(bytes.slice(0, 4)) !== this.getSighash(fragment)) {
|
262
|
+
logger.throwArgumentError(`data signature does not match error ${fragment.name}.`, "data", hexlify(bytes));
|
263
|
+
}
|
264
|
+
return this._decodeParams(fragment.inputs, bytes.slice(4));
|
265
|
+
}
|
266
|
+
encodeErrorResult(fragment, values) {
|
267
|
+
if (typeof (fragment) === "string") {
|
268
|
+
fragment = this.getError(fragment);
|
269
|
+
}
|
270
|
+
return hexlify(concat([
|
271
|
+
this.getSighash(fragment),
|
272
|
+
this._encodeParams(fragment.inputs, values || [])
|
273
|
+
]));
|
274
|
+
}
|
275
|
+
// Decode the data for a function call (e.g. tx.data)
|
276
|
+
decodeFunctionData(functionFragment, data) {
|
277
|
+
if (typeof (functionFragment) === "string") {
|
278
|
+
functionFragment = this.getFunction(functionFragment);
|
279
|
+
}
|
280
|
+
const bytes = arrayify(data);
|
281
|
+
if (hexlify(bytes.slice(0, 4)) !== this.getSighash(functionFragment)) {
|
282
|
+
logger.throwArgumentError(`data signature does not match function ${functionFragment.name}.`, "data", hexlify(bytes));
|
283
|
+
}
|
284
|
+
return this._decodeParams(functionFragment.inputs, bytes.slice(4));
|
285
|
+
}
|
286
|
+
// Encode the data for a function call (e.g. tx.data)
|
287
|
+
encodeFunctionData(functionFragment, values) {
|
288
|
+
if (typeof (functionFragment) === "string") {
|
289
|
+
functionFragment = this.getFunction(functionFragment);
|
290
|
+
}
|
291
|
+
return hexlify(concat([
|
292
|
+
this.getSighash(functionFragment),
|
293
|
+
this._encodeParams(functionFragment.inputs, values || [])
|
294
|
+
]));
|
295
|
+
}
|
296
|
+
// Decode the result from a function call (e.g. from eth_call)
|
297
|
+
decodeFunctionResult(functionFragment, data) {
|
298
|
+
if (typeof (functionFragment) === "string") {
|
299
|
+
functionFragment = this.getFunction(functionFragment);
|
300
|
+
}
|
301
|
+
let bytes = arrayify(data);
|
302
|
+
let reason = null;
|
303
|
+
let message = "";
|
304
|
+
let errorArgs = null;
|
305
|
+
let errorName = null;
|
306
|
+
let errorSignature = null;
|
307
|
+
switch (bytes.length % this._abiCoder._getWordSize()) {
|
308
|
+
case 0:
|
309
|
+
try {
|
310
|
+
return this._abiCoder.decode(functionFragment.outputs, bytes);
|
311
|
+
}
|
312
|
+
catch (error) { }
|
313
|
+
break;
|
314
|
+
case 4: {
|
315
|
+
const selector = hexlify(bytes.slice(0, 4));
|
316
|
+
const builtin = BuiltinErrors[selector];
|
317
|
+
if (builtin) {
|
318
|
+
errorArgs = this._abiCoder.decode(builtin.inputs, bytes.slice(4));
|
319
|
+
errorName = builtin.name;
|
320
|
+
errorSignature = builtin.signature;
|
321
|
+
if (builtin.reason) {
|
322
|
+
reason = errorArgs[0];
|
323
|
+
}
|
324
|
+
if (errorName === "Error") {
|
325
|
+
message = `; VM Exception while processing transaction: reverted with reason string ${JSON.stringify(errorArgs[0])}`;
|
326
|
+
}
|
327
|
+
else if (errorName === "Panic") {
|
328
|
+
message = `; VM Exception while processing transaction: reverted with panic code ${errorArgs[0]}`;
|
329
|
+
}
|
330
|
+
}
|
331
|
+
else {
|
332
|
+
try {
|
333
|
+
const error = this.getError(selector);
|
334
|
+
errorArgs = this._abiCoder.decode(error.inputs, bytes.slice(4));
|
335
|
+
errorName = error.name;
|
336
|
+
errorSignature = error.format();
|
337
|
+
}
|
338
|
+
catch (error) { }
|
339
|
+
}
|
340
|
+
break;
|
341
|
+
}
|
342
|
+
}
|
343
|
+
return logger.throwError("call revert exception" + message, Logger.errors.CALL_EXCEPTION, {
|
344
|
+
method: functionFragment.format(),
|
345
|
+
data: hexlify(data), errorArgs, errorName, errorSignature, reason
|
346
|
+
});
|
347
|
+
}
|
348
|
+
// Encode the result for a function call (e.g. for eth_call)
|
349
|
+
encodeFunctionResult(functionFragment, values) {
|
350
|
+
if (typeof (functionFragment) === "string") {
|
351
|
+
functionFragment = this.getFunction(functionFragment);
|
352
|
+
}
|
353
|
+
return hexlify(this._abiCoder.encode(functionFragment.outputs, values || []));
|
354
|
+
}
|
355
|
+
// Create the filter for the event with search criteria (e.g. for eth_filterLog)
|
356
|
+
encodeFilterTopics(eventFragment, values) {
|
357
|
+
if (typeof (eventFragment) === "string") {
|
358
|
+
eventFragment = this.getEvent(eventFragment);
|
359
|
+
}
|
360
|
+
if (values.length > eventFragment.inputs.length) {
|
361
|
+
logger.throwError("too many arguments for " + eventFragment.format(), Logger.errors.UNEXPECTED_ARGUMENT, {
|
362
|
+
argument: "values",
|
363
|
+
value: values
|
364
|
+
});
|
365
|
+
}
|
366
|
+
let topics = [];
|
367
|
+
if (!eventFragment.anonymous) {
|
368
|
+
topics.push(this.getEventTopic(eventFragment));
|
369
|
+
}
|
370
|
+
const encodeTopic = (param, value) => {
|
371
|
+
if (param.type === "string") {
|
372
|
+
return id(value);
|
373
|
+
}
|
374
|
+
else if (param.type === "bytes") {
|
375
|
+
return keccak256(hexlify(value));
|
376
|
+
}
|
377
|
+
if (param.type === "bool" && typeof (value) === "boolean") {
|
378
|
+
value = (value ? "0x01" : "0x00");
|
379
|
+
}
|
380
|
+
if (param.type.match(/^u?int/)) {
|
381
|
+
value = BigNumber.from(value).toHexString();
|
382
|
+
}
|
383
|
+
// Check addresses are valid
|
384
|
+
if (param.type === "address") {
|
385
|
+
this._abiCoder.encode(["address"], [value]);
|
386
|
+
}
|
387
|
+
return hexZeroPad(hexlify(value), 32);
|
388
|
+
};
|
389
|
+
values.forEach((value, index) => {
|
390
|
+
let param = eventFragment.inputs[index];
|
391
|
+
if (!param.indexed) {
|
392
|
+
if (value != null) {
|
393
|
+
logger.throwArgumentError("cannot filter non-indexed parameters; must be null", ("contract." + param.name), value);
|
394
|
+
}
|
395
|
+
return;
|
396
|
+
}
|
397
|
+
if (value == null) {
|
398
|
+
topics.push(null);
|
399
|
+
}
|
400
|
+
else if (param.baseType === "array" || param.baseType === "tuple") {
|
401
|
+
logger.throwArgumentError("filtering with tuples or arrays not supported", ("contract." + param.name), value);
|
402
|
+
}
|
403
|
+
else if (Array.isArray(value)) {
|
404
|
+
topics.push(value.map((value) => encodeTopic(param, value)));
|
405
|
+
}
|
406
|
+
else {
|
407
|
+
topics.push(encodeTopic(param, value));
|
408
|
+
}
|
409
|
+
});
|
410
|
+
// Trim off trailing nulls
|
411
|
+
while (topics.length && topics[topics.length - 1] === null) {
|
412
|
+
topics.pop();
|
413
|
+
}
|
414
|
+
return topics;
|
415
|
+
}
|
416
|
+
encodeEventLog(eventFragment, values) {
|
417
|
+
if (typeof (eventFragment) === "string") {
|
418
|
+
eventFragment = this.getEvent(eventFragment);
|
419
|
+
}
|
420
|
+
const topics = [];
|
421
|
+
const dataTypes = [];
|
422
|
+
const dataValues = [];
|
423
|
+
if (!eventFragment.anonymous) {
|
424
|
+
topics.push(this.getEventTopic(eventFragment));
|
425
|
+
}
|
426
|
+
if (values.length !== eventFragment.inputs.length) {
|
427
|
+
logger.throwArgumentError("event arguments/values mismatch", "values", values);
|
428
|
+
}
|
429
|
+
eventFragment.inputs.forEach((param, index) => {
|
430
|
+
const value = values[index];
|
431
|
+
if (param.indexed) {
|
432
|
+
if (param.type === "string") {
|
433
|
+
topics.push(id(value));
|
434
|
+
}
|
435
|
+
else if (param.type === "bytes") {
|
436
|
+
topics.push(keccak256(value));
|
437
|
+
}
|
438
|
+
else if (param.baseType === "tuple" || param.baseType === "array") {
|
439
|
+
// @TODO
|
440
|
+
throw new Error("not implemented");
|
441
|
+
}
|
442
|
+
else {
|
443
|
+
topics.push(this._abiCoder.encode([param.type], [value]));
|
444
|
+
}
|
445
|
+
}
|
446
|
+
else {
|
447
|
+
dataTypes.push(param);
|
448
|
+
dataValues.push(value);
|
449
|
+
}
|
450
|
+
});
|
451
|
+
return {
|
452
|
+
data: this._abiCoder.encode(dataTypes, dataValues),
|
453
|
+
topics: topics
|
454
|
+
};
|
455
|
+
}
|
456
|
+
// Decode a filter for the event and the search criteria
|
457
|
+
decodeEventLog(eventFragment, data, topics) {
|
458
|
+
if (typeof (eventFragment) === "string") {
|
459
|
+
eventFragment = this.getEvent(eventFragment);
|
460
|
+
}
|
461
|
+
if (topics != null && !eventFragment.anonymous) {
|
462
|
+
let topicHash = this.getEventTopic(eventFragment);
|
463
|
+
if (!isHexString(topics[0], 32) || topics[0].toLowerCase() !== topicHash) {
|
464
|
+
logger.throwError("fragment/topic mismatch", Logger.errors.INVALID_ARGUMENT, { argument: "topics[0]", expected: topicHash, value: topics[0] });
|
465
|
+
}
|
466
|
+
topics = topics.slice(1);
|
467
|
+
}
|
468
|
+
let indexed = [];
|
469
|
+
let nonIndexed = [];
|
470
|
+
let dynamic = [];
|
471
|
+
eventFragment.inputs.forEach((param, index) => {
|
472
|
+
if (param.indexed) {
|
473
|
+
if (param.type === "string" || param.type === "bytes" || param.baseType === "tuple" || param.baseType === "array") {
|
474
|
+
indexed.push(ParamType.fromObject({ type: "bytes32", name: param.name }));
|
475
|
+
dynamic.push(true);
|
476
|
+
}
|
477
|
+
else {
|
478
|
+
indexed.push(param);
|
479
|
+
dynamic.push(false);
|
480
|
+
}
|
481
|
+
}
|
482
|
+
else {
|
483
|
+
nonIndexed.push(param);
|
484
|
+
dynamic.push(false);
|
485
|
+
}
|
486
|
+
});
|
487
|
+
let resultIndexed = (topics != null) ? this._abiCoder.decode(indexed, concat(topics)) : null;
|
488
|
+
let resultNonIndexed = this._abiCoder.decode(nonIndexed, data, true);
|
489
|
+
let result = [];
|
490
|
+
let nonIndexedIndex = 0, indexedIndex = 0;
|
491
|
+
eventFragment.inputs.forEach((param, index) => {
|
492
|
+
if (param.indexed) {
|
493
|
+
if (resultIndexed == null) {
|
494
|
+
result[index] = new Indexed({ _isIndexed: true, hash: null });
|
495
|
+
}
|
496
|
+
else if (dynamic[index]) {
|
497
|
+
result[index] = new Indexed({ _isIndexed: true, hash: resultIndexed[indexedIndex++] });
|
498
|
+
}
|
499
|
+
else {
|
500
|
+
try {
|
501
|
+
result[index] = resultIndexed[indexedIndex++];
|
502
|
+
}
|
503
|
+
catch (error) {
|
504
|
+
result[index] = error;
|
505
|
+
}
|
506
|
+
}
|
507
|
+
}
|
508
|
+
else {
|
509
|
+
try {
|
510
|
+
result[index] = resultNonIndexed[nonIndexedIndex++];
|
511
|
+
}
|
512
|
+
catch (error) {
|
513
|
+
result[index] = error;
|
514
|
+
}
|
515
|
+
}
|
516
|
+
// Add the keyword argument if named and safe
|
517
|
+
if (param.name && result[param.name] == null) {
|
518
|
+
const value = result[index];
|
519
|
+
// Make error named values throw on access
|
520
|
+
if (value instanceof Error) {
|
521
|
+
Object.defineProperty(result, param.name, {
|
522
|
+
enumerable: true,
|
523
|
+
get: () => { throw wrapAccessError(`property ${JSON.stringify(param.name)}`, value); }
|
524
|
+
});
|
525
|
+
}
|
526
|
+
else {
|
527
|
+
result[param.name] = value;
|
528
|
+
}
|
529
|
+
}
|
530
|
+
});
|
531
|
+
// Make all error indexed values throw on access
|
532
|
+
for (let i = 0; i < result.length; i++) {
|
533
|
+
const value = result[i];
|
534
|
+
if (value instanceof Error) {
|
535
|
+
Object.defineProperty(result, i, {
|
536
|
+
enumerable: true,
|
537
|
+
get: () => { throw wrapAccessError(`index ${i}`, value); }
|
538
|
+
});
|
539
|
+
}
|
540
|
+
}
|
541
|
+
return Object.freeze(result);
|
542
|
+
}
|
543
|
+
// Given a transaction, find the matching function fragment (if any) and
|
544
|
+
// determine all its properties and call parameters
|
545
|
+
parseTransaction(tx) {
|
546
|
+
let fragment = this.getFunction(tx.data.substring(0, 10).toLowerCase());
|
547
|
+
if (!fragment) {
|
548
|
+
return null;
|
549
|
+
}
|
550
|
+
return new TransactionDescription({
|
551
|
+
args: this._abiCoder.decode(fragment.inputs, "0x" + tx.data.substring(10)),
|
552
|
+
functionFragment: fragment,
|
553
|
+
name: fragment.name,
|
554
|
+
signature: fragment.format(),
|
555
|
+
sighash: this.getSighash(fragment),
|
556
|
+
value: BigNumber.from(tx.value || "0"),
|
557
|
+
});
|
558
|
+
}
|
559
|
+
// @TODO
|
560
|
+
//parseCallResult(data: BytesLike): ??
|
561
|
+
// Given an event log, find the matching event fragment (if any) and
|
562
|
+
// determine all its properties and values
|
563
|
+
parseLog(log) {
|
564
|
+
let fragment = this.getEvent(log.topics[0]);
|
565
|
+
if (!fragment || fragment.anonymous) {
|
566
|
+
return null;
|
567
|
+
}
|
568
|
+
// @TODO: If anonymous, and the only method, and the input count matches, should we parse?
|
569
|
+
// Probably not, because just because it is the only event in the ABI does
|
570
|
+
// not mean we have the full ABI; maybe just a fragment?
|
571
|
+
return new LogDescription({
|
572
|
+
eventFragment: fragment,
|
573
|
+
name: fragment.name,
|
574
|
+
signature: fragment.format(),
|
575
|
+
topic: this.getEventTopic(fragment),
|
576
|
+
args: this.decodeEventLog(fragment, log.data, log.topics)
|
577
|
+
});
|
578
|
+
}
|
579
|
+
parseError(data) {
|
580
|
+
const hexData = hexlify(data);
|
581
|
+
let fragment = this.getError(hexData.substring(0, 10).toLowerCase());
|
582
|
+
if (!fragment) {
|
583
|
+
return null;
|
584
|
+
}
|
585
|
+
return new ErrorDescription({
|
586
|
+
args: this._abiCoder.decode(fragment.inputs, "0x" + hexData.substring(10)),
|
587
|
+
errorFragment: fragment,
|
588
|
+
name: fragment.name,
|
589
|
+
signature: fragment.format(),
|
590
|
+
sighash: this.getSighash(fragment),
|
591
|
+
});
|
592
|
+
}
|
593
|
+
/*
|
594
|
+
static from(value: Array<Fragment | string | JsonAbi> | string | Interface) {
|
595
|
+
if (Interface.isInterface(value)) {
|
596
|
+
return value;
|
597
|
+
}
|
598
|
+
if (typeof(value) === "string") {
|
599
|
+
return new Interface(JSON.parse(value));
|
600
|
+
}
|
601
|
+
return new Interface(value);
|
602
|
+
}
|
603
|
+
*/
|
604
|
+
static isInterface(value) {
|
605
|
+
return !!(value && value._isInterface);
|
606
|
+
}
|
607
|
+
}
|
608
|
+
|
609
|
+
export { ErrorDescription, Indexed, Interface, LogDescription, TransactionDescription };
|
@@ -0,0 +1,66 @@
|
|
1
|
+
import { defineReadOnly, resolveProperties, Description } from '../../properties/lib.esm/index.js';
|
2
|
+
import { Logger } from '../../logger/lib.esm/index.js';
|
3
|
+
import { version } from './_version.js';
|
4
|
+
import { BigNumber } from '../../bignumber/lib.esm/bignumber.js';
|
5
|
+
|
6
|
+
var __awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
|
7
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
8
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
9
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
10
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
11
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
12
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
13
|
+
});
|
14
|
+
};
|
15
|
+
const logger = new Logger(version);
|
16
|
+
//export type CallTransactionable = {
|
17
|
+
// call(transaction: TransactionRequest): Promise<TransactionResponse>;
|
18
|
+
//};
|
19
|
+
class ForkEvent extends Description {
|
20
|
+
static isForkEvent(value) {
|
21
|
+
return !!(value && value._isForkEvent);
|
22
|
+
}
|
23
|
+
}
|
24
|
+
///////////////////////////////
|
25
|
+
// Exported Abstracts
|
26
|
+
class Provider {
|
27
|
+
constructor() {
|
28
|
+
logger.checkAbstract(new.target, Provider);
|
29
|
+
defineReadOnly(this, "_isProvider", true);
|
30
|
+
}
|
31
|
+
getFeeData() {
|
32
|
+
return __awaiter(this, undefined, undefined, function* () {
|
33
|
+
const { block, gasPrice } = yield resolveProperties({
|
34
|
+
block: this.getBlock("latest"),
|
35
|
+
gasPrice: this.getGasPrice().catch((error) => {
|
36
|
+
// @TODO: Why is this now failing on Calaveras?
|
37
|
+
//console.log(error);
|
38
|
+
return null;
|
39
|
+
})
|
40
|
+
});
|
41
|
+
let lastBaseFeePerGas = null, maxFeePerGas = null, maxPriorityFeePerGas = null;
|
42
|
+
if (block && block.baseFeePerGas) {
|
43
|
+
// We may want to compute this more accurately in the future,
|
44
|
+
// using the formula "check if the base fee is correct".
|
45
|
+
// See: https://eips.ethereum.org/EIPS/eip-1559
|
46
|
+
lastBaseFeePerGas = block.baseFeePerGas;
|
47
|
+
maxPriorityFeePerGas = BigNumber.from("1500000000");
|
48
|
+
maxFeePerGas = block.baseFeePerGas.mul(2).add(maxPriorityFeePerGas);
|
49
|
+
}
|
50
|
+
return { lastBaseFeePerGas, maxFeePerGas, maxPriorityFeePerGas, gasPrice };
|
51
|
+
});
|
52
|
+
}
|
53
|
+
// Alias for "on"
|
54
|
+
addListener(eventName, listener) {
|
55
|
+
return this.on(eventName, listener);
|
56
|
+
}
|
57
|
+
// Alias for "off"
|
58
|
+
removeListener(eventName, listener) {
|
59
|
+
return this.off(eventName, listener);
|
60
|
+
}
|
61
|
+
static isProvider(value) {
|
62
|
+
return !!(value && value._isProvider);
|
63
|
+
}
|
64
|
+
}
|
65
|
+
|
66
|
+
export { ForkEvent, Provider };
|