Refactor Buy/Sell Glidera. Fix 2FA Code. Clean amount/confirm views
This commit is contained in:
parent
4ec340640e
commit
c223de2c63
12 changed files with 802 additions and 320 deletions
|
|
@ -1,6 +1,6 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copayApp.controllers').controller('amountController', function($scope, $filter, $timeout, $ionicScrollDelegate, $ionicHistory, gettextCatalog, platformInfo, lodash, configService, rateService, $stateParams, $window, $state, $log, txFormatService, ongoingProcess, bitpayCardService, popupService, bwcError, payproService, profileService, bitcore, amazonService, glideraService) {
|
||||
angular.module('copayApp.controllers').controller('amountController', function($scope, $filter, $timeout, $ionicScrollDelegate, $ionicHistory, gettextCatalog, platformInfo, lodash, configService, rateService, $stateParams, $window, $state, $log, txFormatService, ongoingProcess, bitpayCardService, popupService, bwcError, payproService, profileService, bitcore, amazonService) {
|
||||
var unitToSatoshi;
|
||||
var satToUnit;
|
||||
var unitDecimals;
|
||||
|
|
@ -14,9 +14,6 @@ angular.module('copayApp.controllers').controller('amountController', function($
|
|||
});
|
||||
|
||||
$scope.$on("$ionicView.beforeEnter", function(event, data) {
|
||||
// Glidera parameters
|
||||
$scope.isGlidera = data.stateParams.isGlidera;
|
||||
$scope.glideraAccessToken = data.stateParams.glideraAccessToken;
|
||||
|
||||
// Go to...
|
||||
$scope.nextStep = data.stateParams.nextStep;
|
||||
|
|
@ -30,26 +27,17 @@ angular.module('copayApp.controllers').controller('amountController', function($
|
|||
$scope.toAddress = data.stateParams.toAddress;
|
||||
$scope.toName = data.stateParams.toName;
|
||||
$scope.toEmail = data.stateParams.toEmail;
|
||||
$scope.showAlternativeAmount = !!$scope.cardId || !!$scope.isGlidera || !!$scope.nextStep;
|
||||
$scope.showAlternativeAmount = !!$scope.cardId || !!$scope.nextStep;
|
||||
$scope.toColor = data.stateParams.toColor;
|
||||
$scope.showSendMax = false;
|
||||
|
||||
$scope.customAmount = data.stateParams.customAmount;
|
||||
|
||||
if (!$scope.cardId && !$scope.isGlidera && !$scope.nextStep && !data.stateParams.toAddress) {
|
||||
if (!$scope.cardId && !$scope.nextStep && !data.stateParams.toAddress) {
|
||||
$log.error('Bad params at amount')
|
||||
throw ('bad params');
|
||||
}
|
||||
|
||||
if ($scope.isGlidera) {
|
||||
glideraService.getLimits($scope.glideraAccessToken, function(err, limits) {
|
||||
$scope.limits = limits;
|
||||
$timeout(function() {
|
||||
$scope.$apply();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
var reNr = /^[1234567890\.]$/;
|
||||
var reOp = /^[\*\+\-\/]$/;
|
||||
|
||||
|
|
@ -293,13 +281,6 @@ angular.module('copayApp.controllers').controller('amountController', function($
|
|||
});
|
||||
});
|
||||
|
||||
} else if ($scope.isGlidera) {
|
||||
var amount = $scope.showAlternativeAmount ? fromFiat(_amount) : _amount;
|
||||
$state.transitionTo('tabs.buyandsell.glidera.confirm', {
|
||||
toAmount: (amount * unitToSatoshi).toFixed(0),
|
||||
isGlidera: $scope.isGlidera,
|
||||
glideraAccessToken: $scope.glideraAccessToken
|
||||
});
|
||||
} else if ($scope.nextStep) {
|
||||
$state.transitionTo($scope.nextStep, {
|
||||
amount: _amount,
|
||||
|
|
|
|||
163
src/js/controllers/buyGlidera.js
Normal file
163
src/js/controllers/buyGlidera.js
Normal file
|
|
@ -0,0 +1,163 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copayApp.controllers').controller('buyGlideraController', function($scope, $log, $state, $timeout, $ionicHistory, lodash, glideraService, popupService, profileService, ongoingProcess, walletService) {
|
||||
|
||||
var amount;
|
||||
var currency;
|
||||
|
||||
var showErrorAndBack = function(err) {
|
||||
$scope.sendStatus = '';
|
||||
$log.error(err);
|
||||
err = err.errors ? err.errors[0].message : err || '';
|
||||
popupService.showAlert('Error', err, function() {
|
||||
$ionicHistory.goBack();
|
||||
});
|
||||
};
|
||||
|
||||
var showError = function(err) {
|
||||
$scope.sendStatus = '';
|
||||
$log.error(err);
|
||||
err = err.errors ? err.errors[0].message : err;
|
||||
popupService.showAlert('Error', err);
|
||||
};
|
||||
|
||||
var statusChangeHandler = function (processName, showName, isOn) {
|
||||
$log.debug('statusChangeHandler: ', processName, showName, isOn);
|
||||
if ( processName == 'buyingBitcoin' && !isOn) {
|
||||
$scope.sendStatus = 'success';
|
||||
$timeout(function() {
|
||||
$scope.$digest();
|
||||
}, 100);
|
||||
} else if (showName) {
|
||||
$scope.sendStatus = showName;
|
||||
}
|
||||
};
|
||||
|
||||
$scope.$on("$ionicView.beforeEnter", function(event, data) {
|
||||
$scope.isFiat = data.stateParams.currency ? true : false;
|
||||
var parsedAmount = glideraService.parseAmount(
|
||||
data.stateParams.amount,
|
||||
data.stateParams.currency);
|
||||
|
||||
amount = parsedAmount.amount;
|
||||
currency = parsedAmount.currency;
|
||||
$scope.amountUnitStr = parsedAmount.amountUnitStr;
|
||||
|
||||
$scope.network = glideraService.getNetwork();
|
||||
$scope.wallets = profileService.getWallets({
|
||||
onlyComplete: true,
|
||||
network: $scope.network
|
||||
});
|
||||
$scope.wallet = $scope.wallets[0]; // Default first wallet
|
||||
|
||||
ongoingProcess.set('connectingGlidera', true);
|
||||
glideraService.init(function(err, data) {
|
||||
if (err) {
|
||||
ongoingProcess.set('connectingGlidera', false);
|
||||
showErrorAndBack(err);
|
||||
return;
|
||||
}
|
||||
$scope.token = data.token;
|
||||
var price = {};
|
||||
if ($scope.isFiat) {
|
||||
price['fiat'] = amount;
|
||||
} else {
|
||||
price['qty'] = amount;
|
||||
}
|
||||
glideraService.buyPrice($scope.token, price, function(err, buy) {
|
||||
ongoingProcess.set('connectingGlidera', false);
|
||||
if (err) {
|
||||
showErrorAndBack(err);
|
||||
return;
|
||||
}
|
||||
$scope.buyInfo = buy;
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
var ask2FaCode = function(mode, cb) {
|
||||
if (mode != 'NONE') {
|
||||
// SHOW PROMPT
|
||||
var title = 'Please, enter the code below';
|
||||
var message;
|
||||
if (mode == 'PIN') {
|
||||
message = 'You have enabled PIN based two-factor authentication.';
|
||||
} else if (mode == 'AUTHENTICATOR') {
|
||||
message = 'Use an authenticator app (Authy or Google Authenticator).';
|
||||
} else {
|
||||
message = 'A SMS containing a confirmation code was sent to your phone.';
|
||||
}
|
||||
popupService.showPrompt(title, message, null, function(twoFaCode) {
|
||||
if (typeof twoFaCode == 'undefined') return cb();
|
||||
return cb(twoFaCode);
|
||||
});
|
||||
} else {
|
||||
return cb();
|
||||
}
|
||||
};
|
||||
|
||||
$scope.buyConfirm = function() {
|
||||
var message = 'Buy bitcoin for ' + amount + ' ' + currency;
|
||||
var okText = 'Confirm';
|
||||
var cancelText = 'Cancel';
|
||||
popupService.showConfirm(null, message, okText, cancelText, function(ok) {
|
||||
if (!ok) return;
|
||||
ongoingProcess.set('buyingBitcoin', true, statusChangeHandler);
|
||||
glideraService.get2faCode($scope.token, function(err, tfa) {
|
||||
if (err) {
|
||||
ongoingProcess.set('buyingBitcoin', false, statusChangeHandler);
|
||||
showError(err);
|
||||
return;
|
||||
}
|
||||
ask2FaCode(tfa.mode, function(twoFaCode) {
|
||||
if (tfa.mode != 'NONE' && lodash.isEmpty(twoFaCode)) {
|
||||
ongoingProcess.set('buyingBitcoin', false, statusChangeHandler);
|
||||
showError('No code entered');
|
||||
return;
|
||||
}
|
||||
|
||||
walletService.getAddress($scope.wallet, false, function(err, walletAddr) {
|
||||
if (err) {
|
||||
ongoingProcess.set('buyingBitcoin', false, statusChangeHandler);
|
||||
showError(err);
|
||||
return;
|
||||
}
|
||||
var data = {
|
||||
destinationAddress: walletAddr,
|
||||
qty: $scope.buyInfo.qty,
|
||||
priceUuid: $scope.buyInfo.priceUuid,
|
||||
useCurrentPrice: false,
|
||||
ip: null
|
||||
};
|
||||
glideraService.buy($scope.token, twoFaCode, data, function(err, data) {
|
||||
ongoingProcess.set('buyingBitcoin', false, statusChangeHandler);
|
||||
if (err) return showError(err);
|
||||
$log.info(data);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
$scope.showWalletSelector = function() {
|
||||
$scope.walletSelectorTitle = 'Receive in';
|
||||
$scope.showWallets = true;
|
||||
};
|
||||
|
||||
$scope.onWalletSelect = function(wallet) {
|
||||
$scope.wallet = wallet;
|
||||
};
|
||||
|
||||
$scope.goBackHome = function() {
|
||||
$scope.sendStatus = '';
|
||||
$ionicHistory.nextViewOptions({
|
||||
disableAnimate: true,
|
||||
historyRoot: true
|
||||
});
|
||||
$ionicHistory.clearHistory();
|
||||
$state.go('tabs.home').then(function() {
|
||||
$state.transitionTo('tabs.buyandsell.glidera');
|
||||
});
|
||||
};
|
||||
});
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copayApp.controllers').controller('confirmController', function($rootScope, $scope, $interval, $filter, $timeout, $ionicScrollDelegate, gettextCatalog, walletService, platformInfo, lodash, configService, rateService, $stateParams, $window, $state, $log, profileService, bitcore, txFormatService, ongoingProcess, $ionicModal, popupService, $ionicHistory, $ionicConfig, payproService, feeService, glideraService, bwcError, bitpayCardService) {
|
||||
angular.module('copayApp.controllers').controller('confirmController', function($rootScope, $scope, $interval, $filter, $timeout, $ionicScrollDelegate, gettextCatalog, walletService, platformInfo, lodash, configService, rateService, $stateParams, $window, $state, $log, profileService, bitcore, txFormatService, ongoingProcess, $ionicModal, popupService, $ionicHistory, $ionicConfig, payproService, feeService, bwcError, bitpayCardService) {
|
||||
var cachedTxp = {};
|
||||
var toAmount;
|
||||
var isChromeApp = platformInfo.isChromeApp;
|
||||
|
|
@ -11,10 +11,6 @@ angular.module('copayApp.controllers').controller('confirmController', function(
|
|||
|
||||
$scope.$on("$ionicView.beforeEnter", function(event, data) {
|
||||
|
||||
// Glidera parameters
|
||||
$scope.isGlidera = data.stateParams.isGlidera;
|
||||
$scope.glideraAccessToken = data.stateParams.glideraAccessToken;
|
||||
|
||||
toAmount = data.stateParams.toAmount;
|
||||
cachedSendMax = {};
|
||||
$scope.useSendMax = data.stateParams.useSendMax == 'true' ? true : false;
|
||||
|
|
@ -39,8 +35,7 @@ angular.module('copayApp.controllers').controller('confirmController', function(
|
|||
var config = configService.getSync().wallet;
|
||||
var feeLevel = config.settings && config.settings.feeLevel ? config.settings.feeLevel : 'normal';
|
||||
$scope.feeLevel = feeService.feeOpts[feeLevel];
|
||||
if ($scope.isGlidera) $scope.network = glideraService.getEnvironment();
|
||||
else $scope.network = (new bitcore.Address($scope.toAddress)).network.name;
|
||||
$scope.network = (new bitcore.Address($scope.toAddress)).network.name;
|
||||
resetValues();
|
||||
setwallets();
|
||||
applyButtonText();
|
||||
|
|
@ -49,7 +44,7 @@ angular.module('copayApp.controllers').controller('confirmController', function(
|
|||
function applyButtonText(multisig) {
|
||||
$scope.buttonText = $scope.isCordova ? gettextCatalog.getString('Slide') + ' ' : gettextCatalog.getString('Click') + ' ';
|
||||
|
||||
if ($scope.isGlidera || $scope.cardId) {
|
||||
if ($scope.cardId) {
|
||||
$scope.buttonText += gettextCatalog.getString('to complete');
|
||||
} else if ($scope.paypro) {
|
||||
$scope.buttonText += gettextCatalog.getString('to pay');
|
||||
|
|
@ -75,11 +70,6 @@ angular.module('copayApp.controllers').controller('confirmController', function(
|
|||
return;
|
||||
}
|
||||
|
||||
if ($scope.isGlidera == 'buy') {
|
||||
initConfirm();
|
||||
return;
|
||||
}
|
||||
|
||||
var filteredWallets = [];
|
||||
var index = 0;
|
||||
var enoughFunds = false;
|
||||
|
|
@ -161,8 +151,6 @@ angular.module('copayApp.controllers').controller('confirmController', function(
|
|||
$scope.alternativeAmountStr = v;
|
||||
});
|
||||
}
|
||||
if ($scope.isGlidera == 'buy') $scope.getBuyPrice();
|
||||
if ($scope.isGlidera == 'sell') $scope.getSellPrice();
|
||||
};
|
||||
|
||||
function resetValues() {
|
||||
|
|
@ -271,7 +259,7 @@ angular.module('copayApp.controllers').controller('confirmController', function(
|
|||
});
|
||||
|
||||
$scope.showWalletSelector = function() {
|
||||
$scope.walletSelectorTitle = $scope.isGlidera == 'buy' ? 'Receive in' : $scope.isGlidera == 'sell' ? 'Sell From' : gettextCatalog.getString('Send from');
|
||||
$scope.walletSelectorTitle = gettextCatalog.getString('Send from');
|
||||
if (!$scope.useSendMax && ($scope.insufficientFunds || $scope.noMatchingWallet)) return;
|
||||
$scope.showWallets = true;
|
||||
};
|
||||
|
|
@ -350,7 +338,6 @@ angular.module('copayApp.controllers').controller('confirmController', function(
|
|||
$scope.wallet = wallet;
|
||||
$scope.fee = $scope.txp = null;
|
||||
|
||||
if ($scope.isGlidera) return;
|
||||
if (stop) {
|
||||
$timeout.cancel(stop);
|
||||
stop = null;
|
||||
|
|
@ -476,47 +463,6 @@ angular.module('copayApp.controllers').controller('confirmController', function(
|
|||
return;
|
||||
}
|
||||
|
||||
if ($scope.isGlidera) {
|
||||
$scope.get2faCode(function(err, sent) {
|
||||
if (err) {
|
||||
popupService.showAlert(gettextCatalog.getString('Error'), gettextCatalog.getString('Could not send confirmation code to your phone'));
|
||||
return;
|
||||
}
|
||||
if (sent) {
|
||||
var title = gettextCatalog.getString("Please, enter the code below");
|
||||
var message = gettextCatalog.getString("A SMS containing a confirmation code was sent to your phone.");
|
||||
popupService.showPrompt(title, message, null, function(twoFaCode) {
|
||||
if (typeof twoFaCode == 'undefined') return;
|
||||
if ($scope.isGlidera == 'buy') {
|
||||
$scope.buyRequest(wallet, twoFaCode, function(err, data) {
|
||||
if (err) {
|
||||
popupService.showAlert(gettextCatalog.getString('Error'), err);
|
||||
return;
|
||||
}
|
||||
$scope.sendStatus = 'success';
|
||||
$timeout(function() {
|
||||
$scope.$digest();
|
||||
});
|
||||
})
|
||||
}
|
||||
if ($scope.isGlidera == 'sell') {
|
||||
$scope.sellRequest(wallet, twoFaCode, function(err, data) {
|
||||
if (err) {
|
||||
popupService.showAlert(gettextCatalog.getString('Error'), err);
|
||||
return;
|
||||
}
|
||||
$scope.sendStatus = 'success';
|
||||
$timeout(function() {
|
||||
$scope.$digest();
|
||||
});
|
||||
})
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
ongoingProcess.set('creatingTx', true, onSendStatusChange);
|
||||
createTx(wallet, false, function(err, txp) {
|
||||
ongoingProcess.set('creatingTx', false, onSendStatusChange);
|
||||
|
|
@ -587,7 +533,6 @@ angular.module('copayApp.controllers').controller('confirmController', function(
|
|||
$scope.onSuccessConfirm = function() {
|
||||
var previousView = $ionicHistory.viewHistory().backView && $ionicHistory.viewHistory().backView.stateName;
|
||||
var fromBitPayCard = previousView.match(/tabs.bitpayCard/) ? true : false;
|
||||
var fromGlidera = previousView.match(/tabs.buyandsell.glidera/) ? true : false;
|
||||
|
||||
$ionicHistory.nextViewOptions({
|
||||
disableAnimate: true
|
||||
|
|
@ -601,15 +546,6 @@ angular.module('copayApp.controllers').controller('confirmController', function(
|
|||
id: $stateParams.cardId
|
||||
});
|
||||
}, 100);
|
||||
} else if (fromGlidera) {
|
||||
$ionicHistory.nextViewOptions({
|
||||
disableAnimate: true,
|
||||
historyRoot: true
|
||||
});
|
||||
$ionicHistory.clearHistory();
|
||||
$state.go('tabs.home').then(function() {
|
||||
$state.transitionTo('tabs.buyandsell.glidera');
|
||||
});
|
||||
} else {
|
||||
$ionicHistory.nextViewOptions({
|
||||
disableAnimate: true,
|
||||
|
|
@ -622,162 +558,6 @@ angular.module('copayApp.controllers').controller('confirmController', function(
|
|||
}
|
||||
};
|
||||
|
||||
$scope.get2faCode = function(cb) {
|
||||
ongoingProcess.set('sending2faCode', true);
|
||||
$timeout(function() {
|
||||
glideraService.get2faCode($scope.glideraAccessToken, function(err, sent) {
|
||||
ongoingProcess.set('sending2faCode', false);
|
||||
return cb(err, sent);
|
||||
});
|
||||
}, 100);
|
||||
};
|
||||
|
||||
$scope.buyRequest = function(wallet, twoFaCode, cb) {
|
||||
ongoingProcess.set('buyingBitcoin', true);
|
||||
$timeout(function() {
|
||||
walletService.getAddress(wallet, false, function(err, walletAddr) {
|
||||
if (err) {
|
||||
ongoingProcess.set('buyingBitcoin', false);
|
||||
popupService.showAlert(gettextCatalog.getString('Error'), bwcError.cb(err, 'Could not create address'));
|
||||
return;
|
||||
}
|
||||
var data = {
|
||||
destinationAddress: walletAddr,
|
||||
qty: $scope.buyPrice.qty,
|
||||
priceUuid: $scope.buyPrice.priceUuid,
|
||||
useCurrentPrice: false,
|
||||
ip: null
|
||||
};
|
||||
glideraService.buy($scope.glideraAccessToken, twoFaCode, data, function(err, data) {
|
||||
ongoingProcess.set('buyingBitcoin', false);
|
||||
return cb(err, data);
|
||||
});
|
||||
});
|
||||
}, 100);
|
||||
};
|
||||
|
||||
$scope.sellRequest = function(wallet, twoFaCode, cb) {
|
||||
var outputs = [];
|
||||
var config = configService.getSync();
|
||||
var configWallet = config.wallet;
|
||||
var walletSettings = configWallet.settings;
|
||||
|
||||
ongoingProcess.set('creatingTx', true);
|
||||
walletService.getAddress(wallet, null, function(err, refundAddress) {
|
||||
if (!refundAddress) {
|
||||
ongoingProcess.clear();
|
||||
popupService.showAlert(gettextCatalog.getString('Error'), bwcError.msg(err, 'Could not create address'));
|
||||
return;
|
||||
}
|
||||
glideraService.getSellAddress($scope.glideraAccessToken, function(err, sellAddress) {
|
||||
if (!sellAddress || err) {
|
||||
ongoingProcess.clear();
|
||||
popupService.showAlert(gettextCatalog.getString('Error'), gettextCatalog.getString('Could not get the destination bitcoin address'));
|
||||
return;
|
||||
}
|
||||
var amount = parseInt(($scope.sellPrice.qty * 100000000).toFixed(0));
|
||||
var comment = 'Glidera transaction';
|
||||
|
||||
outputs.push({
|
||||
'toAddress': sellAddress,
|
||||
'amount': amount,
|
||||
'message': comment
|
||||
});
|
||||
|
||||
var txp = {
|
||||
toAddress: sellAddress,
|
||||
amount: amount,
|
||||
outputs: outputs,
|
||||
message: comment,
|
||||
payProUrl: null,
|
||||
excludeUnconfirmedUtxos: configWallet.spendUnconfirmed ? false : true,
|
||||
feeLevel: walletSettings.feeLevel || 'normal',
|
||||
customData: {
|
||||
'glideraToken': $scope.glideraAccessToken
|
||||
}
|
||||
};
|
||||
|
||||
walletService.createTx(wallet, txp, function(err, createdTxp) {
|
||||
ongoingProcess.clear();
|
||||
if (err) {
|
||||
popupService.showAlert(gettextCatalog.getString('Error'), err.message || bwcError.msg(err));
|
||||
return;
|
||||
}
|
||||
walletService.prepare(wallet, function(err, password) {
|
||||
if (err) {
|
||||
ongoingProcess.clear();
|
||||
popupService.showAlert(gettextCatalog.getString('Error'), err.message || bwcError.msg(err));
|
||||
return;
|
||||
}
|
||||
ongoingProcess.set('signingTx', true);
|
||||
walletService.publishTx(wallet, createdTxp, function(err, publishedTxp) {
|
||||
if (err) {
|
||||
ongoingProcess.clear();
|
||||
popupService.showAlert(gettextCatalog.getString('Error'), err.message || bwcError.msg(err));
|
||||
return;
|
||||
}
|
||||
|
||||
walletService.signTx(wallet, publishedTxp, password, function(err, signedTxp) {
|
||||
if (err) {
|
||||
ongoingProcess.clear();
|
||||
popupService.showAlert(gettextCatalog.getString('Error'), err.message || bwcError.msg(err));
|
||||
walletService.removeTx(wallet, signedTxp, function(err) {
|
||||
if (err) $log.debug(err);
|
||||
});
|
||||
return;
|
||||
}
|
||||
var rawTx = signedTxp.raw;
|
||||
var data = {
|
||||
refundAddress: refundAddress,
|
||||
signedTransaction: rawTx,
|
||||
priceUuid: $scope.sellPrice.priceUuid,
|
||||
useCurrentPrice: $scope.sellPrice.priceUuid ? false : true,
|
||||
ip: null
|
||||
};
|
||||
ongoingProcess.set('sellingBitcoin', true);
|
||||
glideraService.sell($scope.glideraAccessToken, twoFaCode, data, function(err, data) {
|
||||
ongoingProcess.clear();
|
||||
if (err) {
|
||||
popupService.showAlert(gettextCatalog.getString('Error'), err.message || bwcError.msg(err));
|
||||
return;
|
||||
}
|
||||
return cb(err, data)
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
$scope.getBuyPrice = function() {
|
||||
var satToBtc = 1 / 100000000;
|
||||
var price = {};
|
||||
price.qty = (toAmount * satToBtc).toFixed(8);
|
||||
glideraService.buyPrice($scope.glideraAccessToken, price, function(err, buyPrice) {
|
||||
if (err) {
|
||||
popupService.showAlert(gettextCatalog.getString('Error'), 'Could not get exchange information. Please, try again');
|
||||
return;
|
||||
}
|
||||
$scope.buyPrice = buyPrice;
|
||||
});
|
||||
};
|
||||
|
||||
$scope.getSellPrice = function() {
|
||||
var satToBtc = 1 / 100000000;
|
||||
var price = {};
|
||||
price.qty = (toAmount * satToBtc).toFixed(8);
|
||||
|
||||
glideraService.sellPrice($scope.glideraAccessToken, price, function(err, sellPrice) {
|
||||
if (err) {
|
||||
popupService.showAlert(gettextCatalog.getString('Error'), 'Could not get exchange information. Please, try again');
|
||||
return;
|
||||
}
|
||||
$scope.sellPrice = sellPrice;
|
||||
});
|
||||
};
|
||||
|
||||
function publishAndSign(wallet, txp, onSendStatusChange) {
|
||||
|
||||
if (!wallet.canSign() && !wallet.isPrivKeyExternal()) {
|
||||
|
|
|
|||
|
|
@ -92,20 +92,13 @@ angular.module('copayApp.controllers').controller('glideraController',
|
|||
externalLinkService.open(url, optIn, title, message, okText, cancelText);
|
||||
}
|
||||
|
||||
$scope.retry = function() {
|
||||
$scope.connectingGlidera = true;
|
||||
$scope.update({'fullUpdate': true});
|
||||
$timeout(function(){
|
||||
$scope.connectingGlidera = false;
|
||||
}, 300);
|
||||
}
|
||||
|
||||
$scope.toggleOauthForm = function() {
|
||||
$scope.showOauthForm = !$scope.showOauthForm;
|
||||
}
|
||||
|
||||
$scope.$on("$ionicView.beforeEnter", function(event, data) {
|
||||
$scope.network = glideraService.getNetwork();
|
||||
$scope.currency = glideraService.getCurrency();
|
||||
$scope.showOauthForm = false;
|
||||
$scope.account = {};
|
||||
if (data.stateParams && data.stateParams.code) {
|
||||
|
|
|
|||
231
src/js/controllers/sellGlidera.js
Normal file
231
src/js/controllers/sellGlidera.js
Normal file
|
|
@ -0,0 +1,231 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copayApp.controllers').controller('sellGlideraController', function($scope, $log, $state, $timeout, $ionicHistory, lodash, glideraService, popupService, profileService, ongoingProcess, walletService, configService) {
|
||||
|
||||
var amount;
|
||||
var currency;
|
||||
|
||||
var showErrorAndBack = function(err) {
|
||||
$scope.sendStatus = '';
|
||||
$log.error(err);
|
||||
err = err.errors ? err.errors[0].message : err;
|
||||
popupService.showAlert('Error', err, function() {
|
||||
$ionicHistory.goBack();
|
||||
});
|
||||
};
|
||||
|
||||
var showError = function(err) {
|
||||
$scope.sendStatus = '';
|
||||
$log.error(err);
|
||||
err = err.errors ? err.errors[0].message : err;
|
||||
popupService.showAlert('Error', err);
|
||||
};
|
||||
|
||||
var statusChangeHandler = function (processName, showName, isOn) {
|
||||
$log.debug('statusChangeHandler: ', processName, showName, isOn);
|
||||
if ( processName == 'sellingBitcoin' && !isOn) {
|
||||
$scope.sendStatus = 'success';
|
||||
$timeout(function() {
|
||||
$scope.$digest();
|
||||
}, 100);
|
||||
} else if (showName) {
|
||||
$scope.sendStatus = showName;
|
||||
}
|
||||
};
|
||||
|
||||
$scope.$on("$ionicView.beforeEnter", function(event, data) {
|
||||
$scope.isFiat = data.stateParams.currency ? true : false;
|
||||
var parsedAmount = glideraService.parseAmount(
|
||||
data.stateParams.amount,
|
||||
data.stateParams.currency);
|
||||
|
||||
amount = parsedAmount.amount;
|
||||
currency = parsedAmount.currency;
|
||||
$scope.amountUnitStr = parsedAmount.amountUnitStr;
|
||||
|
||||
$scope.network = glideraService.getNetwork();
|
||||
$scope.wallets = profileService.getWallets({
|
||||
m: 1, // Only 1-signature wallet
|
||||
onlyComplete: true,
|
||||
network: $scope.network
|
||||
});
|
||||
$scope.wallet = $scope.wallets[0]; // Default first wallet
|
||||
|
||||
ongoingProcess.set('connectingGlidera', true);
|
||||
glideraService.init(function(err, data) {
|
||||
if (err) {
|
||||
ongoingProcess.set('connectingGlidera', false);
|
||||
showErrorAndBack(err);
|
||||
return;
|
||||
}
|
||||
$scope.token = data.token;
|
||||
var price = {};
|
||||
if ($scope.isFiat) {
|
||||
price['fiat'] = amount;
|
||||
} else {
|
||||
price['qty'] = amount;
|
||||
}
|
||||
glideraService.sellPrice($scope.token, price, function(err, sell) {
|
||||
ongoingProcess.set('connectingGlidera', false);
|
||||
if (err) {
|
||||
showErrorAndBack(err);
|
||||
return;
|
||||
}
|
||||
$scope.sellInfo = sell;
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
var ask2FaCode = function(mode, cb) {
|
||||
if (mode != 'NONE') {
|
||||
// SHOW PROMPT
|
||||
var title = 'Please, enter the code below';
|
||||
var message;
|
||||
if (mode == 'PIN') {
|
||||
message = 'You have enabled PIN based two-factor authentication.';
|
||||
} else if (mode == 'AUTHENTICATOR') {
|
||||
message = 'Use an authenticator app (Authy or Google Authenticator).';
|
||||
} else {
|
||||
message = 'A SMS containing a confirmation code was sent to your phone.';
|
||||
}
|
||||
popupService.showPrompt(title, message, null, function(twoFaCode) {
|
||||
if (typeof twoFaCode == 'undefined') return cb();
|
||||
return cb(twoFaCode);
|
||||
});
|
||||
} else {
|
||||
return cb();
|
||||
}
|
||||
};
|
||||
|
||||
$scope.sellConfirm = function() {
|
||||
var message = 'Sell bitcoin for ' + amount + ' ' + currency;
|
||||
var okText = 'Confirm';
|
||||
var cancelText = 'Cancel';
|
||||
popupService.showConfirm(null, message, okText, cancelText, function(ok) {
|
||||
if (!ok) return;
|
||||
ongoingProcess.set('sellingBitcoin', true, statusChangeHandler);
|
||||
glideraService.get2faCode($scope.token, function(err, tfa) {
|
||||
if (err) {
|
||||
ongoingProcess.set('sellingBitcoin', false, statusChangeHandler);
|
||||
showError(err);
|
||||
return;
|
||||
}
|
||||
ask2FaCode(tfa.mode, function(twoFaCode) {
|
||||
if (tfa.mode != 'NONE' && lodash.isEmpty(twoFaCode)) {
|
||||
ongoingProcess.set('sellingBitcoin', false, statusChangeHandler);
|
||||
showError('No code entered');
|
||||
return;
|
||||
}
|
||||
|
||||
var outputs = [];
|
||||
var config = configService.getSync();
|
||||
var configWallet = config.wallet;
|
||||
var walletSettings = configWallet.settings;
|
||||
|
||||
walletService.getAddress($scope.wallet, null, function(err, refundAddress) {
|
||||
if (!refundAddress) {
|
||||
ongoingProcess.set('sellingBitcoin', false, statusChangeHandler);
|
||||
showError('Could not create address');
|
||||
return;
|
||||
}
|
||||
glideraService.getSellAddress($scope.token, function(err, sellAddress) {
|
||||
if (!sellAddress || err) {
|
||||
ongoingProcess.set('sellingBitcoin', false, statusChangeHandler);
|
||||
showError(err);
|
||||
return;
|
||||
}
|
||||
var amount = parseInt(($scope.sellInfo.qty * 100000000).toFixed(0));
|
||||
var comment = 'Glidera transaction';
|
||||
|
||||
outputs.push({
|
||||
'toAddress': sellAddress,
|
||||
'amount': amount,
|
||||
'message': comment
|
||||
});
|
||||
|
||||
var txp = {
|
||||
toAddress: sellAddress,
|
||||
amount: amount,
|
||||
outputs: outputs,
|
||||
message: comment,
|
||||
payProUrl: null,
|
||||
excludeUnconfirmedUtxos: configWallet.spendUnconfirmed ? false : true,
|
||||
feeLevel: walletSettings.feeLevel || 'normal',
|
||||
customData: {
|
||||
'glideraToken': $scope.token
|
||||
}
|
||||
};
|
||||
|
||||
walletService.createTx($scope.wallet, txp, function(err, createdTxp) {
|
||||
if (err) {
|
||||
ongoingProcess.set('sellingBitcoin', false, statusChangeHandler);
|
||||
showError(err);
|
||||
return;
|
||||
}
|
||||
walletService.prepare($scope.wallet, function(err, password) {
|
||||
if (err) {
|
||||
ongoingProcess.set('sellingBitcoin', false, statusChangeHandler);
|
||||
showError(err);
|
||||
return;
|
||||
}
|
||||
walletService.publishTx($scope.wallet, createdTxp, function(err, publishedTxp) {
|
||||
if (err) {
|
||||
ongoingProcess.set('sellingBitcoin', false, statusChangeHandler);
|
||||
showError(err);
|
||||
return;
|
||||
}
|
||||
walletService.signTx($scope.wallet, publishedTxp, password, function(err, signedTxp) {
|
||||
if (err) {
|
||||
ongoingProcess.set('sellingBitcoin', false, statusChangeHandler);
|
||||
showError(err);
|
||||
walletService.removeTx($scope.wallet, signedTxp, function(err) {
|
||||
if (err) $log.debug(err);
|
||||
});
|
||||
return;
|
||||
}
|
||||
var rawTx = signedTxp.raw;
|
||||
var data = {
|
||||
refundAddress: refundAddress,
|
||||
signedTransaction: rawTx,
|
||||
priceUuid: $scope.sellInfo.priceUuid,
|
||||
useCurrentPrice: $scope.sellInfo.priceUuid ? false : true,
|
||||
ip: null
|
||||
};
|
||||
glideraService.sell($scope.token, twoFaCode, data, function(err, data) {
|
||||
ongoingProcess.set('sellingBitcoin', false, statusChangeHandler);
|
||||
if (err) return showError(err);
|
||||
$log.info(data);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
$scope.showWalletSelector = function() {
|
||||
$scope.walletSelectorTitle = 'Sell From';
|
||||
$scope.showWallets = true;
|
||||
};
|
||||
|
||||
$scope.onWalletSelect = function(wallet) {
|
||||
$scope.wallet = wallet;
|
||||
};
|
||||
|
||||
$scope.goBackHome = function() {
|
||||
$scope.sendStatus = '';
|
||||
$ionicHistory.nextViewOptions({
|
||||
disableAnimate: true,
|
||||
historyRoot: true
|
||||
});
|
||||
$ionicHistory.clearHistory();
|
||||
$state.go('tabs.home').then(function() {
|
||||
$state.transitionTo('tabs.buyandsell.glidera');
|
||||
});
|
||||
};
|
||||
|
||||
});
|
||||
|
|
@ -885,7 +885,7 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr
|
|||
}
|
||||
})
|
||||
.state('tabs.buyandsell.glidera.amount', {
|
||||
url: '/amount/:isGlidera/:glideraAccessToken',
|
||||
url: '/amount/:nextStep/:currency',
|
||||
views: {
|
||||
'tab-home@tabs': {
|
||||
controller: 'amountController',
|
||||
|
|
@ -893,12 +893,21 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr
|
|||
}
|
||||
}
|
||||
})
|
||||
.state('tabs.buyandsell.glidera.confirm', {
|
||||
url: '/confirm/:toAmount/:isGlidera/:glideraAccessToken',
|
||||
.state('tabs.buyandsell.glidera.buy', {
|
||||
url: '/buy/:amount/:currency',
|
||||
views: {
|
||||
'tab-home@tabs': {
|
||||
controller: 'confirmController',
|
||||
templateUrl: 'views/confirm.html'
|
||||
controller: 'buyGlideraController',
|
||||
templateUrl: 'views/buyGlidera.html'
|
||||
}
|
||||
}
|
||||
})
|
||||
.state('tabs.buyandsell.glidera.sell', {
|
||||
url: '/sell/:amount/:currency',
|
||||
views: {
|
||||
'tab-home@tabs': {
|
||||
controller: 'sellGlideraController',
|
||||
templateUrl: 'views/sellGlidera.html'
|
||||
}
|
||||
}
|
||||
})
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copayApp.services').factory('glideraService', function($http, $log, $window, platformInfo, storageService, buyAndSellService, lodash) {
|
||||
angular.module('copayApp.services').factory('glideraService', function($http, $log, $window, $filter, platformInfo, storageService, buyAndSellService, lodash, configService, txFormatService) {
|
||||
var root = {};
|
||||
var credentials = {};
|
||||
var isCordova = platformInfo.isCordova;
|
||||
|
|
@ -49,6 +49,34 @@ angular.module('copayApp.services').factory('glideraService', function($http, $l
|
|||
return credentials.NETWORK;
|
||||
};
|
||||
|
||||
root.getCurrency = function() {
|
||||
return 'USD';
|
||||
};
|
||||
|
||||
root.parseAmount = function(amount, currency) {
|
||||
var config = configService.getSync().wallet.settings;
|
||||
var satToBtc = 1 / 100000000;
|
||||
var unitToSatoshi = config.unitToSatoshi;
|
||||
var amountUnitStr;
|
||||
|
||||
// IF 'USD'
|
||||
if (currency) {
|
||||
amountUnitStr = $filter('formatFiatAmount')(amount) + ' ' + currency;
|
||||
} else {
|
||||
var amountSat = parseInt((amount * unitToSatoshi).toFixed(0));
|
||||
amountUnitStr = txFormatService.formatAmountStr(amountSat);
|
||||
// convert unit to BTC
|
||||
amount = (amountSat * satToBtc).toFixed(8);
|
||||
currency = 'BTC';
|
||||
}
|
||||
|
||||
return {
|
||||
amount: amount,
|
||||
currency: currency,
|
||||
amountUnitStr: amountUnitStr
|
||||
};
|
||||
};
|
||||
|
||||
root.getSignupUrl = function() {
|
||||
return credentials.HOST + '/register';
|
||||
}
|
||||
|
|
@ -225,18 +253,13 @@ angular.module('copayApp.services').factory('glideraService', function($http, $l
|
|||
};
|
||||
|
||||
root.get2faCode = function(token, cb) {
|
||||
if (!token) {
|
||||
$log.error('Glidera Sent 2FA code by SMS: ERROR Invalid Token');
|
||||
return cb('Invalid Token');
|
||||
}
|
||||
|
||||
if (!token) return cb('Invalid Token');
|
||||
$http(_get('/authentication/get2faCode', token)).then(function(data) {
|
||||
|
||||
$log.info('Glidera Sent 2FA code by SMS: SUCCESS');
|
||||
return cb(null, data.status == 200 ? true : false);
|
||||
$log.info('Glidera 2FA code: SUCCESS');
|
||||
return cb(null, data.data);
|
||||
}, function(data) {
|
||||
$log.error('Glidera Sent 2FA code by SMS: ERROR ' + data.statusText);
|
||||
return cb('Glidera Sent 2FA code by SMS: ERROR ' + data.statusText);
|
||||
$log.error('Glidera 2FA code: ERROR ' + data.statusText);
|
||||
return cb('Glidera 2FA code: ERROR ' + data.statusText);
|
||||
});
|
||||
};
|
||||
|
||||
|
|
@ -248,7 +271,7 @@ angular.module('copayApp.services').factory('glideraService', function($http, $l
|
|||
'Content-Type': 'application/json',
|
||||
'Accept': 'application/json',
|
||||
'Authorization': 'Bearer ' + token,
|
||||
'2FA_CODE': twoFaCode
|
||||
'X-2FA-CODE': twoFaCode
|
||||
},
|
||||
data: data
|
||||
};
|
||||
|
|
@ -308,6 +331,7 @@ angular.module('copayApp.services').factory('glideraService', function($http, $l
|
|||
ip: data.ip
|
||||
};
|
||||
$http(_post('/buy', token, twoFaCode, data)).then(function(data) {
|
||||
console.log('[glideraService.js:333]',data); //TODO
|
||||
$log.info('Glidera Buy: SUCCESS');
|
||||
return cb(null, data.data);
|
||||
}, function(data) {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,136 @@
|
|||
#glidera {
|
||||
$item-lateral-padding: 20px;
|
||||
$item-vertical-padding: 10px;
|
||||
$item-border-color: #EFEFEF;
|
||||
$item-label-color: #6C6C6E;
|
||||
@extend .deflash-blue;
|
||||
|
||||
.spinner svg {
|
||||
stroke: #0067c8;
|
||||
fill: #0067c8;
|
||||
}
|
||||
|
||||
.add-bottom-for-cta {
|
||||
bottom: 92px;
|
||||
}
|
||||
.head {
|
||||
padding: 30px $item-lateral-padding 4rem;
|
||||
border-top: 0;
|
||||
|
||||
.sending-label {
|
||||
display: flex;
|
||||
font-size: 18px;
|
||||
align-items: center;
|
||||
margin-bottom: 1.5rem;
|
||||
|
||||
img {
|
||||
margin-right: 1rem;
|
||||
height: 35px;
|
||||
width: 35px;
|
||||
}
|
||||
|
||||
span {
|
||||
text-transform: capitalize;
|
||||
}
|
||||
}
|
||||
.amount-label{
|
||||
line-height: 30px;
|
||||
.amount{
|
||||
font-size: 38px;
|
||||
margin-bottom: .5rem;
|
||||
|
||||
> .unit {
|
||||
font-family: "Roboto-Light";
|
||||
}
|
||||
}
|
||||
.alternative {
|
||||
font-size: 16px;
|
||||
font-family: "Roboto-Light";
|
||||
color: #9B9B9B;
|
||||
}
|
||||
}
|
||||
}
|
||||
.item {
|
||||
border-color: $item-border-color;
|
||||
}
|
||||
.info {
|
||||
.badge {
|
||||
border-radius: 0;
|
||||
padding: .5rem;
|
||||
}
|
||||
.item {
|
||||
color: #4A4A4A;
|
||||
padding-top: $item-vertical-padding;
|
||||
padding-bottom: $item-vertical-padding;
|
||||
padding-left: $item-lateral-padding;
|
||||
|
||||
&:not(.item-icon-right) {
|
||||
padding-right: $item-lateral-padding;
|
||||
}
|
||||
|
||||
.label {
|
||||
font-size: 14px;
|
||||
color: $item-label-color;
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
|
||||
.capitalized {
|
||||
text-transform: capitalize;
|
||||
}
|
||||
|
||||
.wallet .big-icon-svg > .bg {
|
||||
height: 24px;
|
||||
width: 24px;
|
||||
padding: 2px;
|
||||
box-shadow: none;
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
.total-amount {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
&.single-line {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
padding-top: 17px;
|
||||
padding-bottom: 17px;
|
||||
|
||||
.label {
|
||||
margin: 0;
|
||||
flex-grow: 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
.item-divider {
|
||||
padding-top: 1.2rem;
|
||||
color: $item-label-color;
|
||||
font-size: 15px;
|
||||
}
|
||||
.wallet {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
padding: .2rem 0;
|
||||
margin-bottom: 5px;
|
||||
|
||||
~ .bp-arrow-right {
|
||||
top: 14px;
|
||||
}
|
||||
|
||||
> i {
|
||||
padding: 0;
|
||||
position: static;
|
||||
|
||||
> img {
|
||||
height: 24px;
|
||||
width: 24px;
|
||||
padding: 2px;
|
||||
margin-right: .7rem;
|
||||
box-shadow: none;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
.glidera-lead {
|
||||
margin: 2rem 1rem;
|
||||
color: $dark-gray;
|
||||
|
|
|
|||
103
www/views/buyGlidera.html
Normal file
103
www/views/buyGlidera.html
Normal file
|
|
@ -0,0 +1,103 @@
|
|||
<ion-view id="glidera" hide-tabs>
|
||||
<ion-nav-bar class="bar-royal">
|
||||
<ion-nav-back-button>
|
||||
</ion-nav-back-button>
|
||||
<ion-nav-title>Buy bitcoin</ion-nav-title>
|
||||
</ion-nav-bar>
|
||||
|
||||
<ion-content class="add-bottom-for-cta">
|
||||
<!-- BUY -->
|
||||
<div class="list" ng-if="buyInfo">
|
||||
|
||||
<div class="item head">
|
||||
<div class="sending-label">
|
||||
<img src="img/buy-bitcoin.svg" alt="buy bitcoin" width="35" class="item-img-buy">
|
||||
<span>Buying</span>
|
||||
</div>
|
||||
<div class="amount-label">
|
||||
<div class="amount">{{amountUnitStr}}</div>
|
||||
<div class="alternative">
|
||||
<span ng-show="!isFiat">{{buyInfo.subtotal}} {{buyInfo.currency}}</span>
|
||||
<span ng-show="isFiat">{{buyInfo.qty}} BTC</span>
|
||||
@ ${{buyInfo.price}} per BTC
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="info">
|
||||
|
||||
<div class="item item-icon-right" ng-click="showWalletSelector()">
|
||||
<div class="label">Receive in</div>
|
||||
<div class="wallet">
|
||||
<i class="icon big-icon-svg">
|
||||
<img src="img/icon-wallet.svg" ng-style="{'background-color': wallet.color}" class="bg">
|
||||
</i>
|
||||
{{wallet ? wallet.name : '...'}}
|
||||
</div>
|
||||
<i class="icon bp-arrow-right"></i>
|
||||
</div>
|
||||
|
||||
<div class="item item-divider">
|
||||
Transaction details
|
||||
</div>
|
||||
<div class="item">
|
||||
Expires
|
||||
<span class="item-note">
|
||||
{{buyInfo.expires | amCalendar}}
|
||||
</span>
|
||||
</div>
|
||||
<div class="item">
|
||||
Fees
|
||||
<span class="item-note">
|
||||
{{buyInfo.fees}} {{buyInfo.currency}}
|
||||
</span>
|
||||
</div>
|
||||
<div class="item">
|
||||
Total to pay
|
||||
<span class="item-note total-amount">
|
||||
{{buyInfo.total}} {{buyInfo.currency}}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</ion-content>
|
||||
|
||||
<click-to-accept
|
||||
ng-disabled="!buyInfo || !wallet"
|
||||
ng-click="buyConfirm()"
|
||||
ng-if="!isCordova && buyInfo"
|
||||
click-send-status="sendStatus"
|
||||
has-wallet-chosen="wallet"
|
||||
insufficient-funds="false"
|
||||
no-matching-wallet="!buyInfo">
|
||||
Confirm purchase
|
||||
</click-to-accept>
|
||||
<slide-to-accept
|
||||
ng-disabled="!buyInfo || !wallet"
|
||||
ng-if="isCordova && buyInfo"
|
||||
slide-on-confirm="buyConfirm()"
|
||||
slide-send-status="sendStatus"
|
||||
has-wallet-chosen="wallet"
|
||||
insufficient-funds="false"
|
||||
no-matching-wallet="!buyInfo">
|
||||
Slide to buy
|
||||
</slide-to-accept>
|
||||
<slide-to-accept-success
|
||||
slide-success-show="sendStatus === 'success'"
|
||||
slide-success-on-confirm="goBackHome()"
|
||||
slide-success-hide-on-confirm="true">
|
||||
<span>Bought</span>
|
||||
<div class="m10 size-14">
|
||||
A transfer has been initiated from your bank account. Your bitcoins should arrive to your wallet in 2-4 business day
|
||||
</div>
|
||||
</slide-to-accept-success>
|
||||
|
||||
<wallet-selector
|
||||
wallet-selector-title="walletSelectorTitle"
|
||||
wallet-selector-wallets="wallets"
|
||||
wallet-selector-selected-wallet="wallet"
|
||||
wallet-selector-show="showWallets"
|
||||
wallet-selector-on-select="onWalletSelect">
|
||||
</wallet-selector>
|
||||
</ion-view>
|
||||
|
|
@ -12,10 +12,8 @@
|
|||
<div class="item head">
|
||||
<div class="sending-label">
|
||||
<img src="img/icon-tx-sent-outline.svg">
|
||||
<span translate ng-if="!useSendMax && !isGlidera">Sending</span>
|
||||
<span translate ng-if="!useSendMax">Sending</span>
|
||||
<span translate ng-if="useSendMax">Sending maximum amount</span>
|
||||
<span ng-if="isGlidera == 'buy'">Buying</span>
|
||||
<span ng-if="isGlidera == 'sell'">Selling</span>
|
||||
</div>
|
||||
<div class="amount-label">
|
||||
<div class="amount">{{displayAmount || '...'}} <span class="unit">{{displayUnit}}</span></div>
|
||||
|
|
@ -31,16 +29,13 @@
|
|||
</div>
|
||||
|
||||
<div class="item">
|
||||
<span class="label" ng-if="!isGlidera" translate>To</span>
|
||||
<span class="label" ng-if="isGlidera == 'buy'">From</span>
|
||||
<span class="label" ng-if="isGlidera == 'sell'">To</span>
|
||||
<span class="label" translate>To</span>
|
||||
<span class="payment-proposal-to">
|
||||
<img ng-if="!cardId && !isGiftCard && !isGlidera" src="img/icon-bitcoin-small.svg">
|
||||
<img ng-if="!cardId && !isGiftCard" src="img/icon-bitcoin-small.svg">
|
||||
<img ng-if="cardId" src="img/icon-card.svg" width="34">
|
||||
<i ng-if="isGiftCard" class="icon big-icon-svg">
|
||||
<div class="bg icon-amazon"></div>
|
||||
</i>
|
||||
<img ng-if="isGlidera" src="img/glidera-logo.png" width="90"/>
|
||||
|
||||
<div copy-to-clipboard="toAddress" ng-if="!paypro" class="ellipsis">
|
||||
<contact ng-if="!toName" address="{{toAddress}}"></contact>
|
||||
|
|
@ -58,9 +53,7 @@
|
|||
</span>
|
||||
</div>
|
||||
<a class="item item-icon-right" ng-hide="!useSendMax && (insufficientFunds || noMatchingWallet)" ng-click="showWalletSelector()">
|
||||
<span class="label" ng-if="!isGlidera" translate>From</span>
|
||||
<span class="label" ng-if="isGlidera == 'buy'">To</span>
|
||||
<span class="label" ng-if="isGlidera == 'sell'">From</span>
|
||||
<span class="label" translate>From</span>
|
||||
<div class="wallet" ng-if="wallet">
|
||||
<i class="icon big-icon-svg">
|
||||
<img src="img/icon-wallet.svg" ng-style="{'background-color': wallet.color}" class="bg"/>
|
||||
|
|
@ -75,47 +68,19 @@
|
|||
</div>
|
||||
<i class="icon bp-arrow-right"></i>
|
||||
</a>
|
||||
<a class="item single-line item-icon-right" ng-if="!insufficientFunds && !noMatchingWallet && !isGlidera" ng-click="showDescriptionPopup()">
|
||||
<a class="item single-line item-icon-right" ng-if="!insufficientFunds && !noMatchingWallet" ng-click="showDescriptionPopup()">
|
||||
<span class="label" translate>Add Memo</span>
|
||||
<span class="item-note m10l">
|
||||
{{description}}
|
||||
</span>
|
||||
<i class="icon bp-arrow-right"></i>
|
||||
</a>
|
||||
<div class="item single-line" ng-if="!insufficientFunds && !noMatchingWallet && !isGlidera">
|
||||
<div class="item single-line" ng-if="!insufficientFunds && !noMatchingWallet">
|
||||
<span class="label">{{'Fee' | translate}}: {{feeLevel | translate}}</span>
|
||||
<span class="item-note">
|
||||
{{fee || '...'}}
|
||||
</span>
|
||||
</div>
|
||||
<div class="item" ng-show="isGlidera == 'buy'">
|
||||
<span class="label">Information</span>
|
||||
<div class="glidera-explanation">
|
||||
<div class="glidera-description" ng-show="buyPrice.qty">
|
||||
Buy {{buyPrice.subtotal|currency:'':2}} {{buyPrice.currency}} in Bitcoin at {{buyPrice.price}} {{buyPrice.currency}}/BTC
|
||||
</div>
|
||||
<div class="glidera-description">
|
||||
Fiat will be immediately withdrawn from your bank account.
|
||||
</div>
|
||||
<div class="glidera-description">
|
||||
The bitcoins will be purchased and deposited to "{{wallet.name || '...' }}" wallet in 2-4 business days.
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="item" ng-show="isGlidera == 'sell'">
|
||||
<span class="label">Information</span>
|
||||
<div class="glidera-explanation">
|
||||
<div class="glidera-description" ng-show="sellPrice.qty">
|
||||
Sell {{sellPrice.subtotal|currency:'':2}} {{sellPrice.currency}} in Bitcoin at {{sellPrice.price|currency:'':2}} {{sellPrice.currency}}/BTC
|
||||
</div>
|
||||
<div class="glidera-description">
|
||||
Fiat will be deposited in your bank account in 4-6 business days.
|
||||
</div>
|
||||
<div class="glidera-description">
|
||||
Bitcoins will be immediately sent from your "{{wallet.name || '...' }}" wallet to Glidera.
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="text-center" ng-show="noMatchingWallet">
|
||||
<span class="badge badge-energized" translate>No wallets available</span>
|
||||
</div>
|
||||
|
|
@ -150,10 +115,6 @@
|
|||
<span ng-show="wallet.m == 1 && (wallet.canSign() || wallet.isPrivKeyExternal())" translate>Payment Sent</span>
|
||||
<span ng-show="wallet.m > 1 && (wallet.canSign() || wallet.isPrivKeyExternal())" translate>Proposal Created</span>
|
||||
<span ng-show="!wallet.canSign() && !wallet.isPrivKeyExternal()" translate>Transaction created</span>
|
||||
<div ng-show="isGlidera" class="glidera-success">
|
||||
<span ng-show="isGlidera == 'buy'">A transfer has been initiated from your bank account. Your bitcoins should arrive to your wallet in 2-4 business day</span>
|
||||
<span ng-show="isGlidera == 'sell'">A transfer has been initiated to your bank account. Should arrive in 4-6 business days</span>
|
||||
</div>
|
||||
</slide-to-accept-success>
|
||||
|
||||
<wallet-selector
|
||||
|
|
|
|||
|
|
@ -8,7 +8,8 @@
|
|||
<span ng-hide="showOauthForm">Enter Code</span>
|
||||
<span ng-show="showOauthForm">Restart</span>
|
||||
</button>
|
||||
<button class="button button-clear button-small ng-hide" ng-show="account.token && account.status && !account.status.userCanTransact" ng-click="retry()">
|
||||
<button class="button button-clear button-small ng-hide" ng-show="account.token && account.status &&
|
||||
!account.status.userCanTransact" ng-click="update()">
|
||||
Refresh
|
||||
</button>
|
||||
</ion-nav-buttons>
|
||||
|
|
@ -58,13 +59,13 @@
|
|||
|
||||
<ion-content class="ng-hide" ng-show="account.token && account.status && account.status.userCanTransact">
|
||||
<div class="text-center m20v">
|
||||
<img src="img/glidera-logo.png" width="170">
|
||||
<img src="img/glidera-logo.png" width="170" ng-click="update()">
|
||||
</div>
|
||||
|
||||
<div class="list card">
|
||||
<a ng-show="account.status.userCanBuy"
|
||||
class="item item-icon-right"
|
||||
href ui-sref="tabs.buyandsell.glidera.amount({isGlidera: 'buy', glideraAccessToken: account.token})">
|
||||
href ui-sref="tabs.buyandsell.glidera.amount({nextStep: 'tabs.buyandsell.glidera.buy', currency: currency})">
|
||||
<img src="img/buy-bitcoin.svg" alt="buy bitcoin" width="25" class="item-img-buy">
|
||||
Buy Bitcoin
|
||||
<span class="item-note" ng-show="account.price.buy">
|
||||
|
|
@ -74,7 +75,7 @@
|
|||
</a>
|
||||
<a class="item item-icon-right"
|
||||
ng-show="account.status.userCanSell"
|
||||
href ui-sref="tabs.buyandsell.glidera.amount({isGlidera: 'sell', glideraAccessToken: account.token})">
|
||||
href ui-sref="tabs.buyandsell.glidera.amount({nextStep: 'tabs.buyandsell.glidera.sell', currency: currency})">
|
||||
<img src="img/sell-bitcoin.svg" alt="buy bitcoin" width="25" class="item-img-sell">
|
||||
Sell Bitcoin
|
||||
<span class="item-note" ng-show="account.price.sell">
|
||||
|
|
|
|||
104
www/views/sellGlidera.html
Normal file
104
www/views/sellGlidera.html
Normal file
|
|
@ -0,0 +1,104 @@
|
|||
<ion-view id="glidera" hide-tabs>
|
||||
<ion-nav-bar class="bar-royal">
|
||||
<ion-nav-back-button>
|
||||
</ion-nav-back-button>
|
||||
<ion-nav-title>Sell bitcoin</ion-nav-title>
|
||||
</ion-nav-bar>
|
||||
|
||||
<ion-content class="add-bottom-for-cta">
|
||||
<!-- SELL -->
|
||||
<div class="list" ng-if="sellInfo">
|
||||
|
||||
<div class="item head">
|
||||
<div class="sending-label">
|
||||
<img src="img/sell-bitcoin.svg" alt="sell bitcoin" width="35" class="item-img-sell">
|
||||
<span>Selling</span>
|
||||
</div>
|
||||
<div class="amount-label">
|
||||
<div class="amount">{{amountUnitStr}}</div>
|
||||
<div class="alternative">
|
||||
<span ng-show="!isFiat">{{sellInfo.subtotal}} {{sellInfo.currency}}</span>
|
||||
<span ng-show="isFiat">{{sellInfo.qty}} BTC</span>
|
||||
@ ${{sellInfo.price}} per BTC
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="info">
|
||||
|
||||
<div class="item item-icon-right" ng-click="showWalletSelector()">
|
||||
<div class="label">From</div>
|
||||
<div class="wallet">
|
||||
<i class="icon big-icon-svg">
|
||||
<img src="img/icon-wallet.svg" ng-style="{'background-color': wallet.color}" class="bg">
|
||||
</i>
|
||||
{{wallet ? wallet.name : '...'}}
|
||||
</div>
|
||||
<i class="icon bp-arrow-right"></i>
|
||||
</div>
|
||||
|
||||
<div class="item item-divider">
|
||||
Transaction details
|
||||
</div>
|
||||
<div class="item">
|
||||
Expires
|
||||
<span class="item-note">
|
||||
{{sellInfo.expires | amCalendar}}
|
||||
</span>
|
||||
</div>
|
||||
<div class="item">
|
||||
Fees
|
||||
<span class="item-note">
|
||||
{{sellInfo.fees}} {{sellInfo.currency}}
|
||||
</span>
|
||||
</div>
|
||||
<div class="item">
|
||||
Total to receive
|
||||
<span class="item-note total-amount">
|
||||
{{sellInfo.total}} {{sellInfo.currency}}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</ion-content>
|
||||
|
||||
<click-to-accept
|
||||
ng-disabled="!sellInfo || !wallet"
|
||||
ng-click="sellConfirm()"
|
||||
ng-if="!isCordova && sellInfo"
|
||||
click-send-status="sendStatus"
|
||||
has-wallet-chosen="wallet"
|
||||
insufficient-funds="false"
|
||||
no-matching-wallet="!sellInfo">
|
||||
Confirm sale
|
||||
</click-to-accept>
|
||||
<slide-to-accept
|
||||
ng-disabled="!sellInfo || !wallet"
|
||||
ng-if="isCordova && sellInfo"
|
||||
slide-on-confirm="sellConfirm()"
|
||||
slide-send-status="sendStatus"
|
||||
has-wallet-chosen="wallet"
|
||||
insufficient-funds="false"
|
||||
no-matching-wallet="!sellInfo">
|
||||
Slide to sell
|
||||
</slide-to-accept>
|
||||
<slide-to-accept-success
|
||||
slide-success-show="sendStatus === 'success'"
|
||||
slide-success-on-confirm="goBackHome()"
|
||||
slide-success-hide-on-confirm="true">
|
||||
<span>Funds sent to Glidera Account</span>
|
||||
<div class="m10 size-14">
|
||||
The transaction is not yet confirmed, and will show as "Pending" in your Activity. The bitcoin sale will be
|
||||
completed automatically once it is confirmed by Glidera.
|
||||
</div>
|
||||
</slide-to-accept-success>
|
||||
|
||||
<wallet-selector
|
||||
wallet-selector-title="walletSelectorTitle"
|
||||
wallet-selector-wallets="wallets"
|
||||
wallet-selector-selected-wallet="wallet"
|
||||
wallet-selector-show="showWallets"
|
||||
wallet-selector-on-select="onWalletSelect">
|
||||
</wallet-selector>
|
||||
</ion-view>
|
||||
Loading…
Add table
Add a link
Reference in a new issue