Skip to content

Commit 12d4cb2

Browse files
authored
accept sol addresses (#993)
1 parent f57d6be commit 12d4cb2

File tree

5 files changed

+62
-91
lines changed

5 files changed

+62
-91
lines changed

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"url": "https://uniswap.org"
77
},
88
"description": "📚 The Token Lists specification",
9-
"version": "1.0.0-beta.34",
9+
"version": "1.0.0-beta.35",
1010
"license": "MIT",
1111
"main": "dist/index.js",
1212
"typings": "dist/index.d.ts",
@@ -29,7 +29,7 @@
2929
"lint": "tsdx lint src test",
3030
"prepublishOnly": "yarn test && yarn build"
3131
},
32-
"publishConfig" : {
32+
"publishConfig": {
3333
"access": "public",
3434
"provenance": true
3535
},

src/tokenlist.schema.json

Lines changed: 26 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -20,58 +20,38 @@
2020
"type": "integer",
2121
"description": "The major version of the list. Must be incremented when tokens are removed from the list or token addresses are changed.",
2222
"minimum": 0,
23-
"examples": [
24-
1,
25-
2
26-
]
23+
"examples": [1, 2]
2724
},
2825
"minor": {
2926
"type": "integer",
3027
"description": "The minor version of the list. Must be incremented when tokens are added to the list.",
3128
"minimum": 0,
32-
"examples": [
33-
0,
34-
1
35-
]
29+
"examples": [0, 1]
3630
},
3731
"patch": {
3832
"type": "integer",
3933
"description": "The patch version of the list. Must be incremented for any changes to the list.",
4034
"minimum": 0,
41-
"examples": [
42-
0,
43-
1
44-
]
35+
"examples": [0, 1]
4536
}
4637
},
47-
"required": [
48-
"major",
49-
"minor",
50-
"patch"
51-
]
38+
"required": ["major", "minor", "patch"]
5239
},
5340
"TagIdentifier": {
5441
"type": "string",
5542
"description": "The unique identifier of a tag",
5643
"minLength": 1,
5744
"maxLength": 10,
5845
"pattern": "^[\\w]+$",
59-
"examples": [
60-
"compound",
61-
"stablecoin"
62-
]
46+
"examples": ["compound", "stablecoin"]
6347
},
6448
"ExtensionIdentifier": {
6549
"type": "string",
6650
"description": "The name of a token extension property",
6751
"minLength": 1,
6852
"maxLength": 40,
6953
"pattern": "^[\\w]+$",
70-
"examples": [
71-
"color",
72-
"is_fee_on_transfer",
73-
"aliases"
74-
]
54+
"examples": ["color", "is_fee_on_transfer", "aliases"]
7555
},
7656
"ExtensionMap": {
7757
"type": "object",
@@ -104,21 +84,15 @@
10484
"type": "string",
10585
"minLength": 1,
10686
"maxLength": 42,
107-
"examples": [
108-
"#00000"
109-
]
87+
"examples": ["#00000"]
11088
},
11189
{
11290
"type": "boolean",
113-
"examples": [
114-
true
115-
]
91+
"examples": [true]
11692
},
11793
{
11894
"type": "number",
119-
"examples": [
120-
15
121-
]
95+
"examples": [15]
12296
},
12397
{
12498
"type": "null"
@@ -186,10 +160,7 @@
186160
"maxLength": 200
187161
}
188162
},
189-
"required": [
190-
"name",
191-
"description"
192-
],
163+
"required": ["name", "description"],
193164
"examples": [
194165
{
195166
"name": "Stablecoin",
@@ -206,27 +177,23 @@
206177
"type": "integer",
207178
"description": "The chain ID of the Ethereum network where this token is deployed",
208179
"minimum": 1,
209-
"examples": [
210-
1,
211-
42
212-
]
180+
"examples": [1, 42]
213181
},
214182
"address": {
215183
"type": "string",
216184
"description": "The checksummed address of the token on the specified chain ID",
217-
"pattern": "^0x[a-fA-F0-9]{40}$",
185+
"pattern": "^(0x[a-fA-F0-9]{40}|[1-9A-HJ-NP-Za-km-z]{32,44})$",
218186
"examples": [
219-
"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"
187+
"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
188+
"So11111111111111111111111111111111111111112"
220189
]
221190
},
222191
"decimals": {
223192
"type": "integer",
224193
"description": "The number of decimals for the token balance",
225194
"minimum": 0,
226195
"maximum": 255,
227-
"examples": [
228-
18
229-
]
196+
"examples": [18]
230197
},
231198
"name": {
232199
"type": "string",
@@ -241,9 +208,7 @@
241208
"pattern": "^[ \\S+]+$"
242209
}
243210
],
244-
"examples": [
245-
"USD Coin"
246-
]
211+
"examples": ["USD Coin"]
247212
},
248213
"symbol": {
249214
"type": "string",
@@ -258,17 +223,13 @@
258223
"pattern": "^\\S+$"
259224
}
260225
],
261-
"examples": [
262-
"USDC"
263-
]
226+
"examples": ["USDC"]
264227
},
265228
"logoURI": {
266229
"type": "string",
267230
"description": "A URI to the token logo asset; if not set, interface will attempt to find a logo based on the token address; suggest SVG or PNG of size 64x64",
268231
"format": "uri",
269-
"examples": [
270-
"ipfs://QmXfzKRvjZz3u5JRgC4v5mGVbm9ahrUiB4DgzHBsnWbTMM"
271-
]
232+
"examples": ["ipfs://QmXfzKRvjZz3u5JRgC4v5mGVbm9ahrUiB4DgzHBsnWbTMM"]
272233
},
273234
"tags": {
274235
"type": "array",
@@ -277,22 +238,13 @@
277238
"$ref": "#/definitions/TagIdentifier"
278239
},
279240
"maxItems": 10,
280-
"examples": [
281-
"stablecoin",
282-
"compound"
283-
]
241+
"examples": ["stablecoin", "compound"]
284242
},
285243
"extensions": {
286244
"$ref": "#/definitions/ExtensionMap"
287245
}
288246
},
289-
"required": [
290-
"chainId",
291-
"address",
292-
"decimals",
293-
"name",
294-
"symbol"
295-
]
247+
"required": ["chainId", "address", "decimals", "name", "symbol"]
296248
}
297249
},
298250
"type": "object",
@@ -303,9 +255,7 @@
303255
"minLength": 1,
304256
"maxLength": 30,
305257
"pattern": "^[\\w ]+$",
306-
"examples": [
307-
"My Token List"
308-
]
258+
"examples": ["My Token List"]
309259
},
310260
"timestamp": {
311261
"type": "string",
@@ -337,7 +287,7 @@
337287
},
338288
"examples": [
339289
{
340-
"4_0x1f9840a85d5aF5bf1D1762F925BDADdC4201F984": {
290+
"4_0x1f9840a85d5aF5bf1D1762F925BDADdC4201F984": {
341291
"name": "Uniswap",
342292
"address": "0x1f9840a85d5aF5bf1D1762F925BDADdC4201F984",
343293
"symbol": "UNI",
@@ -357,11 +307,7 @@
357307
"minLength": 1,
358308
"maxLength": 20,
359309
"pattern": "^[\\w ]+$",
360-
"examples": [
361-
"compound",
362-
"lending",
363-
"personal tokens"
364-
]
310+
"examples": ["compound", "lending", "personal tokens"]
365311
},
366312
"maxItems": 20,
367313
"uniqueItems": true
@@ -389,15 +335,8 @@
389335
"type": "string",
390336
"description": "A URI for the logo of the token list; prefer SVG or PNG of size 256x256",
391337
"format": "uri",
392-
"examples": [
393-
"ipfs://QmXfzKRvjZz3u5JRgC4v5mGVbm9ahrUiB4DgzHBsnWbTMM"
394-
]
338+
"examples": ["ipfs://QmXfzKRvjZz3u5JRgC4v5mGVbm9ahrUiB4DgzHBsnWbTMM"]
395339
}
396340
},
397-
"required": [
398-
"name",
399-
"timestamp",
400-
"version",
401-
"tokens"
402-
]
403-
}
341+
"required": ["name", "timestamp", "version", "tokens"]
342+
}

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
// Jest Snapshot v1, https://goo.gl/fbAQLP
22

3+
exports[`schema accepts Solana addresses 1`] = `null`;
4+
35
exports[`schema allows additional top-level fields 1`] = `null`;
46

57
exports[`schema allows up to 10k tokens 1`] = `null`;
@@ -350,9 +352,9 @@ Array [
350352
Object {
351353
"instancePath": "/tokens/0/address",
352354
"keyword": "pattern",
353-
"message": "must match pattern \\"^0x[a-fA-F0-9]{40}$\\"",
355+
"message": "must match pattern \\"^(0x[a-fA-F0-9]{40}|[1-9A-HJ-NP-Za-km-z]{32,44})$\\"",
354356
"params": Object {
355-
"pattern": "^0x[a-fA-F0-9]{40}$",
357+
"pattern": "^(0x[a-fA-F0-9]{40}|[1-9A-HJ-NP-Za-km-z]{32,44})$",
356358
},
357359
"schemaPath": "#/properties/address/pattern",
358360
},
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"name": "Solana Token List",
3+
"timestamp": "2023-10-14T00:00:00+00:00",
4+
"version": {
5+
"major": 1,
6+
"minor": 0,
7+
"patch": 0
8+
},
9+
"tokens": [
10+
{
11+
"chainId": 101,
12+
"address": "So11111111111111111111111111111111111111112",
13+
"symbol": "SOL",
14+
"name": "Wrapped SOL",
15+
"decimals": 9
16+
},
17+
{
18+
"chainId": 101,
19+
"address": "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
20+
"symbol": "USDC",
21+
"name": "USD Coin",
22+
"decimals": 6
23+
}
24+
]
25+
}

test/tokenlist.schema.test.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import extensionsValidObject from './schema/extensions-valid-object.tokenlist.js
2323
import extensionsInvalidObjectTooDeep from './schema/extensions-invalid-object-too-deep.tokenlist.json';
2424
import tokenSymbolWithPeriod from './schema/tokenwithperiodsymbol.tokenlist.json';
2525
import crossChainExtensions from './schema/example-crosschain.tokenlist.json';
26+
import solanaAddresses from './schema/solana-addresses.tokenlist.json';
2627
import addFormats from 'ajv-formats';
2728

2829
const ajv = new Ajv({ allErrors: true });
@@ -121,6 +122,10 @@ describe('schema', () => {
121122
checkSchema(crossChainExtensions, true);
122123
});
123124

125+
it('accepts Solana addresses', () => {
126+
checkSchema(solanaAddresses, true);
127+
});
128+
124129
it('allows up to 10k tokens', () => {
125130
const exampleListWith10kTokens = {
126131
...exampleList,

0 commit comments

Comments
 (0)