Skip to content

Commit

Permalink
fix: no-await-in-loop removed from eslintConfig and explict added in …
Browse files Browse the repository at this point in the history
…file to disable
  • Loading branch information
LijuJoseJJ committed Jun 10, 2021
1 parent bad99e8 commit cd49225
Show file tree
Hide file tree
Showing 14 changed files with 29 additions and 12 deletions.
1 change: 0 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ module.exports = {
'import/extensions': 'off',
'no-restricted-syntax': 'off',
'no-plusplus': 'off',
'no-await-in-loop': 'off',
'import/no-extraneous-dependencies': ['error', { devDependencies: ['**/test/*'] }],
},
globals: {
Expand Down
2 changes: 2 additions & 0 deletions nightfall-client/src/services/commitment-storage.mjs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/* eslint-disable no-await-in-loop */

/**
Logic for storing and retrieving commitments from a mongo DB. Abstracted from
deposit/transfer/withdraw
Expand Down
2 changes: 1 addition & 1 deletion nightfall-client/src/services/transfer.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ async function transfer(transferParams) {
ercAddress,
tokenId,
value: values[i],
salt: await rand(ZKP_KEY_LENGTH),
salt: await rand(ZKP_KEY_LENGTH), // eslint-disable-line no-await-in-loop
}),
);
}
Expand Down
2 changes: 2 additions & 0 deletions nightfall-client/test/http.mjs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/* eslint-disable no-await-in-loop */

import chai from 'chai';
import chaiHttp from 'chai-http';
import chaiAsPromised from 'chai-as-promised';
Expand Down
4 changes: 3 additions & 1 deletion nightfall-client/test/tx-gas.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ describe('Testing the http API', () => {
blockSubmissionFunction = (a, b, c, d, e) => submitTransaction(a, b, c, d, e);
it('should deposit some crypto into a ZKP commitment', async () => {
for (let i = 0; i < TRANSACTIONS_PER_BLOCK; i++) {
// eslint-disable-next-line no-await-in-loop
const res = await chai.request(url).post('/deposit').send({
ercAddress,
tokenId,
Expand All @@ -162,12 +163,13 @@ describe('Testing the http API', () => {
txDataToSign = res.body.txDataToSign;
expect(txDataToSign).to.be.a('string');
// now we need to sign the transaction and send it to the blockchain
// eslint-disable-next-line no-await-in-loop
const receipt = await submitTransaction(txDataToSign, privateKey, shieldAddress, gas, fee);
expect(receipt).to.have.property('transactionHash');
expect(receipt).to.have.property('blockHash');
console.log(`Gas used was ${Number(receipt.gasUsed)}`);
// give Timber time to respond to the blockchain event
await new Promise(resolve => setTimeout(resolve, 3000));
await new Promise(resolve => setTimeout(resolve, 3000)); // eslint-disable-line no-await-in-loop
}
});
});
Expand Down
2 changes: 2 additions & 0 deletions nightfall-deployer/src/circuit-setup.mjs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/* eslint-disable no-await-in-loop */

/**
Module to set up all of the circuits contained in circuits/ to a zokrates
instance. Note, we don't need to deploy the circuits through a zokrates microservice http interface because we're going to create the volume that the zokrates microservice mounts to hold its circuits, so we'll just pop them straight in there. No one will mind.
Expand Down
4 changes: 2 additions & 2 deletions nightfall-deployer/src/utils/contract.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ export async function waitForContract(contractName) {
while (errorCount < 50) {
try {
error = undefined;
const address = await getContractAddress(contractName);
const address = await getContractAddress(contractName); // eslint-disable-line no-await-in-loop
logger.debug(`${contractName} contract address is ${address}`);
if (address === undefined) throw new Error(`${contractName} contract address was undefined`);
instance = getContractInstance(contractName, address);
Expand All @@ -109,7 +109,7 @@ export async function waitForContract(contractName) {
error = err;
errorCount++;
logger.warn(`Unable to get a ${contractName} contract instance will try again in 3 seconds`);
await new Promise(resolve => setTimeout(() => resolve(), 3000));
await new Promise(resolve => setTimeout(() => resolve(), 3000)); // eslint-disable-line no-await-in-loop
}
}
if (error) throw error;
Expand Down
2 changes: 2 additions & 0 deletions nightfall-optimist/src/event-handlers/subscribe.mjs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/* eslint-disable no-await-in-loop */

/**
* Module to subscribe to blockchain events
*/
Expand Down
2 changes: 2 additions & 0 deletions nightfall-optimist/src/services/block-assembler.mjs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/* eslint-disable no-await-in-loop */

/**
This module does all of the heaving lifting for a Proposer: It assembles blocks
from posted transactions and proposes these blocks.
Expand Down
2 changes: 1 addition & 1 deletion nightfall-optimist/src/services/check-block.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ async function checkBlock(block, transactions) {
// check if the transaction is valid - transaction type, public input hash and proof verification are all checked
for (let i = 0; i < transactions.length; i++) {
try {
await checkTransaction(transactions[i]);
await checkTransaction(transactions[i]); // eslint-disable-line no-await-in-loop
} catch (err) {
throw new BlockError(
`The transaction check failed with error: ${err.message}`,
Expand Down
2 changes: 2 additions & 0 deletions nightfall-optimist/src/services/state-sync.mjs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/* eslint-disable no-await-in-loop */

import config from 'config';
import { getContractInstance } from '../utils/contract.mjs';
import blockProposedEventHandler from '../event-handlers/block-proposed.mjs';
Expand Down
1 change: 0 additions & 1 deletion zokrates-worker/src/services/generateKeys.mjs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import fs from 'fs';
import path from 'path';
import { compile, setup, extractVk } from '../zokrates-lib/index.mjs';
import rabbitmq from '../utils/rabbitmq.mjs';
import logger from '../utils/logger.mjs';

export default async function generateKeys({
Expand Down
6 changes: 3 additions & 3 deletions zokrates-worker/src/services/generateProof.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ import logger from '../utils/logger.mjs';

const unlink = util.promisify(fs.unlink);

export default async function generateProof({
export default async ({
folderpath,
inputs,
transactionInputs,
outputDirectoryPath,
proofFileName,
backend = 'ark',
provingScheme = 'gm17',
}) {
}) => {
const outputPath = `./output`;
let proof;
let publicInputs;
Expand Down Expand Up @@ -82,4 +82,4 @@ export default async function generateProof({
transactionInputs,
type: folderpath,
};
}
};
9 changes: 7 additions & 2 deletions zokrates-worker/src/zokrates-lib/verify.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import childProcess from 'child_process';
import fs from 'fs';
import jsonfile from 'jsonfile';

import { deleteSingleFile } from '../utils/filing.mjs';
Expand Down Expand Up @@ -31,7 +30,13 @@ const { writeFile } = jsonfile;
* @param {String} [options.fileName=proof.json] - Name of JSON proof file ()
* @returns {Object} JSON of the proof.
*/
export default async function verify(vk, proof, provingScheme = 'gm17', backend = 'ark', curve = 'bn128') {
export default async function verify(
vk,
proof,
provingScheme = 'gm17',
backend = 'ark',
curve = 'bn128',
) {
// we've provided a json proof and a verifying key but Zokrates needs to read
// these from a file. Thus we should write them to temporary unique files.
// Note: Math.random is used to create unique filename to avoid error at concurrent execution.
Expand Down

0 comments on commit cd49225

Please sign in to comment.