Merge pull request #311 from status-im/feat/all-fiat

feat: add fiat currencies handled by status app
This commit is contained in:
Iuri Matias 2019-06-14 09:43:31 -04:00 committed by GitHub
commit 9dd239068e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 97 additions and 17 deletions

View File

@ -0,0 +1,85 @@
export const CURRENCY_DATA = [
{id: 'USD', label: 'United States Dollar', symbol: "$"},
{id: 'EUR', label: 'Euro', symbol: "€"},
{id: 'AED', label: 'Emirati Dirham', symbol: "د.إ"},
{id: 'AFN', label: 'Afghanistan Afghani', symbol: "؋"},
{id: 'ARS', label: 'Argentine Peso', symbol: "$"},
{id: 'AUD', label: 'Australian Dollar', symbol: "$"},
{id: 'BBD', label: 'Barbados Dollar', symbol: "$"},
{id: 'BDT', label: 'Bangladeshi Taka', symbol: " Tk"},
{id: 'BGN', label: 'Bulgarian Lev', symbol: "лв"},
{id: 'BHD', label: 'Bahraini Dinar', symbol: "BD"},
{id: 'BND', label: 'Brunei Darussalam Dollar', symbol: "$"},
{id: 'BOB', label: 'Bolivia Bolíviano', symbol: "$b"},
{id: 'BRL', label: 'Brazil Real', symbol: "R$"},
{id: 'BTN', label: 'Bhutanese Ngultrum', symbol: "Nu."},
{id: 'CAD', label: 'Canada Dollar', symbol: "$"},
{id: 'CHF', label: 'Switzerland Franc', symbol: "CHF"},
{id: 'CLP', label: 'Chile Peso', symbol: "$"},
{id: 'CNY', label: 'China Yuan Renminbi', symbol: "¥"},
{id: 'COP', label: 'Colombia Peso', symbol: "$"},
{id: 'CRC', label: 'Costa Rica Colon', symbol: "₡"},
{id: 'CZK', label: 'Czech Koruna', symbol: "Kč"},
{id: 'DKK', label: 'Denmark Krone', symbol: "kr"},
{id: 'DOP', label: 'Dominican Republic Peso', symbol: "RD$"},
{id: 'EGP', label: 'Egypt Pound', symbol: "£"},
{id: 'ETB', label: 'Ethiopian Birr', symbol: "Br"},
{id: 'GBP', label: 'British Pound', symbol: "£"},
{id: 'GEL', label: 'Georgian Lari', symbol: "₾"},
{id: 'GHS', label: 'Ghana Cedi', symbol: "¢"},
{id: 'HKD', label: 'Hong Kong Dollar', symbol: "$"},
{id: 'HRK', label: 'Croatia Kuna', symbol: "kn"},
{id: 'HUF', label: 'Hungary Forint', symbol: "Ft"},
{id: 'IDR', label: 'Indonesia Rupiah', symbol: "Rp"},
{id: 'ILS', label: 'Israel Shekel', symbol: "₪"},
{id: 'INR', label: 'India Rupee', symbol: "₹"},
{id: 'ISK', label: 'Iceland Krona', symbol: "kr"},
{id: 'JMD', label: 'Jamaica Dollar', symbol: "J$"},
{id: 'JPY', label: 'Japanese Yen', symbol: "¥"},
{id: 'KES', label: 'Kenyan Shilling', symbol: "KSh"},
{id: 'KRW', label: 'Korea (South) Won', symbol: "₩"},
{id: 'KWD', label: 'Kuwaiti Dinar', symbol: "د.ك"},
{id: 'KZT', label: 'Kazakhstan Tenge', symbol: "лв"},
{id: 'LKR', label: 'Sri Lanka Rupee', symbol: "₨"},
{id: 'MAD', label: 'Moroccan Dirham', symbol: "MAD"},
{id: 'MDL', label: 'Moldovan Leu', symbol: "MDL"},
{id: 'MUR', label: 'Mauritius Rupee', symbol: "₨"},
{id: 'MWK', label: 'Malawian Kwacha', symbol: "MK"},
{id: 'MXN', label: 'Mexico Peso', symbol: "$"},
{id: 'MYR', label: 'Malaysia Ringgit', symbol: "RM"},
{id: 'MZN', label: 'Mozambique Metical', symbol: "MT"},
{id: 'NAD', label: 'Namibia Dollar', symbol: "$"},
{id: 'NGN', label: 'Nigeria Naira', symbol: "₦"},
{id: 'NOK', label: 'Norway Krone', symbol: "kr"},
{id: 'NPR', label: 'Nepal Rupee', symbol: "₨"},
{id: 'NZD', label: 'New Zealand Dollar', symbol: "$"},
{id: 'OMR', label: 'Oman Rial', symbol: "﷼"},
{id: 'PEN', label: 'Peru Sol', symbol: "S/."},
{id: 'PGK', label: 'Papua New Guinean Kina', symbol: "K"},
{id: 'PHP', label: 'Philippines Peso', symbol: "₱"},
{id: 'PKR', label: 'Pakistan Rupee', symbol: "₨"},
{id: 'PLN', label: 'Poland Zloty', symbol: "zł"},
{id: 'PYG', label: 'Paraguay Guarani', symbol: "Gs"},
{id: 'QAR', label: 'Qatar Riyal', symbol: "﷼"},
{id: 'RON', label: 'Romania Leu', symbol: "lei"},
{id: 'RSD', label: 'Serbia Dinar', symbol: "Дин."},
{id: 'RUB', label: 'Russia Ruble', symbol: "₽"},
{id: 'SAR', label: 'Saudi Arabia Riya', symbol: "﷼"},
{id: 'SEK', label: 'Sweden Krona', symbol: "kr"},
{id: 'SGD', label: 'Singapore Dollar', symbol: "$"},
{id: 'THB', label: 'Thailand Baht', symbol: "฿"},
{id: 'TTD', label: 'Trinidad and Tobago Dollar', symbol: "TT$"},
{id: 'TWD', label: 'Taiwan New Dollar', symbol: "NT$"},
{id: 'TZS', label: 'Tanzanian Shilling', symbol: "TSh"},
{id: 'TRY', label: 'Turkish Lira', symbol: "₺"},
{id: 'UAH', label: 'Ukraine Hryvnia', symbol: "₴"},
{id: 'UGX', label: 'Ugandan Shilling', symbol: "USh"},
{id: 'UYU', label: 'Uruguay Peso', symbol: "$U"},
{id: 'VEF', label: 'Venezuela Bolívar', symbol: "Bs"},
{id: 'VND', label: 'Viet Nam Dong', symbol: "₫"},
{id: 'ZAR', label: 'South Africa Rand', symbol: "R"}
];
export default {
CURRENCY_DATA
};

View File

@ -2,7 +2,8 @@ import { fork, take, takeEvery, call, put, actionChannel, select } from 'redux-s
import cc from 'cryptocompare';
import { FETCH_PRICES, FETCH_PRICES_SUCCEEDED, FETCH_PRICES_FAILED, FETCH_EXCHANGE_RATE } from './constants';
import network from "../../features/network";
import merge from 'merge';
import {CURRENCY_DATA} from "../../constants/currencies";
export function *doFetchPrices(action) {
try {
@ -26,10 +27,15 @@ function *fetchAllTokenPrices() {
let tokens = yield select(network.selectors.getTokens); // <-- get the project
const symbols = Object.keys(tokens);
const fiat = ['USD', 'EUR', 'GBP', 'JPY', 'CNY', 'KRW']; // TODO: where will this list come from?
let data = {};
try {
const data = yield call(cc.priceMulti, symbols, fiat);
const size = 20;
for (let i = 0; i < CURRENCY_DATA.length; i += size) { // Query 20 currencies at a time
const fiat = CURRENCY_DATA.slice(i, i + size).map(x => x.id);
const prices = yield call(cc.priceMulti, symbols, fiat);
data = merge.recursive(true, prices, data);
}
yield put({type: FETCH_PRICES_SUCCEEDED, data});
} catch (error) {
yield put({type: FETCH_PRICES_FAILED, error});

View File

@ -6,18 +6,7 @@ import {connect} from 'react-redux';
import FiatSelectorForm from "./components/FiatSelectorForm";
import Loading from '../../../components/Loading';
import newSeller from "../../../features/newSeller";
// TODO: where will this FIAT currency list come from?
// cryptocompare does not identify which currencies are FIAT
// and it does not have a full list of FIAT currencies
const CURRENCY_DATA = [
{id: 'USD', label: 'United States Dollar - USD'},
{id: 'EUR', label: 'Euro - EUR'},
{id: 'GBP', label: 'Pound sterling - GBP'},
{id: 'JPY', label: 'Japanese Yen - JPY'},
{id: 'CNY', label: 'Chinese Yuan - CNY'},
{id: 'KRW', label: 'South Korean Won - KRW'}
];
import {CURRENCY_DATA} from "../../../constants/currencies";
class Currency extends Component {
constructor(props) {
@ -61,7 +50,7 @@ class Currency extends Component {
}
return (<FiatSelectorForm value={this.state.currency}
currencies={CURRENCY_DATA}
currencies={CURRENCY_DATA.map(x => ({id: x.id, label: `${x.id} - ${x.label}. ${x.symbol}`}))}
changeCurrency={this.changeCurrency}/>);
}
}