Skip to content

Commit

Permalink
chore: create new token (#129)
Browse files Browse the repository at this point in the history
  • Loading branch information
SGiaccobasso authored Sep 24, 2024
1 parent c595dc9 commit 336100f
Show file tree
Hide file tree
Showing 6 changed files with 2,527 additions and 356 deletions.
42 changes: 22 additions & 20 deletions .github/workflows/validate-tokens.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,31 +9,33 @@ jobs:
validate-tokens:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Use Node.js
uses: actions/setup-node@v2
- name: Setup Bun
uses: oven-sh/setup-bun@v1
with:
node-version: "16"
bun-version: latest

- name: Install dependencies
run: |
npm install [email protected]
npm install axios
run: bun install

- 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 scripts/validate-token-configs.js
git fetch origin ${{ github.base_ref }}
git show origin/${{ github.base_ref }}:registry/mainnet/interchain/squid.tokenlist.json > base_file.json
cp registry/mainnet/interchain/squid.tokenlist.json current_file.json
- 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
bun run - <<EOF
import * as fs from 'fs/promises';
const base = JSON.parse(await fs.readFile('base_file.json', 'utf8'));
const current = JSON.parse(await fs.readFile('current_file.json', 'utf8'));
const newTokens = Object.entries(current.tokens)
.filter(([id, token]) => !base.tokens[id])
.reduce((obj, [id, token]) => ({ ...obj, [id]: token }), {});
await fs.writeFile('new_tokens.json', JSON.stringify(newTokens, null, 2));
EOF
bun run scripts/validate-token-configs.ts
7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
"codegen:chains": "bun run scripts/codegen-chains.ts",
"codegen": "bun run codegen:schemas && bun run codegen:chains",
"test": "vitest --run",
"prepare": "husky install"
"prepare": "husky install",
"validate": "bun run scripts/run-validation.ts"
},
"keywords": [
"axelar",
Expand All @@ -20,7 +21,9 @@
],
"license": "LicenseRef-LICENSE",
"dependencies": {
"@inquirer/prompts": "^4.3.0"
"@inquirer/prompts": "^4.3.0",
"ethers": "^6.13.2",
"axios": "^1.6.7"
},
"devDependencies": {
"@axelarjs/utils": "^0.1.12",
Expand Down
Loading

0 comments on commit 336100f

Please sign in to comment.