diff --git a/.github/workflows/js-checks.yml b/.github/workflows/js-checks.yml index 78d7576..d8591ee 100644 --- a/.github/workflows/js-checks.yml +++ b/.github/workflows/js-checks.yml @@ -8,30 +8,6 @@ concurrency: group: ${{ github.workflow }}-${{ github.ref }}-${{ github.event_name }} cancel-in-progress: true -# The reusable workflow at bloq/actions/.github/workflows/js-checks.yml@v1 -# cannot be used as environment variables must be sent to the test command to -# overwrite the EVM RPC URL of Hemi mainnet. When this is not needed anymore, -# the custom workflow should be replaced by the reusable one. - jobs: js-checks: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - uses: bloq/actions/setup-node-env@v1 - with: - cache: npm - - run: npm run --if-present format:check - - run: npm run --if-present lint - - run: npm run --if-present deps:check - run-tests: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - uses: bloq/actions/setup-node-env@v1 - with: - cache: npm - - run: npm run test - env: - EVM_RPC_URL_43111: ${{ secrets.EVM_RPC_URL_43111 }} - EVM_RPC_URL_743111: ${{ secrets.WEB3_RPC_743111 }} + uses: hemilabs/actions/.github/workflows/js-checks.yml@01a748b9e1b966ae64d2a7b146ff7e4700dc1da5 diff --git a/package-lock.json b/package-lock.json index f4ac6f9..207d54d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10,6 +10,8 @@ "license": "MIT", "devDependencies": { "@commitlint/cli": "19.5.0", + "ajv": "8.17.1", + "ajv-formats": "3.0.1", "better-sort-package-json": "1.1.0", "commitlint-config-bloq": "1.1.0", "eslint": "8.57.1", @@ -895,6 +897,7 @@ "resolved": "https://registry.npmjs.org/ajv/-/ajv-8.17.1.tgz", "integrity": "sha512-B/gBuNg5SiMTrPkC+A2+cW0RszwxYmn6VYxB/inlBStS5nx6xHIt/ehKRhIMhqusl7a8LjQoZnjCs5vhwxOQ1g==", "dev": true, + "license": "MIT", "dependencies": { "fast-deep-equal": "^3.1.3", "fast-uri": "^3.0.1", @@ -906,6 +909,24 @@ "url": "https://github.com/sponsors/epoberezkin" } }, + "node_modules/ajv-formats": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/ajv-formats/-/ajv-formats-3.0.1.tgz", + "integrity": "sha512-8iUql50EUR+uUcdRQ3HDqa6EVyo3docL8g5WJ3FNcWmu62IbkGUue/pEyLBW8VGKKucTPgqeks4fIU1DA4yowQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "ajv": "^8.0.0" + }, + "peerDependencies": { + "ajv": "^8.0.0" + }, + "peerDependenciesMeta": { + "ajv": { + "optional": true + } + } + }, "node_modules/ansi-escapes": { "version": "7.0.0", "resolved": "https://registry.npmjs.org/ansi-escapes/-/ansi-escapes-7.0.0.tgz", diff --git a/package.json b/package.json index b77f69c..c5f9564 100644 --- a/package.json +++ b/package.json @@ -22,11 +22,15 @@ "format:check": "prettier --check .", "lint": "eslint --cache .", "prepare": "husky", + "schema:validate": "node scripts/validate-list.js", + "pretest": "npm run schema:validate", "test": "node --test", "version": "node scripts/sync-version.js && git add ." }, "devDependencies": { "@commitlint/cli": "19.5.0", + "ajv": "8.17.1", + "ajv-formats": "3.0.1", "better-sort-package-json": "1.1.0", "commitlint-config-bloq": "1.1.0", "eslint": "8.57.1", diff --git a/scripts/validate-list.js b/scripts/validate-list.js new file mode 100644 index 0000000..4cf8be9 --- /dev/null +++ b/scripts/validate-list.js @@ -0,0 +1,33 @@ +import Ajv from "ajv"; +import addFormats from "ajv-formats"; +import fs from "node:fs"; +import { exit } from "node:process"; + +// eslint fails to parse "with { type: "json" }" +// See https://github.com/eslint/eslint/discussions/15305 +const tokenList = JSON.parse(fs.readFileSync("./src/hemi.tokenlist.json")); + +const schemaUrl = + "https://raw.githubusercontent.com/Uniswap/token-lists/main/src/tokenlist.schema.json"; + +// See https://github.com/uniswap/token-lists?tab=readme-ov-file#validating-token-lists +async function validate() { + const ajv = new Ajv({ allErrors: true, verbose: true }); + addFormats(ajv); + const schema = await fetch(schemaUrl).then((r) => r.json()); + const validator = ajv.compile(schema); + const valid = validator(tokenList); + if (valid) { + return; + } + if (validator.errors) { + throw validator.errors; + } +} + +validate() + .then(() => console.info("Schema is valid")) + .catch(function (err) { + console.error(err); + exit(1); + }); diff --git a/src/hemi.tokenlist.json b/src/hemi.tokenlist.json index 065d31d..5cc3044 100644 --- a/src/hemi.tokenlist.json +++ b/src/hemi.tokenlist.json @@ -1,6 +1,6 @@ { "name": "Hemi Token List", - "timestamp": "2025-01-16T15:25:35.973Z", + "timestamp": "2025-01-22T20:42:04.584Z", "version": { "major": 1, "minor": 5,