Fix bwcError service

This commit is contained in:
Gustavo Maximiliano Cortez 2016-07-13 14:00:21 -03:00
commit c8058fefa4
No known key found for this signature in database
GPG key ID: 15EDAD8D9F2EB1AF

View file

@ -1,8 +1,8 @@
'use strict'; 'use strict';
angular.module('copayApp.controllers').controller('buyAmazonController', angular.module('copayApp.controllers').controller('buyAmazonController',
function($rootScope, $scope, $ionicModal, $log, $timeout, lodash, profileService, bwsError, configService, walletService, fingerprintService, amazonService, ongoingProcess) { function($rootScope, $scope, $ionicModal, $log, $timeout, lodash, profileService, bwcError, configService, walletService, fingerprintService, amazonService, ongoingProcess) {
var self = this; var self = this;
var client; var client;
@ -21,7 +21,7 @@ angular.module('copayApp.controllers').controller('buyAmazonController',
amazonService.initUuid(); amazonService.initUuid();
self.allWallets = profileService.getWallets(network, 1); self.allWallets = profileService.getWallets(network, 1);
client = profileService.focusedClient; client = profileService.focusedClient;
if (client && client.credentials.m == 1) { if (client && client.credentials.m == 1) {
$timeout(function() { $timeout(function() {
self.selectedWalletId = client.credentials.walletId; self.selectedWalletId = client.credentials.walletId;
self.selectedWalletName = client.credentials.walletName; self.selectedWalletName = client.credentials.walletName;
@ -59,7 +59,7 @@ angular.module('copayApp.controllers').controller('buyAmazonController',
self.errorInfo = null; self.errorInfo = null;
var currency_code = configService.getSync().amazon.testnet ? window.amazon_sandbox_currency_code : window.amazon_currency_code; var currency_code = configService.getSync().amazon.testnet ? window.amazon_sandbox_currency_code : window.amazon_currency_code;
var dataSrc = { var dataSrc = {
price: $scope.fiat, price: $scope.fiat,
currency: currency_code, currency: currency_code,
orderId: self.selectedWalletName orderId: self.selectedWalletName
@ -76,7 +76,7 @@ angular.module('copayApp.controllers').controller('buyAmazonController',
amazonService.createBitPayInvoice(dataSrc, function(err, data) { amazonService.createBitPayInvoice(dataSrc, function(err, data) {
if (err) { if (err) {
ongoingProcess.set('Processing Transaction...', false); ongoingProcess.set('Processing Transaction...', false);
self.error = bwsError.msg(err); self.error = bwcError.msg(err);
$timeout(function() { $timeout(function() {
$scope.$digest(); $scope.$digest();
}); });
@ -94,7 +94,7 @@ angular.module('copayApp.controllers').controller('buyAmazonController',
'amount': amount, 'amount': amount,
'message': comment 'message': comment
}); });
var txp = { var txp = {
toAddress: address, toAddress: address,
amount: amount, amount: amount,
@ -108,18 +108,18 @@ angular.module('copayApp.controllers').controller('buyAmazonController',
walletService.createTx(client, txp, function(err, createdTxp) { walletService.createTx(client, txp, function(err, createdTxp) {
ongoingProcess.set('Processing Transaction...', false); ongoingProcess.set('Processing Transaction...', false);
if (err) { if (err) {
self.error = bwsError.msg(err); self.error = bwcError.msg(err);
$timeout(function() { $timeout(function() {
$scope.$digest(); $scope.$digest();
}); });
return; return;
} }
$scope.$emit('Local/NeedsConfirmation', createdTxp, function(accept) { $scope.$emit('Local/NeedsConfirmation', createdTxp, function(accept) {
if (accept) { if (accept) {
self.confirmTx(createdTxp, function(err, tx) { self.confirmTx(createdTxp, function(err, tx) {
if (err) { if (err) {
ongoingProcess.set('Processing Transaction...', false); ongoingProcess.set('Processing Transaction...', false);
self.error = bwsError.msg(err); self.error = bwcError.msg(err);
$timeout(function() { $timeout(function() {
$scope.$digest(); $scope.$digest();
}); });
@ -134,8 +134,8 @@ angular.module('copayApp.controllers').controller('buyAmazonController',
ongoingProcess.set('Processing Transaction...', true); ongoingProcess.set('Processing Transaction...', true);
amazonService.createGiftCard(gift, function(err, giftCard) { amazonService.createGiftCard(gift, function(err, giftCard) {
ongoingProcess.set('Processing Transaction...', false); ongoingProcess.set('Processing Transaction...', false);
if (err) { if (err) {
self.error = bwsError.msg(err); self.error = bwcError.msg(err);
self.errorInfo = gift; self.errorInfo = gift;
$timeout(function() { $timeout(function() {
$scope.$digest(); $scope.$digest();
@ -167,14 +167,14 @@ angular.module('copayApp.controllers').controller('buyAmazonController',
handleEncryptedWallet(client, function(err) { handleEncryptedWallet(client, function(err) {
if (err) { if (err) {
$log.debug(err); $log.debug(err);
return bwsError.cb(err, null, cb); return bwcError.cb(err, null, cb);
} }
ongoingProcess.set('Processing Transaction...', true); ongoingProcess.set('Processing Transaction...', true);
walletService.publishTx(client, txp, function(err, publishedTxp) { walletService.publishTx(client, txp, function(err, publishedTxp) {
if (err) { if (err) {
$log.debug(err); $log.debug(err);
return bwsError.cb(err, null, cb); return bwcError.cb(err, null, cb);
} }
walletService.signTx(client, publishedTxp, function(err, signedTxp) { walletService.signTx(client, publishedTxp, function(err, signedTxp) {
@ -184,7 +184,7 @@ angular.module('copayApp.controllers').controller('buyAmazonController',
walletService.removeTx(client, signedTxp, function(err) { walletService.removeTx(client, signedTxp, function(err) {
if (err) $log.debug(err); if (err) $log.debug(err);
}); });
return bwsError.cb(err, null, cb); return bwcError.cb(err, null, cb);
} }
walletService.broadcastTx(client, signedTxp, function(err, broadcastedTxp) { walletService.broadcastTx(client, signedTxp, function(err, broadcastedTxp) {
@ -193,7 +193,7 @@ angular.module('copayApp.controllers').controller('buyAmazonController',
walletService.removeTx(client, broadcastedTxp, function(err) { walletService.removeTx(client, broadcastedTxp, function(err) {
if (err) $log.debug(err); if (err) $log.debug(err);
}); });
return bwsError.cb(err, null, cb); return bwcError.cb(err, null, cb);
} }
$timeout(function() { $timeout(function() {
return cb(null, broadcastedTxp); return cb(null, broadcastedTxp);