Skip to content

Commit

Permalink
Merge branch 'master' into all-tokens-list-gen
Browse files Browse the repository at this point in the history
  • Loading branch information
DZGoldman authored Dec 16, 2022
2 parents 1054d6e + edb9abb commit 73e15fd
Show file tree
Hide file tree
Showing 14 changed files with 123 additions and 2,842 deletions.
45 changes: 23 additions & 22 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,40 +4,41 @@ module.exports = {
es6: true,
node: true,
},
plugins: ["prettier"],
ignorePatterns: ['dist'],
plugins: ['prettier'],
extends: [
"eslint:recommended",
"plugin:prettier/recommended", // Enables eslint-plugin-prettier and displays prettier errors as ESLint errors. Make sure this is always the last configuration in the extends array.
'eslint:recommended',
'plugin:prettier/recommended', // Enables eslint-plugin-prettier and displays prettier errors as ESLint errors. Make sure this is always the last configuration in the extends array.
],
parserOptions: {
ecmaVersion: 2018, // Allows for the parsing of modern ECMAScript features
sourceType: "module", // Allows for the use of imports
sourceType: 'module', // Allows for the use of imports
},
rules: {
"prettier/prettier": "error",
"no-unused-vars": "warn",
"prefer-const": [2, { destructuring: "all" }],
"object-curly-spacing": ["error", "always"],
'prettier/prettier': 'error',
'no-unused-vars': 'warn',
'prefer-const': [2, { destructuring: 'all' }],
'object-curly-spacing': ['error', 'always'],
},
overrides: [
{
files: ["*.ts", "*.tsx"],
parser: "@typescript-eslint/parser",
files: ['*.ts', '*.tsx'],
parser: '@typescript-eslint/parser',
extends: [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"plugin:prettier/recommended",
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
'plugin:prettier/recommended',
],
plugins: ["@typescript-eslint", "prettier"],
plugins: ['@typescript-eslint', 'prettier'],
rules: {
"no-empty-pattern": "warn",
"no-useless-escape": "warn",
"prettier/prettier": ["error", { singleQuote: true }],
"@typescript-eslint/member-delimiter-style": ["off"],
"@typescript-eslint/no-explicit-any": ["warn"],
"@typescript-eslint/no-use-before-define": ["off"],
"@typescript-eslint/no-non-null-assertion": ["off"],
"@typescript-eslint/ban-ts-comment": ["warn"],
'no-empty-pattern': 'warn',
'no-useless-escape': 'warn',
'prettier/prettier': ['error', { singleQuote: true }],
'@typescript-eslint/member-delimiter-style': ['off'],
'@typescript-eslint/no-explicit-any': ['warn'],
'@typescript-eslint/no-use-before-define': ['off'],
'@typescript-eslint/no-non-null-assertion': ['off'],
'@typescript-eslint/ban-ts-comment': ['warn'],
},
},
],
Expand Down
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,10 @@ node_modules
ArbTokenLists
FullList
dist

# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
8 changes: 8 additions & 0 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"tabWidth": 2,
"useTabs": false,
"semi": true,
"singleQuote": true,
"bracketSpacing": true,
"arrowParens": "avoid"
}
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,13 @@
"start_server": "yarn ts-node server/app.ts"
},
"dependencies": {
"@arbitrum/sdk": "^2.0.13",
"@arbitrum/sdk": "^3.0.0",
"@uniswap/token-lists": "^1.0.0-beta.30",
"ajv": "^8.6.3",
"ajv-formats": "^2.1.1",
"axios": "^0.23.0",
"better-ajv-errors": "^1.1.2",
"dotenv": "^16.0.3",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-prettier": "^4.0.0",
"express": "^4.17.1",
Expand Down
6 changes: 3 additions & 3 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ From root:
2. In `.env`, set `MAINNET_RPC` var (i.e., set infura key or use different endpoint)
3. `yarn install`

### Arbify an L1 Token Lost
### Arbify an L1 Token List

yarn arbify --tokenList https://gateway.ipfs.io/ipns/tokens.uniswap.org --l2NetworkID 42161
`yarn arbify --tokenList https://gateway.ipfs.io/ipns/tokens.uniswap.org --l2NetworkID 42161`

Note that a local list can also be used, i.e.:

yarn arbify --tokenList ./src/SourceLists/my_l1_list.json --l2NetworkID 42161
`yarn arbify --tokenList ./src/SourceLists/my_l1_list.json --l2NetworkID 42161`

### Generate Full List

Expand Down
16 changes: 8 additions & 8 deletions src/PermitTokens/permitSignature.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ async function getPermitSig(
) {
// TODO: check that error is that function instead available (differentiate network fails)
const [nonce, name, version, chainId] = await Promise.all([
optional?.nonce ?? token.nonces(wallet.address).catch((err: Error) => 0),
optional?.name ?? token.name().catch((err: Error) => ''),
optional?.nonce ?? token.nonces(wallet.address).catch(() => 0),
optional?.name ?? token.name().catch(() => ''),
optional?.version ?? '1',
optional?.chainId ?? wallet.getChainId(),
]);
Expand Down Expand Up @@ -67,8 +67,8 @@ async function getPermitSigNoVersion(
) {
// TODO: check that error is that function instead available (differentiate network fails)
const [nonce, name, chainId] = await Promise.all([
optional?.nonce ?? token.nonces(wallet.address).catch((err: Error) => 0),
optional?.name ?? token.name().catch((err: Error) => ''),
optional?.nonce ?? token.nonces(wallet.address).catch(() => 0),
optional?.name ?? token.name().catch(() => ''),
optional?.chainId ?? wallet.getChainId(),
]);

Expand Down Expand Up @@ -109,8 +109,8 @@ async function getDaiLikePermitSignature(
): Promise<[string, number]> {
// TODO: check that error is that function instead available (differentiate network fails)
const [nonce, name, chainId] = await Promise.all([
optional?.nonce ?? token.nonces(wallet.address).catch((err: Error) => 0),
optional?.name ?? token.name().catch((err: Error) => ''),
optional?.nonce ?? token.nonces(wallet.address).catch(() => 0),
optional?.name ?? token.name().catch(() => ''),
optional?.chainId ?? wallet.getChainId(),
]);

Expand Down Expand Up @@ -286,7 +286,7 @@ export const addPermitTags = async (
isL1Mainnet ? 'tryAggregateGasRation' : 'tryAggregate'
](
false,
chunk.map((curr) => ({
chunk.map(curr => ({
target: curr.target,
callData: curr.callData,
}))
Expand All @@ -310,7 +310,7 @@ export const addPermitTags = async (
const originalIndex = calls[i].tokenIndex;
// add to existing token lists w tags for all tokens (permit or no permit)
if (!permitTokenInfo[originalIndex].tags)
(permitTokenInfo[originalIndex].tags as any) = [];
(permitTokenInfo[originalIndex].tags as string[]) = [];
permitTokenInfo[originalIndex].tags!.push(tag);
}
};
Expand Down
6 changes: 3 additions & 3 deletions src/lib/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ export const l2ToL1GatewayAddresses: L2ToL1GatewayAddresses =
'0xf9F2e89c8347BD96742Cc07095dee490e64301d6':
'0x6e244cD02BBB8a6dbd7F626f05B2ef82151Ab502',

// 421613 graph gateway:
'0xef2757855d2802bA53733901F90C91645973f743':
// 421613 graph gateway:
'0xef2757855d2802bA53733901F90C91645973f743':
'0xc82fF7b51c3e593D709BA3dE1b3a0d233D1DEca1',
});

Expand Down Expand Up @@ -91,7 +91,7 @@ export const excludeList = [
'0x106538cc16f938776c7c180186975bca23875287', // remove once bridged (basv2)
'0xB4A3B0Faf0Ab53df58001804DdA5Bfc6a3D59008', // spera
// "0x960b236a07cf122663c4303350609a66a7b288c0", //aragon old
].map((s) => s.toLowerCase());
].map(s => s.toLowerCase());

export const SEVEN_DAYS_IN_SECONDS = 7 * 24 * 60 * 60;

Expand Down
16 changes: 8 additions & 8 deletions src/lib/graph.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const isGraphTokenResult = (obj: any) => {
const expectedKeys = ['joinTableEntry', 'l1TokenAddr'];
const actualKeys = new Set(Object.keys(obj));

if (!expectedKeys.every((key) => actualKeys.has(key))) {
if (!expectedKeys.every(key => actualKeys.has(key))) {
throw new Error('Graph result: missing top level key');
}
const joinTableEntry = obj.joinTableEntry[0];
Expand Down Expand Up @@ -63,16 +63,16 @@ export const getTokens = async (
if (tokenList.length > 500) {
const allTokens = await getAllTokens(networkID);
const allTokenAddresses = new Set(
allTokens.map((token) => token.l1TokenAddr.toLowerCase())
allTokens.map(token => token.l1TokenAddr.toLowerCase())
);
tokenList = tokenList.filter((token) =>
tokenList = tokenList.filter(token =>
allTokenAddresses.has(token.addr.toLowerCase())
);
if (tokenList.length > 500)
throw new Error('Too many tokens for graph query');
}
const formattedAddresses = tokenList
.map((token) => `"${token.addr}"`.toLowerCase())
.map(token => `"${token.addr}"`.toLowerCase())
.join(',');
const blockNumber = graphGatewayBlockNumField(_networkID);
const query = gql`
Expand Down Expand Up @@ -100,10 +100,10 @@ export const getTokens = async (
`;

const { tokens } = (await request(clientUrl, query)) as GraphTokensResult;
tokens.map((token) => isGraphTokenResult(token));
tokens.map(token => isGraphTokenResult(token));

return tokens.filter(
(token) => !excludeList.includes(token.l1TokenAddr.toLowerCase())
token => !excludeList.includes(token.l1TokenAddr.toLowerCase())
);
};

Expand Down Expand Up @@ -137,12 +137,12 @@ export const getAllTokens = async (
`;

const { tokens } = (await request(clientUrl, query)) as GraphTokensResult;
const res = tokens.map((token) => {
const res = tokens.map(token => {
isGraphTokenResult(token);
return { ...token };
});

return res.filter(
(token) => !excludeList.includes(token.l1TokenAddr.toLowerCase())
token => !excludeList.includes(token.l1TokenAddr.toLowerCase())
);
};
3 changes: 1 addition & 2 deletions src/lib/instantiate_bridge.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { providers, Wallet, VoidSigner } from 'ethers';
import { providers } from 'ethers';
import args from './getClargs';
import dotenv from 'dotenv';
import { getL2Network, MultiCaller } from '@arbitrum/sdk';
Expand Down Expand Up @@ -36,7 +36,6 @@ export const getNetworkConfig = async () => {

return {
l1: {
// network: l1Network,
provider: ethProvider,
multiCaller: l1MultiCaller,
},
Expand Down
Loading

0 comments on commit 73e15fd

Please sign in to comment.