Skip to content

Commit 019dc9d

Browse files
committed
feat: use json input
1 parent f827a6d commit 019dc9d

File tree

3 files changed

+72
-12
lines changed

3 files changed

+72
-12
lines changed

contracts/foundry.toml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ test = 'src/v0.8/ccip/test'
3030
script = 'script'
3131
optimizer_runs = 800
3232
evm_version = 'paris'
33+
fs_permissions = [{ access = "read", path = "./script/config.json" }]
34+
3335

3436
[profile.functions]
3537
solc_version = '0.8.19'
@@ -99,5 +101,34 @@ src = 'src/v0.8/shared'
99101
test = 'src/v0.8/shared/test'
100102
solc_version = '0.8.24'
101103

104+
[rpc_endpoints]
105+
mainnet = "${RPC_MAINNET}"
106+
optimism = "${RPC_OPTIMISM}"
107+
avalanche = "${RPC_AVALANCHE}"
108+
polygon = "${RPC_POLYGON}"
109+
arbitrum = "${RPC_ARBITRUM}"
110+
fantom = "${RPC_FANTOM}"
111+
harmony = "${RPC_HARMONY}"
112+
metis = "${RPC_METIS}"
113+
base = "${RPC_BASE}"
114+
zkevm = "${RPC_ZKEVM}"
115+
gnosis = "${RPC_GNOSIS}"
116+
bnb = "${RPC_BNB}"
117+
celo = "${RPC_CELO}"
118+
119+
[etherscan]
120+
mainnet = { key = "${ETHERSCAN_API_KEY_MAINNET}", chainId = 1 }
121+
optimism = { key = "${ETHERSCAN_API_KEY_OPTIMISM}", chainId = 10 }
122+
avalanche = { key = "${ETHERSCAN_API_KEY_AVALANCHE}", chainId = 43114 }
123+
polygon = { key = "${ETHERSCAN_API_KEY_POLYGON}", chainId = 137 }
124+
arbitrum = { key = "${ETHERSCAN_API_KEY_ARBITRUM}", chainId = 42161 }
125+
fantom = { key = "${ETHERSCAN_API_KEY_FANTOM}", chainId = 250 }
126+
metis = { key = "any", chainId = 1088, url = 'https://andromeda-explorer.metis.io/' }
127+
base = { key = "${ETHERSCAN_API_KEY_BASE}", chainId = 8453 }
128+
zkevm = { key = "${ETHERSCAN_API_KEY_ZKEVM}", chainId = 1101 }
129+
gnosis = { key = "${ETHERSCAN_API_KEY_GNOSIS}", chainId = 100 }
130+
bnb = { key = "${ETHERSCAN_API_KEY_BNB}", chainId = 56 }
131+
celo = { key = "${ETHERSCAN_API_KEY_CELO}", chainId = 42220 }
132+
102133

103134
# See more config options https://github.com/foundry-rs/foundry/tree/master/config

contracts/script/DeployUpgradableBurnMintTokenPool.s.sol

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
// SPDX-License-Identifier: BUSL-1.1
22
pragma solidity ^0.8.0;
33

4-
import {Script, console2 as console} from "forge-std/Script.sol";
4+
import {Script} from "forge-std/Script.sol";
5+
import {console2 as console} from "forge-std/console2.sol";
6+
import {stdJson} from "forge-std/StdJson.sol";
57

68
import {UpgradeableBurnMintTokenPool} from "./../src/v0.8/ccip/pools/GHO/UpgradeableBurnMintTokenPool.sol";
79
import {ITransparentProxyFactory} from "solidity-utils/contracts/transparent-proxy/interfaces/ITransparentProxyFactory.sol";
@@ -11,26 +13,32 @@ interface IProxyAdmin {
1113
function UPGRADE_INTERFACE_VERSION() external view returns (string memory);
1214
}
1315

16+
struct Config {
17+
IERC20Metadata GHO_TOKEN;
18+
address OWNER;
19+
ITransparentProxyFactory PROXY_FACTORY;
20+
address RMN_PROXY;
21+
address ROUTER;
22+
}
23+
1424
contract DeployUpgradableBurnMintTokenPool is Script {
25+
using stdJson for string;
26+
1527
function run() external {
16-
IERC20Metadata GHO_TOKEN = IERC20Metadata(vm.promptAddress("GHO_TOKEN"));
17-
uint8 TOKEN_DECIMALS = _validateTokenAndFetchDecimals(GHO_TOKEN);
18-
ITransparentProxyFactory PROXY_FACTORY = ITransparentProxyFactory(vm.promptAddress("TRANSPARENT_PROXY_FACTORY"));
19-
address OWNER = vm.promptAddress("OWNER");
20-
address ROUTER = vm.promptAddress("ROUTER");
21-
address RMN_PROXY = vm.promptAddress("RMN_PROXY");
28+
Config memory config = this.parseConfig();
29+
uint8 TOKEN_DECIMALS = _validateTokenAndFetchDecimals(config.GHO_TOKEN);
2230

2331
address[] memory ALLOW_LIST = new address[](0);
2432
bool ALLOW_LIST_ENABLED = false;
2533

2634
vm.startBroadcast();
2735
address tokenPool = address(
28-
new UpgradeableBurnMintTokenPool(address(GHO_TOKEN), TOKEN_DECIMALS, RMN_PROXY, ALLOW_LIST_ENABLED)
36+
new UpgradeableBurnMintTokenPool(address(config.GHO_TOKEN), TOKEN_DECIMALS, config.RMN_PROXY, ALLOW_LIST_ENABLED)
2937
);
30-
address tokenPoolProxy = PROXY_FACTORY.create(
38+
address tokenPoolProxy = config.PROXY_FACTORY.create(
3139
tokenPool,
32-
OWNER,
33-
abi.encodeCall(UpgradeableBurnMintTokenPool.initialize, (OWNER, ALLOW_LIST, ROUTER))
40+
config.OWNER,
41+
abi.encodeCall(UpgradeableBurnMintTokenPool.initialize, (config.OWNER, ALLOW_LIST, config.ROUTER))
3442
);
3543
vm.stopBroadcast();
3644

@@ -40,8 +48,13 @@ contract DeployUpgradableBurnMintTokenPool is Script {
4048
_validateProxyAdminVersion(tokenPoolProxy);
4149
}
4250

51+
function parseConfig() external view returns (Config memory) {
52+
string memory config = vm.readFile(string.concat(vm.projectRoot(), "/script/config.json"));
53+
return abi.decode(vm.parseJson(config, string.concat(".", vm.toString(block.chainid))), (Config));
54+
}
55+
4356
function _validateTokenAndFetchDecimals(IERC20Metadata token) internal view returns (uint8) {
44-
require(_cmp(token.name(), "GHO"), "InvalidToken");
57+
require(_cmp(token.name(), "Gho Token"), "InvalidToken");
4558
require(_cmp(token.symbol(), "GHO"), "InvalidToken");
4659
return token.decimals();
4760
}

contracts/script/config.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"42161": {
3+
"GHO_TOKEN": "0x7dfF72693f6A4149b17e7C6314655f6A9F7c8B33",
4+
"OWNER": "0xFF1137243698CaA18EE364Cc966CF0e02A4e6327",
5+
"PROXY_FACTORY": "0xEB0682d148e874553008730f0686ea89db7DA412",
6+
"RMN_PROXY": "0xC311a21e6fEf769344EB1515588B9d535662a145",
7+
"ROUTER": "0x141fa059441E0ca23ce184B6A78bafD2A517DdE8"
8+
},
9+
"8453": {
10+
"GHO_TOKEN": "0x6Bb7a212910682DCFdbd5BCBb3e28FB4E8da10Ee",
11+
"OWNER": "0x9390B1735def18560c509E2d0bc090E9d6BA257a",
12+
"PROXY_FACTORY": "0xEB0682d148e874553008730f0686ea89db7DA412",
13+
"RMN_PROXY": "0xC842c69d54F83170C42C4d556B4F6B2ca53Dd3E8",
14+
"ROUTER": "0x881e3A65B4d4a04dD529061dd0071cf975F58bCD"
15+
}
16+
}

0 commit comments

Comments
 (0)