Skip to content

Commit

Permalink
fix(circuits): use dynamic imports for promisify
Browse files Browse the repository at this point in the history
  • Loading branch information
0xmad committed Aug 6, 2024
1 parent d1f0aa7 commit 20b700d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions packages/circuits/ts/compile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,9 @@ import { type CircomkitConfig, type CircuitConfig, Circomkit } from "circomkit";
import childProcess from "child_process";
import fs from "fs";
import path from "path";
import { promisify } from "util";

import type { CircuitConfigWithName } from "./types";

const execFile = promisify(childProcess.execFile);

/**
* Compile MACI's circuits using circomkit
* and setup the dir structure
Expand Down Expand Up @@ -51,6 +48,9 @@ export const compileCircuits = async (cWitness?: boolean, outputPath?: string):
verbose: false,
});

const { promisify } = await import("util");
const execFile = promisify(childProcess.execFile);

// loop through each circuit config and compile them
// eslint-disable-next-line @typescript-eslint/prefer-for-of
for (let i = 0; i < circuitsConfigs.length; i += 1) {
Expand Down
6 changes: 3 additions & 3 deletions packages/circuits/ts/proofs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,12 @@ import childProcess from "child_process";
import fs from "fs";
import { tmpdir } from "os";
import path from "path";
import { promisify } from "util";

import type { IGenProofOptions, ISnarkJSVerificationKey, FullProveResult } from "./types";
import type { IVkObjectParams } from "maci-domainobjs";

import { cleanThreads, isArm } from "./utils";

const execFile = promisify(childProcess.execFile);

/**
* Generate a zk-SNARK proof
* @dev if running on a intel chip we use rapidsnark for
Expand Down Expand Up @@ -70,6 +67,9 @@ export const genProof = async ({
const jsonData = JSON.stringify(stringifyBigInts(inputs));
await fs.promises.writeFile(inputJsonPath, jsonData);

const { promisify } = await import("util");
const execFile = promisify(childProcess.execFile);

// Generate the witness
await execFile(witnessExePath!, [inputJsonPath, outputWtnsPath]);

Expand Down

0 comments on commit 20b700d

Please sign in to comment.