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: add XAI token list #121

Merged
merged 7 commits into from
Jan 11, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
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
24 changes: 18 additions & 6 deletions .github/workflows/generate-token-lists.yml
Original file line number Diff line number Diff line change
Expand Up @@ -151,12 +151,19 @@ jobs:
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 --ignore-previous-list --tokenList https://gateway.ipfs.io/ipns/tokens.uniswap.org --newArbifiedList ./src/ArbTokenLists/660279_arbed_uniswap_labs.json
Copy link
Contributor Author

Choose a reason for hiding this comment

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

--ignore-previous-list will be replaced with --prevArbifiedList in a subsequent PR, once the list is uploaded

Copy link
Contributor Author

Choose a reason for hiding this comment

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


env:
INFURA_KEY: '${{ secrets.INFURA_KEY }}'
MAINNET_RPC: 'https://mainnet.infura.io/v3/${{ secrets.INFURA_KEY }}'
GOERLI_RPC: 'https://goerli.infura.io/v3/${{ secrets.INFURA_KEY }}'
SEPOLIA_RPC: 'https://sepolia.infura.io/v3/${{ secrets.INFURA_KEY }}'

ARB_ONE_RPC: 'https://arbitrum-mainnet.infura.io/v3/${{ secrets.INFURA_KEY }}'
steps:
- uses: actions/checkout@v3

Expand All @@ -177,12 +184,17 @@ jobs:
id: onlineVersion
if: ${{ matrix.commands.version == true && matrix.commands.version == true }}
run: |
version=$(curl https://tokenlist.arbitrum.io/${{ matrix.commands.paths[0] }} | jq .version | jq 'join(".")')
if [[ -n $version ]]; then
echo "onlineVersion=$version" >> $GITHUB_OUTPUT
if curl --silent --head --fail "https://tokenlist.arbitrum.io/ArbTokenLists/${{ matrix.commands.paths[0] }}"; then
version=$(curl https://tokenlist.arbitrum.io/${{ matrix.commands.paths[0] }} | jq .version | jq 'join(".")')
if [[ -n $version ]]; then
echo "onlineVersion=$version" >> $GITHUB_OUTPUT
else
# Make sure failure from curl or jq fails the generation
exit 1
fi
else
# Make sure failure from curl or jq fails the generation
exit 1
# Only applies when a new list is added
echo "onlineVersion=1.0.0" >> $GITHUB_OUTPUT
fi

- name: Backup
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"test:unit": "yarn test --ci __test__/unit"
},
"dependencies": {
"@arbitrum/sdk": "^3.1.13",
"@arbitrum/sdk": "^3.1.13-orbit-custom-fee-token.1",
"@types/jest": "^29.2.5",
"@uniswap/token-lists": "^1.0.0-beta.33",
"ajv": "^8.12.0",
Expand Down
46 changes: 25 additions & 21 deletions src/lib/instantiate_bridge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,40 +7,44 @@ export const getNetworkConfig = async () => {
const networkID = argv.l2NetworkID;
console.log('Using L2 networkID:', networkID);

const l2Rpc = (() => {
if (networkID === 42161) return 'https://arb1.arbitrum.io/rpc';
else if (networkID === 42170) return 'https://nova.arbitrum.io/rpc';
else if (networkID === 421613)
return 'https://goerli-rollup.arbitrum.io/rpc';
else if (networkID === 421614)
return 'https://sepolia-rollup.arbitrum.io/rpc';
const childRpc = {
42161: 'https://arb1.arbitrum.io/rpc',
42170: 'https://nova.arbitrum.io/rpc',
421613: 'https://goerli-rollup.arbitrum.io/rpc',
421614: 'https://sepolia-rollup.arbitrum.io/rpc',
660279: 'https://xai-chain.net/rpc',
}[networkID];

if (!childRpc) {
throw new Error('No L2 RPC detected');
chrstph-dvx marked this conversation as resolved.
Show resolved Hide resolved
})();
const arbProvider = new providers.JsonRpcProvider(l2Rpc);
const l2Network = await getL2Network(arbProvider);
}

const childProvider = new providers.JsonRpcProvider(childRpc);
const childNetwork = await getL2Network(childProvider);

const expectedEnv = (() => {
if (l2Network.partnerChainID === 1) return 'MAINNET_RPC';
else if (l2Network.partnerChainID === 5) return 'GOERLI_RPC';
else if (l2Network.partnerChainID === 11155111) return 'SEPOLIA_RPC';
if (childNetwork.partnerChainID === 1) return 'MAINNET_RPC';
else if (childNetwork.partnerChainID === 5) return 'GOERLI_RPC';
else if (childNetwork.partnerChainID === 11155111) return 'SEPOLIA_RPC';
else if (childNetwork.partnerChainID === 42161) return 'ARB_ONE_RPC';
throw new Error('No L1 RPC detected');
})();
const l1Rpc = process.env[expectedEnv];
if (!l1Rpc) throw new Error(`Please set ${expectedEnv}`);
const parentRpc = process.env[expectedEnv];
if (!parentRpc) throw new Error(`Please set ${expectedEnv}`);

const ethProvider = new providers.JsonRpcProvider(l1Rpc);
const parentProvider = new providers.JsonRpcProvider(parentRpc);

const l1MultiCaller = await MultiCaller.fromProvider(ethProvider);
const l2MultiCaller = await MultiCaller.fromProvider(arbProvider);
const l1MultiCaller = await MultiCaller.fromProvider(parentProvider);
Copy link

Choose a reason for hiding this comment

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

nit for consistency

Suggested change
const l1MultiCaller = await MultiCaller.fromProvider(parentProvider);
const parentMultiCaller = await MultiCaller.fromProvider(parentProvider);

same for L2

const l2MultiCaller = await MultiCaller.fromProvider(childProvider);

return {
l1: {
provider: ethProvider,
provider: parentProvider,
multiCaller: l1MultiCaller,
},
l2: {
network: l2Network,
provider: arbProvider,
network: childNetwork,
provider: childProvider,
multiCaller: l2MultiCaller,
},
};
Expand Down
41 changes: 41 additions & 0 deletions src/main.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
#!/usr/bin/env node
import { addCustomChain } from '@arbitrum/sdk';
import { Chain } from '@arbitrum/sdk/dist/lib/dataEntities/networks';

import { yargsInstance } from './lib/options';
import * as dotenv from 'dotenv';
import dotenvExpand from 'dotenv-expand';
Expand Down Expand Up @@ -63,4 +66,42 @@ if (process.env.NODE_ENV !== 'test') {
alltokenslist.parseAsync();
}

const xai: Chain = {
chainID: 660279,
confirmPeriodBlocks: 45818,
ethBridge: {
bridge: '0x7dd8A76bdAeBE3BBBaCD7Aa87f1D4FDa1E60f94f',
inbox: '0xaE21fDA3de92dE2FDAF606233b2863782Ba046F9',
outbox: '0x1E400568AD4840dbE50FB32f306B842e9ddeF726',
rollup: '0xC47DacFbAa80Bd9D8112F4e8069482c2A3221336',
sequencerInbox: '0x995a9d3ca121D48d21087eDE20bc8acb2398c8B1',
},
explorerUrl: 'https://explorer.xai-chain.net',
isArbitrum: true,
isCustom: true,
name: 'Xai',
partnerChainID: 42161,
retryableLifetimeSeconds: 604800,
tokenBridge: {
l1CustomGateway: '0xb15A0826d65bE4c2fDd961b72636168ee70Af030',
l1ERC20Gateway: '0xb591cE747CF19cF30e11d656EB94134F523A9e77',
l1GatewayRouter: '0x22CCA5Dc96a4Ac1EC32c9c7C5ad4D66254a24C35',
l1MultiCall: '0x842eC2c7D803033Edf55E478F461FC547Bc54EB2',
l1ProxyAdmin: '0x041f85dd87c46b941dc9b15c6628b19ee5358485',
l1Weth: '0x0000000000000000000000000000000000000000',
l1WethGateway: '0x0000000000000000000000000000000000000000',
l2CustomGateway: '0x96551194230725c72ACF8E9573B1382CCBC70635',
l2ERC20Gateway: '0x0c71417917D24F4A6A6A55559B98c5cCEcb33F7a',
l2GatewayRouter: '0xd096e8dE90D34de758B0E0bA4a796eA2e1e272cF',
l2Multicall: '0xEEC168551A85911Ec3A905e0561b656979f3ea67',
l2ProxyAdmin: '0x56800fDCFbE19Ea3EE9d115dAC30d95d6459c44E',
l2Weth: '0x0000000000000000000000000000000000000000',
l2WethGateway: '0x0000000000000000000000000000000000000000',
},
nitroGenesisBlock: 0,
nitroGenesisL1Block: 0,
depositTimeout: 1800000,
};
addCustomChain({ customChain: xai });
Copy link
Member

Choose a reason for hiding this comment

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

Just a note that this will change back to addCustomNetwork in the next stable release of the SDK


export { update, yargsInstance };
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
"@jridgewell/gen-mapping" "^0.1.0"
"@jridgewell/trace-mapping" "^0.3.9"

"@arbitrum/sdk@^3.1.13":
version "3.1.13"
resolved "https://registry.yarnpkg.com/@arbitrum/sdk/-/sdk-3.1.13.tgz#a0d3d9a7b387f42547c63f6f066d8a6c4dd945cc"
integrity sha512-oE/j8ThWWEdFfV0helmR8lD0T67/CY1zMCt6RVslaCLrytFdbg3QsrHs/sQE3yiCXgisQlsx3qomCgh8PfBo8Q==
"@arbitrum/sdk@^3.1.13-orbit-custom-fee-token.1":
version "3.1.13-orbit-custom-fee-token.1"
resolved "https://registry.yarnpkg.com/@arbitrum/sdk/-/sdk-3.1.13-orbit-custom-fee-token.1.tgz#c10e26c71447eb8c9d0cb1c6efe26c57841b18b7"
integrity sha512-DkKk92Ga1lAsn0FZ+6/HAMcPHdmdAvCalZYfWhyHxTQXYdAWDA9Pz0gRi1KaOBPV2eQn7t64Cluz9Z3LU+7Bog==
dependencies:
"@ethersproject/address" "^5.0.8"
"@ethersproject/bignumber" "^5.1.1"
Expand Down