Skip to content

Commit

Permalink
(nameRegistry): check short name is not zero
Browse files Browse the repository at this point in the history
  • Loading branch information
benjaminbollen committed Oct 1, 2024
1 parent 74a6435 commit 3954035
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/errors/Errors.sol
Original file line number Diff line number Diff line change
Expand Up @@ -95,4 +95,6 @@ interface INameRegistryErrors {
error CirclesNamesAvatarAlreadyHasCustomNameOrSymbol(address avatar, string nameOrSymbol, uint8 code);

error CirclesNamesOrganizationHasNoSymbol(address organization, uint8 code);

error CirclesNamesShortNameZero(address avatar, uint256 nonce);
}
5 changes: 5 additions & 0 deletions src/names/NameRegistry.sol
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,11 @@ contract NameRegistry is Base58Converter, INameRegistry, INameRegistryErrors, IC
}

function _storeShortName(address _avatar, uint72 _shortName, uint256 _nonce) internal {
if (_shortName == uint72(0)) {
// short name cannot be zero (but congrats if you got it!)
// this would break the reverse lookup
revert CirclesNamesShortNameZero(_avatar, _nonce);
}
// assign the name to the address
shortNames[_avatar] = _shortName;
// assign the address to the name
Expand Down

0 comments on commit 3954035

Please sign in to comment.