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

Commit f60734a

Browse files
AgusVelez5scnale
authored andcommitted
Refactor verification scripts
1 parent 128d952 commit f60734a

File tree

8 files changed

+263
-66
lines changed

8 files changed

+263
-66
lines changed

deployment/config/config-types.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ export type RouterEndpointConfig = {
1111
}
1212

1313
export type TokenRouterConfiguration = {
14-
// EVM Chain ID of the token router configuration
15-
chainId: number;
14+
// Wormhole Chain ID of the token router configuration
15+
chainId: ChainId;
1616

1717
// Immutable values
1818
matchingEngineMintRecipient: string;
@@ -32,8 +32,8 @@ export type TokenRouterConfiguration = {
3232
};
3333

3434
export type MatchingEngineConfiguration = {
35-
// EVM Chain ID of the matching engine configuration
36-
chainId: number;
35+
// Wormhole Chain ID of the matching engine configuration
36+
chainId: ChainId;
3737

3838
// Immutable values
3939
userPenaltyRewardBps: string;

deployment/helpers/env.ts

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { ChainConfig, ChainInfo, ContractsJson, Dependencies, Ecosystem } from "
55
import { getSigner } from "./evm";
66
// TODO: support different env files
77
import 'dotenv/config';
8+
import { ChainId } from "@wormhole-foundation/sdk-base";
89

910
export const env = getEnv("ENV");
1011
export const contracts = loadContracts();
@@ -39,46 +40,46 @@ export function getEnv(env: string): string {
3940
return v;
4041
}
4142

42-
export async function getChainConfig<T extends ChainConfig>(filename: string, evmChainId: number): Promise<T> {
43+
export async function getChainConfig<T extends ChainConfig>(filename: string, whChainId: ChainId): Promise<T> {
4344
const scriptConfig: T[] = await loadJson(filename);
4445

45-
const chainConfig = scriptConfig.find((x) => x.chainId == evmChainId);
46+
const chainConfig = scriptConfig.find((x) => x.chainId == whChainId);
4647

4748
if (!chainConfig) {
48-
throw Error(`Failed to find chain config for chain ${evmChainId}`);
49+
throw Error(`Failed to find chain config for chain ${whChainId}`);
4950
}
5051

5152
return chainConfig;
5253
}
5354

54-
export function getContractAddress(contractName: string, evmChainId: number): string {
55-
const contract = contracts[contractName]?.find((c) => c.chainId === evmChainId)?.address;
55+
export function getContractAddress(contractName: string, whChainId: ChainId): string {
56+
const contract = contracts[contractName]?.find((c) => c.chainId === whChainId)?.address;
5657

5758
if (!contract) {
58-
throw new Error(`No ${contractName} contract found for chain ${evmChainId}`);
59+
throw new Error(`No ${contractName} contract found for chain ${whChainId}`);
5960
}
6061

6162
if (!utils.isAddress(contract) && !validateSolAddress(contract)){
62-
throw new Error(`Invalid address for ${contractName} contract found for chain ${evmChainId}`);
63+
throw new Error(`Invalid address for ${contractName} contract found for chain ${whChainId}`);
6364
}
6465

6566
return contract;
6667
}
6768

68-
export function getDependencyAddress(dependencyName: string, evmChainId: number): string {
69-
const chainDependencies = dependencies.find((d) => d.chainId === evmChainId);
69+
export function getDependencyAddress(dependencyName: string, whChainId: ChainId): string {
70+
const chainDependencies = dependencies.find((d) => d.chainId === whChainId);
7071

7172
if (chainDependencies === undefined ) {
72-
throw new Error(`No dependencies found for chain ${evmChainId}`);
73+
throw new Error(`No dependencies found for chain ${whChainId}`);
7374
}
7475

7576
const dependency = chainDependencies[dependencyName as keyof Dependencies] as string;
7677
if (dependency === undefined) {
77-
throw new Error(`No dependency found for ${dependencyName} for chain ${evmChainId}`);
78+
throw new Error(`No dependency found for ${dependencyName} for chain ${whChainId}`);
7879
}
7980

8081
if (!utils.isAddress(dependency) && !validateSolAddress(dependency)){
81-
throw new Error(`Invalid address for ${dependencyName} dependency found for chain ${evmChainId}`);
82+
throw new Error(`Invalid address for ${dependencyName} dependency found for chain ${whChainId}`);
8283
}
8384

8485
return dependency;
@@ -94,30 +95,30 @@ export async function getContractInstance(
9495
return factory.connect(contractAddress, signer);
9596
}
9697

97-
export function getDeploymentArgs(contractName: string, evmChainId: number): any[] {
98-
const constructorArgs = contracts[contractName]?.find((c) => c.chainId === evmChainId)?.constructorArgs;
98+
export function getDeploymentArgs(contractName: string, whChainId: ChainId): any[] {
99+
const constructorArgs = contracts[contractName]?.find((c) => c.chainId === whChainId)?.constructorArgs;
99100

100101
if (!constructorArgs) {
101-
throw new Error(`No constructorArgs found for ${contractName} contract for chain ${evmChainId}`);
102+
throw new Error(`No constructorArgs found for ${contractName} contract for chain ${whChainId}`);
102103
}
103104

104105
return constructorArgs;
105106
}
106107

107-
export function writeDeployedContract(evmChainId: number, contractName: string, address: string, constructorArgs: any[] ) {
108+
export function writeDeployedContract(whChainId: ChainId, contractName: string, address: string, constructorArgs: any[] ) {
108109
const contracts = loadContracts();
109110
if (!contracts[contractName]) {
110-
contracts[contractName] = [{ chainId: evmChainId, address, constructorArgs }];
111+
contracts[contractName] = [{ chainId: whChainId, address, constructorArgs }];
111112
}
112113

113-
else if (!contracts[contractName].find((c) => c.chainId === evmChainId)) {
114-
contracts[contractName].push({ chainId: evmChainId, address, constructorArgs });
114+
else if (!contracts[contractName].find((c) => c.chainId === whChainId)) {
115+
contracts[contractName].push({ chainId: whChainId, address, constructorArgs });
115116
}
116117

117118
else {
118119
contracts[contractName] = contracts[contractName].map((c) => {
119-
if (c.chainId === evmChainId) {
120-
return { chainId: evmChainId, address, constructorArgs };
120+
if (c.chainId === whChainId) {
121+
return { chainId: whChainId, address, constructorArgs };
121122
}
122123

123124
return c;

deployment/helpers/interfaces.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,21 @@
1+
import { ChainId } from "@wormhole-foundation/sdk-base";
2+
import { SolanaLedgerSigner } from "@xlabs-xyz/ledger-signer-solana";
13
import { ethers } from "ethers";
24

35
export type EvmScriptCb = (chain: ChainInfo, signer: ethers.Signer, logFn: LoggerFn) => Promise<void>;
6+
export type SolanaScriptCb = (chain: ChainInfo, signer: SolanaLedgerSigner, logFn: LoggerFn) => Promise<void>;
47

58
export type LoggerFn = (...args: any[]) => void;
69

710
export type ChainInfo = {
811
name: string;
9-
chainId: number; // EVM ChainId
12+
chainId: ChainId; // Wormhole ChainId
1013
rpc: string;
11-
type: "Mainnet" | "Testnet" | "Devnet";
12-
externalId?: string;
14+
externalId?: string; // Native ChainId
1315
};
1416

1517
export type Deployment = {
16-
chainId: number; // EVM ChainId
18+
chainId: number; // Wormhole ChainId
1719
address: string;
1820
constructorArgs?: any[];
1921
};
@@ -32,7 +34,7 @@ export type Ecosystem = {
3234
export type ContractsJson = Record<string, Deployment[]>;
3335

3436
export interface ChainConfig {
35-
chainId: number; // EVM ChainId
37+
chainId: ChainId; // Wormhole ChainId
3638
}
3739

3840
export interface Dependencies extends ChainConfig {

0 commit comments

Comments
 (0)