Skip to content

Commit

Permalink
fix: for uint replace > 0 with != 0
Browse files Browse the repository at this point in the history
  • Loading branch information
maximebrugel committed Dec 21, 2021
1 parent ae9ed2a commit 03fc18a
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 15 deletions.
5 changes: 3 additions & 2 deletions contracts/FeeSplitter.sol
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ contract FeeSplitter is Ownable, ReentrancyGuard {
/// @param _weights Weight for each shareholder. Determines part of the payment allocated to them
function setShareholders(address[] memory _accounts, uint256[] memory _weights) public onlyOwner {
delete shareholders;
require(_accounts.length > 0 && _accounts.length == _weights.length, "FS: INPUTS_LENGTH_MUST_MATCH");
require(_accounts.length != 0 && _accounts.length == _weights.length, "FS: INPUTS_LENGTH_MUST_MATCH");
totalWeights = royaltiesWeight;

for (uint256 i = 0; i < _accounts.length; i++) {
Expand Down Expand Up @@ -262,10 +262,11 @@ contract FeeSplitter is Ownable, ReentrancyGuard {
}

function _addShareholder(address _account, uint256 _weight) private {
require(_weight > 0, "FS: ZERO_WEIGHT");
require(_weight != 0, "FS: ZERO_WEIGHT");
for (uint256 i = 0; i < shareholders.length; i++) {
require(shareholders[i].account != _account, "FS: ALREADY_SHAREHOLDER");
}

shareholders.push(Shareholder(_account, _weight));
totalWeights += _weight;
}
Expand Down
2 changes: 1 addition & 1 deletion contracts/NestedBuybacker.sol
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ contract NestedBuybacker is Ownable {
address payable _swapTarget,
IERC20 _sellToken
) external onlyOwner {
if (feeSplitter.getAmountDue(address(this), _sellToken) > 0) {
if (feeSplitter.getAmountDue(address(this), _sellToken) != 0) {
feeSplitter.releaseToken(_sellToken);
}
require(ExchangeHelpers.fillQuote(_sellToken, _swapTarget, _swapCallData), "NB : FAILED_SWAP");
Expand Down
14 changes: 7 additions & 7 deletions contracts/NestedFactory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ contract NestedFactory is INestedFactory, ReentrancyGuard, Ownable, MixinOperato
while (operators[i] != operator) {
i++;
}
require(i > 0, "NF: NON_EXISTENT_OPERATOR");
require(i != 0, "NF: NON_EXISTENT_OPERATOR");
delete operators[i];
}

Expand All @@ -112,7 +112,7 @@ contract NestedFactory is INestedFactory, ReentrancyGuard, Ownable, MixinOperato
uint256 _sellTokenAmount,
Order[] calldata _orders
) external payable override nonReentrant {
require(_orders.length > 0, "NF: INVALID_ORDERS");
require(_orders.length != 0, "NF: INVALID_ORDERS");

uint256 nftId = nestedAsset.mint(_msgSender(), _originalTokenId);
(uint256 fees, IERC20 tokenSold) = _submitInOrders(nftId, _sellToken, _sellTokenAmount, _orders, true, false);
Expand All @@ -128,7 +128,7 @@ contract NestedFactory is INestedFactory, ReentrancyGuard, Ownable, MixinOperato
uint256 _sellTokenAmount,
Order[] calldata _orders
) external payable override nonReentrant onlyTokenOwner(_nftId) {
require(_orders.length > 0, "NF: INVALID_ORDERS");
require(_orders.length != 0, "NF: INVALID_ORDERS");
require(nestedRecords.getAssetReserve(_nftId) == address(reserve), "NF: RESERVE_MISMATCH");

(uint256 fees, IERC20 tokenSold) = _submitInOrders(_nftId, _sellToken, _sellTokenAmount, _orders, true, false);
Expand All @@ -143,7 +143,7 @@ contract NestedFactory is INestedFactory, ReentrancyGuard, Ownable, MixinOperato
uint256 _sellTokenAmount,
Order[] calldata _orders
) external override nonReentrant onlyTokenOwner(_nftId) isUnlocked(_nftId) {
require(_orders.length > 0, "NF: INVALID_ORDERS");
require(_orders.length != 0, "NF: INVALID_ORDERS");
require(nestedRecords.getAssetReserve(_nftId) == address(reserve), "NF: RESERVE_MISMATCH");

(uint256 fees, IERC20 tokenSold) = _submitInOrders(_nftId, _sellToken, _sellTokenAmount, _orders, true, true);
Expand All @@ -159,7 +159,7 @@ contract NestedFactory is INestedFactory, ReentrancyGuard, Ownable, MixinOperato
uint256[] memory _sellTokensAmount,
Order[] calldata _orders
) external override nonReentrant onlyTokenOwner(_nftId) isUnlocked(_nftId) {
require(_orders.length > 0, "NF: INVALID_ORDERS");
require(_orders.length != 0, "NF: INVALID_ORDERS");
require(_sellTokensAmount.length == _orders.length, "NF: INPUTS_LENGTH_MUST_MATCH");
require(nestedRecords.getAssetReserve(_nftId) == address(reserve), "NF: RESERVE_MISMATCH");

Expand All @@ -176,7 +176,7 @@ contract NestedFactory is INestedFactory, ReentrancyGuard, Ownable, MixinOperato
uint256[] memory _sellTokensAmount,
Order[] calldata _orders
) external override nonReentrant onlyTokenOwner(_nftId) isUnlocked(_nftId) {
require(_orders.length > 0, "NF: INVALID_ORDERS");
require(_orders.length != 0, "NF: INVALID_ORDERS");
require(_sellTokensAmount.length == _orders.length, "NF: INPUTS_LENGTH_MUST_MATCH");
require(nestedRecords.getAssetReserve(_nftId) == address(reserve), "NF: RESERVE_MISMATCH");

Expand All @@ -201,7 +201,7 @@ contract NestedFactory is INestedFactory, ReentrancyGuard, Ownable, MixinOperato
Order[] calldata _orders
) external override nonReentrant onlyTokenOwner(_nftId) isUnlocked(_nftId) {
address[] memory tokens = nestedRecords.getAssetTokens(_nftId);
require(_orders.length > 0, "NF: INVALID_ORDERS");
require(_orders.length != 0, "NF: INVALID_ORDERS");
require(tokens.length == _orders.length, "NF: INPUTS_LENGTH_MUST_MATCH");
require(nestedRecords.getAssetReserve(_nftId) == address(reserve), "NF: RESERVE_MISMATCH");

Expand Down
2 changes: 1 addition & 1 deletion contracts/NestedRecords.sol
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ contract NestedRecords is OwnableFactoryHandler {
/// @notice Sets the maximum number of holdings for an NFT record
/// @param _maxHoldingsCount The new maximum number of holdings
function setMaxHoldingsCount(uint256 _maxHoldingsCount) external onlyOwner {
require(_maxHoldingsCount > 0, "NRC: INVALID_MAX_HOLDINGS");
require(_maxHoldingsCount != 0, "NRC: INVALID_MAX_HOLDINGS");
maxHoldingsCount = _maxHoldingsCount;
emit MaxHoldingsChanges(maxHoldingsCount);
}
Expand Down
2 changes: 1 addition & 1 deletion contracts/operators/Flat/FlatOperator.sol
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ contract FlatOperator is IFlatOperator, IOperatorSelector {
address token,
uint256 amount
) external payable override returns (uint256[] memory amounts, address[] memory tokens) {
require(amount > 0, "FO: INVALID_AMOUNT");
require(amount != 0, "FO: INVALID_AMOUNT");

amounts = new uint256[](2);
tokens = new address[](2);
Expand Down
2 changes: 1 addition & 1 deletion contracts/operators/Flat/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ function commitAndRevert(
address token,
uint256 amount
) external payable override returns (uint256[] memory amounts, address[] memory tokens) {
require(amount > 0, "FO: INVALID_AMOUNT");
require(amount != 0, "FO: INVALID_AMOUNT");

amounts = new uint256[](2);
tokens = new address[](2);
Expand Down
4 changes: 2 additions & 2 deletions contracts/operators/ZeroEx/ZeroExOperator.sol
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ contract ZeroExOperator is IZeroExOperator, IOperatorSelector {

uint256 amountBought = buyToken.balanceOf(address(this)) - buyBalanceBeforePurchase;
uint256 amountSold = sellBalanceBeforePurchase - sellToken.balanceOf(address(this));
require(amountBought > 0, "ZeroExOperator::commitAndRevert: amountBought cant be zero");
require(amountSold > 0, "ZeroExOperator::commitAndRevert: amountSold cant be zero");
require(amountBought != 0, "ZeroExOperator::commitAndRevert: amountBought cant be zero");
require(amountSold != 0, "ZeroExOperator::commitAndRevert: amountSold cant be zero");

// Output amounts
amounts[0] = amountBought;
Expand Down

0 comments on commit 03fc18a

Please sign in to comment.