create profile separately from default wallet

This commit is contained in:
Gabriel Bazán 2016-08-30 15:38:48 -03:00
commit 74e6897d66
10 changed files with 57 additions and 68 deletions

View file

@ -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) {