complete import process
This commit is contained in:
parent
f2257f2519
commit
9632fe8b64
5 changed files with 41 additions and 80 deletions
|
|
@ -1,4 +1,4 @@
|
|||
<ion-view>
|
||||
<ion-view ng-controller="tabsController" ng-init="importInit()">
|
||||
<ion-nav-bar class="bar-royal">
|
||||
<ion-nav-title>{{'Import Wallet' | translate}}</ion-nav-title>
|
||||
<ion-nav-back-button>
|
||||
|
|
@ -6,7 +6,7 @@
|
|||
</ion-nav-back-button>
|
||||
</ion-nav-bar>
|
||||
|
||||
<ion-content ng-controller="importController" ng-init="phrase = true; importInit()">
|
||||
<ion-content ng-controller="importController" ng-init="phrase = true; init()">
|
||||
<div class="row text-center">
|
||||
<div class="col" ng-click="phrase = true; file = hardware = false" ng-style="phrase && {'border-bottom': '2px solid'}">
|
||||
<span translate>Recovery phrase</span>
|
||||
|
|
@ -24,18 +24,3 @@
|
|||
<div ng-include="'views/tab-import-hardware.html'" ng-if="hardware"></div>
|
||||
</ion-content>
|
||||
</ion-view>
|
||||
|
||||
|
||||
<!-- <ion-view ng-controller="tabsController" ng-init="importInit()">
|
||||
<ion-tabs class="tabs-striped tabs-color-positive tabs-color-active-positive tabs-top">
|
||||
|
||||
<div ng-if="!fromOnboarding">
|
||||
<div ng-include="'views/tab-import'"></div>
|
||||
</div>
|
||||
|
||||
<div ng-if="fromOnboarding">
|
||||
<div ng-include="'views/tab-import'"></div>
|
||||
</div>
|
||||
|
||||
</ion-tabs>
|
||||
</ion-view> -->
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@
|
|||
<button class="button button-block get-started col col-75" href ui-sref="onboarding.tour" translate>Get started</button>
|
||||
</div>
|
||||
<div class="row">
|
||||
<button class="button button-block restore col col-75" translate href ui-sref="onboarding.import.phrase({'fromOnboarding':true})">Restore</button>
|
||||
<button class="button button-block restore col col-75" translate href ui-sref="onboarding.import({'fromOnboarding':true})">Restore</button>
|
||||
</div>
|
||||
</ion-content>
|
||||
</ion-view>
|
||||
|
|
|
|||
|
|
@ -11,21 +11,16 @@
|
|||
<div class="input-label" translate>
|
||||
Wallet Type
|
||||
</div>
|
||||
<select ng-model="seedSource"
|
||||
ng-options="seed as seed.label for seed in seedOptions"
|
||||
ng-change="setSeedSource()">
|
||||
</select>
|
||||
|
||||
<select ng-model="seedSource" ng-options="seed as seed.label for seed in seedOptions"></select>
|
||||
</label>
|
||||
|
||||
<label class="item item-input item-stacked-label"
|
||||
ng-show="seedSourceId == 'trezor' || seedSourceId == 'ledger'">
|
||||
<label class="item item-input item-stacked-label" ng-show="seedSource.id == 'trezor' || seedSource.id == 'ledger'">
|
||||
<span class="input-label" translate>Account Number</span>
|
||||
<input type="number" id="account" ng-model="account" ignore-mouse-wheel>
|
||||
<input type="number" ng-model="formData.account" ignore-mouse-wheel>
|
||||
</label>
|
||||
|
||||
<ion-toggle ng-show="seedSourceId == 'trezor'"
|
||||
ng-model="isMultisig"
|
||||
toggle-class="toggle-positive">
|
||||
<ion-toggle ng-show="seedSource.id == 'trezor'" ng-model="formData.isMultisig" toggle-class="toggle-positive">
|
||||
<span translate>Shared Wallet</span>
|
||||
</ion-toggle>
|
||||
|
||||
|
|
@ -37,9 +32,8 @@
|
|||
<div ng-show="showAdv">
|
||||
<label class="item item-input item-stacked-label">
|
||||
<span class="input-label">Wallet Service URL</span>
|
||||
<input type="text" id="bwsurl" name="bwsurl" ng-model="bwsurl">
|
||||
<input type="text" ng-model="formData.bwsurl">
|
||||
</label>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
|
|
|||
|
|
@ -1,23 +1,26 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copayApp.controllers').controller('importController',
|
||||
function($scope, $rootScope, $timeout, $log, $state, $stateParams, $ionicHistory, profileService, configService, sjcl, gettext, ledger, trezor, derivationPathHelper, platformInfo, bwcService, ongoingProcess, walletService, popupService, gettextCatalog) {
|
||||
function($scope, $timeout, $log, $state, $stateParams, profileService, configService, sjcl, ledger, trezor, derivationPathHelper, platformInfo, bwcService, ongoingProcess, walletService, popupService, gettextCatalog) {
|
||||
|
||||
var isChromeApp = platformInfo.isChromeApp;
|
||||
var isDevel = platformInfo.isDevel;
|
||||
var reader = new FileReader();
|
||||
var defaults = configService.getDefaults();
|
||||
var errors = bwcService.getErrors();
|
||||
var derivationPath = 'livenet';
|
||||
$scope.isSafari = platformInfo.isSafari;
|
||||
$scope.isCordova = platformInfo.isCordova;
|
||||
$scope.formData = {};
|
||||
$scope.formData.bwsurl = defaults.bws.url;
|
||||
$scope.formData.derivationPath = derivationPathHelper.default;
|
||||
$scope.formData.account = 1;
|
||||
$scope.importErr = false;
|
||||
|
||||
var updateSeedSourceSelect = function() {
|
||||
$scope.init = function() {
|
||||
$scope.isSafari = platformInfo.isSafari;
|
||||
$scope.isCordova = platformInfo.isCordova;
|
||||
$scope.formData = {};
|
||||
$scope.formData.bwsurl = defaults.bws.url;
|
||||
$scope.formData.derivationPath = derivationPathHelper.default;
|
||||
$scope.formData.account = 1;
|
||||
$scope.importErr = false;
|
||||
|
||||
if ($stateParams.code)
|
||||
$scope.processWalletInfo($stateParams.code);
|
||||
|
||||
$scope.seedOptions = [];
|
||||
|
||||
if (isChromeApp) {
|
||||
|
|
@ -38,6 +41,7 @@ angular.module('copayApp.controllers').controller('importController',
|
|||
|
||||
$scope.processWalletInfo = function(code) {
|
||||
if (!code) return;
|
||||
|
||||
$scope.importErr = false;
|
||||
var parsedCode = code.split('|');
|
||||
|
||||
|
|
@ -58,19 +62,12 @@ angular.module('copayApp.controllers').controller('importController',
|
|||
if (info.type == 1 && info.hasPassphrase)
|
||||
popupService.showAlert(gettextCatalog.getString('Password required. Make sure to enter your password in advanced options'));
|
||||
|
||||
$scope.derivationPath = info.derivationPath;
|
||||
$scope.testnetEnabled = info.network == 'testnet' ? true : false;
|
||||
$scope.formData.derivationPath = info.derivationPath;
|
||||
$scope.formData.testnetEnabled = info.network == 'testnet' ? true : false;
|
||||
|
||||
$timeout(function() {
|
||||
$scope.words = info.data;
|
||||
$rootScope.$apply();
|
||||
}, 1);
|
||||
};
|
||||
|
||||
$scope.setType = function(type) {
|
||||
$scope.type = type;
|
||||
$timeout(function() {
|
||||
$rootScope.$apply();
|
||||
$scope.formData.words = info.data;
|
||||
$scope.$apply();
|
||||
}, 1);
|
||||
};
|
||||
|
||||
|
|
@ -85,9 +82,6 @@ angular.module('copayApp.controllers').controller('importController',
|
|||
|
||||
if (err) {
|
||||
popupService.showAlert(gettextCatalog.getString('Error'), err);
|
||||
$timeout(function() {
|
||||
$rootScope.$apply();
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -179,7 +173,7 @@ angular.module('copayApp.controllers').controller('importController',
|
|||
};
|
||||
|
||||
$scope.setDerivationPath = function() {
|
||||
derivationPath = $scope.formData.testnetEnabled ? derivationPathHelper.defaultTestnet : derivationPathHelper.default;
|
||||
$scope.formData.derivationPath = $scope.formData.testnetEnabled ? derivationPathHelper.defaultTestnet : derivationPathHelper.default;
|
||||
};
|
||||
|
||||
$scope.getFile = function() {
|
||||
|
|
@ -228,7 +222,8 @@ angular.module('copayApp.controllers').controller('importController',
|
|||
if ($scope.formData.bwsurl)
|
||||
opts.bwsurl = $scope.formData.bwsurl;
|
||||
|
||||
var pathData = derivationPathHelper.parse(derivationPath);
|
||||
var pathData = derivationPathHelper.parse($scope.formData.derivationPath);
|
||||
|
||||
if (!pathData) {
|
||||
popupService.showAlert(gettextCatalog.getString('Error'), gettextCatalog.getString('Invalid derivation path'));
|
||||
return;
|
||||
|
|
@ -268,7 +263,7 @@ angular.module('copayApp.controllers').controller('importController',
|
|||
}
|
||||
|
||||
lopts.externalSource = 'trezor';
|
||||
lopts.bwsurl = $scope.bwsurl;
|
||||
lopts.bwsurl = $scope.formData.bwsurl;
|
||||
ongoingProcess.set('importingWallet', true);
|
||||
$log.debug('Import opts', lopts);
|
||||
|
||||
|
|
@ -284,45 +279,37 @@ angular.module('copayApp.controllers').controller('importController',
|
|||
};
|
||||
|
||||
$scope.importHW = function(form) {
|
||||
if (form.$invalid || $scope.account < 0) {
|
||||
if (form.$invalid || $scope.formData.ccount < 0) {
|
||||
popupService.showAlert(gettextCatalog.getString('There is an error in the form'));
|
||||
return;
|
||||
}
|
||||
|
||||
$scope.importErr = false;
|
||||
|
||||
var account = +$scope.account;
|
||||
var account = $scope.formData.ccount;
|
||||
|
||||
if ($scope.seedSourceId == 'trezor') {
|
||||
if ($scope.seedSource.id == 'trezor') {
|
||||
if (account < 1) {
|
||||
$scope.error = gettext('Invalid account number');
|
||||
popupService.showAlert(gettextCatalog.getString('Invalid account number'));
|
||||
return;
|
||||
}
|
||||
account = account - 1;
|
||||
}
|
||||
|
||||
switch ($scope.seedSourceId) {
|
||||
switch ($scope.seedSource.id) {
|
||||
case ('ledger'):
|
||||
ongoingProcess.set('connectingledger', true);
|
||||
$scope.importLedger(account);
|
||||
break;
|
||||
case ('trezor'):
|
||||
ongoingProcess.set('connectingtrezor', true);
|
||||
$scope.importTrezor(account, $scope.isMultisig);
|
||||
$scope.importTrezor(account, $scope.formData.isMultisig);
|
||||
break;
|
||||
default:
|
||||
throw ('Error: bad source id');
|
||||
};
|
||||
};
|
||||
|
||||
$scope.setSeedSource = function() {
|
||||
|
||||
if (!$scope.seedSource) return;
|
||||
$scope.seedSourceId = $scope.seedSource.id;
|
||||
$timeout(function() {
|
||||
$rootScope.$apply();
|
||||
});
|
||||
};
|
||||
|
||||
$scope.importLedger = function(account) {
|
||||
ledger.getInfoForNewWallet(true, account, function(err, lopts) {
|
||||
ongoingProcess.clear();
|
||||
|
|
@ -332,7 +319,7 @@ angular.module('copayApp.controllers').controller('importController',
|
|||
}
|
||||
|
||||
lopts.externalSource = 'ledger';
|
||||
lopts.bwsurl = $scope.bwsurl;
|
||||
lopts.bwsurl = $scope.formData.bwsurl;
|
||||
ongoingProcess.set('importingWallet', true);
|
||||
$log.debug('Import opts', lopts);
|
||||
|
||||
|
|
@ -348,7 +335,6 @@ angular.module('copayApp.controllers').controller('importController',
|
|||
};
|
||||
|
||||
var finish = function(wallet) {
|
||||
|
||||
walletService.updateRemotePreferences(wallet, {}, function() {
|
||||
$log.debug('Remote preferences saved for:' + wallet.credentials.walletId)
|
||||
});
|
||||
|
|
@ -361,8 +347,4 @@ angular.module('copayApp.controllers').controller('importController',
|
|||
}
|
||||
$state.go('tabs.home');
|
||||
};
|
||||
|
||||
updateSeedSourceSelect();
|
||||
$scope.setSeedSource();
|
||||
if ($stateParams.code) $scope.processWalletInfo($stateParams.code);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
angular.module('copayApp.controllers').controller('welcomeController', function($scope, $state, $timeout, $log, $ionicPopup, profileService) {
|
||||
|
||||
$scope.goImport = function(code) {
|
||||
$state.go('onboarding.import.phrase', {
|
||||
$state.go('onboarding.import', {
|
||||
fromOnboarding: true,
|
||||
code: code
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue