From 6cb0ebff5b2c7fcd3e69f5c2a713296408201e36 Mon Sep 17 00:00:00 2001 From: William O'Beirne Date: Fri, 1 Dec 2017 12:40:27 -0800 Subject: [PATCH] Fix EquivalentValue crash on invalid tokens (#511) --- common/actions/rates/actionPayloads.ts | 10 ++++++---- common/components/BalanceSidebar/EquivalentValues.tsx | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/common/actions/rates/actionPayloads.ts b/common/actions/rates/actionPayloads.ts index 7ba9d9cf..92e80412 100644 --- a/common/actions/rates/actionPayloads.ts +++ b/common/actions/rates/actionPayloads.ts @@ -36,10 +36,12 @@ export const fetchRates = (symbols: string[] = []): Promise => // to their respective rates via ETH. return symbols.reduce( (eqRates, sym) => { - eqRates[sym] = rateSymbols.reduce((symRates, rateSym) => { - symRates[rateSym] = 1 / rates[sym] * rates[rateSym]; - return symRates; - }, {}); + if (rates[sym]) { + eqRates[sym] = rateSymbols.reduce((symRates, rateSym) => { + symRates[rateSym] = 1 / rates[sym] * rates[rateSym]; + return symRates; + }, {}); + } return eqRates; }, { diff --git a/common/components/BalanceSidebar/EquivalentValues.tsx b/common/components/BalanceSidebar/EquivalentValues.tsx index 40162333..c822259a 100644 --- a/common/components/BalanceSidebar/EquivalentValues.tsx +++ b/common/components/BalanceSidebar/EquivalentValues.tsx @@ -110,7 +110,7 @@ export default class EquivalentValues extends React.Component { {tokenBalances && tokenBalances.map(tk => { - if (!tk.balance || tk.balance.isZero()) { + if (!tk.balance || tk.balance.isZero() || !rates[tk.symbol]) { return; } const sym = tk.symbol;