Skip to content

Commit

Permalink
minor fix
Browse files Browse the repository at this point in the history
  • Loading branch information
dan13ram committed Sep 17, 2024
1 parent d00d1da commit 51676be
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 14 deletions.
12 changes: 12 additions & 0 deletions script/BaseData.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,13 @@ contract BaseData is Script {
require(isSupportedChainId(block.chainid), "BaseData: unsupported chainId");
a = __chainIdToAddresses[block.chainid];
require(a.OFT_DELEGATE != address(0), "BaseData: addresses not set");
require(a.TOKEN_ADMIN != address(0), "BaseData: addresses not set");
require(a.PROXY_ADMIN != address(0), "BaseData: addresses not set");
if (!isTestnet(block.chainid)) {
require(a.OFT_DELEGATE != TEMP_GNOSIS_SAFE, "BaseData: addresses not set");
require(a.TOKEN_ADMIN != TEMP_GNOSIS_SAFE, "BaseData: addresses not set");
require(a.PROXY_ADMIN != TEMP_PROXY_CONTROLLER, "BaseData: addresses not set");
}
}

function getEID(uint256 chainId) internal view returns (uint32) {
Expand All @@ -132,4 +139,9 @@ contract BaseData is Script {
bool isEID = __chainIdToLzEID[chainId] != 0;
return isSupported && isEID;
}

function isTestnet(uint256 chainId) internal view returns (bool) {
return
chainId == __chainIds.holesky || chainId == __chainIds.fraxtalTestnet || chainId == __chainIds.sepolia;
}
}
9 changes: 4 additions & 5 deletions script/DeployL1OFTAdapter.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ contract DeployL1OFTAdapter is BaseScript {

vm.broadcast();
ITransparentUpgradeableProxy(address(l1OFTAdapter)).changeAdmin(getAddresses().PROXY_ADMIN);
console.log("Deployer L1OFTAdapter at: %s", address(l1OFTAdapter));
console.log("Deployed L1OFTAdapter at: %s", address(l1OFTAdapter));
} else {
l1OFTAdapter = L1YnOFTAdapterUpgradeable(currentDeployment.oftAdapter);
console.log("Already deployed L1OFTAdapter at: %s", address(l1OFTAdapter));
Expand All @@ -59,24 +59,23 @@ contract DeployL1OFTAdapter is BaseScript {
require(address(l1OFTAdapter) == predictions.l1OftAdapter, "Prediction mismatch");

if (l1OFTAdapter.owner() == CURRENT_SIGNER) {
console.log("Setting rate limits");
vm.broadcast();
l1OFTAdapter.setRateLimits(_getRateLimitConfigs());
console.log("Set rate limits");

console.log("Setting peers");
for (uint256 i = 0; i < baseInput.l2ChainIds.length; i++) {
uint256 chainId = baseInput.l2ChainIds[i];
uint32 eid = getEID(chainId);
address adapter = predictions.l2OftAdapter;
bytes32 adapterBytes32 = addressToBytes32(adapter);
if (l1OFTAdapter.peers(eid) == adapterBytes32) {
console.log("Peer already set for chain %d", chainId);
console.log("Already set peer for chain %d", chainId);
continue;
}

vm.broadcast();
l1OFTAdapter.setPeer(eid, adapterBytes32);
console.log("Set Peer %s for eid %d", adapter, eid);
console.log("Set peer %s for eid %d", adapter, eid);
}

vm.broadcast();
Expand Down
8 changes: 3 additions & 5 deletions script/DeployL2OFTAdapter.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -111,11 +111,9 @@ contract DeployL2OFTAdapter is BaseScript {
require(predictedOFTAdapter == address(l2OFTAdapter), "Prediction mismatch");

if (l2OFTAdapter.owner() == CURRENT_SIGNER) {
console.log("Setting rate limits");
vm.broadcast();
l2OFTAdapter.setRateLimits(_getRateLimitConfigs());

console.log("Setting peers");
console.log("Set rate limits");

uint256[] memory chainIds = new uint256[](baseInput.l2ChainIds.length + 1);
for (uint256 i = 0; i < baseInput.l2ChainIds.length; i++) {
Expand All @@ -133,13 +131,13 @@ contract DeployL2OFTAdapter is BaseScript {
chainId == baseInput.l1ChainId ? predictions.l1OftAdapter : predictions.l2OftAdapter;
bytes32 adapterBytes32 = addressToBytes32(adapter);
if (l2OFTAdapter.peers(eid) == adapterBytes32) {
console.log("Peer already set for chain %d", chainId);
console.log("Already set peer for chain %d", chainId);
continue;
}

vm.broadcast();
l2OFTAdapter.setPeer(eid, adapterBytes32);
console.log("Set Peer %s for eid %d", adapter, eid);
console.log("Set peer %s for eid %d", adapter, eid);
}

vm.broadcast();
Expand Down
8 changes: 4 additions & 4 deletions script/deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -74,15 +74,15 @@ function simulate() {
}

function broadcast() {
forge script $1 --sig $2 --rpc-url $3 --account $DEPLOYER_ACCOUNT_NAME --sender $DEPLOYER_ADDRESS --broadcast
forge script $1 --sig $2 --rpc-url $3 --account $DEPLOYER_ACCOUNT_NAME --sender $DEPLOYER_ADDRESS --broadcast --slow
}

function verify() {
forge script $1 --sig $2 --rpc-url $3 --account $DEPLOYER_ACCOUNT_NAME --sender $DEPLOYER_ADDRESS --verify --etherscan-api-key $3
forge script $1 --sig $2 --rpc-url $3 --account $DEPLOYER_ACCOUNT_NAME --sender $DEPLOYER_ADDRESS --verify --etherscan-api-key $3 --slow
}

function broadcastAndVerify() {
forge script $1 --sig $2 --rpc-url $3 --account $DEPLOYER_ACCOUNT_NAME --sender $DEPLOYER_ADDRESS --broadcast --verify
forge script $1 --sig $2 --rpc-url $3 --account $DEPLOYER_ACCOUNT_NAME --sender $DEPLOYER_ADDRESS --broadcast --verify --etherscan-api-key $3 --slow
}

function getRPC() {
Expand Down Expand Up @@ -215,7 +215,7 @@ while [[ $# -gt 0 ]]; do
shift
;;
--verify | -v)
BROADCAST=true
VERIFY=true
shift
;;
--force | -f)
Expand Down

0 comments on commit 51676be

Please sign in to comment.