From 0f9c41e35055cca12b7a5c0ec3f5975a08fd264f Mon Sep 17 00:00:00 2001 From: Jordan Frankfurt Date: Thu, 28 Oct 2021 16:43:12 -0500 Subject: [PATCH] update readme --- README.md | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/README.md b/README.md index 85ad45d5..9698fee8 100644 --- a/README.md +++ b/README.md @@ -28,6 +28,22 @@ This package does not include code for token list validation. You can easily do [ajv](https://ajv.js.org/) to perform the validation against the JSON schema. The schema is exported from the package 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); + +const response = await fetch('https://bridge.arbitrum.io/token-list-42161.json') +const listData = await response.json() + +const valid = validate(listData) +if (!valid) { + // oh no! +} +``` + ## Authoring token lists ### Manual