Skip to content

Commit a16b512

Browse files
committed
feat: update ZKsync specific abis to imported instead of hardcoded
1 parent 875cd3d commit a16b512

File tree

4 files changed

+26
-15
lines changed

4 files changed

+26
-15
lines changed

core/tests/ts-integration/src/constants.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,3 +58,6 @@ export const ArtifactL1AssetRouter = readContract(`${ARTIFACTS_PATH}`, 'L1AssetR
5858
export const ArtifactL1AssetTracker = readContract(`${ARTIFACTS_PATH}`, 'L1AssetTracker');
5959
export const ArtifactL2AssetTracker = readContract(`${ARTIFACTS_PATH}`, 'L2AssetTracker');
6060
export const ArtifactDummyInteropRecipient = readContract(`${L1_ZK_ARTIFACTS_PATH}`, 'DummyInteropRecipient');
61+
export const ArtifactIBridgehubBase = readContract(`${ARTIFACTS_PATH}`, 'IBridgehubBase');
62+
export const ArtifactIGetters = readContract(`${ARTIFACTS_PATH}`, 'IGetters');
63+
export const ArtifactIChainAssetHandler = readContract(`${ARTIFACTS_PATH}`, 'IChainAssetHandler');

core/tests/ts-integration/src/helpers.ts

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@ import {
99
GATEWAY_CHAIN_ID,
1010
L2_INTEROP_ROOT_STORAGE_ADDRESS,
1111
L2_BRIDGEHUB_ADDRESS,
12-
ArtifactL2InteropRootStorage
12+
ArtifactL2InteropRootStorage,
13+
ArtifactIBridgehubBase,
14+
ArtifactIGetters
1315
} from './constants';
1416

1517
import { log } from 'console';
@@ -107,17 +109,9 @@ export async function waitUntilBlockExecutedOnGateway(
107109
gwWallet: zksync.Wallet,
108110
blockNumber: number
109111
) {
110-
const bridgehub = new ethers.Contract(
111-
L2_BRIDGEHUB_ADDRESS,
112-
['function getZKChain(uint256) view returns (address)'],
113-
gwWallet
114-
);
115-
const zkChainAddr = await bridgehub.getZKChain(await wallet.provider.getNetwork().then((net) => net.chainId));
116-
const gettersFacet = new ethers.Contract(
117-
zkChainAddr,
118-
['function getTotalBatchesExecuted() view returns (uint256)'],
119-
gwWallet
120-
);
112+
const bridgehub = new ethers.Contract(L2_BRIDGEHUB_ADDRESS, ArtifactIBridgehubBase.abi, gwWallet);
113+
const zkChainAddr = await bridgehub.getZKChain(await wallet.provider.getNetwork().then((net: any) => net.chainId));
114+
const gettersFacet = new ethers.Contract(zkChainAddr, ArtifactIGetters.abi, gwWallet);
121115

122116
let batchNumber = (await wallet.provider.getBlockDetails(blockNumber)).l1BatchNumber;
123117
let currentExecutedBatchNumber = 0;

core/tests/upgrade-test/tests/upgrade.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -773,21 +773,21 @@ async function pauseMigrationsCalldata(
773773
// For gateway, get the ChainAssetHandler address from L2 Bridgehub
774774
const l2BridgehubContract = new ethers.Contract(
775775
L2_BRIDGEHUB_ADDRESS,
776-
['function chainAssetHandler() external view returns (address)'],
776+
contracts.bridgehubAbi,
777777
gatewayInfo.gatewayProvider
778778
);
779779
chainAssetHandlerAddr = await l2BridgehubContract.chainAssetHandler();
780780
} else {
781781
// For L1, get the ChainAssetHandler address from L1 Bridgehub
782782
const bridgehubContract = new ethers.Contract(
783783
l1BridgehubAddr,
784-
['function chainAssetHandler() external view returns (address)'],
784+
contracts.bridgehubAbi,
785785
l1Provider
786786
);
787787
chainAssetHandlerAddr = await bridgehubContract.chainAssetHandler();
788788
}
789789

790-
const iface = new ethers.Interface(['function pauseMigration() external']);
790+
const iface = contracts.chainAssetHandlerAbi;
791791

792792
return prepareGovernanceCalldata(
793793
chainAssetHandlerAddr,

core/tests/upgrade-test/tests/utils.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ export interface Contracts {
4242
counterBytecode: any;
4343
chainTypeManager: any;
4444
bytecodesSupplierAbi: any;
45+
bridgehubAbi: any;
46+
chainAssetHandlerAbi: any;
4547
}
4648

4749
export function initContracts(pathToHome: string, zkStack: boolean): Contracts {
@@ -74,6 +76,12 @@ export function initContracts(pathToHome: string, zkStack: boolean): Contracts {
7476
),
7577
bytecodesSupplierAbi: new ethers.Interface(
7678
require(`${CONTRACTS_FOLDER}/l1-contracts/out/BytecodesSupplier.sol/BytecodesSupplier.json`).abi
79+
),
80+
bridgehubAbi: new ethers.Interface(
81+
require(`${CONTRACTS_FOLDER}/l1-contracts/out/IBridgehubBase.sol/IBridgehubBase.json`).abi
82+
),
83+
chainAssetHandlerAbi: new ethers.Interface(
84+
require(`${CONTRACTS_FOLDER}/l1-contracts/out/IChainAssetHandler.sol/IChainAssetHandler.json`).abi
7785
)
7886
};
7987
} else {
@@ -106,6 +114,12 @@ export function initContracts(pathToHome: string, zkStack: boolean): Contracts {
106114
),
107115
bytecodesSupplierAbi: new ethers.Interface(
108116
require(`${L1_CONTRACTS_FOLDER}/upgrades/BytecodesSupplier.sol/BytecodesSupplier.json`).abi
117+
),
118+
bridgehubAbi: new ethers.Interface(
119+
require(`${L1_CONTRACTS_FOLDER}/core/bridgehub/IBridgehubBase.sol/IBridgehubBase.json`).abi
120+
),
121+
chainAssetHandlerAbi: new ethers.Interface(
122+
require(`${L1_CONTRACTS_FOLDER}/core/chain-asset-handler/IChainAssetHandler.sol/IChainAssetHandler.json`).abi
109123
)
110124
};
111125
}

0 commit comments

Comments
 (0)