-
Notifications
You must be signed in to change notification settings - Fork 153
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(contracts): get rid of bash scripts for prebuild command
- Loading branch information
Showing
8 changed files
with
102 additions
and
99 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
#!/usr/bin/env node | ||
import hre from "hardhat"; | ||
|
||
import fs from "fs"; | ||
import path from "path"; | ||
|
||
import { buildPoseidonT3, buildPoseidonT4, buildPoseidonT5, buildPoseidonT6 } from "../ts/buildPoseidon"; | ||
import { genEmptyBallotRootsContract } from "../ts/genEmptyBallotRootsContract"; | ||
import { genZerosContract } from "../ts/genZerosContract"; | ||
|
||
const PATHS = [ | ||
path.resolve(__dirname, "..", "artifacts"), | ||
path.resolve(__dirname, "..", "cache"), | ||
path.resolve(__dirname, "..", "typechain-types"), | ||
]; | ||
|
||
const NOTHING_UP_MY_SLEEVE_MACI_NUMS = 8370432830353022751713833565135785980866757267633941821328460903436894336785n; | ||
const BLANK_STATE_LEAF = 6769006970205099520508948723718471724660867171122235270773600567925038008762n; | ||
const NUM_ZEROS = 33; | ||
|
||
const ZERO_TREES = [ | ||
{ | ||
name: "MerkleBinary0", | ||
zero: 0n, | ||
hashLength: 2, | ||
comment: "Binary tree zeros (0)", | ||
}, | ||
{ | ||
name: "MerkleBinaryMaci", | ||
zero: NOTHING_UP_MY_SLEEVE_MACI_NUMS, | ||
hashLength: 2, | ||
comment: "Binary tree zeros (Keccak hash of 'Maci')", | ||
}, | ||
{ | ||
name: "MerkleQuinary0", | ||
zero: 0n, | ||
hashLength: 5, | ||
comment: "Quinary tree zeros (0)", | ||
}, | ||
{ | ||
name: "MerkleQuinaryMaci", | ||
zero: NOTHING_UP_MY_SLEEVE_MACI_NUMS, | ||
hashLength: 5, | ||
comment: "Quinary tree zeros (Keccak hash of 'Maci')", | ||
}, | ||
{ | ||
name: "MerkleQuinaryBlankSl", | ||
zero: BLANK_STATE_LEAF, | ||
hashLength: 5, | ||
comment: "Quinary tree zeros (hash of a blank state leaf)", | ||
}, | ||
]; | ||
|
||
async function main(): Promise<void> { | ||
await Promise.all(PATHS.map((filepath) => fs.existsSync(filepath) && fs.promises.rm(filepath, { recursive: true }))); | ||
|
||
await Promise.all( | ||
ZERO_TREES.map(({ name, zero, hashLength, comment }) => { | ||
const text = genZerosContract({ | ||
name, | ||
zeroVal: zero, | ||
hashLength, | ||
numZeros: NUM_ZEROS, | ||
comment, | ||
useSha256: false, | ||
subDepth: 0, | ||
}); | ||
return fs.promises.writeFile(path.resolve(__dirname, "..", "contracts/trees/zeros", `${name}.sol`), `${text}\n`); | ||
}), | ||
); | ||
|
||
genEmptyBallotRootsContract(); | ||
|
||
await hre.run("compile"); | ||
|
||
await Promise.all([buildPoseidonT3(), buildPoseidonT4(), buildPoseidonT5(), buildPoseidonT6()]); | ||
} | ||
|
||
main(); |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters