Skip to content

Commit 678a896

Browse files
committed
Added foundry zksync profile check in deployment utils
Signed-off-by: Faisal Usmani <[email protected]>
1 parent e2ab1c0 commit 678a896

File tree

3 files changed

+870
-2
lines changed

3 files changed

+870
-2
lines changed

script/059DeployLensSpokePool.s.sol

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ import { DeploymentUtils } from "./utils/DeploymentUtils.sol";
1111

1212
// How to run:
1313
// 1. `source .env` where `.env` has MNEMONIC="x x x ... x"
14-
// 2. forge script script/059DeployLensSpokePool.s.sol:DeployLensSpokePool --rpc-url lens -vvvv
14+
// 2. yarn forge-script-zksync script/059DeployLensSpokePool.s.sol:DeployLensSpokePool --rpc-url lens -vvvv
1515
// 3. Verify the above works in simulation mode.
1616
// 4. Deploy with:
17-
// forge script script/059DeployLensSpokePool.s.sol:DeployLensSpokePool --rpc-url lens \
17+
// yarn forge-script-zksync script/059DeployLensSpokePool.s.sol:DeployLensSpokePool --rpc-url lens \
1818
// --broadcast --verify --verifier blockscout --verifier-url https://verify.lens.xyz/contract_verification
1919

2020
contract DeployLensSpokePool is Script, Test, DeploymentUtils {

script/utils/DeploymentUtils.sol

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@ contract DeploymentUtils is Script, Test, Constants, DeployedAddresses {
3030
bool isNewProxy;
3131
}
3232

33+
constructor() {
34+
checkZkSyncChain(block.chainid);
35+
}
36+
3337
/**
3438
* @notice Get deployment information for SpokePool deployment
3539
* @dev This function mimics getSpokePoolDeploymentInfo from utils.hre.ts
@@ -190,4 +194,26 @@ contract DeploymentUtils is Script, Test, Constants, DeployedAddresses {
190194
chainId == getChainId("LISK_SEPOLIA") ||
191195
chainId == getChainId("MODE_SEPOLIA");
192196
}
197+
198+
/**
199+
* @notice Check if a chain ID is a ZkSync chain
200+
* @dev This function will revert if the chain ID is a ZkSync chain but the FOUNDRY_PROFILE is not zksync
201+
* @param chainId Chain ID to check
202+
*/
203+
function checkZkSyncChain(uint256 chainId) internal view {
204+
bool isZkSyncChain = chainId == getChainId("ZK_SYNC") ||
205+
chainId == getChainId("ZK_SYNC_SEPOLIA") ||
206+
chainId == getChainId("LENS") ||
207+
chainId == getChainId("LENS_TESTNET");
208+
209+
string memory foundryProfile = vm.envOr("FOUNDRY_PROFILE", string("default"));
210+
211+
if (isZkSyncChain && keccak256(abi.encodePacked(foundryProfile)) != keccak256(abi.encodePacked("zksync"))) {
212+
vm.assertEq(
213+
foundryProfile,
214+
string("zksync"),
215+
"Chain is a ZkSync chain but FOUNDRY_PROFILE is not zksync. Use yarn forge-script-zksync to deploy"
216+
);
217+
}
218+
}
193219
}

0 commit comments

Comments
 (0)