diff --git a/public/views/add.html b/public/views/add.html index b41d8bd08..4b24c8da7 100644 --- a/public/views/add.html +++ b/public/views/add.html @@ -10,7 +10,7 @@ - +

Create new wallet

diff --git a/public/views/create.html b/public/views/create.html index c379f7d72..49a483906 100644 --- a/public/views/create.html +++ b/public/views/create.html @@ -1,13 +1,22 @@ - - + + + {{'Create new wallet' | translate}} + + + + - - - + +
+
+ Personal Wallet +
+
+ Shared Wallet +
+
- - - - -
+
+
+
diff --git a/public/views/tab-create-personal.html b/public/views/tab-create-personal.html index be899d465..94887a3ba 100644 --- a/public/views/tab-create-personal.html +++ b/public/views/tab-create-personal.html @@ -1,125 +1,88 @@ - - - - - - {{'Create new wallet' | translate}} - +
+
+ - + + Show advanced options + Hide advanced options + - +
+ -
- + - - Show advanced options - Hide advanced options - + -
+
+
+ WARNING: The password cannot be recovered. Be sure to write it down. The wallet can not be restored without the password. +
+
- + - + - + -
-
- WARNING: The password cannot be recovered. Be sure to write it down. The wallet can not be restored without the password. -
-
+ - + + Testnet + + + Single Address Wallet + For audit purposes + - +
+
- - - - - - Testnet - - - - Single Address Wallet - For audit purposes - - -
-
- - - - - -
- -
+ + diff --git a/public/views/tab-create-shared.html b/public/views/tab-create-shared.html index 2d5dc1ccf..a40c1df8b 100644 --- a/public/views/tab-create-shared.html +++ b/public/views/tab-create-shared.html @@ -1,159 +1,119 @@ - - - - - - {{'Create new wallet' | translate}} - +
+
+ - + - + -
- + - + + Show advanced options + Hide advanced options + - +
+ - + - - Show advanced options - Hide advanced options - + -
+
+
+ WARNING: The password cannot be recovered. Be sure to write it down. The wallet can not be restored without the password. +
+
- - - - - - -
-
- WARNING: The password cannot be recovered. Be sure to write it down. The wallet can not be restored without the password. -
-
- - + - + - + - + - - Testnet - + + Testnet + - - Single Address Wallet - For audit purposes - + + Single Address Wallet + For audit purposes + -
-
+
+
- - - - -
- -
+ + diff --git a/src/js/controllers/create.js b/src/js/controllers/create.js index 1faf089f7..f2b49c79e 100644 --- a/src/js/controllers/create.js +++ b/src/js/controllers/create.js @@ -7,11 +7,6 @@ angular.module('copayApp.controllers').controller('createController', var isCordova = platformInfo.isCordova; var isDevel = platformInfo.isDevel; - var self = this; - var defaults = configService.getDefaults(); - this.isWindowsPhoneApp = platformInfo.isWP && isCordova; - $scope.account = 1; - /* For compressed keys, m*73 + n*34 <= 496 */ var COPAYER_PAIR_LIMITS = { 1: 1, @@ -28,96 +23,91 @@ angular.module('copayApp.controllers').controller('createController', 12: 1, }; - var defaults = configService.getDefaults(); - $scope.bwsurl = defaults.bws.url; - $scope.derivationPath = derivationPathHelper.default; - - // ng-repeat defined number of times instead of repeating over array? - this.getNumber = function(num) { - return new Array(num); - } + $scope.init = function() { + $scope.formData = {}; + var defaults = configService.getDefaults(); + $scope.formData.account = 1; + $scope.formData.bwsurl = defaults.bws.url; + $scope.TCValues = lodash.range(2, defaults.limits.totalCopayers + 1); + $scope.formData.totalCopayers = defaults.wallet.totalCopayers; + $scope.formData.derivationPath = derivationPathHelper.default; + $scope.setTotalCopayers(1); + updateRCSelect(1); + updateSeedSourceSelect(1); + }; $scope.showAdvChange = function() { $ionicScrollDelegate.resize(); }; - var updateRCSelect = function(n) { - $scope.totalCopayers = n; + function updateRCSelect(n) { + $scope.formData.totalCopayers = n; var maxReq = COPAYER_PAIR_LIMITS[n]; - self.RCValues = lodash.range(1, maxReq + 1); - $scope.requiredCopayers = Math.min(parseInt(n / 2 + 1), maxReq); + $scope.RCValues = lodash.range(1, maxReq + 1); + $scope.formData.requiredCopayers = Math.min(parseInt(n / 2 + 1), maxReq); }; - var updateSeedSourceSelect = function(n) { - - self.seedOptions = [{ + function updateSeedSourceSelect(n) { + var seedOptions = [{ id: 'new', label: gettext('Random'), }, { id: 'set', label: gettext('Specify Recovery Phrase...'), }]; - $scope.seedSource = self.seedOptions[0]; + + $scope.seedSource = seedOptions[0]; if (n > 1 && isChromeApp) - self.seedOptions.push({ + seedOptions.push({ id: 'ledger', label: 'Ledger Hardware Wallet', }); if (isChromeApp || isDevel) { - self.seedOptions.push({ + seedOptions.push({ id: 'trezor', label: 'Trezor Hardware Wallet', }); } + $scope.seedOptions = seedOptions; }; - this.TCValues = lodash.range(2, defaults.limits.totalCopayers + 1); - $scope.totalCopayers = defaults.wallet.totalCopayers; - - this.setTotalCopayers = function(tc) { + $scope.setTotalCopayers = function(tc) { + $scope.formData.totalCopayers = tc; updateRCSelect(tc); updateSeedSourceSelect(tc); - self.seedSourceId = $scope.seedSource.id; }; - this.setSeedSource = function(src) { - self.seedSourceId = $scope.seedSource.id; - - $timeout(function() { - $rootScope.$apply(); - }); - }; - - this.create = function(form) { + $scope.create = function(form) { if (form && form.$invalid) { popupService.showAlert(gettextCatalog.getString('Error'), gettextCatalog.getString('Please enter the required fields')); return; } var opts = { - m: $scope.requiredCopayers, - n: $scope.totalCopayers, - name: $scope.walletName, - myName: $scope.totalCopayers > 1 ? $scope.myName : null, - networkName: $scope.testnetEnabled ? 'testnet' : 'livenet', - bwsurl: $scope.bwsurl, - singleAddress: $scope.singleAddressEnabled, - walletPrivKey: $scope._walletPrivKey, // Only for testing + name: $scope.formData.walletName, + m: $scope.formData.requiredCopayers, + n: $scope.formData.totalCopayers, + myName: $scope.formData.totalCopayers > 1 ? $scope.formData.myName : null, + networkName: $scope.formData.testnetEnabled ? 'testnet' : 'livenet', + bwsurl: $scope.formData.bwsurl, + singleAddress: $scope.formData.singleAddressEnabled, + walletPrivKey: $scope.formData._walletPrivKey, // Only for testing }; - var setSeed = self.seedSourceId == 'set'; + + var setSeed = $scope.seedSource.id == 'set'; if (setSeed) { - var words = $scope.privateKey || ''; + var words = $scope.formData.privateKey || ''; if (words.indexOf(' ') == -1 && words.indexOf('prv') == 1 && words.length > 108) { opts.extendedPrivateKey = words; } else { opts.mnemonic = words; } - opts.passphrase = $scope.passphrase; + opts.passphrase = $scope.formData.passphrase; - var pathData = derivationPathHelper.parse($scope.derivationPath); + var pathData = derivationPathHelper.parse($scope.formData.derivationPath); if (!pathData) { popupService.showAlert(gettextCatalog.getString('Error'), gettextCatalog.getString('Invalid derivation path')); return; @@ -128,7 +118,7 @@ angular.module('copayApp.controllers').controller('createController', opts.derivationStrategy = pathData.derivationStrategy; } else { - opts.passphrase = $scope.createPassphrase; + opts.passphrase = $scope.formData.createPassphrase; } if (setSeed && !opts.mnemonic && !opts.extendedPrivateKey) { @@ -136,36 +126,36 @@ angular.module('copayApp.controllers').controller('createController', return; } - if (self.seedSourceId == 'ledger' || self.seedSourceId == 'trezor') { - var account = $scope.account; + if ($scope.seedSource.id == 'ledger' || $scope.seedSource.id == 'trezor') { + var account = $scope.formData.account; if (!account || account < 1) { popupService.showAlert(gettextCatalog.getString('Error'), gettextCatalog.getString('Invalid account number')); return; } - if (self.seedSourceId == 'trezor') + if ($scope.seedSource.id == 'trezor') account = account - 1; opts.account = account; - ongoingProcess.set('connecting' + self.seedSourceId, true); + ongoingProcess.set('connecting' + $scope.seedSource.id, true); - var src = self.seedSourceId == 'ledger' ? ledger : trezor; + var src = $scope.seedSource.id == 'ledger' ? ledger : trezor; src.getInfoForNewWallet(opts.n > 1, account, function(err, lopts) { - ongoingProcess.set('connecting' + self.seedSourceId, false); + ongoingProcess.set('connecting' + $scope.seedSource.id, false); if (err) { popupService.showAlert(gettextCatalog.getString('Error'), err); return; } opts = lodash.assign(lopts, opts); - self._create(opts); + _create(opts); }); } else { - self._create(opts); + _create(opts); } }; - this._create = function(opts) { + function _create(opts) { ongoingProcess.set('creatingWallet', true); $timeout(function() { @@ -182,35 +172,11 @@ angular.module('copayApp.controllers').controller('createController', }); - if (self.seedSourceId == 'set') { + if ($scope.seedSource.id == 'set') { profileService.setBackupFlag(client.credentials.walletId); } $state.go('tabs.home') }); }, 100); } - - this.formFocus = function(what) { - if (!this.isWindowsPhoneApp) return - - if (what && what == 'my-name') { - this.hideWalletName = true; - this.hideTabs = true; - } else if (what && what == 'wallet-name') { - this.hideTabs = true; - } else { - this.hideWalletName = false; - this.hideTabs = false; - } - $timeout(function() { - $rootScope.$digest(); - }, 1); - }; - - $scope.$on("$destroy", function() { - $rootScope.hideWalletNavigation = false; - }); - - updateSeedSourceSelect(1); - self.setSeedSource(); }); diff --git a/src/js/routes.js b/src/js/routes.js index 6ae72be6f..bde25a606 100644 --- a/src/js/routes.js +++ b/src/js/routes.js @@ -309,30 +309,12 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr }) .state('tabs.create', { url: '/create', - abstract: true, - templateUrl: 'views/create.html', views: { 'tab-home': { templateUrl: 'views/create.html' }, } }) - .state('tabs.create.personal', { - url: '/tab-create-personal', - views: { - 'tab-create-personal': { - templateUrl: 'views/tab-create-personal.html', - }, - } - }) - .state('tabs.create.shared', { - url: '/tab-create-shared', - views: { - 'tab-create-shared': { - templateUrl: 'views/tab-create-shared.html', - }, - } - }) /* *