Skip to content

Commit

Permalink
final deploy script
Browse files Browse the repository at this point in the history
  • Loading branch information
piotrostr committed Sep 7, 2024
1 parent 70ea2cd commit dfbe23a
Showing 1 changed file with 50 additions and 5 deletions.
55 changes: 50 additions & 5 deletions packages/foundry/script/Deploy.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,59 @@ pragma solidity ^0.8.19;
import "../contracts/FairDrop.sol";
import "./DeployHelpers.s.sol";
import { DeployFairDrop } from "./00_deploy_fair_drop.s.sol";
import { DeployFairDropSatellite } from "./01_deploy_satellite.s.sol";

contract DeployScript is ScaffoldETHDeploy {
function run() external {
// DeployFairDrop deployFairDrop = new DeployFairDrop();
// deployFairDrop.run();
if (block.chainid == 10) {
// Deploy on Optimism
DeployFairDrop deployFairDrop = new DeployFairDrop();
deployFairDrop.run();
console.logString("FairDrop deployed on Optimism");
} else if (block.chainid == 42161) {
// Deploy on Arbitrum
DeployFairDropSatellite deployFairDropSatellite =
new DeployFairDropSatellite();
deployFairDropSatellite.run();
console.logString("FairDropSatellite deployed on Arbitrum");

// deploy more contracts here
// DeployMyContract deployMyContract = new DeployMyContract();
// deployMyContract.run();
// Set cross-chain information
address fairDropAddress = getDeploymentAddress("FairDrop");
address fairDropSatelliteAddress =
getDeploymentAddress("FairDropSatellite");

if (
fairDropAddress != address(0) && fairDropSatelliteAddress != address(0)
) {
FairDrop fairDrop = FairDrop(fairDropAddress);
FairDropSatellite fairDropSatellite =
FairDropSatellite(fairDropSatelliteAddress);

fairDrop.setReceiver(42161, fairDropSatelliteAddress);
fairDropSatellite.setVerifier(10, fairDropAddress);

console.logString("Cross-chain information set successfully");
} else {
console.logString(
"Unable to set cross-chain information. Make sure both contracts are deployed."
);
}
} else {
revert("Unsupported chain ID");
}
}

function getDeploymentAddress(
string memory name
) internal view returns (address) {
for (uint256 i = 0; i < deployments.length; i++) {
if (
keccak256(abi.encodePacked(deployments[i].name))
== keccak256(abi.encodePacked(name))
) {
return deployments[i].addr;
}
}
return address(0);
}
}

0 comments on commit dfbe23a

Please sign in to comment.