-
Notifications
You must be signed in to change notification settings - Fork 17
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
base: master
Are you sure you want to change the base?
Changes from 30 commits
694b4b4
4d27b98
5b7c4de
bed2f52
fb7e7f4
d0977cb
47b652e
a9ef2d0
df80547
b12f3d3
fe555e8
62a9ef4
d499a03
1f761ce
44690f7
40c4fa7
dd79fb9
8c7f1c5
c8f79b5
89377c7
73188e2
32fa6df
d60c7bc
57840c5
5356a13
f82aadc
f4c514a
02532b8
c90fed7
a2a038f
5923521
b6ce59f
297428e
d8a8d31
3445081
db94f4c
42a71fd
7d5b6c9
6996a45
6b2e15d
7a6bb6e
7c01cbc
0e7c0d2
bfcddcf
f9c9338
7a91c9b
3aa24f9
6da0306
1f55872
532810b
44658f1
66bb0a4
f0c3877
95d12d9
da94dd0
a4997d0
2c971a5
7a0c188
d76facd
d51e97b
8e4a960
3a250e3
eb8dca0
d7ab51a
107f39c
f8f607f
2ead8d0
44e6537
3fac174
e53859b
494444e
97352fe
162bbbd
a881ee7
d200a7c
bcb3a4d
4293102
7376bbc
223e7e3
a65e544
5d98ef6
cf2270b
e2fef5f
2c6d5b1
2812bd5
b4a77e0
c49c733
7346c62
854cd91
c176008
2a48445
a573db1
3eec9e4
7fdfd75
e8b9754
6c3bd83
0d8f1d5
ba1b886
1dbfeab
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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(); | ||
const result: L2NetworkWithRpc[] = orbitChains.map((orbitChain) => | ||
parseChainToL2Network(orbitChain), | ||
); | ||
|
||
fs.writeFileSync( | ||
fileName, | ||
JSON.stringify({ | ||
data: result, | ||
}), | ||
); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Pretty much yes |
||
})(); |
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' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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)); | ||
})(); |
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 |
There was a problem hiding this comment.
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?