Skip to content

Commit

Permalink
test: coverage for SuccinctFeeVault
Browse files Browse the repository at this point in the history
  • Loading branch information
mattstam committed Oct 31, 2023
1 parent 669ad3a commit 95f6a87
Show file tree
Hide file tree
Showing 3 changed files with 667 additions and 26 deletions.
15 changes: 4 additions & 11 deletions contracts/src/payments/SuccinctFeeVault.sol
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,6 @@ contract SuccinctFeeVault is IFeeVault, TimelockedUpgradeable {
/// @notice The allowed senders for the deduct functions.
mapping(address => bool) public allowedDeductors;

event Received(address indexed account, address indexed token, uint256 amount);
event Deducted(address indexed account, address indexed token, uint256 amount);
event Collected(address indexed to, address indexed token, uint256 amount);

error InvalidAccount(address account);
error InvalidToken(address token);
error InsufficentAllowance(address token, uint256 amount);
error InsufficientBalance(address token, uint256 amount);
error FailedToSendNative(uint256 amount);
error OnlyDeductor(address sender);

modifier onlyDeductor() {
if (!allowedDeductors[msg.sender]) {
revert OnlyDeductor(msg.sender);
Expand Down Expand Up @@ -168,4 +157,8 @@ contract SuccinctFeeVault is IFeeVault, TimelockedUpgradeable {

emit Collected(_to, _token, _amount);
}

/// @dev This empty reserved space to add new variables without shifting down storage.
/// See: https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
uint256[50] private __gap;
}
31 changes: 16 additions & 15 deletions contracts/src/payments/interfaces/IFeeVault.sol
Original file line number Diff line number Diff line change
@@ -1,22 +1,23 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.16;

interface IFeeVault {
/// @notice Returns the amount of active balance that an account has.
/// @param token The address of the token to check the balance of. To check native currency
/// balance, use address(0) as the token address.
/// @param account The address of the account to check the balance of.
function balances(address token, address account) external view returns (uint256);
interface IFeeVaultEvents {
event Received(address indexed account, address indexed token, uint256 amount);
event Deducted(address indexed account, address indexed token, uint256 amount);
event Collected(address indexed to, address indexed token, uint256 amount);
}

/// @notice Deposit the specified amount of native currency from the caller.
/// @dev The native currency is represented by address(0) in balances.
/// @param account The account to deposit the native currency for.
function depositNative(address account) external payable;
interface IFeeVaultErrors {
error InvalidAccount(address account);
error InvalidToken(address token);
error InsufficentAllowance(address token, uint256 amount);
error InsufficientBalance(address token, uint256 amount);
error FailedToSendNative(uint256 amount);
error OnlyDeductor(address sender);
}

/// @notice Deposit the specified amount of the specified token from the caller.
/// @dev MUST approve this contract to spend at least `amount` of `token` before calling this.
/// @param account The account to deposit the tokens to.
/// @param token The address of the token to deposit.
/// @param amount The amount of the token to deposit.
interface IFeeVault is IFeeVaultEvents, IFeeVaultErrors {
function balances(address token, address account) external view returns (uint256);
function depositNative(address account) external payable;
function deposit(address account, address token, uint256 amount) external;
}
Loading

0 comments on commit 95f6a87

Please sign in to comment.