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

Nojira update scripts #58

Merged
merged 48 commits into from
Feb 13, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
48c1051
Support ledger & switch to ts
wcgcyx Nov 27, 2023
68faca9
Fix mocha issue
wcgcyx Nov 27, 2023
5543823
Merge pull request #57 from immutable/1993-Hardware-Wallet-Integration
wcgcyx Nov 28, 2023
ac227d3
Fix issues
wcgcyx Dec 2, 2023
d90f3b4
Fix ledge issue with multiple accounts
wcgcyx Dec 4, 2023
acdade4
Fix role control
wcgcyx Dec 5, 2023
5b7ced7
Add create2 contract deployer with access control
ermyas Dec 5, 2023
81747bd
Accept intended owner in constructor
ermyas Dec 5, 2023
3418986
Merge pull request #63 from immutable/add/create2-contract-deployer
ermyas Dec 6, 2023
5608a4e
Merge branch 'develop' into NOJIRA_UPDATE_SCRIPTS
wcgcyx Dec 6, 2023
42debb9
Fix issue
wcgcyx Dec 6, 2023
9e5dddc
Fix defaults
wcgcyx Dec 6, 2023
6e04ccb
Update root_initialisation.ts
wcgcyx Dec 8, 2023
6384295
Fix e2e
wcgcyx Dec 8, 2023
56672af
Fix CI
wcgcyx Dec 8, 2023
e90aa43
Update bootstrap
wcgcyx Dec 8, 2023
d2d9273
Merge branch 'main' into NOJIRA_UPDATE_SCRIPTS
wcgcyx Dec 13, 2023
f9f1c8a
Fix CI
wcgcyx Dec 13, 2023
e5e48a8
Add role on L2
wcgcyx Dec 13, 2023
78ac63d
Update e2e.yml
wcgcyx Dec 13, 2023
b58a234
Add verification of contracts
wcgcyx Dec 13, 2023
3ea5908
Fix CI
wcgcyx Dec 13, 2023
25a5a75
Delete verify.txt
wcgcyx Dec 14, 2023
44cf804
Update helpers.ts
wcgcyx Dec 14, 2023
e989792
Update helpers.ts
wcgcyx Dec 14, 2023
156005a
Improve stability
wcgcyx Dec 14, 2023
bcac3a9
Improve stability again
wcgcyx Dec 14, 2023
11359b3
Update verification
wcgcyx Dec 15, 2023
480d7da
Use Retry provider & Improve stability
wcgcyx Dec 19, 2023
6f5d84a
Update rate configuration
wcgcyx Dec 19, 2023
49f7af9
Fix rate limit for USDC
wcgcyx Dec 19, 2023
52130e5
Merge branch 'main' into NOJIRA_UPDATE_SCRIPTS
wcgcyx Jan 22, 2024
b8a2603
Add more e2e test cases
wcgcyx Jan 29, 2024
1f3db34
Fix CI
wcgcyx Jan 29, 2024
2a730d2
Lint
wcgcyx Jan 29, 2024
9cfd57f
Add test case
wcgcyx Jan 31, 2024
33cbe5c
Merge branch 'main' into NOJIRA_UPDATE_SCRIPTS
wcgcyx Jan 31, 2024
ba85766
Update e2e.yml
wcgcyx Jan 31, 2024
4692803
Merge branch 'main' into NOJIRA_UPDATE_SCRIPTS
wcgcyx Jan 31, 2024
9a678f6
Delete OwnableCreate2Deployer.sol
wcgcyx Feb 11, 2024
f4c7278
Delete OwnableCreate2Deployer.t.sol
wcgcyx Feb 11, 2024
1e83d42
Refactor
wcgcyx Feb 12, 2024
f102a3e
Update e2e.ts
wcgcyx Feb 12, 2024
b3bd113
Update e2e.ts
wcgcyx Feb 12, 2024
ece2260
Update e2e.ts
wcgcyx Feb 12, 2024
e7f5e37
Fix e2e
wcgcyx Feb 12, 2024
edc3b75
Fix e2e
wcgcyx Feb 12, 2024
e79a3f9
Merge branch 'main' into NOJIRA_UPDATE_SCRIPTS
wcgcyx Feb 12, 2024
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
Prev Previous commit
Next Next commit
Fix issues
  • Loading branch information
wcgcyx committed Dec 2, 2023
commit ac227d3eaccc21a9de9ec30cb5a2ebb14f34f8d4
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@
"test": "forge test",
"lint": "forge fmt",
"local:start": "cd scripts/localdev; ./start.sh",
"local:setup": "cd scripts/localdev; ./deploy.sh",
"local:test": "cd scripts/localdev; npx mocha --require mocha-suppress-logs ../e2e/e2e.ts",
"local:ci": "cd scripts/localdev; ./ci.sh && ./deploy.sh && npx mocha --require mocha-suppress-logs ../e2e/e2e.ts && ./stop.sh",
"local:setup": "cd scripts/localdev; rm -rf .child.bridge.contracts.json .root.bridge.contracts.json; ./deploy.sh",
"local:test": "cd scripts/localdev; LONG_WAIT=0 SHORT_WAIT=0 npx mocha --require mocha-suppress-logs ../e2e/e2e.ts",
"local:ci": "cd scripts/localdev; rm -rf .child.bridge.contracts.json .root.bridge.contracts.json; ./ci.sh && ./deploy.sh && LONG_WAIT=0 SHORT_WAIT=0 npx mocha --require mocha-suppress-logs ../e2e/e2e.ts && ./stop.sh",
"local:chainonly": "cd scripts/localdev; LOCAL_CHAIN_ONLY=true ./start.sh",
"local:axelaronly": "cd scripts/localdev; node axelar_setup.js",
"local:axelaronly": "cd scripts/localdev; npx ts-node axelar_setup.ts",
"stop": "cd scripts/localdev; ./stop.sh"
},
"author": "",
Expand Down
90 changes: 26 additions & 64 deletions scripts/bootstrap/.env.example
Original file line number Diff line number Diff line change
@@ -1,82 +1,44 @@
# Set prior to 1_deployer_funding.js
# Set prior to 0_pre_validation.js
# Name of the child chain MUST match Axelar's definition.
CHILD_CHAIN_NAME=
# The RPC URL of child chain.
CHILD_RPC_URL=
# The chain ID of the child chain.
CHILD_CHAIN_ID=
# Name of the root chain MUST match Axelar's definition.
ROOT_CHAIN_NAME=
# The RPC URL of root chain.
ROOT_RPC_URL=
# The chain ID of the root chain.
ROOT_CHAIN_ID=
## The admin EOA address on the child chain.
CHILD_ADMIN_ADDR=
## The private key for the admin EOA or "ledger" if using hardware wallet.
CHILD_ADMIN_EOA_SECRET=
## The ledger index for the admin EOA, required if using ledger.
CHILD_ADMIN_EOA_LEDGER_INDEX=
## The deployer address on child chain.
CHILD_DEPLOYER_ADDR=
## The private key for the deployer on child chain or "ledger" if using hardware wallet.
CHILD_DEPLOYER_SECRET=
## The ledger index for the deployer on child chain, required if using ledger.
CHILD_DEPLOYER_LEDGER_INDEX=
## The amount of fund deployer required on L2, unit is in IMX or 10^18 Wei.
CHILD_DEPLOYER_FUND=
## The deployer address on root chain.
ROOT_DEPLOYER_ADDR=
## The private key for the deployer on root chain or "ledger" if using hardware wallet.
ROOT_DEPLOYER_SECRET=
## The ledger index for the deployer on root chain, required if using ledger.
ROOT_DEPLOYER_LEDGER_INDEX=
## The private key for rate admin or "ledger" if using hardware wallet.
ROOT_BRIDGE_RATE_ADMIN_SECRET=
## The ledger index for the rate admin, required if using ledger.
ROOT_BRIDGE_RATE_ADMIN_LEDGER_INDEX=
## The deployer address on child & root chains.
DEPLOYER_ADDR=
## The private key for the deployer on child & root chains or "ledger" if using hardware wallet.
DEPLOYER_SECRET=
## The ledger index for the deployer on child & root chains, required if using ledger.
DEPLOYER_LEDGER_INDEX=
## The nonce reserved deployer address on child & root chains.
NONCE_RESERVED_DEPLOYER_ADDR=
## The nonce reserved deployer, or "ledger" if using hardware wallet.
NONCE_RESERVED_DEPLOYER_SECRET=
## The ledger index for the nonce reserved deployer.
NONCE_RESERVED_DEPLOYER_INDEX=
## The reserved nonce for token template deployment.
NONCE_RESERVED=
## The IMX token address on root chain.
ROOT_IMX_ADDR=
## The Wrapped ETH token address on the root chain.
ROOT_WETH_ADDR=
## The Axelar address for receive initial funding on the child chain.
## The Axelar address to receive initial funding on the child chain.
AXELAR_EOA=
## The amount of fund Axelar requested, unit is in IMX or 10^18 Wei.
AXELAR_FUND=
## The amount of fund deployer to be left with after bootstrapping on L2, unit is in IMX or 10^18 Wei.
CHILD_DEPLOYER_FUND=
## The amount of fund nonce reserved deployer required on L2, unit is in IMX or 10^18 Wei.
CHILD_NONCE_RESERVED_DEPLOYER_FUND=
## The maximum amount of IMX that can be deposited to L2, unit is in IMX or 10^18 Wei.
IMX_DEPOSIT_LIMIT=
## The address to perform child bridge upgrade.
CHILD_PROXY_ADMIN=
## The address to be assigned with DEFAULT_ADMIN_ROLE in child bridge.
CHILD_BRIDGE_DEFAULT_ADMIN=
## The address to be assigned with PAUSER_ROLE in child bridge.
CHILD_BRIDGE_PAUSER=
## The address to be assigned with UNPAUSER_ROLE in child bridge.
CHILD_BRIDGE_UNPAUSER=
## The address to be assigned with ADAPTOR_MANAGER_ROLE in child bridge.
CHILD_BRIDGE_ADAPTOR_MANAGER=
## The address to be assigned with DEFAULT_ADMIN_ROLE in child adaptor.
CHILD_ADAPTOR_DEFAULT_ADMIN=
## The address to be assigned with BRIDGE_MANAGER_ROLE in child adaptor.
CHILD_ADAPTOR_BRIDGE_MANAGER=
## The address to be assigned with GAS_SERVICE_MANAGER_ROLE in child adaptor.
CHILD_ADAPTOR_GAS_SERVICE_MANAGER=
## The address to be assigned with TARGET_MANAGER_ROLE in child adaptor.
CHILD_ADAPTOR_TARGET_MANAGER=
## The address to perform root adaptor upgrade.
ROOT_PROXY_ADMIN=
## The address to be assigned with DEFAULT_ADMIN_ROLE in root bridge.
ROOT_BRIDGE_DEFAULT_ADMIN=
## The address to be assigned with PAUSER_ROLE in root bridge.
ROOT_BRIDGE_PAUSER=
## The address to be assigned with UNPAUSER_ROLE in root bridge.
ROOT_BRIDGE_UNPAUSER=
## The address to be assigned with VARIABLE_MANAGER_ROLE in root bridge.
ROOT_BRIDGE_VARIABLE_MANAGER=
## The address to be assigned with ADAPTOR_MANAGER_ROLE in root bridge.
ROOT_BRIDGE_ADAPTOR_MANAGER=
## The address to be assigned with DEFAULT_ADMIN_ROLE in root adaptor.
ROOT_ADAPTOR_DEFAULT_ADMIN=
## The address to be assigned with BRIDGE_MANAGER_ROLE in root adaptor.
ROOT_ADAPTOR_BRIDGE_MANAGER=
## The address to be assigned with GAS_SERVICE_MANAGER_ROLE in root adaptor.
ROOT_ADAPTOR_GAS_SERVICE_MANAGER=
## The address to be assigned with TARGET_MANAGER_ROLE in root adaptor.
ROOT_ADAPTOR_TARGET_MANAGER=
## The capacity of the rate limit policy of IMX token, unit is in 10^18.
RATE_LIMIT_IMX_CAPACITY=
## The refill rate of the rate limit policy of IMX token, unit is in 10^18.
Expand Down
148 changes: 148 additions & 0 deletions scripts/bootstrap/0_pre_validation.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
// Pre validation
import * as dotenv from "dotenv";
dotenv.config();
import { ethers } from "ethers";
import { requireEnv, hasDuplicates } from "../helpers/helpers";
import { LedgerSigner } from "../helpers/ledger_signer";

// The total supply of IMX
const TOTAL_SUPPLY = "2000000000";

// The contract ABI of IMX on L1.
const IMX_ABI = `[{"inputs":[{"internalType":"address","name":"minter","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"spender","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"previousAdminRole","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"newAdminRole","type":"bytes32"}],"name":"RoleAdminChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleGranted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleRevoked","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Transfer","type":"event"},{"inputs":[],"name":"DEFAULT_ADMIN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MINTER_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"spender","type":"address"}],"name":"allowance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"approve","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"cap","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"decimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"subtractedValue","type":"uint256"}],"name":"decreaseAllowance","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"getRoleAdmin","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"grantRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"hasRole","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"addedValue","type":"uint256"}],"name":"increaseAllowance","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"mint","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"renounceRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"revokeRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transfer","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"sender","type":"address"},{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transferFrom","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"}]`;

function tryThrow(errorMsg: string) {
if (process.env["THROW_ON_FAIL"] != null) {
throw(errorMsg);
} else {
console.log(errorMsg);
}
}

async function run() {
console.log("=======Start Pre Validation=======");

// Check environment variables
requireEnv("CHILD_CHAIN_NAME");
let childRPCURL = requireEnv("CHILD_RPC_URL");
let childChainID = requireEnv("CHILD_CHAIN_ID");
requireEnv("ROOT_CHAIN_NAME");
let rootRPCURL = requireEnv("ROOT_RPC_URL");
let rootChainID = requireEnv("ROOT_CHAIN_ID");
let deployerAddr = requireEnv("DEPLOYER_ADDR");
let deployerSecret = requireEnv("DEPLOYER_SECRET");
let reservedDeployerAddr = requireEnv("NONCE_RESERVED_DEPLOYER_ADDR");
let reservedDeployerSecret = requireEnv("NONCE_RESERVED_DEPLOYER_SECRET");
Number(requireEnv("NONCE_RESERVED"));
let rootIMXAddr = requireEnv("ROOT_IMX_ADDR");
let rootWETHAddr = requireEnv("ROOT_WETH_ADDR");
let axelarEOA = requireEnv("AXELAR_EOA");
let axelarFund = requireEnv("AXELAR_FUND");
let childDeployerFund = requireEnv("CHILD_DEPLOYER_FUND");
let childReservedDeployerFund = requireEnv("CHILD_NONCE_RESERVED_DEPLOYER_FUND");
let imxDepositLimit = requireEnv("IMX_DEPOSIT_LIMIT");
requireEnv("RATE_LIMIT_IMX_CAPACITY");
requireEnv("RATE_LIMIT_IMX_REFILL_RATE");
requireEnv("RATE_LIMIT_IMX_LARGE_THRESHOLD");
requireEnv("RATE_LIMIT_ETH_CAPACITY");
requireEnv("RATE_LIMIT_ETH_REFILL_RATE");
requireEnv("RATE_LIMIT_ETH_LARGE_THRESHOLD");
requireEnv("RATE_LIMIT_USDC_ADDR");
requireEnv("RATE_LIMIT_USDC_CAPACITY");
requireEnv("RATE_LIMIT_USDC_REFILL_RATE");
requireEnv("RATE_LIMIT_USDC_LARGE_THRESHOLD");
requireEnv("RATE_LIMIT_GU_ADDR");
requireEnv("RATE_LIMIT_GU_CAPACITY");
requireEnv("RATE_LIMIT_GU_REFILL_RATE");
requireEnv("RATE_LIMIT_GU_LARGE_THRESHOLD");
requireEnv("RATE_LIMIT_CHECKMATE_ADDR");
requireEnv("RATE_LIMIT_CHECKMATE_CAPACITY");
requireEnv("RATE_LIMIT_CHECKMATE_REFILL_RATE");
requireEnv("RATE_LIMIT_CHECKMATE_LARGE_THRESHOLD");
requireEnv("RATE_LIMIT_GOG_ADDR");
requireEnv("RATE_LIMIT_GOG_CAPACITY");
requireEnv("RATE_LIMIT_GOG_REFILL_RATE");
requireEnv("RATE_LIMIT_GOG_LARGE_THRESHOLD");

const childProvider = new ethers.providers.JsonRpcProvider(childRPCURL, Number(childChainID));
const rootProvider = new ethers.providers.JsonRpcProvider(rootRPCURL, Number(rootChainID));
let deployerWallet;
if (deployerSecret == "ledger") {
let index = requireEnv("DEPLOYER_LEDGER_INDEX");
const derivationPath = `m/44'/60'/${parseInt(index)}'/0/0`;
deployerWallet = new LedgerSigner(childProvider, derivationPath);
} else {
deployerWallet = new ethers.Wallet(deployerSecret, childProvider);
}
let reservedWallet;
if (reservedDeployerSecret == "ledger") {
let index = requireEnv("NONCE_RESERVED_DEPLOYER_INDEX");
const derivationPath = `m/44'/60'/${parseInt(index)}'/0/0`;
reservedWallet = new LedgerSigner(childProvider, derivationPath);
} else {
reservedWallet = new ethers.Wallet(reservedDeployerSecret, childProvider);
}

// Check deployer address matches deployer addr
let actualDeployerAddress = await deployerWallet.getAddress();
if (actualDeployerAddress != deployerAddr) {
tryThrow("Deployer addresses mismatch, expect " + deployerAddr + " actual " + actualDeployerAddress);
}
let actualReservedDeployerAddress = await reservedWallet.getAddress();
if (actualReservedDeployerAddress != reservedDeployerAddr) {
tryThrow("Reserved Nonce deployer addresses mismatch, expect " + reservedDeployerAddr + " actual " + actualReservedDeployerAddress);
}

// Check duplicates
if (hasDuplicates([actualDeployerAddress, actualReservedDeployerAddress, axelarEOA])) {
throw("Duplicate address detected!");
}
if (hasDuplicates([rootIMXAddr, rootWETHAddr])) {
throw("Duplicate address detected!");
}

// Check deployer fund on root chain and child chain.
let IMX = new ethers.Contract(rootIMXAddr, IMX_ABI, rootProvider);
let rootDeployerETHBalance = await rootProvider.getBalance(actualDeployerAddress);
let rootReservedDeployerETHBalance = await rootProvider.getBalance(actualReservedDeployerAddress);
if (rootDeployerETHBalance.lt(ethers.utils.parseEther("0.1"))) {
tryThrow("Deployer on root chain needs to have at least 0.1 ETH, got " + ethers.utils.formatEther(rootDeployerETHBalance));
}
if (rootReservedDeployerETHBalance.lt(ethers.utils.parseEther("0.1"))) {
tryThrow("Reserved deployer on root chain needs to have at least 0.1 ETH, got " + ethers.utils.formatEther(rootReservedDeployerETHBalance));
}
let rootDeployerIMXBalance = await IMX.balanceOf(actualDeployerAddress);
let axelarRequiredIMX = ethers.utils.parseEther(axelarFund);
let deployerRequiredIMX = ethers.utils.parseEther(childDeployerFund);
let reservedDeployerRequiredIMX = ethers.utils.parseEther(childReservedDeployerFund);
if (axelarRequiredIMX.lt(ethers.utils.parseEther("500.0"))) {
tryThrow("Axelar on child chain should request at least 500 IMX, got" + ethers.utils.formatEther(axelarRequiredIMX));
}
if (deployerRequiredIMX.lt(ethers.utils.parseEther("500.0"))) {
tryThrow("Deployer on child chain should request at least 500 IMX, got" + ethers.utils.formatEther(deployerRequiredIMX));
}
if (reservedDeployerRequiredIMX.lt(ethers.utils.parseEther("10.0"))) {
tryThrow("Reserved deployer on child chain should request at least 10 IMX, got" + ethers.utils.formatEther(reservedDeployerRequiredIMX));
}
let extraIMX = ethers.utils.parseEther("100.0");
let requiredIMX = axelarRequiredIMX.add(deployerRequiredIMX).add(reservedDeployerRequiredIMX).add(extraIMX);
if (rootDeployerIMXBalance.lt(requiredIMX)) {
tryThrow("Deployer on root chain needs to have at least " + ethers.utils.formatEther(requiredIMX) + " IMX, got " + ethers.utils.formatEther(rootDeployerIMXBalance));
}
let childDeployerIMXBalance = await childProvider.getBalance(actualDeployerAddress);
if (!childDeployerIMXBalance.eq(ethers.utils.parseEther(TOTAL_SUPPLY))) {
tryThrow("Deployer on child chain needs to have 2B units of pre-mined IMX, got " + ethers.utils.formatEther(childDeployerIMXBalance));
}

// Check IMX deposit limit
let depositLimit = ethers.utils.parseEther(imxDepositLimit);
if (depositLimit.gt(ethers.utils.parseEther("200000000"))) {
tryThrow("Deposit limit should be at most 200m, got " + ethers.utils.formatEther(depositLimit));
}
if (depositLimit.lt(ethers.utils.parseEther("2000000"))) {
tryThrow("Deposit limit should be at least 2m, got " + ethers.utils.formatEther(depositLimit));
}

console.log("=======End Pre Validation=======");
}
run();
Loading