Omniscia 0xPhase Audit
ITreasury Code Style Findings
ITreasury Code Style Findings
ITY-01C: Multiple Top-Level Declarations
Type | Severity | Location |
---|---|---|
Code Style | ITreasury.sol:L10, L136 |
Description:
The referenced file contains multiple top-level declarations that decrease the legibility of the codebase.
Example:
treasury/ITreasury.sol
10interface ITreasury {11 struct TokenInfo {12 uint256 balance;13 bool set;14 }15
16 struct Cause {17 mapping(address => TokenInfo) token;18 address[] tokens;19 }20
21 /// @notice Event emitted when a token or ETH is donated to a cause22 /// @param cause The cause that was donated to23 /// @param token The donated token address (ETH_ADDRESS for ETH)24 /// @param amount The donation amount25 event Donated(bytes32 indexed cause, address indexed token, uint256 amount);26
27 /// @notice Event emitted when a token or ETH is spent by a cause28 /// @param cause The cause that spent29 /// @param token The spent token address (ETH_ADDRESS for ETH)30 /// @param to The spend target address31 /// @param amount The spent amount32 event Spent(33 bytes32 indexed cause,34 address indexed token,35 address indexed to,36 uint256 amount37 );38
39 /// @notice Donates a token or ETH to a cause40 /// @param cause The cause to donate to41 /// @param token The donated token address (ETH_ADDRESS for ETH)42 /// @param amount The donation amount43 function donate(44 bytes32 cause,45 address token,46 uint256 amount47 ) external payable;48
49 /// @notice Donates a token or ETH to a cause50 /// @param cause The cause to donate to51 /// @param token The donated token address (ETH_ADDRESS for ETH)52 /// @param amount The donation amount53 function donate(54 string memory cause,55 address token,56 uint256 amount57 ) external payable;58
59 /// @notice Spends a token or ETH from a cause60 /// @param cause The cause that's spending61 /// @param token The spent token address (ETH_ADDRESS for ETH)62 /// @param amount The spent amount63 /// @param to The spend target address64 function spend(65 bytes32 cause,66 address token,67 uint256 amount,68 address to69 ) external;70
71 /// @notice Spends a token or ETH from a cause72 /// @param cause The cause that's spending73 /// @param token The spent token address (ETH_ADDRESS for ETH)74 /// @param amount The spent amount75 /// @param to The spend target address76 function spend(77 string memory cause,78 address token,79 uint256 amount,80 address to81 ) external;82
83 /// @notice Increases the balance for a token or ETH for a cause without transferring it in84 /// @param cause The cause to increase for85 /// @param token The token address to increase (ETH_ADDRESS for ETH)86 /// @param amount The amount to increase87 function increaseUnsafe(88 bytes32 cause,89 address token,90 uint256 amount91 ) external;92
93 /// @notice Returns the total token or ETH balance in the treasury94 /// @param token The token address (ETH_ADDRESS for ETH)95 /// @return The balance for the token or ETH96 function tokenBalance(address token) external view returns (uint256);97
98 /// @notice Returns the total token or ETH balance in the treasury for the cause99 /// @param cause The cause to check for100 /// @param token The token address (ETH_ADDRESS for ETH)101 /// @return The balance for the token or ETH102 function tokenBalance(103 bytes32 cause,104 address token105 ) external view returns (uint256);106
107 /// @notice Returns the total token or ETH balance in the treasury for the cause108 /// @param cause The cause to check for109 /// @param token The token address (ETH_ADDRESS for ETH)110 /// @return The balance for the token or ETH111 function tokenBalance(112 string memory cause,113 address token114 ) external view returns (uint256);115
116 /// @notice Returns all tokens in the treasury117 /// @return The list of token addresses118 function tokens() external view returns (address[] memory);119
120 /// @notice Returns all tokens in the treasury for the cause121 /// @param cause The cause to check for122 /// @return The list of token addresses123 function tokens(bytes32 cause) external view returns (address[] memory);124
125 /// @notice Returns all tokens in the treasury for the cause126 /// @param cause The cause to check for127 /// @return The list of token addresses128 function tokens(string memory cause) external view returns (address[] memory);129
130 /// @notice Returns the reserved address to represent native ETH131 /// @return The reserved ETH address132 // solhint-disable-next-line func-name-mixedcase133 function ETH_ADDRESS() external view returns (address);134}135
136abstract contract TreasuryStorageV1 is
Recommendation:
We advise all highlighted top-level declarations to be split into their respective code files, avoiding unnecessary imports as well as increasing the legibility of the codebase.
Alleviation (3dd3d7bf0c2693b2f9c23bacedfa420393f7ea84):
The TreasuryStorageV1
implementation was split to its dedicated file, rendering this exhibit applied in full.