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

feat: Fetch orbit chains data #154

Open
wants to merge 99 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 30 commits
Commits
Show all changes
99 commits
Select commit Hold shift + click to select a range
694b4b4
refactor: Generate matrix from custom networks
chrstph-dvx Nov 26, 2024
4d27b98
Add missing file
chrstph-dvx Nov 26, 2024
5b7c4de
fix path
chrstph-dvx Nov 26, 2024
bed2f52
fix path
chrstph-dvx Nov 26, 2024
fb7e7f4
fix path
chrstph-dvx Nov 26, 2024
d0977cb
parse json
chrstph-dvx Nov 26, 2024
47b652e
Generate token lists for orbit chains
chrstph-dvx Nov 26, 2024
a9ef2d0
format
chrstph-dvx Nov 26, 2024
df80547
Remove commands
chrstph-dvx Nov 26, 2024
b12f3d3
Fix path
chrstph-dvx Nov 26, 2024
fe555e8
Try a command with error
chrstph-dvx Nov 26, 2024
62a9ef4
Remove error
chrstph-dvx Nov 26, 2024
d499a03
Fix path for arbified list
chrstph-dvx Dec 9, 2024
1f761ce
feat: Fetch orbit chains from bridge repo
chrstph-dvx Nov 28, 2024
44690f7
Add workflow to generate new token lists every 24h
chrstph-dvx Nov 28, 2024
40c4fa7
dryrun
chrstph-dvx Dec 9, 2024
dd79fb9
dryrun
chrstph-dvx Dec 9, 2024
8c7f1c5
restore
chrstph-dvx Dec 9, 2024
c8f79b5
Add support for base, baseSepolia, holesky
chrstph-dvx Dec 10, 2024
89377c7
WIP: Run new generation before regular generation
chrstph-dvx Dec 10, 2024
73188e2
Remove ts-ignore
chrstph-dvx Dec 10, 2024
32fa6df
Simplify workflow
chrstph-dvx Dec 11, 2024
d60c7bc
Remove fetchNewOrbitChains.ts
chrstph-dvx Dec 11, 2024
57840c5
Remove uneeded flag
chrstph-dvx Dec 11, 2024
5356a13
Remove log
chrstph-dvx Dec 11, 2024
f82aadc
Fetch orbit chain data before running matrix
chrstph-dvx Dec 11, 2024
f4c514a
Fetch orbit chain data
chrstph-dvx Dec 11, 2024
02532b8
Format orbitChainsData
chrstph-dvx Dec 11, 2024
c90fed7
Add file back
chrstph-dvx Dec 11, 2024
a2a038f
with file
chrstph-dvx Dec 11, 2024
5923521
Generate orbitChainsData after yarn install
chrstph-dvx Dec 12, 2024
b6ce59f
with scripts folder
chrstph-dvx Dec 12, 2024
297428e
cleanup
chrstph-dvx Dec 12, 2024
d8a8d31
Add support for holesky and nova as parent
chrstph-dvx Dec 12, 2024
3445081
Pick uniswap token list based on parent chain
chrstph-dvx Dec 12, 2024
db94f4c
Ensure orbitChainsData is generated in CI
chrstph-dvx Dec 12, 2024
42a71fd
Replace yarn with npx for generating orbit chains
chrstph-dvx Dec 12, 2024
7d5b6c9
Replace yarn with npm
chrstph-dvx Dec 12, 2024
6996a45
run prettier after generation
chrstph-dvx Dec 12, 2024
6b2e15d
cleanup
chrstph-dvx Dec 12, 2024
7a6bb6e
Add actions to download and restore artifacts
chrstph-dvx Dec 12, 2024
7c01cbc
Add checkout call
chrstph-dvx Dec 12, 2024
0e7c0d2
add checkout before calling generation
chrstph-dvx Dec 12, 2024
bfcddcf
WIP
chrstph-dvx Dec 12, 2024
f9c9338
WIP
chrstph-dvx Dec 12, 2024
7a91c9b
WIP
chrstph-dvx Dec 12, 2024
3aa24f9
WIP
chrstph-dvx Dec 12, 2024
6da0306
WIP
chrstph-dvx Dec 12, 2024
1f55872
WIP
chrstph-dvx Dec 12, 2024
532810b
Restore after checkout
chrstph-dvx Dec 12, 2024
44658f1
WIP
chrstph-dvx Dec 12, 2024
66bb0a4
WIP
chrstph-dvx Dec 12, 2024
f0c3877
WIP
chrstph-dvx Dec 12, 2024
95d12d9
WIP
chrstph-dvx Dec 12, 2024
da94dd0
WIP
chrstph-dvx Dec 12, 2024
a4997d0
WIP
chrstph-dvx Dec 13, 2024
2c971a5
WIP
chrstph-dvx Dec 13, 2024
7a0c188
WIP
chrstph-dvx Dec 13, 2024
d76facd
WIP
chrstph-dvx Dec 13, 2024
d51e97b
WIP
chrstph-dvx Dec 13, 2024
8e4a960
WIP
chrstph-dvx Dec 13, 2024
3a250e3
WIP
chrstph-dvx Dec 13, 2024
eb8dca0
WIP
chrstph-dvx Dec 13, 2024
d7ab51a
WIP
chrstph-dvx Dec 13, 2024
107f39c
WIP
chrstph-dvx Dec 13, 2024
f8f607f
WIP
chrstph-dvx Dec 13, 2024
2ead8d0
WIP
chrstph-dvx Dec 13, 2024
44e6537
WIP
chrstph-dvx Dec 13, 2024
3fac174
WIP
chrstph-dvx Dec 13, 2024
e53859b
WIP
chrstph-dvx Dec 13, 2024
494444e
WIP
chrstph-dvx Dec 13, 2024
97352fe
WIP
chrstph-dvx Dec 13, 2024
162bbbd
WIP
chrstph-dvx Dec 13, 2024
a881ee7
WIP
chrstph-dvx Dec 13, 2024
d200a7c
WIP
chrstph-dvx Dec 13, 2024
bcb3a4d
WIP
chrstph-dvx Dec 13, 2024
4293102
WIP
chrstph-dvx Dec 13, 2024
7376bbc
WIP
chrstph-dvx Dec 13, 2024
223e7e3
WIP
chrstph-dvx Dec 13, 2024
a65e544
WIP
chrstph-dvx Dec 13, 2024
5d98ef6
WIP
chrstph-dvx Dec 13, 2024
cf2270b
WIP
chrstph-dvx Dec 13, 2024
e2fef5f
WIP
chrstph-dvx Dec 13, 2024
2c6d5b1
WIP
chrstph-dvx Dec 13, 2024
2812bd5
Add uniswap list for base and base sepolia
chrstph-dvx Dec 13, 2024
b4a77e0
WIP
chrstph-dvx Dec 13, 2024
c49c733
Correct path
chrstph-dvx Dec 13, 2024
7346c62
Update path
chrstph-dvx Dec 13, 2024
854cd91
Update path
chrstph-dvx Dec 13, 2024
c176008
Correct path
chrstph-dvx Dec 13, 2024
2a48445
Correct path
chrstph-dvx Dec 13, 2024
a573db1
update getUniswapTokenListFromPartnerChainId to use partnerChainId
chrstph-dvx Dec 13, 2024
3eec9e4
Add Base and Base sepolia RPC
chrstph-dvx Dec 13, 2024
7fdfd75
Update tsconfig
chrstph-dvx Dec 13, 2024
e8b9754
Cleanup
chrstph-dvx Dec 13, 2024
6c3bd83
minimize diff
chrstph-dvx Dec 13, 2024
0d8f1d5
move overwrite option
chrstph-dvx Dec 13, 2024
ba1b886
Update path
chrstph-dvx Dec 13, 2024
1dbfeab
Update
chrstph-dvx Dec 13, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
123 changes: 123 additions & 0 deletions .github/scripts/fetchOrbitChainsData.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
import * as fs from 'fs';
import { L2Network, constants as arbConstants } from '@arbitrum/sdk';

type OrbitChainData = {
chainId: number;
confirmPeriodBlocks: number;
ethBridge: {
bridge: string;
inbox: string;
outbox: string;
rollup: string;
sequencerInbox: string;
};
nativeToken: string;
explorerUrl: string;
rpcUrl: string;
isCustom: boolean;
isTestnet: boolean;
name: string;
slug: string;
parentChainId: number;
tokenBridge: {
parentCustomGateway: string;
parentErc20Gateway: string;
parentGatewayRouter: string;
parentMultiCall: string;
parentProxyAdmin: string;
parentWeth: string;
parentWethGateway: string;
childCustomGateway: string;
childErc20Gateway: string;
childGatewayRouter: string;
childMultiCall: string;
childProxyAdmin: string;
childWeth: string;
childWethGateway: string;
};
bridgeUiConfig: {
color: string;
network: {
name: string;
logo: string;
description: string;
};
nativeTokenData: {
name: string;
symbol: string;
logoUrl: string;
};
};
};

type OrbitChainDataResponse = {
mainnet: OrbitChainData[];
testnet: OrbitChainData[];
};

type L2NetworkWithRpc = L2Network & { rpcUrl: string };

const fileName = './src/Assets/orbitChainsData.json';

export async function fetchOrbitChainsData() {
const response = await fetch(
'https://raw.githubusercontent.com/OffchainLabs/arbitrum-token-bridge/refs/heads/master/packages/arb-token-bridge-ui/src/util/orbitChainsData.json',
);

const data: OrbitChainDataResponse = await response.json();
return data.mainnet.concat(data.testnet);
}

function parseChainToL2Network({
chainId,
nativeToken,
isTestnet,
slug,
bridgeUiConfig,
parentChainId,
tokenBridge,
...chain
}: OrbitChainData): L2NetworkWithRpc {
return {
chainID: chainId,
nitroGenesisBlock: 0,
nitroGenesisL1Block: 0,
isArbitrum: true,
partnerChainID: parentChainId,
partnerChainIDs: [],
retryableLifetimeSeconds: 604800,
depositTimeout: 1800000,
blockTime: arbConstants.ARB_MINIMUM_BLOCK_TIME_IN_SECONDS,
tokenBridge: {
l1CustomGateway: tokenBridge.parentCustomGateway,
l1ERC20Gateway: tokenBridge.parentErc20Gateway,
l1GatewayRouter: tokenBridge.parentGatewayRouter,
l1MultiCall: tokenBridge.parentMultiCall,
l1ProxyAdmin: tokenBridge.parentProxyAdmin,
l1Weth: tokenBridge.parentWeth,
l1WethGateway: tokenBridge.parentWethGateway,
l2CustomGateway: tokenBridge.childCustomGateway,
l2ERC20Gateway: tokenBridge.childErc20Gateway,
l2GatewayRouter: tokenBridge.childGatewayRouter,
l2Multicall: tokenBridge.childMultiCall,
l2ProxyAdmin: tokenBridge.childProxyAdmin,
l2Weth: tokenBridge.childWeth,
l2WethGateway: tokenBridge.childWethGateway,
},
...chain,
};
}

(async () => {
const orbitChains = await fetchOrbitChainsData();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we want to add a try catch here?

const result: L2NetworkWithRpc[] = orbitChains.map((orbitChain) =>
parseChainToL2Network(orbitChain),
);

fs.writeFileSync(
fileName,
JSON.stringify({
data: result,
}),
);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if i understand this correctly, if we update arb sdk to v4, we don't need this step and can use the orbit chains data json from bridge ui directly?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pretty much yes

})();
165 changes: 165 additions & 0 deletions .github/scripts/generateMatrix.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,165 @@
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 Sepolia 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: '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[] = [];

async function addCommand({
chainID,
name,
path,
inputList,
}: {
chainID: number;
name: string;
path: string;
inputList: string;
}) {
const url = `https://tokenlist.arbitrum.io/${path}`;
const requiresFirstTimeGeneration = await fetch(url)
.then((response) => response.json())
.then(() => false)
.catch(() => true);

const previousListFlag = requiresFirstTimeGeneration
? '--ignorePreviousList'
: `--prevArbifiedList ${url}`;

return {
name,
paths: [path],
version: true,
command: `yarn arbify --l2NetworkID ${chainID} ${previousListFlag} --tokenList ${inputList} --newArbifiedList ./src/${path}`,
};
}

const l1ChainIds = [1, 11155111, 17000]; // Mainnet, sepolia, holesky
(async () => {
for (let { name, chainID, partnerChainID } of customNetworks) {
// For Orbit chain settling on L1, use uniswap as source. Otherwise use arbified token list
const inputUniswapTokenList = l1ChainIds.includes(partnerChainID)
? 'https://tokens.uniswap.org'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we would also want to use uniswap's list for tokens on Base for Orbit chains on top of Base

: 'https://tokenlist.arbitrum.io/ArbTokenLists/arbed_uniswap_labs.json';

orbitCommands.push(
await addCommand({
name: `${name} Arbify Uniswap`,
chainID,
path: `ArbTokenLists/${chainID}_arbed_uniswap_labs.json`,
inputList: inputUniswapTokenList,
}),
);

// For L3, generate arbified native token list
if (!l1ChainIds.includes(partnerChainID)) {
orbitCommands.push(
await addCommand({
name: `${name} Arbify L2 native list`,
chainID,
path: `ArbTokenLists/${chainID}_arbed_native_list.json`,
inputList: './src/Assets/42161_arbitrum_native_token_list.json',
}),
);
}
}

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

console.log(JSON.stringify(matrix, null, 0));
})();
14 changes: 14 additions & 0 deletions .github/workflows/generate-new-orbit-chain-token-list.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: Generate new orbit chain token list

on:
schedule:
# Every day at 9:00
- cron: '0 9 * * *'

jobs:
generate-token-lists:
uses: ./.github/workflows/generate-token-lists.yml
with:
environment: 'Test'
firstTimeGeneration: true
secrets: inherit
Loading
Loading