Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set the correct testnet/mainnet evm state storage account - port #5311

Merged
merged 1 commit into from
Jan 29, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion fvm/systemcontracts/system_contracts.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,11 @@ var (
nftTokenAddressMainnet = flow.HexToAddress("1d7e57aa55817448")
// nftTokenAddressTestnet is the address of the NonFungibleToken contract on Testnet
nftTokenAddressTestnet = flow.HexToAddress("631e88ae7f1d7c20")

// evmStorageAddressTestnet is the address of the EVM state storage contract on Testnet
evmStorageAddressTestnet = flow.HexToAddress("1a54ed2be7552821")
// evmStorageAddressMainnet is the address of the EVM state storage contract on Mainnet
evmStorageAddressMainnet = flow.HexToAddress("d421a63faae318f9")
)

// SystemContract represents a system contract on a particular chain.
Expand Down Expand Up @@ -284,6 +289,17 @@ func init() {
}
}

evmStorageEVMFunc := func(chain flow.ChainID) flow.Address {
switch chain {
case flow.Mainnet:
return evmStorageAddressMainnet
case flow.Testnet:
return evmStorageAddressTestnet
default:
return nthAddressFunc(EVMStorageAccountIndex)(chain)
}
}

contractAddressFunc = map[string]func(id flow.ChainID) flow.Address{
ContractNameIDTableStaking: epochAddressFunc,
ContractNameEpoch: epochAddressFunc,
Expand All @@ -304,7 +320,7 @@ func init() {
ContractNameViewResolver: nftTokenAddressFunc,

ContractNameEVM: serviceAddressFunc,
AccountNameEVMStorage: nthAddressFunc(EVMStorageAccountIndex),
AccountNameEVMStorage: evmStorageEVMFunc,
}

getSystemContractsForChain := func(chainID flow.ChainID) *SystemContracts {
Expand Down
Loading