Skip to content

Commit 4677066

Browse files
committed
Updated Constans.sol script to read by chainid instead of chain name
Signed-off-by: Faisal Usmani <[email protected]>
1 parent 791d7e7 commit 4677066

File tree

3 files changed

+59
-50
lines changed

3 files changed

+59
-50
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
"process-hardhat-export": "hardhat export --export-all ./cache/massExport.json && ts-node ./scripts/processHardhatExport.ts && prettier --write ./deployments/deployments.json",
4949
"pre-commit-hook": "sh scripts/preCommitHook.sh",
5050
"extract-addresses": "./script/utils/extract_foundry_addresses.sh",
51-
"generate-constants-json": "ts-node ./scripts/generate-constants-json.ts"
51+
"generate-constants-json": "ts-node ./script/utils/GenerateConstantsJson.ts"
5252
},
5353
"dependencies": {
5454
"@across-protocol/constants": "^3.1.69",

script/utils/Constants.sol

Lines changed: 48 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,6 @@ contract Constants is Script {
2323
return vm.parseJsonUint(file, string.concat(".chainIds.", chainName));
2424
}
2525

26-
function getWrappedNativeToken(string memory chainName) public view returns (WETH9Interface) {
27-
return WETH9Interface(vm.parseJsonAddress(file, string.concat(".wrappedNativeTokens.", chainName)));
28-
}
29-
3026
function QUOTE_TIME_BUFFER() public view returns (uint256) {
3127
return vm.parseJsonUint(file, ".timeConstants.QUOTE_TIME_BUFFER");
3228
}
@@ -95,98 +91,110 @@ contract Constants is Script {
9591

9692
// Helper functions to get addresses for a specific chain
9793
function getL1Addresses(uint256 chainId) public view returns (L1Addresses memory) {
98-
string memory chainName = _getChainName(chainId);
94+
string memory chainIdString = vm.toString(chainId);
9995
if (chainId == getChainId("MAINNET") || chainId == getChainId("SEPOLIA")) {
10096
return
10197
L1Addresses({
102-
finder: vm.parseJsonAddress(file, string.concat(".l1Addresses.", chainName, ".finder")),
98+
finder: vm.parseJsonAddress(file, string.concat(".l1Addresses.", chainIdString, ".finder")),
10399
l1ArbitrumInbox: vm.parseJsonAddress(
104100
file,
105-
string.concat(".l1Addresses.", chainName, ".l1ArbitrumInbox")
101+
string.concat(".l1Addresses.", chainIdString, ".l1ArbitrumInbox")
106102
),
107103
l1ERC20GatewayRouter: vm.parseJsonAddress(
108104
file,
109-
string.concat(".l1Addresses.", chainName, ".l1ERC20GatewayRouter")
105+
string.concat(".l1Addresses.", chainIdString, ".l1ERC20GatewayRouter")
110106
),
111107
polygonRootChainManager: vm.parseJsonAddress(
112108
file,
113-
string.concat(".l1Addresses.", chainName, ".polygonRootChainManager")
109+
string.concat(".l1Addresses.", chainIdString, ".polygonRootChainManager")
114110
),
115111
polygonFxRoot: vm.parseJsonAddress(
116112
file,
117-
string.concat(".l1Addresses.", chainName, ".polygonFxRoot")
113+
string.concat(".l1Addresses.", chainIdString, ".polygonFxRoot")
118114
),
119115
polygonERC20Predicate: vm.parseJsonAddress(
120116
file,
121-
string.concat(".l1Addresses.", chainName, ".polygonERC20Predicate")
117+
string.concat(".l1Addresses.", chainIdString, ".polygonERC20Predicate")
122118
),
123119
polygonRegistry: vm.parseJsonAddress(
124120
file,
125-
string.concat(".l1Addresses.", chainName, ".polygonRegistry")
121+
string.concat(".l1Addresses.", chainIdString, ".polygonRegistry")
126122
),
127123
polygonDepositManager: vm.parseJsonAddress(
128124
file,
129-
string.concat(".l1Addresses.", chainName, ".polygonDepositManager")
125+
string.concat(".l1Addresses.", chainIdString, ".polygonDepositManager")
130126
),
131127
cctpTokenMessenger: vm.parseJsonAddress(
132128
file,
133-
string.concat(".l1Addresses.", chainName, ".cctpTokenMessenger")
129+
string.concat(".l1Addresses.", chainIdString, ".cctpTokenMessenger")
134130
),
135131
cctpV2TokenMessenger: vm.parseJsonAddress(
136132
file,
137-
string.concat(".l1Addresses.", chainName, ".cctpV2TokenMessenger")
133+
string.concat(".l1Addresses.", chainIdString, ".cctpV2TokenMessenger")
138134
),
139135
cctpMessageTransmitter: vm.parseJsonAddress(
140136
file,
141-
string.concat(".l1Addresses.", chainName, ".cctpMessageTransmitter")
137+
string.concat(".l1Addresses.", chainIdString, ".cctpMessageTransmitter")
142138
),
143139
lineaMessageService: vm.parseJsonAddress(
144140
file,
145-
string.concat(".l1Addresses.", chainName, ".lineaMessageService")
141+
string.concat(".l1Addresses.", chainIdString, ".lineaMessageService")
146142
),
147143
lineaTokenBridge: vm.parseJsonAddress(
148144
file,
149-
string.concat(".l1Addresses.", chainName, ".lineaTokenBridge")
145+
string.concat(".l1Addresses.", chainIdString, ".lineaTokenBridge")
150146
),
151147
scrollERC20GatewayRouter: vm.parseJsonAddress(
152148
file,
153-
string.concat(".l1Addresses.", chainName, ".scrollERC20GatewayRouter")
149+
string.concat(".l1Addresses.", chainIdString, ".scrollERC20GatewayRouter")
154150
),
155151
scrollMessengerRelay: vm.parseJsonAddress(
156152
file,
157-
string.concat(".l1Addresses.", chainName, ".scrollMessengerRelay")
153+
string.concat(".l1Addresses.", chainIdString, ".scrollMessengerRelay")
158154
),
159155
scrollGasPriceOracle: vm.parseJsonAddress(
160156
file,
161-
string.concat(".l1Addresses.", chainName, ".scrollGasPriceOracle")
157+
string.concat(".l1Addresses.", chainIdString, ".scrollGasPriceOracle")
162158
),
163159
blastYieldManager: vm.parseJsonAddress(
164160
file,
165-
string.concat(".l1Addresses.", chainName, ".blastYieldManager")
161+
string.concat(".l1Addresses.", chainIdString, ".blastYieldManager")
166162
),
167163
blastDaiRetriever: vm.parseJsonAddress(
168164
file,
169-
string.concat(".l1Addresses.", chainName, ".blastDaiRetriever")
165+
string.concat(".l1Addresses.", chainIdString, ".blastDaiRetriever")
170166
),
171167
l1AlephZeroInbox: vm.parseJsonAddress(
172168
file,
173-
string.concat(".l1Addresses.", chainName, ".l1AlephZeroInbox")
169+
string.concat(".l1Addresses.", chainIdString, ".l1AlephZeroInbox")
174170
),
175171
l1AlephZeroERC20GatewayRouter: vm.parseJsonAddress(
176172
file,
177-
string.concat(".l1Addresses.", chainName, ".l1AlephZeroERC20GatewayRouter")
173+
string.concat(".l1Addresses.", chainIdString, ".l1AlephZeroERC20GatewayRouter")
174+
),
175+
adapterStore: vm.parseJsonAddress(
176+
file,
177+
string.concat(".l1Addresses.", chainIdString, ".adapterStore")
178+
),
179+
donationBox: vm.parseJsonAddress(
180+
file,
181+
string.concat(".l1Addresses.", chainIdString, ".donationBox")
182+
),
183+
hubPoolStore: vm.parseJsonAddress(
184+
file,
185+
string.concat(".l1Addresses.", chainIdString, ".hubPoolStore")
186+
),
187+
zkBridgeHub: vm.parseJsonAddress(
188+
file,
189+
string.concat(".l1Addresses.", chainIdString, ".zkBridgeHub")
178190
),
179-
adapterStore: vm.parseJsonAddress(file, string.concat(".l1Addresses.", chainName, ".adapterStore")),
180-
donationBox: vm.parseJsonAddress(file, string.concat(".l1Addresses.", chainName, ".donationBox")),
181-
hubPoolStore: vm.parseJsonAddress(file, string.concat(".l1Addresses.", chainName, ".hubPoolStore")),
182-
zkBridgeHub: vm.parseJsonAddress(file, string.concat(".l1Addresses.", chainName, ".zkBridgeHub")),
183191
zkUsdcSharedBridge_232: vm.parseJsonAddress(
184192
file,
185-
string.concat(".l1Addresses.", chainName, ".zkUsdcSharedBridge_232")
193+
string.concat(".l1Addresses.", chainIdString, ".zkUsdcSharedBridge_232")
186194
),
187195
zkUsdcSharedBridge_324: vm.parseJsonAddress(
188196
file,
189-
string.concat(".l1Addresses.", chainName, ".zkUsdcSharedBridge_324")
197+
string.concat(".l1Addresses.", chainIdString, ".zkUsdcSharedBridge_324")
190198
)
191199
});
192200
}
@@ -197,10 +205,12 @@ contract Constants is Script {
197205
uint256 hubChainId,
198206
uint256 spokeChainId
199207
) public view returns (OpStackAddresses memory) {
200-
string memory hubChainName = _getChainName(hubChainId);
201-
string memory spokeChainName = _getChainName(spokeChainId);
202-
203-
string memory path = string.concat(".opStackAddresses.", hubChainName, ".", spokeChainName);
208+
string memory path = string.concat(
209+
".opStackAddresses.",
210+
vm.toString(hubChainId),
211+
".",
212+
vm.toString(spokeChainId)
213+
);
204214

205215
return
206216
OpStackAddresses({
@@ -213,14 +223,12 @@ contract Constants is Script {
213223

214224
// Circle domain IDs mapping
215225
function getCircleDomainId(uint256 chainId) public view returns (uint32) {
216-
string memory chainName = _getChainName(chainId);
217-
return uint32(vm.parseJsonUint(file, string.concat(".circleDomainIds.", chainName)));
226+
return uint32(vm.parseJsonUint(file, string.concat(".circleDomainIds.", vm.toString(chainId))));
218227
}
219228

220229
// Get WETH address for any supported chain
221230
function getWrappedNativeToken(uint256 chainId) public view returns (WETH9Interface) {
222-
string memory chainName = _getChainName(chainId);
223-
return WETH9Interface(vm.parseJsonAddress(file, string.concat(".wrappedNativeTokens.", chainName)));
231+
return WETH9Interface(vm.parseJsonAddress(file, string.concat(".wrappedNativeTokens.", vm.toString(chainId))));
224232
}
225233

226234
// Helper function to convert chain ID to chain name
@@ -238,9 +246,8 @@ contract Constants is Script {
238246
if (chainId == getChainId("BASE")) return "BASE";
239247
if (chainId == getChainId("BASE_SEPOLIA")) return "BASE_SEPOLIA";
240248
if (chainId == getChainId("LENS")) return "LENS";
241-
if (chainId == getChainId("LENS_TESTNET")) return "LENS_TESTNET";
249+
if (chainId == getChainId("LENS_SEPOLIA")) return "LENS_SEPOLIA";
242250
if (chainId == getChainId("LINEA")) return "LINEA";
243-
if (chainId == getChainId("LINEA_SEPOLIA")) return "LINEA_SEPOLIA";
244251
if (chainId == getChainId("SCROLL_SEPOLIA")) return "SCROLL_SEPOLIA";
245252
if (chainId == getChainId("SCROLL")) return "SCROLL";
246253
if (chainId == getChainId("UNICHAIN")) return "UNICHAIN";

script/utils/DeploymentUtils.sol

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -176,18 +176,20 @@ contract DeploymentUtils is Script, Test, Constants, DeployedAddresses {
176176
*/
177177
function isTestnet(uint256 chainId) internal view returns (bool) {
178178
return
179-
chainId == getChainId("SEPOLIA") ||
180179
chainId == getChainId("ARBITRUM_SEPOLIA") ||
181-
chainId == getChainId("OPTIMISM_SEPOLIA") ||
182180
chainId == getChainId("BASE_SEPOLIA") ||
183-
chainId == getChainId("POLYGON_AMOY") ||
184-
chainId == getChainId("LENS_TESTNET") ||
185-
chainId == getChainId("LINEA_SEPOLIA") ||
186-
chainId == getChainId("SCROLL_SEPOLIA") ||
187-
chainId == getChainId("UNICHAIN_SEPOLIA") ||
188181
chainId == getChainId("BLAST_SEPOLIA") ||
182+
chainId == getChainId("BOB_SEPOLIA") ||
189183
chainId == getChainId("INK_SEPOLIA") ||
184+
chainId == getChainId("TATARA") ||
185+
chainId == getChainId("LENS_SEPOLIA") ||
190186
chainId == getChainId("LISK_SEPOLIA") ||
191-
chainId == getChainId("MODE_SEPOLIA");
187+
chainId == getChainId("MODE_SEPOLIA") ||
188+
chainId == getChainId("OPTIMISM_SEPOLIA") ||
189+
chainId == getChainId("POLYGON_AMOY") ||
190+
chainId == getChainId("SCROLL_SEPOLIA") ||
191+
chainId == getChainId("SEPOLIA") ||
192+
chainId == getChainId("UNICHAIN_SEPOLIA") ||
193+
chainId == getChainId("ZK_SYNC_SEPOLIA");
192194
}
193195
}

0 commit comments

Comments
 (0)