Fix Glidera URI. Uses showAlert service
This commit is contained in:
parent
748c28b235
commit
092e8308b0
16 changed files with 216 additions and 340 deletions
|
|
@ -83,7 +83,7 @@ angular.module('copayApp.controllers').controller('bitpayCardController', functi
|
|||
bitpayCardService.transactionHistory(dateRange, function(err, history) {
|
||||
$scope.loadingHistory = false;
|
||||
if (err) {
|
||||
popupService.showAler(gettextCatalog.getString('Error'), gettextCatalog.getString('Getting transactions'));
|
||||
popupService.showAlert(gettextCatalog.getString('Error'), gettextCatalog.getString('Could not get transactions'));
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -120,7 +120,7 @@ angular.module('copayApp.controllers').controller('bitpayCardController', functi
|
|||
|
||||
if (!wallet.canSign() && !wallet.isPrivKeyExternal()) {
|
||||
$log.info('No signing proposal: No private key');
|
||||
popupService.showAler(gettextCatalog.getString('Error'), bwcError.msg('MISSING_PRIVATE_KEY'));
|
||||
popupService.showAlert(gettextCatalog.getString('Error'), bwcError.msg('MISSING_PRIVATE_KEY'));
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -140,7 +140,7 @@ angular.module('copayApp.controllers').controller('bitpayCardController', functi
|
|||
bitpayCardService.topUp(dataSrc, function(err, invoiceId) {
|
||||
if (err) {
|
||||
ongoingProcess.set('Processing Transaction...', false);
|
||||
popupService.showAler(gettextCatalog.getString('Error'), bwcError.msg(err));
|
||||
popupService.showAlert(gettextCatalog.getString('Error'), bwcError.msg(err));
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -169,12 +169,12 @@ angular.module('copayApp.controllers').controller('bitpayCardController', functi
|
|||
|
||||
walletService.createTx(wallet, txp, function(err, createdTxp) {
|
||||
if (err) {
|
||||
popupService.showAler(gettextCatalog.getString('Error'), bwcError.msg(err));
|
||||
popupService.showAlert(gettextCatalog.getString('Error'), bwcError.msg(err));
|
||||
return;
|
||||
}
|
||||
walletService.publishAndSign(wallet, createdTxp, function(err, tx) {
|
||||
if (err) {
|
||||
popupService.showAler(gettextCatalog.getString('Error'), bwcError.msg(err));
|
||||
popupService.showAlert(gettextCatalog.getString('Error'), bwcError.msg(err));
|
||||
return;
|
||||
}
|
||||
self.update();
|
||||
|
|
@ -203,7 +203,7 @@ angular.module('copayApp.controllers').controller('bitpayCardController', functi
|
|||
bitpayCardService.authenticate(data, function(err, auth) {
|
||||
self.authenticating = false;
|
||||
if (err && err.data && err.data.error && !err.data.error.twoFactorPending) {
|
||||
popupService.showAler(gettextCatalog.getString('Error'), err.statusText || err.data.error || 'Authentiation error');
|
||||
popupService.showAlert(gettextCatalog.getString('Error'), err.statusText || err.data.error || 'Authentiation error');
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -224,7 +224,7 @@ angular.module('copayApp.controllers').controller('bitpayCardController', functi
|
|||
bitpayCardService.authenticate2FA(data, function(err, auth) {
|
||||
self.authenticating = false;
|
||||
if (err) {
|
||||
popupService.showAler(gettextCatalog.getString('Error'), gettextCatalog.getString('Authentiation error'));
|
||||
popupService.showAlert(gettextCatalog.getString('Error'), gettextCatalog.getString('Authentiation error'));
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ angular.module('copayApp.controllers').controller('buyAmazonController',
|
|||
|
||||
if (!wallet.canSign() && !wallet.isPrivKeyExternal()) {
|
||||
$log.info('No signing proposal: No private key');
|
||||
popupService.showAler(gettextCatalog.getString('Error'), bwcError.msg('MISSING_PRIVATE_KEY'));
|
||||
popupService.showAlert(gettextCatalog.getString('Error'), bwcError.msg('MISSING_PRIVATE_KEY'));
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -59,7 +59,7 @@ angular.module('copayApp.controllers').controller('buyAmazonController',
|
|||
amazonService.createBitPayInvoice(dataSrc, function(err, dataInvoice) {
|
||||
if (err) {
|
||||
ongoingProcess.set('Processing Transaction...', false);
|
||||
popupService.showAler(gettextCatalog.getString('Error'), bwcError.msg(err));
|
||||
popupService.showAlert(gettextCatalog.getString('Error'), bwcError.msg(err));
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,19 +1,26 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copayApp.controllers').controller('buyGlideraController',
|
||||
function($scope, $timeout, $log, $ionicModal, profileService, walletService, glideraService, bwcError, lodash, ongoingProcess) {
|
||||
function($scope, $timeout, $log, profileService, walletService, glideraService, bwcError, lodash, ongoingProcess, popupService, gettextCatalog) {
|
||||
|
||||
var wallet;
|
||||
var self = this;
|
||||
this.show2faCodeInput = null;
|
||||
this.error = null;
|
||||
this.success = null;
|
||||
|
||||
$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.init = function(accessToken) {
|
||||
$scope.network = glideraService.getEnvironment();
|
||||
|
||||
$scope.token = accessToken;
|
||||
$scope.error = null;
|
||||
$scope.permissions = null;
|
||||
$scope.email = null;
|
||||
$scope.personalInfo = null;
|
||||
|
|
@ -25,7 +32,7 @@ angular.module('copayApp.controllers').controller('buyGlideraController',
|
|||
glideraService.init($scope.token, function(err, glidera) {
|
||||
ongoingProcess.set('connectingGlidera');
|
||||
if (err || !glidera) {
|
||||
$scope.error = err;
|
||||
if (err) popupService.showAlert(gettextCatalog.getString('Error'), err);
|
||||
return;
|
||||
}
|
||||
$scope.token = glidera.token;
|
||||
|
|
@ -33,21 +40,11 @@ angular.module('copayApp.controllers').controller('buyGlideraController',
|
|||
$scope.update({fullUpdate: true});
|
||||
});
|
||||
|
||||
self.allWallets = profileService.getWallets({
|
||||
$scope.wallets = profileService.getWallets({
|
||||
network: $scope.network,
|
||||
n: 1,
|
||||
onlyComplete: true
|
||||
});
|
||||
if (lodash.isEmpty(self.allWallets)) return;
|
||||
|
||||
wallet = self.allWallets[0];
|
||||
if (wallet) {
|
||||
$timeout(function() {
|
||||
self.selectedWalletId = wallet.credentials.walletId;
|
||||
self.selectedWalletName = wallet.credentials.walletName;
|
||||
$scope.$apply();
|
||||
}, 100);
|
||||
}
|
||||
};
|
||||
|
||||
$scope.update = function(opts) {
|
||||
|
|
@ -84,33 +81,6 @@ angular.module('copayApp.controllers').controller('buyGlideraController',
|
|||
}
|
||||
};
|
||||
|
||||
$scope.openWalletsModal = function(wallets) {
|
||||
self.error = null;
|
||||
|
||||
$scope.type = 'BUY';
|
||||
$scope.wallets = wallets;
|
||||
$scope.noColor = true;
|
||||
$scope.self = self;
|
||||
|
||||
$ionicModal.fromTemplateUrl('views/modals/wallets.html', {
|
||||
scope: $scope,
|
||||
animation: 'slide-in-up'
|
||||
}).then(function(modal) {
|
||||
$scope.walletsModal = modal;
|
||||
$scope.walletsModal.show();
|
||||
});
|
||||
|
||||
$scope.$on('walletSelected', function(ev, walletId) {
|
||||
$timeout(function() {
|
||||
wallet = profileService.getClient(walletId);
|
||||
self.selectedWalletId = walletId;
|
||||
self.selectedWalletName = wallet.credentials.walletName;
|
||||
$scope.$apply();
|
||||
}, 100);
|
||||
$scope.walletsModal.hide();
|
||||
});
|
||||
};
|
||||
|
||||
this.getBuyPrice = function(token, price) {
|
||||
var self = this;
|
||||
this.error = null;
|
||||
|
|
@ -122,7 +92,7 @@ angular.module('copayApp.controllers').controller('buyGlideraController',
|
|||
glideraService.buyPrice(token, price, function(err, buyPrice) {
|
||||
self.gettingBuyPrice = false;
|
||||
if (err) {
|
||||
self.error = 'Could not get exchange information. Please, try again.';
|
||||
popupService.showAlert(gettextCatalog.getString('Error'), gettextCatalog.getString('Could not get exchange information. Please, try again'));
|
||||
return;
|
||||
}
|
||||
self.buyPrice = buyPrice;
|
||||
|
|
@ -131,13 +101,12 @@ angular.module('copayApp.controllers').controller('buyGlideraController',
|
|||
|
||||
this.get2faCode = function(token) {
|
||||
var self = this;
|
||||
self.error = null;
|
||||
ongoingProcess.set('Sending 2FA code...', true);
|
||||
$timeout(function() {
|
||||
glideraService.get2faCode(token, function(err, sent) {
|
||||
ongoingProcess.set('Sending 2FA code...', false);
|
||||
if (err) {
|
||||
self.error = 'Could not send confirmation code to your phone';
|
||||
popupService.showAlert(gettextCatalog.getString('Error'), gettextCatalog.getString('Could not send confirmation code to your phone'));
|
||||
return;
|
||||
}
|
||||
self.show2faCodeInput = sent;
|
||||
|
|
@ -147,13 +116,12 @@ angular.module('copayApp.controllers').controller('buyGlideraController',
|
|||
|
||||
this.sendRequest = function(token, permissions, twoFaCode) {
|
||||
var self = this;
|
||||
self.error = null;
|
||||
ongoingProcess.set('Buying Bitcoin...', true);
|
||||
$timeout(function() {
|
||||
walletService.getAddress(wallet, false, function(err, walletAddr) {
|
||||
if (err) {
|
||||
ongoingProcess.set('Buying Bitcoin...', false);
|
||||
self.error = bwcError.cb(err, 'Could not create address');
|
||||
popupService.showAlert(gettextCatalog.getString('Error'), bwcError.cb(err, 'Could not create address'));
|
||||
return;
|
||||
}
|
||||
var data = {
|
||||
|
|
@ -166,11 +134,13 @@ angular.module('copayApp.controllers').controller('buyGlideraController',
|
|||
glideraService.buy(token, twoFaCode, data, function(err, data) {
|
||||
ongoingProcess.set('Buying Bitcoin...', false);
|
||||
if (err) {
|
||||
self.error = err;
|
||||
popupService.showAlert(gettextCatalog.getString('Error'), err);
|
||||
return;
|
||||
}
|
||||
self.success = data;
|
||||
$scope.$emit('Local/GlideraTx');
|
||||
$timeout(function() {
|
||||
$scope.$digest();
|
||||
});
|
||||
});
|
||||
});
|
||||
}, 100);
|
||||
|
|
|
|||
|
|
@ -1,11 +1,7 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copayApp.controllers').controller('glideraController',
|
||||
function($rootScope, $scope, $timeout, $ionicModal, $log, profileService, storageService, glideraService, lodash, ongoingProcess, platformInfo, nodeWebkit) {
|
||||
|
||||
if (platformInfo.isCordova && StatusBar.isVisible) {
|
||||
StatusBar.backgroundColorByHexString("#4B6178");
|
||||
}
|
||||
function($scope, $timeout, $ionicModal, $log, storageService, glideraService, ongoingProcess, platformInfo, nodeWebkit, popupService, gettextCatalog) {
|
||||
|
||||
$scope.openExternalLink = function(url, target) {
|
||||
if (platformInfo.isNW) {
|
||||
|
|
@ -20,7 +16,6 @@ angular.module('copayApp.controllers').controller('glideraController',
|
|||
$scope.network = glideraService.getEnvironment();
|
||||
|
||||
$scope.token = null;
|
||||
$scope.error = null;
|
||||
$scope.permissions = null;
|
||||
$scope.email = null;
|
||||
$scope.personalInfo = null;
|
||||
|
|
@ -32,7 +27,7 @@ angular.module('copayApp.controllers').controller('glideraController',
|
|||
glideraService.init($scope.token, function(err, glidera) {
|
||||
ongoingProcess.set('connectingGlidera');
|
||||
if (err || !glidera) {
|
||||
$scope.error = err;
|
||||
if (err) popupService.showAlert(gettextCatalog.getString('Error'), err);
|
||||
return;
|
||||
}
|
||||
$scope.token = glidera.token;
|
||||
|
|
@ -81,15 +76,11 @@ angular.module('copayApp.controllers').controller('glideraController',
|
|||
|
||||
this.submitOauthCode = function(code) {
|
||||
ongoingProcess.set('connectingGlidera', true);
|
||||
$scope.error = null;
|
||||
$timeout(function() {
|
||||
glideraService.getToken(code, function(err, data) {
|
||||
ongoingProcess.set('connectingGlidera', false);
|
||||
if (err) {
|
||||
$scope.error = err;
|
||||
$timeout(function() {
|
||||
$scope.$apply();
|
||||
}, 100);
|
||||
popupService.showAlert(gettextCatalog.getString('Error'), err);
|
||||
} else if (data && data.access_token) {
|
||||
storageService.setGlideraToken($scope.network, data.access_token, function() {
|
||||
$scope.init(data.access_token);
|
||||
|
|
@ -108,7 +99,11 @@ angular.module('copayApp.controllers').controller('glideraController',
|
|||
$scope.self = self;
|
||||
$scope.tx = tx;
|
||||
|
||||
glideraService.getTransaction(token, tx.transactionUuid, function(error, tx) {
|
||||
glideraService.getTransaction(token, tx.transactionUuid, function(err, tx) {
|
||||
if (err) {
|
||||
popupService.showAlert(gettextCatalog.getString('Error'), gettextCatalog.getString('Could not get transactions'));
|
||||
return;
|
||||
}
|
||||
$scope.tx = tx;
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -1,41 +1,34 @@
|
|||
'use strict';
|
||||
angular.module('copayApp.controllers').controller('glideraUriController',
|
||||
function($scope, $log, $stateParams, $timeout, profileService, configService, glideraService, storageService, $state, ongoingProcess) {
|
||||
function($scope, $log, $stateParams, $timeout, glideraService, storageService, $state, ongoingProcess, popupService, gettextCatalog) {
|
||||
|
||||
this.submitOauthCode = function(code) {
|
||||
var submitOauthCode = function(code) {
|
||||
$log.debug('Glidera Oauth Code:' + code);
|
||||
var self = this;
|
||||
var glideraTestnet = configService.getSync().glidera.testnet;
|
||||
var network = glideraTestnet ? 'testnet' : 'livenet';
|
||||
$scope.network = glideraService.getEnvironment();
|
||||
ongoingProcess.set('connectingGlidera', true);
|
||||
this.error = null;
|
||||
$timeout(function() {
|
||||
glideraService.getToken(code, function(err, data) {
|
||||
ongoingProcess.set('connectingGlidera', false);
|
||||
if (err) {
|
||||
self.error = err;
|
||||
$timeout(function() {
|
||||
$scope.$apply();
|
||||
}, 100);
|
||||
popupService.showAlert(gettextCatalog.getString('Error'), err);
|
||||
} else if (data && data.access_token) {
|
||||
storageService.setGlideraToken(network, data.access_token, function() {
|
||||
$scope.$emit('Local/GlideraUpdated', data.access_token);
|
||||
storageService.setGlideraToken($scope.network, data.access_token, function() {
|
||||
$timeout(function() {
|
||||
$state.go('glidera');
|
||||
$state.go('glidera.main');
|
||||
$scope.$apply();
|
||||
}, 100);
|
||||
}, 500);
|
||||
});
|
||||
}
|
||||
});
|
||||
}, 100);
|
||||
};
|
||||
|
||||
this.checkCode = function() {
|
||||
$scope.checkCode = function() {
|
||||
if ($stateParams.url) {
|
||||
var match = $stateParams.url.match(/code=(.+)/);
|
||||
if (match && match[1]) {
|
||||
this.code = match[1];
|
||||
return this.submitOauthCode(this.code);
|
||||
submitOauthCode(match[1]);
|
||||
return;
|
||||
}
|
||||
}
|
||||
$log.error('Bad state: ' + JSON.stringify($stateParams));
|
||||
|
|
|
|||
|
|
@ -1,13 +1,13 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copayApp.controllers').controller('amazonCardDetailsController', function($scope, $log, $timeout, bwcError, amazonService, lodash, ongoingProcess) {
|
||||
angular.module('copayApp.controllers').controller('amazonCardDetailsController', function($scope, $log, $timeout, bwcError, amazonService, lodash, ongoingProcess, popupService, gettextCatalog) {
|
||||
|
||||
$scope.cancelGiftCard = function() {
|
||||
ongoingProcess.set('Canceling gift card...', true);
|
||||
amazonService.cancelGiftCard($scope.card, function(err, data) {
|
||||
ongoingProcess.set('Canceling gift card...', false);
|
||||
if (err) {
|
||||
$scope.error = bwcError.msg(err);
|
||||
popupService.showAlert(gettextCatalog.getString('Error'), bwcError.msg(err));
|
||||
return;
|
||||
}
|
||||
$scope.card.cardStatus = data.cardStatus;
|
||||
|
|
@ -29,7 +29,7 @@ angular.module('copayApp.controllers').controller('amazonCardDetailsController',
|
|||
$scope.refreshGiftCard = function() {
|
||||
amazonService.getPendingGiftCards(function(err, gcds) {
|
||||
if (err) {
|
||||
self.error = err;
|
||||
popupService.showAlert(gettextCatalog.getString('Error'), err);
|
||||
return;
|
||||
}
|
||||
lodash.forEach(gcds, function(dataFromStorage) {
|
||||
|
|
@ -37,8 +37,7 @@ angular.module('copayApp.controllers').controller('amazonCardDetailsController',
|
|||
$log.debug("creating gift card");
|
||||
amazonService.createGiftCard(dataFromStorage, function(err, giftCard) {
|
||||
if (err) {
|
||||
self.error = bwcError.msg(err);
|
||||
$log.debug(bwcError.msg(err));
|
||||
popupService.showAlert(gettextCatalog.getString('Error'), bwcError.msg(err));
|
||||
return;
|
||||
}
|
||||
if (!lodash.isEmpty(giftCard)) {
|
||||
|
|
|
|||
|
|
@ -1,13 +1,12 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copayApp.controllers').controller('preferencesGlideraController',
|
||||
function($scope, $log, $ionicModal, ongoingProcess, glideraService) {
|
||||
function($scope, $log, $timeout, $state, ongoingProcess, glideraService, popupService, gettextCatalog) {
|
||||
|
||||
$scope.init = function(accessToken) {
|
||||
$scope.network = glideraService.getEnvironment();
|
||||
|
||||
$scope.token = accessToken;
|
||||
$scope.error = null;
|
||||
$scope.permissions = null;
|
||||
$scope.email = null;
|
||||
$scope.personalInfo = null;
|
||||
|
|
@ -19,7 +18,7 @@ angular.module('copayApp.controllers').controller('preferencesGlideraController'
|
|||
glideraService.init($scope.token, function(err, glidera) {
|
||||
ongoingProcess.set('connectingGlidera');
|
||||
if (err || !glidera) {
|
||||
$scope.error = err;
|
||||
if (err) popupService.showAlert(gettextCatalog.getString('Error'), err);
|
||||
return;
|
||||
}
|
||||
$scope.token = glidera.token;
|
||||
|
|
@ -63,11 +62,14 @@ angular.module('copayApp.controllers').controller('preferencesGlideraController'
|
|||
};
|
||||
|
||||
$scope.revokeToken = function() {
|
||||
$ionicModal.fromTemplateUrl('views/modals/glidera-confirmation.html', {
|
||||
scope: $scope
|
||||
}).then(function(modal) {
|
||||
$scope.glideraConfirmationModal = modal;
|
||||
$scope.glideraConfirmationModal.show();
|
||||
popupService.showConfirm('Glidera', 'Are you sure you would like to log out of your Glidera account?', function(res) {
|
||||
if (res) {
|
||||
glideraService.removeToken(function() {
|
||||
$timeout(function() {
|
||||
$state.go('glidera.main');
|
||||
}, 100);
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -1,28 +1,27 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copayApp.controllers').controller('sellGlideraController',
|
||||
function($rootScope, $scope, $timeout, $ionicModal, $log, profileService, glideraService, bwcError, lodash, walletService, fingerprintService, configService, ongoingProcess) {
|
||||
function($scope, $timeout, $log, profileService, glideraService, bwcError, lodash, walletService, configService, ongoingProcess, popupService, gettextCatalog) {
|
||||
|
||||
var self = this;
|
||||
this.data = {};
|
||||
this.show2faCodeInput = null;
|
||||
this.success = null;
|
||||
this.error = null;
|
||||
var wallet;
|
||||
|
||||
var handleEncryptedWallet = function(wallet, cb) {
|
||||
if (!walletService.isEncrypted(wallet)) return cb();
|
||||
$rootScope.$emit('Local/NeedsPassword', false, function(err, password) {
|
||||
if (err) return cb(err);
|
||||
return cb(walletService.unlock(wallet, password));
|
||||
});
|
||||
};
|
||||
$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.init = function(accessToken) {
|
||||
$scope.network = glideraService.getEnvironment();
|
||||
|
||||
$scope.token = accessToken;
|
||||
$scope.error = null;
|
||||
$scope.permissions = null;
|
||||
$scope.email = null;
|
||||
$scope.personalInfo = null;
|
||||
|
|
@ -34,7 +33,7 @@ angular.module('copayApp.controllers').controller('sellGlideraController',
|
|||
glideraService.init($scope.token, function(err, glidera) {
|
||||
ongoingProcess.set('connectingGlidera');
|
||||
if (err || !glidera) {
|
||||
$scope.error = err;
|
||||
if (err) popupService.showAlert(gettextCatalog.getString('Error'), err);
|
||||
return;
|
||||
}
|
||||
$scope.token = glidera.token;
|
||||
|
|
@ -42,21 +41,11 @@ angular.module('copayApp.controllers').controller('sellGlideraController',
|
|||
$scope.update({fullUpdate: true});
|
||||
});
|
||||
|
||||
self.allWallets = profileService.getWallets({
|
||||
$scope.wallets = profileService.getWallets({
|
||||
network: $scope.network,
|
||||
n: 1,
|
||||
onlyComplete: true
|
||||
});
|
||||
if (lodash.isEmpty(self.allWallets)) return;
|
||||
|
||||
wallet = self.allWallets[0];
|
||||
if (wallet) {
|
||||
$timeout(function() {
|
||||
self.selectedWalletId = wallet.credentials.walletId;
|
||||
self.selectedWalletName = wallet.credentials.walletName;
|
||||
$scope.$apply();
|
||||
}, 100);
|
||||
}
|
||||
};
|
||||
|
||||
$scope.update = function(opts) {
|
||||
|
|
@ -93,36 +82,8 @@ angular.module('copayApp.controllers').controller('sellGlideraController',
|
|||
}
|
||||
};
|
||||
|
||||
$scope.openWalletsModal = function(wallets) {
|
||||
self.error = null;
|
||||
|
||||
$scope.type = 'SELL';
|
||||
$scope.wallets = wallets;
|
||||
$scope.noColor = true;
|
||||
$scope.self = self;
|
||||
|
||||
$ionicModal.fromTemplateUrl('views/modals/wallets.html', {
|
||||
scope: $scope,
|
||||
animation: 'slide-in-up'
|
||||
}).then(function(modal) {
|
||||
$scope.walletsModal = modal;
|
||||
$scope.walletsModal.show();
|
||||
});
|
||||
|
||||
$scope.$on('walletSelected', function(ev, walletId) {
|
||||
$timeout(function() {
|
||||
wallet = profileService.getClient(walletId);
|
||||
self.selectedWalletId = walletId;
|
||||
self.selectedWalletName = wallet.credentials.walletName;
|
||||
$scope.$apply();
|
||||
}, 100);
|
||||
$scope.walletsModal.hide();
|
||||
});
|
||||
};
|
||||
|
||||
this.getSellPrice = function(token, price) {
|
||||
var self = this;
|
||||
self.error = null;
|
||||
if (!price || (price && !price.qty && !price.fiat)) {
|
||||
self.sellPrice = null;
|
||||
return;
|
||||
|
|
@ -131,7 +92,7 @@ angular.module('copayApp.controllers').controller('sellGlideraController',
|
|||
glideraService.sellPrice(token, price, function(err, sellPrice) {
|
||||
self.gettingSellPrice = false;
|
||||
if (err) {
|
||||
self.error = 'Could not get exchange information. Please, try again.';
|
||||
popupService.showAlert(gettextCatalog.getString('Error'), gettextCatalog.getString('Could not get exchange information. Please, try again'));
|
||||
return;
|
||||
}
|
||||
self.sellPrice = sellPrice;
|
||||
|
|
@ -145,7 +106,7 @@ angular.module('copayApp.controllers').controller('sellGlideraController',
|
|||
glideraService.get2faCode(token, function(err, sent) {
|
||||
ongoingProcess.set('Sending 2FA code...', false);
|
||||
if (err) {
|
||||
self.error = 'Could not send confirmation code to your phone';
|
||||
popupService.showAlert(gettextCatalog.getString('Error'), gettextCatalog.getString('Could not send confirmation code to your phone'));
|
||||
} else {
|
||||
self.show2faCodeInput = sent;
|
||||
}
|
||||
|
|
@ -155,29 +116,27 @@ angular.module('copayApp.controllers').controller('sellGlideraController',
|
|||
|
||||
this.createTx = function(token, permissions, twoFaCode) {
|
||||
var self = this;
|
||||
self.error = null;
|
||||
var outputs = [];
|
||||
var config = configService.getSync();
|
||||
var configWallet = config.wallet;
|
||||
var walletSettings = configWallet.settings;
|
||||
|
||||
if (!wallet) {
|
||||
self.error = 'No wallet selected';
|
||||
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();
|
||||
self.error = bwcError.msg(err, 'Could not create address');
|
||||
popupService.showAlert(gettextCatalog.getString('Error'), bwcError.msg(err, 'Could not create address'));
|
||||
return;
|
||||
}
|
||||
glideraService.getSellAddress(token, function(error, sellAddress) {
|
||||
if (!sellAddress) {
|
||||
glideraService.getSellAddress(token, function(err, sellAddress) {
|
||||
if (!sellAddress || err) {
|
||||
ongoingProcess.clear();
|
||||
self.error = 'Could not get the destination bitcoin address';
|
||||
popupService.showAlert(gettextCatalog.getString('Error'), gettextCatalog.getString('Could not get the destination bitcoin address'));
|
||||
return;
|
||||
}
|
||||
var amount = parseInt((self.sellPrice.qty * 100000000).toFixed(0));
|
||||
|
|
@ -205,28 +164,30 @@ angular.module('copayApp.controllers').controller('sellGlideraController',
|
|||
walletService.createTx(wallet, txp, function(err, createdTxp) {
|
||||
ongoingProcess.clear();
|
||||
if (err) {
|
||||
self.error = err.message || bwcError.msg(err);
|
||||
popupService.showAlert(gettextCatalog.getString('Error'), err.message || bwcError.msg(err));
|
||||
return;
|
||||
}
|
||||
walletService.prepare(wallet, txp, function(err, password) {
|
||||
walletService.prepare(wallet, function(err, password) {
|
||||
if (err) {
|
||||
self.error = err.message || bwcError.msg(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();
|
||||
self.error = err.message || bwcError.msg(err);
|
||||
popupService.showAlert(gettextCatalog.getString('Error'), err.message || bwcError.msg(err));
|
||||
return;
|
||||
}
|
||||
|
||||
walletService.signTx(wallet, publishedTxp, function(err, password, signedTxp) {
|
||||
walletService.removeTx(wallet, signedTxp, function(err) {
|
||||
if (err) $log.debug(err);
|
||||
});
|
||||
ongoingProcess.clear();
|
||||
walletService.signTx(wallet, publishedTxp, password, function(err, signedTxp) {
|
||||
if (err) {
|
||||
self.error = err.message || bwcError.msg(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;
|
||||
|
|
@ -237,15 +198,17 @@ angular.module('copayApp.controllers').controller('sellGlideraController',
|
|||
useCurrentPrice: self.sellPrice.priceUuid ? false : true,
|
||||
ip: null
|
||||
};
|
||||
ongoingProcess.set('Seling Bitcoin', true);
|
||||
ongoingProcess.set('Selling Bitcoin', true);
|
||||
glideraService.sell(token, twoFaCode, data, function(err, data) {
|
||||
ongoingProcess.clear();
|
||||
if (err) {
|
||||
self.error = err.message || bwcError.msg(err);
|
||||
popupService.showAlert(gettextCatalog.getString('Error'), err.message || bwcError.msg(err));
|
||||
return;
|
||||
}
|
||||
self.success = data;
|
||||
$scope.update();
|
||||
$timeout(function() {
|
||||
$scope.$digest();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -824,7 +824,7 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr
|
|||
});
|
||||
|
||||
$ionicPlatform.on('resume', function() {
|
||||
$rootScope.$emit('Local/Resume');
|
||||
// Nothing tot do
|
||||
});
|
||||
|
||||
$ionicPlatform.on('menubutton', function() {
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copayApp.services').factory('incomingData', function($log, $ionicModal, $state, bitcore) {
|
||||
|
||||
|
||||
var root = {};
|
||||
|
||||
root.redir = function(data) {
|
||||
|
|
@ -32,7 +32,7 @@ angular.module('copayApp.services').factory('incomingData', function($log, $ioni
|
|||
|
||||
data = sanitizeUri(data);
|
||||
|
||||
// BIP21
|
||||
// BIP21
|
||||
if (bitcore.URI.isValid(data)) {
|
||||
var parsed = new bitcore.URI(data);
|
||||
|
||||
|
|
@ -52,7 +52,7 @@ angular.module('copayApp.services').factory('incomingData', function($log, $ioni
|
|||
}
|
||||
return true;
|
||||
|
||||
// Plain URL
|
||||
// Plain URL
|
||||
} else if (/^https?:\/\//.test(data)) {
|
||||
return $state.go('send.confirm', {paypro: data})
|
||||
|
||||
|
|
@ -64,10 +64,10 @@ angular.module('copayApp.services').factory('incomingData', function($log, $ioni
|
|||
|
||||
|
||||
// copay: protocol
|
||||
} else if (data.indexOf('copay:glidera')==0) {
|
||||
return $state.go('send.uriglidera', {url: data})
|
||||
} else if (data.indexOf('copay:coinbase')==0) {
|
||||
return $state.go('send.uricoinbase', {url: data})
|
||||
} else if (data.indexOf('copay://glidera')==0) {
|
||||
return $state.go('uriglidera', {url: data})
|
||||
} else if (data.indexOf('copay://coinbase')==0) {
|
||||
return $state.go('uricoinbase', {url: data})
|
||||
|
||||
// Join
|
||||
} else if (data.match(/^copay:[0-9A-HJ-NP-Za-km-z]{70,80}$/)) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue