|
1 | 1 | import {relative, dirname} from 'node:path';
|
| 2 | +import {readFileSync} from 'node:fs'; |
2 | 3 |
|
3 | 4 | import { isHex } from 'viem';
|
4 | 5 | import * as chains from 'viem/chains';
|
@@ -83,6 +84,41 @@ export async function deploy(file, chainId, options) {
|
83 | 84 | process.exit(0);
|
84 | 85 | }
|
85 | 86 |
|
| 87 | +export async function verifyMulti(file, options) { |
| 88 | + options = await loadConfig(options); |
| 89 | + const parsed = JSON.parse(readFileSync(file, 'utf8')); |
| 90 | + const event = { |
| 91 | + payload: { |
| 92 | + ...parsed, |
| 93 | + action: 'verifyCircomMulti', |
| 94 | + }, |
| 95 | + }; |
| 96 | + console.log(`# Verifying groth16 multi-verifier...`); |
| 97 | + |
| 98 | + const response = await fetch(options.config.serverURL, { |
| 99 | + method: 'POST', |
| 100 | + headers: { |
| 101 | + 'Content-Type': 'application/json', |
| 102 | + }, |
| 103 | + body: JSON.stringify(event), |
| 104 | + }); |
| 105 | + if (!response.ok && response.status !== 400) { |
| 106 | + throw new Error('Network response was not ok'); |
| 107 | + } |
| 108 | + const data = await response.json(); |
| 109 | + const body = 'body' in data ? JSON.parse(data.body) : data; |
| 110 | + if('errorType' in body) { |
| 111 | + throw new Error(`Verification error: ${body.errorMessage}`); |
| 112 | + } |
| 113 | + |
| 114 | + if(body && body.status === 'verified') { |
| 115 | + console.log(`# Completed successfully!`); |
| 116 | + console.log(`\nhttps://circuitscan.org/chain/${parsed.deployed.chainId}/address/${parsed.deployed.address}`); |
| 117 | + } else { |
| 118 | + console.log(`# Verification failed.`); |
| 119 | + } |
| 120 | +} |
| 121 | + |
86 | 122 | function viemChain(nameOrId) {
|
87 | 123 | if(isNaN(nameOrId)) {
|
88 | 124 | return chains[nameOrId];
|
|
0 commit comments