Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: Generate matrix from custom networks #153

Open
wants to merge 13 commits into
base: master
Choose a base branch
from
125 changes: 125 additions & 0 deletions .github/scripts/generateMatrix.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
import { customNetworks } from '../../src/customNetworks';

type Command = {
name: string;
paths: string[];
version: boolean;
command: string;
};

const arbitrumCommands: Command[] = [
// Arb1
{
name: 'Arb1 FullList',
paths: ['ArbTokenLists/arbed_full.json'],
version: false,
command:
'yarn fullList --l2NetworkID 42161 --newArbifiedList ./src/ArbTokenLists/arbed_full.json --skipValidation',
},
{
name: 'Arb1 Arbify Uniswap',
paths: [
'ArbTokenLists/arbed_uniswap_labs.json',
'ArbTokenLists/arbed_uniswap_labs_default.json',
],
version: true,
command:
'yarn arbify --l2NetworkID 42161 --prevArbifiedList https://tokenlist.arbitrum.io/ArbTokenLists/arbed_uniswap_labs.json --tokenList https://tokens.uniswap.org --newArbifiedList ./src/ArbTokenLists/arbed_uniswap_labs.json && cp ./src/ArbTokenLists/arbed_uniswap_labs.json ./src/ArbTokenLists/arbed_uniswap_labs_default.json',
},
{
name: 'Arb1 Arbify CMC',
paths: ['ArbTokenLists/arbed_coinmarketcap.json'],
version: true,
command:
'yarn arbify --l2NetworkID 42161 --prevArbifiedList https://tokenlist.arbitrum.io/ArbTokenLists/arbed_coinmarketcap.json --tokenList https://api.coinmarketcap.com/data-api/v3/uniswap/all.json --newArbifiedList ./src/ArbTokenLists/arbed_coinmarketcap.json',
},
{
name: 'Arb1 Arbify CoinGecko',
paths: ['ArbTokenLists/arbed_coingecko.json'],
version: true,
command:
'yarn arbify --l2NetworkID 42161 --prevArbifiedList https://tokenlist.arbitrum.io/ArbTokenLists/arbed_coingecko.json --tokenList https://tokens.coingecko.com/uniswap/all.json --newArbifiedList ./src/ArbTokenLists/arbed_coingecko.json',
},
{
name: 'Arb1 Update Whitelist',
paths: ['ArbTokenLists/arbed_arb_whitelist_era.json'],
version: true,
command:
'yarn update --l2NetworkID 42161 --prevArbifiedList https://tokenlist.arbitrum.io/ArbTokenLists/arbed_arb_whitelist_era.json --tokenList https://tokenlist.arbitrum.io/ArbTokenLists/arbed_arb_whitelist_era.json --includeOldDataFields true --newArbifiedList ./src/ArbTokenLists/arbed_arb_whitelist_era.json',
},
// Arb Nova
{
name: 'ArbNova Arbify Uniswap',
paths: [
'ArbTokenLists/42170_arbed_uniswap_labs.json',
'ArbTokenLists/42170_arbed_uniswap_labs_default.json',
],
version: true,
command:
'yarn arbify --l2NetworkID 42170 --prevArbifiedList https://tokenlist.arbitrum.io/ArbTokenLists/42170_arbed_uniswap_labs_default.json --newArbifiedList ./src/ArbTokenLists/42170_arbed_uniswap_labs.json --tokenList https://tokens.uniswap.org && cp ./src/ArbTokenLists/42170_arbed_uniswap_labs.json ./src/ArbTokenLists/42170_arbed_uniswap_labs_default.json',
},
{
name: 'ArbNova Arbify CMC',
paths: ['ArbTokenLists/42170_arbed_coinmarketcap.json'],
version: true,
command:
'yarn arbify --l2NetworkID 42170 --prevArbifiedList https://tokenlist.arbitrum.io/ArbTokenLists/42170_arbed_coinmarketcap.json --tokenList https://api.coinmarketcap.com/data-api/v3/uniswap/all.json --newArbifiedList ./src/ArbTokenLists/42170_arbed_coinmarketcap.json',
},
{
name: 'ArbNova Arbify CoinGecko',
paths: ['ArbTokenLists/42170_arbed_coingecko.json'],
version: true,
command:
'yarn arbify --l2NetworkID 42170 --prevArbifiedList https://tokenlist.arbitrum.io/ArbTokenLists/42170_arbed_coingecko.json --tokenList https://tokens.coingecko.com/uniswap/all.json --newArbifiedList ./src/ArbTokenLists/42170_arbed_coingecko.json',
},
// ArbSepolia
{
name: 'ArbSepolia Arbify Uniswap',
paths: ['ArbTokenLists/421614_arbed_uniswap_labs.json'],
version: true,
command:
'yarn arbify --l2NetworkID 421614 --prevArbifiedList https://tokenlist.arbitrum.io/ArbTokenLists/421614_arbed_uniswap_labs.json --tokenList https://tokens.uniswap.org --newArbifiedList ./src/ArbTokenLists/421614_arbed_uniswap_labs.json',
},
{
name: 'ArbSepolia Arbify CoinGecko',
paths: ['ArbTokenLists/421614_arbed_coingecko.json'],
version: true,
command:
'yarn arbify --l2NetworkID 421614 --prevArbifiedList https://tokenlist.arbitrum.io/ArbTokenLists/421614_arbed_coingecko.json --tokenList https://tokens.coingecko.com/uniswap/all.json --newArbifiedList ./src/ArbTokenLists/421614_arbed_coingecko.json',
},
];

const orbitCommands: Command[] = [];

Object.values(customNetworks).forEach(({ name, chainID, partnerChainID }) => {
// For each L2, generate arbified list
if (partnerChainID === 1 || partnerChainID === 11155111) {
orbitCommands.push({
name: `${name} Arbify Uniswap`,
paths: [`ArbTokenLists/${chainID}_arbed_uniswap_labs.json`],
version: true,
command: `yarn arbify --l2NetworkID ${chainID} --prevArbifiedList https://tokenlist.arbitrum.io/ArbTokenLists/${chainID}_arbed_uniswap_labs.json --newArbifiedList ./src/ArbTokenLists/${chainID}_arbed_uniswap_labs.json --tokenList https://tokens.uniswap.org`,
});
return;
}

// For each L3, generate native and uniswap list
orbitCommands.push({
name: `${name} Arbify Uniswap`,
paths: [`ArbTokenLists/${chainID}_arbed_uniswap_labs.json`],
version: true,
command: `yarn arbify --l2NetworkID ${chainID} --prevArbifiedList https://tokenlist.arbitrum.io/ArbTokenLists/${chainID}_arbed_uniswap_labs.json --tokenList https://tokenlist.arbitrum.io/ArbTokenLists/arbed_uniswap_labs.json --newArbifiedList ./src/ArbTokenLists/${chainID}_arbed_uniswap_labs.json`,
});
orbitCommands.push({
name: `${name} Arbify L2 native list`,
paths: [`ArbTokenLists/${chainID}_arbed_native_list.json`],
version: true,
command: `yarn arbify --l2NetworkID ${chainID} --prevArbifiedList https://tokenlist.arbitrum.io/ArbTokenLists/${chainID}_arbed_native_list.json --tokenList ./src/Assets/42161_arbitrum_native_token_list.json --newArbifiedList ./src/ArbTokenLists/${chainID}_arbed_native_list.json`,
});
});

const matrix: Record<'include', Command[]> = {
include: arbitrumCommands.concat(orbitCommands),
};

console.log(JSON.stringify(matrix, null, 0));
178 changes: 27 additions & 151 deletions .github/workflows/generate-token-lists.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,160 +42,36 @@ jobs:
path: '**/node_modules'
key: ${{ steps.cache.outputs.primary-key }}

generate-matrix:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- uses: actions/checkout@v4

- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '20'

- name: Install dependencies
run: npm install ts-node typescript

- id: set-matrix
run: echo "matrix=$(npx ts-node .github/scripts/generateMatrix.ts)" >> $GITHUB_OUTPUT

generate-token-lists:
name: 'Generate'
runs-on: ubuntu-latest
environment: ${{ inputs.environment }}
needs: [install]
needs: [install, generate-matrix]
permissions:
id-token: write # need this for OIDC
contents: read # This is required for actions/checkout@v2
strategy:
max-parallel: 5
fail-fast: false
matrix:
commands:
# Arb1
- name: Arb1 FullList
paths:
- ArbTokenLists/arbed_full.json
version: false
command: yarn fullList --l2NetworkID 42161 --newArbifiedList ./src/ArbTokenLists/arbed_full.json --skipValidation

- name: Arb1 Arbify Uniswap
paths:
- ArbTokenLists/arbed_uniswap_labs.json
- ArbTokenLists/arbed_uniswap_labs_default.json
version: true
command: yarn arbify --l2NetworkID 42161 --prevArbifiedList https://tokenlist.arbitrum.io/ArbTokenLists/arbed_uniswap_labs.json --tokenList https://tokens.uniswap.org --newArbifiedList ./src/ArbTokenLists/arbed_uniswap_labs.json && cp ./src/ArbTokenLists/arbed_uniswap_labs.json ./src/ArbTokenLists/arbed_uniswap_labs_default.json

# - name: Arb1 Arbify Gemini
# paths:
# - ArbTokenLists/arbed_gemini_token_list.json
# version: true
# command: yarn arbify --l2NetworkID 42161 --prevArbifiedList https://tokenlist.arbitrum.io/ArbTokenLists/arbed_gemini_token_list.json --tokenList https://www.gemini.com/uniswap/manifest.json --newArbifiedList ./src/ArbTokenLists/arbed_gemini_token_list.json

- name: Arb1 Arbify CMC
paths:
- ArbTokenLists/arbed_coinmarketcap.json
version: true
command: yarn arbify --l2NetworkID 42161 --prevArbifiedList https://tokenlist.arbitrum.io/ArbTokenLists/arbed_coinmarketcap.json --tokenList https://api.coinmarketcap.com/data-api/v3/uniswap/all.json --newArbifiedList ./src/ArbTokenLists/arbed_coinmarketcap.json

- name: Arb1 Arbify CoinGecko
paths:
- ArbTokenLists/arbed_coingecko.json
version: true
command: yarn arbify --l2NetworkID 42161 --prevArbifiedList https://tokenlist.arbitrum.io/ArbTokenLists/arbed_coingecko.json --tokenList https://tokens.coingecko.com/uniswap/all.json --newArbifiedList ./src/ArbTokenLists/arbed_coingecko.json

- name: Arb1 Update Whitelist
paths:
- ArbTokenLists/arbed_arb_whitelist_era.json
version: true
command: yarn update --l2NetworkID 42161 --prevArbifiedList https://tokenlist.arbitrum.io/ArbTokenLists/arbed_arb_whitelist_era.json --tokenList https://tokenlist.arbitrum.io/ArbTokenLists/arbed_arb_whitelist_era.json --includeOldDataFields true --newArbifiedList ./src/ArbTokenLists/arbed_arb_whitelist_era.json

# ArbNova
- name: ArbNova Arbify Uniswap
paths:
- ArbTokenLists/42170_arbed_uniswap_labs.json
- ArbTokenLists/42170_arbed_uniswap_labs_default.json
version: true
command: yarn arbify --l2NetworkID 42170 --prevArbifiedList https://tokenlist.arbitrum.io/ArbTokenLists/42170_arbed_uniswap_labs_default.json --newArbifiedList ./src/ArbTokenLists/42170_arbed_uniswap_labs.json --tokenList https://tokens.uniswap.org && cp ./src/ArbTokenLists/42170_arbed_uniswap_labs.json ./src/ArbTokenLists/42170_arbed_uniswap_labs_default.json

# - name: ArbNova Arbify Gemini
# paths:
# - ArbTokenLists/42170_arbed_gemini_token_list.json
# version: true
# command: yarn arbify --l2NetworkID 42170 --prevArbifiedList https://tokenlist.arbitrum.io/ArbTokenLists/42170_arbed_gemini_token_list.json --tokenList https://www.gemini.com/uniswap/manifest.json --newArbifiedList ./src/ArbTokenLists/42170_arbed_gemini_token_list.json

- name: ArbNova Arbify CMC
paths:
- ArbTokenLists/42170_arbed_coinmarketcap.json
version: true
command: yarn arbify --l2NetworkID 42170 --prevArbifiedList https://tokenlist.arbitrum.io/ArbTokenLists/42170_arbed_coinmarketcap.json --tokenList https://api.coinmarketcap.com/data-api/v3/uniswap/all.json --newArbifiedList ./src/ArbTokenLists/42170_arbed_coinmarketcap.json

- name: ArbNova Arbify CoinGecko
paths:
- ArbTokenLists/42170_arbed_coingecko.json
version: true
command: yarn arbify --l2NetworkID 42170 --prevArbifiedList https://tokenlist.arbitrum.io/ArbTokenLists/42170_arbed_coingecko.json --tokenList https://tokens.coingecko.com/uniswap/all.json --newArbifiedList ./src/ArbTokenLists/42170_arbed_coingecko.json

# SX Network
- name: SX Network Arbify Uniswap
paths:
- ArbTokenLists/4162_arbed_uniswap_labs.json
version: true
command: yarn arbify --l2NetworkID 4162 --prevArbifiedList https://tokenlist.arbitrum.io/ArbTokenLists/4162_arbed_uniswap_labs.json --newArbifiedList ./src/ArbTokenLists/4162_arbed_uniswap_labs.json --tokenList https://tokens.uniswap.org

# ArbSepolia
- name: ArbSepolia Arbify Uniswap
paths:
- ArbTokenLists/421614_arbed_uniswap_labs.json
version: true
command: yarn arbify --l2NetworkID 421614 --prevArbifiedList https://tokenlist.arbitrum.io/ArbTokenLists/421614_arbed_uniswap_labs.json --tokenList https://tokens.uniswap.org --newArbifiedList ./src/ArbTokenLists/421614_arbed_uniswap_labs.json

- name: ArbSepolia Arbify CoinGecko
paths:
- ArbTokenLists/421614_arbed_coingecko.json
version: true
command: yarn arbify --l2NetworkID 421614 --prevArbifiedList https://tokenlist.arbitrum.io/ArbTokenLists/421614_arbed_coingecko.json --tokenList https://tokens.coingecko.com/uniswap/all.json --newArbifiedList ./src/ArbTokenLists/421614_arbed_coingecko.json

# Orbit Chains
- name: Xai Arbify Uniswap
paths:
- ArbTokenLists/660279_arbed_uniswap_labs.json
version: true
command: yarn arbify --l2NetworkID 660279 --prevArbifiedList https://tokenlist.arbitrum.io/ArbTokenLists/660279_arbed_uniswap_labs.json --tokenList https://tokenlist.arbitrum.io/ArbTokenLists/arbed_uniswap_labs.json --newArbifiedList ./src/ArbTokenLists/660279_arbed_uniswap_labs.json
- name: Xai Arbify L2 native list
paths:
- ArbTokenLists/660279_arbed_native_list.json
version: true
command: yarn arbify --l2NetworkID 660279 --prevArbifiedList https://tokenlist.arbitrum.io/ArbTokenLists/660279_arbed_native_list.json --tokenList ./src/Assets/42161_arbitrum_native_token_list.json --newArbifiedList ./src/ArbTokenLists/660279_arbed_native_list.json

- name: Rari Arbify Uniswap
paths:
- ArbTokenLists/1380012617_arbed_uniswap_labs.json
version: true
command: yarn arbify --l2NetworkID 1380012617 --prevArbifiedList https://tokenlist.arbitrum.io/ArbTokenLists/1380012617_arbed_uniswap_labs.json --tokenList https://tokenlist.arbitrum.io/ArbTokenLists/arbed_uniswap_labs.json --newArbifiedList ./src/ArbTokenLists/1380012617_arbed_uniswap_labs.json
- name: Rari Arbify L2 native list
paths:
- ArbTokenLists/1380012617_arbed_native_list.json
version: true
command: yarn arbify --l2NetworkID 1380012617 --prevArbifiedList https://tokenlist.arbitrum.io/ArbTokenLists/1380012617_arbed_native_list.json --tokenList ./src/Assets/42161_arbitrum_native_token_list.json --newArbifiedList ./src/ArbTokenLists/1380012617_arbed_native_list.json

- name: Muster Arbify Uniswap
paths:
- ArbTokenLists/4078_arbed_uniswap_labs.json
version: true
command: yarn arbify --l2NetworkID 4078 --prevArbifiedList https://tokenlist.arbitrum.io/ArbTokenLists/4078_arbed_uniswap_labs.json --tokenList https://tokenlist.arbitrum.io/ArbTokenLists/arbed_uniswap_labs.json --newArbifiedList ./src/ArbTokenLists/4078_arbed_uniswap_labs.json
- name: Muster Arbify L2 native list
paths:
- ArbTokenLists/4078_arbed_native_list.json
version: true
command: yarn arbify --l2NetworkID 4078 --prevArbifiedList https://tokenlist.arbitrum.io/ArbTokenLists/4078_arbed_native_list.json --tokenList ./src/Assets/42161_arbitrum_native_token_list.json --newArbifiedList ./src/ArbTokenLists/4078_arbed_native_list.json

- name: Proof of Play Apex Arbify Uniswap
paths:
- ArbTokenLists/70700_arbed_uniswap_labs.json
version: true
command: yarn arbify --l2NetworkID 70700 --prevArbifiedList https://tokenlist.arbitrum.io/ArbTokenLists/70700_arbed_uniswap_labs.json --tokenList https://tokenlist.arbitrum.io/ArbTokenLists/arbed_uniswap_labs.json --newArbifiedList ./src/ArbTokenLists/70700_arbed_uniswap_labs.json
- name: Proof of Play Apex Arbify L2 native list
paths:
- ArbTokenLists/70700_arbed_native_list.json
version: true
command: yarn arbify --l2NetworkID 70700 --prevArbifiedList https://tokenlist.arbitrum.io/ArbTokenLists/70700_arbed_native_list.json --tokenList ./src/Assets/42161_arbitrum_native_token_list.json --newArbifiedList ./src/ArbTokenLists/70700_arbed_native_list.json

# Orbit Chains testnet
- name: Xai Testnet Arbify Uniswap
paths:
- ArbTokenLists/37714555429_arbed_uniswap_labs.json
version: true
command: yarn arbify --l2NetworkID 37714555429 --prevArbifiedList https://tokenlist.arbitrum.io/ArbTokenLists/37714555429_arbed_uniswap_labs.json --tokenList https://tokenlist.arbitrum.io/ArbTokenLists/arbed_uniswap_labs.json --newArbifiedList ./src/ArbTokenLists/37714555429_arbed_uniswap_labs.json

- name: Dodochain Testnet Arbify Uniswap
paths:
- ArbTokenLists/53457_arbed_uniswap_labs.json
version: true
command: yarn arbify --l2NetworkID 53457 --prevArbifiedList https://tokenlist.arbitrum.io/ArbTokenLists/53457_arbed_uniswap_labs.json --tokenList https://tokenlist.arbitrum.io/ArbTokenLists/arbed_uniswap_labs.json --newArbifiedList ./src/ArbTokenLists/53457_arbed_uniswap_labs.json
matrix: ${{ fromJson(needs.generate-matrix.outputs.matrix) }}

env:
INFURA_KEY: '${{ secrets.INFURA_KEY }}'
Expand All @@ -217,18 +93,18 @@ jobs:
aws-access-key-id: ${{ secrets.AWS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}

- name: ${{ matrix.commands.name }}
- name: ${{ matrix.name }}
if: success()
run: ${{ matrix.commands.command }}
run: ${{ matrix.command }}

- name: Get online version
id: onlineVersion
if: ${{ matrix.commands.version == true && matrix.commands.version == true }}
if: ${{ matrix.version == true && matrix.version == true }}
run: |
# Check if the list exists online (it will not exist on the first run)
if curl --silent --head --fail "https://tokenlist.arbitrum.io/${{ matrix.commands.paths[0] }}"; then
if curl --silent --head --fail "https://tokenlist.arbitrum.io/${{ matrix.paths[0] }}"; then
# Get the version from the online list (formatted to major.minor.patch)
version=$(curl https://tokenlist.arbitrum.io/${{ matrix.commands.paths[0] }} | jq .version | jq 'join(".")')
version=$(curl https://tokenlist.arbitrum.io/${{ matrix.paths[0] }} | jq .version | jq 'join(".")')
if [[ -n $version ]]; then
echo "onlineVersion=$version" >> $GITHUB_OUTPUT
else
Expand All @@ -241,9 +117,9 @@ jobs:
fi

- name: Backup
if: ${{ matrix.commands.version == true }}
if: ${{ matrix.version == true }}
run: |
paths=(${{ join(matrix.commands.paths, ' ') }})
paths=(${{ join(matrix.paths, ' ') }})
for path in ${paths[*]}
do
if [[ "${{ inputs.environment }}" == "Test" ]]
Expand Down
Loading
Loading