added a wrapper for the method fromObj of Wallet

This commit is contained in:
Mario Colque 2014-04-28 12:02:43 -03:00
commit 47cb4bd3da
3 changed files with 29 additions and 16 deletions

View file

@ -225,14 +225,16 @@ Wallet.prototype.toObj = function() {
return walletObj;
};
Wallet.fromObj = function(wallet) {
var opts = wallet.opts;
opts['publicKeyRing'] = this.publicKeyring.fromObj(wallet.publicKeyRing);
opts['txProposals'] = this.txProposal.fromObj(wallet.txProposals);
opts['privateKey'] = this.privateKey.fromObj(wallet.privateKey);
Wallet.fromObj = function(o, storage, network, blockchain) {
var opts = JSON.parse(JSON.stringify(o.opts));
opts.publicKeyRing = copay.PublicKeyRing.fromObj(o.publicKeyRing);
opts.txProposals = copay.TxProposals.fromObj(o.txProposals);
opts.privateKey = copay.PrivateKey.fromObj(o.privateKey);
opts.storage = storage;
opts.network = network;
opts.blockchain = blockchain;
var w = new Wallet(opts);
return w;
};