-
Notifications
You must be signed in to change notification settings - Fork 84
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c595dc9
commit 336100f
Showing
6 changed files
with
2,527 additions
and
356 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.