create profile separately from default wallet
This commit is contained in:
parent
7584d2b145
commit
74e6897d66
10 changed files with 57 additions and 68 deletions
|
|
@ -1,12 +1,12 @@
|
|||
<ion-view ng-controller="collectEmailController">
|
||||
<ion-nav-bar class="bar-stable">
|
||||
<ion-view>
|
||||
<ion-nav-bar class="bar-stable" ng-controller="backController">
|
||||
<ion-nav-buttons side="secondary">
|
||||
<button class="button no-border" ng-click="skip()">
|
||||
<button class="button no-border" ng-click="onboardingMailSkip()">
|
||||
Skip
|
||||
</button>
|
||||
</ion-nav-buttons>
|
||||
</ion-nav-bar>
|
||||
<ion-content >
|
||||
<ion-content ng-controller="collectEmailController">
|
||||
Wallet Created
|
||||
Where would you like to receive email notifications about payments
|
||||
<form name="emailForm" ng-submit="save(emailForm)" novalidate>
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
</button>
|
||||
</ion-nav-buttons>
|
||||
<ion-nav-buttons side="secondary">
|
||||
<button class="button no-border" ng-show="data.index == 0" ng-click="createProfile()">
|
||||
<button class="button no-border" ng-show="data.index == 0" ng-click="createDefaultWallet()">
|
||||
Skip
|
||||
</button>
|
||||
</ion-nav-buttons>
|
||||
|
|
@ -55,7 +55,7 @@
|
|||
<p translate>
|
||||
Not even BitPay can access it
|
||||
</p>
|
||||
<button class="button icon-right button-positive" ng-click="createProfile()">
|
||||
<button class="button icon-right button-positive" ng-click="createDefaultWallet()">
|
||||
Create bitcoin wallet
|
||||
</button>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -1,8 +1,7 @@
|
|||
<ion-view>
|
||||
<ion-content ng-controller="welcomeController">
|
||||
<ion-content ng-controller="welcomeController" ng-init="createProfile()">
|
||||
<div class="text-center">
|
||||
<h2>bitpay</h2>
|
||||
|
||||
<h2>bitpay</h2>
|
||||
<span translate>
|
||||
Take control of your money - get started with bitcoin
|
||||
</span>
|
||||
|
|
|
|||
|
|
@ -1,10 +1,19 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copayApp.controllers').controller('backController', function($scope, $state, $stateParams) {
|
||||
angular.module('copayApp.controllers').controller('backController', function($scope, $state, $stateParams, platformInfo) {
|
||||
|
||||
var isCordova = platformInfo.isCordova;
|
||||
var isWP = platformInfo.isWP;
|
||||
var usePushNotifications = isCordova && !isWP;
|
||||
|
||||
$scope.importGoBack = function() {
|
||||
if ($stateParams.fromOnboarding) $state.go('onboarding.welcome');
|
||||
else $state.go('add.main');
|
||||
};
|
||||
|
||||
$scope.onboardingMailSkip = function() {
|
||||
if (!usePushNotifications) $state.go('onboarding.backupRequest');
|
||||
else $state.go('onboarding.notifications');
|
||||
}
|
||||
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copayApp.controllers').controller('backupWarningController', function($scope, $state, $ionicPopup, profileService) {
|
||||
angular.module('copayApp.controllers').controller('backupWarningController', function($scope, $state, $ionicPopup, $stateParams, profileService) {
|
||||
|
||||
$scope.openPopup = function() {
|
||||
var backupWarningPopup = $ionicPopup.show({
|
||||
|
|
@ -10,12 +10,10 @@ angular.module('copayApp.controllers').controller('backupWarningController', fun
|
|||
|
||||
$scope.close = function() {
|
||||
backupWarningPopup.close();
|
||||
var wallet = profileService.getWallets()[0];
|
||||
$state.go('wallet.backup', {
|
||||
walletId: wallet.credentials.walletId,
|
||||
walletId: $stateParams.walletId,
|
||||
fromOnboarding: true
|
||||
})
|
||||
};
|
||||
}
|
||||
|
||||
});
|
||||
|
|
|
|||
|
|
@ -6,11 +6,6 @@ angular.module('copayApp.controllers').controller('collectEmailController', func
|
|||
var isWP = platformInfo.isWP;
|
||||
var usePushNotifications = isCordova && !isWP;
|
||||
|
||||
$scope.skip = function() {
|
||||
if (!usePushNotifications) $state.go('onboarding.backupRequest');
|
||||
else $state.go('onboarding.notifications');
|
||||
}
|
||||
|
||||
$scope.save = function(form) {
|
||||
var wallet = profileService.getWallet($stateParams.walletId);
|
||||
var email = $scope.email || '';
|
||||
|
|
|
|||
|
|
@ -2,8 +2,9 @@
|
|||
angular.module('copayApp.controllers').controller('tourController',
|
||||
function($scope, $state, $log, $timeout, ongoingProcess, profileService) {
|
||||
|
||||
$scope.init = function() {
|
||||
var tries = 0;
|
||||
|
||||
$scope.init = function() {
|
||||
$scope.data = {
|
||||
index: 0
|
||||
};
|
||||
|
|
@ -16,33 +17,25 @@ angular.module('copayApp.controllers').controller('tourController',
|
|||
}
|
||||
};
|
||||
|
||||
$scope.createProfile = function(opts) {
|
||||
var tries = 0;
|
||||
opts = opts || {};
|
||||
$log.debug('Creating profile');
|
||||
$scope.createDefaultWallet = function() {
|
||||
ongoingProcess.set('creatingWallet', true);
|
||||
profileService.create(opts, function(err) {
|
||||
profileService.createDefaultWallet(function(err, walletClient) {
|
||||
if (err) {
|
||||
$log.warn(err);
|
||||
$scope.error = err;
|
||||
$scope.$apply();
|
||||
|
||||
return $timeout(function() {
|
||||
$log.warn('Retrying to create profile......');
|
||||
$log.warn('Retrying to create default wallet......');
|
||||
if (tries == 3) {
|
||||
tries == 0;
|
||||
return $scope.createProfile({
|
||||
noWallet: true
|
||||
});
|
||||
return $scope.createDefaultWallet();
|
||||
} else {
|
||||
tries += 1;
|
||||
return $scope.createProfile();
|
||||
return $scope.createDefaultWallet();
|
||||
}
|
||||
}, 3000);
|
||||
};
|
||||
$scope.error = "";
|
||||
ongoingProcess.set('creatingWallet', false);
|
||||
var wallet = profileService.getWallets()[0];
|
||||
var wallet = walletClient;
|
||||
$state.go('onboarding.collectEmail', {
|
||||
walletId: wallet.credentials.walletId
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,11 +1,18 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copayApp.controllers').controller('welcomeController', function($scope, $state, $ionicPopup, profileService) {
|
||||
angular.module('copayApp.controllers').controller('welcomeController', function($scope, $state, $timeout, $log, $ionicPopup, profileService) {
|
||||
|
||||
$scope.goImport = function() {
|
||||
$state.go('add.import.phrase', {
|
||||
fromOnboarding: true
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
$scope.createProfile = function() {
|
||||
$log.debug('Creating profile');
|
||||
profileService.createProfile(function(err) {
|
||||
if (err) $log.warn(err);
|
||||
});
|
||||
};
|
||||
|
||||
});
|
||||
|
|
|
|||
|
|
@ -554,7 +554,7 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr
|
|||
*/
|
||||
|
||||
.state('onboarding', {
|
||||
url: '/onboarding',
|
||||
url: '/onboarding/:walletId',
|
||||
abstract: true,
|
||||
template: '<ion-nav-view name="onboarding"></ion-nav-view>'
|
||||
})
|
||||
|
|
|
|||
|
|
@ -367,26 +367,6 @@ angular.module('copayApp.services')
|
|||
}, 50);
|
||||
};
|
||||
|
||||
// Creates the default Copay profile and its wallet
|
||||
root.createDefaultProfile = function(opts, cb) {
|
||||
var p = Profile.create();
|
||||
|
||||
if (opts.noWallet) {
|
||||
return cb(null, p);
|
||||
}
|
||||
|
||||
opts.m = 1;
|
||||
opts.n = 1;
|
||||
opts.network = 'livenet';
|
||||
|
||||
doCreateWallet(opts, function(err, walletClient) {
|
||||
if (err) return cb(err);
|
||||
|
||||
p.addWallet(JSON.parse(walletClient.export()));
|
||||
return cb(null, p);
|
||||
});
|
||||
};
|
||||
|
||||
// create and store a wallet
|
||||
root.createWallet = function(opts, cb) {
|
||||
doCreateWallet(opts, function(err, walletClient, secret) {
|
||||
|
|
@ -482,6 +462,7 @@ angular.module('copayApp.services')
|
|||
if (!client || !client.credentials)
|
||||
return cb(gettext('Could not access wallet'));
|
||||
|
||||
if (root.profile) root.profile = Profile.create();
|
||||
var walletId = client.credentials.walletId
|
||||
|
||||
if (!root.profile.addWallet(JSON.parse(client.export())))
|
||||
|
|
@ -633,26 +614,33 @@ angular.module('copayApp.services')
|
|||
});
|
||||
};
|
||||
|
||||
root.create = function(opts, cb) {
|
||||
$log.info('Creating profile', opts);
|
||||
root.createProfile = function(cb) {
|
||||
$log.info('Creating profile');
|
||||
var defaults = configService.getDefaults();
|
||||
|
||||
configService.get(function(err) {
|
||||
root.createDefaultProfile(opts, function(err, p) {
|
||||
if (err) return cb(err);
|
||||
if (err) $log.debug(err);
|
||||
|
||||
storageService.storeNewProfile(p, function(err) {
|
||||
if (err) return cb(err);
|
||||
root.bindProfile(p, function(err) {
|
||||
// ignore NONAGREEDDISCLAIMER
|
||||
if (err && err.toString().match('NONAGREEDDISCLAIMER')) return cb();
|
||||
return cb(err);
|
||||
});
|
||||
var p = Profile.create();
|
||||
storageService.storeNewProfile(p, function(err) {
|
||||
if (err) return cb(err);
|
||||
root.bindProfile(p, function(err) {
|
||||
// ignore NONAGREEDDISCLAIMER
|
||||
if (err && err.toString().match('NONAGREEDDISCLAIMER')) return cb();
|
||||
return cb(err);
|
||||
});
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
root.createDefaultWallet = function(cb) {
|
||||
var opts = {};
|
||||
opts.m = 1;
|
||||
opts.n = 1;
|
||||
opts.network = 'livenet';
|
||||
root.createWallet(opts, cb);
|
||||
};
|
||||
|
||||
root.setDisclaimerAccepted = function(cb) {
|
||||
root.profile.disclaimerAccepted = true;
|
||||
storageService.storeProfile(root.profile, function(err) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue