Skip to content

Commit e7d66ba

Browse files
authored
Revert "remove legacy patchwork (#607)"
This reverts commit 7da18d8.
1 parent 7da18d8 commit e7d66ba

File tree

3 files changed

+59
-16
lines changed

3 files changed

+59
-16
lines changed

.github/workflows/build-test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ jobs:
183183
- name: Set up the local node
184184
uses: OffchainLabs/actions/run-nitro-test-node@main
185185
with:
186-
nitro-testnode-ref: release
186+
nitro-testnode-ref: f5a54d679733c65b81d5106488feb957ec579a46
187187
l3-node: ${{ matrix.orbit-test == '1' }}
188188
args: ${{ matrix.decimals == 16 && '--l3-fee-token --l3-fee-token-decimals 16' || matrix.decimals == 20 && '--l3-fee-token --l3-fee-token-decimals 20' || matrix.decimals == 18 && '--l3-fee-token' || '' }}
189189

packages/sdk/scripts/genNetwork.ts

Lines changed: 57 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,14 @@
11
import { loadEnv } from '../src/lib/utils/env'
22
import { execSync } from 'child_process'
33
import * as fs from 'fs'
4-
import { ArbitrumNetwork, L2Network } from '../src'
4+
5+
import { IERC20Bridge__factory } from '../src/lib/abi/factories/IERC20Bridge__factory'
6+
import { ethers } from 'ethers'
7+
import {
8+
L2Network,
9+
ArbitrumNetwork,
10+
mapL2NetworkToArbitrumNetwork,
11+
} from '../src/lib/dataEntities/networks'
512

613
loadEnv()
714

@@ -28,30 +35,66 @@ function getLocalNetworksFromContainer(which: 'l1l2' | 'l2l3'): any {
2835
throw new Error('nitro-testnode sequencer not found')
2936
}
3037

31-
function isLegacyNetworkType(
32-
network: L2Network | ArbitrumNetwork
33-
): network is L2Network {
34-
return 'partnerChainID' in network
38+
/**
39+
* the container's files are written by the token bridge deployment step of the test node, which runs a script in token-bridge-contracts.
40+
* once the script in token-bridge-contracts repo uses an sdk version with the same types and is updated to populate those fields,
41+
* we can remove this patchwork
42+
*/
43+
async function patchNetworks(
44+
l2Network: L2Network,
45+
l3Network: L2Network | undefined,
46+
l2Provider: ethers.providers.Provider | undefined
47+
): Promise<{
48+
patchedL2Network: ArbitrumNetwork
49+
patchedL3Network?: ArbitrumNetwork
50+
}> {
51+
const patchedL2Network = mapL2NetworkToArbitrumNetwork(l2Network)
52+
53+
// native token for l3
54+
if (l3Network && l2Provider) {
55+
const patchedL3Network = mapL2NetworkToArbitrumNetwork(l3Network)
56+
57+
try {
58+
patchedL3Network.nativeToken = await IERC20Bridge__factory.connect(
59+
l3Network.ethBridge.bridge,
60+
l2Provider
61+
).nativeToken()
62+
} catch (e) {
63+
// l3 network doesn't have a native token
64+
}
65+
66+
return { patchedL2Network, patchedL3Network }
67+
}
68+
69+
return { patchedL2Network }
3570
}
3671

3772
async function main() {
3873
fs.rmSync('localNetwork.json', { force: true })
3974

40-
const output = getLocalNetworksFromContainer('l1l2')
75+
let output = getLocalNetworksFromContainer('l1l2')
4176

4277
if (isTestingOrbitChains) {
4378
// When running with L3 active, the container calls the L3 network L2 so we rename it here
4479
const { l2Network: l3Network } = getLocalNetworksFromContainer('l2l3')
45-
output.l3Network = l3Network
46-
}
80+
const { patchedL2Network, patchedL3Network } = await patchNetworks(
81+
output.l2Network,
82+
l3Network,
83+
new ethers.providers.JsonRpcProvider(process.env['ARB_URL'])
84+
)
4785

48-
if (
49-
isLegacyNetworkType(output.l2Network) ||
50-
(output.l3Network && isLegacyNetworkType(output.l3Network))
51-
) {
52-
throw new Error(
53-
'Legacy L2Network type detected. Please use the latest testnode version and token-bridge-contracts version 1.2.5 or above.'
86+
output = {
87+
l2Network: patchedL2Network,
88+
l3Network: patchedL3Network,
89+
}
90+
} else {
91+
const { patchedL2Network } = await patchNetworks(
92+
output.l2Network,
93+
undefined,
94+
undefined
5495
)
96+
97+
output.l2Network = patchedL2Network
5598
}
5699

57100
fs.writeFileSync('localNetwork.json', JSON.stringify(output, null, 2))

packages/sdk/tests/integration/standarderc20.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ describe('standard ERC20', () => {
257257

258258
// force the redeem to fail by submitted just a bit under the required gas
259259
// so it is enough to pay for L1 + L2 intrinsic gas costs
260-
await redeemAndTest(waitRes.message, 0, gasComponents.gasEstimate.sub(9000))
260+
await redeemAndTest(waitRes.message, 0, gasComponents.gasEstimate.sub(3000))
261261
await redeemAndTest(waitRes.message, 1)
262262
})
263263

0 commit comments

Comments
 (0)