Skip to content
This repository was archived by the owner on Jun 16, 2025. It is now read-only.

Commit 61cae3b

Browse files
AgusVelez5scnale
authored andcommitted
Finish bytecode verification script
1 parent 2ba338f commit 61cae3b

File tree

5 files changed

+56
-27
lines changed

5 files changed

+56
-27
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"<wormhole-chain-id-1>": { "etherscan": "<key>", "blockscout": {"key": "<key>", "apiUrl": "https://<chain>.blockscout.com/api"}, "sourcify": ""},
3+
"<wormhole-chain-id-2>": { "etherscan": "<key>", "blockscout": {"key": "<key>", "apiUrl": "https://<chain>.blockscout.com/api"}},
4+
"<wormhole-chain-id-3>": { "blockscout": {"key": "<key>", "apiUrl": "https://<chain>.blockscout.com/api"}, "sourcify": ""},
5+
"<wormhole-chain-id-4>": { "etherscan": "<key>", "sourcify": ""},
6+
"<wormhole-chain-id-5>": { "etherscan": "<key>"}
7+
}

deployment/helpers/evm.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { LedgerSigner } from "@xlabs-xyz/ledger-signer";
22
import { ethers } from "ethers";
33
import { ChainInfo, ecosystemChains, EvmScriptCb, getEnv } from "./index";
4+
import { toChain } from "@wormhole-foundation/sdk-base";
45

56
export async function runOnEvms(scriptName: string, cb: EvmScriptCb) {
67
const chains = evmOperatingChains();
@@ -10,7 +11,7 @@ export async function runOnEvms(scriptName: string, cb: EvmScriptCb) {
1011
const result = chains.map(async chain => {
1112
const log = (...args: any[]) => console.log(`[${chain.chainId}]`, ...args);
1213
const signer = await getSigner(chain);
13-
log(`Starting script. Signer: ${await signer.getAddress()}`);
14+
log(`Starting script. Signer: ${await signer.getAddress()}. Chain: ${toChain(chain.chainId)}`);
1415

1516
try {
1617
await cb(chain, signer, log);

deployment/helpers/utils.ts

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,22 +49,37 @@ export function flattenObject(obj: Record<string, any>, parentKey = '', result:
4949
return result;
5050
}
5151

52-
export function getVerifyCommand(
52+
export function getVerifyCommand({
53+
chain,
54+
contractName,
55+
contractPath,
56+
contractAddress,
57+
constructorSignature,
58+
constructorArgs,
59+
verifier,
60+
verifierUrl,
61+
apiKey
62+
}: {
5363
chain: ChainInfo,
5464
contractName: string,
5565
contractPath: string,
5666
contractAddress: string,
5767
constructorSignature: string,
5868
constructorArgs: any[],
5969
verifier: string,
70+
verifierUrl?: string,
6071
apiKey?: string
61-
): string {
72+
}): string {
6273
if (chain.externalId === undefined)
6374
throw new Error(`Chain ${chain.chainId} does not have an external ID`);
6475

76+
if (verifier === "blockscout" && verifierUrl === undefined)
77+
throw new Error(`Verifier URL is required for Blockscout verifier`);
78+
6579
let command = `
6680
forge verify-contract ${contractAddress} ${contractPath}:${contractName} \
6781
--verifier ${verifier} \
82+
${ verifier === "blockscout" ? `--verifier-url ${verifierUrl}` : ''} \
6883
--watch --constructor-args $(cast abi-encode "${constructorSignature}" "${constructorArgs.join('" "')}") \
6984
--chain-id ${chain.externalId} \
7085
${ apiKey === undefined || apiKey === "" ? '' : `--etherscan-api-key ${apiKey}` }

deployment/scripts/evm/TokenRouter/bytecode-verification-token-router.ts

Lines changed: 29 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -7,48 +7,53 @@ evm.runOnEvms("bytecode-verification-token-router", async (chain, signer, log) =
77
// The root path of the foundry project
88
const rootPath = path.resolve('../evm/');
99

10-
const verifiersData = verificationApiKeys.find((x) => x.chainId == chain.chainId);
11-
const verifiers = flattenObject(verifiersData!);
12-
delete verifiers.chainId;
10+
const verifiers = verificationApiKeys[chain.chainId];
11+
if (!verifiers) {
12+
log(chalk.red(`No verifiers found for chain ${chain.chainId}`));
13+
return;
14+
}
1315

14-
for (let [name, apiKey] of Object.entries(verifiers)) {
15-
name = name.split("-")[0];
16+
for (let [verifier, data] of Object.entries(verifiers)) {
17+
const apiKey = typeof data === 'string' ? data : data.key;
18+
const verifierUrl = typeof data === 'string' ? undefined : data.apiUrl;
1619

1720
// Implementation data
1821
const implementationName = "TokenRouter";
1922
const implementationPath = 'src/TokenRouter/TokenRouter.sol';
2023
const implementationAddress = getContractAddress("TokenRouterImplementation", chain.chainId);
2124
const implementationDeploymentArgs = getDeploymentArgs("TokenRouterImplementation", chain.chainId);
2225
const implementationConstructorSignature = "constructor(address,address,address,uint16,bytes32,bytes32,uint32)";
23-
const verifyImplementationCommand = getVerifyCommand(
26+
const verifyImplementationCommand = getVerifyCommand({
2427
chain,
25-
implementationName,
26-
implementationPath,
27-
implementationAddress,
28-
implementationConstructorSignature,
29-
implementationDeploymentArgs,
30-
name,
28+
contractName: implementationName,
29+
contractPath: implementationPath,
30+
contractAddress: implementationAddress,
31+
constructorSignature: implementationConstructorSignature,
32+
constructorArgs: implementationDeploymentArgs,
33+
verifier,
34+
verifierUrl,
3135
apiKey
32-
);
36+
});
3337

3438
// Proxy data
3539
const proxyName = "ERC1967Proxy";
3640
const proxyPath = 'lib/openzeppelin-contracts/contracts/proxy/ERC1967/ERC1967Proxy.sol';
37-
const proxyAddress = getContractAddress("MatchingEngineProxy", chain.chainId);
38-
const proxyDeploymentArgs = getDeploymentArgs("MatchingEngineProxy", chain.chainId);
41+
const proxyAddress = getContractAddress("TokenRouterProxy", chain.chainId);
42+
const proxyDeploymentArgs = getDeploymentArgs("TokenRouterProxy", chain.chainId);
3943
const proxyConstructorSignature = "constructor(address,bytes)";
40-
const verifyProxyCommand = getVerifyCommand(
44+
const verifyProxyCommand = getVerifyCommand({
4145
chain,
42-
proxyName,
43-
proxyPath,
44-
proxyAddress,
45-
proxyConstructorSignature,
46-
proxyDeploymentArgs,
47-
name,
46+
contractName: proxyName,
47+
contractPath: proxyPath,
48+
contractAddress: proxyAddress,
49+
constructorSignature: proxyConstructorSignature,
50+
constructorArgs: proxyDeploymentArgs,
51+
verifier,
52+
verifierUrl,
4853
apiKey
49-
);
54+
});
5055

51-
log(chalk.green(`Verifying bytecode on ${name}...`));
56+
log(chalk.green(`Verifying bytecode on ${verifier}...`));
5257
log(chalk.green("Verifying implementation bytecode..."));
5358
execSync(verifyImplementationCommand, { stdio: "inherit", cwd: rootPath });
5459
console.log()

0 commit comments

Comments
 (0)