Fix EquivalentValue crash on invalid tokens (#511)

This commit is contained in:
William O'Beirne 2017-12-01 12:40:27 -08:00 committed by Daniel Ternyak
parent 4b3def2fce
commit 6cb0ebff5b
2 changed files with 7 additions and 5 deletions

View File

@ -36,10 +36,12 @@ export const fetchRates = (symbols: string[] = []): Promise<CCResponse> =>
// to their respective rates via ETH.
return symbols.reduce(
(eqRates, sym) => {
if (rates[sym]) {
eqRates[sym] = rateSymbols.reduce((symRates, rateSym) => {
symRates[rateSym] = 1 / rates[sym] * rates[rateSym];
return symRates;
}, {});
}
return eqRates;
},
{

View File

@ -110,7 +110,7 @@ export default class EquivalentValues extends React.Component<Props, CmpState> {
<option value="ETH">ETH</option>
{tokenBalances &&
tokenBalances.map(tk => {
if (!tk.balance || tk.balance.isZero()) {
if (!tk.balance || tk.balance.isZero() || !rates[tk.symbol]) {
return;
}
const sym = tk.symbol;