mirror of
https://github.com/Instadapp/trustwallet-assets.git
synced 2024-07-29 22:37:31 +00:00
[Internal] Cleanup empty pairs[] from Eth tokenlist (#13933)
* Cleanup empty pairs[] from Eth tokenlist * Small revert
This commit is contained in:
parent
69bb712494
commit
af967a8d91
File diff suppressed because it is too large
Load Diff
|
@ -268,7 +268,9 @@ function sort(list: List) {
|
|||
return t1.address.localeCompare(t2.address);
|
||||
});
|
||||
list.tokens.forEach(t => {
|
||||
t.pairs.sort((p1, p2) => p1.base.localeCompare(p2.base));
|
||||
if (t.pairs) {
|
||||
t.pairs.sort((p1, p2) => p1.base.localeCompare(p2.base));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -296,6 +298,14 @@ export function diffTokenlist(listOrig1: List, listOrig2: List): unknown {
|
|||
return diffs;
|
||||
}
|
||||
|
||||
function adjustTokenList(list: List) {
|
||||
list.tokens.forEach(t => {
|
||||
if (t.pairs.length == 0) {
|
||||
delete t.pairs;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
export async function rebuildTokenlist(chainName: string, pairs: [TokenItem, TokenItem][], listName: string, forceExcludeList: string[]): Promise<void> {
|
||||
// sanity check, prevent deletion of many pairs
|
||||
if (!pairs || pairs.length < 5) {
|
||||
|
@ -335,6 +345,8 @@ export async function rebuildTokenlist(chainName: string, pairs: [TokenItem, Tok
|
|||
await addPairIfNeeded(p[0], p[1], list);
|
||||
});
|
||||
console.log(`Tokenlist updated: ${list.tokens.length} tokens`);
|
||||
adjustTokenList(list);
|
||||
console.log(`Tokenlist adjusted: ${list.tokens.length} tokens`);
|
||||
|
||||
const newList = createTokensList(listName, list.tokens,
|
||||
"2021-01-29T01:02:03.000+00:00", // use constant here to prevent changing time every time
|
||||
|
|
Loading…
Reference in New Issue
Block a user