Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Raindrops1-Playground #735

Open
wants to merge 24 commits into
base: add-array-extension-support
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
3af2199
allow object extensions (#81)
JFrankfurt Dec 27, 2021
077b1ce
update readme with info on accessing validation errors and extending …
JFrankfurt Mar 1, 2022
2d8584d
1.0.0-beta.28
moodysalem Mar 23, 2022
38d30e3
Update README.md
akarys92 May 31, 2022
d052483
Update README.md
akarys92 May 31, 2022
039768a
Increase length limit for token list name (#136)
matteenm Jun 7, 2022
9fd77cf
1.0.0-beta.29
matteenm Jun 7, 2022
1023c40
update TokenInfo extensions type to support objects nested 2 levels d…
matteenm Jun 16, 2022
245d0ab
1.0.0-beta.30
matteenm Jun 16, 2022
61c4411
Add support for symbols containing unicode chars (#176)
alexandrebini Dec 12, 2022
abe195a
v1.0.0-beta.31
matteenm Dec 12, 2022
395b5d6
feat: add tokenMap to schema (#420)
lynnshaoyu Jul 5, 2023
a273873
prettier (#421)
lynnshaoyu Jul 5, 2023
8e9f553
fix: allow additional top level fields (#460)
just-toby Aug 2, 2023
7f82d08
chore: add semgrep (#599)
mr-uniswap Jan 10, 2024
7f2eccf
Chore/fix semgrep path (#605)
mr-uniswap Jan 19, 2024
423b5a8
increase char limit on token name (#639)
DefiPanda Mar 26, 2024
9332f91
chore(infra): add an automated release (#682)
mr-uniswap Jul 3, 2024
65bce6f
chore: setup token lists deploy (#683)
mr-uniswap Jul 4, 2024
ea7b2a2
chore: add provenance (#698)
mr-uniswap Aug 1, 2024
786a165
fix/publishconfig (#699)
mr-uniswap Aug 1, 2024
f57d6be
chore(infra): enable write permissions (#703)
mr-uniswap Aug 7, 2024
da618ff
Merge pull request #1 from Uniswap/main
GloWE3 Sep 30, 2024
68c7a9a
Create SECURITY.md
GloWE3 Oct 15, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 27 additions & 10 deletions README.md
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

gh pr checkout 735

Original file line number Diff line number Diff line change
Expand Up @@ -29,19 +29,36 @@ This package does not include code for token list validation. You can easily do
for ease of use.

```typescript
import Ajv from 'ajv';
import { schema } from '@uniswap/token-lists'

const ajv = new Ajv({ allErrors: true });
const validate = ajv.compile(schema);
import { schema } from '@uniswap/token-lists'
import Ajv from 'ajv'
import addFormats from 'ajv-formats'
import fetch from 'node-fetch'

const ARBITRUM_LIST = 'https://bridge.arbitrum.io/token-list-42161.json'

async function validate() {
const ajv = new Ajv({ allErrors: true, verbose: true })
addFormats(ajv)
const validator = ajv.compile(schema);
const response = await fetch(ARBITRUM_LIST)
const data = await response.json()
const valid = validator(data)
if (valid) {
return valid
}
if (validator.errors) {
throw validator.errors.map(error => {
delete error.data
return error
})
}
}

const response = await fetch('https://bridge.arbitrum.io/token-list-42161.json')
const listData = await response.json()
validate()
.then(console.log("Valid List."))
.catch(console.error)

const valid = validate(listData)
if (!valid) {
// oh no!
}
```

## Authoring token lists
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"url": "https://uniswap.org"
},
"description": "📚 The Token Lists specification",
"version": "1.0.0-beta.27",
"version": "1.0.0-beta.28",
"license": "MIT",
"main": "dist/index.js",
"typings": "dist/index.d.ts",
Expand Down
4 changes: 3 additions & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
type ExtensionValue = string | number | boolean | null;

export interface TokenInfo {
readonly chainId: number;
readonly address: string;
Expand All @@ -7,7 +9,7 @@ export interface TokenInfo {
readonly logoURI?: string;
readonly tags?: string[];
readonly extensions?: {
readonly [key: string]: string | number | boolean | null;
readonly [key: string]: { [key: string]: ExtensionValue } | ExtensionValue;
};
}

Expand Down