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) :
1
contract TwitterHandleNameVerifier is IIdeaTokenNameVerifier {
2
/**
3
* Verifies whether a string matches the required format
4
*
5
* @param name The input string (Twitter handle)
6
*
7
* @return Bool; True=matches, False=does not match
8
*/
9
function verifyTokenName(string calldata name) external pure override returns (bool) {
10
bytes memory b = bytes(name);
11
if(b.length < 2 || b.length > 16) {
12
return false;
13
}
14
​
15
if(b[0] != 0x40) { // @
16
return false;
17
}
18
​
19
for(uint i = 1; i < b.length; i++) {
20
bytes1 char = b[i];
21
if (!(char >= 0x30 && char <= 0x39) && //9-0
22
!(char >= 0x61 && char <= 0x7A) && //a-z
23
!(char == 0x5F)) { //_
24
25
return false;
26
}
27
}
28
​
29
return true;
30
}
31
}
Copied!
If the token name verification is unsuccessful the IdeaTokenFactory will revert on addToken.
Last modified 11mo ago
Copy link