Skip to content

Commit

Permalink
updated errror types
Browse files Browse the repository at this point in the history
  • Loading branch information
alysiahuggins committed Dec 6, 2024
1 parent 7bd7f4b commit 2b2411c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
9 changes: 6 additions & 3 deletions contracts/src/StakeTable.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion contracts/test/StakeTable.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down

0 comments on commit 2b2411c

Please sign in to comment.