add option to enable console.logs
This commit is contained in:
parent
d0e114c346
commit
8cf91d027e
6 changed files with 33 additions and 35 deletions
|
|
@ -17,6 +17,12 @@ function Wallet(config) {
|
|||
this._startInterface(config);
|
||||
}
|
||||
|
||||
Wallet.prototype.log = function(){
|
||||
if (!this.verbose) return;
|
||||
|
||||
console.this.log(arguments);
|
||||
}
|
||||
|
||||
Wallet.prototype._startInterface = function(config) {
|
||||
this.storage = new Storage(config.storage);
|
||||
this.network = new Network(config.network);
|
||||
|
|
@ -31,12 +37,12 @@ Wallet.prototype._startInterface = function(config) {
|
|||
Wallet.prototype.create = function(opts) {
|
||||
|
||||
this.id = opts.id || Wallet.getRandomId();
|
||||
console.log('### CREATING NEW WALLET.' + (opts.id ? ' USING ID: ' + opts.id : ' NEW ID'));
|
||||
this.log('### CREATING NEW WALLET.' + (opts.id ? ' USING ID: ' + opts.id : ' NEW ID'));
|
||||
|
||||
this.privateKey = new copay.PrivateKey({
|
||||
networkName: this.networkName
|
||||
});
|
||||
console.log('\t### PrivateKey Initialized');
|
||||
this.log('\t### PrivateKey Initialized');
|
||||
|
||||
this.publicKeyRing = new copay.PublicKeyRing({
|
||||
walletId: this.id,
|
||||
|
|
@ -46,14 +52,14 @@ Wallet.prototype.create = function(opts) {
|
|||
});
|
||||
|
||||
this.publicKeyRing.addCopayer(this.privateKey.getBIP32().extendedPublicKeyString());
|
||||
console.log('\t### PublicKeyRing Initialized WalletID: ' + this.publicKeyRing.walletId);
|
||||
this.log('\t### PublicKeyRing Initialized WalletID: ' + this.publicKeyRing.walletId);
|
||||
|
||||
this.txProposals = new copay.TxProposals({
|
||||
walletId: this.id,
|
||||
publicKeyRing: this.publicKeyRing,
|
||||
networkName: this.networkName,
|
||||
});
|
||||
console.log('\t### TxProposals Initialized');
|
||||
this.log('\t### TxProposals Initialized');
|
||||
};
|
||||
|
||||
|
||||
|
|
@ -86,7 +92,7 @@ Wallet.prototype.load = function(walletId) {
|
|||
this.privateKey.getBIP32().extendedPublicKeyString()
|
||||
);
|
||||
} catch (e) {
|
||||
console.log('NOT NECCESARY AN ERROR:', e); //TODO
|
||||
this.log('NOT NECCESARY AN ERROR:', e); //TODO
|
||||
};
|
||||
};
|
||||
|
||||
|
|
@ -101,7 +107,7 @@ Wallet.prototype.store = function() {
|
|||
|
||||
|
||||
Wallet.prototype.sendTxProposals = function(recipients) {
|
||||
console.log('### SENDING txProposals TO:', recipients||'All', this.txProposals);
|
||||
this.log('### SENDING txProposals TO:', recipients||'All', this.txProposals);
|
||||
|
||||
this.network.send( recipients, {
|
||||
type: 'txProposals',
|
||||
|
|
@ -111,7 +117,7 @@ Wallet.prototype.sendTxProposals = function(recipients) {
|
|||
};
|
||||
|
||||
Wallet.prototype.sendPublicKeyRing = function(recipients) {
|
||||
console.log('### SENDING publicKeyRing TO:', recipients||'All', this.publicKeyRing.toObj());
|
||||
this.log('### SENDING publicKeyRing TO:', recipients||'All', this.publicKeyRing.toObj());
|
||||
|
||||
this.network.send(recipients, {
|
||||
type: 'publicKeyRing',
|
||||
|
|
|
|||
|
|
@ -63,7 +63,7 @@ Network._arrayRemove = function(el, array) {
|
|||
|
||||
// DEBUG
|
||||
Network.prototype._showConnectedPeers = function() {
|
||||
console.log("### CONNECTED PEERS", this.connectedPeers);
|
||||
// console.log("### CONNECTED PEERS", this.connectedPeers);
|
||||
};
|
||||
|
||||
Network.prototype._onClose = function(peerId) {
|
||||
|
|
@ -166,7 +166,6 @@ Network.prototype._setupConnectionHandlers = function(
|
|||
};
|
||||
|
||||
Network.prototype._notify = function(newPeer) {
|
||||
console.log('[Network.js.168:_notify:]'); //TODO
|
||||
this._showConnectedPeers();
|
||||
this.emit('networkChange', newPeer);
|
||||
};
|
||||
|
|
@ -177,7 +176,6 @@ Network.prototype._setupPeerHandlers = function(openCallback) {
|
|||
|
||||
|
||||
p.on('open', function(peerId) {
|
||||
console.log('### PEER OPEN. I AM:' + peerId);
|
||||
self.peerId = peerId;
|
||||
self.connectedPeers = [peerId];
|
||||
self._notify();
|
||||
|
|
@ -241,13 +239,10 @@ console.log('[WebRTC.js.222:peerId:]',peerId, data); //TODO
|
|||
|
||||
Network.prototype.send = function(peerIds, data, cb) {
|
||||
var self=this;
|
||||
|
||||
console.log('[WebRTC.js.242:peerIds:]',peerIds); //TODO
|
||||
if (!peerIds) {
|
||||
peerIds = this.connectedPeers;
|
||||
data.isBroadcast = 1;
|
||||
}
|
||||
console.log('[WebRTC.js.246:peerIds:]',peerIds, data); //TODO
|
||||
|
||||
if (Array.isArray(peerIds)) {
|
||||
var l = peerIds.length;
|
||||
|
|
@ -279,13 +274,10 @@ Network.prototype.connectTo = function(peerId, openCallback, closeCallback ) {
|
|||
|
||||
|
||||
Network.prototype.disconnect = function(peerId, cb) {
|
||||
console.log('[Network.js.268:disconnect:]'); //TODO
|
||||
var self = this;
|
||||
self.closing = 1;
|
||||
|
||||
this.send(null, { type: 'disconnect' }, function() {
|
||||
|
||||
console.log('[Network.js.273] disconnect CB'); //TODO
|
||||
self.connectedPeers = [];
|
||||
self.peerId = null;
|
||||
if (self.peer) {
|
||||
|
|
|
|||
|
|
@ -23,8 +23,6 @@ Storage.prototype.getGlobal = function(k) {
|
|||
// set value for key
|
||||
Storage.prototype.setGlobal = function(k,v) {
|
||||
localStorage.setItem(k, JSON.stringify(v));
|
||||
console.log('[Plain.js.25]',k,v); //TODO
|
||||
|
||||
};
|
||||
|
||||
// remove value for key
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue