refactor
This commit is contained in:
parent
19971c57a6
commit
2d6dad6557
4 changed files with 37 additions and 33 deletions
|
|
@ -426,6 +426,12 @@ angular.module('copayApp.controllers').controller('confirmController', function(
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.approve = function(onSendStatusChange) {
|
$scope.approve = function(onSendStatusChange) {
|
||||||
|
|
||||||
|
var wallet = $scope.wallet;
|
||||||
|
if (!wallet) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if ($scope.paypro && $scope.paymentExpired.value) {
|
if ($scope.paypro && $scope.paymentExpired.value) {
|
||||||
popupService.showAlert(null, gettextCatalog.getString('This bitcoin payment request has expired.'));
|
popupService.showAlert(null, gettextCatalog.getString('This bitcoin payment request has expired.'));
|
||||||
$scope.sendStatus = '';
|
$scope.sendStatus = '';
|
||||||
|
|
@ -435,26 +441,21 @@ angular.module('copayApp.controllers').controller('confirmController', function(
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var wallet = $scope.wallet;
|
|
||||||
if (!wallet) {
|
|
||||||
return setSendError(gettextCatalog.getString('No wallet selected'));
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($scope.isGlidera) {
|
if ($scope.isGlidera) {
|
||||||
$scope.get2faCode(function(err, sent) {
|
$scope.get2faCode(function(err, sent) {
|
||||||
if (err) {
|
if (err) {
|
||||||
popupService.showAlert(gettextCatalog.getString('Error'), gettextCatalog.getString('Could not send confirmation code to your phone'));
|
popupService.showAlert('Error', 'Could not send confirmation code to your phone');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (sent) {
|
if (sent) {
|
||||||
var title = gettextCatalog.getString("Please, enter the code below");
|
var title = "Please, enter the code below";
|
||||||
var message = gettextCatalog.getString("A SMS containing a confirmation code was sent to your phone.");
|
var message = "A SMS containing a confirmation code was sent to your phone.";
|
||||||
popupService.showPrompt(title, message, null, function(twoFaCode) {
|
popupService.showPrompt(title, message, null, function(twoFaCode) {
|
||||||
if (typeof twoFaCode == 'undefined') return;
|
if (typeof twoFaCode == 'undefined') return;
|
||||||
if ($scope.glideraBuy) {
|
if ($scope.glideraBuy) {
|
||||||
$scope.buyRequest(wallet, twoFaCode, function(err, data) {
|
$scope.buyRequest(wallet, twoFaCode, function(err, data) {
|
||||||
if (err) {
|
if (err) {
|
||||||
popupService.showAlert(gettextCatalog.getString('Error'), err);
|
popupService.showAlert('Error', err);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$scope.sendStatus = 'success';
|
$scope.sendStatus = 'success';
|
||||||
|
|
@ -466,7 +467,7 @@ angular.module('copayApp.controllers').controller('confirmController', function(
|
||||||
if ($scope.glideraSell) {
|
if ($scope.glideraSell) {
|
||||||
$scope.sellRequest(wallet, twoFaCode, function(err, data) {
|
$scope.sellRequest(wallet, twoFaCode, function(err, data) {
|
||||||
if (err) {
|
if (err) {
|
||||||
popupService.showAlert(gettextCatalog.getString('Error'), err);
|
popupService.showAlert('Error', err);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$scope.sendStatus = 'success';
|
$scope.sendStatus = 'success';
|
||||||
|
|
@ -600,22 +601,22 @@ angular.module('copayApp.controllers').controller('confirmController', function(
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.get2faCode = function(cb) {
|
$scope.get2faCode = function(cb) {
|
||||||
ongoingProcess.set('Sending 2FA code...', true);
|
ongoingProcess.set('sending2faCode', true);
|
||||||
$timeout(function() {
|
$timeout(function() {
|
||||||
glideraService.get2faCode($scope.glideraAccessToken, function(err, sent) {
|
glideraService.get2faCode($scope.glideraAccessToken, function(err, sent) {
|
||||||
ongoingProcess.set('Sending 2FA code...', false);
|
ongoingProcess.set('sending2faCode', false);
|
||||||
return cb(err, sent);
|
return cb(err, sent);
|
||||||
});
|
});
|
||||||
}, 100);
|
}, 100);
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.buyRequest = function(wallet, twoFaCode, cb) {
|
$scope.buyRequest = function(wallet, twoFaCode, cb) {
|
||||||
ongoingProcess.set('Buying Bitcoin...', true);
|
ongoingProcess.set('buyingBitcoin', true);
|
||||||
$timeout(function() {
|
$timeout(function() {
|
||||||
walletService.getAddress(wallet, false, function(err, walletAddr) {
|
walletService.getAddress(wallet, false, function(err, walletAddr) {
|
||||||
if (err) {
|
if (err) {
|
||||||
ongoingProcess.set('Buying Bitcoin...', false);
|
ongoingProcess.set('buyingBitcoin', false);
|
||||||
popupService.showAlert(gettextCatalog.getString('Error'), bwcError.cb(err, 'Could not create address'));
|
popupService.showAlert('Error', bwcError.cb(err, 'Could not create address'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var data = {
|
var data = {
|
||||||
|
|
@ -626,7 +627,7 @@ angular.module('copayApp.controllers').controller('confirmController', function(
|
||||||
ip: null
|
ip: null
|
||||||
};
|
};
|
||||||
glideraService.buy($scope.glideraAccessToken, twoFaCode, data, function(err, data) {
|
glideraService.buy($scope.glideraAccessToken, twoFaCode, data, function(err, data) {
|
||||||
ongoingProcess.set('Buying Bitcoin...', false);
|
ongoingProcess.set('buyingBitcoin', false);
|
||||||
return cb(err, data);
|
return cb(err, data);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
@ -643,13 +644,13 @@ angular.module('copayApp.controllers').controller('confirmController', function(
|
||||||
walletService.getAddress(wallet, null, function(err, refundAddress) {
|
walletService.getAddress(wallet, null, function(err, refundAddress) {
|
||||||
if (!refundAddress) {
|
if (!refundAddress) {
|
||||||
ongoingProcess.clear();
|
ongoingProcess.clear();
|
||||||
popupService.showAlert(gettextCatalog.getString('Error'), bwcError.msg(err, 'Could not create address'));
|
popupService.showAlert('Error', bwcError.msg(err, 'Could not create address'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
glideraService.getSellAddress($scope.glideraAccessToken, function(err, sellAddress) {
|
glideraService.getSellAddress($scope.glideraAccessToken, function(err, sellAddress) {
|
||||||
if (!sellAddress || err) {
|
if (!sellAddress || err) {
|
||||||
ongoingProcess.clear();
|
ongoingProcess.clear();
|
||||||
popupService.showAlert(gettextCatalog.getString('Error'), gettextCatalog.getString('Could not get the destination bitcoin address'));
|
popupService.showAlert('Error', 'Could not get the destination bitcoin address');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var amount = parseInt(($scope.sellPrice.qty * 100000000).toFixed(0));
|
var amount = parseInt(($scope.sellPrice.qty * 100000000).toFixed(0));
|
||||||
|
|
@ -677,27 +678,27 @@ angular.module('copayApp.controllers').controller('confirmController', function(
|
||||||
walletService.createTx(wallet, txp, function(err, createdTxp) {
|
walletService.createTx(wallet, txp, function(err, createdTxp) {
|
||||||
ongoingProcess.clear();
|
ongoingProcess.clear();
|
||||||
if (err) {
|
if (err) {
|
||||||
popupService.showAlert(gettextCatalog.getString('Error'), err.message || bwcError.msg(err));
|
popupService.showAlert('Error', err.message || bwcError.msg(err));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
walletService.prepare(wallet, function(err, password) {
|
walletService.prepare(wallet, function(err, password) {
|
||||||
if (err) {
|
if (err) {
|
||||||
ongoingProcess.clear();
|
ongoingProcess.clear();
|
||||||
popupService.showAlert(gettextCatalog.getString('Error'), err.message || bwcError.msg(err));
|
popupService.showAlert('Error', err.message || bwcError.msg(err));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ongoingProcess.set('signingTx', true);
|
ongoingProcess.set('signingTx', true);
|
||||||
walletService.publishTx(wallet, createdTxp, function(err, publishedTxp) {
|
walletService.publishTx(wallet, createdTxp, function(err, publishedTxp) {
|
||||||
if (err) {
|
if (err) {
|
||||||
ongoingProcess.clear();
|
ongoingProcess.clear();
|
||||||
popupService.showAlert(gettextCatalog.getString('Error'), err.message || bwcError.msg(err));
|
popupService.showAlert('Error', err.message || bwcError.msg(err));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
walletService.signTx(wallet, publishedTxp, password, function(err, signedTxp) {
|
walletService.signTx(wallet, publishedTxp, password, function(err, signedTxp) {
|
||||||
if (err) {
|
if (err) {
|
||||||
ongoingProcess.clear();
|
ongoingProcess.clear();
|
||||||
popupService.showAlert(gettextCatalog.getString('Error'), err.message || bwcError.msg(err));
|
popupService.showAlert('Error', err.message || bwcError.msg(err));
|
||||||
walletService.removeTx(wallet, signedTxp, function(err) {
|
walletService.removeTx(wallet, signedTxp, function(err) {
|
||||||
if (err) $log.debug(err);
|
if (err) $log.debug(err);
|
||||||
});
|
});
|
||||||
|
|
@ -711,11 +712,11 @@ angular.module('copayApp.controllers').controller('confirmController', function(
|
||||||
useCurrentPrice: $scope.sellPrice.priceUuid ? false : true,
|
useCurrentPrice: $scope.sellPrice.priceUuid ? false : true,
|
||||||
ip: null
|
ip: null
|
||||||
};
|
};
|
||||||
ongoingProcess.set('Selling Bitcoin', true);
|
ongoingProcess.set('sellingBitcoin', true);
|
||||||
glideraService.sell($scope.glideraAccessToken, twoFaCode, data, function(err, data) {
|
glideraService.sell($scope.glideraAccessToken, twoFaCode, data, function(err, data) {
|
||||||
ongoingProcess.clear();
|
ongoingProcess.clear();
|
||||||
if (err) {
|
if (err) {
|
||||||
popupService.showAlert(gettextCatalog.getString('Error'), err.message || bwcError.msg(err));
|
popupService.showAlert('Error', err.message || bwcError.msg(err));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
return cb(err, data)
|
return cb(err, data)
|
||||||
|
|
@ -734,7 +735,7 @@ angular.module('copayApp.controllers').controller('confirmController', function(
|
||||||
price.qty = (toAmount * satToBtc).toFixed(8);
|
price.qty = (toAmount * satToBtc).toFixed(8);
|
||||||
glideraService.buyPrice($scope.glideraAccessToken, price, function(err, buyPrice) {
|
glideraService.buyPrice($scope.glideraAccessToken, price, function(err, buyPrice) {
|
||||||
if (err) {
|
if (err) {
|
||||||
popupService.showAlert(gettextCatalog.getString('Error'), gettextCatalog.getString('Could not get exchange information. Please, try again'));
|
popupService.showAlert('Error', 'Could not get exchange information. Please, try again');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$scope.buyPrice = buyPrice;
|
$scope.buyPrice = buyPrice;
|
||||||
|
|
@ -748,7 +749,7 @@ angular.module('copayApp.controllers').controller('confirmController', function(
|
||||||
|
|
||||||
glideraService.sellPrice($scope.glideraAccessToken, price, function(err, sellPrice) {
|
glideraService.sellPrice($scope.glideraAccessToken, price, function(err, sellPrice) {
|
||||||
if (err) {
|
if (err) {
|
||||||
popupService.showAlert(gettextCatalog.getString('Error'), gettextCatalog.getString('Could not get exchange information. Please, try again'));
|
popupService.showAlert('Error', 'Could not get exchange information. Please, try again');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$scope.sellPrice = sellPrice;
|
$scope.sellPrice = sellPrice;
|
||||||
|
|
|
||||||
|
|
@ -37,6 +37,9 @@ angular.module('copayApp.services').factory('ongoingProcess', function($log, $ti
|
||||||
'generatingNewAddress': gettext('Generating new address...'),
|
'generatingNewAddress': gettext('Generating new address...'),
|
||||||
'gettingAddresses': gettext('Getting addresses...'),
|
'gettingAddresses': gettext('Getting addresses...'),
|
||||||
'sendingByEmail': gettext('Preparing addresses...'),
|
'sendingByEmail': gettext('Preparing addresses...'),
|
||||||
|
'sending2faCode': gettext('Sending 2FA code...'),
|
||||||
|
'buyingBitcoin': gettext('Buying Bitcoin...'),
|
||||||
|
'sellingBitcoin': gettext('Selling Bitcoin...')
|
||||||
};
|
};
|
||||||
|
|
||||||
root.clear = function() {
|
root.clear = function() {
|
||||||
|
|
|
||||||
|
|
@ -117,7 +117,7 @@
|
||||||
</div>
|
</div>
|
||||||
</ion-content>
|
</ion-content>
|
||||||
<click-to-accept
|
<click-to-accept
|
||||||
ng-click="wallet ? approve(statusChangeHandler) : null"
|
ng-click="approve(statusChangeHandler)"
|
||||||
ng-if="!isCordova && wallets[0] && !insufficientFunds && !noMatchingWallet"
|
ng-if="!isCordova && wallets[0] && !insufficientFunds && !noMatchingWallet"
|
||||||
click-send-status="sendStatus"
|
click-send-status="sendStatus"
|
||||||
has-wallet-chosen="wallet">
|
has-wallet-chosen="wallet">
|
||||||
|
|
@ -126,7 +126,7 @@
|
||||||
<slide-to-accept
|
<slide-to-accept
|
||||||
ng-disabled="!wallet"
|
ng-disabled="!wallet"
|
||||||
ng-if="isCordova && wallets[0] && !insufficientFunds && !noMatchingWallet"
|
ng-if="isCordova && wallets[0] && !insufficientFunds && !noMatchingWallet"
|
||||||
slide-on-confirm="wallet ? onConfirm() : null"
|
slide-on-confirm="onConfirm()"
|
||||||
slide-send-status="sendStatus"
|
slide-send-status="sendStatus"
|
||||||
has-wallet-chosen="wallet">
|
has-wallet-chosen="wallet">
|
||||||
Slide to pay
|
Slide to pay
|
||||||
|
|
|
||||||
|
|
@ -5,17 +5,17 @@
|
||||||
<ion-nav-title>Glidera</ion-nav-title>
|
<ion-nav-title>Glidera</ion-nav-title>
|
||||||
</ion-nav-bar>
|
</ion-nav-bar>
|
||||||
|
|
||||||
<ion-content>
|
<ion-content ng-show="!connectingGlidera">
|
||||||
|
|
||||||
<div class="box-notification error m0" ng-show="!network && !connectingGlidera">
|
<div class="box-notification error m0" ng-show="!network">
|
||||||
Glidera is disabled for this application
|
Glidera is disabled for this application
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="box-notification warning m0" ng-show="network == 'testnet' && !connectingGlidera">
|
<div class="box-notification warning m0" ng-show="network == 'testnet'">
|
||||||
Testnet wallets only work with Glidera Sandbox Accounts
|
Testnet wallets only work with Glidera Sandbox Accounts
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div ng-if="!token && !connectingGlidera">
|
<div ng-if="!token">
|
||||||
|
|
||||||
<div ng-init="showOauthForm = false">
|
<div ng-init="showOauthForm = false">
|
||||||
<div class="text-center m20v">
|
<div class="text-center m20v">
|
||||||
|
|
@ -56,7 +56,7 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div ng-if="token && !connectingGlidera">
|
<div ng-if="token">
|
||||||
<div class="text-center m20v">
|
<div class="text-center m20v">
|
||||||
<img src="img/glidera-logo.png" ng-click="update({'fullUpdate': true})" width="200">
|
<img src="img/glidera-logo.png" ng-click="update({'fullUpdate': true})" width="200">
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue