Skip to content

Commit

Permalink
Update list task (#55)
Browse files Browse the repository at this point in the history
* fix listname generation

* update list take; add whitelist update to update_all
  • Loading branch information
DZGoldman authored Dec 21, 2022
1 parent 73e15fd commit 62b5444
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
9 changes: 6 additions & 3 deletions src/lib/token_list_gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ export const generateTokenList = async (
includeOldDataFields?: boolean;
sourceListURL?: string;
skipValidation?: boolean;
preserveListName?: boolean
}
) => {
if (options?.includeAllL1Tokens && options.includeUnbridgedL1Tokens) {
Expand Down Expand Up @@ -334,7 +335,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 @@ -365,7 +366,7 @@ export const generateTokenList = async (

export const arbifyL1List = async (
pathOrUrl: string,
includeOldDataFields?: boolean
includeOldDataFields: boolean
): Promise<{
newList: ArbTokenList;
l1ListName: string;
Expand All @@ -390,7 +391,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 @@ -410,6 +411,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

0 comments on commit 62b5444

Please sign in to comment.