eth_watchToken working

feature/default_network_editable
Esteban MIno 6 years ago
parent 12dd7a7232
commit 9ac9f53a73
  1. 7
      app/scripts/controllers/preferences.js
  2. 1
      app/scripts/metamask-controller.js
  3. 24
      ui/app/actions.js
  4. 9
      ui/app/components/pages/confirm-add-token/confirm-add-token.component.js
  5. 3
      ui/app/components/pages/confirm-add-token/confirm-add-token.container.js
  6. 1
      ui/app/reducers/metamask.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
*

@ -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),

@ -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,

@ -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>

@ -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()),
}
}

@ -29,6 +29,7 @@ function reduceMetamask (state, action) {
tokenExchangeRates: {},
tokens: [],
pendingTokens: {},
suggestedTokens: {},
send: {
gasLimit: null,
gasPrice: null,

Loading…
Cancel
Save