@@ -27,68 +27,76 @@ task('verify-deployment', 'Verifies proxy upgrades').setAction(
27
27
) ;
28
28
29
29
// 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
+ ) ;
38
43
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
+ } ) ;
43
48
44
- console . log ( '--- Upgrade Validated...' ) ;
49
+ console . log ( '--- Upgrade Validated...' ) ;
45
50
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
+ ) ;
49
54
50
- const { data : expectedInitCode } = await factory . getDeployTransaction (
51
- ...deployment . linkedData . constructorArgs
52
- ) ;
55
+ const { data : expectedInitCode } = await factory . getDeployTransaction (
56
+ ...deployment . linkedData . constructorArgs
57
+ ) ;
53
58
54
- const fetchedDeploymentTx = await ethers . provider . getTransaction (
55
- deployment . transactionHash !
56
- ) ! ;
59
+ const fetchedDeploymentTx = await ethers . provider . getTransaction (
60
+ deployment . transactionHash !
61
+ ) ! ;
57
62
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`
60
74
) ;
61
-
62
- const txPayload = await hre . ethers . provider . getTransaction (
63
- deployment . transactionHash !
75
+ } else {
76
+ console . log (
77
+ `❌ ${ contractName } ( ${ deployment . address } ): Init Code mismatch`
64
78
) ;
79
+ throw new Error ( 'Init Code mismatch' ) ;
80
+ }
65
81
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
+ ) ;
76
85
86
+ // checking for null/undefined value too
87
+ if (
88
+ receipt ?. contractAddress &&
89
+ receipt . contractAddress === deployment . implementation
90
+ ) {
77
91
console . log (
78
- '--- Check if the new implementation deployment resulted in deploying that implementation address...'
92
+ `✅ ${ contractName } ( ${ deployment . address } ): New implementation deployment verified`
79
93
) ;
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
+ }
92
100
}
93
101
}
94
102
) ;
0 commit comments