From 4042d04f1bdf1c1566ab79fd92d601408008d9cd Mon Sep 17 00:00:00 2001 From: Javier Date: Tue, 20 Oct 2015 12:46:46 -0300 Subject: [PATCH] refactor bws control on import --- src/js/controllers/import.js | 47 +++++++++++-------------------- src/js/services/profileService.js | 3 -- 2 files changed, 17 insertions(+), 33 deletions(-) diff --git a/src/js/controllers/import.js b/src/js/controllers/import.js index a12b6f0dc..b473c8fdc 100644 --- a/src/js/controllers/import.js +++ b/src/js/controllers/import.js @@ -23,14 +23,6 @@ angular.module('copayApp.controllers').controller('importController', }); }; - var setBwsURL = function(walletId, cb) { - var opts = { - bws: {} - }; - opts.bws[walletId] = $scope.bwsurl; - configService.set(opts, cb); - } - var _importBlob = function(str, opts) { var str2, err; try { @@ -58,10 +50,8 @@ angular.module('copayApp.controllers').controller('importController', if (err) { self.error = err; } else { - setBwsURL(walletId, function() { - $rootScope.$emit('Local/WalletImported', walletId); - notification.success(gettext('Success'), gettext('Your wallet has been imported correctly')); - }); + $rootScope.$emit('Local/WalletImported', walletId); + notification.success(gettext('Success'), gettext('Your wallet has been imported correctly')); } }); }, 100); @@ -79,11 +69,8 @@ angular.module('copayApp.controllers').controller('importController', $scope.$apply(); }); } - - setBwsURL(walletId, function() { - $rootScope.$emit('Local/WalletImported', walletId); - notification.success(gettext('Success'), gettext('Your wallet has been imported correctly')); - }); + $rootScope.$emit('Local/WalletImported', walletId); + notification.success(gettext('Success'), gettext('Your wallet has been imported correctly')); }); }, 100); }; @@ -100,10 +87,8 @@ angular.module('copayApp.controllers').controller('importController', $scope.$apply(); }); } - setBwsURL(walletId, function() { - $rootScope.$emit('Local/WalletImported', walletId); - notification.success(gettext('Success'), gettext('Your wallet has been imported correctly')); - }); + $rootScope.$emit('Local/WalletImported', walletId); + notification.success(gettext('Success'), gettext('Your wallet has been imported correctly')); }); }, 100); }; @@ -211,9 +196,12 @@ angular.module('copayApp.controllers').controller('importController', $scope.$apply(); return; } + lopts.externalSource = 'trezor'; + lopts.bwsurl = $scope.bwsurl; self.loading = true; $log.debug('Import opts', lopts); + profileService.importExtendedPublicKey(lopts, function(err, walletId) { self.loading = false; if (err) { @@ -222,11 +210,9 @@ angular.module('copayApp.controllers').controller('importController', $scope.$apply(); }); } - setBwsURL(walletId, function() { - $rootScope.$emit('Local/WalletImported', walletId); - notification.success(gettext('Success'), gettext('Your wallet has been imported correctly')); - go.walletHome(); - }); + $rootScope.$emit('Local/WalletImported', walletId); + notification.success(gettext('Success'), gettext('Your wallet has been imported correctly')); + go.walletHome(); }); }, 100); }; @@ -249,9 +235,12 @@ angular.module('copayApp.controllers').controller('importController', $scope.$apply(); return; } + lopts.externalSource = 'ledger'; + lopts.bwsurl = $scope.bwsurl; self.loading = true; $log.debug('Import opts', lopts); + profileService.importExtendedPublicKey(lopts, function(err, walletId) { self.loading = false; if (err) { @@ -260,10 +249,8 @@ angular.module('copayApp.controllers').controller('importController', $scope.$apply(); }); } - setBwsURL(walletId, function() { - $rootScope.$emit('Local/WalletImported', walletId); - notification.success(gettext('Success'), gettext('Your wallet has been imported correctly')); - }); + $rootScope.$emit('Local/WalletImported', walletId); + notification.success(gettext('Success'), gettext('Your wallet has been imported correctly')); }); }, 100); }; diff --git a/src/js/services/profileService.js b/src/js/services/profileService.js index b4f69f8be..f108f0e38 100644 --- a/src/js/services/profileService.js +++ b/src/js/services/profileService.js @@ -441,9 +441,6 @@ angular.module('copayApp.services') }; root.importLegacyWallet = function(username, password, blob, cb) { - if (opts.bwsurl) - bwcService.setBaseUrl(opts.bwsurl); - var walletClient = bwcService.getClient(); walletClient.createWalletFromOldCopay(username, password, blob, function(err, existed) {