From b638ed08dd8da436e59658fadd405e370ae3413c Mon Sep 17 00:00:00 2001 From: Ivan Socolsky Date: Wed, 1 Jun 2016 15:27:28 -0300 Subject: [PATCH 1/2] fill editedByName field --- lib/storage.js | 18 ++++++++++-------- test/integration/server.js | 1 + 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/lib/storage.js b/lib/storage.js index 5b571bc..7f044ef 100644 --- a/lib/storage.js +++ b/lib/storage.js @@ -174,10 +174,11 @@ Storage.prototype.fetchCopayerLookup = function(copayerId, cb) { // TODO: should be done client-side Storage.prototype._completeTxData = function(walletId, txs, cb) { - var txList = [].concat(txs); - this.fetchWallet(walletId, function(err, wallet) { + var self = this; + + self.fetchWallet(walletId, function(err, wallet) { if (err) return cb(err); - _.each(txList, function(tx) { + _.each([].concat(txs), function(tx) { tx.derivationStrategy = wallet.derivationStrategy || 'BIP45'; tx.creatorName = wallet.getCopayer(tx.creatorId).name; _.each(tx.actions, function(action) { @@ -657,22 +658,23 @@ Storage.prototype.fetchFiatRate = function(providerName, code, ts, cb) { Storage.prototype.fetchTxNote = function(walletId, txid, cb) { var self = this; - this.db.collection(collections.TX_NOTES).findOne({ + self.db.collection(collections.TX_NOTES).findOne({ walletId: walletId, txid: txid, }, function(err, result) { if (err) return cb(err); if (!result || !result.body) return cb(); - return cb(null, Model.TxNote.fromObj(result)); + return self._completeTxNotesData(walletId, Model.TxNote.fromObj(result), cb); }); }; // TODO: should be done client-side Storage.prototype._completeTxNotesData = function(walletId, notes, cb) { - var notesList = [].concat(notes); - this.fetchWallet(walletId, function(err, wallet) { + var self = this; + + self.fetchWallet(walletId, function(err, wallet) { if (err) return cb(err); - _.each(notesList, function(note) { + _.each([].concat(notes), function(note) { note.editedByName = wallet.getCopayer(note.editedBy).name; }); return cb(null, notes); diff --git a/test/integration/server.js b/test/integration/server.js index f9272f9..e4dfb6c 100644 --- a/test/integration/server.js +++ b/test/integration/server.js @@ -3924,6 +3924,7 @@ describe('Wallet service', function() { note.walletId.should.equal(wallet.id); note.body.should.equal('note body'); note.editedBy.should.equal(server.copayerId); + note.editedByName.should.equal('copayer 1'); note.createdOn.should.equal(note.editedOn); done(); }); From 812ac43dbff4d92bdda4c24e3ba43c22a17bdbe5 Mon Sep 17 00:00:00 2001 From: Ivan Socolsky Date: Wed, 1 Jun 2016 15:28:02 -0300 Subject: [PATCH 2/2] bump v1.8.2 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 91d69fc..6d21233 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "bitcore-wallet-service", "description": "A service for Mutisig HD Bitcoin Wallets", "author": "BitPay Inc", - "version": "1.8.1", + "version": "1.8.2", "keywords": [ "bitcoin", "copay",