add txStatus service
This commit is contained in:
parent
5f5d74944f
commit
a70e7e61a4
6 changed files with 130 additions and 56 deletions
5
TODO
5
TODO
|
|
@ -1,4 +1 @@
|
||||||
- join. on walletComplete!
|
- addressbock
|
||||||
- paypro fetch-> return TIMEOUT
|
|
||||||
- yellow lock on paypro
|
|
||||||
- attack: change paypro ->no! in is cached
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
angular.module('copayApp.controllers').controller('HomeWalletController', function($scope, $rootScope, $timeout, $filter, $modal, rateService, notification, identityService) {
|
angular.module('copayApp.controllers').controller('HomeWalletController', function($scope, $rootScope, $timeout, $filter, $modal, rateService, notification, txStatus, identityService) {
|
||||||
$scope.initHome = function() {
|
$scope.initHome = function() {
|
||||||
var w = $rootScope.wallet;
|
var w = $rootScope.wallet;
|
||||||
|
|
||||||
|
|
@ -44,23 +44,7 @@ angular.module('copayApp.controllers').controller('HomeWalletController', functi
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$scope.$on("$destroy", function() {
|
||||||
// TODO duplicated on controller send. move to a service.
|
|
||||||
$scope.notifyStatus = function(status) {
|
|
||||||
if (status == copay.Wallet.TX_BROADCASTED)
|
|
||||||
notification.success('Success', 'Transaction broadcasted!');
|
|
||||||
else if (status == copay.Wallet.TX_PROPOSAL_SENT)
|
|
||||||
notification.info('Success', 'Transaction proposal created');
|
|
||||||
else if (status == copay.Wallet.TX_SIGNED)
|
|
||||||
notification.success('Success', 'Transaction proposal was signed');
|
|
||||||
else if (status == copay.Wallet.TX_SIGNED_AND_BROADCASTED)
|
|
||||||
notification.success('Success', 'Transaction signed and broadcasted!');
|
|
||||||
else
|
|
||||||
notification.error('Error', 'Unknown error occured');
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
$scope.$on("$destroy", function() {
|
|
||||||
var w = $rootScope.wallet;
|
var w = $rootScope.wallet;
|
||||||
if (w) {
|
if (w) {
|
||||||
removeWatch();
|
removeWatch();
|
||||||
|
|
@ -113,7 +97,8 @@ angular.module('copayApp.controllers').controller('HomeWalletController', functi
|
||||||
$scope.error = $scope.success = null;
|
$scope.error = $scope.success = null;
|
||||||
w.signAndSend(ntxid, function(err, id, status) {
|
w.signAndSend(ntxid, function(err, id, status) {
|
||||||
$scope.loading = false;
|
$scope.loading = false;
|
||||||
$scope.notifyStatus(status);
|
if (!txStatus.notify(status))
|
||||||
|
$scope.error = status;
|
||||||
_updateTxs();
|
_updateTxs();
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
@ -121,14 +106,14 @@ angular.module('copayApp.controllers').controller('HomeWalletController', functi
|
||||||
$scope.reject = function(ntxid) {
|
$scope.reject = function(ntxid) {
|
||||||
var w = $rootScope.wallet;
|
var w = $rootScope.wallet;
|
||||||
w.reject(ntxid);
|
w.reject(ntxid);
|
||||||
notification.warning('Transaction rejected', 'You rejected the transaction successfully');
|
txStatus.notify('txRejected');
|
||||||
_updateTxs();
|
_updateTxs();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
$scope.openTxModal = function(btx) {
|
$scope.openTxModal = function(tx) {
|
||||||
var ModalInstanceCtrl = function($scope, $modalInstance) {
|
var ModalInstanceCtrl = function($scope, $modalInstance) {
|
||||||
$scope.btx = btx;
|
$scope.tx = tx;
|
||||||
|
|
||||||
$scope.getShortNetworkName = function() {
|
$scope.getShortNetworkName = function() {
|
||||||
var w = $rootScope.wallet;
|
var w = $rootScope.wallet;
|
||||||
|
|
@ -141,7 +126,7 @@ angular.module('copayApp.controllers').controller('HomeWalletController', functi
|
||||||
};
|
};
|
||||||
|
|
||||||
$modal.open({
|
$modal.open({
|
||||||
templateUrl: 'views/modals/tx-details.html',
|
templateUrl: 'views/modals/txp-details.html',
|
||||||
windowClass: 'tiny',
|
windowClass: 'tiny',
|
||||||
controller: ModalInstanceCtrl,
|
controller: ModalInstanceCtrl,
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ var bitcore = require('bitcore');
|
||||||
var preconditions = require('preconditions').singleton();
|
var preconditions = require('preconditions').singleton();
|
||||||
|
|
||||||
angular.module('copayApp.controllers').controller('SendController',
|
angular.module('copayApp.controllers').controller('SendController',
|
||||||
function($scope, $rootScope, $window, $timeout, $modal, $filter, notification, isMobile, rateService) {
|
function($scope, $rootScope, $window, $timeout, $modal, $filter, notification, isMobile, rateService, txStatus) {
|
||||||
|
|
||||||
var satToUnit, unitToSat, w;
|
var satToUnit, unitToSat, w;
|
||||||
|
|
||||||
|
|
@ -250,7 +250,6 @@ angular.module('copayApp.controllers').controller('SendController',
|
||||||
|
|
||||||
qrcode.callback = function(data) {
|
qrcode.callback = function(data) {
|
||||||
_scanStop();
|
_scanStop();
|
||||||
|
|
||||||
$scope.$apply(function() {
|
$scope.$apply(function() {
|
||||||
$scope.sendForm.address.$setViewValue(data);
|
$scope.sendForm.address.$setViewValue(data);
|
||||||
$scope.sendForm.address.$render();
|
$scope.sendForm.address.$render();
|
||||||
|
|
@ -389,7 +388,10 @@ angular.module('copayApp.controllers').controller('SendController',
|
||||||
form.address.$setViewValue('');
|
form.address.$setViewValue('');
|
||||||
form.address.$render();
|
form.address.$render();
|
||||||
}
|
}
|
||||||
$scope.notifyStatus(status);
|
|
||||||
|
if (!txStatus.notify(status))
|
||||||
|
$scope.error = status;
|
||||||
|
|
||||||
$timeout(function() {
|
$timeout(function() {
|
||||||
$rootScope.$digest();
|
$rootScope.$digest();
|
||||||
}, 1);
|
}, 1);
|
||||||
|
|
@ -414,23 +416,8 @@ angular.module('copayApp.controllers').controller('SendController',
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.openTxStatusModal = function(statusStr) {
|
|
||||||
var ModalInstanceCtrl = function($scope, $modalInstance) {
|
|
||||||
$scope.statusStr = statusStr;
|
|
||||||
$scope.cancel = function() {
|
|
||||||
$modalInstance.dismiss('cancel');
|
|
||||||
};
|
|
||||||
};
|
|
||||||
$modal.open({
|
|
||||||
templateUrl: 'views/modals/tx-status.html',
|
|
||||||
windowClass: 'tiny',
|
|
||||||
controller: ModalInstanceCtrl,
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
$scope.setFromPayPro = function(uri) {
|
$scope.setFromPayPro = function(uri) {
|
||||||
console.log('[send.js.391:uri:]', uri); //TODO
|
|
||||||
|
|
||||||
$scope.fetchingURL = uri;
|
$scope.fetchingURL = uri;
|
||||||
$scope.loading = true;
|
$scope.loading = true;
|
||||||
|
|
||||||
|
|
@ -478,9 +465,6 @@ angular.module('copayApp.controllers').controller('SendController',
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.onAddressChange = function(value) {
|
$scope.onAddressChange = function(value) {
|
||||||
var addr;
|
|
||||||
console.log('[send.js.391:value:]', value); //TODO
|
|
||||||
|
|
||||||
$scope.error = $scope.success = null;
|
$scope.error = $scope.success = null;
|
||||||
if (!value) return '';
|
if (!value) return '';
|
||||||
|
|
||||||
|
|
@ -489,6 +473,7 @@ angular.module('copayApp.controllers').controller('SendController',
|
||||||
} else if (/^https?:\/\//.test(value)) {
|
} else if (/^https?:\/\//.test(value)) {
|
||||||
return $scope.setFromPayPro(value);
|
return $scope.setFromPayPro(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
return value;
|
return value;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -558,8 +543,7 @@ angular.module('copayApp.controllers').controller('SendController',
|
||||||
});
|
});
|
||||||
|
|
||||||
modalInstance.result.then(function(addr) {
|
modalInstance.result.then(function(addr) {
|
||||||
$scope._address = addr;
|
$scope.setForm(addr);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
|
||||||
39
js/services/txStatus.js
Normal file
39
js/services/txStatus.js
Normal file
|
|
@ -0,0 +1,39 @@
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
angular.module('copayApp.services').factory('txStatus', function($modal) {
|
||||||
|
var root = {};
|
||||||
|
|
||||||
|
root.notify = function(status) {
|
||||||
|
var msg;
|
||||||
|
if (status == copay.Wallet.TX_BROADCASTED)
|
||||||
|
msg = 'Transaction broadcasted!';
|
||||||
|
else if (status == copay.Wallet.TX_PROPOSAL_SENT)
|
||||||
|
msg = 'Transaction proposal created';
|
||||||
|
else if (status == copay.Wallet.TX_SIGNED)
|
||||||
|
msg = 'Transaction proposal was signed';
|
||||||
|
else if (status == copay.Wallet.TX_SIGNED_AND_BROADCASTED)
|
||||||
|
msg = 'Transaction signed and broadcasted!';
|
||||||
|
else if (status == 'txRejected')
|
||||||
|
msg = 'Transaction was rejected!';
|
||||||
|
|
||||||
|
if (msg)
|
||||||
|
root.openModal(msg);
|
||||||
|
return msg ? true : false;
|
||||||
|
};
|
||||||
|
|
||||||
|
root.openModal = function(statusStr) {
|
||||||
|
var ModalInstanceCtrl = function($scope, $modalInstance) {
|
||||||
|
$scope.statusStr = statusStr;
|
||||||
|
$scope.cancel = function() {
|
||||||
|
$modalInstance.dismiss('cancel');
|
||||||
|
};
|
||||||
|
};
|
||||||
|
$modal.open({
|
||||||
|
templateUrl: 'views/modals/tx-status.html',
|
||||||
|
windowClass: 'tiny',
|
||||||
|
controller: ModalInstanceCtrl,
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
return root;
|
||||||
|
});
|
||||||
|
|
@ -31,11 +31,11 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="line-b m10t"></div>
|
<div class="line-b m10t"></div>
|
||||||
<h1 class="m30v">Transaction Details</h1>
|
<h1 class="m30v">Transaction Details</h1>
|
||||||
<div class="ellipsis"> <b>ID:</b> <span class="text-gray"> {{btx.txid}} </span></div>
|
<div class="ellipsis" ng-if="btx.txid"> <b>ID:</b> <span class="text-gray"> {{btx.txid}} </span></div>
|
||||||
<div ng-if="btx.ts" class="m10v">
|
<div ng-if="btx.ts || btx.createdTs " class="m10v">
|
||||||
<time> <span>{{btx.ts | amCalendar}}</span></time>
|
<time> <span>{{ (btx.ts || btx.createdTs ) | amCalendar}}</span></time>
|
||||||
|
|
||||||
[<time>{{btx.ts | amTimeAgo}}</time>]
|
[<time>{{ (btx.ts || btx.createdTs ) | amTimeAgo}}</time>]
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="m10v">
|
<div class="m10v">
|
||||||
|
|
@ -83,12 +83,11 @@
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="m10t oh">
|
<div class="m10t oh" ng-if="btx.txid">
|
||||||
<a class="right button-setup"
|
<a class="right button-setup"
|
||||||
ng-click="openExternalLink('http://' + getShortNetworkName() + '.insight.is/tx/' + btx.txid)">
|
ng-click="openExternalLink('http://' + getShortNetworkName() + '.insight.is/tx/' + btx.txid)">
|
||||||
See it on the blockchain <i class="icon-arrow-right2 vm"></i>
|
See it on the blockchain <i class="icon-arrow-right2 vm"></i>
|
||||||
</a>
|
</a>
|
||||||
</p>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
|
||||||
70
views/modals/txp-details.html
Normal file
70
views/modals/txp-details.html
Normal file
|
|
@ -0,0 +1,70 @@
|
||||||
|
|
||||||
|
<a class="close-reveal-modal" ng-click="cancel()">×</a>
|
||||||
|
|
||||||
|
<h1 class="m30v">Transaction Proposal Details</h1>
|
||||||
|
|
||||||
|
<div class="row" ng-repeat="out in tx.outs">
|
||||||
|
<div class="large-5 medium-5 small-6 columns size-14">
|
||||||
|
<b>{{out.value}} {{$root.wallet.settings.unitName}}</b>
|
||||||
|
<span ng-show="out.alternativeAmount" class="alt-currency gray">
|
||||||
|
{{out.alternativeAmount}} {{out.alternativeIsoCode}}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<div class="large-2 medium-2 small-1 columns text-center">
|
||||||
|
<i class="fi-arrow-right"></i>
|
||||||
|
</div>
|
||||||
|
<div class="large-5 medium m0-5 small-5 columns ellipsis size-12">
|
||||||
|
<div ng-if="tx.merchant">
|
||||||
|
<span ng-show="tx.merchant.pr.ca"><i class="fi-lock color-greeni"></i> {{tx.merchant.domain}}</span>
|
||||||
|
<span ng-show="!tx.merchant.pr.ca"><i class="fi-unlock color-yellowi"></i> {{tx.merchant.domain}}</span>
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<contact address="{{out.address}}" tooltip-popup-delay="500" tooltip tooltip-placement="right" ng-hide="tx.merchant" />
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="text-light size-14">{{tx.comment}}</div>
|
||||||
|
|
||||||
|
<div class="line-b m10t"></div>
|
||||||
|
<div ng-if="tx.createdTs " class="m10v size-14">
|
||||||
|
<time> <span>{{ tx.createdTs | amCalendar}}</span></time>
|
||||||
|
|
||||||
|
[<time>{{ tx.createdTs | amTimeAgo}}</time>]
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div ng-if="tx.addressTo" class="m10v">
|
||||||
|
<span class="ellipsis">
|
||||||
|
<b>To:</b>
|
||||||
|
<span ng-if="tx.merchant">
|
||||||
|
<span ng-show="tx.merchant.pr.ca"><i class="fi-lock color-greeni"></i> {{tx.merchant.domain}}</span>
|
||||||
|
<span ng-show="!tx.merchant.pr.ca"><i class="fi-unlock color-yellowi"></i> {{tx.merchant.domain}}</span>
|
||||||
|
</span>
|
||||||
|
|
||||||
|
<span ng-if="!tx.merchant">
|
||||||
|
<span class="text-gray"> {{tx.labelTo || tx.addressTo}}</span>
|
||||||
|
</span>
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div ng-if="tx.merchant" class="size-12 m10v">
|
||||||
|
{{tx.merchant.pr.pd.memo}}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div ng-if="tx.actionList[0]" class="m10v">
|
||||||
|
<b>Copayers Signatures</b>
|
||||||
|
<ul class="tx-copayers m10t" ng-if="tx.actionList[0]">
|
||||||
|
<li ng-repeat="c in tx.actionList" ng-class="{'bottom-line-copayers':!$last}">
|
||||||
|
<span>
|
||||||
|
<i ng-if="c.actions.rejected" class="fi-x icon-sign x"></i>
|
||||||
|
<i ng-if="c.actions.sign" class="fi-check icon-sign check"></i>
|
||||||
|
<i ng-if="!c.actions.sign && !c.actions.rejected && tx.missingSignatures" class="m10r fi-loop icon-rotate"></i>
|
||||||
|
</span>
|
||||||
|
<span>
|
||||||
|
<i ng-if="c.actions.create" class="fi-crown icon-status icon-active m10r"></i>
|
||||||
|
</span>
|
||||||
|
<span>{{c.cId === $root.wallet.getMyCopayerId() ? 'Me' : $root.wallet.publicKeyRing.nicknameForCopayer(c.cId)}}</span>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue