mirror of
https://github.com/Instadapp/trustwallet-assets.git
synced 2024-07-29 22:37:31 +00:00
[internal] Optimize BEP asset info retrieval from dex (rate limit) (#3091)
* Optimize BEP asset info retrieval from dex (rate limit). * Sync fix. Co-authored-by: Catenocrypt <catenocrypt@users.noreply.github.com>
This commit is contained in:
parent
6527b8c78d
commit
6276c67e36
|
@ -4237,6 +4237,7 @@
|
|||
"0xc6A18790d4D3988D28cc1E274E2c696602ea4343",
|
||||
"0xc6AbF3C09341741Ac6041B0B08195701bdFD460C",
|
||||
"0xC6D603A9Df53D1542552058c382bf115AACE70C7",
|
||||
"0xC6D76756Fec88A289B20091846b81C23997BFD00",
|
||||
"0xc6E2970cf8b1943fb58dB5b3c19CFc2ee146f376",
|
||||
"0xc719d010B63E5bbF2C0551872CD5316ED26AcD83",
|
||||
"0xC72ED4445B3fe9f0863106E344E241530d338906",
|
||||
|
|
|
@ -18,6 +18,7 @@ const binanceChain = "binance"
|
|||
const binanceUrlTokens2 = config.getConfig("binance_url_tokens2", "https://dex-atlantic.binance.org/api/v1/tokens?limit=1000");
|
||||
const binanceUrlTokens8 = config.getConfig("binance_url_tokens8", "https://dex-atlantic.binance.org/api/v1/mini/tokens?limit=1000");
|
||||
const binanceUrlTokenAssets = config.getConfig("binance_url_token_assets", "https://explorer.binance.org/api/v1/assets?page=1&rows=1000");
|
||||
var cachedAssets = [];
|
||||
|
||||
async function retrieveBep2AssetList(): Promise<any[]> {
|
||||
console.log(` Retrieving token asset infos from: ${binanceUrlTokenAssets}`);
|
||||
|
@ -26,13 +27,21 @@ async function retrieveBep2AssetList(): Promise<any[]> {
|
|||
return assetInfoList
|
||||
}
|
||||
|
||||
async function retrieveAssets(): Promise<any[]> {
|
||||
// cache results because of rate limit, used more than once
|
||||
if (cachedAssets.length == 0) {
|
||||
console.log(` Retrieving token infos (${binanceUrlTokens2}, ${binanceUrlTokens8})`);
|
||||
const bep2assets = await axios.get(binanceUrlTokens2);
|
||||
const bep8assets = await axios.get(binanceUrlTokens8);
|
||||
cachedAssets = bep2assets.data.concat(bep8assets.data);
|
||||
}
|
||||
console.log(` Using ${cachedAssets.length} assets`);
|
||||
return cachedAssets;
|
||||
}
|
||||
|
||||
export async function retrieveAssetSymbols(): Promise<string[]> {
|
||||
console.log(` Retrieving token infos (${binanceUrlTokens2}, ${binanceUrlTokens8})`);
|
||||
const bep2assets = await axios.get(binanceUrlTokens2);
|
||||
const bep8assets = await axios.get(binanceUrlTokens8);
|
||||
const symbols = bep2assets.data.map(({ symbol }) => symbol)
|
||||
.concat(bep8assets.data.map(({ symbol }) => symbol));
|
||||
console.log(` Retrieved ${symbols.length} symbols`);
|
||||
const assets = await retrieveAssets();
|
||||
const symbols = assets.map(({ symbol }) => symbol);
|
||||
return symbols;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user