diff --git a/app-template/package.json b/app-template/package.json index 0d396c2af..3e19f4248 100644 --- a/app-template/package.json +++ b/app-template/package.json @@ -42,7 +42,7 @@ "url": "https://github.com/bitpay/copay/issues" }, "dependencies": { - "bitcore-wallet-client": "4.1.0", + "bitcore-wallet-client": "4.2.0", "coveralls": "^2.11.9", "express": "^4.11.2", "fs": "0.0.2", diff --git a/package.json b/package.json index abfa18eb5..b4086fa2f 100644 --- a/package.json +++ b/package.json @@ -45,7 +45,7 @@ "url": "https://github.com/bitpay/copay/issues" }, "dependencies": { - "bitcore-wallet-client": "4.1.0", + "bitcore-wallet-client": "4.2.0", "coveralls": "^2.11.9", "express": "^4.11.2", "fs": "0.0.2", diff --git a/src/js/controllers/confirm.js b/src/js/controllers/confirm.js index 0ecd5b01e..4c701775c 100644 --- a/src/js/controllers/confirm.js +++ b/src/js/controllers/confirm.js @@ -5,6 +5,17 @@ angular.module('copayApp.controllers').controller('confirmController', function( var cachedTxp = {}; var isChromeApp = platformInfo.isChromeApp; + + $scope.$on('Wallet/Changed', function(event, wallet) { + if (lodash.isEmpty(wallet)) { + $log.debug('No wallet provided'); + return; + } + $log.debug('Wallet changed: ' + wallet.name); + setWallet(wallet, true); + }); + + $scope.showDescriptionPopup = function() { var commentPopup = $ionicPopup.show({ templateUrl: "views/includes/note.html", @@ -130,15 +141,6 @@ angular.module('copayApp.controllers').controller('confirmController', function( }); }; - $scope.$on('Wallet/Changed', function(event, wallet) { - if (lodash.isEmpty(wallet)) { - $log.debug('No wallet provided'); - return; - } - $log.debug('Wallet changed: ' + wallet.name); - setWallet(wallet, true); - }); - function setWallet(wallet, delayed) { var stop; $scope.wallet = wallet; @@ -255,7 +257,9 @@ angular.module('copayApp.controllers').controller('confirmController', function( }); } + ongoingProcess.set('creatingTx', true); createTx(wallet, false, function(err, txp) { + ongoingProcess.set('creatingTx', false); if (err) return; walletService.publishAndSign(wallet, txp, function(err, txp) { if (err) return setSendError(err); diff --git a/src/js/controllers/modals/txpDetails.js b/src/js/controllers/modals/txpDetails.js index 3804cd830..a9fd5656c 100644 --- a/src/js/controllers/modals/txpDetails.js +++ b/src/js/controllers/modals/txpDetails.js @@ -34,7 +34,7 @@ angular.module('copayApp.controllers').controller('txpDetailsController', functi walletService.publishAndSign($scope.wallet, $scope.tx, function(err, txp) { $scope.$emit('UpdateTx'); if (err) return setSendError(err); - $scope.close(true); + $scope.close(); }); }; @@ -50,7 +50,7 @@ angular.module('copayApp.controllers').controller('txpDetailsController', functi if (err) return setError(err, gettextCatalog.getString('Could not reject payment')); - $scope.close(true); + $scope.close(); }); @@ -70,7 +70,7 @@ angular.module('copayApp.controllers').controller('txpDetailsController', functi return setError(err, gettextCatalog.getString('Could not delete payment proposal')); } - $scope.close(true); + $scope.close(); }); }, 10); }; @@ -87,7 +87,7 @@ angular.module('copayApp.controllers').controller('txpDetailsController', functi return setError(err, gettextCatalog.getString('Could not broadcast payment')); } - $scope.close(true); + $scope.close(); }); }, 10); }; @@ -172,10 +172,7 @@ angular.module('copayApp.controllers').controller('txpDetailsController', functi }); }; - $scope.close = function(shouldEmit) { - if (shouldEmit) - $rootScope.$emit('Local/TxAction', $scope.wallet.id); - + $scope.close = function() { $scope.loading = null; $scope.txpDetailsModal.hide(); }; diff --git a/src/js/controllers/tab-home.js b/src/js/controllers/tab-home.js index ac8ef2750..3abf9f157 100644 --- a/src/js/controllers/tab-home.js +++ b/src/js/controllers/tab-home.js @@ -106,6 +106,7 @@ angular.module('copayApp.controllers').controller('tabHomeController', $scope.updateWallet(wallet); }), $rootScope.$on('Local/TxAction', function(e, walletId) { + $log.debug('Got action for wallet '+ walletId); var wallet = profileService.getWallet(walletId); $scope.updateWallet(wallet); }), diff --git a/src/js/services/profileService.js b/src/js/services/profileService.js index dbad76e34..2e11c97d4 100644 --- a/src/js/services/profileService.js +++ b/src/js/services/profileService.js @@ -123,7 +123,6 @@ angular.module('copayApp.services') if (wallet.cachedActivity) wallet.cachedActivity.isValid = false; - if (wallet.cachedTxps) wallet.cachedTxps.isValid = false; diff --git a/src/js/services/walletService.js b/src/js/services/walletService.js index bd447f7ff..f5bf2e45d 100644 --- a/src/js/services/walletService.js +++ b/src/js/services/walletService.js @@ -92,13 +92,17 @@ angular.module('copayApp.services').factory('walletService', function($log, $tim root.invalidateCache = function(wallet) { - if (wallet.cachedStatus) { + if (wallet.cachedStatus) wallet.cachedStatus.isValid = false; - } - if (wallet.completeHistory) { + if (wallet.completeHistory) wallet.completeHistory.isValid = false; - } + + if (wallet.cachedActivity) + wallet.cachedActivity.isValid = false; + + if (wallet.cachedTxps) + wallet.cachedTxps.isValid = false; }; root.getStatus = function(wallet, opts, cb) { @@ -623,6 +627,10 @@ angular.module('copayApp.services').factory('walletService', function($log, $tim wallet.removeTxProposal(txp, function(err) { $log.debug('Transaction removed'); + + root.invalidateCache(wallet); + $rootScope.$emit('Local/TxAction', wallet.id); + return cb(err); }); }; @@ -864,8 +872,8 @@ angular.module('copayApp.services').factory('walletService', function($log, $tim ongoingProcess.set('rejectTx', true); root.rejectTx(wallet, txp, function(err, txpr) { root.invalidateCache(wallet); - ongoingProcess.set('rejectTx', false); + if (err) return cb(err); $rootScope.$emit('Local/TxAction', wallet.id); @@ -935,6 +943,7 @@ angular.module('copayApp.services').factory('walletService', function($log, $tim var msg = err.message ? err.message : gettext('The payment was created but could not be completed. Please try again from home screen'); + $rootScope.$emit('Local/TxAction', wallet.id); return cb(msg); } @@ -945,18 +954,18 @@ angular.module('copayApp.services').factory('walletService', function($log, $tim ongoingProcess.set('broadcastingTx', false); if (err) return cb('sign error' + err); + $rootScope.$emit('Local/TxAction', wallet.id); var type = root.getViewStatus(wallet, broadcastedTxp); root.openStatusModal(type, broadcastedTxp, function() { - $rootScope.$emit('Local/TxAction', wallet.id); }); return cb(null, broadcastedTxp) }); } else { + $rootScope.$emit('Local/TxAction', wallet.id); + var type = root.getViewStatus(wallet, signedTxp); root.openStatusModal(type, signedTxp, function() { - root.invalidateCache(wallet); - $rootScope.$emit('Local/TxAction', wallet.id); }); return cb(null, signedTxp); }