From 2b2411ca5784ccc80afcf676d6aea9c6bef4b98c Mon Sep 17 00:00:00 2001 From: Alysia Huggins Date: Fri, 6 Dec 2024 08:41:41 -0500 Subject: [PATCH] updated errror types --- contracts/src/StakeTable.sol | 9 ++++++--- contracts/test/StakeTable.t.sol | 2 +- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/contracts/src/StakeTable.sol b/contracts/src/StakeTable.sol index 9d00dd9e9d..dc630eb740 100644 --- a/contracts/src/StakeTable.sol +++ b/contracts/src/StakeTable.sol @@ -45,7 +45,10 @@ contract StakeTable is AbstractStakeTable { error InsufficientAllowance(uint256, uint256); // Error raised when the staker does not have the sufficient balance on the stake ERC20 token - error InsufficientBalance(uint256, uint256); + error InsufficientBalance(uint256); + + // Error raised when the staker does not have the sufficient stake balance to withdraw + error InsufficientStakeBalance(uint256); // Error raised when the staker does not register with the correct stakeAmount error InsufficientStakeAmount(uint256); @@ -259,7 +262,7 @@ contract StakeTable is AbstractStakeTable { // Verify that the validator has the balance for this stake token. uint256 balance = ERC20(tokenAddress).balanceOf(msg.sender); if (balance < fixedStakeAmount) { - revert InsufficientBalance(balance, fixedStakeAmount); + revert InsufficientBalance(balance); } // Verify that the validator can sign for that blsVK @@ -391,7 +394,7 @@ contract StakeTable is AbstractStakeTable { // Verify that the balance is greater than zero uint256 balance = node.balance; if (balance == 0) { - revert InsufficientBalance(0, 0); + revert InsufficientStakeBalance(0); } // Verify that the validator can sign for that blsVK diff --git a/contracts/test/StakeTable.t.sol b/contracts/test/StakeTable.t.sol index 313e26dbe0..53154850f6 100644 --- a/contracts/test/StakeTable.t.sol +++ b/contracts/test/StakeTable.t.sol @@ -197,7 +197,7 @@ contract StakeTable_register_Test is Test { vm.startPrank(newUser); // Prepare for the token transfer by giving the StakeTable contract the required allowance token.approve(address(stakeTable), depositAmount); - vm.expectRevert(abi.encodeWithSelector(S.InsufficientBalance.selector, 0, depositAmount)); + vm.expectRevert(abi.encodeWithSelector(S.InsufficientBalance.selector, 0)); stakeTable.register(blsVK, schnorrVK, depositAmount, sig, validUntilEpoch); vm.stopPrank(); }