Commit 910a752c authored by Mark Tyneway's avatar Mark Tyneway Committed by Kelvin Fichter

regenesis-script: replaceWETH helper

Create a replaceWETH helper function that can be reused in the
tests. WETH is an immutable in the uniswap contracts so a find
and replace is used to replace the weth address with the L2 eth
address on optimism.
parent 6bb040b7
...@@ -12,6 +12,7 @@ import { ...@@ -12,6 +12,7 @@ import {
transferStorageSlot, transferStorageSlot,
getMappingKey, getMappingKey,
getUniswapV3Factory, getUniswapV3Factory,
replaceWETH,
} from './utils' } from './utils'
import { compile } from './solc' import { compile } from './solc'
import { import {
...@@ -233,10 +234,7 @@ export const handlers: { ...@@ -233,10 +234,7 @@ export const handlers: {
} }
// Replace references to L1 WETH address with the L2 WETH address. // Replace references to L1 WETH address with the L2 WETH address.
code = code.replace( code = replaceWETH(code)
/c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2/g,
'4200000000000000000000000000000000000006'
)
return { return {
...account, ...account,
......
...@@ -46,6 +46,13 @@ export const hexStringEqual = (a: string, b: string): boolean => { ...@@ -46,6 +46,13 @@ export const hexStringEqual = (a: string, b: string): boolean => {
return a.toLowerCase() === b.toLowerCase() return a.toLowerCase() === b.toLowerCase()
} }
export const replaceWETH = (code: string): string => {
return code.replace(
/c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2/g,
'4200000000000000000000000000000000000006'
)
}
/** /**
* Left-pads a hex string with zeroes to 32 bytes. * Left-pads a hex string with zeroes to 32 bytes.
* *
......
import { ethers } from 'ethers' import { ethers } from 'ethers'
import { abi as UNISWAP_POOL_ABI } from '@uniswap/v3-core/artifacts/contracts/UniswapV3Pool.sol/UniswapV3Pool.json' import { abi as UNISWAP_POOL_ABI } from '@uniswap/v3-core/artifacts/contracts/UniswapV3Pool.sol/UniswapV3Pool.json'
import { UNISWAP_V3_NFPM_ADDRESS } from '../../scripts/constants' import { UNISWAP_V3_NFPM_ADDRESS } from '../../scripts/constants'
import { getUniswapV3Factory } from '../../scripts/utils' import { getUniswapV3Factory, replaceWETH } from '../../scripts/utils'
import { expect, env } from '../setup' import { expect, env } from '../setup'
import { AccountType } from '../../scripts/types' import { AccountType } from '../../scripts/types'
...@@ -63,11 +63,12 @@ describe('uniswap contracts', () => { ...@@ -63,11 +63,12 @@ describe('uniswap contracts', () => {
describe('V3 NFPM', () => { describe('V3 NFPM', () => {
it('should have the same code as on mainnet', async () => { it('should have the same code as on mainnet', async () => {
const l2Code = await env.postL2Provider.getCode(UNISWAP_V3_NFPM_ADDRESS) let l2Code = await env.postL2Provider.getCode(UNISWAP_V3_NFPM_ADDRESS)
const l1Code = await env.surgeryDataSources.l1Provider.getCode( const l1Code = await env.surgeryDataSources.l1Provider.getCode(
UNISWAP_V3_NFPM_ADDRESS UNISWAP_V3_NFPM_ADDRESS
) )
expect(l2Code).to.not.equal('0x') expect(l2Code).to.not.equal('0x')
l2Code = replaceWETH(l2Code)
expect(l2Code).to.equal(l1Code) expect(l2Code).to.equal(l1Code)
}) })
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment