mirror of https://github.com/BTCPrivate/copay.git
commit
ef181c0931
|
@ -1,9 +1,9 @@
|
|||
<span class="wallet-activity">
|
||||
<div ng-if="x.type == 'NewCopayer' && x.wallet.n>1">
|
||||
<div ng-if="x.type == 'NewCopayer' && x.wallet.n>1" translate>
|
||||
Copayer joined
|
||||
</div>
|
||||
|
||||
<div ng-if="x.type == 'NewCopayer' && x.wallet.n==1">
|
||||
<div ng-if="x.type == 'NewCopayer' && x.wallet.n==1" translate>
|
||||
Wallet created
|
||||
</div>
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<ion-modal-view ng-controller="txpDetailsController">
|
||||
<ion-header-bar align-title="center" class="tab-bar">
|
||||
<div class="left-small">
|
||||
<a ng-click="cancel()" class="p10">
|
||||
<a ng-click="close()" class="p10">
|
||||
<span class="text-close" translate>Close</span>
|
||||
</a>
|
||||
</div>
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copayApp.controllers').controller('confirmController', function($rootScope, $scope, $filter, $timeout, $ionicScrollDelegate, $ionicNavBarDelegate, gettextCatalog, walletService, platformInfo, lodash, configService, rateService, $stateParams, $window, $state, $log, profileService, bitcore, $ionicPopup, txStatus, gettext, txFormatService, ongoingProcess, $ionicModal, popupService) {
|
||||
angular.module('copayApp.controllers').controller('confirmController', function($rootScope, $scope, $filter, $timeout, $ionicScrollDelegate, $ionicNavBarDelegate, gettextCatalog, walletService, platformInfo, lodash, configService, rateService, $stateParams, $window, $state, $log, profileService, bitcore, $ionicPopup, gettext, txFormatService, ongoingProcess, $ionicModal, popupService) {
|
||||
$ionicNavBarDelegate.title(gettextCatalog.getString('Confirm'));
|
||||
var cachedTxp = {};
|
||||
var isChromeApp = platformInfo.isChromeApp;
|
||||
|
|
|
@ -7,5 +7,4 @@ angular.module('copayApp.controllers').controller('txStatusController', function
|
|||
$scope.cancel = function() {
|
||||
$scope.txStatusModal.hide();
|
||||
};
|
||||
|
||||
});
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copayApp.controllers').controller('txpDetailsController', function($scope, $rootScope, $timeout, $interval, $ionicModal, ongoingProcess, platformInfo, txStatus, $ionicScrollDelegate, txFormatService, fingerprintService, bwcError, gettextCatalog, lodash, walletService, popupService) {
|
||||
angular.module('copayApp.controllers').controller('txpDetailsController', function($scope, $rootScope, $timeout, $interval, $ionicModal, ongoingProcess, platformInfo, $ionicScrollDelegate, txFormatService, fingerprintService, bwcError, gettextCatalog, lodash, walletService, popupService) {
|
||||
var self = $scope.self;
|
||||
var tx = $scope.tx;
|
||||
var copayers = $scope.copayers;
|
||||
|
@ -32,6 +32,9 @@ angular.module('copayApp.controllers').controller('txpDetailsController', functi
|
|||
$scope.sign = function() {
|
||||
$scope.loading = true;
|
||||
walletService.publishAndSign($scope.wallet, $scope.tx, function(err, txp) {
|
||||
|
||||
console.log('[txpDetails.js.35] AFTER publush'); //TODO
|
||||
|
||||
$scope.$emit('UpdateTx');
|
||||
if (err) return setSendError(err);
|
||||
$scope.close(txp);
|
||||
|
@ -174,28 +177,6 @@ angular.module('copayApp.controllers').controller('txpDetailsController', functi
|
|||
|
||||
$scope.close = function(txp) {
|
||||
$scope.loading = null;
|
||||
if (txp) {
|
||||
var type = txStatus.notify(txp);
|
||||
$scope.openStatusModal(type, txp, function() {});
|
||||
}
|
||||
$scope.cancel();
|
||||
};
|
||||
|
||||
$scope.openStatusModal = function(type, txp, cb) {
|
||||
$scope.type = type;
|
||||
$scope.tx = txFormatService.processTx(txp);
|
||||
$scope.cb = cb;
|
||||
|
||||
$ionicModal.fromTemplateUrl('views/modals/tx-status.html', {
|
||||
scope: $scope,
|
||||
animation: 'slide-in-up'
|
||||
}).then(function(modal) {
|
||||
$scope.txStatusModal = modal;
|
||||
$scope.txStatusModal.show();
|
||||
});
|
||||
};
|
||||
|
||||
$scope.cancel = function() {
|
||||
$scope.txpDetailsModal.hide();
|
||||
};
|
||||
});
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
angular.module('copayApp.controllers').controller('paperWalletController',
|
||||
function($scope, $timeout, $log, $ionicModal, configService, profileService, $state, addressService, txStatus, bitcore, ongoingProcess, txFormatService, $stateParams) {
|
||||
function($scope, $timeout, $log, $ionicModal, configService, profileService, $state, addressService, bitcore, ongoingProcess, txFormatService, $stateParams, walletService) {
|
||||
|
||||
var wallet = profileService.getWallet($stateParams.walletId);
|
||||
var rawTx;
|
||||
|
@ -100,7 +100,7 @@ angular.module('copayApp.controllers').controller('paperWalletController',
|
|||
$scope.error = err.message || err.toString();
|
||||
$log.error(err);
|
||||
} else {
|
||||
var type = txStatus.notify(txp);
|
||||
var type = walletService.getViewStatus(wallet, txp);
|
||||
$scope.openStatusModal(type, txp, function() {
|
||||
$state.go('tabs.home');
|
||||
});
|
||||
|
|
|
@ -1,41 +0,0 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copayApp.services').factory('txStatus', function($stateParams, lodash, profileService, $timeout, platformInfo) {
|
||||
var root = {};
|
||||
var isCordova = platformInfo.isCordova;
|
||||
|
||||
root.notify = function(txp) {
|
||||
var wallet = profileService.getWallet(txp.walletId);
|
||||
var status = txp.status;
|
||||
var type;
|
||||
var INMEDIATE_SECS = 10;
|
||||
|
||||
if (status == 'broadcasted') {
|
||||
type = 'broadcasted';
|
||||
} else {
|
||||
|
||||
var n = txp.actions.length;
|
||||
var action = lodash.find(txp.actions, {
|
||||
copayerId: wallet.credentials.copayerId
|
||||
});
|
||||
|
||||
if (!action) {
|
||||
type = 'created';
|
||||
} else if (action.type == 'accept') {
|
||||
// created and accepted at the same time?
|
||||
if (n == 1 && action.createdOn - txp.createdOn < INMEDIATE_SECS) {
|
||||
type = 'created';
|
||||
} else {
|
||||
type = 'accepted';
|
||||
}
|
||||
} else if (action.type == 'reject') {
|
||||
type = 'rejected';
|
||||
} else {
|
||||
throw new Error('Unknown type:' + type);
|
||||
}
|
||||
}
|
||||
return type;
|
||||
};
|
||||
|
||||
return root;
|
||||
});
|
|
@ -1,6 +1,6 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copayApp.services').factory('walletService', function($log, $timeout, lodash, trezor, ledger, storageService, configService, rateService, uxLanguage, $filter, gettextCatalog, bwcError, $ionicPopup, fingerprintService, ongoingProcess, gettext, $rootScope, txStatus, txFormatService, $ionicModal, $state, bwcService, bitcore, popupService) {
|
||||
angular.module('copayApp.services').factory('walletService', function($log, $timeout, lodash, trezor, ledger, storageService, configService, rateService, uxLanguage, $filter, gettextCatalog, bwcError, $ionicPopup, fingerprintService, ongoingProcess, gettext, $rootScope, txFormatService, $ionicModal, $state, bwcService, bitcore, popupService) {
|
||||
// `wallet` is a decorated version of client.
|
||||
|
||||
var root = {};
|
||||
|
@ -674,11 +674,13 @@ angular.module('copayApp.services').factory('walletService', function($log, $tim
|
|||
handleError(err);
|
||||
return;
|
||||
}
|
||||
root.startScan(wallet);
|
||||
|
||||
profileService.bindWalletClient(wallet, {
|
||||
force: true
|
||||
});
|
||||
wallet.startScan(wallet);
|
||||
// TODO TODO TODO TODO:
|
||||
// Do it on the controller
|
||||
// profileService.bindWalletClient(wallet, {
|
||||
// force: true
|
||||
// });
|
||||
});
|
||||
};
|
||||
|
||||
|
@ -878,7 +880,7 @@ angular.module('copayApp.services').factory('walletService', function($log, $tim
|
|||
ongoingProcess.set('sendingTx', false);
|
||||
if (err) return cb(err);
|
||||
|
||||
var type = txStatus.notify(createdTxp);
|
||||
var type = root.getViewStatus(wallet, createdTxp);
|
||||
root.openStatusModal(type, createdTxp, function() {
|
||||
$rootScope.$emit('Local/TxAction', wallet.id);
|
||||
return;
|
||||
|
@ -941,7 +943,7 @@ angular.module('copayApp.services').factory('walletService', function($log, $tim
|
|||
ongoingProcess.set('broadcastingTx', false);
|
||||
if (err) return cb('sign error' + err);
|
||||
|
||||
var type = txStatus.notify(broadcastedTxp);
|
||||
var type = root.getViewStatus(wallet, broadcastedTxp);
|
||||
root.openStatusModal(type, broadcastedTxp, function() {
|
||||
$rootScope.$emit('Local/TxAction', wallet.id);
|
||||
});
|
||||
|
@ -949,7 +951,7 @@ angular.module('copayApp.services').factory('walletService', function($log, $tim
|
|||
return cb(null, broadcastedTxp)
|
||||
});
|
||||
} else {
|
||||
var type = txStatus.notify(signedTxp);
|
||||
var type = root.getViewStatus(wallet, signedTxp);
|
||||
root.openStatusModal(type, signedTxp, function() {
|
||||
root.invalidateCache(wallet);
|
||||
$rootScope.$emit('Local/TxAction', wallet.id);
|
||||
|
@ -1026,6 +1028,38 @@ angular.module('copayApp.services').factory('walletService', function($log, $tim
|
|||
});
|
||||
};
|
||||
|
||||
root.getViewStatus = function(wallet, txp) {
|
||||
var status = txp.status;
|
||||
var type;
|
||||
var INMEDIATE_SECS = 10;
|
||||
|
||||
if (status == 'broadcasted') {
|
||||
type = 'broadcasted';
|
||||
} else {
|
||||
|
||||
var n = txp.actions.length;
|
||||
var action = lodash.find(txp.actions, {
|
||||
copayerId: wallet.credentials.copayerId
|
||||
});
|
||||
|
||||
if (!action) {
|
||||
type = 'created';
|
||||
} else if (action.type == 'accept') {
|
||||
// created and accepted at the same time?
|
||||
if (n == 1 && action.createdOn - txp.createdOn < INMEDIATE_SECS) {
|
||||
type = 'created';
|
||||
} else {
|
||||
type = 'accepted';
|
||||
}
|
||||
} else if (action.type == 'reject') {
|
||||
type = 'rejected';
|
||||
} else {
|
||||
throw new Error('Unknown type:' + type);
|
||||
}
|
||||
}
|
||||
return type;
|
||||
};
|
||||
|
||||
|
||||
return root;
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue