aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEsteban MIno <efmino@uc.cl>2018-08-04 07:24:12 +0800
committerEsteban MIno <efmino@uc.cl>2018-08-04 07:24:12 +0800
commit9ac9f53a73357238ed2ee0ce57c65de592cfd968 (patch)
tree3ae3540c33a84dc5fc744aaee15fde6f76f2f6c6
parent12dd7a72323bf82d60e99502104e375864c0fbab (diff)
downloadtangerine-wallet-browser-9ac9f53a73357238ed2ee0ce57c65de592cfd968.tar
tangerine-wallet-browser-9ac9f53a73357238ed2ee0ce57c65de592cfd968.tar.gz
tangerine-wallet-browser-9ac9f53a73357238ed2ee0ce57c65de592cfd968.tar.bz2
tangerine-wallet-browser-9ac9f53a73357238ed2ee0ce57c65de592cfd968.tar.lz
tangerine-wallet-browser-9ac9f53a73357238ed2ee0ce57c65de592cfd968.tar.xz
tangerine-wallet-browser-9ac9f53a73357238ed2ee0ce57c65de592cfd968.tar.zst
tangerine-wallet-browser-9ac9f53a73357238ed2ee0ce57c65de592cfd968.zip
eth_watchToken working
-rw-r--r--app/scripts/controllers/preferences.js7
-rw-r--r--app/scripts/metamask-controller.js1
-rw-r--r--ui/app/actions.js24
-rw-r--r--ui/app/components/pages/confirm-add-token/confirm-add-token.component.js9
-rw-r--r--ui/app/components/pages/confirm-add-token/confirm-add-token.container.js3
-rw-r--r--ui/app/reducers/metamask.js1
6 files changed, 42 insertions, 3 deletions
diff --git a/app/scripts/controllers/preferences.js b/app/scripts/controllers/preferences.js
index 50f716852..521a68a66 100644
--- a/app/scripts/controllers/preferences.js
+++ b/app/scripts/controllers/preferences.js
@@ -211,6 +211,13 @@ class PreferencesController {
return selected
}
+ removeSuggestedTokens () {
+ return new Promise((resolve, reject) => {
+ this.store.updateState({ suggestedTokens: {} })
+ resolve()
+ })
+ }
+
/**
* Setter for the `selectedAddress` property
*
diff --git a/app/scripts/metamask-controller.js b/app/scripts/metamask-controller.js
index e843ec660..801363cb0 100644
--- a/app/scripts/metamask-controller.js
+++ b/app/scripts/metamask-controller.js
@@ -392,6 +392,7 @@ module.exports = class MetamaskController extends EventEmitter {
setSelectedAddress: nodeify(preferencesController.setSelectedAddress, preferencesController),
addToken: nodeify(preferencesController.addToken, preferencesController),
removeToken: nodeify(preferencesController.removeToken, preferencesController),
+ removeSuggestedTokens: nodeify(preferencesController.removeSuggestedTokens, preferencesController),
setCurrentAccountTab: nodeify(preferencesController.setCurrentAccountTab, preferencesController),
setAccountLabel: nodeify(preferencesController.setAccountLabel, preferencesController),
setFeatureFlag: nodeify(preferencesController.setFeatureFlag, preferencesController),
diff --git a/ui/app/actions.js b/ui/app/actions.js
index 7a8d9667d..c15dd05a5 100644
--- a/ui/app/actions.js
+++ b/ui/app/actions.js
@@ -226,6 +226,7 @@ var actions = {
addTokens,
removeToken,
updateTokens,
+ removeSuggestedTokens,
UPDATE_TOKENS: 'UPDATE_TOKENS',
setRpcTarget: setRpcTarget,
setProviderType: setProviderType,
@@ -1612,6 +1613,29 @@ function addTokens (tokens) {
}
}
+function removeSuggestedTokens () {
+ return (dispatch) => {
+ dispatch(actions.showLoadingIndication())
+ return new Promise((resolve, reject) => {
+ background.removeSuggestedTokens((err) => {
+ dispatch(actions.hideLoadingIndication())
+ if (err) {
+ dispatch(actions.displayWarning(err.message))
+ reject(err)
+ }
+ dispatch(actions.clearPendingTokens())
+ resolve()
+ })
+ })
+ }
+}
+
+function clearPendingTokens () {
+ return {
+ type: actions.CLEAR_PENDING_TOKENS,
+ }
+}
+
function updateTokens (newTokens) {
return {
type: actions.UPDATE_TOKENS,
diff --git a/ui/app/components/pages/confirm-add-token/confirm-add-token.component.js b/ui/app/components/pages/confirm-add-token/confirm-add-token.component.js
index 65d654b92..ad5264b30 100644
--- a/ui/app/components/pages/confirm-add-token/confirm-add-token.component.js
+++ b/ui/app/components/pages/confirm-add-token/confirm-add-token.component.js
@@ -15,6 +15,7 @@ export default class ConfirmAddToken extends Component {
clearPendingTokens: PropTypes.func,
addTokens: PropTypes.func,
pendingTokens: PropTypes.object,
+ removeSuggestedTokens: PropTypes.func,
}
componentDidMount () {
@@ -32,7 +33,7 @@ export default class ConfirmAddToken extends Component {
}
render () {
- const { history, addTokens, clearPendingTokens, pendingTokens } = this.props
+ const { history, addTokens, clearPendingTokens, pendingTokens, removeSuggestedTokens } = this.props
return (
<div className="page-container">
@@ -90,7 +91,11 @@ export default class ConfirmAddToken extends Component {
type="default"
large
className="page-container__footer-button"
- onClick={() => history.push(ADD_TOKEN_ROUTE)}
+ onClick={() => {
+ // TODO find the right pace to removeSuggestedTokens
+ removeSuggestedTokens()
+ history.push(ADD_TOKEN_ROUTE)
+ }}
>
{ this.context.t('back') }
</Button>
diff --git a/ui/app/components/pages/confirm-add-token/confirm-add-token.container.js b/ui/app/components/pages/confirm-add-token/confirm-add-token.container.js
index 500b406bb..47d7a105b 100644
--- a/ui/app/components/pages/confirm-add-token/confirm-add-token.container.js
+++ b/ui/app/components/pages/confirm-add-token/confirm-add-token.container.js
@@ -3,7 +3,7 @@ import ConfirmAddToken from './confirm-add-token.component'
const extend = require('xtend')
-const { addTokens, clearPendingTokens } = require('../../../actions')
+const { addTokens, clearPendingTokens, removeSuggestedTokens } = require('../../../actions')
const mapStateToProps = ({ metamask }) => {
const { pendingTokens, suggestedTokens } = metamask
@@ -18,6 +18,7 @@ const mapDispatchToProps = dispatch => {
return {
addTokens: tokens => dispatch(addTokens(tokens)),
clearPendingTokens: () => dispatch(clearPendingTokens()),
+ removeSuggestedTokens: () => dispatch(removeSuggestedTokens()),
}
}
diff --git a/ui/app/reducers/metamask.js b/ui/app/reducers/metamask.js
index 3f1d3394f..9e472bc6f 100644
--- a/ui/app/reducers/metamask.js
+++ b/ui/app/reducers/metamask.js
@@ -29,6 +29,7 @@ function reduceMetamask (state, action) {
tokenExchangeRates: {},
tokens: [],
pendingTokens: {},
+ suggestedTokens: {},
send: {
gasLimit: null,
gasPrice: null,