diff --git a/.eslintrc.json b/.eslintrc.json index c28e3e5..4e28574 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -1,6 +1,7 @@ { "env": { "node": true, + "browser": true, "es6": true, "mocha": true }, diff --git a/cli.js b/cli.js index 49e1b66..9f4edbd 100755 --- a/cli.js +++ b/cli.js @@ -79,7 +79,7 @@ async function withdraw(note, receiver) { async function init() { let contractJson if (inBrowser) { - web3 = new Web3(window.web3.currentProvider, null, {transactionConfirmationBlocks: 1}) + web3 = new Web3(window.web3.currentProvider, null, { transactionConfirmationBlocks: 1 }) contractJson = await (await fetch('build/contracts/Mixer.json')).json() circuit = await (await fetch('build/circuits/withdraw.json')).json() proving_key = await (await fetch('build/circuits/withdraw_proving_key.bin')).arrayBuffer() @@ -87,7 +87,7 @@ async function init() { AMOUNT = 1e18 EMPTY_ELEMENT = 0 } else { - web3 = new Web3('http://localhost:8545', null, {transactionConfirmationBlocks: 1}) + web3 = new Web3('http://localhost:8545', null, { transactionConfirmationBlocks: 1 }) contractJson = require('./build/contracts/Mixer.json') circuit = require('./build/circuits/withdraw.json') proving_key = fs.readFileSync('build/circuits/withdraw_proving_key.bin').buffer @@ -140,19 +140,19 @@ if (inBrowser) { switch (args[0]) { case 'deposit': if (args.length === 1) { - init().then(async () => deposit()).then(() => process.exit(0)).catch(err => {console.log(err); process.exit(1)}) + init().then(() => deposit()).then(() => process.exit(0)).catch(err => {console.log(err); process.exit(1)}) } else printHelp(1) break case 'balance': if (args.length === 2 && /^0x[0-9a-fA-F]{40}$/.test(args[1])) { - init().then(async () => getBalance(args[1])).then(() => process.exit(0)).catch(err => {console.log(err); process.exit(1)}) + init().then(() => getBalance(args[1])).then(() => process.exit(0)).catch(err => {console.log(err); process.exit(1)}) } break case 'withdraw': if (args.length === 3 && /^0x[0-9a-fA-F]{128}$/.test(args[1]) && /^0x[0-9a-fA-F]{40}$/.test(args[2])) { - init().then(async () => withdraw(args[1], args[2])).then(() => process.exit(0)).catch(err => {console.log(err); process.exit(1)}) + init().then(() => withdraw(args[1], args[2])).then(() => process.exit(0)).catch(err => {console.log(err); process.exit(1)}) } else printHelp(1) diff --git a/migrations/1_initial_migration.js b/migrations/1_initial_migration.js index a7a4fdb..c0dea38 100644 --- a/migrations/1_initial_migration.js +++ b/migrations/1_initial_migration.js @@ -1,3 +1,4 @@ +/* global artifacts */ const Migrations = artifacts.require('Migrations') module.exports = function(deployer) { diff --git a/migrations/2_deploy_mimc.js b/migrations/2_deploy_mimc.js index a299f10..6c0b797 100644 --- a/migrations/2_deploy_mimc.js +++ b/migrations/2_deploy_mimc.js @@ -1,3 +1,4 @@ +/* global artifacts */ const path = require('path') const mimcGenContract = require('circomlib/src/mimcsponge_gencontract.js') diff --git a/migrations/3_deploy_verifier.js b/migrations/3_deploy_verifier.js index edd1a94..82c926f 100644 --- a/migrations/3_deploy_verifier.js +++ b/migrations/3_deploy_verifier.js @@ -1,3 +1,4 @@ +/* global artifacts */ require('dotenv').config() const Verifier = artifacts.require('Verifier') diff --git a/migrations/4_deploy_mixer.js b/migrations/4_deploy_mixer.js index b605fb6..59996ca 100644 --- a/migrations/4_deploy_mixer.js +++ b/migrations/4_deploy_mixer.js @@ -1,3 +1,4 @@ +/* global artifacts */ require('dotenv').config({ path: '../.env' }) const Mixer = artifacts.require('Mixer') const Verifier = artifacts.require('Verifier') diff --git a/package.json b/package.json index a5a5d52..118f7ee 100644 --- a/package.json +++ b/package.json @@ -13,7 +13,8 @@ "test": "npx truffle test", "migrate": "npx truffle migrate --network kovan --reset", "migrate:dev": "npx truffle migrate --network development --reset", - "browserify": "npx browserify cli.js -o index.js --exclude worker_threads" + "browserify": "npx browserify cli.js -o index.js --exclude worker_threads", + "eslint": "npx eslint ." }, "keywords": [], "author": "", diff --git a/relay/relay.js b/relay/relay.js index 25a7828..044824a 100644 --- a/relay/relay.js +++ b/relay/relay.js @@ -1,4 +1,5 @@ let bigInt = require('snarkjs/src/bigint') +const utils = require('../scripts/utils') const express = require('express') const app = express() diff --git a/test/MerkleTreeWithHistory.test.js b/test/MerkleTreeWithHistory.test.js index 8fd5a72..e5241a0 100644 --- a/test/MerkleTreeWithHistory.test.js +++ b/test/MerkleTreeWithHistory.test.js @@ -1,4 +1,4 @@ -/*global artifacts, web3, contract, assert*/ +/* global artifacts, web3, contract, assert */ require('chai') .use(require('bn-chai')(web3.utils.BN)) .use(require('chai-as-promised'))