11import { task } from "hardhat/config" ;
2- import { HardhatRuntimeEnvironment } from "hardhat/types" ;
2+ import { HardhatRuntimeEnvironment , ActionType } from "hardhat/types" ;
33
44task ( "upgrade-spokepool" , "Generate calldata to upgrade a SpokePool deployment" )
55 . addParam ( "implementation" , "New SpokePool implementation address" )
6+ . addOptionalParam ( "upgradeOnly" , "Upgrade only, do not pause deposits" )
67 . setAction ( async function ( args , hre : HardhatRuntimeEnvironment ) {
7- const { implementation } = args ;
8+ const { implementation, upgradeOnly } = args ;
89 if ( ! implementation ) {
910 console . log ( "Usage: yarn hardhat upgrade-spokepool --implementation <implementation>" ) ;
1011 return ;
@@ -18,6 +19,19 @@ task("upgrade-spokepool", "Generate calldata to upgrade a SpokePool deployment")
1819
1920 // @dev Any spoke pool's interface can be used here since they all should have the same upgradeTo function signature.
2021 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+ } ,
2135 {
2236 inputs : [
2337 {
@@ -49,17 +63,23 @@ task("upgrade-spokepool", "Generate calldata to upgrade a SpokePool deployment")
4963 ] ;
5064 const spokePool = new ethers . Contract ( implementation , abi ) ;
5165
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+ ] ) ;
5877
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+ }
6181
6282 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.`
6484 ) ;
6585 } ) ;
0 commit comments