diff --git a/.eslintrc.js b/.eslintrc.js index c5a4821..53e0e9a 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -9,6 +9,6 @@ module.exports = { env: { node: true, }, - rules: {}, - ignorePatterns: ['node_modules', 'dist'], + rules: { '@typescript-eslint/no-explicit-any': 'off' }, + ignorePatterns: ['node_modules', 'dist', 'data', 'build', 'src/vendors'], }; diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..673c1f8 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,27 @@ +name: CI + +on: + push: + branches: + - main + pull_request: + +jobs: + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + - name: Use Node.js + uses: actions/setup-node@v3 + with: + node-version: '18.x' + - name: Install dependencies + run: npm ci + + - name: Linting + run: npm run lint + + - name: Formatting + run: npm run format \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 96d556c..29152a5 100644 --- a/package-lock.json +++ b/package-lock.json @@ -4376,8 +4376,6 @@ }, "node_modules/ganache-cli/node_modules/@types/bn.js": { "version": "4.11.6", - "resolved": "https://registry.npmjs.org/@types/bn.js/-/bn.js-4.11.6.tgz", - "integrity": "sha512-pqr857jrp2kPuO9uRjZ3PwnJTjoQy+fcdxvBTvHm6dkmEL9q+hDD/2j/0ELOBPtPnS8LjCX0gI9nbl8lVkadpg==", "inBundle": true, "license": "MIT", "dependencies": { @@ -4386,15 +4384,11 @@ }, "node_modules/ganache-cli/node_modules/@types/node": { "version": "14.11.2", - "resolved": "https://registry.npmjs.org/@types/node/-/node-14.11.2.tgz", - "integrity": "sha512-jiE3QIxJ8JLNcb1Ps6rDbysDhN4xa8DJJvuC9prr6w+1tIh+QAbYyNF3tyiZNLDBIuBCf4KEcV2UvQm/V60xfA==", "inBundle": true, "license": "MIT" }, "node_modules/ganache-cli/node_modules/@types/pbkdf2": { "version": "3.1.0", - "resolved": "https://registry.npmjs.org/@types/pbkdf2/-/pbkdf2-3.1.0.tgz", - "integrity": "sha512-Cf63Rv7jCQ0LaL8tNXmEyqTHuIJxRdlS5vMh1mj5voN4+QFhVZnlZruezqpWYDiJ8UTzhP0VmeLXCmBk66YrMQ==", "inBundle": true, "license": "MIT", "dependencies": { @@ -4403,8 +4397,6 @@ }, "node_modules/ganache-cli/node_modules/@types/secp256k1": { "version": "4.0.1", - "resolved": "https://registry.npmjs.org/@types/secp256k1/-/secp256k1-4.0.1.tgz", - "integrity": "sha512-+ZjSA8ELlOp8SlKi0YLB2tz9d5iPNEmOBd+8Rz21wTMdaXQIa9b6TEnD6l5qKOCypE7FSyPyck12qZJxSDNoog==", "inBundle": true, "license": "MIT", "dependencies": { @@ -4413,8 +4405,6 @@ }, "node_modules/ganache-cli/node_modules/ansi-regex": { "version": "4.1.0", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-4.1.0.tgz", - "integrity": "sha512-1apePfXM1UOSqw0o9IiFAovVz9M5S1Dg+4TrDwfMewQ6p/rmMueb7tWZjQ1rx4Loy1ArBggoqGpfqqdI4rondg==", "inBundle": true, "license": "MIT", "engines": { @@ -4423,8 +4413,6 @@ }, "node_modules/ganache-cli/node_modules/ansi-styles": { "version": "3.2.1", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", - "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", "inBundle": true, "license": "MIT", "dependencies": { @@ -4436,8 +4424,6 @@ }, "node_modules/ganache-cli/node_modules/base-x": { "version": "3.0.8", - "resolved": "https://registry.npmjs.org/base-x/-/base-x-3.0.8.tgz", - "integrity": "sha512-Rl/1AWP4J/zRrk54hhlxH4drNxPJXYUaKffODVI53/dAsV4t9fBxyxYKAVPU1XBHxYwOWP9h9H0hM2MVw4YfJA==", "inBundle": true, "license": "MIT", "dependencies": { @@ -4446,29 +4432,21 @@ }, "node_modules/ganache-cli/node_modules/blakejs": { "version": "1.1.0", - "resolved": "https://registry.npmjs.org/blakejs/-/blakejs-1.1.0.tgz", - "integrity": "sha1-ad+S75U6qIylGjLfarHFShVfx6U=", "inBundle": true, "license": "CC0-1.0" }, "node_modules/ganache-cli/node_modules/bn.js": { "version": "4.11.9", - "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.11.9.tgz", - "integrity": "sha512-E6QoYqCKZfgatHTdHzs1RRKP7ip4vvm+EyRUeE2RF0NblwVvb0p6jSVeNTOFxPn26QXN2o6SMfNxKp6kU8zQaw==", "inBundle": true, "license": "MIT" }, "node_modules/ganache-cli/node_modules/brorand": { "version": "1.1.0", - "resolved": "https://registry.npmjs.org/brorand/-/brorand-1.1.0.tgz", - "integrity": "sha1-EsJe/kCkXjwyPrhnWgoM5XsiNx8=", "inBundle": true, "license": "MIT" }, "node_modules/ganache-cli/node_modules/browserify-aes": { "version": "1.2.0", - "resolved": "https://registry.npmjs.org/browserify-aes/-/browserify-aes-1.2.0.tgz", - "integrity": "sha512-+7CHXqGuspUn/Sl5aO7Ea0xWGAtETPXNSAjHo48JfLdPWcMng33Xe4znFvQweqc/uzk5zSOI3H52CYnjCfb5hA==", "inBundle": true, "license": "MIT", "dependencies": { @@ -4482,8 +4460,6 @@ }, "node_modules/ganache-cli/node_modules/bs58": { "version": "4.0.1", - "resolved": "https://registry.npmjs.org/bs58/-/bs58-4.0.1.tgz", - "integrity": "sha1-vhYedsNU9veIrkBx9j806MTwpCo=", "inBundle": true, "license": "MIT", "dependencies": { @@ -4492,8 +4468,6 @@ }, "node_modules/ganache-cli/node_modules/bs58check": { "version": "2.1.2", - "resolved": "https://registry.npmjs.org/bs58check/-/bs58check-2.1.2.tgz", - "integrity": "sha512-0TS1jicxdU09dwJMNZtVAfzPi6Q6QeN0pM1Fkzrjn+XYHvzMKPU3pHVpva+769iNVSfIYWf7LJ6WR+BuuMf8cA==", "inBundle": true, "license": "MIT", "dependencies": { @@ -4504,22 +4478,16 @@ }, "node_modules/ganache-cli/node_modules/buffer-from": { "version": "1.1.1", - "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.1.tgz", - "integrity": "sha512-MQcXEUbCKtEo7bhqEs6560Hyd4XaovZlO/k9V3hjVUF/zwW7KBVdSK4gIt/bzwS9MbR5qob+F5jusZsb0YQK2A==", "inBundle": true, "license": "MIT" }, "node_modules/ganache-cli/node_modules/buffer-xor": { "version": "1.0.3", - "resolved": "https://registry.npmjs.org/buffer-xor/-/buffer-xor-1.0.3.tgz", - "integrity": "sha1-JuYe0UIvtw3ULm42cp7VHYVf6Nk=", "inBundle": true, "license": "MIT" }, "node_modules/ganache-cli/node_modules/camelcase": { "version": "5.3.1", - "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-5.3.1.tgz", - "integrity": "sha512-L28STB170nwWS63UjtlEOE3dldQApaJXZkOI1uMFfzf3rRuPegHaHesyee+YxQ+W6SvRDQV6UrdOdRiR153wJg==", "inBundle": true, "license": "MIT", "engines": { @@ -4528,8 +4496,6 @@ }, "node_modules/ganache-cli/node_modules/cipher-base": { "version": "1.0.4", - "resolved": "https://registry.npmjs.org/cipher-base/-/cipher-base-1.0.4.tgz", - "integrity": "sha512-Kkht5ye6ZGmwv40uUDZztayT2ThLQGfnj/T71N/XzeZeo3nf8foyW7zGTsPYkEya3m5f3cAypH+qe7YOrM1U2Q==", "inBundle": true, "license": "MIT", "dependencies": { @@ -4539,8 +4505,6 @@ }, "node_modules/ganache-cli/node_modules/cliui": { "version": "5.0.0", - "resolved": "https://registry.npmjs.org/cliui/-/cliui-5.0.0.tgz", - "integrity": "sha512-PYeGSEmmHM6zvoef2w8TPzlrnNpXIjTipYK780YswmIP9vjxmd6Y2a3CB2Ks6/AU8NHjZugXvo8w3oWM2qnwXA==", "inBundle": true, "license": "ISC", "dependencies": { @@ -4551,8 +4515,6 @@ }, "node_modules/ganache-cli/node_modules/color-convert": { "version": "1.9.3", - "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz", - "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==", "inBundle": true, "license": "MIT", "dependencies": { @@ -4561,15 +4523,11 @@ }, "node_modules/ganache-cli/node_modules/color-name": { "version": "1.1.3", - "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", - "integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=", "inBundle": true, "license": "MIT" }, "node_modules/ganache-cli/node_modules/create-hash": { "version": "1.2.0", - "resolved": "https://registry.npmjs.org/create-hash/-/create-hash-1.2.0.tgz", - "integrity": "sha512-z00bCGNHDG8mHAkP7CtT1qVu+bFQUPjYq/4Iv3C3kWjTFV10zIjfSoeqXo9Asws8gwSHDGj/hl2u4OGIjapeCg==", "inBundle": true, "license": "MIT", "dependencies": { @@ -4582,8 +4540,6 @@ }, "node_modules/ganache-cli/node_modules/create-hmac": { "version": "1.1.7", - "resolved": "https://registry.npmjs.org/create-hmac/-/create-hmac-1.1.7.tgz", - "integrity": "sha512-MJG9liiZ+ogc4TzUwuvbER1JRdgvUFSB5+VR/g5h82fGaIRWMWddtKBHi7/sVhfjQZ6SehlyhvQYrcYkaUIpLg==", "inBundle": true, "license": "MIT", "dependencies": { @@ -4597,8 +4553,6 @@ }, "node_modules/ganache-cli/node_modules/cross-spawn": { "version": "6.0.5", - "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-6.0.5.tgz", - "integrity": "sha512-eTVLrBSt7fjbDygz805pMnstIs2VTBNkRm0qxZd+M7A5XDdxVRWO5MxGBXZhjY4cqLYLdtrGqRf8mBPmzwSpWQ==", "inBundle": true, "license": "MIT", "dependencies": { @@ -4614,8 +4568,6 @@ }, "node_modules/ganache-cli/node_modules/decamelize": { "version": "1.2.0", - "resolved": "https://registry.npmjs.org/decamelize/-/decamelize-1.2.0.tgz", - "integrity": "sha1-9lNNFRSCabIDUue+4m9QH5oZEpA=", "inBundle": true, "license": "MIT", "engines": { @@ -4624,8 +4576,6 @@ }, "node_modules/ganache-cli/node_modules/elliptic": { "version": "6.5.3", - "resolved": "https://registry.npmjs.org/elliptic/-/elliptic-6.5.3.tgz", - "integrity": "sha512-IMqzv5wNQf+E6aHeIqATs0tOLeOTwj1QKbRcS3jBbYkl5oLAserA8yJTT7/VyHUYG91PRmPyeQDObKLPpeS4dw==", "inBundle": true, "license": "MIT", "dependencies": { @@ -4640,15 +4590,11 @@ }, "node_modules/ganache-cli/node_modules/emoji-regex": { "version": "7.0.3", - "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-7.0.3.tgz", - "integrity": "sha512-CwBLREIQ7LvYFB0WyRvwhq5N5qPhc6PMjD6bYggFlI5YyDgl+0vxq5VHbMOFqLg7hfWzmu8T5Z1QofhmTIhItA==", "inBundle": true, "license": "MIT" }, "node_modules/ganache-cli/node_modules/end-of-stream": { "version": "1.4.4", - "resolved": "https://registry.npmjs.org/end-of-stream/-/end-of-stream-1.4.4.tgz", - "integrity": "sha512-+uw1inIHVPQoaVuHzRyXd21icM+cnt4CzD5rW+NC1wjOUSTOs+Te7FOv7AhN7vS9x/oIyhLP5PR1H+phQAHu5Q==", "inBundle": true, "license": "MIT", "dependencies": { @@ -4657,8 +4603,6 @@ }, "node_modules/ganache-cli/node_modules/ethereum-cryptography": { "version": "0.1.3", - "resolved": "https://registry.npmjs.org/ethereum-cryptography/-/ethereum-cryptography-0.1.3.tgz", - "integrity": "sha512-w8/4x1SGGzc+tO97TASLja6SLd3fRIK2tLVcV2Gx4IB21hE19atll5Cq9o3d0ZmAYC/8aw0ipieTSiekAea4SQ==", "inBundle": true, "license": "MIT", "dependencies": { @@ -4681,8 +4625,6 @@ }, "node_modules/ganache-cli/node_modules/ethereumjs-util": { "version": "6.2.1", - "resolved": "https://registry.npmjs.org/ethereumjs-util/-/ethereumjs-util-6.2.1.tgz", - "integrity": "sha512-W2Ktez4L01Vexijrm5EB6w7dg4n/TgpoYU4avuT5T3Vmnw/eCRtiBrJfQYS/DCSvDIOLn2k57GcHdeBcgVxAqw==", "inBundle": true, "license": "MPL-2.0", "dependencies": { @@ -4697,8 +4639,6 @@ }, "node_modules/ganache-cli/node_modules/ethjs-util": { "version": "0.1.6", - "resolved": "https://registry.npmjs.org/ethjs-util/-/ethjs-util-0.1.6.tgz", - "integrity": "sha512-CUnVOQq7gSpDHZVVrQW8ExxUETWrnrvXYvYz55wOU8Uj4VCgw56XC2B/fVqQN+f7gmrnRHSLVnFAwsCuNwji8w==", "inBundle": true, "license": "MIT", "dependencies": { @@ -4712,8 +4652,6 @@ }, "node_modules/ganache-cli/node_modules/evp_bytestokey": { "version": "1.0.3", - "resolved": "https://registry.npmjs.org/evp_bytestokey/-/evp_bytestokey-1.0.3.tgz", - "integrity": "sha512-/f2Go4TognH/KvCISP7OUsHn85hT9nUkxxA9BEWxFn+Oj9o8ZNLm/40hdlgSLyuOimsrTKLUMEorQexp/aPQeA==", "inBundle": true, "license": "MIT", "dependencies": { @@ -4723,8 +4661,6 @@ }, "node_modules/ganache-cli/node_modules/execa": { "version": "1.0.0", - "resolved": "https://registry.npmjs.org/execa/-/execa-1.0.0.tgz", - "integrity": "sha512-adbxcyWV46qiHyvSp50TKt05tB4tK3HcmF7/nxfAdhnox83seTDbwnaqKO4sXRy7roHAIFqJP/Rw/AuEbX61LA==", "inBundle": true, "license": "MIT", "dependencies": { @@ -4742,8 +4678,6 @@ }, "node_modules/ganache-cli/node_modules/find-up": { "version": "3.0.0", - "resolved": "https://registry.npmjs.org/find-up/-/find-up-3.0.0.tgz", - "integrity": "sha512-1yD6RmLI1XBfxugvORwlck6f75tYL+iR0jqwsOrOxMZyGYqUuDhJ0l4AXdO1iX/FTs9cBAMEk1gWSEx1kSbylg==", "inBundle": true, "license": "MIT", "dependencies": { @@ -4755,8 +4689,6 @@ }, "node_modules/ganache-cli/node_modules/get-caller-file": { "version": "2.0.5", - "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz", - "integrity": "sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==", "inBundle": true, "license": "ISC", "engines": { @@ -4765,8 +4697,6 @@ }, "node_modules/ganache-cli/node_modules/get-stream": { "version": "4.1.0", - "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-4.1.0.tgz", - "integrity": "sha512-GMat4EJ5161kIy2HevLlr4luNjBgvmj413KaQA7jt4V8B4RDsfpHk7WQ9GVqfYyyx8OS/L66Kox+rJRNklLK7w==", "inBundle": true, "license": "MIT", "dependencies": { @@ -4778,8 +4708,6 @@ }, "node_modules/ganache-cli/node_modules/hash-base": { "version": "3.1.0", - "resolved": "https://registry.npmjs.org/hash-base/-/hash-base-3.1.0.tgz", - "integrity": "sha512-1nmYp/rhMDiE7AYkDw+lLwlAzz0AntGIe51F3RfFfEqyQ3feY2eI/NcwC6umIQVOASPMsWJLJScWKSSvzL9IVA==", "inBundle": true, "license": "MIT", "dependencies": { @@ -4793,8 +4721,6 @@ }, "node_modules/ganache-cli/node_modules/hash.js": { "version": "1.1.7", - "resolved": "https://registry.npmjs.org/hash.js/-/hash.js-1.1.7.tgz", - "integrity": "sha512-taOaskGt4z4SOANNseOviYDvjEJinIkRgmp7LbKP2YTTmVxWBl87s/uzK9r+44BclBSp2X7K1hqeNfz9JbBeXA==", "inBundle": true, "license": "MIT", "dependencies": { @@ -4804,8 +4730,6 @@ }, "node_modules/ganache-cli/node_modules/hmac-drbg": { "version": "1.0.1", - "resolved": "https://registry.npmjs.org/hmac-drbg/-/hmac-drbg-1.0.1.tgz", - "integrity": "sha1-0nRXAQJabHdabFRXk+1QL8DGSaE=", "inBundle": true, "license": "MIT", "dependencies": { @@ -4816,15 +4740,11 @@ }, "node_modules/ganache-cli/node_modules/inherits": { "version": "2.0.4", - "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", - "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", "inBundle": true, "license": "ISC" }, "node_modules/ganache-cli/node_modules/invert-kv": { "version": "2.0.0", - "resolved": "https://registry.npmjs.org/invert-kv/-/invert-kv-2.0.0.tgz", - "integrity": "sha512-wPVv/y/QQ/Uiirj/vh3oP+1Ww+AWehmi1g5fFWGPF6IpCBCDVrhgHRMvrLfdYcwDh3QJbGXDW4JAuzxElLSqKA==", "inBundle": true, "license": "MIT", "engines": { @@ -4833,8 +4753,6 @@ }, "node_modules/ganache-cli/node_modules/is-fullwidth-code-point": { "version": "2.0.0", - "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz", - "integrity": "sha1-o7MKXE8ZkYMWeqq5O+764937ZU8=", "inBundle": true, "license": "MIT", "engines": { @@ -4843,8 +4761,6 @@ }, "node_modules/ganache-cli/node_modules/is-hex-prefixed": { "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-hex-prefixed/-/is-hex-prefixed-1.0.0.tgz", - "integrity": "sha1-fY035q135dEnFIkTxXPggtd39VQ=", "inBundle": true, "license": "MIT", "engines": { @@ -4854,8 +4770,6 @@ }, "node_modules/ganache-cli/node_modules/is-stream": { "version": "1.1.0", - "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-1.1.0.tgz", - "integrity": "sha1-EtSj3U5o4Lec6428hBc66A2RykQ=", "inBundle": true, "license": "MIT", "engines": { @@ -4864,15 +4778,11 @@ }, "node_modules/ganache-cli/node_modules/isexe": { "version": "2.0.0", - "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", - "integrity": "sha1-6PvzdNxVb/iUehDcsFctYz8s+hA=", "inBundle": true, "license": "ISC" }, "node_modules/ganache-cli/node_modules/keccak": { "version": "3.0.1", - "resolved": "https://registry.npmjs.org/keccak/-/keccak-3.0.1.tgz", - "integrity": "sha512-epq90L9jlFWCW7+pQa6JOnKn2Xgl2mtI664seYR6MHskvI9agt7AnDqmAlp9TqU4/caMYbA08Hi5DMZAl5zdkA==", "hasInstallScript": true, "inBundle": true, "license": "MIT", @@ -4886,8 +4796,6 @@ }, "node_modules/ganache-cli/node_modules/lcid": { "version": "2.0.0", - "resolved": "https://registry.npmjs.org/lcid/-/lcid-2.0.0.tgz", - "integrity": "sha512-avPEb8P8EGnwXKClwsNUgryVjllcRqtMYa49NTsbQagYuT1DcXnl1915oxWjoyGrXR6zH/Y0Zc96xWsPcoDKeA==", "inBundle": true, "license": "MIT", "dependencies": { @@ -4899,8 +4807,6 @@ }, "node_modules/ganache-cli/node_modules/locate-path": { "version": "3.0.0", - "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-3.0.0.tgz", - "integrity": "sha512-7AO748wWnIhNqAuaty2ZWHkQHRSNfPVIsPIfwEOWO22AmaoVrWavlOcMR5nzTLNYvp36X220/maaRsrec1G65A==", "inBundle": true, "license": "MIT", "dependencies": { @@ -4913,8 +4819,6 @@ }, "node_modules/ganache-cli/node_modules/map-age-cleaner": { "version": "0.1.3", - "resolved": "https://registry.npmjs.org/map-age-cleaner/-/map-age-cleaner-0.1.3.tgz", - "integrity": "sha512-bJzx6nMoP6PDLPBFmg7+xRKeFZvFboMrGlxmNj9ClvX53KrmvM5bXFXEWjbz4cz1AFn+jWJ9z/DJSz7hrs0w3w==", "inBundle": true, "license": "MIT", "dependencies": { @@ -4926,8 +4830,6 @@ }, "node_modules/ganache-cli/node_modules/md5.js": { "version": "1.3.5", - "resolved": "https://registry.npmjs.org/md5.js/-/md5.js-1.3.5.tgz", - "integrity": "sha512-xitP+WxNPcTTOgnTJcrhM0xvdPepipPSf3I8EIpGKeFLjt3PlJLIDG3u8EX53ZIubkb+5U2+3rELYpEhHhzdkg==", "inBundle": true, "license": "MIT", "dependencies": { @@ -4938,8 +4840,6 @@ }, "node_modules/ganache-cli/node_modules/mem": { "version": "4.3.0", - "resolved": "https://registry.npmjs.org/mem/-/mem-4.3.0.tgz", - "integrity": "sha512-qX2bG48pTqYRVmDB37rn/6PT7LcR8T7oAX3bf99u1Tt1nzxYfxkgqDwUwolPlXweM0XzBOBFzSx4kfp7KP1s/w==", "inBundle": true, "license": "MIT", "dependencies": { @@ -4953,8 +4853,6 @@ }, "node_modules/ganache-cli/node_modules/mimic-fn": { "version": "2.1.0", - "resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-2.1.0.tgz", - "integrity": "sha512-OqbOk5oEQeAZ8WXWydlu9HJjz9WVdEIvamMCcXmuqUYjTknH/sqsWvhQ3vgwKFRR1HpjvNBKQ37nbJgYzGqGcg==", "inBundle": true, "license": "MIT", "engines": { @@ -4963,36 +4861,26 @@ }, "node_modules/ganache-cli/node_modules/minimalistic-assert": { "version": "1.0.1", - "resolved": "https://registry.npmjs.org/minimalistic-assert/-/minimalistic-assert-1.0.1.tgz", - "integrity": "sha512-UtJcAD4yEaGtjPezWuO9wC4nwUnVH/8/Im3yEHQP4b67cXlD/Qr9hdITCU1xDbSEXg2XKNaP8jsReV7vQd00/A==", "inBundle": true, "license": "ISC" }, "node_modules/ganache-cli/node_modules/minimalistic-crypto-utils": { "version": "1.0.1", - "resolved": "https://registry.npmjs.org/minimalistic-crypto-utils/-/minimalistic-crypto-utils-1.0.1.tgz", - "integrity": "sha1-9sAMHAsIIkblxNmd+4x8CDsrWCo=", "inBundle": true, "license": "MIT" }, "node_modules/ganache-cli/node_modules/nice-try": { "version": "1.0.5", - "resolved": "https://registry.npmjs.org/nice-try/-/nice-try-1.0.5.tgz", - "integrity": "sha512-1nh45deeb5olNY7eX82BkPO7SSxR5SSYJiPTrTdFUVYwAl8CKMA5N9PjTYkHiRjisVcxcQ1HXdLhx2qxxJzLNQ==", "inBundle": true, "license": "MIT" }, "node_modules/ganache-cli/node_modules/node-addon-api": { "version": "2.0.2", - "resolved": "https://registry.npmjs.org/node-addon-api/-/node-addon-api-2.0.2.tgz", - "integrity": "sha512-Ntyt4AIXyaLIuMHF6IOoTakB3K+RWxwtsHNRxllEoA6vPwP9o4866g6YWDLUdnucilZhmkxiHwHr11gAENw+QA==", "inBundle": true, "license": "MIT" }, "node_modules/ganache-cli/node_modules/node-gyp-build": { "version": "4.2.3", - "resolved": "https://registry.npmjs.org/node-gyp-build/-/node-gyp-build-4.2.3.tgz", - "integrity": "sha512-MN6ZpzmfNCRM+3t57PTJHgHyw/h4OWnZ6mR8P5j/uZtqQr46RRuDE/P+g3n0YR/AiYXeWixZZzaip77gdICfRg==", "inBundle": true, "license": "MIT", "bin": { @@ -5003,8 +4891,6 @@ }, "node_modules/ganache-cli/node_modules/npm-run-path": { "version": "2.0.2", - "resolved": "https://registry.npmjs.org/npm-run-path/-/npm-run-path-2.0.2.tgz", - "integrity": "sha1-NakjLfo11wZ7TLLd8jV7GHFTbF8=", "inBundle": true, "license": "MIT", "dependencies": { @@ -5016,8 +4902,6 @@ }, "node_modules/ganache-cli/node_modules/once": { "version": "1.4.0", - "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", - "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", "inBundle": true, "license": "ISC", "dependencies": { @@ -5026,8 +4910,6 @@ }, "node_modules/ganache-cli/node_modules/os-locale": { "version": "3.1.0", - "resolved": "https://registry.npmjs.org/os-locale/-/os-locale-3.1.0.tgz", - "integrity": "sha512-Z8l3R4wYWM40/52Z+S265okfFj8Kt2cC2MKY+xNi3kFs+XGI7WXu/I309QQQYbRW4ijiZ+yxs9pqEhJh0DqW3Q==", "inBundle": true, "license": "MIT", "dependencies": { @@ -5041,8 +4923,6 @@ }, "node_modules/ganache-cli/node_modules/p-defer": { "version": "1.0.0", - "resolved": "https://registry.npmjs.org/p-defer/-/p-defer-1.0.0.tgz", - "integrity": "sha1-n26xgvbJqozXQwBKfU+WsZaw+ww=", "inBundle": true, "license": "MIT", "engines": { @@ -5051,8 +4931,6 @@ }, "node_modules/ganache-cli/node_modules/p-finally": { "version": "1.0.0", - "resolved": "https://registry.npmjs.org/p-finally/-/p-finally-1.0.0.tgz", - "integrity": "sha1-P7z7FbiZpEEjs0ttzBi3JDNqLK4=", "inBundle": true, "license": "MIT", "engines": { @@ -5061,8 +4939,6 @@ }, "node_modules/ganache-cli/node_modules/p-is-promise": { "version": "2.1.0", - "resolved": "https://registry.npmjs.org/p-is-promise/-/p-is-promise-2.1.0.tgz", - "integrity": "sha512-Y3W0wlRPK8ZMRbNq97l4M5otioeA5lm1z7bkNkxCka8HSPjR0xRWmpCmc9utiaLP9Jb1eD8BgeIxTW4AIF45Pg==", "inBundle": true, "license": "MIT", "engines": { @@ -5071,8 +4947,6 @@ }, "node_modules/ganache-cli/node_modules/p-limit": { "version": "2.3.0", - "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.3.0.tgz", - "integrity": "sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w==", "inBundle": true, "license": "MIT", "dependencies": { @@ -5087,8 +4961,6 @@ }, "node_modules/ganache-cli/node_modules/p-locate": { "version": "3.0.0", - "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-3.0.0.tgz", - "integrity": "sha512-x+12w/To+4GFfgJhBEpiDcLozRJGegY+Ei7/z0tSLkMmxGZNybVMSfWj9aJn8Z5Fc7dBUNJOOVgPv2H7IwulSQ==", "inBundle": true, "license": "MIT", "dependencies": { @@ -5100,8 +4972,6 @@ }, "node_modules/ganache-cli/node_modules/p-try": { "version": "2.2.0", - "resolved": "https://registry.npmjs.org/p-try/-/p-try-2.2.0.tgz", - "integrity": "sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ==", "inBundle": true, "license": "MIT", "engines": { @@ -5110,8 +4980,6 @@ }, "node_modules/ganache-cli/node_modules/path-exists": { "version": "3.0.0", - "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-3.0.0.tgz", - "integrity": "sha1-zg6+ql94yxiSXqfYENe1mwEP1RU=", "inBundle": true, "license": "MIT", "engines": { @@ -5120,8 +4988,6 @@ }, "node_modules/ganache-cli/node_modules/path-key": { "version": "2.0.1", - "resolved": "https://registry.npmjs.org/path-key/-/path-key-2.0.1.tgz", - "integrity": "sha1-QRyttXTFoUDTpLGRDUDYDMn0C0A=", "inBundle": true, "license": "MIT", "engines": { @@ -5130,8 +4996,6 @@ }, "node_modules/ganache-cli/node_modules/pbkdf2": { "version": "3.1.1", - "resolved": "https://registry.npmjs.org/pbkdf2/-/pbkdf2-3.1.1.tgz", - "integrity": "sha512-4Ejy1OPxi9f2tt1rRV7Go7zmfDQ+ZectEQz3VGUQhgq62HtIRPDyG/JtnwIxs6x3uNMwo2V7q1fMvKjb+Tnpqg==", "inBundle": true, "license": "MIT", "dependencies": { @@ -5147,8 +5011,6 @@ }, "node_modules/ganache-cli/node_modules/pump": { "version": "3.0.0", - "resolved": "https://registry.npmjs.org/pump/-/pump-3.0.0.tgz", - "integrity": "sha512-LwZy+p3SFs1Pytd/jYct4wpv49HiYCqd9Rlc5ZVdk0V+8Yzv6jR5Blk3TRmPL1ft69TxP0IMZGJ+WPFU2BFhww==", "inBundle": true, "license": "MIT", "dependencies": { @@ -5158,8 +5020,6 @@ }, "node_modules/ganache-cli/node_modules/randombytes": { "version": "2.1.0", - "resolved": "https://registry.npmjs.org/randombytes/-/randombytes-2.1.0.tgz", - "integrity": "sha512-vYl3iOX+4CKUWuxGi9Ukhie6fsqXqS9FE2Zaic4tNFD2N2QQaXOMFbuKK4QmDHC0JO6B1Zp41J0LpT0oR68amQ==", "inBundle": true, "license": "MIT", "dependencies": { @@ -5168,8 +5028,6 @@ }, "node_modules/ganache-cli/node_modules/readable-stream": { "version": "3.6.0", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.0.tgz", - "integrity": "sha512-BViHy7LKeTz4oNnkcLJ+lVSL6vpiFeX6/d3oSH8zCW7UxP2onchk+vTGB143xuFjHS3deTgkKoXXymXqymiIdA==", "inBundle": true, "license": "MIT", "dependencies": { @@ -5183,8 +5041,6 @@ }, "node_modules/ganache-cli/node_modules/require-directory": { "version": "2.1.1", - "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz", - "integrity": "sha1-jGStX9MNqxyXbiNE/+f3kqam30I=", "inBundle": true, "license": "MIT", "engines": { @@ -5193,15 +5049,11 @@ }, "node_modules/ganache-cli/node_modules/require-main-filename": { "version": "2.0.0", - "resolved": "https://registry.npmjs.org/require-main-filename/-/require-main-filename-2.0.0.tgz", - "integrity": "sha512-NKN5kMDylKuldxYLSUfrbo5Tuzh4hd+2E8NPPX02mZtn1VuREQToYe/ZdlJy+J3uCpfaiGF05e7B8W0iXbQHmg==", "inBundle": true, "license": "ISC" }, "node_modules/ganache-cli/node_modules/ripemd160": { "version": "2.0.2", - "resolved": "https://registry.npmjs.org/ripemd160/-/ripemd160-2.0.2.tgz", - "integrity": "sha512-ii4iagi25WusVoiC4B4lq7pbXfAp3D9v5CwfkY33vffw2+pkDjY1D8GaN7spsxvCSx8dkPqOZCEZyfxcmJG2IA==", "inBundle": true, "license": "MIT", "dependencies": { @@ -5211,8 +5063,6 @@ }, "node_modules/ganache-cli/node_modules/rlp": { "version": "2.2.6", - "resolved": "https://registry.npmjs.org/rlp/-/rlp-2.2.6.tgz", - "integrity": "sha512-HAfAmL6SDYNWPUOJNrM500x4Thn4PZsEy5pijPh40U9WfNk0z15hUYzO9xVIMAdIHdFtD8CBDHd75Td1g36Mjg==", "inBundle": true, "license": "MPL-2.0", "dependencies": { @@ -5224,8 +5074,6 @@ }, "node_modules/ganache-cli/node_modules/safe-buffer": { "version": "5.2.1", - "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", - "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==", "funding": [ { "type": "github", @@ -5245,15 +5093,11 @@ }, "node_modules/ganache-cli/node_modules/scrypt-js": { "version": "3.0.1", - "resolved": "https://registry.npmjs.org/scrypt-js/-/scrypt-js-3.0.1.tgz", - "integrity": "sha512-cdwTTnqPu0Hyvf5in5asVdZocVDTNRmR7XEcJuIzMjJeSHybHl7vpB66AzwTaIg6CLSbtjcxc8fqcySfnTkccA==", "inBundle": true, "license": "MIT" }, "node_modules/ganache-cli/node_modules/secp256k1": { "version": "4.0.2", - "resolved": "https://registry.npmjs.org/secp256k1/-/secp256k1-4.0.2.tgz", - "integrity": "sha512-UDar4sKvWAksIlfX3xIaQReADn+WFnHvbVujpcbr+9Sf/69odMwy2MUsz5CKLQgX9nsIyrjuxL2imVyoNHa3fg==", "hasInstallScript": true, "inBundle": true, "license": "MIT", @@ -5268,8 +5112,6 @@ }, "node_modules/ganache-cli/node_modules/semver": { "version": "5.7.1", - "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz", - "integrity": "sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==", "inBundle": true, "license": "ISC", "bin": { @@ -5278,22 +5120,16 @@ }, "node_modules/ganache-cli/node_modules/set-blocking": { "version": "2.0.0", - "resolved": "https://registry.npmjs.org/set-blocking/-/set-blocking-2.0.0.tgz", - "integrity": "sha1-BF+XgtARrppoA93TgrJDkrPYkPc=", "inBundle": true, "license": "ISC" }, "node_modules/ganache-cli/node_modules/setimmediate": { "version": "1.0.5", - "resolved": "https://registry.npmjs.org/setimmediate/-/setimmediate-1.0.5.tgz", - "integrity": "sha1-KQy7Iy4waULX1+qbg3Mqt4VvgoU=", "inBundle": true, "license": "MIT" }, "node_modules/ganache-cli/node_modules/sha.js": { "version": "2.4.11", - "resolved": "https://registry.npmjs.org/sha.js/-/sha.js-2.4.11.tgz", - "integrity": "sha512-QMEp5B7cftE7APOjk5Y6xgrbWu+WkLVQwk8JNjZ8nKRciZaByEW6MubieAiToS7+dwvrjGhH8jRXz3MVd0AYqQ==", "inBundle": true, "license": "(MIT AND BSD-3-Clause)", "dependencies": { @@ -5306,8 +5142,6 @@ }, "node_modules/ganache-cli/node_modules/shebang-command": { "version": "1.2.0", - "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-1.2.0.tgz", - "integrity": "sha1-RKrGW2lbAzmJaMOfNj/uXer98eo=", "inBundle": true, "license": "MIT", "dependencies": { @@ -5319,8 +5153,6 @@ }, "node_modules/ganache-cli/node_modules/shebang-regex": { "version": "1.0.0", - "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-1.0.0.tgz", - "integrity": "sha1-2kL0l0DAtC2yypcoVxyxkMmO/qM=", "inBundle": true, "license": "MIT", "engines": { @@ -5329,15 +5161,11 @@ }, "node_modules/ganache-cli/node_modules/signal-exit": { "version": "3.0.3", - "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.3.tgz", - "integrity": "sha512-VUJ49FC8U1OxwZLxIbTTrDvLnf/6TDgxZcK8wxR8zs13xpx7xbG60ndBlhNrFi2EMuFRoeDoJO7wthSLq42EjA==", "inBundle": true, "license": "ISC" }, "node_modules/ganache-cli/node_modules/source-map": { "version": "0.6.1", - "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", - "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", "inBundle": true, "license": "BSD-3-Clause", "engines": { @@ -5346,8 +5174,6 @@ }, "node_modules/ganache-cli/node_modules/source-map-support": { "version": "0.5.12", - "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.12.tgz", - "integrity": "sha512-4h2Pbvyy15EE02G+JOZpUCmqWJuqrs+sEkzewTm++BPi7Hvn/HwcqLAcNxYAyI0x13CpPPn+kMjl+hplXMHITQ==", "inBundle": true, "license": "MIT", "dependencies": { @@ -5357,8 +5183,6 @@ }, "node_modules/ganache-cli/node_modules/string_decoder": { "version": "1.3.0", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.3.0.tgz", - "integrity": "sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA==", "inBundle": true, "license": "MIT", "dependencies": { @@ -5367,8 +5191,6 @@ }, "node_modules/ganache-cli/node_modules/string-width": { "version": "3.1.0", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-3.1.0.tgz", - "integrity": "sha512-vafcv6KjVZKSgz06oM/H6GDBrAtz8vdhQakGjFIvNrHA6y3HCF1CInLy+QLq8dTJPQ1b+KDUqDFctkdRW44e1w==", "inBundle": true, "license": "MIT", "dependencies": { @@ -5382,8 +5204,6 @@ }, "node_modules/ganache-cli/node_modules/strip-ansi": { "version": "5.2.0", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-5.2.0.tgz", - "integrity": "sha512-DuRs1gKbBqsMKIZlrffwlug8MHkcnpjs5VPmL1PAh+mA30U0DTotfDZ0d2UUsXpPmPmMMJ6W773MaA3J+lbiWA==", "inBundle": true, "license": "MIT", "dependencies": { @@ -5395,8 +5215,6 @@ }, "node_modules/ganache-cli/node_modules/strip-eof": { "version": "1.0.0", - "resolved": "https://registry.npmjs.org/strip-eof/-/strip-eof-1.0.0.tgz", - "integrity": "sha1-u0P/VZim6wXYm1n80SnJgzE2Br8=", "inBundle": true, "license": "MIT", "engines": { @@ -5405,8 +5223,6 @@ }, "node_modules/ganache-cli/node_modules/strip-hex-prefix": { "version": "1.0.0", - "resolved": "https://registry.npmjs.org/strip-hex-prefix/-/strip-hex-prefix-1.0.0.tgz", - "integrity": "sha1-DF8VX+8RUTczd96du1iNoFUA428=", "inBundle": true, "license": "MIT", "dependencies": { @@ -5419,15 +5235,11 @@ }, "node_modules/ganache-cli/node_modules/util-deprecate": { "version": "1.0.2", - "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", - "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=", "inBundle": true, "license": "MIT" }, "node_modules/ganache-cli/node_modules/which": { "version": "1.3.1", - "resolved": "https://registry.npmjs.org/which/-/which-1.3.1.tgz", - "integrity": "sha512-HxJdYWq1MTIQbJ3nw0cqssHoTNU267KlrDuGZ1WYlxDStUtKUhOaJmh112/TZmHxxUfuJqPXSOm7tDyas0OSIQ==", "inBundle": true, "license": "ISC", "dependencies": { @@ -5439,15 +5251,11 @@ }, "node_modules/ganache-cli/node_modules/which-module": { "version": "2.0.0", - "resolved": "https://registry.npmjs.org/which-module/-/which-module-2.0.0.tgz", - "integrity": "sha1-2e8H3Od7mQK4o6j6SzHD4/fm6Ho=", "inBundle": true, "license": "ISC" }, "node_modules/ganache-cli/node_modules/wrap-ansi": { "version": "5.1.0", - "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-5.1.0.tgz", - "integrity": "sha512-QC1/iN/2/RPVJ5jYK8BGttj5z83LmSKmvbvrXPNCLZSEb32KKVDJDl/MOt2N01qU2H/FkzEa9PKto1BqDjtd7Q==", "inBundle": true, "license": "MIT", "dependencies": { @@ -5461,22 +5269,16 @@ }, "node_modules/ganache-cli/node_modules/wrappy": { "version": "1.0.2", - "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", - "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=", "inBundle": true, "license": "ISC" }, "node_modules/ganache-cli/node_modules/y18n": { "version": "4.0.0", - "resolved": "https://registry.npmjs.org/y18n/-/y18n-4.0.0.tgz", - "integrity": "sha512-r9S/ZyXu/Xu9q1tYlpsLIsa3EeLXXk0VwlxqTcFRfg9EhMW+17kbt9G0NrgCmhGb5vT2hyhJZLfDGx+7+5Uj/w==", "inBundle": true, "license": "ISC" }, "node_modules/ganache-cli/node_modules/yargs": { "version": "13.2.4", - "resolved": "https://registry.npmjs.org/yargs/-/yargs-13.2.4.tgz", - "integrity": "sha512-HG/DWAJa1PAnHT9JAhNa8AbAv3FPaiLzioSjCcmuXXhP8MlpHO5vwls4g4j6n30Z74GVQj8Xa62dWVx1QCGklg==", "inBundle": true, "license": "MIT", "dependencies": { @@ -5495,8 +5297,6 @@ }, "node_modules/ganache-cli/node_modules/yargs-parser": { "version": "13.1.2", - "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-13.1.2.tgz", - "integrity": "sha512-3lbsNRf/j+A4QuSZfDRA7HRSfWrzO0YjqTJd5kjAq37Zep1CEgaYmrH9Q3GwPiB9cHyd1Y1UwggGhJGoxipbzg==", "inBundle": true, "license": "ISC", "dependencies": { diff --git a/package.json b/package.json index a2434c9..a591b7f 100644 --- a/package.json +++ b/package.json @@ -8,9 +8,11 @@ "scripts": { "build": "tsc --project tsconfig.json && cp -r src/vendors dist/vendors", "clean": "rm -rf dist types", - "format": "prettier --write \"**/*.js\" \"**/*.ts\"", - "lint": "eslint .", - "test": "echo 1" + "lint": "eslint \"**/*.{js,ts}\"", + "lint:fix": "eslint --fix \"**/*.{js,ts}\"", + "format": "prettier --check \"**/*.{ts,js}\"", + "format:fix": "prettier --write \"**/*.{ts,js}\"", + "test": "jest" }, "keywords": [ "circom", diff --git a/src/circuit.ts b/src/circuit.ts index d092fa6..0845646 100644 --- a/src/circuit.ts +++ b/src/circuit.ts @@ -1,7 +1,7 @@ import * as path from 'path'; import log from 'log'; -const { wasm: wasmTester } = require('./vendors/circom_tester'); +import { wasm as wasmTester } from './vendors/circom_tester'; import { CircuitConfig, @@ -24,6 +24,7 @@ import { getTauFileUrlByConstraints } from './utils/tau'; export class Circuit { private _circuitConfig: CircuitConfig; + // eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-ignore // TODO: Remove ts-ignore and use _networks variable in the file private _networks: Networks; private _wasmTester: typeof wasmTester; @@ -122,7 +123,7 @@ export class Circuit { this._circuitConfig.zKeyPath, ); switch (this._circuitConfig.compileOptions.snarkType) { - case 'plonk': + case 'plonk': { const r1csFp = path.resolve( this._circuitConfig.outputDir, `${this._circuitConfig.cktName}.r1cs`, @@ -132,6 +133,7 @@ export class Circuit { this._circuitConfig.powerOfTauFp, this._circuitConfig.zKeyPath, ); + } case 'groth16': return genGrothZKey( this._circuitConfig.outputDir, diff --git a/src/configParser.ts b/src/configParser.ts index ee52587..58a796f 100644 --- a/src/configParser.ts +++ b/src/configParser.ts @@ -19,64 +19,56 @@ export class ConfigParser { private _parseAndValidate(fp: string): CFG { log.info('reading config, path:', fp); - try { - try { - fs.accessSync(fp, fs.constants.R_OK); - } catch (err) { - throw err; - } - - const cfgBuff = fs.readFileSync(fp); + fs.accessSync(fp, fs.constants.R_OK); + + const cfgBuff = fs.readFileSync(fp); + + const parsedConfig: CFG = JSON.parse(cfgBuff.toString()); + + if (!parsedConfig) { + throw new Error(`Config parsing failed, filepath:${this._fp}`); + } else if (!parsedConfig.outputDir) { + throw new Error( + `Field "outputDir" is not present in config json, File Path : ${this._fp}`, + ); + } else if (!parsedConfig.build) { + throw new Error( + `Field "build" is not present in config json, File Path : ${this._fp}`, + ); + } else if (!parsedConfig.build.inputDir) { + throw new Error( + `Field "inputDir" is not present in config json, File Path : ${this._fp}`, + ); + } else if (!parsedConfig.build?.circuits) { + throw new Error( + `Field "circuits" is not present in config json, filepath:${this._fp}`, + ); + } - const parsedConfig: CFG = JSON.parse(cfgBuff.toString()); + const circuitsValidation = this._areCircuitsValid(parsedConfig); + if (circuitsValidation !== '') { + throw new Error(circuitsValidation); + } - if (!parsedConfig) { - throw new Error(`Config parsing failed, filepath:${this._fp}`); - } else if (!parsedConfig.outputDir) { - throw new Error( - `Field "outputDir" is not present in config json, File Path : ${this._fp}`, - ); - } else if (!parsedConfig.build) { - throw new Error( - `Field "build" is not present in config json, File Path : ${this._fp}`, - ); - } else if (!parsedConfig.build.inputDir) { - throw new Error( - `Field "inputDir" is not present in config json, File Path : ${this._fp}`, - ); - } else if (!parsedConfig.build?.circuits) { + // Check if ouput directory path is valid + const outputDirectory = path.resolve(parsedConfig.outputDir); + if (!fs.existsSync(outputDirectory)) { + fs.mkdirSync(outputDirectory, { recursive: true }); + } else { + try { + fs.accessSync(outputDirectory, fs.constants.W_OK); + } catch (err) { throw new Error( - `Field "circuits" is not present in config json, filepath:${this._fp}`, + `Output directory is not writable. Please check outputDir in config json, filepath:${this._fp}`, ); } - - const circuitsValidation = this._areCircuitsValid(parsedConfig); - if (circuitsValidation !== '') { - throw new Error(circuitsValidation); - } - - // Check if ouput directory path is valid - const outputDirectory = path.resolve(parsedConfig.outputDir); - if (!fs.existsSync(outputDirectory)) { - fs.mkdirSync(outputDirectory, { recursive: true }); - } else { - try { - fs.accessSync(outputDirectory, fs.constants.W_OK); - } catch (err) { - throw new Error( - `Output directory is not writable. Please check outputDir in config json, filepath:${this._fp}`, - ); - } - } - - return Object.assign({}, parsedConfig); - } catch (err) { - throw err; } + + return Object.assign({}, parsedConfig); } private _areCircuitsValid(config: CFG): string { - let cIDListSoFar = Object.create(null); + const cIDListSoFar = Object.create(null); const circuitList = config.build?.circuits; const { build: { inputDir }, @@ -98,7 +90,7 @@ export class ConfigParser { } // Check for unique cID - let currentID = circuitList[i].cID; + const currentID = circuitList[i].cID; if (currentID in cIDListSoFar) { return `Field "cID" is not unique in the circuits, File Path : ${this._fp}`; } diff --git a/src/utils/curves.ts b/src/utils/curves.ts index ffd6bb5..dfdd4fe 100644 --- a/src/utils/curves.ts +++ b/src/utils/curves.ts @@ -1,4 +1,4 @@ -const { Scalar, buildBn128, buildBls12381 } = require('ffjavascript'); +import { Scalar, buildBn128, buildBls12381 } from 'ffjavascript'; const bls12381r = Scalar.e( '73eda753299d7d483339d80809a1d80553bda402fffe5bfeffffffff00000001', diff --git a/src/utils/https.ts b/src/utils/https.ts index 0c3853f..b5feb0e 100644 --- a/src/utils/https.ts +++ b/src/utils/https.ts @@ -6,7 +6,7 @@ export const downloadFile = async (fileUrl, outputPath) => { log.info('Downloading File: %s', fileUrl); const file = fs.createWriteStream(outputPath); - return new Promise((resolve, reject) => { + return new Promise((resolve) => { https.get(fileUrl, function (response) { response.pipe(file); diff --git a/src/utils/proof.ts b/src/utils/proof.ts index 0ae62ff..3f84c8c 100644 --- a/src/utils/proof.ts +++ b/src/utils/proof.ts @@ -1,8 +1,7 @@ import { CircuitInput, ZK_PROOF } from '../types'; import * as fs from 'fs'; -const { groth16 } = require('snarkjs'); -const { plonk } = require('snarkjs'); +import { groth16, plonk } from 'snarkjs'; export const genGroth16Proof = async ( inp: CircuitInput, diff --git a/src/utils/r1cs.ts b/src/utils/r1cs.ts index b6e86f2..24fc719 100644 --- a/src/utils/r1cs.ts +++ b/src/utils/r1cs.ts @@ -1,4 +1,4 @@ -const { r1cs } = require('snarkjs'); +import { r1cs } from 'snarkjs'; const { info } = r1cs; // TODO: provide typescript type for the return type diff --git a/src/utils/zKey.ts b/src/utils/zKey.ts index 285309a..1f797a5 100644 --- a/src/utils/zKey.ts +++ b/src/utils/zKey.ts @@ -2,10 +2,11 @@ import * as path from 'path'; import * as fs from 'fs'; -const { zKey } = require('snarkjs'); -const { plonk } = require('snarkjs'); -const { getCurveFromName } = require('./curves'); -const util = require('util'); +import { zKey } from 'snarkjs'; +import { plonk } from 'snarkjs'; +import { getCurveFromName } from './curves'; +import util from 'util'; +// eslint-disable-next-line @typescript-eslint/no-var-requires const exec = util.promisify(require('child_process').exec); export const genGrothZKey = async ( diff --git a/tests/circuit.test.ts b/tests/circuit.test.ts index 51655ec..2c0ae9e 100644 --- a/tests/circuit.test.ts +++ b/tests/circuit.test.ts @@ -119,13 +119,13 @@ describe('Circuit test', () => { const vKeyObject = JSON.parse(fs.readFileSync(vKeyPath, 'utf8')); expect( - vKeyObject.hasOwnProperty('protocol') && - vKeyObject.hasOwnProperty('curve') && - vKeyObject.hasOwnProperty('vk_alpha_1') && - vKeyObject.hasOwnProperty('vk_beta_2') && - vKeyObject.hasOwnProperty('vk_gamma_2') && - vKeyObject.hasOwnProperty('vk_delta_2') && - vKeyObject.hasOwnProperty('vk_alphabeta_12'), + Object.prototype.hasOwnProperty.call(vKeyObject, 'protocol') && + Object.prototype.hasOwnProperty.call(vKeyObject, 'curve') && + Object.prototype.hasOwnProperty.call(vKeyObject, 'vk_alpha_1') && + Object.prototype.hasOwnProperty.call(vKeyObject, 'vk_beta_2') && + Object.prototype.hasOwnProperty.call(vKeyObject, 'vk_gamma_2') && + Object.prototype.hasOwnProperty.call(vKeyObject, 'vk_delta_2') && + Object.prototype.hasOwnProperty.call(vKeyObject, 'vk_alphabeta_12'), ).toBe(true); }, 30000); diff --git a/tests/configParser.test.ts b/tests/configParser.test.ts index 23403e8..c176aed 100644 --- a/tests/configParser.test.ts +++ b/tests/configParser.test.ts @@ -4,8 +4,6 @@ import * as fs from 'fs'; import { ConfigParser } from '../src/configParser'; describe('ConfigParser test', () => { - beforeAll(async () => {}); - it('should instantiate configparser successfully', () => { const configPath = `tests/data/${uuidv4()}.json`; const jsonConfig = ` diff --git a/tests/helpers.ts b/tests/helpers.ts index 91ab98b..9a1fef6 100644 --- a/tests/helpers.ts +++ b/tests/helpers.ts @@ -2,11 +2,11 @@ import { ZK_PROOF } from '../types/types'; export const proofIsInValidShape = (p: ZK_PROOF) => { return ( - p.hasOwnProperty('proof') && - p.proof.hasOwnProperty('pi_a') && - p.proof.hasOwnProperty('pi_b') && - p.proof.hasOwnProperty('pi_c') && - p.proof.hasOwnProperty('curve') && - p.proof.hasOwnProperty('protocol') + Object.prototype.hasOwnProperty.call(p, 'proof') && + Object.prototype.hasOwnProperty.call(p.proof, 'pi_a') && + Object.prototype.hasOwnProperty.call(p.proof, 'pi_b') && + Object.prototype.hasOwnProperty.call(p.proof, 'pi_c') && + Object.prototype.hasOwnProperty.call(p.proof, 'curve') && + Object.prototype.hasOwnProperty.call(p.proof, 'protocol') ); };