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

Update list task #55

Merged
merged 3 commits into from
Dec 21, 2022
Merged
Show file tree
Hide file tree
Changes from all 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
9 changes: 6 additions & 3 deletions src/lib/token_list_gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ export const generateTokenList = async (
includeOldDataFields?: boolean;
sourceListURL?: string;
skipValidation?: boolean;
preserveListName?: boolean
}
) => {
if (options?.includeAllL1Tokens && options.includeUnbridgedL1Tokens) {
Expand Down Expand Up @@ -337,7 +338,7 @@ export const generateTokenList = async (
})();
const sourceListURL = getFormattedSourceURL(options?.sourceListURL);
const arbTokenList: ArbTokenList = {
name: listNameToArbifiedListName(name),
name: (options && options.preserveListName) ? name : listNameToArbifiedListName(name),
timestamp: new Date().toISOString(),
version,
tokens: arbifiedTokenList,
Expand Down Expand Up @@ -368,7 +369,7 @@ export const generateTokenList = async (

export const arbifyL1List = async (
pathOrUrl: string,
includeOldDataFields?: boolean
includeOldDataFields: boolean
): Promise<{
newList: ArbTokenList;
l1ListName: string;
Expand All @@ -393,7 +394,7 @@ export const arbifyL1List = async (
};
};

export const updateArbifiedList = async (pathOrUrl: string) => {
export const updateArbifiedList = async (pathOrUrl: string, includeOldDataFields: boolean) => {
const arbTokenList = await getTokenListObj(pathOrUrl);
removeInvalidTokensFromList(arbTokenList);
const path =
Expand All @@ -413,6 +414,8 @@ export const updateArbifiedList = async (pathOrUrl: string) => {
const newList = await generateTokenList(arbTokenList, prevArbTokenList, {
includeAllL1Tokens: true,
sourceListURL: isValidHttpUrl(pathOrUrl) ? pathOrUrl : undefined,
includeOldDataFields,
preserveListName: true
});

return {
Expand Down
5 changes: 3 additions & 2 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,17 @@ const main = async () => {

let tokenList: ArbTokenList;
let path: string;
const includeOldDataFields:boolean = !!args.includeOldDataFields

if (args.action === 'arbify') {
const { newList, l1ListName } = await arbifyL1List(
args.tokenList,
!!args.includeOldDataFields
includeOldDataFields
);
tokenList = newList;
path = getPath(l1ListName);
} else if (args.action === 'update') {
const { newList, path: _path } = await updateArbifiedList(args.tokenList);
const { newList, path: _path } = await updateArbifiedList(args.tokenList, includeOldDataFields);
tokenList = newList;
path = _path;
} else if (args.action === 'alltokenslist') {
Expand Down
2 changes: 2 additions & 0 deletions update_all
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ yarn fullList --l2NetworkID 42161
yarn arbify --l2NetworkID 42161 --tokenList https://gateway.ipfs.io/ipns/tokens.uniswap.org
yarn arbify --l2NetworkID 42161 --tokenList https://www.gemini.com/uniswap/manifest.json
yarn arbify --l2NetworkID 42161 --tokenList https://api.coinmarketcap.com/data-api/v3/uniswap/all.json
# update whitelist era list (for e.g. changed gateways)
yarn update --l2NetworkID 42161 --tokenList ./src/ArbTokenLists/arbed_arb_whitelist_era.json --includeOldDataFields true

# nova
# yarn fullList --l2NetworkID 42170
Expand Down