From b2e92b9424837a78110768a71169e73d13d1f42e Mon Sep 17 00:00:00 2001 From: Javier Date: Thu, 15 Oct 2015 16:32:10 -0300 Subject: [PATCH 01/19] bws is moved to preferences->advanced and set it locally --- public/views/preferences.html | 7 ------- public/views/preferencesAdvanced.html | 5 +++++ public/views/preferencesBwsUrl.html | 2 +- src/js/controllers/preferencesBwsUrl.js | 15 ++++++++------- 4 files changed, 14 insertions(+), 15 deletions(-) diff --git a/public/views/preferences.html b/public/views/preferences.html index 3a46128c1..e564d38dc 100644 --- a/public/views/preferences.html +++ b/public/views/preferences.html @@ -115,13 +115,6 @@ Enable Glidera Service -
  • - Bitcore Wallet Service - - - {{preferences.bwsurl}} - -
  • - diff --git a/src/js/controllers/create.js b/src/js/controllers/create.js index 8c1442016..b4cb64337 100644 --- a/src/js/controllers/create.js +++ b/src/js/controllers/create.js @@ -4,7 +4,6 @@ angular.module('copayApp.controllers').controller('createController', function($scope, $rootScope, $location, $timeout, $log, lodash, go, profileService, configService, isCordova, gettext, ledger, trezor, isMobile) { var self = this; - var config = configService.getSync(); var defaults = configService.getDefaults(); this.isWindowsPhoneApp = isMobile.Windows() && isCordova; diff --git a/src/js/controllers/import.js b/src/js/controllers/import.js index 81359e7ed..ddf1c5fb2 100644 --- a/src/js/controllers/import.js +++ b/src/js/controllers/import.js @@ -1,11 +1,12 @@ 'use strict'; angular.module('copayApp.controllers').controller('importController', - function($scope, $rootScope, $location, $timeout, $log, profileService, notification, go, sjcl, gettext, lodash, ledger, trezor) { + function($scope, $rootScope, $location, $timeout, $log, profileService, configService, notification, go, sjcl, gettext, lodash, ledger, trezor) { var self = this; - var reader = new FileReader(); + var defaults = configService.getDefaults(); + $scope.bwsurl = defaults.bws.url; window.ignoreMobilePause = true; $scope.$on('$destroy', function() { @@ -22,6 +23,19 @@ angular.module('copayApp.controllers').controller('importController', }); }; + var setBwsurl = function(walletId, cb) { + var opts = { + bws: {} + }; + opts.bws[walletId] = $scope.bwsurl; + configService.set(opts, function(err) { + if (err) return cb(err); + $scope.$emit('Local/BWSUpdated'); + applicationService.restart(); + return cb(null); + }); + } + var _importBlob = function(str, opts) { var str2, err; try { @@ -50,15 +64,16 @@ angular.module('copayApp.controllers').controller('importController', if (err) { self.error = err; } else { - $rootScope.$emit('Local/WalletImported', walletId); - go.walletHome(); - notification.success(gettext('Success'), gettext('Your wallet has been imported correctly')); + setBwsurl(walletId, function() { + $rootScope.$emit('Local/WalletImported', walletId); + go.walletHome(); + notification.success(gettext('Success'), gettext('Your wallet has been imported correctly')); + }); } }); }, 100); }; - var _importExtendedPrivateKey = function(xPrivKey) { self.loading = true; @@ -71,15 +86,16 @@ angular.module('copayApp.controllers').controller('importController', $scope.$apply(); }); } - $rootScope.$emit('Local/WalletImported', walletId); - notification.success(gettext('Success'), gettext('Your wallet has been imported correctly')); - go.walletHome(); + + setBwsurl(walletId, function() { + $rootScope.$emit('Local/WalletImported', walletId); + notification.success(gettext('Success'), gettext('Your wallet has been imported correctly')); + go.walletHome(); + }); }); }, 100); }; - - var _importMnemonic = function(words, opts) { self.loading = true; @@ -92,9 +108,11 @@ angular.module('copayApp.controllers').controller('importController', $scope.$apply(); }); } - $rootScope.$emit('Local/WalletImported', walletId); - notification.success(gettext('Success'), gettext('Your wallet has been imported correctly')); - go.walletHome(); + setBwsurl(walletId, function() { + $rootScope.$emit('Local/WalletImported', walletId); + notification.success(gettext('Success'), gettext('Your wallet has been imported correctly')); + go.walletHome(); + }); }); }, 100); }; @@ -138,7 +156,6 @@ angular.module('copayApp.controllers').controller('importController', } }; - this.importMnemonic = function(form) { if (form.$invalid) { this.error = gettext('There is an error in the form'); @@ -157,7 +174,7 @@ angular.module('copayApp.controllers').controller('importController', if (!words) { this.error = gettext('Please enter the seed words'); - } else if (words.indexOf('xprv') == 0 || words.indexOf('tprv') == 0) { + } else if (words.indexOf('xprv') == 0 || words.indexOf('tprv') == 0) { return _importExtendedPrivateKey(words) } else { var wordList = words.split(/[\u3000\s]+/); @@ -173,7 +190,6 @@ angular.module('copayApp.controllers').controller('importController', return; } - opts.passphrase = form.passphrase.$modelValue || null; opts.networkName = form.isTestnet.$modelValue ? 'testnet' : 'livenet'; @@ -209,15 +225,15 @@ angular.module('copayApp.controllers').controller('importController', $scope.$apply(); }); } - $rootScope.$emit('Local/WalletImported', walletId); - notification.success(gettext('Success'), gettext('Your wallet has been imported correctly')); - go.walletHome(); + setBwsurl(walletId, function() { + $rootScope.$emit('Local/WalletImported', walletId); + notification.success(gettext('Success'), gettext('Your wallet has been imported correctly')); + go.walletHome(); + }); }); }, 100); }; - - this.importLedger = function(form) { var self = this; if (form.$invalid) { @@ -247,9 +263,11 @@ angular.module('copayApp.controllers').controller('importController', $scope.$apply(); }); } - $rootScope.$emit('Local/WalletImported', walletId); - notification.success(gettext('Success'), gettext('Your wallet has been imported correctly')); - go.walletHome(); + setBwsurl(walletId, function() { + $rootScope.$emit('Local/WalletImported', walletId); + notification.success(gettext('Success'), gettext('Your wallet has been imported correctly')); + go.walletHome(); + }); }); }, 100); }; From a75bbe6e4554a2a296df30411a3106165c7e673c Mon Sep 17 00:00:00 2001 From: Javier Date: Fri, 16 Oct 2015 13:00:41 -0300 Subject: [PATCH 05/19] add bws settings in join wallet --- public/views/join.html | 7 +++++++ src/js/controllers/join.js | 27 +++++++++++++++++++++------ 2 files changed, 28 insertions(+), 6 deletions(-) diff --git a/public/views/join.html b/public/views/join.html index 6dda21922..0ff5ffe8b 100644 --- a/public/views/join.html +++ b/public/views/join.html @@ -77,6 +77,13 @@
    + + +
    - + +
    +
    + +
    +
    + -
    + + + +
    +
    + + +
    +
    +