Merge pull request #59 from JDonadio/fix/tabs-create

Fix/tabs create
This commit is contained in:
Gustavo Maximiliano Cortez 2016-09-06 10:14:51 -03:00 committed by GitHub
commit 2354a46bed
6 changed files with 247 additions and 367 deletions

View File

@ -10,7 +10,7 @@
<ion-content> <ion-content>
<ion-list> <ion-list>
<a class="item item-remove-animate item-icon-right" type="item-text-wrap" ui-sref="tabs.create.personal"> <a class="item item-remove-animate item-icon-right" type="item-text-wrap" ui-sref="tabs.create">
<h2 translate>Create new wallet</h2> <h2 translate>Create new wallet</h2>
<i class="icon ion-ios-arrow-right nav-item-arrow-right"></i> <i class="icon ion-ios-arrow-right nav-item-arrow-right"></i>
</a> </a>

View File

@ -1,13 +1,22 @@
<ion-view > <ion-view>
<ion-tabs class="tabs-striped tabs-color-positive tabs-color-active-positive tabs-top"> <ion-nav-bar class="bar-royal">
<ion-nav-title>{{'Create new wallet' | translate}}</ion-nav-title>
<ion-nav-back-button>
<i class="icon ion-ios-arrow-thin-left"></i>
</ion-nav-back-button>
</ion-nav-bar>
<ion-tab title="Personal Wallet" ui-sref="tabs.create.personal"> <ion-content ng-controller="createController" ng-init="personal = true; init()">
<ion-nav-view name="tab-create-personal"></ion-nav-view> <div class="row text-center">
</ion-tab> <div class="col" ng-click="personal = true; setTotalCopayers(1)" ng-style="personal && {'border-bottom': '2px solid'}">
<span class="" translate>Personal Wallet</span>
</div>
<div class="col" ng-click="personal = false; setTotalCopayers(3)" ng-style="!personal && {'border-bottom': '2px solid'}">
<span class="" translate>Shared Wallet</span>
</div>
</div>
<ion-tab title="Shared Wallet" ui-sref="tabs.create.shared"> <div ng-include="'views/tab-create-personal.html'" ng-if="personal"></div>
<ion-nav-view name="tab-create-shared"></ion-nav-view> <div ng-include="'views/tab-create-shared.html'" ng-if="!personal"></div>
</ion-tab> </ion-content>
</ion-tabs>
</ion-view> </ion-view>

View File

@ -1,125 +1,88 @@
<ion-view> <form name="setupForm" ng-submit="create(setupForm)" novalidate>
<ion-nav-bar class="bar-royal"> <div class="card list">
<ion-nav-buttons side="primary"> <label class="item item-input item-stacked-label">
<button class="button back-button" ui-sref="tabs.add"> <span class="input-label" translate>Wallet name</span>
<i class="icon ion-ios-arrow-thin-left"></i> <input type="text"
</button> placeholder="{{'Family vacation funds'|translate}}"
</ion-nav-buttons> ng-model="formData.walletName"
<ion-nav-title>{{'Create new wallet' | translate}}</ion-nav-title> ng-required="true"
</ion-nav-bar> ng-focus="formFocus('wallet-name')"
ng-blur="formFocus(false)">
</label>
<ion-content ng-controller="createController as create" ng-init="create.setTotalCopayers(1)"> <ion-toggle ng-model="showAdv" toggle-class="toggle-stable" ng-change="showAdvChange()">
<span translate ng-show="!showAdv">Show advanced options</span>
<span translate ng-show="showAdv">Hide advanced options</span>
</ion-toggle>
<form name="setupForm" ng-submit="create.create(setupForm)" novalidate> <div ng-show="showAdv">
<label class="item item-input item-stacked-label">
<span class="input-label">Wallet Service URL</span>
<input type="text" ng-model="formData.bwsurl" placeholder="https://bws.bitpay.com/bws/api">
</label>
<div class="card list"> <label class="item item-input item-select">
<label ng-hide="create.hideWalletName" class="item item-input item-stacked-label"> <div class="input-label" translate>
<span class="input-label" translate>Wallet name</span> Wallet Key
<input type="text" </div>
placeholder="{{'Family vacation funds'|translate}}" <select class="m10t" ng-model="seedSource" ng-options="seed as seed.label for seed in seedOptions"></select>
name="walletName" </label>
ng-model="walletName"
ng-required="true"
ng-focus="create.formFocus('wallet-name')"
ng-blur="create.formFocus(false)">
</label>
<ion-toggle ng-model="showAdv" toggle-class="toggle-stable" ng-change="showAdvChange()"> <label class="item item-input item-stacked-label" ng-show="seedSource.id == 'trezor' || seedSource.id == 'ledger'">
<span translate ng-show="!showAdv">Show advanced options</span> <span class="input-label" translate>Account Number</span>
<span translate ng-show="showAdv">Hide advanced options</span> <input type="number" ng-model="formData.account" ignore-mouse-wheel>
</ion-toggle> </label>
<div ng-show="showAdv"> <div class="card" ng-show="seedSource.id == 'new' && createPassphrase">
<div class="item item-text-wrap" translate>
WARNING: The password cannot be recovered. <b>Be sure to write it down</b>. The wallet can not be restored without the password.
</div>
</div>
<label class="item item-input item-stacked-label"> <label class="item item-input item-stacked-label" ng-show="seedSource.id == 'new'">
<span class="input-label">Wallet Service URL</span> <span class="input-label" translate>Add a Password</span>
<input type="text" id="bwsurl" name="bwsurl" ng-model="bwsurl"> <input type="text"
</label> placeholder="{{'Add an optional password to secure the recovery phrase'|translate}}"
autocapitalize="off"
ng-model="formData.createPassphrase">
</label>
<label class="item item-input item-select"> <label class="item item-input item-stacked-label" ng-show="seedSource.id == 'set'">
<div class="input-label" translate> <span class="input-label" translate>Wallet Recovery Phrase</span>
Wallet Key <input placeholder="{{'Enter the recovery phrase (BIP39)'|translate}}"
</div> autocapitalize="off"
<select class="m10t" type="text"
ng-model="seedSource" ng-model="formData.privateKey">
ng-options="seed as seed.label for seed in create.seedOptions" </label>
ng-change="create.setSeedSource()">
</select>
</label>
<label class="item item-input item-stacked-label" <label class="item item-input item-stacked-label" ng-show="seedSource.id == 'set'">
ng-show="create.seedSourceId == 'trezor' || create.seedSourceId == 'ledger'"> <span class="input-label" translate>Password</span>
<span class="input-label" translate>Account Number</span> <input type="text"
<input type="number" id="account" ng-model="account" ignore-mouse-wheel> placeholder="{{'The recovery phrase could require a password to be imported'|translate}}"
</label> autocapitalize="off"
ng-model="formData.passphrase">
</label>
<div class="card" ng-show="create.seedSourceId=='new' && createPassphrase"> <label class="item item-input item-stacked-label" ng-show="seedSource.id == 'set'">
<div class="item item-text-wrap" translate> <span class="input-label" translate>Derivation Path</span>
WARNING: The password cannot be recovered. <b>Be sure to write it down</b>. The wallet can not be restored without the password. <input type="text"
</div> placeholder="{{'BIP32 path for address derivation'|translate}}"
</div> ng-model="formData.derivationPath">
</label>
<label class="item item-input item-stacked-label" ng-show="create.seedSourceId=='new'"> <ion-toggle ng-show="seedSource.id == 'new'" ng-model="formData.testnetEnabled" toggle-class="toggle-positive">
<span class="input-label" translate>Add a Password</span> <span translate>Testnet</span>
<input type="text" </ion-toggle>
placeholder="{{'Add an optional password to secure the recovery phrase'|translate}}"
autocapitalize="off"
name="createPassphrase"
ng-model="createPassphrase">
</label>
<ion-toggle ng-model="formData.singleAddressEnabled" toggle-class="toggle-positive">
<span translate>Single Address Wallet</span>
<small translate>For audit purposes</small>
</ion-toggle>
<label class="item item-input item-stacked-label" ng-show="create.seedSourceId=='set'"> </div> <!-- advanced -->
<span class="input-label" translate>Wallet Recovery Phrase</span> </div> <!-- list -->
<input id="ext-master"
placeholder="{{'Enter the recovery phrase (BIP39)'|translate}}"
autocapitalize="off"
type="text"
name="privateKey"
ng-model="privateKey">
</label>
<label class="item item-input item-stacked-label" ng-show="create.seedSourceId=='set'"> <button type="submit" class="button button-block button-positive" ng-disabled="setupForm.$invalid">
<span class="input-label" translate>Password</span> <span translate>Create new wallet</span>
<input type="text" </button>
placeholder="{{'The recovery phrase could require a password to be imported'|translate}}" </form>
autocapitalize="off"
name="passphrase"
ng-model="passphrase">
</label>
<label class="item item-input item-stacked-label" ng-show="create.seedSourceId == 'set'">
<span class="input-label" translate>Derivation Path</span>
<input type="text"
placeholder="{{'BIP32 path for address derivation'|translate}}"
name="derivationPath"
ng-model="derivationPath">
</label>
<ion-toggle ng-show="create.seedSourceId == 'new'" ng-model="testnetEnabled" toggle-class="toggle-positive">
Testnet
</ion-toggle>
<ion-toggle ng-model="singleAddressEnabled" toggle-class="toggle-positive">
<span translate>Single Address Wallet</span>
<small translate>For audit purposes</small>
</ion-toggle>
</div> <!-- advanced -->
</div> <!-- list -->
<button type="submit"
class="button button-block button-positive"
ng-show="totalCopayers != 1" ng-disabled="setupForm.$invalid">
<span translate>Create {{requiredCopayers}}-of-{{totalCopayers}} wallet</span>
</button>
<button type="submit"
class="button button-block button-positive"
ng-show="totalCopayers == 1" ng-disabled="setupForm.$invalid">
<span translate>Create new wallet</span>
</button>
</form>
</ion-content>
</ion-view>

View File

@ -1,159 +1,119 @@
<ion-view> <form name="setupForm" ng-submit="create(setupForm)" novalidate>
<ion-nav-bar class="bar-royal"> <div class="card list">
<ion-nav-buttons side="primary"> <label class="item item-input item-stacked-label">
<button class="button back-button" ui-sref="tabs.add"> <span class="input-label" translate>Wallet name</span>
<i class="icon ion-ios-arrow-thin-left"></i> <input type="text"
</button> placeholder="{{'Family vacation funds'|translate}}"
</ion-nav-buttons> ng-model="formData.walletName"
<ion-nav-title>{{'Create new wallet' | translate}}</ion-nav-title> ng-required="true"
</ion-nav-bar> ng-focus="formFocus('wallet-name')"
ng-blur="formFocus(false)">
</label>
<ion-content ng-controller="createController as create" ng-init="create.setTotalCopayers(3)"> <label class="item item-input item-stacked-label">
<span class="input-label" translate>Your nickname</span>
<input type="text"
placeholder="{{'John'|translate}}"
ng-model="formData.myName"
ng-required="formData.totalCopayers != 1"
ng-disabled="formData.totalCopayers == 1"
ng-focus="formFocus('my-name')"
ng-blur="formFocus(false)">
</label>
<form name="setupForm" ng-submit="create.create(setupForm)" novalidate> <label class="item item-input item-select">
<div class="input-label" translate>
Total number of copayers
</div>
<select class="m10t" ng-model="formData.totalCopayers" ng-options="totalCopayers as totalCopayers for totalCopayers in TCValues"
ng-change="setTotalCopayers(formData.totalCopayers)">
</select>
</label>
<div class="card list"> <label class="item item-input item-select">
<label ng-hide="create.hideWalletName" class="item item-input item-stacked-label"> <div class="input-label" translate>
<span class="input-label" translate>Wallet name</span> Required number of signatures
<input type="text" </div>
placeholder="{{'Family vacation funds'|translate}}" <select class="m10t"
name="walletName" ng-model="formData.requiredCopayers" ng-options="requiredCopayers as requiredCopayers for requiredCopayers in RCValues"
ng-model="walletName" ng-disabled="formData.totalCopayers == 1">
ng-required="true" </select>
ng-focus="create.formFocus('wallet-name')" </label>
ng-blur="create.formFocus(false)">
</label>
<label ng-show="totalCopayers != 1" class="item item-input item-stacked-label"> <ion-toggle ng-model="showAdv" toggle-class="toggle-stable" ng-change="showAdvChange()">
<span class="input-label" translate>Your nickname</span> <span translate ng-show="!showAdv">Show advanced options</span>
<input type="text" <span translate ng-show="showAdv">Hide advanced options</span>
placeholder="{{'John'|translate}}" </ion-toggle>
name="myName"
ng-model="myName"
ng-required="totalCopayers != 1"
ng-disabled="totalCopayers == 1"
ng-focus="create.formFocus('my-name')"
ng-blur="create.formFocus(false)">
</label>
<label ng-show="totalCopayers != 1" class="item item-input item-select"> <div ng-show="showAdv">
<div class="input-label" translate> <label class="item item-input item-stacked-label">
Total number of copayers <span class="input-label">Wallet Service URL</span>
</div> <input type="text" ng-model="formData.bwsurl">
<select class="m10t" </label>
ng-model="totalCopayers"
ng-options="totalCopayers as totalCopayers for totalCopayers in create.TCValues"
ng-change="create.setTotalCopayers(totalCopayers)">
</select>
</label>
<label ng-show="totalCopayers != 1" class="item item-input item-select"> <label class="item item-input item-select">
<div class="input-label" translate> <div class="input-label" translate>
Required number of signatures Wallet Key
</div> </div>
<select class="m10t" <select class="m10t" ng-model="seedSource" ng-options="seed as seed.label for seed in seedOptions"></select>
ng-model="requiredCopayers" </label>
ng-options="requiredCopayers as requiredCopayers for requiredCopayers in create.RCValues"
ng-disabled="totalCopayers == 1">
</select>
</label>
<ion-toggle ng-model="showAdv" toggle-class="toggle-stable" ng-change="showAdvChange()"> <label class="item item-input item-stacked-label" ng-show="seedSource.id == 'trezor' || seedSource.id == 'ledger'">
<span translate ng-show="!showAdv">Show advanced options</span> <span class="input-label" translate>Account Number</span>
<span translate ng-show="showAdv">Hide advanced options</span> <input type="number" ng-model="formData.account" ignore-mouse-wheel>
</ion-toggle> </label>
<div ng-show="showAdv"> <div class="card" ng-show="seedSource.id =='new' && formData.createPassphrase">
<div class="item item-text-wrap" translate>
WARNING: The password cannot be recovered. <b>Be sure to write it down</b>. The wallet can not be restored without the password.
</div>
</div>
<label class="item item-input item-stacked-label"> <label class="item item-input item-stacked-label" ng-show="seedSource.id == 'new'">
<span class="input-label">Wallet Service URL</span> <span class="input-label" translate>Add a Password</span>
<input type="text" id="bwsurl" name="bwsurl" ng-model="bwsurl"> <input type="text"
</label> placeholder="{{'Add an optional password to secure the recovery phrase'|translate}}"
autocapitalize="off"
<label class="item item-input item-select"> ng-model="formData.createPassphrase">
<div class="input-label" translate> </label>
Wallet Key
</div>
<select class="m10t"
ng-model="seedSource"
ng-options="seed as seed.label for seed in create.seedOptions"
ng-change="create.setSeedSource()">
</select>
</label>
<label class="item item-input item-stacked-label"
ng-show="create.seedSourceId == 'trezor' || create.seedSourceId == 'ledger'">
<span class="input-label" translate>Account Number</span>
<input type="number" id="account" ng-model="account" ignore-mouse-wheel>
</label>
<div class="card" ng-show="create.seedSourceId=='new' && createPassphrase">
<div class="item item-text-wrap" translate>
WARNING: The password cannot be recovered. <b>Be sure to write it down</b>. The wallet can not be restored without the password.
</div>
</div>
<label class="item item-input item-stacked-label" ng-show="create.seedSourceId=='new'">
<span class="input-label" translate>Add a Password</span>
<input type="text"
placeholder="{{'Add an optional password to secure the recovery phrase'|translate}}"
autocapitalize="off"
name="createPassphrase"
ng-model="createPassphrase">
</label>
<label class="item item-input item-stacked-label" ng-show="create.seedSourceId=='set'"> <label class="item item-input item-stacked-label" ng-show="seedSource.id == 'set'">
<span class="input-label" translate>Wallet Recovery Phrase</span> <span class="input-label" translate>Wallet Recovery Phrase</span>
<input id="ext-master" <input placeholder="{{'Enter the recovery phrase (BIP39)'|translate}}"
placeholder="{{'Enter the recovery phrase (BIP39)'|translate}}" autocapitalize="off"
autocapitalize="off" type="text"
type="text" ng-model="formData.privateKey">
name="privateKey" </label>
ng-model="privateKey">
</label>
<label class="item item-input item-stacked-label" ng-show="create.seedSourceId=='set'"> <label class="item item-input item-stacked-label" ng-show="seedSource.id == 'set'">
<span class="input-label" translate>Password</span> <span class="input-label" translate>Password</span>
<input type="text" <input type="text"
placeholder="{{'The recovery phrase could require a password to be imported'|translate}}" placeholder="{{'The recovery phrase could require a password to be imported'|translate}}"
autocapitalize="off" autocapitalize="off"
name="passphrase" ng-model="formData.passphrase">
ng-model="passphrase"> </label>
</label>
<label class="item item-input item-stacked-label" ng-show="create.seedSourceId == 'set'"> <label class="item item-input item-stacked-label" ng-show="seedSource.id == 'set'">
<span class="input-label" translate>Derivation Path</span> <span class="input-label" translate>Derivation Path</span>
<input type="text" <input type="text"
placeholder="{{'BIP32 path for address derivation'|translate}}" placeholder="{{'BIP32 path for address derivation'|translate}}"
name="derivationPath" ng-model="formData.derivationPath">
ng-model="derivationPath"> </label>
</label>
<ion-toggle ng-show="create.seedSourceId == 'new'" ng-model="testnetEnabled" toggle-class="toggle-positive"> <ion-toggle ng-show="seedSource.id == 'new'" ng-model="formData.testnetEnabled" toggle-class="toggle-positive">
Testnet Testnet
</ion-toggle> </ion-toggle>
<ion-toggle ng-model="singleAddressEnabled" toggle-class="toggle-positive"> <ion-toggle ng-model="formData.singleAddressEnabled" toggle-class="toggle-positive">
<span translate>Single Address Wallet</span> <span translate>Single Address Wallet</span>
<small translate>For audit purposes</small> <small translate>For audit purposes</small>
</ion-toggle> </ion-toggle>
</div> <!-- advanced --> </div> <!-- advanced -->
</div> <!-- list --> </div> <!-- list -->
<button type="submit" <button type="submit" class="button button-block button-positive" ng-disabled="setupForm.$invalid">
class="button button-block button-positive" <span translate>Create {{formData.requiredCopayers}}-of-{{formData.totalCopayers}} wallet</span>
ng-show="totalCopayers != 1" ng-disabled="setupForm.$invalid"> </button>
<span translate>Create {{requiredCopayers}}-of-{{totalCopayers}} wallet</span> </form>
</button>
<button type="submit"
class="button button-block button-positive"
ng-show="totalCopayers == 1" ng-disabled="setupForm.$invalid">
<span translate>Create new wallet</span>
</button>
</form>
</ion-content>
</ion-view>

View File

@ -7,11 +7,6 @@ angular.module('copayApp.controllers').controller('createController',
var isCordova = platformInfo.isCordova; var isCordova = platformInfo.isCordova;
var isDevel = platformInfo.isDevel; 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 */ /* For compressed keys, m*73 + n*34 <= 496 */
var COPAYER_PAIR_LIMITS = { var COPAYER_PAIR_LIMITS = {
1: 1, 1: 1,
@ -28,96 +23,91 @@ angular.module('copayApp.controllers').controller('createController',
12: 1, 12: 1,
}; };
var defaults = configService.getDefaults(); $scope.init = function() {
$scope.bwsurl = defaults.bws.url; $scope.formData = {};
$scope.derivationPath = derivationPathHelper.default; var defaults = configService.getDefaults();
$scope.formData.account = 1;
// ng-repeat defined number of times instead of repeating over array? $scope.formData.bwsurl = defaults.bws.url;
this.getNumber = function(num) { $scope.TCValues = lodash.range(2, defaults.limits.totalCopayers + 1);
return new Array(num); $scope.formData.totalCopayers = defaults.wallet.totalCopayers;
} $scope.formData.derivationPath = derivationPathHelper.default;
$scope.setTotalCopayers(1);
updateRCSelect(1);
updateSeedSourceSelect(1);
};
$scope.showAdvChange = function() { $scope.showAdvChange = function() {
$ionicScrollDelegate.resize(); $ionicScrollDelegate.resize();
}; };
var updateRCSelect = function(n) { function updateRCSelect(n) {
$scope.totalCopayers = n; $scope.formData.totalCopayers = n;
var maxReq = COPAYER_PAIR_LIMITS[n]; var maxReq = COPAYER_PAIR_LIMITS[n];
self.RCValues = lodash.range(1, maxReq + 1); $scope.RCValues = lodash.range(1, maxReq + 1);
$scope.requiredCopayers = Math.min(parseInt(n / 2 + 1), maxReq); $scope.formData.requiredCopayers = Math.min(parseInt(n / 2 + 1), maxReq);
}; };
var updateSeedSourceSelect = function(n) { function updateSeedSourceSelect(n) {
var seedOptions = [{
self.seedOptions = [{
id: 'new', id: 'new',
label: gettext('Random'), label: gettext('Random'),
}, { }, {
id: 'set', id: 'set',
label: gettext('Specify Recovery Phrase...'), label: gettext('Specify Recovery Phrase...'),
}]; }];
$scope.seedSource = self.seedOptions[0];
$scope.seedSource = seedOptions[0];
if (n > 1 && isChromeApp) if (n > 1 && isChromeApp)
self.seedOptions.push({ seedOptions.push({
id: 'ledger', id: 'ledger',
label: 'Ledger Hardware Wallet', label: 'Ledger Hardware Wallet',
}); });
if (isChromeApp || isDevel) { if (isChromeApp || isDevel) {
self.seedOptions.push({ seedOptions.push({
id: 'trezor', id: 'trezor',
label: 'Trezor Hardware Wallet', label: 'Trezor Hardware Wallet',
}); });
} }
$scope.seedOptions = seedOptions;
}; };
this.TCValues = lodash.range(2, defaults.limits.totalCopayers + 1); $scope.setTotalCopayers = function(tc) {
$scope.totalCopayers = defaults.wallet.totalCopayers; $scope.formData.totalCopayers = tc;
this.setTotalCopayers = function(tc) {
updateRCSelect(tc); updateRCSelect(tc);
updateSeedSourceSelect(tc); updateSeedSourceSelect(tc);
self.seedSourceId = $scope.seedSource.id;
}; };
this.setSeedSource = function(src) { $scope.create = function(form) {
self.seedSourceId = $scope.seedSource.id;
$timeout(function() {
$rootScope.$apply();
});
};
this.create = function(form) {
if (form && form.$invalid) { if (form && form.$invalid) {
popupService.showAlert(gettextCatalog.getString('Error'), gettextCatalog.getString('Please enter the required fields')); popupService.showAlert(gettextCatalog.getString('Error'), gettextCatalog.getString('Please enter the required fields'));
return; return;
} }
var opts = { var opts = {
m: $scope.requiredCopayers, name: $scope.formData.walletName,
n: $scope.totalCopayers, m: $scope.formData.requiredCopayers,
name: $scope.walletName, n: $scope.formData.totalCopayers,
myName: $scope.totalCopayers > 1 ? $scope.myName : null, myName: $scope.formData.totalCopayers > 1 ? $scope.formData.myName : null,
networkName: $scope.testnetEnabled ? 'testnet' : 'livenet', networkName: $scope.formData.testnetEnabled ? 'testnet' : 'livenet',
bwsurl: $scope.bwsurl, bwsurl: $scope.formData.bwsurl,
singleAddress: $scope.singleAddressEnabled, singleAddress: $scope.formData.singleAddressEnabled,
walletPrivKey: $scope._walletPrivKey, // Only for testing walletPrivKey: $scope.formData._walletPrivKey, // Only for testing
}; };
var setSeed = self.seedSourceId == 'set';
var setSeed = $scope.seedSource.id == 'set';
if (setSeed) { if (setSeed) {
var words = $scope.privateKey || ''; var words = $scope.formData.privateKey || '';
if (words.indexOf(' ') == -1 && words.indexOf('prv') == 1 && words.length > 108) { if (words.indexOf(' ') == -1 && words.indexOf('prv') == 1 && words.length > 108) {
opts.extendedPrivateKey = words; opts.extendedPrivateKey = words;
} else { } else {
opts.mnemonic = words; 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) { if (!pathData) {
popupService.showAlert(gettextCatalog.getString('Error'), gettextCatalog.getString('Invalid derivation path')); popupService.showAlert(gettextCatalog.getString('Error'), gettextCatalog.getString('Invalid derivation path'));
return; return;
@ -128,7 +118,7 @@ angular.module('copayApp.controllers').controller('createController',
opts.derivationStrategy = pathData.derivationStrategy; opts.derivationStrategy = pathData.derivationStrategy;
} else { } else {
opts.passphrase = $scope.createPassphrase; opts.passphrase = $scope.formData.createPassphrase;
} }
if (setSeed && !opts.mnemonic && !opts.extendedPrivateKey) { if (setSeed && !opts.mnemonic && !opts.extendedPrivateKey) {
@ -136,36 +126,36 @@ angular.module('copayApp.controllers').controller('createController',
return; return;
} }
if (self.seedSourceId == 'ledger' || self.seedSourceId == 'trezor') { if ($scope.seedSource.id == 'ledger' || $scope.seedSource.id == 'trezor') {
var account = $scope.account; var account = $scope.formData.account;
if (!account || account < 1) { if (!account || account < 1) {
popupService.showAlert(gettextCatalog.getString('Error'), gettextCatalog.getString('Invalid account number')); popupService.showAlert(gettextCatalog.getString('Error'), gettextCatalog.getString('Invalid account number'));
return; return;
} }
if (self.seedSourceId == 'trezor') if ($scope.seedSource.id == 'trezor')
account = account - 1; account = account - 1;
opts.account = account; 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) { src.getInfoForNewWallet(opts.n > 1, account, function(err, lopts) {
ongoingProcess.set('connecting' + self.seedSourceId, false); ongoingProcess.set('connecting' + $scope.seedSource.id, false);
if (err) { if (err) {
popupService.showAlert(gettextCatalog.getString('Error'), err); popupService.showAlert(gettextCatalog.getString('Error'), err);
return; return;
} }
opts = lodash.assign(lopts, opts); opts = lodash.assign(lopts, opts);
self._create(opts); _create(opts);
}); });
} else { } else {
self._create(opts); _create(opts);
} }
}; };
this._create = function(opts) { function _create(opts) {
ongoingProcess.set('creatingWallet', true); ongoingProcess.set('creatingWallet', true);
$timeout(function() { $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); profileService.setBackupFlag(client.credentials.walletId);
} }
$state.go('tabs.home') $state.go('tabs.home')
}); });
}, 100); }, 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();
}); });

View File

@ -309,30 +309,12 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr
}) })
.state('tabs.create', { .state('tabs.create', {
url: '/create', url: '/create',
abstract: true,
templateUrl: 'views/create.html',
views: { views: {
'tab-home': { 'tab-home': {
templateUrl: 'views/create.html' 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',
},
}
})
/* /*
* *