From f2257f2519444155d7106ff6a249097ef135e40d Mon Sep 17 00:00:00 2001 From: Javier Date: Tue, 6 Sep 2016 15:11:02 -0300 Subject: [PATCH] import from phrase and text done --- public/views/add.html | 2 +- public/views/import.html | 56 ++++++----- public/views/tab-import-file.html | 95 ++++++++---------- public/views/tab-import-hardware.html | 111 +++++++++------------- public/views/tab-import-phrase.html | 132 +++++++++++--------------- src/js/controllers/import.js | 43 ++++----- src/js/directives/directives.js | 2 +- src/js/routes.js | 50 ---------- 8 files changed, 195 insertions(+), 296 deletions(-) diff --git a/public/views/add.html b/public/views/add.html index 4b24c8da7..32081b939 100644 --- a/public/views/add.html +++ b/public/views/add.html @@ -20,7 +20,7 @@ - +

Import wallet

diff --git a/public/views/import.html b/public/views/import.html index 17e6187aa..8f1eb7261 100644 --- a/public/views/import.html +++ b/public/views/import.html @@ -1,33 +1,41 @@ - + + + {{'Import Wallet' | translate}} + + + + + + +
+
+ Recovery phrase +
+
+ File/Text +
+
+ Hardware wallet +
+
+ +
+
+
+
+
+ + + diff --git a/public/views/tab-import-file.html b/public/views/tab-import-file.html index 07cae197b..76946086d 100644 --- a/public/views/tab-import-file.html +++ b/public/views/tab-import-file.html @@ -1,61 +1,40 @@ - - - - - - {{'Import wallet' | translate}} - - - - -
- -
- - - - - - - - - Show advanced options - Hide advanced options - - -
- - - -
+ +
+ - - + - - + + + + Show advanced options + Hide advanced options + + +
+ +
+
+ + + diff --git a/public/views/tab-import-hardware.html b/public/views/tab-import-hardware.html index 835a46328..5f0b7c1b6 100644 --- a/public/views/tab-import-hardware.html +++ b/public/views/tab-import-hardware.html @@ -1,69 +1,50 @@ - - - - - - {{'Import wallet' | translate}} - +
+
+
+ No hardware wallets supported on this device +
+
- - - - -
-
- No hardware wallets supported on this device +
+
+ + + + + + Shared Wallet + + + + Show advanced options + Hide advanced options + + +
+ +
+
-
-
- - - - - - - Shared Wallet - - - - Show advanced options - Hide advanced options - - -
- - - -
-
- - -
- - - - - + +
+ diff --git a/public/views/tab-import-phrase.html b/public/views/tab-import-phrase.html index 0473f6944..91447b758 100644 --- a/public/views/tab-import-phrase.html +++ b/public/views/tab-import-phrase.html @@ -1,84 +1,66 @@ - - - - - - Import wallet - +
+
Could not access the wallet at the server. Please check:
+
    +
  • The password of the recovery phrase (if set)
  • +
  • The derivation path
  • +
  • The wallet service URL
  • +
+
+ NOTE: To import a wallet from a 3rd party software, please go to Add Wallet > Create Wallet, and specify the Recovery Phrase there. +
+
- - -
-
Could not access the wallet at the server. Please check:
-
    -
  • The password of the recovery phrase (if set)
  • -
  • The derivation path
  • -
  • The wallet service URL
  • -
-
- NOTE: To import a wallet from a 3rd party software, please go to Add Wallet > Create Wallet, and specify the Recovery Phrase there. +
+
+
+
+ +
+
+
- -
+ + Show advanced options + Hide advanced options + -
-
- -
-
- -
-
+
+ - - Show advanced options - Hide advanced options - + -
+ - + + Testnet + +
+
- - - - - - Testnet - -
-
- - -
- - + + diff --git a/src/js/controllers/import.js b/src/js/controllers/import.js index 4ba74e011..8206ed56b 100644 --- a/src/js/controllers/import.js +++ b/src/js/controllers/import.js @@ -8,11 +8,13 @@ angular.module('copayApp.controllers').controller('importController', var reader = new FileReader(); var defaults = configService.getDefaults(); var errors = bwcService.getErrors(); + var derivationPath = 'livenet'; $scope.isSafari = platformInfo.isSafari; $scope.isCordova = platformInfo.isCordova; - $scope.bwsurl = defaults.bws.url; - $scope.derivationPath = derivationPathHelper.default; - $scope.account = 1; + $scope.formData = {}; + $scope.formData.bwsurl = defaults.bws.url; + $scope.formData.derivationPath = derivationPathHelper.default; + $scope.formData.account = 1; $scope.importErr = false; var updateSeedSourceSelect = function() { @@ -75,7 +77,7 @@ angular.module('copayApp.controllers').controller('importController', var _importBlob = function(str, opts) { var str2, err; try { - str2 = sjcl.decrypt($scope.password, str); + str2 = sjcl.decrypt($scope.formData.password, str); } catch (e) { err = gettextCatalog.getString('Could not decrypt file, check your password'); $log.warn(e); @@ -147,7 +149,7 @@ angular.module('copayApp.controllers').controller('importController', if (err) $log.error(err); }); } - + $state.go('tabs.home'); }); }, 100); @@ -176,11 +178,8 @@ angular.module('copayApp.controllers').controller('importController', }, 100); }; - $scope.setDerivationPath = function(testnetEnabled) { - if (testnetEnabled) - $scope.derivationPath = derivationPathHelper.defaultTestnet; - else - $scope.derivationPath = derivationPathHelper.default; + $scope.setDerivationPath = function() { + derivationPath = $scope.formData.testnetEnabled ? derivationPathHelper.defaultTestnet : derivationPathHelper.default; }; $scope.getFile = function() { @@ -188,7 +187,7 @@ angular.module('copayApp.controllers').controller('importController', reader.onloadend = function(evt) { if (evt.target.readyState == FileReader.DONE) { // DONE == 2 var opts = {}; - opts.bwsurl = $scope.bwsurl; + opts.bwsurl = $scope.formData.bwsurl; _importBlob(evt.target.result, opts); } } @@ -200,9 +199,9 @@ angular.module('copayApp.controllers').controller('importController', return; } - var backupFile = $scope.file; - var backupText = form.backupText.$modelValue; - var password = form.password.$modelValue; + var backupFile = $scope.formData.file; + var backupText = $scope.formData.backupText; + var password = $scope.formData.password; if (!backupFile && !backupText) { popupService.showAlert(gettextCatalog.getString('Error'), gettextCatalog.getString('Please, select your backup file')); @@ -213,7 +212,7 @@ angular.module('copayApp.controllers').controller('importController', reader.readAsBinaryString(backupFile); } else { var opts = {}; - opts.bwsurl = $scope.bwsurl; + opts.bwsurl = $scope.formData.bwsurl; _importBlob(backupText, opts); } }; @@ -225,19 +224,21 @@ angular.module('copayApp.controllers').controller('importController', } var opts = {}; - if ($scope.bwsurl) - opts.bwsurl = $scope.bwsurl; - var pathData = derivationPathHelper.parse($scope.derivationPath); + if ($scope.formData.bwsurl) + opts.bwsurl = $scope.formData.bwsurl; + + var pathData = derivationPathHelper.parse(derivationPath); if (!pathData) { popupService.showAlert(gettextCatalog.getString('Error'), gettextCatalog.getString('Invalid derivation path')); return; } + opts.account = pathData.account; opts.networkName = pathData.networkName; opts.derivationStrategy = pathData.derivationStrategy; - var words = form.words.$modelValue || null; + var words = $scope.formData.words || null; if (!words) { popupService.showAlert(gettextCatalog.getString('Please enter the recovery phrase')); @@ -254,9 +255,7 @@ angular.module('copayApp.controllers').controller('importController', } } - var passphrase = form.passphrase.$modelValue; - opts.passphrase = form.passphrase.$modelValue || null; - + opts.passphrase = $scope.formData.passphrase || null; _importMnemonic(words, opts); }; diff --git a/src/js/directives/directives.js b/src/js/directives/directives.js index 88458c146..d9bee9bf3 100644 --- a/src/js/directives/directives.js +++ b/src/js/directives/directives.js @@ -107,7 +107,7 @@ angular.module('copayApp.directives') return { link: function($scope, el) { el.bind('change', function(e) { - $scope.file = (e.srcElement || e.target).files[0]; + $scope.formData.file = (e.srcElement || e.target).files[0]; $scope.getFile(); }); } diff --git a/src/js/routes.js b/src/js/routes.js index bde25a606..e5899e480 100644 --- a/src/js/routes.js +++ b/src/js/routes.js @@ -276,37 +276,12 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr }) .state('tabs.import', { url: '/import', - // abstract: true, views: { 'tab-home': { templateUrl: 'views/import.html' }, }, }) - .state('tabs.import.phrase', { - url: '/tab-import-phrase', - views: { - 'tab-import-phrase': { - templateUrl: 'views/tab-import-phrase.html', - }, - } - }) - .state('tabs.import.file', { - url: '/tab-import-file', - views: { - 'tab-import-file': { - templateUrl: 'views/tab-import-file.html', - }, - } - }) - .state('tabs.import.hardware', { - url: '/tab-import-hardware', - views: { - 'tab-import-hardware': { - templateUrl: 'views/tab-import-hardware.html', - }, - } - }) .state('tabs.create', { url: '/create', views: { @@ -626,7 +601,6 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr }) .state('onboarding.import', { url: '/import', - abstract: true, views: { 'onboarding': { templateUrl: 'views/import.html' @@ -637,30 +611,6 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr fromOnboarding: null }, }) - .state('onboarding.import.phrase', { - url: '/tab-import-phrase', - views: { - 'tab-import-phrase': { - templateUrl: 'views/tab-import-phrase.html', - }, - } - }) - .state('onboarding.import.file', { - url: '/tab-import-file', - views: { - 'tab-import-file': { - templateUrl: 'views/tab-import-file.html', - }, - } - }) - .state('onboarding.import.hardware', { - url: '/tab-import-hardware', - views: { - 'tab-import-hardware': { - templateUrl: 'views/tab-import-hardware.html', - }, - } - }) /* *