Comment on page
IdeaTokenNameVerifier
Each market has its own
IdeaTokenNameVerifier
which is a small contract performing basic checks on a token name. These name verifiers are used by the IdeaTokenFactory
when a new token is listed. For example on the Twitter
market the TwitterHandleNameVerifier
is used to verify the token name is a valid Twitter handle (@ followed by 1-15 letters or numbers including "_". All lower-case) :contract TwitterHandleNameVerifier is IIdeaTokenNameVerifier {
/**
* Verifies whether a string matches the required format
*
* @param name The input string (Twitter handle)
*
* @return Bool; True=matches, False=does not match
*/
function verifyTokenName(string calldata name) external pure override returns (bool) {
bytes memory b = bytes(name);
if(b.length < 2 || b.length > 16) {
return false;
}
if(b[0] != 0x40) { // @
return false;
}
for(uint i = 1; i < b.length; i++) {
bytes1 char = b[i];
if (!(char >= 0x30 && char <= 0x39) && //9-0
!(char >= 0x61 && char <= 0x7A) && //a-z
!(char == 0x5F)) { //_
return false;
}
}
return true;
}
}
If the token name verification is unsuccessful the
IdeaTokenFactory
will revert on addToken
.Last modified 2yr ago