Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

deploy: whitelist with gateway #84

Merged
merged 2 commits into from
Feb 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions scripts/DeployScripts.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ contract DeployScript is Script, Create2Deployer {
contract DeployWhitelist is Script, Create2Deployer {
function run() external {

console.log("Warning: DeployWhitelist is deprecated and only for backwards compatibility with hyperlane");

address expectedWhiteListAddr = 0x57508f0B0f3426758F1f3D63ad4935a7c9383620;
if (isContractDeployed(expectedWhiteListAddr)) {
console.log("Whitelist already deployed to:", expectedWhiteListAddr);
Expand Down
51 changes: 34 additions & 17 deletions scripts/DeployStandardBridge.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,12 @@ import "forge-std/Script.sol";
import {Create2Deployer} from "scripts/DeployScripts.s.sol";
import {SettlementGateway} from "contracts/standard-bridge/SettlementGateway.sol";
import {L1Gateway} from "contracts/standard-bridge/L1Gateway.sol";
import {Whitelist} from "contracts/Whitelist.sol";
import {Strings} from "@openzeppelin/contracts/utils/Strings.sol";

contract DeploySettlementGateway is Script, Create2Deployer {
function run() external {

// Note this addr is dependant on values given to contract constructor
address expectedAddr = 0xc1f93bE11D7472c9B9a4d87B41dD0a491F1fbc75;
if (isContractDeployed(expectedAddr)) {
console.log("Standard bridge gateway on settlement chain already deployed to:",
expectedAddr);
return;
}

vm.startBroadcast();

checkCreate2Deployed();
Expand All @@ -25,8 +19,12 @@ contract DeploySettlementGateway is Script, Create2Deployer {
bytes32 salt = 0x8989000000000000000000000000000000000000000000000000000000000000;

address expectedWhitelistAddr = 0x57508f0B0f3426758F1f3D63ad4935a7c9383620;
address relayerAddr = vm.envAddress("RELAYER_ADDR");
if (isContractDeployed(expectedWhitelistAddr)) {
console.log("Whitelist must not be deployed to execute DeploySettlementGateway script. Exiting...");
return;
}

address relayerAddr = vm.envAddress("RELAYER_ADDR");
SettlementGateway gateway = new SettlementGateway{salt: salt}(
expectedWhitelistAddr,
msg.sender, // Owner
Expand All @@ -35,21 +33,33 @@ contract DeploySettlementGateway is Script, Create2Deployer {
console.log("Standard bridge gateway for settlement chain deployed to:",
address(gateway));

Whitelist whitelist = new Whitelist{salt: salt}(msg.sender);
console.log("Whitelist deployed to:", address(whitelist));

if (!isContractDeployed(expectedWhitelistAddr)) {
console.log("Whitelist not deployed to expected address:", expectedWhitelistAddr);
return;
}

whitelist.addToWhitelist(address(gateway));
console.log("Settlement gateway has been whitelisted. Gateway contract address:", address(gateway));

string memory jsonOutput = string.concat(
'{"settlement_gateway_addr": "',
Strings.toHexString(address(gateway)),
'", "whitelist_addr": "',
Strings.toHexString(address(whitelist)),
'"}'
);
console.log("JSON_DEPLOY_ARTIFACT:", jsonOutput);

vm.stopBroadcast();
}
}

contract DeployL1Gateway is Script, Create2Deployer {
function run() external {

// Note this addr is dependant on values given to contract constructor
address expectedAddr = 0x1a18dfEc4f2B66207b1Ad30aB5c7A0d62Ef4A40b;
if (isContractDeployed(expectedAddr)) {
console.log("Standard bridge gateway on l1 already deployed to:",
expectedAddr);
return;
}

vm.startBroadcast();

checkCreate2Deployed();
Expand All @@ -66,6 +76,13 @@ contract DeployL1Gateway is Script, Create2Deployer {
1, 1); // Fees set to 1 wei for now
console.log("Standard bridge gateway for l1 deployed to:",
address(gateway));

string memory jsonOutput = string.concat(
'{"l1_gateway_addr": "',
Strings.toHexString(address(gateway)),
'"}'
);
console.log("JSON_DEPLOY_ARTIFACT:", jsonOutput);

vm.stopBroadcast();
}
Expand Down
Loading