Skip to content

Commit 61c4411

Browse files
Add support for symbols containing unicode chars (#176)
* [#175] Add support for symbols containing unicode chars * [#175] Adding support for empty symbols and names * [#175] Add support for names containing unicode chars
1 parent 245d0ab commit 61c4411

File tree

5 files changed

+65
-5
lines changed

5 files changed

+65
-5
lines changed

src/tokenlist.schema.json

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -231,19 +231,33 @@
231231
"name": {
232232
"type": "string",
233233
"description": "The name of the token",
234-
"minLength": 1,
234+
"minLength": 0,
235235
"maxLength": 40,
236-
"pattern": "^[ \\w.'+\\-%/À-ÖØ-öø-ÿ:&\\[\\]\\(\\)]+$",
236+
"anyOf": [
237+
{
238+
"const": ""
239+
},
240+
{
241+
"pattern": "^[ \\S+]+$"
242+
}
243+
],
237244
"examples": [
238245
"USD Coin"
239246
]
240247
},
241248
"symbol": {
242249
"type": "string",
243-
"description": "The symbol for the token; must be alphanumeric",
244-
"pattern": "^[a-zA-Z0-9+\\-%/$.]+$",
245-
"minLength": 1,
250+
"description": "The symbol for the token",
251+
"minLength": 0,
246252
"maxLength": 20,
253+
"anyOf": [
254+
{
255+
"const": ""
256+
},
257+
{
258+
"pattern": "^\\S+$"
259+
}
260+
],
247261
"examples": [
248262
"USDC"
249263
]

test/__snapshots__/tokenlist.schema.test.ts.snap

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -579,6 +579,8 @@ exports[`schema token symbols may contain periods 1`] = `null`;
579579

580580
exports[`schema works for big example schema 1`] = `null`;
581581

582+
exports[`schema works for empty names and symbols 1`] = `null`;
583+
582584
exports[`schema works for example schema 1`] = `null`;
583585

584586
exports[`schema works for special characters schema 1`] = `null`;
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"name": "My Token List",
3+
"timestamp": "2020-06-12T00:00:00+00:00",
4+
"tokens": [
5+
{
6+
"chainId": 137,
7+
"address": "0xc31C535F4d9A789df0c16D461B4F811543b72FEb",
8+
"decimals": 0,
9+
"name": "",
10+
"symbol": ""
11+
},
12+
{
13+
"chainId": 137,
14+
"address": "0xF336f5624D34c3Be82eF3EFc4978bd2397B1524A",
15+
"decimals": 0,
16+
"name": "",
17+
"symbol": ""
18+
}
19+
],
20+
"version": {
21+
"major": 1,
22+
"minor": 0,
23+
"patch": 0
24+
}
25+
}

test/schema/example-name-symbol-special-characters.tokenlist.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,20 @@
4343
"decimals": 18,
4444
"name": "[brackets]&(parenthesis)",
4545
"symbol": "symbol"
46+
},
47+
{
48+
"chainId": 1,
49+
"address": "0x76ee13b775331eeae2bc5e3b67f4a44101b27a94",
50+
"decimals": 18,
51+
"name": "Amatsukami",
52+
"symbol": "天津神"
53+
},
54+
{
55+
"chainId": 137,
56+
"address": "0x841120E51aD43EfE489244728532854A352073aD",
57+
"decimals": 6,
58+
"name": "Timeless ERC4626-Wrapped",
59+
"symbol": "∞-waUSDC-xPYT"
4660
}
4761
],
4862
"version": {

test/tokenlist.schema.test.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import exampleNameSymbolSpecialCharacters from './schema/example-name-symbol-spe
55
import bigExampleList from './schema/bigexample.tokenlist.json';
66
import exampleListMinimum from './schema/exampleminimum.tokenlist.json';
77
import emptyList from './schema/empty.tokenlist.json';
8+
import emptyNameSymbol from './schema/empty-name-symbol.tokenlist.json';
89
import bigWords from './schema/bigwords.tokenlist.json';
910
import invalidTokenAddress from './schema/invalidtokenaddress.tokenlist.json';
1011
import invalidTimestamp from './schema/invalidtimestamp.tokenlist.json';
@@ -63,6 +64,10 @@ describe('schema', () => {
6364
checkSchema(emptyList, false);
6465
});
6566

67+
it('works for empty names and symbols', () => {
68+
checkSchema(emptyNameSymbol, true);
69+
});
70+
6671
it('fails with big names', () => {
6772
checkSchema(bigWords, false);
6873
});

0 commit comments

Comments
 (0)