aboutsummaryrefslogtreecommitdiffstats
path: root/ui/app/actions.js
diff options
context:
space:
mode:
authorBruno Barbieri <bruno.barbieri@consensys.net>2018-08-29 03:33:42 +0800
committerGitHub <noreply@github.com>2018-08-29 03:33:42 +0800
commit4560df6e739b97caf95ef5bc5bc93f91e8c890bb (patch)
tree76984504e65b06ae15633d721fedc7ddd5b0cca7 /ui/app/actions.js
parent0259eb02140fec1db9861506a6ff7890911af652 (diff)
parente743f44150d4c09908d24945de5a281e15e8469d (diff)
downloadtangerine-wallet-browser-4560df6e739b97caf95ef5bc5bc93f91e8c890bb.tar
tangerine-wallet-browser-4560df6e739b97caf95ef5bc5bc93f91e8c890bb.tar.gz
tangerine-wallet-browser-4560df6e739b97caf95ef5bc5bc93f91e8c890bb.tar.bz2
tangerine-wallet-browser-4560df6e739b97caf95ef5bc5bc93f91e8c890bb.tar.lz
tangerine-wallet-browser-4560df6e739b97caf95ef5bc5bc93f91e8c890bb.tar.xz
tangerine-wallet-browser-4560df6e739b97caf95ef5bc5bc93f91e8c890bb.tar.zst
tangerine-wallet-browser-4560df6e739b97caf95ef5bc5bc93f91e8c890bb.zip
Merge pull request #4606 from MetaMask/WatchTokenFeature
Add metamask_watchAsset
Diffstat (limited to 'ui/app/actions.js')
-rw-r--r--ui/app/actions.js47
1 files changed, 39 insertions, 8 deletions
diff --git a/ui/app/actions.js b/ui/app/actions.js
index 6bcc64e17..870ba42be 100644
--- a/ui/app/actions.js
+++ b/ui/app/actions.js
@@ -227,11 +227,14 @@ var actions = {
SET_PROVIDER_TYPE: 'SET_PROVIDER_TYPE',
showConfigPage,
SHOW_ADD_TOKEN_PAGE: 'SHOW_ADD_TOKEN_PAGE',
+ SHOW_ADD_SUGGESTED_TOKEN_PAGE: 'SHOW_ADD_SUGGESTED_TOKEN_PAGE',
showAddTokenPage,
+ showAddSuggestedTokenPage,
addToken,
addTokens,
removeToken,
updateTokens,
+ removeSuggestedTokens,
UPDATE_TOKENS: 'UPDATE_TOKENS',
setRpcTarget: setRpcTarget,
setProviderType: setProviderType,
@@ -1589,11 +1592,18 @@ function showAddTokenPage (transitionForward = true) {
}
}
-function addToken (address, symbol, decimals) {
+function showAddSuggestedTokenPage (transitionForward = true) {
+ return {
+ type: actions.SHOW_ADD_SUGGESTED_TOKEN_PAGE,
+ value: transitionForward,
+ }
+}
+
+function addToken (address, symbol, decimals, image) {
return (dispatch) => {
dispatch(actions.showLoadingIndication())
return new Promise((resolve, reject) => {
- background.addToken(address, symbol, decimals, (err, tokens) => {
+ background.addToken(address, symbol, decimals, image, (err, tokens) => {
dispatch(actions.hideLoadingIndication())
if (err) {
dispatch(actions.displayWarning(err.message))
@@ -1643,6 +1653,27 @@ function addTokens (tokens) {
}
}
+function removeSuggestedTokens () {
+ return (dispatch) => {
+ dispatch(actions.showLoadingIndication())
+ return new Promise((resolve, reject) => {
+ background.removeSuggestedTokens((err, suggestedTokens) => {
+ dispatch(actions.hideLoadingIndication())
+ if (err) {
+ dispatch(actions.displayWarning(err.message))
+ }
+ dispatch(actions.clearPendingTokens())
+ if (global.METAMASK_UI_TYPE === ENVIRONMENT_TYPE_NOTIFICATION) {
+ return global.platform.closeCurrentWindow()
+ }
+ resolve(suggestedTokens)
+ })
+ })
+ .then(() => updateMetamaskStateFromBackground())
+ .then(suggestedTokens => dispatch(actions.updateMetamaskState({...suggestedTokens})))
+ }
+}
+
function updateTokens (newTokens) {
return {
type: actions.UPDATE_TOKENS,
@@ -1650,6 +1681,12 @@ function updateTokens (newTokens) {
}
}
+function clearPendingTokens () {
+ return {
+ type: actions.CLEAR_PENDING_TOKENS,
+ }
+}
+
function goBackToInitView () {
return {
type: actions.BACK_TO_INIT_MENU,
@@ -2310,9 +2347,3 @@ function setPendingTokens (pendingTokens) {
payload: tokens,
}
}
-
-function clearPendingTokens () {
- return {
- type: actions.CLEAR_PENDING_TOKENS,
- }
-}