mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
integrate infura currency
This commit is contained in:
parent
34b327caf0
commit
056276af02
@ -8,7 +8,7 @@ class CurrencyController {
|
||||
|
||||
constructor (opts = {}) {
|
||||
const initState = extend({
|
||||
currentCurrency: 'USD',
|
||||
currentCurrency: 'ethusd',
|
||||
conversionRate: 0,
|
||||
conversionDate: 'N/A',
|
||||
}, opts.initState)
|
||||
@ -45,10 +45,10 @@ class CurrencyController {
|
||||
|
||||
updateConversionRate () {
|
||||
const currentCurrency = this.getCurrentCurrency()
|
||||
return fetch(`https://api.cryptonator.com/api/ticker/eth-${currentCurrency}`)
|
||||
return fetch(`https://api.infura.io/v1/ticker/${currentCurrency}`)
|
||||
.then(response => response.json())
|
||||
.then((parsedResponse) => {
|
||||
this.setConversionRate(Number(parsedResponse.ticker.price))
|
||||
this.setConversionRate(Number(parsedResponse.bid))
|
||||
this.setConversionDate(Number(parsedResponse.timestamp))
|
||||
}).catch((err) => {
|
||||
if (err) {
|
||||
|
@ -647,4 +647,4 @@ module.exports = class MetamaskController extends EventEmitter {
|
||||
return Promise.resolve(rpcTarget)
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3,7 +3,7 @@ const Component = require('react').Component
|
||||
const h = require('react-hyperscript')
|
||||
const connect = require('react-redux').connect
|
||||
const actions = require('./actions')
|
||||
const currencies = require('./conversion.json').rows
|
||||
const infuraCurrencies = require('./infura-conversion.json').symbols
|
||||
const validUrl = require('valid-url')
|
||||
const copyToClipboard = require('copy-to-clipboard')
|
||||
|
||||
@ -166,8 +166,8 @@ function currentConversionInformation (metamaskState, state) {
|
||||
state.dispatch(actions.setCurrentCurrency(newCurrency))
|
||||
},
|
||||
defaultValue: currentCurrency,
|
||||
}, currencies.map((currency) => {
|
||||
return h('option', {key: currency.code, value: currency.code}, `${currency.code} - ${currency.name}`)
|
||||
}, infuraCurrencies.map((currency) => {
|
||||
return h('option', {key: currency, value: currency}, currency)
|
||||
})
|
||||
),
|
||||
])
|
||||
|
59
ui/app/infura-conversion.json
Normal file
59
ui/app/infura-conversion.json
Normal file
@ -0,0 +1,59 @@
|
||||
{
|
||||
"symbols": [
|
||||
"eth1st",
|
||||
"ethadt",
|
||||
"ethadx",
|
||||
"ethant",
|
||||
"ethbat",
|
||||
"ethbnt",
|
||||
"ethbtc",
|
||||
"ethcad",
|
||||
"ethcfi",
|
||||
"ethcrb",
|
||||
"ethcvc",
|
||||
"ethdash",
|
||||
"ethdgd",
|
||||
"ethetc",
|
||||
"etheur",
|
||||
"ethfun",
|
||||
"ethgbp",
|
||||
"ethgno",
|
||||
"ethgnt",
|
||||
"ethgup",
|
||||
"ethhmq",
|
||||
"ethjpy",
|
||||
"ethlgd",
|
||||
"ethlsk",
|
||||
"ethltc",
|
||||
"ethlun",
|
||||
"ethmco",
|
||||
"ethmtl",
|
||||
"ethmyst",
|
||||
"ethnmr",
|
||||
"ethomg",
|
||||
"ethpay",
|
||||
"ethptoy",
|
||||
"ethqrl",
|
||||
"ethqtum",
|
||||
"ethrep",
|
||||
"ethrlc",
|
||||
"ethrub",
|
||||
"ethsc",
|
||||
"ethsngls",
|
||||
"ethsnt",
|
||||
"ethsteem",
|
||||
"ethstorj",
|
||||
"ethtime",
|
||||
"ethtkn",
|
||||
"ethtrst",
|
||||
"ethuah",
|
||||
"ethusd",
|
||||
"ethwings",
|
||||
"ethxbt",
|
||||
"ethxem",
|
||||
"ethxlm",
|
||||
"ethxmr",
|
||||
"ethxrp",
|
||||
"ethzec"
|
||||
]
|
||||
}
|
Loading…
Reference in New Issue
Block a user