Skip to content

Commit

Permalink
wip change key notation object in coinmarketcap api (#436)
Browse files Browse the repository at this point in the history
  • Loading branch information
hichri-louay committed Mar 27, 2024
2 parents 0ae6421 + 9e78e7b commit b20b139
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions web3/wallets.js
Expand Up @@ -669,6 +669,7 @@ exports.getPrices = async () => {
rp.request(options2),
])
} catch (error) {
console.log({ error })
throw new Error('Error fetching prices')
}

Expand Down Expand Up @@ -774,7 +775,6 @@ exports.getPrices = async () => {
urls: '',
network: '',
}
delete finalMap[token.id].symbol
})

const networksContract = await getNetworkByToken(idcrypto.join(','))
Expand Down Expand Up @@ -807,10 +807,17 @@ exports.getPrices = async () => {
finalMap[token.symbol].decimals = token.platform.decimals
}
}
prices = { data: finalMap, date: Date.now() }
let newCryptoPrices = {}
for (const key in finalMap) {
if (finalMap.hasOwnProperty(key)) {
const crypto = finalMap[key]
const symbol = crypto.symbol
newCryptoPrices[symbol] = crypto
}
}
prices = { data: newCryptoPrices, date: Date.now() }
cache.put('prices', prices)

return finalMap
return newCryptoPrices
}
} catch (err) {
throw new Error('Error fetching prices ')
Expand Down

0 comments on commit b20b139

Please sign in to comment.