From d8437cf3fb7730f056b290ef088bd2e476a1c2c5 Mon Sep 17 00:00:00 2001 From: Chris Troutner Date: Wed, 27 Jan 2021 07:24:28 -0800 Subject: [PATCH] fix(sortAllTxs): Renaming Electrumx.sort0ConfTxs to sortAllTxs --- src/electrumx.js | 8 ++++---- test/integration/electrumx.js | 4 ++-- test/unit/electrumx.js | 8 ++++---- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/electrumx.js b/src/electrumx.js index bbf1a57..283593a 100644 --- a/src/electrumx.js +++ b/src/electrumx.js @@ -651,8 +651,8 @@ class ElectrumX { } /** - * @api Electrumx.sort0ConfTxs() sort0ConfTxs() - * @apiName ElectrumX sort0ConfTxs + * @api Electrumx.sortAllTxs() sortAllTxs() + * @apiName ElectrumX sortAllTxs * @apiGroup ElectrumX * @apiDescription Sort the output of Electrum.transactions() by block height. * @@ -666,7 +666,7 @@ class ElectrumX { * @apiExample Example usage: * (async () => { * const txs = await bchjs.Electrumx.transactions('bitcoincash:qpdh9s677ya8tnx7zdhfrn8qfyvy22wj4qa7nwqa5v') - * const sortedTxs = await bchjs.Electrumx.sort0ConfTxs(txs.transactions, 'ASCENDING') + * const sortedTxs = await bchjs.Electrumx.sortAllTxs(txs.transactions, 'ASCENDING') * console.log(sortedTxs) * })() * @@ -682,7 +682,7 @@ class ElectrumX { * // ] */ // Substitute zero-conf txs with the current block-height + 1 - async sort0ConfTxs (txs, sortingOrder = 'DESCENDING') { + async sortAllTxs (txs, sortingOrder = 'DESCENDING') { try { // Calculate the height of the next block const nextBlock = (await this.blockchain.getBlockCount()) + 1 diff --git a/test/integration/electrumx.js b/test/integration/electrumx.js index 50d41ec..40e2b9c 100644 --- a/test/integration/electrumx.js +++ b/test/integration/electrumx.js @@ -369,12 +369,12 @@ describe('#ElectrumX', () => { }) }) - describe('#sort0ConfTxs', () => { + describe('#sortAllTxs', () => { it('should GET transaction history for a single address', async () => { const addr = 'bitcoincash:qpdh9s677ya8tnx7zdhfrn8qfyvy22wj4qa7nwqa5v' const txs = await bchjs.Electrumx.transactions(addr) - const sortedTransactions = await bchjs.Electrumx.sort0ConfTxs( + const sortedTransactions = await bchjs.Electrumx.sortAllTxs( txs.transactions ) // console.log( diff --git a/test/unit/electrumx.js b/test/unit/electrumx.js index ba578d3..6da9721 100644 --- a/test/unit/electrumx.js +++ b/test/unit/electrumx.js @@ -456,12 +456,12 @@ describe('#ElectrumX', () => { }) // These tests use mocked data that contains unconfirmed transactions. - describe('#sort0ConfTxs', () => { + describe('#sortAllTxs', () => { it('should sort in ascending', async () => { // Stub network calls sandbox.stub(bchjs.Electrumx.blockchain, 'getBlockCount').resolves(672141) - const result = await bchjs.Electrumx.sort0ConfTxs(mockData.txHistoryWithUnconfirmed.transactions, 'ASCENDING') + const result = await bchjs.Electrumx.sortAllTxs(mockData.txHistoryWithUnconfirmed.transactions, 'ASCENDING') // console.log(`result: ${JSON.stringify(result, null, 2)}`) assert.isBelow(result[0].height, result[1].height) @@ -471,7 +471,7 @@ describe('#ElectrumX', () => { // Stub network calls sandbox.stub(bchjs.Electrumx.blockchain, 'getBlockCount').resolves(672141) - const result = await bchjs.Electrumx.sort0ConfTxs(mockData.txHistoryWithUnconfirmed.transactions) + const result = await bchjs.Electrumx.sortAllTxs(mockData.txHistoryWithUnconfirmed.transactions) // console.log(`result: ${JSON.stringify(result, null, 2)}`) assert.isAbove(result[1].height, result[2].height) @@ -482,7 +482,7 @@ describe('#ElectrumX', () => { // Stub network calls sandbox.stub(bchjs.Electrumx.blockchain, 'getBlockCount').resolves(672141) - await bchjs.Electrumx.sort0ConfTxs('abc') + await bchjs.Electrumx.sortAllTxs('abc') assert.fail('Unexpected result') } catch (err) {