Skip to content

Commit 16a440e

Browse files
committed
chore: verification script cleanup
1 parent 5063c7c commit 16a440e

File tree

1 file changed

+58
-50
lines changed

1 file changed

+58
-50
lines changed

packages/solidity-contracts/scripts/hardhat/verifyDeployment.ts

Lines changed: 58 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -27,68 +27,76 @@ task('verify-deployment', 'Verifies proxy upgrades').setAction(
2727
);
2828

2929
// Only perform verification checks for a legitimate upgrade
30-
if (currentImplementation != deployment.implementation) {
31-
const factory = (await ethers.getContractFactory(
32-
deployment.linkedData.factory
33-
)) as ContractFactory;
34-
35-
console.log(
36-
`--- Validating the upgrade to ${deployment.implementation} implementation...`
37-
);
30+
if (
31+
currentImplementation.toLowerCase() ===
32+
deployment.implementation!.toLowerCase()
33+
)
34+
continue;
35+
36+
const factory = (await ethers.getContractFactory(
37+
deployment.linkedData.factory
38+
)) as ContractFactory;
39+
40+
console.log(
41+
`--- Validating the upgrade to ${deployment.implementation} implementation...`
42+
);
3843

39-
await validateUpgrade(deployment.address as string, factory, {
40-
kind: 'uups',
41-
constructorArgs: deployment.linkedData.constructorArgs,
42-
});
44+
await validateUpgrade(deployment.address as string, factory, {
45+
kind: 'uups',
46+
constructorArgs: deployment.linkedData.constructorArgs,
47+
});
4348

44-
console.log('--- Upgrade Validated...');
49+
console.log('--- Upgrade Validated...');
4550

46-
console.log(
47-
'--- Comparing expected init code with actual init code on-chain...'
48-
);
51+
console.log(
52+
'--- Comparing expected init code with actual init code on-chain...'
53+
);
4954

50-
const { data: expectedInitCode } = await factory.getDeployTransaction(
51-
...deployment.linkedData.constructorArgs
52-
);
55+
const { data: expectedInitCode } = await factory.getDeployTransaction(
56+
...deployment.linkedData.constructorArgs
57+
);
5358

54-
const fetchedDeploymentTx = await ethers.provider.getTransaction(
55-
deployment.transactionHash!
56-
)!;
59+
const fetchedDeploymentTx = await ethers.provider.getTransaction(
60+
deployment.transactionHash!
61+
)!;
5762

58-
const receipt = await ethers.provider.getTransactionReceipt(
59-
fetchedDeploymentTx?.hash!
63+
const receipt = await ethers.provider.getTransactionReceipt(
64+
fetchedDeploymentTx?.hash!
65+
);
66+
67+
// checking for null/undefined value too
68+
if (
69+
fetchedDeploymentTx?.data &&
70+
expectedInitCode === fetchedDeploymentTx.data
71+
) {
72+
console.log(
73+
`✅ ${contractName} (${deployment.address}): Init Code verified successfully`
6074
);
61-
62-
const txPayload = await hre.ethers.provider.getTransaction(
63-
deployment.transactionHash!
75+
} else {
76+
console.log(
77+
`❌ ${contractName} (${deployment.address}): Init Code mismatch`
6478
);
79+
throw new Error('Init Code mismatch');
80+
}
6581

66-
if (expectedInitCode === txPayload?.data) {
67-
console.log(
68-
`✅ ${contractName} (${deployment.address}): Init Code verified successfully`
69-
);
70-
} else {
71-
console.log(
72-
`❌ ${contractName} (${deployment.address}): Init Code mismatch`
73-
);
74-
throw new Error('Init Code mismatch');
75-
}
82+
console.log(
83+
'--- Check if the new implementation deployment resulted in deploying that implementation address...'
84+
);
7685

86+
// checking for null/undefined value too
87+
if (
88+
receipt?.contractAddress &&
89+
receipt.contractAddress === deployment.implementation
90+
) {
7791
console.log(
78-
'--- Check if the new implementation deployment resulted in deploying that implementation address...'
92+
`✅ ${contractName} (${deployment.address}): New implementation deployment verified`
7993
);
80-
81-
if (receipt?.contractAddress === deployment.implementation) {
82-
console.log(
83-
`✅ ${contractName} (${deployment.address}): New implementation deployment verified`
84-
);
85-
} else {
86-
console.log(
87-
`❌ ${contractName} (${deployment.address}): New implementation deployment verification failed`
88-
);
89-
throw new Error('New implementation deployment verification failed');
90-
}
91-
} else continue;
94+
} else {
95+
console.log(
96+
`❌ ${contractName} (${deployment.address}): New implementation deployment verification failed`
97+
);
98+
throw new Error('New implementation deployment verification failed');
99+
}
92100
}
93101
}
94102
);

0 commit comments

Comments
 (0)