From a742e538141f909cfeead672f31d00979868457e Mon Sep 17 00:00:00 2001 From: Andy Phillipson Date: Mon, 17 Apr 2017 10:55:16 -0400 Subject: [PATCH] Review and test fixes. --- src/js/controllers/import.js | 10 +++--- src/js/controllers/join.js | 37 ++++++++++++++++++----- src/js/controllers/preferencesExternal.js | 1 - www/views/import.html | 2 +- www/views/preferences.html | 2 +- www/views/preferencesInformation.html | 8 ++++- 6 files changed, 43 insertions(+), 17 deletions(-) diff --git a/src/js/controllers/import.js b/src/js/controllers/import.js index 3776671ee..c5657d5cf 100644 --- a/src/js/controllers/import.js +++ b/src/js/controllers/import.js @@ -3,15 +3,13 @@ angular.module('copayApp.controllers').controller('importController', function($scope, $timeout, $log, $state, $stateParams, $ionicHistory, $ionicScrollDelegate, profileService, configService, sjcl, ledger, trezor, derivationPathHelper, platformInfo, bwcService, ongoingProcess, walletService, popupService, gettextCatalog, appConfigService) { - var isChromeApp = platformInfo.isChromeApp; - var isDevel = platformInfo.isDevel; var reader = new FileReader(); var defaults = configService.getDefaults(); var errors = bwcService.getErrors(); $scope.init = function() { - $scope.isDevel = platformInfo.isDevel; - $scope.isChromeApp = platformInfo.isChromeApp; + $scope.supportsLedger = platformInfo.supportsLedger; + $scope.supportsTrezor = platformInfo.supportsTrezor; $scope.isCordova = platformInfo.isCordova; $scope.formData = {}; $scope.formData.bwsurl = defaults.bws.url; @@ -25,14 +23,14 @@ angular.module('copayApp.controllers').controller('importController', $scope.seedOptions = []; - if ($scope.isChromeApp) { + if ($scope.supportsLedger) { $scope.seedOptions.push({ id: walletService.externalSource.ledger.id, label: walletService.externalSource.ledger.longName, }); } - if ($scope.isChromeApp || $scope.isDevel) { + if ($scope.supportsTrezor) { $scope.seedOptions.push({ id: walletService.externalSource.trezor.id, label: walletService.externalSource.trezor.longName, diff --git a/src/js/controllers/join.js b/src/js/controllers/join.js index b2e858969..0f416f0ea 100644 --- a/src/js/controllers/join.js +++ b/src/js/controllers/join.js @@ -1,7 +1,7 @@ 'use strict'; angular.module('copayApp.controllers').controller('joinController', - function($scope, $rootScope, $timeout, $state, $ionicHistory, $ionicScrollDelegate, profileService, configService, storageService, applicationService, gettextCatalog, lodash, ledger, trezor, derivationPathHelper, ongoingProcess, walletService, $log, $stateParams, popupService, appConfigService) { + function($scope, $rootScope, $timeout, $state, $ionicHistory, $ionicScrollDelegate, profileService, configService, storageService, applicationService, gettextCatalog, lodash, ledger, trezor, intelTEE, derivationPathHelper, ongoingProcess, walletService, $log, $stateParams, popupService, appConfigService) { var self = this; var defaults = configService.getDefaults(); @@ -64,14 +64,21 @@ angular.module('copayApp.controllers').controller('joinController', if (walletService.externalSource.ledger.supported) { self.seedOptions.push({ id: walletService.externalSource.ledger.id, - label: walletService.externalSource.ledger.longName, + label: walletService.externalSource.ledger.longName }); } if (walletService.externalSource.trezor.supported) { self.seedOptions.push({ id: walletService.externalSource.trezor.id, - label: walletService.externalSource.trezor.longName, + label: walletService.externalSource.trezor.longName + }); + } + + if (walletService.externalSource.intelTEE.supported) { + seedOptions.push({ + id: walletService.externalSource.intelTEE.id, + label: walletService.externalSource.intelTEE.longName }); } } @@ -94,7 +101,7 @@ angular.module('copayApp.controllers').controller('joinController', var opts = { secret: form.secret.$modelValue, myName: form.myName.$modelValue, - bwsurl: $scope.bwsurl, + bwsurl: $scope.bwsurl } var setSeed = self.seedSourceId == 'set'; @@ -127,21 +134,37 @@ angular.module('copayApp.controllers').controller('joinController', return; } - if (self.seedSourceId == walletService.externalSource.ledger.id || self.seedSourceId == walletService.externalSource.trezor.id) { + if (self.seedSourceId == walletService.externalSource.ledger.id || self.seedSourceId == walletService.externalSource.trezor.id || self.seedSourceId == walletService.externalSource.intelTEE.id) { var account = $scope.account; if (!account || account < 1) { popupService.showAlert(gettextCatalog.getString('Error'), gettextCatalog.getString('Invalid account number')); return; } - if (self.seedSourceId == walletService.externalSource.trezor.id) + if (self.seedSourceId == walletService.externalSource.trezor.id || self.seedSourceId == walletService.externalSource.intelTEE.id) account = account - 1; opts.account = account; opts.isMultisig = true; ongoingProcess.set('connecting' + self.seedSourceId, true); - var src = self.seedSourceId == walletService.externalSource.ledger.id ? ledger : trezor; + var src; + switch (self.seedSourceId) { + case walletService.externalSource.ledger.id: + src = ledger; + break; + case walletService.externalSource.trezor.id: + src = trezor; + break; + case walletService.externalSource.intelTEE.id: + src = intelTEE; + break; + default: + this.error = gettextCatalog.getString('Invalid seed source id: ' + self.seedSourceId); + return; + } + + // TODO: cannot currently join an intelTEE testnet wallet (need to detect from the secret) src.getInfoForNewWallet(true, account, 'livenet', function(err, lopts) { ongoingProcess.set('connecting' + self.seedSourceId, false); if (err) { diff --git a/src/js/controllers/preferencesExternal.js b/src/js/controllers/preferencesExternal.js index 3f7366f1f..916dc0e60 100644 --- a/src/js/controllers/preferencesExternal.js +++ b/src/js/controllers/preferencesExternal.js @@ -2,7 +2,6 @@ angular.module('copayApp.controllers').controller('preferencesExternalController', function($scope, $stateParams, lodash, gettextCatalog, popupService, profileService, walletService) { var wallet = profileService.getWallet($stateParams.walletId); - $scope.wallet = wallet; $scope.externalSource = lodash.find(walletService.externalSource, function(source) { return source.id == wallet.getPrivKeyExternalSourceName(); diff --git a/www/views/import.html b/www/views/import.html index 6baf86f06..973bd6ebb 100644 --- a/www/views/import.html +++ b/www/views/import.html @@ -16,7 +16,7 @@ File/Text
+ {'border-bottom-style': 'solid'}" ng-show="isCopay && (supportsLedger || supportsTrezor)"> Hardware wallet
diff --git a/www/views/preferences.html b/www/views/preferences.html index fda6f20d7..5c8d6f7aa 100644 --- a/www/views/preferences.html +++ b/www/views/preferences.html @@ -32,7 +32,7 @@ Hide Balance -
+
Security
diff --git a/www/views/preferencesInformation.html b/www/views/preferencesInformation.html index 3e1bcd4ff..927aa4d38 100644 --- a/www/views/preferencesInformation.html +++ b/www/views/preferencesInformation.html @@ -43,7 +43,13 @@ {{derivationStrategy}}
- +
+ Hardware Wallet + + {{externalSource}} + +
+
Hardware Wallet {{externalSource}}