Skip to content

Commit

Permalink
loosen symbol restriction
Browse files Browse the repository at this point in the history
  • Loading branch information
moodysalem committed Aug 25, 2020
1 parent 58900b9 commit 26d991d
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 4 deletions.
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"build": "tsdx build",
"test": "tsdx test",
"lint": "tsdx lint",
"prepare": "tsdx test && tsdx build"
"prepublishOnly": "tsdx test && tsdx build"
},
"peerDependencies": {},
"husky": {
Expand Down
4 changes: 2 additions & 2 deletions src/tokenlist.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -128,15 +128,15 @@
"description": "The name of the token",
"minLength": 1,
"maxLength": 40,
"pattern": "^[ \\w+.'-]+$",
"pattern": "^[ \\w.'+\\-%/]+$",
"examples": [
"USD Coin"
]
},
"symbol": {
"type": "string",
"description": "The symbol for the token; must be alphanumeric",
"pattern": "^[a-zA-Z0-9+]+$",
"pattern": "^[a-zA-Z0-9+\\-%/]+$",
"minLength": 1,
"maxLength": 20,
"examples": [
Expand Down
2 changes: 2 additions & 0 deletions test/__snapshots__/tokenlist.schema.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -210,3 +210,5 @@ Array [
exports[`schema works for big example schema 1`] = `null`;

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

exports[`schema works for special characters schema 1`] = `null`;
25 changes: 25 additions & 0 deletions test/schema/example-name-symbol-special-characters.tokenlist.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"name": "My Token List",
"timestamp": "2020-06-12T00:00:00+00:00",
"tokens": [
{
"chainId": 1,
"address": "0x9A48BD0EC040ea4f1D3147C025cd4076A2e71e3e",
"symbol": "USD++",
"name": "PieDAO USD++ Pool",
"decimals": 18
},
{
"chainId": 1,
"address": "0xB4e16d0168e52d35CaCD2c6185b44281Ec28C9Dc",
"symbol": "USDC/ETH+50/50%",
"name": "Uniswap V2 USDC/ETH+50/50%",
"decimals": 18
}
],
"version": {
"major": 1,
"minor": 0,
"patch": 0
}
}
5 changes: 5 additions & 0 deletions test/tokenlist.schema.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import Ajv from 'ajv';
import { schema } from '../src';
import exampleList from './schema/example.tokenlist.json';
import exampleNameSymbolSpecialCharacters from './schema/example-name-symbol-special-characters.tokenlist.json';
import bigExampleList from './schema/bigexample.tokenlist.json';
import exampleListMinimum from './schema/exampleminimum.tokenlist.json';
import emptyList from './schema/empty.tokenlist.json';
Expand Down Expand Up @@ -32,6 +33,10 @@ describe('schema', () => {
checkSchema(exampleList, true);
});

it('works for special characters schema', () => {
checkSchema(exampleNameSymbolSpecialCharacters, true);
});

it('works for big example schema', () => {
checkSchema(bigExampleList, true);
});
Expand Down

0 comments on commit 26d991d

Please sign in to comment.