Skip to content

Commit

Permalink
script: init script
Browse files Browse the repository at this point in the history
  • Loading branch information
nxqbao committed Apr 3, 2024
1 parent b037428 commit 87191a6
Show file tree
Hide file tree
Showing 6 changed files with 100 additions and 15 deletions.
2 changes: 2 additions & 0 deletions foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -50,5 +50,7 @@ runs = 1_000
[rpc_endpoints]
ethereum = "https://eth.llamarpc.com"
goerli = "https://ethereum-goerli.publicnode.com"
# sepolia = "https://ethereum-sepolia-rpc.publicnode.com"
sepolia = "https://sepolia.infura.io/v3/198b01af94b445f78c6d5ef985f57264"
ronin-mainnet = "https://api-partner.roninchain.com/rpc"
ronin-testnet = "https://saigon-archive.roninchain.com/rpc"
76 changes: 76 additions & 0 deletions script/20240403-deploy-sepolia/deploy-sepolia.s.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
import { BaseMigration } from "foundry-deployment-kit/BaseMigration.s.sol";

import { ISharedArgument } from "@ronin/script/interfaces/ISharedArgument.sol";
import { LibSharedAddress } from "foundry-deployment-kit/libraries/LibSharedAddress.sol";

import { MainchainGatewayV3 } from "@ronin/contracts/mainchain/MainchainGatewayV3.sol";
import { PauseEnforcer } from "@ronin/contracts/ronin/gateway/PauseEnforcer.sol";
import { MainchainBridgeManager } from "@ronin/contracts/mainchain/MainchainBridgeManager.sol";
import { MockERC20 } from "@ronin/contracts/mocks/token/MockERC20.sol";
import { MockERC721 } from "@ronin/contracts/mocks/token/MockERC721.sol";
import { MockWrappedToken } from "@ronin/contracts/mocks/token/MockWrappedToken.sol";

import { MainchainBridgeAdminUtils } from "test/helpers/MainchainBridgeAdminUtils.t.sol";

import { MainchainGatewayV3Deploy } from "@ronin/script/contracts/MainchainGatewayV3Deploy.s.sol";
import { MainchainBridgeManagerDeploy } from "@ronin/script/contracts/MainchainBridgeManagerDeploy.s.sol";
import { MainchainPauseEnforcerDeploy } from "@ronin/script/contracts/MainchainPauseEnforcerDeploy.s.sol";
import { WETHDeploy } from "@ronin/script/contracts/token/WETHDeploy.s.sol";
import { WRONDeploy } from "@ronin/script/contracts/token/WRONDeploy.s.sol";
import { AXSDeploy } from "@ronin/script/contracts/token/AXSDeploy.s.sol";
import { SLPDeploy } from "@ronin/script/contracts/token/SLPDeploy.s.sol";
import { USDCDeploy } from "@ronin/script/contracts/token/USDCDeploy.s.sol";
import { MockERC721Deploy } from "@ronin/script/contracts/token/MockERC721Deploy.s.sol";

import { GeneralConfigExtended } from "../GeneralConfigExtended.sol";
import { Network } from "../utils/Network.sol";

contract DeploySepolia is BaseMigration {
ISharedArgument.SharedParameter _param;

PauseEnforcer _mainchainPauseEnforcer;
MainchainGatewayV3 _mainchainGatewayV3;
MainchainBridgeManager _mainchainBridgeManager;

MockWrappedToken _mainchainWeth;
MockERC20 _mainchainAxs;
MockERC20 _mainchainSlp;
MockERC20 _mainchainUsdc;
MockERC721 _mainchainMockERC721;

MainchainBridgeAdminUtils _mainchainProposalUtils;

function _configByteCode() internal virtual override returns (bytes memory) {
return abi.encodePacked(type(GeneralConfigExtended).creationCode);
}

function _sharedArguments() internal virtual override returns (bytes memory rawArgs) {
return "";
}

function setUp() public override {
super.setUp();
}

function run() public {
// function run() public onlyOn(Network.Sepolia.key()) {
_deployContractsOnMainchain();
}

function _deployContractsOnMainchain() internal {
// _mainchainPauseEnforcer = new MainchainPauseEnforcerDeploy().run();
_mainchainGatewayV3 = new MainchainGatewayV3Deploy().run();
_mainchainBridgeManager = new MainchainBridgeManagerDeploy().run();

_mainchainWeth = new WETHDeploy().run();
_mainchainAxs = new AXSDeploy().run();
_mainchainSlp = new SLPDeploy().run();
_mainchainUsdc = new USDCDeploy().run();
_mainchainMockERC721 = new MockERC721Deploy().run();

_param = ISharedArgument(LibSharedAddress.CONFIG).sharedArguments();
_mainchainProposalUtils = new MainchainBridgeAdminUtils(
_param.test.governorPKs, _mainchainBridgeManager, _param.mainchainBridgeManager.governors[0]
);
}
}
12 changes: 6 additions & 6 deletions script/GeneralConfig.sol
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ contract GeneralConfig is BaseGeneralConfig, Utils {

function _setUpNetworks() internal virtual override {
setNetworkInfo(
Network.Goerli.chainId(),
Network.Goerli.key(),
Network.Goerli.chainAlias(),
Network.Goerli.deploymentDir(),
Network.Goerli.envLabel(),
Network.Goerli.explorer()
Network.Sepolia.chainId(),
Network.Sepolia.key(),
Network.Sepolia.chainAlias(),
Network.Sepolia.deploymentDir(),
Network.Sepolia.envLabel(),
Network.Sepolia.explorer()
);
setNetworkInfo(
Network.EthMainnet.chainId(),
Expand Down
14 changes: 7 additions & 7 deletions script/GeneralConfigExtended.sol
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ contract GeneralConfigExtended is BaseGeneralConfig {

function _setUpNetworks() internal virtual override {
setNetworkInfo(
Network.Goerli.chainId(),
Network.Goerli.key(),
Network.Goerli.chainAlias(),
Network.Goerli.deploymentDir(),
Network.Goerli.envLabel(),
Network.Goerli.explorer()
Network.Sepolia.chainId(),
Network.Sepolia.key(),
Network.Sepolia.chainAlias(),
Network.Sepolia.deploymentDir(),
Network.Sepolia.envLabel(),
Network.Sepolia.explorer()
);
setNetworkInfo(
Network.EthMainnet.chainId(),
Expand All @@ -46,7 +46,7 @@ contract GeneralConfigExtended is BaseGeneralConfig {
}

function getCompanionNetwork(TNetwork network) external pure returns (Network) {
if (network == DefaultNetwork.RoninTestnet.key()) return Network.Goerli;
if (network == DefaultNetwork.RoninTestnet.key()) return Network.Sepolia;
if (network == DefaultNetwork.RoninMainnet.key()) return Network.EthMainnet;
revert("Network: Unknown companion network");
}
Expand Down
2 changes: 1 addition & 1 deletion script/Migration.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ contract Migration is BaseMigrationV2, Utils {
function _sharedArguments() internal virtual override returns (bytes memory rawArgs) {
ISharedArgument.SharedParameter memory param;

if (network() == Network.Goerli.key()) {
if (network() == Network.Sepolia.key()) {
// Undefined
} else if (network() == DefaultNetwork.RoninTestnet.key()) {
// Undefined
Expand Down
9 changes: 8 additions & 1 deletion script/utils/Network.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { LibString, TNetwork } from "foundry-deployment-kit/types/Types.sol";

enum Network {
Goerli,
Sepolia,
EthMainnet,
RoninDevnet
}
Expand All @@ -13,6 +14,7 @@ using { key, name, chainId, chainAlias, envLabel, deploymentDir, explorer } for

function chainId(Network network) pure returns (uint256) {
if (network == Network.Goerli) return 5;
if (network == Network.Sepolia) return 11155111;
if (network == Network.EthMainnet) return 1;
if (network == Network.RoninDevnet) return 2022;

Expand All @@ -25,11 +27,13 @@ function key(Network network) pure returns (TNetwork) {

function explorer(Network network) pure returns (string memory link) {
if (network == Network.Goerli) return "https://goerli.etherscan.io/";
if (network == Network.Sepolia) return "https://sepolia.etherscan.io/";
if (network == Network.EthMainnet) return "https://etherscan.io/";
}

function name(Network network) pure returns (string memory) {
if (network == Network.Goerli) return "Goerli";
if (network == Network.Sepolia) return "Sepolia";
if (network == Network.RoninDevnet) return "RoninDevnet";
if (network == Network.EthMainnet) return "EthMainnet";

Expand All @@ -38,14 +42,16 @@ function name(Network network) pure returns (string memory) {

function deploymentDir(Network network) pure returns (string memory) {
if (network == Network.Goerli) return "goerli/";
if (network == Network.Sepolia) return "sepolia/";
if (network == Network.EthMainnet) return "ethereum/";
if (network == Network.RoninDevnet) return "ronin-devnet/";

revert("Network: Unknown network deployment directory");
}

function envLabel(Network network) pure returns (string memory) {
if (network == Network.Goerli) return "TESTNET_PK";
if (network == Network.Goerli) return "GOERLI_PK";
if (network == Network.Sepolia) return "SEPOLIA_PK";
if (network == Network.RoninDevnet) return "DEVNET_PK";
if (network == Network.EthMainnet) return "MAINNET_PK";

Expand All @@ -54,6 +60,7 @@ function envLabel(Network network) pure returns (string memory) {

function chainAlias(Network network) pure returns (string memory) {
if (network == Network.Goerli) return "goerli";
if (network == Network.Sepolia) return "sepolia";
if (network == Network.EthMainnet) return "ethereum";
if (network == Network.RoninDevnet) return "ronin-devnet";

Expand Down

0 comments on commit 87191a6

Please sign in to comment.