Skip to content

Commit b20b139

Browse files
authored
wip change key notation object in coinmarketcap api (#436)
2 parents 0ae6421 + 9e78e7b commit b20b139

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

web3/wallets.js

+11-4
Original file line numberDiff line numberDiff line change
@@ -669,6 +669,7 @@ exports.getPrices = async () => {
669669
rp.request(options2),
670670
])
671671
} catch (error) {
672+
console.log({ error })
672673
throw new Error('Error fetching prices')
673674
}
674675

@@ -774,7 +775,6 @@ exports.getPrices = async () => {
774775
urls: '',
775776
network: '',
776777
}
777-
delete finalMap[token.id].symbol
778778
})
779779

780780
const networksContract = await getNetworkByToken(idcrypto.join(','))
@@ -807,10 +807,17 @@ exports.getPrices = async () => {
807807
finalMap[token.symbol].decimals = token.platform.decimals
808808
}
809809
}
810-
prices = { data: finalMap, date: Date.now() }
810+
let newCryptoPrices = {}
811+
for (const key in finalMap) {
812+
if (finalMap.hasOwnProperty(key)) {
813+
const crypto = finalMap[key]
814+
const symbol = crypto.symbol
815+
newCryptoPrices[symbol] = crypto
816+
}
817+
}
818+
prices = { data: newCryptoPrices, date: Date.now() }
811819
cache.put('prices', prices)
812-
813-
return finalMap
820+
return newCryptoPrices
814821
}
815822
} catch (err) {
816823
throw new Error('Error fetching prices ')

0 commit comments

Comments
 (0)