Skip to content

Commit

Permalink
First round of reviews
Browse files Browse the repository at this point in the history
Co-authored-by: Hadrien Croubois <hadrien.croubois@gmail.com>
  • Loading branch information
ernestognw and Amxx committed May 22, 2023
1 parent adbe841 commit c29e041
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 13 deletions.
6 changes: 3 additions & 3 deletions contracts/finance/PaymentSplitter.sol
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ contract PaymentSplitter is Context {
* total shares and their previous withdrawals.
*/
function release(address payable account) public virtual {
if (_shares[account] <= 0) {
if (_shares[account] == 0) {
revert PaymentSplitterEmptyShares(account);
}

Expand All @@ -196,7 +196,7 @@ contract PaymentSplitter is Context {
* contract.
*/
function release(IERC20 token, address account) public virtual {
if (_shares[account] <= 0) {
if (_shares[account] == 0) {
revert PaymentSplitterEmptyShares(account);
}

Expand Down Expand Up @@ -239,7 +239,7 @@ contract PaymentSplitter is Context {
if (account == address(0)) {
revert PaymentSplitterInvalidPayee(account);
}
if (shares_ <= 0) {
if (shares_ == 0) {
revert PaymentSplitterEmptyShares(account);
}
if (_shares[account] != 0) {
Expand Down
2 changes: 1 addition & 1 deletion contracts/governance/Governor.sol
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ abstract contract Governor is Context, ERC165, EIP712, IGovernor, IERC721Receive
if (currentState != ProposalState.Pending) {
revert GovernorIncorrectState(proposalId, currentState, _encodeState(ProposalState.Pending));
}
address proposer = _proposals[proposalId].proposer;
address proposer = proposalProposer(proposalId);
if (_msgSender() != proposer) {
revert GovernorOnlyProposer(_msgSender());
}
Expand Down
4 changes: 2 additions & 2 deletions contracts/token/ERC20/extensions/ERC20FlashMint.sol
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ abstract contract ERC20FlashMint is ERC20, IERC3156FlashLender {
/**
* @dev The loan token is not valid.
*/
error ERC3156InvalidToken(address token);
error ERC3156UnsupportedToken(address token);

/**
* @dev The requested loan exceeds the max loan amount for `token`.
Expand Down Expand Up @@ -53,7 +53,7 @@ abstract contract ERC20FlashMint is ERC20, IERC3156FlashLender {
*/
function flashFee(address token, uint256 amount) public view virtual override returns (uint256) {
if (token != address(this)) {
revert ERC3156InvalidToken(token);
revert ERC3156UnsupportedToken(token);
}
return _flashFee(token, amount);
}
Expand Down
6 changes: 1 addition & 5 deletions contracts/token/ERC20/extensions/ERC20Snapshot.sol
Original file line number Diff line number Diff line change
Expand Up @@ -142,11 +142,7 @@ abstract contract ERC20Snapshot is ERC20 {
}

function _valueAt(uint256 snapshotId, Snapshots storage snapshots) private view returns (bool, uint256) {
if (snapshotId == 0) {
revert ERC20InvalidSnapshot(0);
}
if (snapshotId > _getCurrentSnapshotId()) {
// Non existent id
if (snapshotId == 0 || snapshotId > _getCurrentSnapshotId()) {
revert ERC20InvalidSnapshot(snapshotId);
}

Expand Down
12 changes: 10 additions & 2 deletions scripts/generate/templates/SafeCast.js
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,15 @@ function toUint${length}(int${length} value) internal pure returns (uint${length
module.exports = format(
header.trimEnd(),
'library SafeCast {',
[...LENGTHS.map(toUintDownCastErrors), toUintErrors(256), ...LENGTHS.map(toIntDownCastErrors), toIntErrors(256)],
[...LENGTHS.map(toUintDownCast), toUint(256), ...LENGTHS.map(toIntDownCast), toInt(256)],
[
...LENGTHS.map(toUintDownCastErrors),
toUintErrors(256),
...LENGTHS.map(toIntDownCastErrors),
toIntErrors(256),
...LENGTHS.map(toUintDownCast),
toUint(256),
...LENGTHS.map(toIntDownCast),
toInt(256),
],
'}',
);

0 comments on commit c29e041

Please sign in to comment.