Skip to content

Commit

Permalink
Merge pull request #1787 from privacy-scaling-explorations/chore/move…
Browse files Browse the repository at this point in the history
…-build-poseidon

chore(contracts): move poseidon creation to compile script
  • Loading branch information
0xmad committed Aug 19, 2024
2 parents 0311830 + 1e9f790 commit a7b8b6a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 14 deletions.
13 changes: 12 additions & 1 deletion packages/contracts/scripts/compileSol.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { poseidonContract } from "circomlibjs";
import hre from "hardhat";

import fs from "fs";
import path from "path";

import { buildPoseidonT3, buildPoseidonT4, buildPoseidonT5, buildPoseidonT6 } from "../ts/buildPoseidon";
import { genZerosContract } from "../ts/genZerosContract";

const PATHS = [
Expand Down Expand Up @@ -55,6 +55,17 @@ const ZERO_TREES = [
},
];

type ExtendedHre = typeof hre & { overwriteArtifact: (name: string, code: unknown) => Promise<void> };

const buildPoseidon = async (numInputs: number) => {
await (hre as ExtendedHre).overwriteArtifact(`PoseidonT${numInputs + 1}`, poseidonContract.createCode(numInputs));
};

const buildPoseidonT3 = (): Promise<void> => buildPoseidon(2);
const buildPoseidonT4 = (): Promise<void> => buildPoseidon(3);
const buildPoseidonT5 = (): Promise<void> => buildPoseidon(4);
const buildPoseidonT6 = (): Promise<void> => buildPoseidon(5);

async function main(): Promise<void> {
await Promise.all(PATHS.map((filepath) => fs.existsSync(filepath) && fs.promises.rm(filepath, { recursive: true })));

Expand Down
13 changes: 0 additions & 13 deletions packages/contracts/ts/buildPoseidon.ts

This file was deleted.

0 comments on commit a7b8b6a

Please sign in to comment.