-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[CodeArena] - [G-06/N-12] : Require messages shorten to fit in 32 bytes #48
Conversation
43bef9a
to
d3c1459
Compare
contracts/MixinOperatorResolver.sol
Outdated
@@ -60,7 +60,7 @@ abstract contract MixinOperatorResolver { | |||
/// @return The operator address | |||
function requireAndGetAddress(bytes32 name) internal view returns (address) { | |||
address _foundAddress = addressCache[name]; | |||
require(_foundAddress != address(0), string(abi.encodePacked("Missing operator : ", name))); | |||
require(_foundAddress != address(0), string(abi.encodePacked("MOR: Missing operator : ", name))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe MOR: MISSING_OPERATOR
?
contracts/NestedFactory.sol
Outdated
@@ -50,15 +50,15 @@ contract NestedFactory is INestedFactory, ReentrancyGuard, Ownable, MixinOperato | |||
/// @dev Reverts the transaction if the caller is not the token owner | |||
/// @param _nftId The NFT Id | |||
modifier onlyTokenOwner(uint256 _nftId) { | |||
require(nestedAsset.ownerOf(_nftId) == _msgSender(), "NestedFactory: Not the token owner"); | |||
require(nestedAsset.ownerOf(_nftId) == _msgSender(), "NF: CALLER_IS_NOT_THE_OWNER"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove the _IS_
and _THE_
=> NF: CALLER_NOT_OWNER
contracts/NestedFactory.sol
Outdated
_; | ||
} | ||
|
||
/// @dev Reverts the transaction if the nft is locked (hold by design). | ||
/// The block.timestamp must be greater than NFT record lock timestamp | ||
/// @param _nftId The NFT Id | ||
modifier isUnlocked(uint256 _nftId) { | ||
require(block.timestamp > nestedRecords.getLockTimestamp(_nftId), "NestedFactory: The NFT is currently locked"); | ||
require(block.timestamp > nestedRecords.getLockTimestamp(_nftId), "NF: NFT_IS_LOCKED"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove _IS_
=> NF: LOCKED_NFT
d3c1459
to
1691fa7
Compare
1691fa7
to
71bc16e
Compare
I found that there is no advantage to using less than 32 bytes for a require reason, but using more will cost an extra 32 at once.
I've looked at 3 options:
CustomError
-> I've chosen option 1. By using initials instead of contract names, and rewriting some messages, the data now fit in 32 bytes.
Issues =>