Skip to content

Commit

Permalink
feat: validation script to run when new tokens are pushed
Browse files Browse the repository at this point in the history
  • Loading branch information
SGiaccobasso committed Sep 18, 2024
1 parent 6f92255 commit 08ff230
Show file tree
Hide file tree
Showing 2 changed files with 406 additions and 0 deletions.
46 changes: 46 additions & 0 deletions .github/workflows/validate-tokens.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Validate New Token Configurations

on:
pull_request:
paths:
- 'registry/mainnet/interchain/squid.tokenlist.json'

jobs:
validate-tokens:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- name: Use Node.js
uses: actions/setup-node@v2
with:
node-version: '16'

- name: Install dependencies
run: |
npm install -g typescript
npm install ethers@5.7.2
npm install viem
npm install axios
npm install fs
npm install @types/node
- name: Compile TypeScript
run: tsc validate-token-configs.ts

- name: Extract and validate new tokens
run: |
DIFF=$(git diff origin/${{ github.base_ref }} -- registry/mainnet/interchain/squid.tokenlist.json | grep '^+' | grep -v '+++')
NEW_TOKENS=$(echo "$DIFF" | sed -n '/"0x/,/]/{/]/q;p}' | jq -s 'reduce .[] as $item ({}; . + ($item | fromjson))')
echo "$NEW_TOKENS" > new_tokens.json
node validate-token-configs.ts
- name: Check validation results
run: |
if [ -f validation_errors.txt ]; then
echo "Validation errors found:"
cat validation_errors.txt
exit 1
else
echo "All new token configurations are valid."
fi
Loading

0 comments on commit 08ff230

Please sign in to comment.