Merge pull request #5146 from gabrielbazan7/feat/glideraNewFlow

Glidera new buy and sell flow
This commit is contained in:
Gustavo Maximiliano Cortez 2016-12-07 16:35:34 -03:00 committed by GitHub
commit 56079eb0f5
21 changed files with 408 additions and 687 deletions

View file

@ -1,6 +1,6 @@
'use strict';
angular.module('copayApp.controllers').controller('amountController', function($scope, $filter, $timeout, $ionicScrollDelegate, $ionicHistory, $ionicPopover, gettextCatalog, platformInfo, lodash, configService, rateService, $stateParams, $window, $state, $log, txFormatService, ongoingProcess, bitpayCardService, popupService, bwcError, payproService, profileService, bitcore, amazonService) {
angular.module('copayApp.controllers').controller('amountController', function($scope, $filter, $timeout, $ionicScrollDelegate, $ionicHistory, $ionicPopover, gettextCatalog, platformInfo, lodash, configService, rateService, $stateParams, $window, $state, $log, txFormatService, ongoingProcess, bitpayCardService, popupService, bwcError, payproService, profileService, bitcore, amazonService, glideraService) {
var unitToSatoshi;
var satToUnit;
var unitDecimals;
@ -15,22 +15,34 @@ angular.module('copayApp.controllers').controller('amountController', function($
$scope.$on("$ionicView.beforeEnter", function(event, data) {
$scope.isGiftCard = data.stateParams.isGiftCard;
// Glidera parameters
$scope.isGlidera = data.stateParams.isGlidera;
$scope.glideraAccessToken = data.stateParams.glideraAccessToken;
$scope.cardId = data.stateParams.cardId;
$scope.showMenu = $ionicHistory.backView().stateName == 'tabs.send';
$scope.isWallet = data.stateParams.isWallet;
$scope.cardId = data.stateParams.cardId;
$scope.toAddress = data.stateParams.toAddress;
$scope.toName = data.stateParams.toName;
$scope.toEmail = data.stateParams.toEmail;
$scope.showAlternativeAmount = !!$scope.cardId || !!$scope.isGiftCard;
$scope.showAlternativeAmount = !!$scope.cardId || !!$scope.isGiftCard || !!$scope.isGlidera;
$scope.toColor = data.stateParams.toColor;
$scope.customAmount = data.stateParams.customAmount;
if (!$scope.cardId && !$scope.isGiftCard && !data.stateParams.toAddress) {
if (!$scope.cardId && !$scope.isGiftCard && !$scope.isGlidera && !data.stateParams.toAddress) {
$log.error('Bad params at amount')
throw ('bad params');
}
glideraService.getLimits($scope.glideraAccessToken, function(err, limits) {
$scope.limits = limits;
$timeout(function() {
$scope.$apply();
});
});
var reNr = /^[1234567890\.]$/;
var reOp = /^[\*\+\-\/]$/;
@ -325,6 +337,13 @@ angular.module('copayApp.controllers').controller('amountController', function($
}, true);
});
});
} 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 {
var amount = $scope.showAlternativeAmount ? fromFiat(_amount) : _amount;
if ($scope.customAmount) {

View file

@ -1,146 +0,0 @@
'use strict';
angular.module('copayApp.controllers').controller('buyGlideraController',
function($scope, $timeout, $log, profileService, walletService, glideraService, bwcError, lodash, ongoingProcess, popupService, gettextCatalog) {
var wallet;
var self = this;
this.show2faCodeInput = null;
this.success = null;
$scope.network = glideraService.getEnvironment();
$scope.$on('Wallet/Changed', function(event, w) {
if (lodash.isEmpty(w)) {
$log.debug('No wallet provided');
return;
}
wallet = w;
$log.debug('Wallet changed: ' + w.name);
});
$scope.update = function(opts) {
if (!$scope.token || !$scope.permissions) return;
$log.debug('Updating Glidera Account...');
var accessToken = $scope.token;
var permissions = $scope.permissions;
opts = opts || {};
glideraService.getStatus(accessToken, function(err, data) {
$scope.status = data;
});
glideraService.getLimits(accessToken, function(err, limits) {
$scope.limits = limits;
});
if (permissions.transaction_history) {
glideraService.getTransactions(accessToken, function(err, data) {
$scope.txs = data;
});
}
if (permissions.view_email_address && opts.fullUpdate) {
glideraService.getEmail(accessToken, function(err, data) {
$scope.email = data.email;
});
}
if (permissions.personal_info && opts.fullUpdate) {
glideraService.getPersonalInfo(accessToken, function(err, data) {
$scope.personalInfo = data;
});
}
};
this.getBuyPrice = function(token, price) {
var self = this;
if (!price || (price && !price.qty && !price.fiat)) {
this.buyPrice = null;
return;
}
this.gettingBuyPrice = true;
glideraService.buyPrice(token, price, function(err, buyPrice) {
self.gettingBuyPrice = false;
if (err) {
popupService.showAlert(gettextCatalog.getString('Error'), gettextCatalog.getString('Could not get exchange information. Please, try again'));
return;
}
self.buyPrice = buyPrice;
});
};
this.get2faCode = function(token) {
var self = this;
ongoingProcess.set('Sending 2FA code...', true);
$timeout(function() {
glideraService.get2faCode(token, function(err, sent) {
ongoingProcess.set('Sending 2FA code...', false);
if (err) {
popupService.showAlert(gettextCatalog.getString('Error'), gettextCatalog.getString('Could not send confirmation code to your phone'));
return;
}
self.show2faCodeInput = sent;
});
}, 100);
};
this.sendRequest = function(token, permissions, twoFaCode) {
var self = this;
ongoingProcess.set('Buying Bitcoin...', true);
$timeout(function() {
walletService.getAddress(wallet, false, function(err, walletAddr) {
if (err) {
ongoingProcess.set('Buying Bitcoin...', false);
popupService.showAlert(gettextCatalog.getString('Error'), bwcError.cb(err, 'Could not create address'));
return;
}
var data = {
destinationAddress: walletAddr,
qty: self.buyPrice.qty,
priceUuid: self.buyPrice.priceUuid,
useCurrentPrice: false,
ip: null
};
glideraService.buy(token, twoFaCode, data, function(err, data) {
ongoingProcess.set('Buying Bitcoin...', false);
if (err) {
popupService.showAlert(gettextCatalog.getString('Error'), err);
return;
}
self.success = data;
$timeout(function() {
$scope.$digest();
});
});
});
}, 100);
};
$scope.$on("$ionicView.enter", function(event, data){
$scope.token = null;
$scope.permissions = null;
$scope.email = null;
$scope.personalInfo = null;
$scope.txs = null;
$scope.status = null;
$scope.limits = null;
ongoingProcess.set('connectingGlidera', true);
glideraService.init($scope.token, function(err, glidera) {
ongoingProcess.set('connectingGlidera');
if (err || !glidera) {
if (err) popupService.showAlert(gettextCatalog.getString('Error'), err);
return;
}
$scope.token = glidera.token;
$scope.permissions = glidera.permissions;
$scope.update({fullUpdate: true});
});
$scope.wallets = profileService.getWallets({
network: $scope.network,
onlyComplete: true
});
});
});

View file

@ -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, gettext, txFormatService, ongoingProcess, $ionicModal, popupService, $ionicHistory, $ionicConfig, payproService, feeService, amazonService) {
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, gettext, txFormatService, ongoingProcess, $ionicModal, popupService, $ionicHistory, $ionicConfig, payproService, feeService, amazonService, glideraService, bwcError) {
var cachedTxp = {};
var toAmount;
var isChromeApp = platformInfo.isChromeApp;
@ -21,6 +21,10 @@ angular.module('copayApp.controllers').controller('confirmController', function(
giftCardInvoiceTime = data.stateParams.giftCardInvoiceTime;
giftCardUUID = data.stateParams.giftCardUUID;
// 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;
@ -42,7 +46,8 @@ angular.module('copayApp.controllers').controller('confirmController', function(
var config = configService.getSync().wallet;
$scope.feeLevel = config.settings && config.settings.feeLevel ? config.settings.feeLevel : 'normal';
$scope.network = (new bitcore.Address($scope.toAddress)).network.name;
if ($scope.isGlidera) $scope.network = glideraService.getEnvironment();
else $scope.network = (new bitcore.Address($scope.toAddress)).network.name;
resetValues();
setwallets();
});
@ -125,6 +130,8 @@ angular.module('copayApp.controllers').controller('confirmController', function(
txFormatService.formatAlternativeStr(toAmount, function(v) {
$scope.alternativeAmountStr = v;
});
if ($scope.isGlidera == 'buy') $scope.getBuyPrice();
if ($scope.isGlidera == 'sell') $scope.getSellPrice();
};
function resetValues() {
@ -233,6 +240,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');
if (!$scope.useSendMax && ($scope.insufficientFunds || $scope.noMatchingWallet)) return;
$scope.showWallets = true;
};
@ -309,6 +317,7 @@ 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;
@ -415,6 +424,12 @@ angular.module('copayApp.controllers').controller('confirmController', function(
};
$scope.approve = function(onSendStatusChange) {
var wallet = $scope.wallet;
if (!wallet) {
return;
}
if ($scope.paypro && $scope.paymentExpired.value) {
popupService.showAlert(null, gettextCatalog.getString('This bitcoin payment request has expired.'));
$scope.sendStatus = '';
@ -424,9 +439,45 @@ angular.module('copayApp.controllers').controller('confirmController', function(
return;
}
var wallet = $scope.wallet;
if (!wallet) {
return setSendError(gettextCatalog.getString('No wallet selected'));
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;
}
if (!wallet.canSign() && !wallet.isPrivKeyExternal()) {
@ -501,6 +552,7 @@ angular.module('copayApp.controllers').controller('confirmController', function(
var previousView = $ionicHistory.viewHistory().backView && $ionicHistory.viewHistory().backView.stateName;
var fromBitPayCard = previousView.match(/tabs.bitpayCard/) ? true : false;
var fromAmazon = previousView.match(/tabs.giftcards.amazon/) ? true : false;
var fromGlidera = previousView.match(/tabs.buyandsell.glidera/) ? true : false;
$ionicHistory.nextViewOptions({
disableAnimate: true
@ -525,6 +577,15 @@ angular.module('copayApp.controllers').controller('confirmController', function(
cardClaimCode: $scope.amazonGiftCard ? $scope.amazonGiftCard.claimCode : null
});
});
} 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,
@ -537,6 +598,162 @@ 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) {
walletService.publishAndSign(wallet, txp, function(err, txp) {
if (err) return setSendError(err);

View file

@ -18,9 +18,11 @@ angular.module('copayApp.controllers').controller('glideraController',
$scope.status = null;
$scope.limits = null;
$scope.connectingGlidera = true;
ongoingProcess.set('connectingGlidera', true);
glideraService.init($scope.token, function(err, glidera) {
ongoingProcess.set('connectingGlidera');
$scope.connectingGlidera = false;
if (err || !glidera) {
if (err) popupService.showAlert(gettextCatalog.getString('Error'), err);
return;
@ -67,11 +69,11 @@ angular.module('copayApp.controllers').controller('glideraController',
}
};
this.getAuthenticateUrl = function() {
$scope.getAuthenticateUrl = function() {
return glideraService.getOauthCodeUrl();
};
this.submitOauthCode = function(code) {
$scope.submitOauthCode = function(code) {
ongoingProcess.set('connectingGlidera', true);
$timeout(function() {
glideraService.getToken(code, function(err, data) {
@ -90,10 +92,7 @@ angular.module('copayApp.controllers').controller('glideraController',
}, 100);
};
this.openTxModal = function(token, tx) {
var self = this;
$scope.self = self;
$scope.openTxModal = function(token, tx) {
$scope.tx = tx;
glideraService.getTransaction(token, tx.transactionUuid, function(err, tx) {

View file

@ -1,219 +0,0 @@
'use strict';
angular.module('copayApp.controllers').controller('sellGlideraController',
function($scope, $timeout, $log, profileService, glideraService, bwcError, lodash, walletService, configService, ongoingProcess, popupService, gettextCatalog) {
var self = this;
this.data = {};
this.show2faCodeInput = null;
this.success = null;
var wallet;
$scope.network = glideraService.getEnvironment();
$scope.$on('Wallet/Changed', function(event, w) {
if (lodash.isEmpty(w)) {
$log.debug('No wallet provided');
return;
}
wallet = w;
$log.debug('Wallet changed: ' + w.name);
});
$scope.update = function(opts) {
if (!$scope.token || !$scope.permissions) return;
$log.debug('Updating Glidera Account...');
var accessToken = $scope.token;
var permissions = $scope.permissions;
opts = opts || {};
glideraService.getStatus(accessToken, function(err, data) {
$scope.status = data;
});
glideraService.getLimits(accessToken, function(err, limits) {
$scope.limits = limits;
});
if (permissions.transaction_history) {
glideraService.getTransactions(accessToken, function(err, data) {
$scope.txs = data;
});
}
if (permissions.view_email_address && opts.fullUpdate) {
glideraService.getEmail(accessToken, function(err, data) {
$scope.email = data.email;
});
}
if (permissions.personal_info && opts.fullUpdate) {
glideraService.getPersonalInfo(accessToken, function(err, data) {
$scope.personalInfo = data;
});
}
};
this.getSellPrice = function(token, price) {
var self = this;
if (!price || (price && !price.qty && !price.fiat)) {
self.sellPrice = null;
return;
}
self.gettingSellPrice = true;
glideraService.sellPrice(token, price, function(err, sellPrice) {
self.gettingSellPrice = false;
if (err) {
popupService.showAlert(gettextCatalog.getString('Error'), gettextCatalog.getString('Could not get exchange information. Please, try again'));
return;
}
self.sellPrice = sellPrice;
});
};
this.get2faCode = function(token) {
var self = this;
ongoingProcess.set('Sending 2FA code...', true);
$timeout(function() {
glideraService.get2faCode(token, function(err, sent) {
ongoingProcess.set('Sending 2FA code...', false);
if (err) {
popupService.showAlert(gettextCatalog.getString('Error'), gettextCatalog.getString('Could not send confirmation code to your phone'));
} else {
self.show2faCodeInput = sent;
}
});
}, 100);
};
this.createTx = function(token, permissions, twoFaCode) {
var self = this;
var outputs = [];
var config = configService.getSync();
var configWallet = config.wallet;
var walletSettings = configWallet.settings;
if (!wallet) {
popupService.showAlert(gettextCatalog.getString('Error'), gettextCatalog.getString('No wallet selected'));
return;
}
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(token, 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((self.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': token
}
};
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: self.sellPrice.priceUuid,
useCurrentPrice: self.sellPrice.priceUuid ? false : true,
ip: null
};
ongoingProcess.set('Selling Bitcoin', true);
glideraService.sell(token, twoFaCode, data, function(err, data) {
ongoingProcess.clear();
if (err) {
popupService.showAlert(gettextCatalog.getString('Error'), err.message || bwcError.msg(err));
return;
}
self.success = data;
$timeout(function() {
$scope.$digest();
});
});
});
});
});
});
});
});
};
$scope.$on("$ionicView.enter", function(event, data){
$scope.token = null;
$scope.permissions = null;
$scope.email = null;
$scope.personalInfo = null;
$scope.txs = null;
$scope.status = null;
$scope.limits = null;
ongoingProcess.set('connectingGlidera', true);
glideraService.init($scope.token, function(err, glidera) {
ongoingProcess.set('connectingGlidera');
if (err || !glidera) {
if (err) popupService.showAlert(gettextCatalog.getString('Error'), err);
return;
}
$scope.token = glidera.token;
$scope.permissions = glidera.permissions;
$scope.update({fullUpdate: true});
});
$scope.wallets = profileService.getWallets({
network: $scope.network,
n: 1,
onlyComplete: true
});
});
});

View file

@ -8,10 +8,11 @@ angular.module('copayApp.directives')
transclude: true,
scope: {
sendStatus: '=clickSendStatus',
wallet: '=hasWalletChosen'
},
link: function(scope, element, attrs) {
scope.$watch('sendStatus', function() {
if(scope.sendStatus !== 'success') {
if (scope.sendStatus !== 'success') {
scope.displaySendStatus = scope.sendStatus;
}
});

View file

@ -8,7 +8,8 @@ angular.module('copayApp.directives')
transclude: true,
scope: {
sendStatus: '=slideSendStatus',
onConfirm: '&slideOnConfirm'
onConfirm: '&slideOnConfirm',
wallet: '=hasWalletChosen'
},
link: function(scope, element, attrs) {
@ -33,9 +34,9 @@ angular.module('copayApp.directives')
scope.displaySendStatus = '';
scope.$watch('sendStatus', function() {
if(!scope.sendStatus) {
if (!scope.sendStatus) {
reset();
} else if(scope.sendStatus === 'success') {
} else if (scope.sendStatus === 'success') {
scope.displaySendStatus = '';
$timeout(function() {
reset();
@ -51,19 +52,20 @@ angular.module('copayApp.directives')
var startTime = currentEaseStartTime;
var initialPct = fromPct;
var distance = pct - fromPct;
function ease() {
if(startTime !== currentEaseStartTime) {
if (startTime !== currentEaseStartTime) {
return;
}
$window.requestAnimationFrame(function() {
var now = Date.now();
var elapsed = now - startTime;
var normalizedElapsedTime = elapsed/duration;
var normalizedElapsedTime = elapsed / duration;
var newVal = easeFx(normalizedElapsedTime);
var newPct = newVal*distance + initialPct;
var newPct = newVal * distance + initialPct;
animateFx(newPct);
scope.$digest();
if(elapsed < duration) {
if (elapsed < duration) {
ease();
} else {
deferred.resolve();
@ -93,31 +95,33 @@ angular.module('copayApp.directives')
function setNewSliderStyle(pct) {
var knobWidthPct = getKnobWidthPercentage();
var translatePct = pct - knobWidthPct;
if(isSliding) {
translatePct += 0.35*pct;
if (isSliding) {
translatePct += 0.35 * pct;
}
scope.sliderStyle = getTransformStyle(translatePct);
curSliderPct = pct;
}
function setNewBitcoinStyle(pct) {
var translatePct = -2.25*pct;
var translatePct = -2.25 * pct;
scope.bitcoinStyle = getTransformStyle(translatePct);
curBitcoinPct = pct;
}
function setNewTextStyle(pct) {
var translatePct = -0.1*pct;
var translatePct = -0.1 * pct;
scope.textStyle = getTransformStyle(translatePct);
curTextPct = pct;
}
function getTransformStyle(translatePct) {
return {'transform': 'translateX(' + translatePct + '%)'};
return {
'transform': 'translateX(' + translatePct + '%)'
};
}
function getKnobWidthPercentage() {
var knobWidthPct = (KNOB_WIDTH/elm.clientWidth)*100;
function getKnobWidthPercentage() {
var knobWidthPct = (KNOB_WIDTH / elm.clientWidth) * 100;
return knobWidthPct;
}
@ -175,8 +179,8 @@ angular.module('copayApp.directives')
function getTouchXPosition($event) {
var x;
if($event.touches || $event.changedTouches) {
if($event.touches.length) {
if ($event.touches || $event.changedTouches) {
if ($event.touches.length) {
x = $event.touches[0].clientX;
} else {
x = $event.changedTouches[0].clientX;
@ -190,18 +194,18 @@ angular.module('copayApp.directives')
function getSlidPercentage($event) {
var x = getTouchXPosition($event);
var width = elm.clientWidth;
var pct = (x/width)*100;
if(x >= width) {
var pct = (x / width) * 100;
if (x >= width) {
pct = 100;
}
return pct;
}
scope.onTouchstart = function($event) {
if(scope.isSlidFully) {
if (scope.isSlidFully) {
return;
}
if(!isSliding) {
if (!isSliding) {
var pct = getSlidPercentage($event);
if (pct > MAX_SLIDE_START_PERCENTAGE) {
jiggleSlider();
@ -209,7 +213,7 @@ angular.module('copayApp.directives')
} else {
isSliding = true;
var knobWidthPct = getKnobWidthPercentage();
if(pct < knobWidthPct) {
if (pct < knobWidthPct) {
pct = knobWidthPct;
}
pct += PERCENTAGE_BUMP;
@ -219,12 +223,12 @@ angular.module('copayApp.directives')
};
scope.onTouchmove = function($event) {
if(!isSliding || scope.isSlidFully) {
if (!isSliding || scope.isSlidFully) {
return;
}
var pct = getSlidPercentage($event);
var knobWidthPct = getKnobWidthPercentage();
if(pct < knobWidthPct) {
if (pct < knobWidthPct) {
pct = knobWidthPct;
}
pct += PERCENTAGE_BUMP;
@ -233,11 +237,11 @@ angular.module('copayApp.directives')
};
scope.onTouchend = function($event) {
if(scope.isSlidFully) {
if (scope.isSlidFully) {
return;
}
var pct = getSlidPercentage($event);
if(isSliding && pct > FULLY_SLID_PERCENTAGE) {
if (isSliding && pct > FULLY_SLID_PERCENTAGE) {
pct = 100;
setSliderPosition(pct);
alertSlidFully();

View file

@ -7,6 +7,7 @@ angular.module('copayApp.directives')
templateUrl: 'views/includes/walletSelector.html',
transclude: true,
scope: {
title: '=walletSelectorTitle',
show: '=walletSelectorShow',
wallets: '=walletSelectorWallets',
selectedWallet: '=walletSelectorSelectedWallet',

View file

@ -888,23 +888,21 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr
}
}
})
.state('tabs.buyandsell.glidera.buy', {
url: '/buy',
.state('tabs.buyandsell.glidera.amount', {
url: '/amount/:isGlidera/:glideraAccessToken',
views: {
'tab-home@tabs': {
controller: 'buyGlideraController',
controllerAs: 'buy',
templateUrl: 'views/buyGlidera.html'
controller: 'amountController',
templateUrl: 'views/amount.html'
}
}
})
.state('tabs.buyandsell.glidera.sell', {
url: '/sell',
.state('tabs.buyandsell.glidera.confirm', {
url: '/confirm/:toAmount/:isGlidera/:glideraAccessToken',
views: {
'tab-home@tabs': {
controller: 'sellGlideraController',
controllerAs: 'sell',
templateUrl: 'views/sellGlidera.html'
controller: 'confirmController',
templateUrl: 'views/confirm.html'
}
}
})

View file

@ -192,8 +192,13 @@ angular.module('copayApp.services').factory('glideraService', function($http, $l
};
root.get2faCode = function(token, cb) {
if (!token) return cb('Invalid Token');
if (!token) {
$log.error('Glidera Sent 2FA code by SMS: ERROR Invalid 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);
}, function(data) {

View file

@ -37,6 +37,9 @@ angular.module('copayApp.services').factory('ongoingProcess', function($log, $ti
'generatingNewAddress': gettext('Generating new address...'),
'gettingAddresses': gettext('Getting addresses...'),
'sendingByEmail': gettext('Preparing addresses...'),
'sending2faCode': gettext('Sending 2FA code...'),
'buyingBitcoin': gettext('Buying Bitcoin...'),
'sellingBitcoin': gettext('Selling Bitcoin...')
};
root.clear = function() {

View file

@ -37,7 +37,7 @@
position: absolute;
top: 10px;
}
.amount-pane-send {
.amount-pane-recipient {
position: absolute;
top: 95px;
bottom: 0;
@ -68,7 +68,7 @@
}
}
}
.amount-pane-receive {
.amount-pane-no-recipient {
position: absolute;
top: 0;
bottom: 0;
@ -84,6 +84,11 @@
padding-top: 10px;
color: $dark-gray;
font-weight: bold;
.limits {
margin-top: 10px;
color: $light-gray;
font-size: 12px;
}
}
}
.amount {

View file

@ -245,4 +245,21 @@
color: rgba(58, 58, 58, .6);
margin-bottom: 1.5rem;
}
.glidera-success {
padding: 20px;
margin-top: 15px;
span {
font-size: 15px;
display: block;
}
}
.glidera-explanation {
padding: 0 1rem;
white-space: normal;
}
.glidera-description {
text-align: center;
font-size: 12px;
color: $mid-gray;
}
}

View file

@ -14,14 +14,14 @@
<ion-content scroll="false">
<div ng-if="!customAmount">
<div ng-if="!customAmount && !isGlidera">
<div class="item item-no-bottom-border recipient-label" translate>Recipient</div>
<div class="item item-text-wrap item-icon-left bitcoin-address" ng-class="{'item-big-icon-left':cardId}">
<i class="icon big-icon-svg" ng-if="isWallet">
<img src="img/icon-wallet.svg" ng-style="{'background-color': toColor}" class="bg"/>
</i>
<span ng-if="!isWallet && !isGiftCard">
<span ng-if="!isWallet && !isGiftCard && !isGlidera">
<gravatar ng-if="!cardId" class="send-gravatar" name="{{toName}}" height="30" width="30" email="{{toEmail}}"></gravatar>
<i ng-if="cardId" class="icon big-icon-svg">
<div class="bg icon-bitpay-card"></div>
@ -36,12 +36,32 @@
</div>
</div>
<div ng-class="{'amount-pane-send': !customAmount, 'amount-pane-receive': customAmount}">
<div ng-class="{'amount-pane-recipient': !customAmount && !isGlidera, 'amount-pane-no-recipient': customAmount || isGlidera}">
<div class="amount-bar oh">
<div class="title">
<span translate>Amount</span>
<span ng-show="isGiftCard" class="size-12">(Purchase Amount is limited to USD 500 per day)</span>
<span ng-show="isGiftCard">(Purchase Amount is limited to USD 500 per day)</span>
<div ng-show="isGlidera">
<div class="limits" ng-show="limits && isGlidera == 'buy'">
<span>Daily buy limit</span>:
{{limits.dailyBuy|currency:'':2}} {{limits.currency}}
(remaining {{limits.dailyBuyRemaining|currency:'':2}} {{limits.currency}})
<br>
<span>Monthly buy limit</span>:
{{limits.monthlyBuy|currency:'':2}} {{limits.currency}}
(remaining {{limits.monthlyBuyRemaining|currency:'':2}} {{limits.currency}})
</div>
<div class="limits" ng-show="limits && isGlidera == 'sell'">
<span>Daily sell limit</span>:
{{limits.dailySell|currency:'':2}} {{limits.currency}}
(remaining {{limits.dailySellRemaining|currency:'':2}} {{limits.currency}})
<br>
<span>Monthly sell limit</span>:
{{limits.monthlySell|currency:'':2}} {{limits.currency}}
(remaining {{limits.monthlySellRemaining|currency:'':2}} {{limits.currency}})
</div>
</div>
</div>
</div>
@ -62,6 +82,7 @@
</div>
</div>
<div class="keypad">
<div class="row">
<div class="col col-25 col-offset-75 operator-send"

View file

@ -1,123 +0,0 @@
<ion-view>
<ion-nav-bar class="bar-royal">
<ion-nav-back-button>
</ion-nav-back-button>
<ion-nav-title>Buy</ion-nav-title>
</ion-nav-bar>
<ion-content>
<div class="box-notification warning" ng-show="network == 'testnet'">
Testnet wallets only work with Glidera Sandbox Accounts
</div>
<div class="box-notification notice" ng-show="limits && !buy.show2faCodeInput && !buy.success">
<span class="text-light">Daily buy limit</span>:
{{limits.dailyBuy|currency:'':2}} {{limits.currency}}
(remaining {{limits.dailyBuyRemaining|currency:'':2}} {{limits.currency}})
<br>
<span class="text-light">Monthly buy limit</span>:
{{limits.monthlyBuy|currency:'':2}} {{limits.currency}}
(remaining {{limits.monthlyBuyRemaining|currency:'':2}} {{limits.currency}})
</div>
<div class="box-notification warning" ng-show="limits.transactDisabledPendingFirstTransaction && !buy.success">
<span class="text-warning">
This operation was disabled because you have a pending first transaction
</span>
</div>
<div ng-show="!buy.show2faCodeInput && !buy.success">
<form name="buyPriceForm" ng-if="token"
ng-submit="buy.get2faCode(token)" novalidate>
<div class="list card">
<label class="item item-input item-stacked-label">
<span class="input-label">Amount in {{showAlternative ? 'USD' : 'BTC'}}</span>
<input ng-show="!showAlternative"
type="number"
id="qty" ignore-mouse-wheel
name="qty"
ng-attr-placeholder="{{'Amount'}}"
ng-minlength="0.00000001"
ng-maxlength="10000000000"
ng-model="qty"
autocomplete="off"
ng-change="buy.getBuyPrice(token, {'qty': qty})">
<input ng-show="showAlternative"
type="number"
id="fiat" ignore-mouse-wheel
name="fiat"
ng-attr-placeholder="{{'Amount'}}"
ng-model="fiat"
autocomplete="off"
ng-change="buy.getBuyPrice(token, {'fiat': fiat})">
<a ng-show="!showAlternative"
class="postfix"
on-tap="showAlternative = true; qty = null; buy.buyPrice = null">BTC</a>
<a ng-show="showAlternative"
class="postfix"
on-tap="showAlternative = false; fiat = null; buy.buyPrice = null">USD</a>
</label>
</div>
<wallets ng-if="wallets[0]" wallets="wallets"></wallets>
<div class="text-center text-gray size-12 m20v" ng-show="!buy.gettingBuyPrice && buy.buyPrice.qty">
Buy
<span ng-show="qty">{{buy.buyPrice.subtotal|currency:'':2}} {{buy.buyPrice.currency}} in Bitcoin</span>
<span ng-show="fiat">{{buy.buyPrice.qty}} BTC</span>
at {{buy.buyPrice.price}} {{buy.buyPrice.currency}}/BTC
</div>
<div class="text-center text-gray size-12 m20b" ng-show="!buy.gettingBuyPrice && !buy.buyPrice.qty">
(Enter the amount to get the exchange rate)
</div>
<div class="text-center text-gray size-12 m20b" ng-show="buy.gettingBuyPrice">
...
</div>
<button class="button button-standard button-primary"
type="submit"
ng-disabled="limits.transactDisabledPendingFirstTransaction || !buy.buyPrice.qty || buy.loading">
Continue
</button>
</form>
</div>
<div ng-show="buy.show2faCodeInput && !buy.success">
<div class="m10t text-center">
{{buy.buyPrice.subtotal|currency:'':2}} {{buy.buyPrice.currency}} &rarr; {{buy.buyPrice.qty}} BTC
<p class="m20t">
A SMS containing a confirmation code was sent to your phone. <br>
Please, enter the code below
</p>
<form name="buyForm"
ng-submit="buy.sendRequest(token, permissions, twoFaCode)" novalidate>
<div class="list card">
<label class="item item-input">
<input type="number" ng-model="twoFaCode" placeholder="2FA Code" required ignore-mouse-wheel>
</label>
</div>
<button class="button button-standard button-primary"
type="submit" ng-disabled="buyForm.$invalid || buy.loading">
Buy
</button>
</form>
<p class="m10t size-12 text-gray padding">
Fiat will be immediately withdrawn from your bank account. The bitcoins will be purchased and deposited to your wallet in 2-4 business days.
</p>
</div>
</div>
<div class="text-center padding" ng-show="buy.success">
<h1>Purchase initiated</h1>
<p class="text-gray">
A transfer has been initiated from your bank account. Your bitcoins should arrive to your wallet in 2-4 business days.
</p>
<button class="button button-standard button-primary" ui-sref="tabs.buyandsell.glidera">OK</button>
</div>
</ion-content>
</ion-view>

View file

@ -12,8 +12,10 @@
<div class="item head">
<div class="sending-label">
<img src="img/icon-tx-sent-outline.svg">
<span translate ng-if="!useSendMax">Sending</span>
<span translate ng-if="!useSendMax && !isGlidera">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>
@ -27,13 +29,16 @@
<span class="item-note" ng-if="paymentExpired.value" ng-style="{'color': 'red'}" translate>Expired</span>
</div>
<div class="item">
<span class="label" translate>To</span>
<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="payment-proposal-to">
<img ng-if="!cardId && !isGiftCard" src="img/icon-bitcoin-small.svg">
<img ng-if="!cardId && !isGiftCard && !isGlidera" 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>
@ -51,7 +56,9 @@
</span>
</div>
<a class="item item-icon-right" ng-hide="!useSendMax && (insufficientFunds || noMatchingWallet)" ng-click="showWalletSelector()">
<span class="label" translate>From</span>
<span class="label" ng-if="!isGlidera" translate>From</span>
<span class="label" ng-if="isGlidera == 'buy'" translate>To</span>
<span class="label" ng-if="isGlidera == 'sell'" translate>From</span>
<div class="wallet">
<i class="icon big-icon-svg">
<img src="img/icon-wallet.svg" ng-style="{'background-color': wallet.color}" class="bg"/>
@ -60,19 +67,47 @@
</div>
<i class="icon bp-arrow-right"></i>
</a>
<a class="item single-line item-icon-right" ng-if="!insufficientFunds && !noMatchingWallet" ng-click="showDescriptionPopup()">
<a class="item single-line item-icon-right" ng-if="!insufficientFunds && !noMatchingWallet && !isGlidera" 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">
<div class="item single-line" ng-if="!insufficientFunds && !noMatchingWallet && !isGlidera">
<span class="label" translate>Fee: {{feeLevel}}</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>
@ -85,13 +120,16 @@
<click-to-accept
ng-click="approve(statusChangeHandler)"
ng-if="!isCordova && wallets[0] && !insufficientFunds && !noMatchingWallet"
click-send-status="sendStatus">
click-send-status="sendStatus"
has-wallet-chosen="wallet">
Click to pay
</click-to-accept>
<slide-to-accept
ng-disabled="!wallet"
ng-if="isCordova && wallets[0] && !insufficientFunds && !noMatchingWallet"
slide-on-confirm="onConfirm()"
slide-send-status="sendStatus">
slide-send-status="sendStatus"
has-wallet-chosen="wallet">
Slide to pay
</slide-to-accept>
<slide-to-accept-success
@ -100,9 +138,14 @@
slide-success-hide-on-confirm="true">
<span ng-hide="wallet.m > 1">Payment Sent</span>
<span ng-show="wallet.m > 1">Proposal 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
wallet-selector-title="walletSelectorTitle"
wallet-selector-wallets="wallets"
wallet-selector-selected-wallet="wallet"
wallet-selector-show="showWallets"

View file

@ -5,7 +5,7 @@
<ion-nav-title>Glidera</ion-nav-title>
</ion-nav-bar>
<ion-content>
<ion-content ng-show="!connectingGlidera">
<div class="box-notification error m0" ng-show="!network">
Glidera is disabled for this application
@ -27,7 +27,7 @@
<p class="glidera-text">Connect your Glidera account to get started.</p>
<button class="button button-standard button-primary"
ng-click="openExternalLink(glidera.getAuthenticateUrl()); showOauthForm = true">
ng-click="openExternalLink(getAuthenticateUrl()); showOauthForm = true">
Connect to Glidera
</button>
<div class="m10t">
@ -41,7 +41,7 @@
</div>
</div>
<div ng-show="showOauthForm">
<form class="settings" name="oauthCodeForm" ng-submit="glidera.submitOauthCode(code)" novalidate>
<form class="settings" name="oauthCodeForm" ng-submit="submitOauthCode(code)" novalidate>
<div class="list settings-input-group">
<label class="item item-input item-stacked-label">
<span class="input-label">OAuth Code</span>
@ -75,14 +75,14 @@
ng-show="status && status.userCanTransact">
<a ng-show="status.userCanBuy"
class="item item-icon-right"
href ui-sref="tabs.buyandsell.glidera.buy">
href ui-sref="tabs.buyandsell.glidera.amount({isGlidera: 'buy', glideraAccessToken: token})">
<img src="img/buy-bitcoin.svg" alt="buy bitcoin" width="45" class="item-img-buy">
Buy Bitcoin
<i class="icon bp-arrow-right"></i>
</a>
<a class="item item-icon-right"
ng-show="status.userCanSell"
href ui-sref="tabs.buyandsell.glidera.sell">
href ui-sref="tabs.buyandsell.glidera.amount({isGlidera: 'sell', glideraAccessToken: token})">
<img src="img/sell-bitcoin.svg" alt="buy bitcoin" width="45" class="item-img-sell">
Sell Bitcoin
<i class="icon bp-arrow-right"></i>
@ -94,7 +94,7 @@
Activity
</div>
<a ng-repeat="tx in txs"
ng-click="glidera.openTxModal(token, tx)"
ng-click="openTxModal(token, tx)"
class="item">
<span class="item-note">

View file

@ -1,4 +1,4 @@
<button class="click-to-accept__button button button-standard button-primary" ng-class="{disable: sendStatus}">
<button ng-disabled="!wallet" class="click-to-accept__button button button-standard button-primary" ng-class="{disable: sendStatus}">
<span ng-if="!sendStatus">
<ng-transclude></ng-transclude>
</span>

View file

@ -3,7 +3,7 @@
ng-class="{'fill-screen': fillScreen}">
</div>
<div class="slide-success__content">
<div ng-disabled="wallet" class="slide-success__content">
<img src="img/onboarding-success.svg" ng-class="{reveal: fillScreen}">
<div class="slide-success__content__header" ng-class="{reveal: fillScreen}">
<ng-transclude>Payment Sent</ng-transclude>

View file

@ -1,6 +1,6 @@
<action-sheet action-sheet-show="show" class="wallet-selector">
<img class="back-arrow" src="img/icon-back-arrow.svg" ng-click="hide()">
<div class="header">Send from</div>
<div class="header">{{title}}</div>
<a
ng-repeat="w in wallets track by $index"
class="item item-icon-left item-big-icon-left item-icon-right wallet"

View file

@ -1,124 +0,0 @@
<ion-view>
<ion-nav-bar class="bar-royal">
<ion-nav-back-button>
</ion-nav-back-button>
<ion-nav-title>Sell</ion-nav-title>
</ion-nav-bar>
<ion-content>
<div class="box-notification warning" ng-show="network == 'testnet'">
Testnet wallets only work with Glidera Sandbox Accounts
</div>
<div class="box-notification notice" ng-show="limits && !sell.show2faCodeInput && !sell.success">
<span class="text-light">Daily sell limit</span>:
{{limits.dailySell|currency:'':2}} {{limits.currency}}
(remaining {{limits.dailySellRemaining|currency:'':2}} {{limits.currency}})
<br>
<span class="text-light">Monthly sell limit</span>:
{{limits.monthlySell|currency:'':2}} {{limits.currency}}
(remaining {{limits.monthlySellRemaining|currency:'':2}} {{limits.currency}})
</div>
<div class="box-notification m20b" ng-show="limits.transactDisabledPendingFirstTransaction">
<span class="text-warning">
This operation was disabled because you have a pending first transaction
</span>
</div>
<div ng-show="!sell.show2faCodeInput && !sell.success">
<form name="sellPriceForm" ng-if="token"
ng-submit="sell.get2faCode(token)" novalidate>
<div class="list card">
<label class="item item-input item-stacked-label">
<span class="input-label"><span>Amount in</span> {{showAlternative ? 'USD' : 'BTC'}}</span>
<input ng-show="!showAlternative"
type="number"
id="qty" ignore-mouse-wheel
name="qty"
ng-attr-placeholder="{{'Amount'}}"
ng-minlength="0.00000001"
ng-maxlength="10000000000"
ng-model="qty"
autocomplete="off"
ng-change="sell.getSellPrice(token, {'qty': qty})">
<input ng-show="showAlternative"
type="number"
id="fiat" ignore-mouse-wheel
name="fiat"
ng-attr-placeholder="{{'Amount'}}"
ng-model="fiat"
autocomplete="off"
ng-change="sell.getSellPrice(token, {'fiat': fiat})">
<a ng-show="!showAlternative"
class="postfix"
on-tap="showAlternative = true; qty = null; sell.sellPrice = null">BTC</a>
<a ng-show="showAlternative"
class="postfix"
on-tap="showAlternative = false; fiat = null; sell.sellPrice = null">USD</a>
</label>
</div>
<wallets ng-if="wallets[0]" wallets="wallets"></wallets>
<div class="text-center text-gray size-12 m20v" ng-show="!sell.gettingSellPrice && sell.sellPrice.qty">
Sell
<span ng-show="qty">{{sell.sellPrice.subtotal|currency:'':2}} {{sell.sellPrice.currency}} in Bitcoin</span>
<span ng-show="fiat">{{sell.sellPrice.qty}} BTC</span>
at {{sell.sellPrice.price|currency:'':2}} {{sell.sellPrice.currency}}/BTC
</div>
<div class="text-center text-gray size-12 m20b" ng-show="!sell.gettingSellPrice && !sell.sellPrice.qty">
(Enter the amount to get the exchange rate)
</div>
<div class="text-center text-gray size-12 m20b" ng-show="sell.gettingSellPrice">
...
</div>
<button class="button button-standard button-primary"
type="submit"
ng-disabled="limits.transactDisabledPendingFirstTransaction || !sell.sellPrice.qty">
Continue
</button>
</form>
</div>
<div ng-show="sell.show2faCodeInput && !sell.success">
<div class="m10t text-center">
{{sell.sellPrice.qty}} BTC &rarr; {{sell.sellPrice.subtotal|currency:'':2}} {{sell.sellPrice.currency}}
<p class="m20t">
A SMS containing a confirmation code was sent to your phone. <br>
Please, enter the code below
</p>
<form name="sellForm"
ng-submit="sell.createTx(token, permissions, twoFaCode)" novalidate>
<div class="list card">
<label class="item item-input">
<input type="number" ng-model="twoFaCode" placeholder="2FA Code" required ignore-mouse-wheel>
</label>
</div>
<button class="button button-standard button-primary"
type="submit"
ng-disabled="sellForm.$invalid ">
Sell
</button>
</form>
<p class="m10t size-12 text-gray padding">
Bitcoins will be immediately sent from your wallet to Glidera. Fiat will be deposited in your bank account in 4-6 business days.
</p>
</div>
</div>
<div class="text-center padding" ng-show="sell.success">
<h1>Sale initiated</h1>
<p class="text-gray">
A transfer has been initiated to your bank account and should arrive in 4-6 business days.
</p>
<button class="button button-standard button-primary" ui-sref="tabs.buyandsell.glidera">OK</button>
</div>
</ion-content>
</ion-view>