diff --git a/test/unit/balance-formatter-test.js b/test/unit/balance-formatter-test.js index bd0eb5008..52a442a00 100644 --- a/test/unit/balance-formatter-test.js +++ b/test/unit/balance-formatter-test.js @@ -1,13 +1,13 @@ const assert = require('assert') const currencyFormatter = require('currency-formatter') -const infuraConversion = require('../../ui/app/helpers/constants/infura-conversion.json') +const availableCurrencies = require('../../ui/app/helpers/constants/available-conversions.json') describe('currencyFormatting', function () { it('be able to format any infura currency', function (done) { const number = 10000 - infuraConversion.objects.forEach((conversion) => { - const code = conversion.quote.code.toUpperCase() + availableCurrencies.forEach((conversion) => { + const code = conversion.code.toUpperCase() const result = currencyFormatter.format(number, { code }) switch (code) { diff --git a/ui/app/helpers/constants/available-conversions.json b/ui/app/helpers/constants/available-conversions.json new file mode 100644 index 000000000..61722de39 --- /dev/null +++ b/ui/app/helpers/constants/available-conversions.json @@ -0,0 +1,238 @@ +[ + { + "code": "aud", + "name": "Australian Dollar" + }, + { + "code": "hkd", + "name": "Hong Kong Dollar" + }, + { + "code": "sgd", + "name": "Singapore Dollar" + }, + { + "code": "idr", + "name": "Indonesian Rupiah" + }, + { + "code": "php", + "name": "Philippine Peso" + }, + { + "code": "1st", + "name": "FirstBlood" + }, + { + "code": "adt", + "name": "adToken" + }, + { + "code": "adx", + "name": "AdEx" + }, + { + "code": "ant", + "name": "Aragon" + }, + { + "code": "bat", + "name": "Basic Attention Token" + }, + { + "code": "bnt", + "name": "Bancor" + }, + { + "code": "btc", + "name": "Bitcoin" + }, + { + "code": "cad", + "name": "Canadian Dollar" + }, + { + "code": "cfi", + "name": "Cofound.it" + }, + { + "code": "crb", + "name": "CreditBit" + }, + { + "code": "cvc", + "name": "Civic" + }, + { + "code": "dash", + "name": "Dash" + }, + { + "code": "dgd", + "name": "DigixDAO" + }, + { + "code": "etc", + "name": "Ethereum Classic" + }, + { + "code": "eur", + "name": "Euro" + }, + { + "code": "fun", + "name": "FunFair" + }, + { + "code": "gbp", + "name": "Pound Sterling" + }, + { + "code": "gno", + "name": "Gnosis" + }, + { + "code": "gnt", + "name": "Golem" + }, + { + "code": "gup", + "name": "Matchpool" + }, + { + "code": "hmq", + "name": "Humaniq" + }, + { + "code": "jpy", + "name": "Japanese Yen" + }, + { + "code": "lgd", + "name": "Legends Room" + }, + { + "code": "lsk", + "name": "Lisk" + }, + { + "code": "ltc", + "name": "Litecoin" + }, + { + "code": "lun", + "name": "Lunyr" + }, + { + "code": "mco", + "name": "Monaco" + }, + { + "code": "mtl", + "name": "Metal" + }, + { + "code": "myst", + "name": "Mysterium" + }, + { + "code": "nmr", + "name": "Numeraire" + }, + { + "code": "omg", + "name": "OmiseGO" + }, + { + "code": "pay", + "name": "TenX" + }, + { + "code": "ptoy", + "name": "Patientory" + }, + { + "code": "qrl", + "name": "Quantum-Resistant Ledger" + }, + { + "code": "qtum", + "name": "Qtum" + }, + { + "code": "rep", + "name": "Augur" + }, + { + "code": "rlc", + "name": "iEx.ec" + }, + { + "code": "rub", + "name": "Russian Ruble" + }, + { + "code": "sc", + "name": "Siacoin" + }, + { + "code": "sngls", + "name": "SingularDTV" + }, + { + "code": "snt", + "name": "Status" + }, + { + "code": "steem", + "name": "Steem" + }, + { + "code": "storj", + "name": "Storj" + }, + { + "code": "time", + "name": "ChronoBank" + }, + { + "code": "tkn", + "name": "TokenCard" + }, + { + "code": "trst", + "name": "WeTrust" + }, + { + "code": "uah", + "name": "Ukrainian Hryvnia" + }, + { + "code": "usd", + "name": "United States Dollar" + }, + { + "code": "wings", + "name": "Wings" + }, + { + "code": "xem", + "name": "NEM" + }, + { + "code": "xlm", + "name": "Stellar Lumen" + }, + { + "code": "xmr", + "name": "Monero" + }, + { + "code": "xrp", + "name": "Ripple" + }, + { + "code": "zec", + "name": "Zcash" + } +] diff --git a/ui/app/helpers/constants/infura-conversion.json b/ui/app/helpers/constants/infura-conversion.json deleted file mode 100644 index 9a96fe069..000000000 --- a/ui/app/helpers/constants/infura-conversion.json +++ /dev/null @@ -1,653 +0,0 @@ -{ - "objects": [ - { - "symbol": "ethaud", - "base": { - "code": "eth", - "name": "Ethereum" - }, - "quote": { - "code": "aud", - "name": "Australian Dollar" - } - }, - { - "symbol": "ethhkd", - "base": { - "code": "eth", - "name": "Ethereum" - }, - "quote": { - "code": "hkd", - "name": "Hong Kong Dollar" - } - }, - { - "symbol": "ethsgd", - "base": { - "code": "eth", - "name": "Ethereum" - }, - "quote": { - "code": "sgd", - "name": "Singapore Dollar" - } - }, - { - "symbol": "ethidr", - "base": { - "code": "eth", - "name": "Ethereum" - }, - "quote": { - "code": "idr", - "name": "Indonesian Rupiah" - } - }, - { - "symbol": "ethphp", - "base": { - "code": "eth", - "name": "Ethereum" - }, - "quote": { - "code": "php", - "name": "Philippine Peso" - } - }, - { - "symbol": "eth1st", - "base": { - "code": "eth", - "name": "Ethereum" - }, - "quote": { - "code": "1st", - "name": "FirstBlood" - } - }, - { - "symbol": "ethadt", - "base": { - "code": "eth", - "name": "Ethereum" - }, - "quote": { - "code": "adt", - "name": "adToken" - } - }, - { - "symbol": "ethadx", - "base": { - "code": "eth", - "name": "Ethereum" - }, - "quote": { - "code": "adx", - "name": "AdEx" - } - }, - { - "symbol": "ethant", - "base": { - "code": "eth", - "name": "Ethereum" - }, - "quote": { - "code": "ant", - "name": "Aragon" - } - }, - { - "symbol": "ethbat", - "base": { - "code": "eth", - "name": "Ethereum" - }, - "quote": { - "code": "bat", - "name": "Basic Attention Token" - } - }, - { - "symbol": "ethbnt", - "base": { - "code": "eth", - "name": "Ethereum" - }, - "quote": { - "code": "bnt", - "name": "Bancor" - } - }, - { - "symbol": "ethbtc", - "base": { - "code": "eth", - "name": "Ethereum" - }, - "quote": { - "code": "btc", - "name": "Bitcoin" - } - }, - { - "symbol": "ethcad", - "base": { - "code": "eth", - "name": "Ethereum" - }, - "quote": { - "code": "cad", - "name": "Canadian Dollar" - } - }, - { - "symbol": "ethcfi", - "base": { - "code": "eth", - "name": "Ethereum" - }, - "quote": { - "code": "cfi", - "name": "Cofound.it" - } - }, - { - "symbol": "ethcrb", - "base": { - "code": "eth", - "name": "Ethereum" - }, - "quote": { - "code": "crb", - "name": "CreditBit" - } - }, - { - "symbol": "ethcvc", - "base": { - "code": "eth", - "name": "Ethereum" - }, - "quote": { - "code": "cvc", - "name": "Civic" - } - }, - { - "symbol": "ethdash", - "base": { - "code": "eth", - "name": "Ethereum" - }, - "quote": { - "code": "dash", - "name": "Dash" - } - }, - { - "symbol": "ethdgd", - "base": { - "code": "eth", - "name": "Ethereum" - }, - "quote": { - "code": "dgd", - "name": "DigixDAO" - } - }, - { - "symbol": "ethetc", - "base": { - "code": "eth", - "name": "Ethereum" - }, - "quote": { - "code": "etc", - "name": "Ethereum Classic" - } - }, - { - "symbol": "etheur", - "base": { - "code": "eth", - "name": "Ethereum" - }, - "quote": { - "code": "eur", - "name": "Euro" - } - }, - { - "symbol": "ethfun", - "base": { - "code": "eth", - "name": "Ethereum" - }, - "quote": { - "code": "fun", - "name": "FunFair" - } - }, - { - "symbol": "ethgbp", - "base": { - "code": "eth", - "name": "Ethereum" - }, - "quote": { - "code": "gbp", - "name": "Pound Sterling" - } - }, - { - "symbol": "ethgno", - "base": { - "code": "eth", - "name": "Ethereum" - }, - "quote": { - "code": "gno", - "name": "Gnosis" - } - }, - { - "symbol": "ethgnt", - "base": { - "code": "eth", - "name": "Ethereum" - }, - "quote": { - "code": "gnt", - "name": "Golem" - } - }, - { - "symbol": "ethgup", - "base": { - "code": "eth", - "name": "Ethereum" - }, - "quote": { - "code": "gup", - "name": "Matchpool" - } - }, - { - "symbol": "ethhmq", - "base": { - "code": "eth", - "name": "Ethereum" - }, - "quote": { - "code": "hmq", - "name": "Humaniq" - } - }, - { - "symbol": "ethjpy", - "base": { - "code": "eth", - "name": "Ethereum" - }, - "quote": { - "code": "jpy", - "name": "Japanese Yen" - } - }, - { - "symbol": "ethlgd", - "base": { - "code": "eth", - "name": "Ethereum" - }, - "quote": { - "code": "lgd", - "name": "Legends Room" - } - }, - { - "symbol": "ethlsk", - "base": { - "code": "eth", - "name": "Ethereum" - }, - "quote": { - "code": "lsk", - "name": "Lisk" - } - }, - { - "symbol": "ethltc", - "base": { - "code": "eth", - "name": "Ethereum" - }, - "quote": { - "code": "ltc", - "name": "Litecoin" - } - }, - { - "symbol": "ethlun", - "base": { - "code": "eth", - "name": "Ethereum" - }, - "quote": { - "code": "lun", - "name": "Lunyr" - } - }, - { - "symbol": "ethmco", - "base": { - "code": "eth", - "name": "Ethereum" - }, - "quote": { - "code": "mco", - "name": "Monaco" - } - }, - { - "symbol": "ethmtl", - "base": { - "code": "eth", - "name": "Ethereum" - }, - "quote": { - "code": "mtl", - "name": "Metal" - } - }, - { - "symbol": "ethmyst", - "base": { - "code": "eth", - "name": "Ethereum" - }, - "quote": { - "code": "myst", - "name": "Mysterium" - } - }, - { - "symbol": "ethnmr", - "base": { - "code": "eth", - "name": "Ethereum" - }, - "quote": { - "code": "nmr", - "name": "Numeraire" - } - }, - { - "symbol": "ethomg", - "base": { - "code": "eth", - "name": "Ethereum" - }, - "quote": { - "code": "omg", - "name": "OmiseGO" - } - }, - { - "symbol": "ethpay", - "base": { - "code": "eth", - "name": "Ethereum" - }, - "quote": { - "code": "pay", - "name": "TenX" - } - }, - { - "symbol": "ethptoy", - "base": { - "code": "eth", - "name": "Ethereum" - }, - "quote": { - "code": "ptoy", - "name": "Patientory" - } - }, - { - "symbol": "ethqrl", - "base": { - "code": "eth", - "name": "Ethereum" - }, - "quote": { - "code": "qrl", - "name": "Quantum-Resistant Ledger" - } - }, - { - "symbol": "ethqtum", - "base": { - "code": "eth", - "name": "Ethereum" - }, - "quote": { - "code": "qtum", - "name": "Qtum" - } - }, - { - "symbol": "ethrep", - "base": { - "code": "eth", - "name": "Ethereum" - }, - "quote": { - "code": "rep", - "name": "Augur" - } - }, - { - "symbol": "ethrlc", - "base": { - "code": "eth", - "name": "Ethereum" - }, - "quote": { - "code": "rlc", - "name": "iEx.ec" - } - }, - { - "symbol": "ethrub", - "base": { - "code": "eth", - "name": "Ethereum" - }, - "quote": { - "code": "rub", - "name": "Russian Ruble" - } - }, - { - "symbol": "ethsc", - "base": { - "code": "eth", - "name": "Ethereum" - }, - "quote": { - "code": "sc", - "name": "Siacoin" - } - }, - { - "symbol": "ethsngls", - "base": { - "code": "eth", - "name": "Ethereum" - }, - "quote": { - "code": "sngls", - "name": "SingularDTV" - } - }, - { - "symbol": "ethsnt", - "base": { - "code": "eth", - "name": "Ethereum" - }, - "quote": { - "code": "snt", - "name": "Status" - } - }, - { - "symbol": "ethsteem", - "base": { - "code": "eth", - "name": "Ethereum" - }, - "quote": { - "code": "steem", - "name": "Steem" - } - }, - { - "symbol": "ethstorj", - "base": { - "code": "eth", - "name": "Ethereum" - }, - "quote": { - "code": "storj", - "name": "Storj" - } - }, - { - "symbol": "ethtime", - "base": { - "code": "eth", - "name": "Ethereum" - }, - "quote": { - "code": "time", - "name": "ChronoBank" - } - }, - { - "symbol": "ethtkn", - "base": { - "code": "eth", - "name": "Ethereum" - }, - "quote": { - "code": "tkn", - "name": "TokenCard" - } - }, - { - "symbol": "ethtrst", - "base": { - "code": "eth", - "name": "Ethereum" - }, - "quote": { - "code": "trst", - "name": "WeTrust" - } - }, - { - "symbol": "ethuah", - "base": { - "code": "eth", - "name": "Ethereum" - }, - "quote": { - "code": "uah", - "name": "Ukrainian Hryvnia" - } - }, - { - "symbol": "ethusd", - "base": { - "code": "eth", - "name": "Ethereum" - }, - "quote": { - "code": "usd", - "name": "United States Dollar" - } - }, - { - "symbol": "ethwings", - "base": { - "code": "eth", - "name": "Ethereum" - }, - "quote": { - "code": "wings", - "name": "Wings" - } - }, - { - "symbol": "ethxem", - "base": { - "code": "eth", - "name": "Ethereum" - }, - "quote": { - "code": "xem", - "name": "NEM" - } - }, - { - "symbol": "ethxlm", - "base": { - "code": "eth", - "name": "Ethereum" - }, - "quote": { - "code": "xlm", - "name": "Stellar Lumen" - } - }, - { - "symbol": "ethxmr", - "base": { - "code": "eth", - "name": "Ethereum" - }, - "quote": { - "code": "xmr", - "name": "Monero" - } - }, - { - "symbol": "ethxrp", - "base": { - "code": "eth", - "name": "Ethereum" - }, - "quote": { - "code": "xrp", - "name": "Ripple" - } - }, - { - "symbol": "ethzec", - "base": { - "code": "eth", - "name": "Ethereum" - }, - "quote": { - "code": "zec", - "name": "Zcash" - } - } - ] -} diff --git a/ui/app/pages/settings/settings-tab/settings-tab.component.js b/ui/app/pages/settings/settings-tab/settings-tab.component.js index d344e7dba..d8c5a7e21 100644 --- a/ui/app/pages/settings/settings-tab/settings-tab.component.js +++ b/ui/app/pages/settings/settings-tab/settings-tab.component.js @@ -1,15 +1,15 @@ import React, { PureComponent } from 'react' import PropTypes from 'prop-types' -import infuraCurrencies from '../../../helpers/constants/infura-conversion.json' +import availableCurrencies from '../../../helpers/constants/available-conversions' import SimpleDropdown from '../../../components/app/dropdowns/simple-dropdown' import ToggleButton from '../../../components/ui/toggle-button' import locales from '../../../../../app/_locales/index.json' -const sortedCurrencies = infuraCurrencies.objects.sort((a, b) => { - return a.quote.name.toLocaleLowerCase().localeCompare(b.quote.name.toLocaleLowerCase()) +const sortedCurrencies = availableCurrencies.sort((a, b) => { + return a.name.toLocaleLowerCase().localeCompare(b.name.toLocaleLowerCase()) }) -const infuraCurrencyOptions = sortedCurrencies.map(({ quote: { code, name } }) => { +const currencyOptions = sortedCurrencies.map(({ code, name }) => { return { displayValue: `${code.toUpperCase()} - ${name}`, key: code, @@ -61,7 +61,7 @@ export default class SettingsTab extends PureComponent {