remove WalletFactory file (everything is in Wallet)

This commit is contained in:
Manuel Araoz 2014-04-15 10:55:50 -03:00
parent 6c753cd5ab
commit f22ca08b39
1 changed files with 0 additions and 47 deletions

View File

@ -1,47 +0,0 @@
'use strict';
var imports = require('soop').imports();
function Wallet(opts) {
opts = opts || {};
this.host = 'localhost';
this.port = '3001';
}
WalletFactory = function() {
this.storage = copay.Storage.default();
};
WalletFactory.prototype.create = function(config, opts) {
var w = new Wallet(config, opts);
w.store();
this._addWalletId(w.id);
};
WalletFactory.prototype.get = function(walletId) {
return Wallet.read(walletId);
};
WalletFactory.prototype.remove = function(walletId) {
// TODO remove wallet contents, not only the id (Wallet.remove?)
this._delWalletId(walletId);
};
WalletFactory.prototype._addWalletId = function(walletId) {
var ids = this._getWalletIds();
if (ids.indexOf(walletId) == -1) return;
localStorage.setItem('walletIds', (ids ? ids + ',' : '') + walletId);
};
WalletFactory.prototype._delWalletId = function(walletId) {
var ids = this._getWalletIds();
var index = ids.indexOf(walletId);
if (index == -1) return;
ids.splice(index, 1); // removes walletId
this.storage.set('walletIds', ids.join(','));
};
WalletFactory.prototype._getWalletIds = function() {
var ids = this.storage.get('walletIds');
return ids ? ids.split(',') : [];
};