aboutsummaryrefslogtreecommitdiffstats
path: root/ui/app/actions.js
diff options
context:
space:
mode:
Diffstat (limited to 'ui/app/actions.js')
-rw-r--r--ui/app/actions.js59
1 files changed, 45 insertions, 14 deletions
diff --git a/ui/app/actions.js b/ui/app/actions.js
index 2d238b2f8..649f740e9 100644
--- a/ui/app/actions.js
+++ b/ui/app/actions.js
@@ -124,8 +124,8 @@ var actions = {
SHOW_PRIVATE_KEY: 'SHOW_PRIVATE_KEY',
showPrivateKey: showPrivateKey,
exportAccountComplete,
- SAVE_ACCOUNT_LABEL: 'SAVE_ACCOUNT_LABEL',
- saveAccountLabel: saveAccountLabel,
+ SET_ACCOUNT_LABEL: 'SET_ACCOUNT_LABEL',
+ setAccountLabel,
// tx conf screen
COMPLETED_TX: 'COMPLETED_TX',
TRANSACTION_ERROR: 'TRANSACTION_ERROR',
@@ -275,6 +275,10 @@ var actions = {
UPDATE_NETWORK_ENDPOINT_TYPE: 'UPDATE_NETWORK_ENDPOINT_TYPE',
retryTransaction,
+ SET_PENDING_TOKENS: 'SET_PENDING_TOKENS',
+ CLEAR_PENDING_TOKENS: 'CLEAR_PENDING_TOKENS',
+ setPendingTokens,
+ clearPendingTokens,
}
module.exports = actions
@@ -1393,16 +1397,24 @@ function markAccountsFound () {
function retryTransaction (txId) {
log.debug(`background.retryTransaction`)
+ let newTxId
+
return (dispatch) => {
- background.retryTransaction(txId, (err, newState) => {
- if (err) {
- return dispatch(actions.displayWarning(err.message))
- }
- const { selectedAddressTxList } = newState
- const { id: newTxId } = selectedAddressTxList[selectedAddressTxList.length - 1]
- dispatch(actions.updateMetamaskState(newState))
- dispatch(actions.viewPendingTx(newTxId))
+ return new Promise((resolve, reject) => {
+ background.retryTransaction(txId, (err, newState) => {
+ if (err) {
+ dispatch(actions.displayWarning(err.message))
+ reject(err)
+ }
+
+ const { selectedAddressTxList } = newState
+ const { id } = selectedAddressTxList[selectedAddressTxList.length - 1]
+ newTxId = id
+ resolve(newState)
+ })
})
+ .then(newState => dispatch(actions.updateMetamaskState(newState)))
+ .then(() => newTxId)
}
}
@@ -1598,13 +1610,13 @@ function showPrivateKey (key) {
}
}
-function saveAccountLabel (account, label) {
+function setAccountLabel (account, label) {
return (dispatch) => {
dispatch(actions.showLoadingIndication())
- log.debug(`background.saveAccountLabel`)
+ log.debug(`background.setAccountLabel`)
return new Promise((resolve, reject) => {
- background.saveAccountLabel(account, label, (err) => {
+ background.setAccountLabel(account, label, (err) => {
dispatch(actions.hideLoadingIndication())
if (err) {
@@ -1613,7 +1625,7 @@ function saveAccountLabel (account, label) {
}
dispatch({
- type: actions.SAVE_ACCOUNT_LABEL,
+ type: actions.SET_ACCOUNT_LABEL,
value: { account, label },
})
@@ -1929,3 +1941,22 @@ function updateNetworkEndpointType (networkEndpointType) {
value: networkEndpointType,
}
}
+
+function setPendingTokens (pendingTokens) {
+ const { customToken = {}, selectedTokens = {} } = pendingTokens
+ const { address, symbol, decimals } = customToken
+ const tokens = address && symbol && decimals
+ ? { ...selectedTokens, [address]: { ...customToken, isCustom: true } }
+ : selectedTokens
+
+ return {
+ type: actions.SET_PENDING_TOKENS,
+ payload: tokens,
+ }
+}
+
+function clearPendingTokens () {
+ return {
+ type: actions.CLEAR_PENDING_TOKENS,
+ }
+}