1
1
import { task } from "hardhat/config" ;
2
- import { HardhatRuntimeEnvironment } from "hardhat/types" ;
2
+ import { HardhatRuntimeEnvironment , ActionType } from "hardhat/types" ;
3
3
4
4
task ( "upgrade-spokepool" , "Generate calldata to upgrade a SpokePool deployment" )
5
5
. addParam ( "implementation" , "New SpokePool implementation address" )
6
+ . addOptionalParam ( "upgradeOnly" , "Upgrade only, do not pause deposits" )
6
7
. setAction ( async function ( args , hre : HardhatRuntimeEnvironment ) {
7
- const { implementation } = args ;
8
+ const { implementation, upgradeOnly } = args ;
8
9
if ( ! implementation ) {
9
10
console . log ( "Usage: yarn hardhat upgrade-spokepool --implementation <implementation>" ) ;
10
11
return ;
@@ -18,6 +19,19 @@ task("upgrade-spokepool", "Generate calldata to upgrade a SpokePool deployment")
18
19
19
20
// @dev Any spoke pool's interface can be used here since they all should have the same upgradeTo function signature.
20
21
const abi = [
22
+ {
23
+ inputs : [
24
+ {
25
+ internalType : "address" ,
26
+ name : "newImplementation" ,
27
+ type : "address" ,
28
+ } ,
29
+ ] ,
30
+ name : "upgradeTo" ,
31
+ outputs : [ ] ,
32
+ stateMutability : "nonpayable" ,
33
+ type : "function" ,
34
+ } ,
21
35
{
22
36
inputs : [
23
37
{
@@ -49,17 +63,23 @@ task("upgrade-spokepool", "Generate calldata to upgrade a SpokePool deployment")
49
63
] ;
50
64
const spokePool = new ethers . Contract ( implementation , abi ) ;
51
65
52
- const data = spokePool . interface . encodeFunctionData ( "multicall" , [
53
- [
54
- spokePool . interface . encodeFunctionData ( "pauseDeposits" , [ true ] ) ,
55
- spokePool . interface . encodeFunctionData ( "pauseDeposits" , [ false ] ) ,
56
- ] ,
57
- ] ) ;
66
+ let calldata = "" ;
67
+ if ( upgradeOnly ) {
68
+ calldata = spokePool . interface . encodeFunctionData ( "upgradeTo" , [ implementation ] ) ;
69
+ console . log ( `upgradeTo bytes: ` , calldata ) ;
70
+ } else {
71
+ const data = spokePool . interface . encodeFunctionData ( "multicall" , [
72
+ [
73
+ spokePool . interface . encodeFunctionData ( "pauseDeposits" , [ true ] ) ,
74
+ spokePool . interface . encodeFunctionData ( "pauseDeposits" , [ false ] ) ,
75
+ ] ,
76
+ ] ) ;
58
77
59
- const upgradeTo = spokePool . interface . encodeFunctionData ( "upgradeToAndCall" , [ implementation , data ] ) ;
60
- console . log ( `upgradeTo bytes: ` , upgradeTo ) ;
78
+ calldata = spokePool . interface . encodeFunctionData ( "upgradeToAndCall" , [ implementation , data ] ) ;
79
+ console . log ( `upgradeToAndCall bytes: ` , calldata ) ;
80
+ }
61
81
62
82
console . log (
63
- `Call relaySpokePoolAdminFunction() with the params [<chainId>, ${ upgradeTo } ] on the hub pool from the owner's account.`
83
+ `Call relaySpokePoolAdminFunction() with the params [<chainId>, ${ calldata } ] on the hub pool from the owner's account.`
64
84
) ;
65
85
} ) ;
0 commit comments