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 Arb Sepolia list #113

Merged
merged 18 commits into from
Jan 3, 2024
Merged
Show file tree
Hide file tree
Changes from 17 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
1 change: 1 addition & 0 deletions .env.sample
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
INFURA_KEY=
MAINNET_RPC="https://mainnet.infura.io/v3/${INFURA_KEY}"
GOERLI_RPC="https://goerli.infura.io/v3/${INFURA_KEY}"
SEPOLIA_RPC="https://sepolia.infura.io/v3/${INFURA_KEY}"
l2NetworkID=42161
PORT=3000
2 changes: 2 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ jobs:
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 }}'

steps:
- uses: actions/checkout@v3
Expand All @@ -72,6 +73,7 @@ jobs:
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 }}'

steps:
- uses: actions/checkout@v3
Expand Down
46 changes: 21 additions & 25 deletions .github/workflows/generate-token-lists.yml
Original file line number Diff line number Diff line change
Expand Up @@ -116,10 +116,18 @@ jobs:
- ArbTokenLists/421613_arbed_full.json
version: false
command: yarn fullList --l2NetworkID 421613 --newArbifiedList ./src/ArbTokenLists/421613_arbed_full.json --skipValidation

- 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://gateway.ipfs.io/ipns/tokens.uniswap.org --newArbifiedList ./src/ArbTokenLists/421614_arbed_uniswap_labs.json

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 }}'

steps:
- uses: actions/checkout@v3
Expand All @@ -139,7 +147,7 @@ jobs:

- name: Get online version
id: onlineVersion
if: ${{ matrix.commands.version == true && matrix.commands.version == true }}
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
Expand All @@ -149,40 +157,28 @@ jobs:
exit 1
fi

- name: Get new version
id: newVersion
if: ${{ matrix.commands.version == true && matrix.commands.version == true }}
run: |
version=$(cat ./src/${{ matrix.commands.paths[0] }} | jq .version | jq 'join(".")')
if [[ -n $version ]]; then
echo "newVersion=$version" >> $GITHUB_OUTPUT
else
# Make sure failure from curl or jq fails the generation
exit 1
fi

- name: Backup (Test folder)
if: ${{ inputs.environment == 'Test' && matrix.commands.version == true }}
- name: Backup
if: ${{ matrix.commands.version == true }}
run: |
paths=(${{ join(matrix.commands.paths, ' ') }})
for path in ${paths[*]}
do
aws s3 cp s3://${{ secrets.AWS_BUCKET }}/TestFolder/$path s3://${{ secrets.AWS_BUCKET }}/TestFolder/${{ steps.onlineVersion.outputs.onlineVersion }}/
if [[ "${{ inputs.environment }}" == "Test" ]]
then
additionalPath='TestFolder/'
else
additionalPath='/'
Copy link
Member Author

Choose a reason for hiding this comment

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

looks like it should be an empty string instead?

Copy link
Contributor

Choose a reason for hiding this comment

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

We can do both, have it as TestFolder or empty string. And add the slash where we use it, or have it here, right now we have it as part of the variable (see line 168)

fi
lines=$(aws s3 ls s3://${{ secrets.AWS_BUCKET }}/$additionalPath$path | wc -l)
if (( $lines > 0 )); then
aws s3 cp s3://${{ secrets.AWS_BUCKET }}/$additionalPath$path s3://${{ secrets.AWS_BUCKET }}/$additionalPath${{ steps.onlineVersion.outputs.onlineVersion }}/
fi
done

- name: Deploy (Test folder)
if: ${{ inputs.environment == 'Test' }}
run: aws s3 sync ./src/ s3://${{ secrets.AWS_BUCKET }}/TestFolder --exclude "*" --include "FullList/*.json" --include "ArbTokenLists/*.json"

- name: Backup
if: ${{ inputs.environment == 'CI' && matrix.commands.version == true }}
run: |
paths=(${{ join(matrix.commands.paths, ' ') }})
for path in ${paths[*]}
do
aws s3 cp s3://${{ secrets.AWS_BUCKET }}/$path s3://${{ secrets.AWS_BUCKET }}/${{ steps.onlineVersion.outputs.onlineVersion }}/
done

- name: Deploy
if: ${{ inputs.environment == 'CI' }}
run: aws s3 sync ./src/ s3://${{ secrets.AWS_BUCKET }} --exclude "*" --include "FullList/*.json" --include "ArbTokenLists/*.json" --acl "public-read"
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.0.0",
"@arbitrum/sdk": "^3.1.13",
"@types/jest": "^29.2.5",
"@uniswap/token-lists": "^1.0.0-beta.33",
"ajv": "^8.12.0",
Expand Down
2 changes: 1 addition & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ From root:

1. `yarn install`
2. `cd packages/cli; cp .env.sample .env`
3. In `.env`, either set `MAINNET_RPC` and `GOERLI_RPC` var or `INFURA_KEY`
3. In `.env`, either set `MAINNET_RPC`, `GOERLI_RPC`, and `SEPOLIA_RPC` var or `INFURA_KEY`

### Arbify an L1 Token List

Expand Down
4 changes: 2 additions & 2 deletions src/lib/graph.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const apolloL2GatewaysRinkebyClient =
const apolloL2GatewaysClient =
'https://api.thegraph.com/subgraphs/name/fredlacs/layer2-token-gateway';

const appoloL2GatewaysGoerliRollupClient =
const apolloL2GatewaysGoerliRollupClient =
'https://api.thegraph.com/subgraphs/name/fredlacs/layer2-token-gateway-nitro-goerli';

const chaidIdToGraphClientUrl = (chainID: string) => {
Expand All @@ -18,7 +18,7 @@ const chaidIdToGraphClientUrl = (chainID: string) => {
case '421611':
return apolloL2GatewaysRinkebyClient;
case '421613':
return appoloL2GatewaysGoerliRollupClient;
return apolloL2GatewaysGoerliRollupClient;
default:
throw new Error('Unsupported chain');
}
Expand Down
5 changes: 3 additions & 2 deletions src/lib/instantiate_bridge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,20 @@ export const getNetworkConfig = async () => {

const l2Rpc = (() => {
if (networkID === 42161) return 'https://arb1.arbitrum.io/rpc';
else if (networkID === 421611) return 'https://rinkeby.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';
throw new Error('No L2 RPC detected');
})();
const arbProvider = new providers.JsonRpcProvider(l2Rpc);
const l2Network = await getL2Network(arbProvider);

const expectedEnv = (() => {
if (l2Network.partnerChainID === 1) return 'MAINNET_RPC';
else if (l2Network.partnerChainID === 4) return 'RINKEBY_RPC';
else if (l2Network.partnerChainID === 5) return 'GOERLI_RPC';
else if (l2Network.partnerChainID === 11155111) return 'SEPOLIA_RPC';
throw new Error('No L1 RPC detected');
})();
const l1Rpc = process.env[expectedEnv];
Expand Down
6 changes: 6 additions & 0 deletions src/lib/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ axiosRetry(axios, {
retries: 5,
retryCondition: () => true,
retryDelay: (retryCount) => 65_000 + retryCount * 10_000, // (milliseconds)
onRetry(retryCount, error) {
console.log(
`Request failed with ${error.code}. Retrying ${retryCount} times.`,
);
},
});

export const isNetwork = () => {
Expand All @@ -28,6 +33,7 @@ export const isNetwork = () => {
isArbOne: argv.l2NetworkID === 42161,
isNova: argv.l2NetworkID === 42170,
isGoerliRollup: argv.l2NetworkID === 421613,
isSepoliaRollup: argv.l2NetworkID === 421614,
};
};

Expand Down
21 changes: 17 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,15 @@
"@jridgewell/gen-mapping" "^0.1.0"
"@jridgewell/trace-mapping" "^0.3.9"

"@arbitrum/sdk@^3.0.0":
version "3.0.0"
resolved "https://registry.yarnpkg.com/@arbitrum/sdk/-/sdk-3.0.0.tgz#a5dc48a00cb8c6e230a2c696c0e880a7f80c637d"
integrity sha512-Mws5WAxxirp3vk8JH3vyQ5H6q1NNUIAAGEd9oEnQYDMyTBHLKU293GA3s9w4w6ZfIq/RZq8YCexhy4D1R+mQng==
"@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==
dependencies:
"@ethersproject/address" "^5.0.8"
"@ethersproject/bignumber" "^5.1.1"
"@ethersproject/bytes" "^5.0.8"
async-mutex "^0.4.0"
ethers "^5.1.0"

"@babel/code-frame@^7.0.0", "@babel/code-frame@^7.12.13", "@babel/code-frame@^7.16.0", "@babel/code-frame@^7.18.6":
Expand Down Expand Up @@ -1386,6 +1387,13 @@ ast-types-flow@^0.0.7:
resolved "https://registry.yarnpkg.com/ast-types-flow/-/ast-types-flow-0.0.7.tgz#f70b735c6bca1a5c9c22d982c3e39e7feba3bdad"
integrity sha512-eBvWn1lvIApYMhzQMsu9ciLfkBY499mFZlNqG+/9WR7PVlroQw0vG30cOQQbaKz3sCEc44TAOu2ykzqXSNnwag==

async-mutex@^0.4.0:
version "0.4.0"
resolved "https://registry.yarnpkg.com/async-mutex/-/async-mutex-0.4.0.tgz#ae8048cd4d04ace94347507504b3cf15e631c25f"
integrity sha512-eJFZ1YhRR8UN8eBLoNzcDPcy/jqjsg6I1AP+KvWQX80BqOSW1oJPJXDylPUEeMr2ZQvHgnQ//Lp6f3RQ1zI7HA==
dependencies:
tslib "^2.4.0"

asynckit@^0.4.0:
version "0.4.0"
resolved "https://registry.yarnpkg.com/asynckit/-/asynckit-0.4.0.tgz#c79ed97f7f34cb8f2ba1bc9790bcc366474b4b79"
Expand Down Expand Up @@ -4070,6 +4078,11 @@ tslib@^1.8.1:
resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.14.1.tgz#cf2d38bdc34a134bcaf1091c41f6619e2f672d00"
integrity sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==

tslib@^2.4.0:
version "2.6.2"
resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.6.2.tgz#703ac29425e7b37cd6fd456e92404d46d1f3e4ae"
integrity sha512-AEYxH93jGFPn/a2iVAwW87VuUIkR1FVUKB77NwMF7nBTDkDrrT/Hpt/IrCJ0QXhW27jTBDcf5ZY7w6RiqTMw2Q==

tsutils@^3.21.0:
version "3.21.0"
resolved "https://registry.yarnpkg.com/tsutils/-/tsutils-3.21.0.tgz#b48717d394cea6c1e096983eed58e9d61715b623"
Expand Down