@@ -3,9 +3,11 @@ import { ContractFactory, ethers, Wallet } from "ethers";
33import * as consts from "./consts" ;
44import { namedAccount , namedAddress } from "./accounts" ;
55import * as L1GatewayRouter from "@arbitrum/token-bridge-contracts/build/contracts/contracts/tokenbridge/ethereum/gateway/L1GatewayRouter.sol/L1GatewayRouter.json" ;
6+ import * as L1AtomicTokenBridgeCreator from "@arbitrum/token-bridge-contracts/build/contracts/contracts/tokenbridge/ethereum/L1AtomicTokenBridgeCreator.sol/L1AtomicTokenBridgeCreator.json" ;
67import * as ERC20PresetFixedSupplyArtifact from "@openzeppelin/contracts/build/contracts/ERC20PresetFixedSupply.json" ;
78import * as ERC20 from "@openzeppelin/contracts/build/contracts/ERC20.json" ;
89import * as fs from "fs" ;
10+ import { ARB_OWNER } from "./consts" ;
911const path = require ( "path" ) ;
1012
1113async function sendTransaction ( argv : any , threadId : number ) {
@@ -184,6 +186,56 @@ export const bridgeNativeTokenToL3Command = {
184186 } ,
185187} ;
186188
189+ export const transferL3ChainOwnershipCommand = {
190+ command : "transfer-l3-chain-ownership" ,
191+ describe : "transfer L3 chain ownership to upgrade executor" ,
192+ builder : {
193+ creator : {
194+ string : true ,
195+ describe : "address of the token bridge creator" ,
196+ } ,
197+ wait : {
198+ boolean : true ,
199+ describe : "wait till ownership is transferred" ,
200+ default : false ,
201+ } ,
202+ } ,
203+ handler : async ( argv : any ) => {
204+ // get inbox address from config file
205+ const deploydata = JSON . parse (
206+ fs
207+ . readFileSync ( path . join ( consts . configpath , "l3deployment.json" ) )
208+ . toString ( )
209+ ) ;
210+ const inboxAddr = ethers . utils . hexlify ( deploydata . inbox ) ;
211+
212+ // get L3 upgrade executor address from token bridge creator
213+ const l2provider = new ethers . providers . WebSocketProvider ( argv . l2url ) ;
214+ const tokenBridgeCreator = new ethers . Contract ( argv . creator , L1AtomicTokenBridgeCreator . abi , l2provider ) ;
215+ const [ , , , , , , , l3UpgradeExecutorAddress , ] = await tokenBridgeCreator . inboxToL2Deployment ( inboxAddr ) ;
216+
217+ // set TX params
218+ argv . provider = new ethers . providers . WebSocketProvider ( argv . l3url ) ;
219+ argv . to = "address_" + ARB_OWNER ;
220+ argv . from = "l3owner" ;
221+ argv . ethamount = "0" ;
222+
223+ // add L3 UpgradeExecutor to chain owners
224+ const arbOwnerIface = new ethers . utils . Interface ( [
225+ "function addChainOwner(address newOwner) external" ,
226+ "function removeChainOwner(address ownerToRemove) external"
227+ ] )
228+ argv . data = arbOwnerIface . encodeFunctionData ( "addChainOwner" , [ l3UpgradeExecutorAddress ] ) ;
229+ await runStress ( argv , sendTransaction ) ;
230+
231+ // remove L3 owner from chain owners
232+ argv . data = arbOwnerIface . encodeFunctionData ( "removeChainOwner" , [ namedAccount ( "l3owner" ) . address ] ) ;
233+ await runStress ( argv , sendTransaction ) ;
234+
235+ argv . provider . destroy ( ) ;
236+ }
237+ } ;
238+
187239export const createERC20Command = {
188240 command : "create-erc20" ,
189241 describe : "creates simple ERC20 on L2" ,
@@ -279,7 +331,6 @@ export const createERC20Command = {
279331 } ,
280332} ;
281333
282-
283334export const sendL1Command = {
284335 command : "send-l1" ,
285336 describe : "sends funds between l1 accounts" ,
0 commit comments