Skip to content
Merged
Show file tree
Hide file tree
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
120 changes: 9 additions & 111 deletions foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ via_ir = true
verbosity = 3
auto_detect_remappings = true

# Foundry 1.0 has Optimizer disabled by default
#optimizer = true
#optimizer_runs = 200

[profile.e2e]
match_path = "test/e2e/*"

Expand All @@ -23,132 +27,26 @@ mainnet = "${RPC_MAINNET}"
sepolia = "${RPC_SEPOLIA}"
arbitrum = "${RPC_ARBITRUM}"
arbitrumTestnet = "${RPC_ARBITRUM_SEPOLIA}"
holesky = "${RPC_HOLESKY}"
bsc = "${RPC_BSC}"
bscTestnet = "${RPC_BSC_TESTNET}"
polygon = "${RPC_POLYGON}"
polygonTestnet = "${RPC_POLYGON_TESTNET}"
zkEVM = "${RPC_ZKEVM}"
zkEVMTestnet = "${RPC_ZKEVM_TESTNET}"
base = "${RPC_BASE}"
baseTestnet = "${RPC_BASE_TESTNET}"
novaArbiscan = "${RPC_NOVA_ARBISCAN}"
linea = "${RPC_LINEA}"
lineaTestnet = "${RPC_LINEA_TESTNET}"
ftm = "${RPC_FTM}"
ftmTestnet = "${RPC_FTM_TESTNET}"
blast = "${RPC_BLAST}"
blastTestnet = "${RPC_BLAST_TESTNET}"
optimistic = "${RPC_OPTIMISTIC}"
optimisticSepolia = "${RPC_OPTIMISTIC_SEPOLIA}"
snow = "${RPC_SNOW}"
snowTestnet = "${RPC_SNOW_TESTNET}"
bttc = "${RPC_BTTC}"
donauBttc = "${RPC_DONAU_BTTC}"
celo = "${RPC_CELO}"
alfajoresCelo = "${RPC_ALFAJORES_CELO}"
cronos = "${RPC_CRONOS}"
frax = "${RPC_FRAX}"
fraxTestnet = "${RPC_FRAX_TESTNET}"
gnosis = "${RPC_GNOSIS}"
kroma = "${RPC_KROMA}"
kromaTestnet = "${RPC_KROMA_TESTNET}"
mantle = "${RPC_MANTLE}"
mantleTestnet = "${RPC_MANTLE_TESTNET}"
moonbeam = "${RPC_MOONBEAM}"
moonriver = "${RPC_MOONRIVER}"
moonbase = "${RPC_MOONBASE}"
opbnb = "${RPC_OPBNB}"
opbnbTestnet = "${RPC_OPBNB_TESTNET}"
scroll = "${RPC_SCROLL}"
scrollTestnet = "${RPC_SCROLL_TESTNET}"
taiko = "${RPC_TAIKO}"
taikoTestnet = "${RPC_TAIKO_TESTNET}"
wemix = "${RPC_WEMIX}"
wemixTestnet = "${RPC_WEMIX_TESTNET}"
zkSync = "${RPC_ZKSYNC}"
zkSyncTestnet = "${RPC_ZKSYNC_TESTNET}"
xai = "${RPC_XAI}"
xaiSepolia = "${RPC_XAI_SEPOLIA}"
gnosisTestnet = "${RPC_GNOSIS_TESTNET}"

[etherscan]
ethereum = { key = "${ETHERSCAN_KEY}", chain = 1 }
sepolia = { key = "${ETHERSCAN_KEY}", chain = 11155111 }
holesky = { key = "${ETHERSCAN_KEY}", chain = 17000 }
#[BSC]
bsc = { key = "${ETHERSCAN_KEY}", chain = 56 }
bscTestnet = { key = "${ETHERSCAN_KEY}", chain = 97 }
#[polygon]
polygon = { key = "${ETHERSCAN_KEY}", chain = 137 }
polygonTestnet = { key = "${ETHERSCAN_KEY}", chain = 80002 }
#[zkEVM]
zkEVM = { key = "${ETHERSCAN_KEY}", chain = 1101 }
zkEVMTestnet = { key = "${ETHERSCAN_KEY}", chain = 2442 }
#[baseScan]
base = { key = "${ETHERSCAN_KEY}", chain = 8453 }
baseTestnet = { key = "${ETHERSCAN_KEY}", chain = 84532 }
#[arbiscan]
polygonTestnet = { key = "${ETHERSCAN_KEY}", chain = 80001 }
optimistic = { key = "${ETHERSCAN_KEY}", chain = 10 }
optimismTestnet = { key = "${ETHERSCAN_KEY}", chain = 420 }
arbitrum = { key = "${ETHERSCAN_KEY}", chain = 42161 }
novaArbiscan = { key = "${ETHERSCAN_KEY}", chain = 42170 }
arbitrumSepolia = { key = "${ETHERSCAN_KEY}", chain = 421614 }
#[lineaScan]
linea = { key = "${ETHERSCAN_KEY}", chain = 59144 }
lineaTestnet = { key = "${ETHERSCAN_KEY}", chain = 59141 }
#[ftmScan]
ftm = { key = "${ETHERSCAN_KEY}", chain = 250 }
ftmTestnet = { key = "${ETHERSCAN_KEY}", chain = 4002 }
#[blastScan]
blast = { key = "${ETHERSCAN_KEY}", chain = 81457 }
blastTestnet = { key = "${ETHERSCAN_KEY}", chain = 168587773 }
#[optimisticEtherscan]
optimistic = { key = "${ETHERSCAN_KEY}", chain = 10 }
optimisticSepolia = { key = "${ETHERSCAN_KEY}", chain = 11155420 }
#[snowScan]
snow = { key = "${ETHERSCAN_KEY}", chain = 43114 }
snowTestnet = { key = "${ETHERSCAN_KEY}", chain = 43113 }
#[bttcScan]
bttc = { key = "${ETHERSCAN_KEY}", chain = 199 }
donauBttc = { key = "${ETHERSCAN_KEY}", chain = 1028 }
#[celoScan]
celo = { key = "${ETHERSCAN_KEY}", chain = 42220 }
alfajoresCelo = { key = "${ETHERSCAN_KEY}", chain = 44787 }
#[cronoscan]
cronos = { key = "${ETHERSCAN_KEY}", chain = 25 }
#[fraxscan]
frax = { key = "${ETHERSCAN_KEY}", chain = 252 }
fraxTestnet = { key = "${ETHERSCAN_KEY}", chain = 2522 }
#[gnosisScan]
gnosis = { key = "${ETHERSCAN_KEY}", chain = 100 }
#[kromaScan]
kroma = { key = "${ETHERSCAN_KEY}", chain = 255 }
kromaTestnet = { key = "${ETHERSCAN_KEY}", chain = 2358 }
#[mantlescan]
mantle = { key = "${ETHERSCAN_KEY}", chain = 5000 }
mantleTestnet = { key = "${ETHERSCAN_KEY}", chain = 5003 }
#[moonbeamScan]
moonbeam = { key = "${ETHERSCAN_KEY}", chain = 1284 }
#[moonriverScan]
moonriver = { key = "${ETHERSCAN_KEY}", chain = 1285 }
#[moonbaseScan]
moonbase = { key = "${ETHERSCAN_KEY}", chain = 1287 }
#[opbnbBscScan]
opbnb = { key = "${ETHERSCAN_KEY}", chain = 204 }
opbnbTestnet = { key = "${ETHERSCAN_KEY}", chain = 5611 }
#[scrollScan]
scroll = { key = "${ETHERSCAN_KEY}", chain = 534352 }
scrollTestnet = { key = "${ETHERSCAN_KEY}", chain = 534351 }
#[taikoScan]
taiko = { key = "${ETHERSCAN_KEY}", chain = 167000 }
taikoTestnet = { key = "${ETHERSCAN_KEY}", chain = 167009 }
#[wemixScan]
wemix = { key = "${ETHERSCAN_KEY}", chain = 1111 }
wemixTestnet = { key = "${ETHERSCAN_KEY}", chain = 1112 }
#[zkSyncEra]
zkSync = { key = "${ETHERSCAN_KEY}", chain = 324 }
zkSyncTestnet = { key = "${ETHERSCAN_KEY}", chain = 300 }
#[xaiScan]
xai = { key = "${ETHERSCAN_KEY}", chain = 660279 }
xaiSepolia = { key = "${ETHERSCAN_KEY}", chain = 37714555429 }
gnosisTestnet = { key = "${ETHERSCAN_KEY}", chain = 10200 }

[fmt]
line_length = 90
Expand Down
48 changes: 44 additions & 4 deletions script/BaseScript.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import "forge-std/Script.sol";
import { strings } from "./utils/strings.sol";
import { Create2 } from "./utils/Create2.sol";
import { ICreateX } from "./utils/ICreateX.sol";
import "./Chains.sol";

abstract contract BaseScript is Script {
type CreateXSeed is bytes32;
Expand All @@ -18,6 +17,19 @@ abstract contract BaseScript is Script {
string contractName;
}

struct ChainConfig {
uint256 chainId;
string name;
uint256 testnetChainId;
string testnetName;
}

struct ChainMetadata {
string name;
uint256 chainId;
bool isTestnet;
}

ICreateX private constant CREATE_X_FACTORY =
ICreateX(0xba5Ed099633D3B313e4D5F7bdc1305d3c28ba5Ed);

Expand All @@ -28,9 +40,34 @@ abstract contract BaseScript is Script {
string private constant ENV_DEPLOY_NETWORK = "DEPLOY_NETWORK";
string private constant DEPLOY_HISTORY_PATH = "/deployment/";
string private constant KEY_CONTRACT_NAME = "contractName";
string private constant CHAINS_CONFIG_FILE_NAME = "Chains";
string private constant LOCAL_HOST_NETWORK_NAME = "localhost";

mapping(string => address) internal contracts;
mapping(string => mapping(string => address)) internal contractsOtherNetworks;
mapping(uint256 => ChainMetadata) internal chainMetadata;

constructor() {
_loadChains();
_loadContracts(false);
}

function _loadChains() private {
ChainConfig[] memory chainConfigs =
abi.decode(vm.parseJson(_getConfig(CHAINS_CONFIG_FILE_NAME)), (ChainConfig[]));

ChainConfig memory indexChainConfig;

for (uint256 i = 0; i < chainConfigs.length; ++i) {
indexChainConfig = chainConfigs[i];

chainMetadata[indexChainConfig.chainId] =
ChainMetadata(indexChainConfig.name, indexChainConfig.chainId, false);

chainMetadata[indexChainConfig.testnetChainId] =
ChainMetadata(indexChainConfig.testnetName, indexChainConfig.testnetChainId, true);
}
}

//Entrypoint for the script
function run() external virtual;
Expand Down Expand Up @@ -132,7 +169,7 @@ abstract contract BaseScript is Script {
* @notice _getNetwork the current chain network's name.
*/
function _getNetwork() internal view returns (string memory) {
return Chains.getChainName();
return chainMetadata[block.chainid].name;
}

/**
Expand Down Expand Up @@ -225,11 +262,14 @@ abstract contract BaseScript is Script {
}

function _isTestnet() internal view returns (bool) {
return Chains.isTestnet();
return chainMetadata[block.chainid].isTestnet;
}

function _isLocal() internal view returns (bool) {
return Chains.isLocal();
bytes32 currentNetwork = keccak256(abi.encode(_getNetwork()));
bytes32 localNetwork = keccak256(abi.encode(LOCAL_HOST_NETWORK_NAME));

return currentNetwork == localNetwork;
}

/**
Expand Down
99 changes: 0 additions & 99 deletions script/Chains.sol

This file was deleted.

45 changes: 45 additions & 0 deletions script/config/Chains.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
[

{
"chainId": 31337,
"name": "localhost",
"testnetChainId": 31337,
"testnetName": "localhost"
},
{
"chainId": 1,
"name": "ethereum",
"testnetChainId": 11155111,
"testnetName": "sepolia"
},
{
"chainId": 56,
"name": "bsc",
"testnetChainId": 97,
"testnetName": "bscTestnet"
},
{
"chainId": 137,
"name": "polygon",
"testnetChainId": 80001,
"testnetName": "polygonTestnet"
},
{
"chainId": 10,
"name": "optimism",
"testnetChainId": 420,
"testnetName": "optimismTestnet"
},
{
"chainId": 42161,
"name": "arbitrum",
"testnetChainId": 421614,
"testnetName": "arbitrumSepolia"
},
{
"chainId": 100,
"name": "gnosis",
"testnetChainId": 10200,
"testnetName": "gnosisTestnet"
}
]
2 changes: 0 additions & 2 deletions script/deploy/HelloWorld.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,6 @@ contract HelloWorldScript is BaseScript {
assert(config.owner == address(0xADaE1798F761Fa7fce29B6673D453d1a48A2931A));
assert(config.ownerTwo == address(0x912CE59144191C1204E64559FE8253a0e49E6548));

_loadContracts(false);

address helloWorldAddress;

if (_isTestnet() || _isLocal()) {
Expand Down
Loading