Skip to content

Commit

Permalink
Clean up access to deposit address in common (#3411)
Browse files Browse the repository at this point in the history
* add test for custom deposit address

* Clean up deposit contract address access

* Merge remote-tracking branch 'origin/master' into add-depositContractAddress-test

* Merge remote-tracking branch 'origin/master' into add-depositContractAddress-test
  • Loading branch information
acolytec3 authored May 8, 2024
1 parent fe28071 commit 0e06ddf
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
14 changes: 13 additions & 1 deletion packages/common/test/customChains.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ describe('[Common]: Custom chains', () => {
/Missing required/,
undefined,
'should throw an exception on missing parameter'
) // eslint-disable-line no-new
)
})

it('custom() -> base functionality', () => {
Expand Down Expand Up @@ -146,6 +146,18 @@ describe('[Common]: Custom chains', () => {
'customChains, chain initialized with custom chain'
)

const customChainParams: Partial<ChainConfig> = {
name: 'custom',
chainId: 123,
networkId: 678,
depositContractAddress: '0x4242424242424242424242424242424242424242',
}
const customChainCommon = Common.custom(customChainParams, { hardfork: Hardfork.Byzantium })

assert.equal(
customChainCommon['_chainParams'].depositContractAddress,
customChainParams.depositContractAddress
)
c.setChain('testnet')
assert.equal(c.chainName(), 'testnet', 'customChains, should allow to switch custom chain')
assert.equal(
Expand Down
2 changes: 1 addition & 1 deletion packages/vm/src/requests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export const accumulateRequests = async (

if (common.isActivatedEIP(6110)) {
const depositContractAddress =
Common.getInitializedChains()[vm.common.chainName()]?.depositContractAddress ??
vm.common['_chainParams'].depositContractAddress ??
Common.getInitializedChains().mainnet.depositContractAddress
if (depositContractAddress === undefined)
throw new Error('deposit contract address required with EIP 6110')
Expand Down

0 comments on commit 0e06ddf

Please sign in to comment.