mirror of https://github.com/BTCPrivate/copay.git
refactor store data
This commit is contained in:
parent
0c1c09d731
commit
beea420c53
|
@ -247,30 +247,11 @@ angular.module('copayApp.services')
|
|||
}, function(err, secret) {
|
||||
if (err) return bwsError.cb(err, gettext('Error creating wallet'), cb);
|
||||
|
||||
root.storeData(walletClient, opts.bwsurl, cb);
|
||||
root._addWalletClient(walletClient, opts, cb);
|
||||
})
|
||||
});
|
||||
};
|
||||
|
||||
root.storeData = function(walletClient, bwsurl, cb) {
|
||||
var walletId = walletClient.credentials.walletId;
|
||||
var defaults = configService.getDefaults();
|
||||
var opts_ = {
|
||||
bwsFor: {}
|
||||
};
|
||||
opts_.bwsFor[walletId] = bwsurl || defaults.bws.url;
|
||||
configService.set(opts_, function(err) {
|
||||
if (err) console.log(err);
|
||||
|
||||
root.profile.credentials.push(JSON.parse(walletClient.export()));
|
||||
root.setWalletClients();
|
||||
|
||||
root.setAndStoreFocus(walletId, function() {
|
||||
storageService.storeProfile(root.profile, cb);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
root.joinWallet = function(opts, cb) {
|
||||
var walletClient = bwcService.getClient();
|
||||
$log.debug('Joining Wallet:', opts);
|
||||
|
@ -296,7 +277,7 @@ angular.module('copayApp.services')
|
|||
|
||||
walletClient.joinWallet(opts.secret, opts.myName || 'me', {}, function(err) {
|
||||
if (err) return bwsError.cb(err, gettext('Could not join wallet'), cb);
|
||||
root.storeData(walletClient, opts.bwsurl, cb);
|
||||
root._addWalletClient(walletClient, opts, cb);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
@ -338,8 +319,24 @@ angular.module('copayApp.services')
|
|||
if (w) {
|
||||
return cb(gettext('Wallet already in Copay' + ": ") + w.walletName);
|
||||
}
|
||||
root.storeData(walletClient, opts.bwsurl, function(err){
|
||||
return cb(err, walletId);
|
||||
|
||||
var defaults = configService.getDefaults();
|
||||
var bwsFor = {};
|
||||
bwsFor[walletId] = opts.bwsurl || defaults.bws.url;
|
||||
|
||||
configService.set({
|
||||
bwsFor: bwsFor,
|
||||
}, function(err) {
|
||||
if (err) console.log(err);
|
||||
|
||||
root.profile.credentials.push(JSON.parse(walletClient.export()));
|
||||
root.setWalletClients();
|
||||
|
||||
root.setAndStoreFocus(walletId, function() {
|
||||
storageService.storeProfile(root.profile, function(err){
|
||||
return cb(err, walletId);
|
||||
});
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue