diff options
Fetch token prices based on contract address
Diffstat (limited to 'ui/app/reducers')
-rw-r--r-- | ui/app/reducers/metamask.js | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/ui/app/reducers/metamask.js b/ui/app/reducers/metamask.js index 6d0a5bb10..d6b6de3b0 100644 --- a/ui/app/reducers/metamask.js +++ b/ui/app/reducers/metamask.js @@ -24,6 +24,7 @@ function reduceMetamask (state, action) { frequentRpcList: [], addressBook: [], selectedTokenAddress: null, + contractExchangeRates: {}, tokenExchangeRates: {}, tokens: [], send: { @@ -176,14 +177,22 @@ function reduceMetamask (state, action) { conversionDate: action.value.conversionDate, }) - case actions.UPDATE_TOKEN_EXCHANGE_RATE: - const { payload: { pair, marketinfo } } = action - return extend(metamaskState, { - tokenExchangeRates: { - ...metamaskState.tokenExchangeRates, - [pair]: marketinfo, + case actions.UPDATE_CONTRACT_EXCHANGE_RATES: + const { payload: { newExchangeRates } } = action + return { + ...metamaskState, + contractExchangeRates: newExchangeRates, + } + + case actions.UPDATE_CONTRACT_EXCHANGE_RATE: + const { payload: { address, rate } } = action + return { + ...metamaskState, + contractExchangeRates: { + ...metamaskState.contractExchangeRates, + [address]: rate, }, - }) + } case actions.UPDATE_TOKENS: return extend(metamaskState, { |