1
0
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:
Kevin Serrano 2017-08-29 16:36:05 -07:00
parent 34b327caf0
commit 056276af02
No known key found for this signature in database
GPG Key ID: BF999DEFC7371BA1
4 changed files with 66 additions and 7 deletions

View File

@ -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) {

View File

@ -647,4 +647,4 @@ module.exports = class MetamaskController extends EventEmitter {
return Promise.resolve(rpcTarget)
})
}
}
}

View File

@ -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)
})
),
])

View 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"
]
}