Skip to content

Commit

Permalink
Ensure Non Zero Bridge Amount (MystenLabs#17745)
Browse files Browse the repository at this point in the history
  • Loading branch information
Bridgerz authored May 15, 2024
1 parent f1aba95 commit e2dc6ad
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
2 changes: 2 additions & 0 deletions bridge/evm/contracts/SuiBridge.sol
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,8 @@ contract SuiBridge is ISuiBridge, CommitteeUpgradeable, PausableUpgradeable {
IERC20Metadata(tokenAddress).decimals(), config.tokenSuiDecimalOf(tokenID), amount
);

require(suiAdjustedAmount > 0, "SuiBridge: Invalid amount provided");

emit TokensDeposited(
config.chainID(),
nonces[BridgeUtils.TOKEN_TRANSFER],
Expand Down
6 changes: 6 additions & 0 deletions bridge/evm/test/SuiBridgeTest.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -548,6 +548,12 @@ contract SuiBridgeTest is BridgeBaseTest, ISuiBridge {
reentrantAttack.attack();
}

function testSuiBridgeInvalidDecimalConversion() public {
IERC20(wETH).approve(address(bridge), 10 ether);
vm.expectRevert(bytes("SuiBridge: Invalid amount provided"));
bridge.bridgeERC20(BridgeUtils.ETH, 1, abi.encode("suiAddress"), 0);
}

// An e2e token transfer regression test covering message ser/de and signature verification
function testTransferSuiToEthRegressionTest() public {
address[] memory _committee = new address[](4);
Expand Down

0 comments on commit e2dc6ad

Please sign in to comment.