From 748e8a4fbb375b735c16c2a1f8aa59bca8b7415a Mon Sep 17 00:00:00 2001 From: Gustavo Maximiliano Cortez Date: Thu, 22 Jun 2017 11:49:20 -0300 Subject: [PATCH] Ref confirm. Removes unused code. Fix noLowFee directive --- src/js/controllers/confirm.js | 42 ++++-------------------------- src/js/directives/noLowFee.js | 2 +- src/js/directives/slideToAccept.js | 2 +- www/views/buyAmazon.html | 10 ++----- www/views/buyCoinbase.html | 14 +++------- www/views/buyGlidera.html | 14 +++------- www/views/confirm.html | 2 +- www/views/modals/paypro.html | 32 +++++++++++------------ www/views/sellCoinbase.html | 24 +++++++---------- www/views/sellGlidera.html | 14 +++------- www/views/topup.html | 12 +++------ 11 files changed, 50 insertions(+), 118 deletions(-) diff --git a/src/js/controllers/confirm.js b/src/js/controllers/confirm.js index 780f30171..3bfb55581 100644 --- a/src/js/controllers/confirm.js +++ b/src/js/controllers/confirm.js @@ -176,12 +176,8 @@ angular.module('copayApp.controllers').controller('confirmController', function( function getTxp(tx, wallet, dryRun, cb) { - var paypro = tx.paypro; - var toAddress = tx.toAddress; - var description = tx.description; - // ToDo: use a credential's (or fc's) function for this - if (description && !wallet.credentials.sharedEncryptingKey) { + if (tx.description && !wallet.credentials.sharedEncryptingKey) { var msg = gettextCatalog.getString('Could not add message to imported wallet without shared encrypting key'); $log.warn(msg); return setSendError(msg); @@ -208,7 +204,7 @@ angular.module('copayApp.controllers').controller('confirmController', function( txp.feeLevel = tx.feeLevel; } - txp.message = description; + txp.message = tx.description; if (tx.paypro) { txp.payProUrl = tx.paypro.url; @@ -254,7 +250,7 @@ angular.module('copayApp.controllers').controller('confirmController', function( tx.feeLevelName = feeService.feeOpts[tx.feeLevel]; // End of quick refresh, before wallet is selected. - if (!wallet) + if (!wallet) return cb(); getSendMaxInfo(lodash.clone(tx), wallet, function(err, sendMaxInfo) { @@ -276,6 +272,7 @@ angular.module('copayApp.controllers').controller('confirmController', function( tx.sendMaxInfo = sendMaxInfo; tx.toAmount = tx.sendMaxInfo.amount; updateAmount(); + showSendMaxWarning(sendMaxInfo); } refresh(); @@ -286,9 +283,6 @@ angular.module('copayApp.controllers').controller('confirmController', function( getTxp(lodash.clone(tx), wallet, opts.dryRun, function(err, txp) { if (err) return cb(err); - if (tx.sendMaxInfo) - showSendMaxWarning(sendMaxInfo, function(err) {}); - txp.feeStr = txFormatService.formatAmountStr(txp.fee); txFormatService.formatAlternativeStr(txp.fee, function(v) { txp.alternativeFeeStr = v; @@ -360,24 +354,6 @@ angular.module('copayApp.controllers').controller('confirmController', function( popupService.showAlert(null, msg, function() {}); }; - function setSendMaxValues(data) { - $scope.amountStr = txFormatService.formatAmountStr(data.amount, true); - $scope.displayAmount = getDisplayAmount($scope.amountStr); - $scope.displayUnit = getDisplayUnit($scope.amountStr); - $scope.fee = txFormatService.formatAmountStr(data.fee); - txFormatService.formatAlternativeStr(data.fee, function(v) { - $scope.feeFiat = v; - }); - toAmount = parseFloat((data.amount * satToUnit).toFixed(unitDecimals)); - txFormatService.formatAlternativeStr(data.amount, function(v) { - $scope.alternativeAmountStr = v; - }); - $scope.feeRateStr = (data.fee / (data.amount + data.fee) * 100).toFixed(2) + '%'; - $timeout(function() { - $scope.$apply(); - }); - }; - $scope.$on('accepted', function(event) { $scope.approve(); }); @@ -565,27 +541,19 @@ angular.module('copayApp.controllers').controller('confirmController', function( }; $scope.onSuccessConfirm = function() { - var previousView = $ionicHistory.viewHistory().backView && $ionicHistory.viewHistory().backView.stateName; - - $ionicHistory.nextViewOptions({ - disableAnimate: true - }); - $ionicHistory.removeBackView(); $scope.sendStatus = ''; - $ionicHistory.nextViewOptions({ disableAnimate: true, historyRoot: true }); - $ionicHistory.clearHistory(); $state.go('tabs.send').then(function() { + $ionicHistory.clearHistory(); $state.transitionTo('tabs.home'); }); }; $scope.chooseFeeLevel = function(tx, wallet) { - var scope = $rootScope.$new(true); scope.network = tx.network; scope.feeLevel = tx.feeLevel; diff --git a/src/js/directives/noLowFee.js b/src/js/directives/noLowFee.js index b332272e5..68046056b 100644 --- a/src/js/directives/noLowFee.js +++ b/src/js/directives/noLowFee.js @@ -12,7 +12,7 @@ angular.module('copayApp.directives') elem.bind('click', function() { configService.whenAvailable(function(config) { - if (config.wallet.settings.feeLevel.match(/conomy/)) { + if (config.wallet.settings.feeLevel && config.wallet.settings.feeLevel.match(/conomy/)) { $log.debug('Economy Fee setting... disabling link:' + elem.text()); popupService.showAlert('Low Fee Error', 'Please change your Bitcoin Network Fee Policy setting to Normal or higher to use this service', function() { $ionicHistory.goBack(); diff --git a/src/js/directives/slideToAccept.js b/src/js/directives/slideToAccept.js index e57aaecff..3f4db0ef9 100644 --- a/src/js/directives/slideToAccept.js +++ b/src/js/directives/slideToAccept.js @@ -9,7 +9,7 @@ angular.module('copayApp.directives') scope: { sendStatus: '=slideSendStatus', onConfirm: '&slideOnConfirm', - wallet: '=hasWalletChosen' + isDisabled: '=isDisabled' }, link: function(scope, element, attrs) { diff --git a/www/views/buyAmazon.html b/www/views/buyAmazon.html index 03e2e4063..04440fa9e 100644 --- a/www/views/buyAmazon.html +++ b/www/views/buyAmazon.html @@ -53,23 +53,17 @@ + is-disabled="!wallet"> Confirm purchase + is-disabled="!wallet"> Slide to buy
{{amountUnitStr}}
- {{buyRequestInfo.amount.amount}} {{buyRequestInfo.amount.currency}} + {{buyRequestInfo.amount.amount}} {{buyRequestInfo.amount.currency}} @ ${{buyPrice.amount}} per BTC
@@ -59,7 +59,7 @@ {{fee.type}} fee - {{fee.amount.amount}} {{fee.amount.currency}} + {{fee.amount.amount}} {{fee.amount.currency}}
@@ -74,23 +74,17 @@ + is-disabled="!selectedPaymentMethodId.value || !buyRequestInfo || !wallet"> Confirm purchase + is-disabled="!selectedPaymentMethodId.value || !buyRequestInfo || !wallet"> Slide to buy
{{amountUnitStr}}
- {{buyInfo.subtotal}} {{buyInfo.currency}} - {{buyInfo.qty}} BTC + {{buyInfo.subtotal}} {{buyInfo.currency}} + {{buyInfo.qty}} BTC @ ${{buyInfo.price}} per BTC
@@ -64,23 +64,17 @@ + is-disabled="!buyInfo || !wallet"> Confirm purchase + is-disabled="!buyInfo || !wallet"> Slide to buy - +
diff --git a/www/views/modals/paypro.html b/www/views/modals/paypro.html index 78dd4380a..18e3ae670 100644 --- a/www/views/modals/paypro.html +++ b/www/views/modals/paypro.html @@ -9,51 +9,51 @@
-
{{displayAmount || '...'}} {{displayUnit}}
-
{{alternativeAmountStr || '...'}}
+
{{tx.amountValueStr || '...'}} {{tx.amountUnitStr}}
+
{{tx.alternativeAmountStr || '...'}}
-
+
{{'Pay To'|translate}} - {{paypro.domain}} + {{tx.paypro.domain}}
-
+
{{'Address'|translate}} - {{paypro.toAddress}} + {{tx.paypro.toAddress}}
{{'Certified by'|translate}} - + - {{paypro.caName}} {{'(Trusted)' | translate}} + {{tx.paypro.caName}} {{'(Trusted)' | translate}} - - + + Self-signed Certificate - - {{paypro.caName}}
+ + {{tx.paypro.caName}}
WARNING: UNTRUSTED CERTIFICATE
-
+
{{'Memo'|translate}} - {{paypro.memo}} + {{tx.paypro.memo}}
-
+
{{'Expires'|translate}} - {{paypro.expires * 1000 | amTimeAgo }} + {{tx.paypro.expires * 1000 | amTimeAgo }}
diff --git a/www/views/sellCoinbase.html b/www/views/sellCoinbase.html index dffd935fe..5827efda6 100644 --- a/www/views/sellCoinbase.html +++ b/www/views/sellCoinbase.html @@ -17,11 +17,11 @@
{{amountUnitStr}}
- {{sellRequestInfo.amount.amount}} {{sellRequestInfo.amount.currency}} + {{sellRequestInfo.amount.amount}} {{sellRequestInfo.amount.currency}} @ ${{sellPrice.amount}} per BTC
-
+
@@ -62,16 +62,16 @@ will be sent to your Coinbase account, and sold when Coinbase accepts the transaction (usually one hour).
-
Estimated sale value: +
Estimated sale value: - {{sellRequestInfo.total.amount | currency : '' : 2}} + {{sellRequestInfo.total.amount | currency : '' : 2}} {{sellRequestInfo.total.currency}}
-
Still sell if price fall until: +
Still sell if price fall until: - {{(sellRequestInfo.total.amount - - (selectedPriceSensitivity.data.value / 100) * sellRequestInfo.total.amount) | currency : '' : 2}} + {{(sellRequestInfo.total.amount - + (selectedPriceSensitivity.data.value / 100) * sellRequestInfo.total.amount) | currency : '' : 2}} {{sellRequestInfo.total.currency}}
@@ -107,23 +107,17 @@ + is-disabled="!selectedPaymentMethodId.value || !sellRequestInfo || !wallet"> Confirm sale + is-disabled="!selectedPaymentMethodId.value || !sellRequestInfo || !wallet"> Slide to sell
{{amountUnitStr}}
- {{sellInfo.subtotal}} {{sellInfo.currency}} + {{sellInfo.subtotal}} {{sellInfo.currency}} {{sellInfo.qty}} BTC @ ${{sellInfo.price}} per BTC
-
+
@@ -64,23 +64,17 @@ + is-disabled="!sellInfo || !wallet"> Confirm sale + is-disabled="!sellInfo || !wallet"> Slide to sell
{{amountUnitStr}}
- @ + @ {{rate | currency:cardInfo.currencySymbol:2}} per BTC ...
@@ -60,23 +60,17 @@ + is-disabled="!cardInfo || !wallet"> Add funds + is-disabled="!cardInfo || !wallet"> Slide to confirm