diff --git a/foundry.toml b/foundry.toml index a55567b..0686a21 100644 --- a/foundry.toml +++ b/foundry.toml @@ -1,6 +1,6 @@ [profile.default] libs = ['lib'] -solc_version = "0.8.21" # Override for the solc version (setting this ignores `auto_detect_solc`) +solc_version = "0.8.23" # Override for the solc version (setting this ignores `auto_detect_solc`) evm_version = "paris" # to prevent usage of PUSH0, which is not supported on all chains optimizer = true diff --git a/lib/forge-std b/lib/forge-std index f73c73d..705263c 160000 --- a/lib/forge-std +++ b/lib/forge-std @@ -1 +1 @@ -Subproject commit f73c73d2018eb6a111f35e4dae7b4f27401e9421 +Subproject commit 705263c95892a906d7af65f0f73ce8a4a0c80b80 diff --git a/lib/openzeppelin-contracts b/lib/openzeppelin-contracts index 9c22fb5..932fddf 160000 --- a/lib/openzeppelin-contracts +++ b/lib/openzeppelin-contracts @@ -1 +1 @@ -Subproject commit 9c22fb5f33ece00e35ed1be4a4a3eb82c6aefeaa +Subproject commit 932fddf69a699a9a80fd2396fd1a2ab91cdda123 diff --git a/lib/solmate b/lib/solmate index 0384dba..fadb2e2 160000 --- a/lib/solmate +++ b/lib/solmate @@ -1 +1 @@ -Subproject commit 0384dbaaa4fcb5715738a9254a7c0a4cb62cf458 +Subproject commit fadb2e2778adbf01c80275bfb99e5c14969d964b diff --git a/src/ERC1155A.sol b/src/ERC1155A.sol index a79da88..0f3a9ef 100644 --- a/src/ERC1155A.sol +++ b/src/ERC1155A.sol @@ -1,5 +1,5 @@ /// SPDX-License-Identifier: Apache-2.0 -pragma solidity ^0.8.21; +pragma solidity ^0.8.23; import { IERC1155A } from "./interfaces/IERC1155A.sol"; import { Strings } from "openzeppelin-contracts/contracts/utils/Strings.sol"; @@ -134,7 +134,7 @@ abstract contract ERC1155A is IERC1155A, IERC1155Errors { uint256 id; uint256 amount; - for (uint256 i; i < len;) { + for (uint256 i; i < len; ++i) { id = ids[i]; amount = amounts[i]; @@ -145,12 +145,6 @@ abstract contract ERC1155A is IERC1155A, IERC1155Errors { balanceOf[from][id] -= amount; balanceOf[to][id] += amount; - - // An array can't have a total length - // larger than the max uint256 value. - unchecked { - ++i; - } } emit TransferBatch(msg.sender, from, to, ids, amounts); @@ -172,12 +166,8 @@ abstract contract ERC1155A is IERC1155A, IERC1155Errors { balances = new uint256[](owners.length); - // Unchecked because the only math done is incrementing - // the array index counter which cannot possibly overflow. - unchecked { - for (uint256 i = 0; i < owners.length; ++i) { - balances[i] = balanceOf[owners[i]][ids[i]]; - } + for (uint256 i = 0; i < owners.length; ++i) { + balances[i] = balanceOf[owners[i]][ids[i]]; } } @@ -199,9 +189,7 @@ abstract contract ERC1155A is IERC1155A, IERC1155Errors { /// inheritdoc IERC1155A function increaseAllowance(address spender, uint256 id, uint256 addedValue) public virtual returns (bool) { address owner = msg.sender; - unchecked { - _setApprovalForOne(owner, spender, id, allowance(owner, spender, id) + addedValue); - } + _setApprovalForOne(owner, spender, id, allowance(owner, spender, id) + addedValue); return true; } @@ -219,12 +207,8 @@ abstract contract ERC1155A is IERC1155A, IERC1155Errors { function setApprovalForMany(address spender, uint256[] memory ids, uint256[] memory amounts) public virtual { address owner = msg.sender; - for (uint256 i; i < ids.length;) { + for (uint256 i; i < ids.length; ++i) { _setApprovalForOne(owner, spender, ids[i], amounts[i]); - - unchecked { - ++i; - } } } @@ -240,12 +224,9 @@ abstract contract ERC1155A is IERC1155A, IERC1155Errors { { address owner = msg.sender; uint256 id; - for (uint256 i; i < ids.length;) { + for (uint256 i; i < ids.length; ++i) { id = ids[i]; - unchecked { - _setApprovalForOne(owner, spender, id, allowance(owner, spender, id) + addedValues[i]); - ++i; - } + _setApprovalForOne(owner, spender, id, allowance(owner, spender, id) + addedValues[i]); } return true; @@ -263,12 +244,8 @@ abstract contract ERC1155A is IERC1155A, IERC1155Errors { { address owner = msg.sender; - for (uint256 i; i < ids.length;) { + for (uint256 i; i < ids.length; ++i) { _decreaseAllowance(owner, spender, ids[i], subtractedValues[i]); - - unchecked { - ++i; - } } return true; @@ -294,14 +271,11 @@ abstract contract ERC1155A is IERC1155A, IERC1155Errors { /// @dev an approval is needed to burn _batchBurn(owner, msg.sender, ids, amounts); - for (uint256 i = 0; i < ids.length;) { + for (uint256 i = 0; i < ids.length; ++i) { address sERC20Token = synthethicTokenId[ids[i]]; if (sERC20Token == address(0)) revert SYNTHETIC_ERC20_NOT_REGISTERED(); IsERC20(sERC20Token).mint(owner, amounts[i]); - unchecked { - ++i; - } } emit TransmutedBatchToERC20(owner, ids, amounts); @@ -316,14 +290,11 @@ abstract contract ERC1155A is IERC1155A, IERC1155Errors { external override { - for (uint256 i = 0; i < ids.length;) { + for (uint256 i = 0; i < ids.length; ++i) { address sERC20Token = synthethicTokenId[ids[i]]; if (sERC20Token == address(0)) revert SYNTHETIC_ERC20_NOT_REGISTERED(); /// @dev an approval is needed on each sERC20 to burn IsERC20(sERC20Token).burn(owner, msg.sender, amounts[i]); - unchecked { - ++i; - } } _batchMint(owner, msg.sender, ids, amounts, bytes("")); @@ -442,9 +413,7 @@ abstract contract ERC1155A is IERC1155A, IERC1155Errors { { uint256 currentAllowance = allowance(owner, operator, id); if (currentAllowance < subtractedValue) revert DECREASED_ALLOWANCE_BELOW_ZERO(); - unchecked { - _setApprovalForOne(owner, operator, id, currentAllowance - subtractedValue); - } + _setApprovalForOne(owner, operator, id, currentAllowance - subtractedValue); return true; } @@ -491,15 +460,9 @@ abstract contract ERC1155A is IERC1155A, IERC1155Errors { if (idsLength != amounts.length) revert LENGTH_MISMATCH(); - for (uint256 i = 0; i < idsLength;) { + for (uint256 i = 0; i < idsLength; ++i) { balanceOf[to][ids[i]] += amounts[i]; _totalSupply[ids[i]] += amounts[i]; - - // An array can't have a total length - // larger than the max uint256 value. - unchecked { - ++i; - } } emit TransferBatch(operator, address(0), to, ids, amounts); @@ -530,7 +493,7 @@ abstract contract ERC1155A is IERC1155A, IERC1155Errors { uint256 id; uint256 amount; - for (uint256 i = 0; i < idsLength;) { + for (uint256 i = 0; i < idsLength; ++i) { id = ids[i]; amount = amounts[i]; @@ -541,12 +504,6 @@ abstract contract ERC1155A is IERC1155A, IERC1155Errors { balanceOf[from][id] -= amount; _totalSupply[id] -= amount; - - // An array can't have a total length - // larger than the max uint256 value. - unchecked { - ++i; - } } emit TransferBatch(operator, from, address(0), ids, amounts); diff --git a/src/interfaces/IERC1155A.sol b/src/interfaces/IERC1155A.sol index 47ea8ab..46c6027 100644 --- a/src/interfaces/IERC1155A.sol +++ b/src/interfaces/IERC1155A.sol @@ -1,5 +1,5 @@ /// SPDX-License-Identifier: Apache-2.0 -pragma solidity ^0.8.21; +pragma solidity ^0.8.23; import { IERC1155 } from "openzeppelin-contracts/contracts/token/ERC1155/IERC1155.sol"; diff --git a/src/interfaces/IsERC20.sol b/src/interfaces/IsERC20.sol index 06e1742..083afea 100644 --- a/src/interfaces/IsERC20.sol +++ b/src/interfaces/IsERC20.sol @@ -1,5 +1,5 @@ /// SPDX-License-Identifier: Apache-2.0 -pragma solidity ^0.8.21; +pragma solidity ^0.8.23; import { IERC20 } from "openzeppelin-contracts/contracts/token/ERC20/IERC20.sol"; diff --git a/src/sERC20.sol b/src/sERC20.sol index f034858..baee875 100644 --- a/src/sERC20.sol +++ b/src/sERC20.sol @@ -1,5 +1,5 @@ /// SPDX-License-Identifier: Apache-2.0 -pragma solidity ^0.8.21; +pragma solidity ^0.8.23; import { ERC20 } from "openzeppelin-contracts/contracts/token/ERC20/ERC20.sol"; import { IsERC20 } from "./interfaces/IsERC20.sol"; diff --git a/src/test/ERC1155.t.sol b/src/test/ERC1155.t.sol index 84a3a9b..80bcabb 100644 --- a/src/test/ERC1155.t.sol +++ b/src/test/ERC1155.t.sol @@ -1,5 +1,5 @@ /// SPDX-License-Identifier: Apache-2.0 -pragma solidity ^0.8.21; +pragma solidity ^0.8.23; import { DSTestPlus } from "solmate/test/utils/DSTestPlus.sol"; import { ERC1155TokenReceiver } from "solmate/tokens/ERC1155.sol"; diff --git a/src/test/ERC1155_A.t.sol b/src/test/ERC1155_A.t.sol index 5624107..857a0b0 100644 --- a/src/test/ERC1155_A.t.sol +++ b/src/test/ERC1155_A.t.sol @@ -1,5 +1,5 @@ /// SPDX-License-Identifier: Apache-2.0 -pragma solidity ^0.8.21; +pragma solidity ^0.8.23; import "forge-std/Test.sol"; import { MockERC1155A } from "./mocks/MockERC1155A.sol"; diff --git a/src/test/mocks/MockERC1155A.sol b/src/test/mocks/MockERC1155A.sol index f642375..81585b4 100644 --- a/src/test/mocks/MockERC1155A.sol +++ b/src/test/mocks/MockERC1155A.sol @@ -1,5 +1,5 @@ /// SPDX-License-Identifier: Apache-2.0 -pragma solidity ^0.8.21; +pragma solidity ^0.8.23; import { ERC1155A } from "../../ERC1155A.sol"; import { sERC20 } from "../../sERC20.sol";