@@ -10,6 +10,8 @@ import * as fs from "fs";
1010import { ARB_OWNER } from "./consts" ;
1111import * as TransparentUpgradeableProxy from "@openzeppelin/contracts/build/contracts/TransparentUpgradeableProxy.json"
1212import * as ExpressLaneAuctionContract from "@arbitrum/nitro-contracts/build/contracts/src/express-lane-auction/ExpressLaneAuction.sol/ExpressLaneAuction.json"
13+ import * as StylusDeployerContract from "@arbitrum/nitro-contracts/build/contracts/src/stylus/StylusDeployer.sol/StylusDeployer.json"
14+
1315const path = require ( "path" ) ;
1416
1517async function sendTransaction ( argv : any , threadId : number ) {
@@ -185,6 +187,36 @@ async function deployWETHContract(deployerWallet: Wallet): Promise<string> {
185187 return weth . address ;
186188}
187189
190+ async function createStylusDeployer ( deployerWallet : Wallet ) : Promise < string > {
191+ // this factory should be deployed by the rollupcreater when deploy helper is used
192+ const create2factory = '0x4e59b44847b379578588920ca78fbf26c0b4956c'
193+ if ( await deployerWallet . provider . getCode ( create2factory ) === '0x' ) {
194+ // wait for 30 seconds, check again before throwing an error
195+ await new Promise ( resolve => setTimeout ( resolve , 30000 ) ) ;
196+ if ( await deployerWallet . provider . getCode ( create2factory ) === '0x' ) {
197+ throw new Error ( 'Create2 factory not yet deployed' )
198+ }
199+ }
200+
201+ const salt = ethers . constants . HashZero
202+ const stylusDeployerBytecode = StylusDeployerContract . bytecode
203+ const stylusDeployerAddress = ethers . utils . getCreate2Address ( create2factory , salt , ethers . utils . keccak256 ( stylusDeployerBytecode ) )
204+
205+ // check if the address is already deployed
206+ const code = await deployerWallet . provider . getCode ( stylusDeployerAddress )
207+ if ( code !== '0x' ) {
208+ console . log ( "Stylus deployer already deployed" )
209+ } else {
210+ const stylusDeployerTx = await deployerWallet . sendTransaction ( {
211+ to : create2factory ,
212+ data : ethers . utils . concat ( [ salt , stylusDeployerBytecode ] )
213+ } )
214+ await stylusDeployerTx . wait ( )
215+ }
216+
217+ return stylusDeployerAddress
218+ }
219+
188220export const bridgeFundsCommand = {
189221 command : "bridge-funds" ,
190222 describe : "sends funds from l1 to l2" ,
@@ -592,6 +624,30 @@ export const createWETHCommand = {
592624 } ,
593625} ;
594626
627+ export const createStylusDeployerCommand = {
628+ command : "create-stylus-deployer" ,
629+ describe : "deploys the stylus deployer contract" ,
630+ builder : {
631+ deployer : { string : true , describe : "account (see general help)" } ,
632+ l3 : { boolean : false , describe : "deploy on L3, otherwise deploy on L2" } ,
633+ } ,
634+ handler : async ( argv : any ) => {
635+ console . log ( "create-stylus-deployer" ) ;
636+
637+ const provider = new ethers . providers . WebSocketProvider ( argv . l3 ? argv . l3url : argv . l2url ) ;
638+ const deployerWallet = namedAccount ( argv . deployer ) . connect ( provider ) ;
639+
640+ const stylusDeployerAddress = await createStylusDeployer ( deployerWallet ) ;
641+ if ( argv . l3 ) {
642+ console . log ( "Stylus deployer deployed at L3 address:" , stylusDeployerAddress ) ;
643+ } else {
644+ console . log ( "Stylus deployer deployed at L2 address:" , stylusDeployerAddress ) ;
645+ }
646+
647+ provider . destroy ( ) ;
648+ }
649+ } ;
650+
595651export const sendL1Command = {
596652 command : "send-l1" ,
597653 describe : "sends funds between l1 accounts" ,
0 commit comments