From 3bdb6d4b28923788c34e17ef713a34b38027dcf6 Mon Sep 17 00:00:00 2001 From: Liron Achdut Date: Sun, 13 Oct 2024 19:52:29 +0700 Subject: [PATCH 1/3] redundant check (both checks check that lower bits are 0) --- contracts/src/protocol/SemiFungible1155.sol | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contracts/src/protocol/SemiFungible1155.sol b/contracts/src/protocol/SemiFungible1155.sol index 4245bf86..974d9c3e 100644 --- a/contracts/src/protocol/SemiFungible1155.sol +++ b/contracts/src/protocol/SemiFungible1155.sol @@ -88,7 +88,7 @@ contract SemiFungible1155 is * @dev Upper 128 bits identify base type ID, lower bits should be 0. */ function isBaseType(uint256 tokenID) internal pure returns (bool) { - return (tokenID & TYPE_MASK == tokenID) && (tokenID & NF_INDEX_MASK == 0); + return (tokenID & NF_INDEX_MASK == 0); } /** From 7cb76ef22478d1b05e46609caa062ac01160a988 Mon Sep 17 00:00:00 2001 From: Liron Achdut Date: Sun, 13 Oct 2024 20:58:15 +0700 Subject: [PATCH 2/3] documentation fixes --- contracts/src/protocol/SemiFungible1155.sol | 1 - 1 file changed, 1 deletion(-) diff --git a/contracts/src/protocol/SemiFungible1155.sol b/contracts/src/protocol/SemiFungible1155.sol index 974d9c3e..7a006dd8 100644 --- a/contracts/src/protocol/SemiFungible1155.sol +++ b/contracts/src/protocol/SemiFungible1155.sol @@ -288,7 +288,6 @@ contract SemiFungible1155 is * @param _account The address of the account that will receive the new tokens. * @param _tokenID The ID of the token to split. * @param _values An array of numbers of units associated with the new tokens. - * @dev This function splits a token into multiple tokens with different unit values. * @dev The `_values` array specifies the number of units associated with each new token. * @dev The function checks that the length of the `_values` array is between 2 and `FRACTION_LIMIT`, and that the * sum of the values in the `_values` array is equal to the number of units associated with the original token. From af392e5e3c41c9a593c5aea5ab01b88e892a21a7 Mon Sep 17 00:00:00 2001 From: Liron Achdut Date: Mon, 14 Oct 2024 14:27:26 +0700 Subject: [PATCH 3/3] check that also the tokenID is not a base type --- contracts/src/protocol/SemiFungible1155.sol | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contracts/src/protocol/SemiFungible1155.sol b/contracts/src/protocol/SemiFungible1155.sol index 7a006dd8..3bac5f9d 100644 --- a/contracts/src/protocol/SemiFungible1155.sol +++ b/contracts/src/protocol/SemiFungible1155.sol @@ -536,7 +536,7 @@ contract SemiFungible1155 is uint256 _from = fromIDs[i]; uint256 _to = toIDs[i]; - if (isBaseType(_from)) revert Errors.NotAllowed(); + if (isBaseType(_from) || isBaseType(_to)) revert Errors.NotAllowed(); if (getBaseType(_from) != getBaseType(_to)) revert Errors.TypeMismatch(); unchecked { ++i;