Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(circuits): use dynamic imports for promisify #1742

Merged
merged 1 commit into from
Aug 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading