1- import { it , expect } from 'vitest' ;
2- import { Address , createPublicClient , http } from 'viem' ;
1+ import { afterAll , beforeAll , it , expect } from 'vitest' ;
2+ import { Address , Hex , createPublicClient , encodeAbiParameters , http } from 'viem' ;
33import { generatePrivateKey , privateKeyToAccount } from 'viem/accounts' ;
44import { nitroTestnodeL3 } from '../chains' ;
55import { arbOwnerPublicActions } from './arbOwnerPublicActions' ;
66import { arbGasInfoPublicActions } from './arbGasInfoPublicActions' ;
7- import { getNitroTestnodePrivateKeyAccounts } from '../testHelpers' ;
7+ import {
8+ getInformationFromTestnode ,
9+ getNitroTestnodePrivateKeyAccounts ,
10+ PrivateKeyAccountWithPrivateKey ,
11+ } from '../testHelpers' ;
12+ import { getAnvilTestStack , isAnvilTestMode } from '../integrationTestHelpers/injectedMode' ;
813
9- // L3 Owner Private Key
10- const devPrivateKey = getNitroTestnodePrivateKeyAccounts ( ) . l3RollupOwner . privateKey ;
14+ const env = isAnvilTestMode ( ) ? getAnvilTestStack ( ) : undefined ;
1115
12- // L3 Upgrade Executor Address
13- const upgradeExecutorAddress : Address = '0x24198F8A339cd3C47AEa3A764A20d2dDaB4D1b5b' ;
14-
15- const owner = privateKeyToAccount ( devPrivateKey ) ;
1616const randomAccount = privateKeyToAccount ( generatePrivateKey ( ) ) ;
1717
18- // Client for arb owner public actions
18+ let l3RollupOwner : PrivateKeyAccountWithPrivateKey ;
19+ let l3UpgradeExecutor : Address ;
20+
21+ if ( env ) {
22+ l3RollupOwner = env . l3 . accounts . rollupOwner ;
23+ l3UpgradeExecutor = env . l3 . childChainUpgradeExecutor ;
24+ } else {
25+ const testnodeAccounts = getNitroTestnodePrivateKeyAccounts ( ) ;
26+ l3RollupOwner = testnodeAccounts . l3RollupOwner ;
27+ l3UpgradeExecutor = getInformationFromTestnode ( ) . l3UpgradeExecutor ;
28+ }
29+
1930const client = createPublicClient ( {
20- chain : nitroTestnodeL3 ,
31+ chain : env ? env . l3 . chain : nitroTestnodeL3 ,
2132 transport : http ( ) ,
2233} )
2334 . extend ( arbOwnerPublicActions )
@@ -36,13 +47,13 @@ it('succesfully adds chain owner using upgrade executor', async () => {
3647 const transactionRequest = await client . arbOwnerPrepareTransactionRequest ( {
3748 functionName : 'addChainOwner' ,
3849 args : [ randomAccount . address ] ,
39- upgradeExecutor : upgradeExecutorAddress ,
40- account : owner . address ,
50+ upgradeExecutor : l3UpgradeExecutor ,
51+ account : l3RollupOwner . address ,
4152 } ) ;
4253
4354 // submit tx to add chain owner
4455 const txHash = await client . sendRawTransaction ( {
45- serializedTransaction : await owner . signTransaction ( transactionRequest ) ,
56+ serializedTransaction : await l3RollupOwner . signTransaction ( transactionRequest ) ,
4657 } ) ;
4758 await client . waitForTransactionReceipt ( { hash : txHash } ) ;
4859
@@ -66,13 +77,13 @@ it('succesfully removes chain owner', async () => {
6677 const transactionRequest = await client . arbOwnerPrepareTransactionRequest ( {
6778 functionName : 'removeChainOwner' ,
6879 args : [ randomAccount . address ] ,
69- upgradeExecutor : upgradeExecutorAddress ,
70- account : owner . address ,
80+ upgradeExecutor : l3UpgradeExecutor ,
81+ account : l3RollupOwner . address ,
7182 } ) ;
7283
7384 // submit tx to remove chain owner
7485 const txHash = await client . sendRawTransaction ( {
75- serializedTransaction : await owner . signTransaction ( transactionRequest ) ,
86+ serializedTransaction : await l3RollupOwner . signTransaction ( transactionRequest ) ,
7687 } ) ;
7788 await client . waitForTransactionReceipt ( { hash : txHash } ) ;
7889
@@ -96,13 +107,13 @@ it('successfully updates infra fee receiver', async () => {
96107 const transactionRequest = await client . arbOwnerPrepareTransactionRequest ( {
97108 functionName : 'setInfraFeeAccount' ,
98109 args : [ randomAccount . address ] ,
99- upgradeExecutor : upgradeExecutorAddress ,
100- account : owner . address ,
110+ upgradeExecutor : l3UpgradeExecutor ,
111+ account : l3RollupOwner . address ,
101112 } ) ;
102113
103114 // submit tx to update infra fee receiver
104115 const txHash = await client . sendRawTransaction ( {
105- serializedTransaction : await owner . signTransaction ( transactionRequest ) ,
116+ serializedTransaction : await l3RollupOwner . signTransaction ( transactionRequest ) ,
106117 } ) ;
107118 await client . waitForTransactionReceipt ( { hash : txHash } ) ;
108119
@@ -119,13 +130,13 @@ it('successfully updates L2 Base Fee Estimate Inertia on Orbit chain', async ()
119130 const transactionRequest = await client . arbOwnerPrepareTransactionRequest ( {
120131 functionName : 'setL1BaseFeeEstimateInertia' ,
121132 args : [ l2BaseFeeEstimateInertia ] ,
122- upgradeExecutor : upgradeExecutorAddress ,
123- account : owner . address ,
133+ upgradeExecutor : l3UpgradeExecutor ,
134+ account : l3RollupOwner . address ,
124135 } ) ;
125136
126137 // submit tx to update infra fee receiver
127138 const txHash = await client . sendRawTransaction ( {
128- serializedTransaction : await owner . signTransaction ( transactionRequest ) ,
139+ serializedTransaction : await l3RollupOwner . signTransaction ( transactionRequest ) ,
129140 } ) ;
130141 await client . waitForTransactionReceipt ( { hash : txHash } ) ;
131142
0 commit comments