From 8ec36c4d65329b40d7e232861c63208761d73b0a Mon Sep 17 00:00:00 2001 From: ctrlc03 <93448202+ctrlc03@users.noreply.github.com> Date: Thu, 18 Jan 2024 13:07:32 +0000 Subject: [PATCH] fix(cli): prioritize contract addresses params do no throw when the contract addresses file is not present but a contract address has been provided fix #1039 --- cli/testScript.sh | 12 ++++++------ cli/ts/commands/proveOnChain.ts | 2 +- cli/ts/utils/storage.ts | 7 +++++-- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/cli/testScript.sh b/cli/testScript.sh index 96ad884273..c14199c1b5 100755 --- a/cli/testScript.sh +++ b/cli/testScript.sh @@ -8,8 +8,8 @@ node build/ts/index.js setVerifyingKeys \ --msg-tree-depth 2 \ --vote-option-tree-depth 2 \ --msg-batch-depth 1 \ - --process-messages-zkey ./zkeys/ProcessMessages_10-2-1-2_test.0.zkey \ - --tally-votes-zkey ./zkeys/TallyVotes_10-1-2_test.0.zkey + --process-messages-zkey ./zkeys/ProcessMessages_10-2-1-2_test/ProcessMessages_10-2-1-2_test.0.zkey \ + --tally-votes-zkey ./zkeys/TallyVotes_10-1-2_test/TallyVotes_10-1-2_test.0.zkey node build/ts/index.js create -s 10 node build/ts/index.js deployPoll \ --pubkey macipk.ea638a3366ed91f2e955110888573861f7c0fc0bb5fb8b8dca9cd7a08d7d6b93 \ @@ -38,12 +38,12 @@ node build/ts/index.js mergeMessages --poll-id 0 node build/ts/index.js genProofs \ --privkey macisk.1751146b59d32e3c0d7426de411218172428263f93b2fc4d981c036047a4d8c0 \ --poll-id 0 \ - --process-zkey ./zkeys/ProcessMessages_10-2-1-2_test.0.zkey \ - --tally-zkey ./zkeys/TallyVotes_10-1-2_test.0.zkey \ + --process-zkey ./zkeys/ProcessMessages_10-2-1-2_test/ProcessMessages_10-2-1-2_test.0.zkey \ + --tally-zkey ./zkeys/TallyVotes_10-1-2_test/TallyVotes_10-1-2_test.0.zkey \ --tally-file tally.json \ --output proofs/ \ - -tw ./zkeys/TallyVotes_10-1-2_test_js/TallyVotes_10-1-2_test.wasm \ - -pw ./zkeys/ProcessMessages_10-2-1-2_test_js/ProcessMessages_10-2-1-2_test.wasm \ + -tw ./zkeys/TallyVotes_10-1-2_test/TallyVotes_10-1-2_test_js/TallyVotes_10-1-2_test.wasm \ + -pw ./zkeys/ProcessMessages_10-2-1-2_test/ProcessMessages_10-2-1-2_test_js/ProcessMessages_10-2-1-2_test.wasm \ -w true node build/ts/index.js proveOnChain \ --poll-id 0 \ diff --git a/cli/ts/commands/proveOnChain.ts b/cli/ts/commands/proveOnChain.ts index 4704cbce5c..445ba70df3 100644 --- a/cli/ts/commands/proveOnChain.ts +++ b/cli/ts/commands/proveOnChain.ts @@ -210,7 +210,7 @@ export const proveOnChain = async ( quiet, error( `The proof files inside ${proofDir} do not have the correct number of message processign proofs` + - `(expected ${totalMessageBatches}, got ${numProcessProofs}.`, + `(expected ${totalMessageBatches}, got ${numProcessProofs}).`, ), ); } diff --git a/cli/ts/utils/storage.ts b/cli/ts/utils/storage.ts index 0ef7ce72be..8e7fc3b16a 100644 --- a/cli/ts/utils/storage.ts +++ b/cli/ts/utils/storage.ts @@ -38,8 +38,11 @@ export const storeContractAddress = (contractName: string, address: string): voi * @returns the contract address or a undefined it it does not exist */ export const readContractAddress = (contractName: string): string => { - const contractAddrs = readJSONFile(contractAddressesStore); - return contractAddrs[contractName] || ""; + try { + return readJSONFile(contractAddressesStore)[contractName] || ""; + } catch (error) { + return ""; + } }; /**