From 491b9cddc5fe1a7d0899d29c9a53aa71f04b9b28 Mon Sep 17 00:00:00 2001 From: Kevin Serrano Date: Thu, 21 Jul 2016 09:30:58 -0700 Subject: [PATCH] Add fiat actions to metamask controllere and actions. --- app/scripts/metamask-controller.js | 10 ++++++++++ ui/app/actions.js | 14 ++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/app/scripts/metamask-controller.js b/app/scripts/metamask-controller.js index 63970799d..bcf5203fe 100644 --- a/app/scripts/metamask-controller.js +++ b/app/scripts/metamask-controller.js @@ -39,6 +39,7 @@ module.exports = class MetamaskController { setProviderType: this.setProviderType.bind(this), useEtherscanProvider: this.useEtherscanProvider.bind(this), agreeToDisclaimer: this.agreeToDisclaimer.bind(this), + setCurrentFiat: this.setCurrentFiat.bind(this), // forward directly to idStore createNewVault: idStore.createNewVault.bind(idStore), recoverFromSeed: idStore.recoverFromSeed.bind(idStore), @@ -236,6 +237,15 @@ module.exports = class MetamaskController { } } + setCurrentFiat (fiat, cb) { + try { + this.configManager.setCurrentFiat(fiat) + this.configManager.setConversionRate() + } catch (e) { + cb(e) + } + } + // called from popup setRpcTarget (rpcTarget) { this.configManager.setRpcTarget(rpcTarget) diff --git a/ui/app/actions.js b/ui/app/actions.js index 3e0fe55c0..c9a5401d3 100644 --- a/ui/app/actions.js +++ b/ui/app/actions.js @@ -55,6 +55,8 @@ var actions = { SHOW_CONF_MSG_PAGE: 'SHOW_CONF_MSG_PAGE', REVEAL_ACCOUNT: 'REVEAL_ACCOUNT', revealAccount: revealAccount, + SET_CURRENT_FIAT: 'SET_CURRENT_FIAT', + setCurrentFiat: setCurrentFiat, // account detail screen SHOW_SEND_PAGE: 'SHOW_SEND_PAGE', showSendPage: showSendPage, @@ -207,6 +209,18 @@ function revealAccount () { } } +function setCurrentFiat (fiat) { + return (dispatch) => { + dispatch(this.showLoadingIndication()) + _accountManager.setCurrentFiat(fiat, (err) => { + dispatch(this.hideLoadingIndication()) + dispatch({ + type: this.SET_CURRENT_FIAT, + }) + }) + } +} + function signMsg (msgData) { return (dispatch) => { dispatch(actions.showLoadingIndication())