Skip to content

Commit

Permalink
fix: script check balance
Browse files Browse the repository at this point in the history
  • Loading branch information
yiweichi committed Sep 3, 2024
1 parent 9adfdf5 commit 8f9a190
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions scripts/deterministic/DeployScroll.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,10 @@ contract DeployScroll is DeterminsticDeployment {

// check funds for initial deposit (L1, ETH as gas token)
if (broadcastLayer == Layer.L1 && !ALTERNATIVE_GAS_TOKEN_ENABLED) {
uint256 l1MessengerBalance = address(L1_SCROLL_MESSENGER_PROXY_ADDR).balance;
address l1ScrollMessengerProxyAddr = contractsCfg.readAddress(
string(abi.encodePacked(".L1_SCROLL_MESSENGER_PROXY_ADDR"))
);
uint256 l1MessengerBalance = l1ScrollMessengerProxyAddr.balance;
uint256 amountToLock = L2_DEPLOYER_INITIAL_BALANCE;

uint256 amountToSend = 0;
Expand Down Expand Up @@ -292,11 +295,12 @@ contract DeployScroll is DeterminsticDeployment {
// skip it if L1_GAS_TOKEN is not configured in the config file
address gasTokenAddr = tryGetOverride("L1_GAS_TOKEN");
if (broadcastLayer == Layer.L1 && ALTERNATIVE_GAS_TOKEN_ENABLED && gasTokenAddr != address(0)) {
uint256 l1GasTokenGatewayBalance = IERC20Metadata(L1_GAS_TOKEN_ADDR).balanceOf(
L1_GAS_TOKEN_GATEWAY_PROXY_ADDR
address l1GasTokenGatewayAddr = contractsCfg.readAddress(
string(abi.encodePacked(".L1_GAS_TOKEN_GATEWAY_PROXY_ADDR"))
);
uint256 l1GasTokenGatewayBalance = IERC20Metadata(gasTokenAddr).balanceOf(l1GasTokenGatewayAddr);

uint256 scale = 10**(18 - IERC20Metadata(L1_GAS_TOKEN_ADDR).decimals());
uint256 scale = 10**(18 - IERC20Metadata(gasTokenAddr).decimals());
uint256 amountToLock = L2_DEPLOYER_INITIAL_BALANCE / scale;
if (L2_DEPLOYER_INITIAL_BALANCE % scale != 0) {
amountToLock += 1;
Expand All @@ -309,14 +313,14 @@ contract DeployScroll is DeterminsticDeployment {

uint256 minBalance = amountToSend;

if (IERC20Metadata(L1_GAS_TOKEN_ADDR).balanceOf(DEPLOYER_ADDR) < minBalance) {
if (IERC20Metadata(gasTokenAddr).balanceOf(DEPLOYER_ADDR) < minBalance) {
revert(
string(
abi.encodePacked(
"[ERROR] insufficient funds on deployer account for initial deposit (",
vm.toString(DEPLOYER_ADDR),
") minimum ",
IERC20Metadata(L1_GAS_TOKEN_ADDR).symbol(),
IERC20Metadata(gasTokenAddr).symbol(),
" balance (in min token unit): ",
vm.toString(minBalance)
)
Expand Down

0 comments on commit 8f9a190

Please sign in to comment.