From b010abce5188441f9cda116d1e05099b19001ee6 Mon Sep 17 00:00:00 2001 From: Nodari Chkuaselidze Date: Tue, 2 Jul 2024 10:17:41 +0400 Subject: [PATCH] wallet-client: rename createAuctionTxs to createAuctionTXs. Make style consistent for methods and variables. --- CHANGELOG.md | 1 + bin/hsw-cli | 6 +++--- lib/client/wallet.js | 6 +++--- lib/wallet/http.js | 16 ++++++++-------- lib/wallet/wallet.js | 6 +++--- lib/wallet/walletdb.js | 14 +++++++------- test/node-rescan-test.js | 16 ++++++++-------- test/wallet-chainstate-test.js | 32 ++++++++++++++++---------------- test/wallet-http-test.js | 8 ++++---- test/wallet-test.js | 6 +++--- 10 files changed, 56 insertions(+), 55 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fa7b70afe..8e585cf3e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -71,6 +71,7 @@ process and allows parallel rescans. - All transaction sending endpoints now fundlock/queue tx creation. (no more conflicting transactions) - Add options to `getNames` for passing `own`. + - Rename `createAuctionTxs` to `createAuctionTXs`. ## v6.0.0 diff --git a/bin/hsw-cli b/bin/hsw-cli index 7727f2d3a..d21f11d0e 100755 --- a/bin/hsw-cli +++ b/bin/hsw-cli @@ -372,7 +372,7 @@ class CLI { this.log(tx); } - async createAuctionTxs() { + async createAuctionTXs() { const options = { name: this.config.str([0, 'name']), bid: this.config.ufixed([1, 'bid'], EXP), @@ -381,7 +381,7 @@ class CLI { passphrase: this.config.str('passphrase') }; - const txs = await this.wallet.createAuctionTxs(options); + const txs = await this.wallet.createAuctionTXs(options); this.log(txs); } @@ -650,7 +650,7 @@ class CLI { await this.getMaster(); break; case 'mkauctiontxs': - await this.createAuctionTxs(); + await this.createAuctionTXs(); break; case 'mktx': await this.createTX(); diff --git a/lib/client/wallet.js b/lib/client/wallet.js index 784b21d17..cf9d16a52 100644 --- a/lib/client/wallet.js +++ b/lib/client/wallet.js @@ -506,7 +506,7 @@ class WalletClient extends Client { * @returns {Promise} */ - createAuctionTxs(id, options) { + createAuctionTXs(id, options) { return this.post(`/wallet/${id}/auction`, options); } @@ -1226,8 +1226,8 @@ class Wallet extends EventEmitter { * @returns {Promise} */ - createAuctionTxs(options) { - return this.client.createAuctionTxs(this.id, options); + createAuctionTXs(options) { + return this.client.createAuctionTXs(this.id, options); } /** diff --git a/lib/wallet/http.js b/lib/wallet/http.js index 4f6f921d6..f11fcac34 100644 --- a/lib/wallet/http.js +++ b/lib/wallet/http.js @@ -1151,7 +1151,7 @@ class HTTP extends Server { enforce(broadcastBid ? sign : true, 'Must sign when broadcasting.'); const options = TransactionOptions.fromValidator(valid); - const auctionTxs = await req.wallet.createAuctionTxs( + const auctionTXs = await req.wallet.createAuctionTXs( name, bid, lockup, @@ -1159,21 +1159,21 @@ class HTTP extends Server { ); if (broadcastBid) - auctionTxs.bid = await req.wallet.sendMTX(auctionTxs.bid, passphrase); + auctionTXs.bid = await req.wallet.sendMTX(auctionTXs.bid, passphrase); if (sign) { if (!broadcastBid) - await req.wallet.sign(auctionTxs.bid, passphrase); + await req.wallet.sign(auctionTXs.bid, passphrase); - await req.wallet.sign(auctionTxs.reveal, passphrase); + await req.wallet.sign(auctionTXs.reveal, passphrase); } - const jsonBid = auctionTxs.bid.getJSON(this.network); - const jsonReveal = auctionTxs.reveal.getJSON(this.network); + const jsonBid = auctionTXs.bid.getJSON(this.network); + const jsonReveal = auctionTXs.reveal.getJSON(this.network); if (options.paths) { - await this.addOutputPaths(jsonBid, auctionTxs.bid, req.wallet); - await this.addOutputPaths(jsonReveal, auctionTxs.reveal, req.wallet); + await this.addOutputPaths(jsonBid, auctionTXs.bid, req.wallet); + await this.addOutputPaths(jsonReveal, auctionTXs.reveal, req.wallet); } return res.json(200, { diff --git a/lib/wallet/wallet.js b/lib/wallet/wallet.js index 0423eeb4f..0ae33504c 100644 --- a/lib/wallet/wallet.js +++ b/lib/wallet/wallet.js @@ -1897,10 +1897,10 @@ class Wallet extends EventEmitter { * @returns {MTX} output.reveal */ - async createAuctionTxs(name, value, lockup, options) { + async createAuctionTXs(name, value, lockup, options) { const unlock = await this.fundLock.lock(); try { - return await this._createAuctionTxs(name, value, lockup, options); + return await this._createAuctionTXs(name, value, lockup, options); } finally { unlock(); } @@ -1918,7 +1918,7 @@ class Wallet extends EventEmitter { * @returns {MTX} output.reveal */ - async _createAuctionTxs(name, value, lockup, options) { + async _createAuctionTXs(name, value, lockup, options) { const bid = await this._createBid(name, value, lockup, options); const bidOuputIndex = bid.outputs.findIndex(o => o.covenant.isBid()); diff --git a/lib/wallet/walletdb.js b/lib/wallet/walletdb.js index 86ae0f522..65df6f5a9 100644 --- a/lib/wallet/walletdb.js +++ b/lib/wallet/walletdb.js @@ -2445,7 +2445,7 @@ class WalletDB extends EventEmitter { return null; } - const walletTxs = []; + const walletTXs = []; let filterUpdated = false; try { @@ -2459,7 +2459,7 @@ class WalletDB extends EventEmitter { const txadded = await this._addTX(tx, tip); if (txadded) { - walletTxs.push(tx); + walletTXs.push(tx); if (txadded.filterUpdated) filterUpdated = true; @@ -2468,20 +2468,20 @@ class WalletDB extends EventEmitter { // Sync the state to the new tip. // If we encountered wallet txs, we also trigger mark check. - await this.setTip(tip, walletTxs.length > 0); + await this.setTip(tip, walletTXs.length > 0); } finally { this.confirming = false; } - if (walletTxs.length > 0) { + if (walletTXs.length > 0) { this.logger.info('Connected WalletDB block %x (tx=%d).', - tip.hash, walletTxs.length); + tip.hash, walletTXs.length); } - this.emit('block connect', entry, walletTxs); + this.emit('block connect', entry, walletTXs); return { - txs: walletTxs.length, + txs: walletTXs.length, filterUpdated: filterUpdated }; } diff --git a/test/node-rescan-test.js b/test/node-rescan-test.js index 40cbc5069..a3868872f 100644 --- a/test/node-rescan-test.js +++ b/test/node-rescan-test.js @@ -290,8 +290,8 @@ describe('Node Rescan Interactive API', function() { const {node} = nodeCtx; const startHeight = nodeCtx.height - RESCAN_DEPTH + 1; - const filterAndTxs = tests.slice(); - let test = filterAndTxs.shift(); + const filterAndTXs = tests.slice(); + let test = filterAndTXs.shift(); // initial run is the first filter test. let count = 0; @@ -304,14 +304,14 @@ describe('Node Rescan Interactive API', function() { // we are testing against the current filter. assert(test.txCountCheck(entry.height, txs)); - if (filterAndTxs.length === 0) { + if (filterAndTXs.length === 0) { return { type: scanActions.ABORT }; } // next test - test = filterAndTxs.shift(); + test = filterAndTXs.shift(); return { type: scanActions.REPEAT_SET, @@ -710,8 +710,8 @@ describe('Node Rescan Interactive API', function() { it('should rescan the same block with update filters (REPEAT_SET)', async () => { const startHeight = nodeCtx.height - RESCAN_DEPTH + 1; - const filterAndTxs = tests.slice(); - let test = filterAndTxs.shift(); + const filterAndTXs = tests.slice(); + let test = filterAndTXs.shift(); let count = 0; @@ -723,13 +723,13 @@ describe('Node Rescan Interactive API', function() { assert.strictEqual(entry.height, startHeight); assert(test.txCountCheck(entry.height, txs)); - if (filterAndTxs.length === 0) { + if (filterAndTXs.length === 0) { return { type: scanActions.ABORT }; } - test = filterAndTxs.shift(); + test = filterAndTXs.shift(); return { type: scanActions.REPEAT_SET, diff --git a/test/wallet-chainstate-test.js b/test/wallet-chainstate-test.js index 0cb32a2c7..3adfe8f51 100644 --- a/test/wallet-chainstate-test.js +++ b/test/wallet-chainstate-test.js @@ -266,8 +266,8 @@ describe('WalletDB ChainState', function() { await progressWithNoTX(wdb); for (let i = 0; i < blocksPerAction; i++) { - const blockAndTxs = await progressWithNoTX(wdb); - removeBlocks.push(blockAndTxs); + const blockAndTXs = await progressWithNoTX(wdb); + removeBlocks.push(blockAndTXs); } assert.strictEqual(wdb.state.startHeight, 0); @@ -277,11 +277,11 @@ describe('WalletDB ChainState', function() { assert.strictEqual(wdb.state.marked, false); for (let i = 0; i < blocksPerAction; i++) { - const blockAndTxs = await progressWithTX(wdb); - removeBlocks.push(blockAndTxs); + const blockAndTXs = await progressWithTX(wdb); + removeBlocks.push(blockAndTXs); if (!firstBlock) - firstBlock = blockAndTxs.block; + firstBlock = blockAndTXs.block; assert.strictEqual(wdb.state.startHeight, firstBlock.height); assert.bufferEqual(wdb.state.startHash, firstBlock.hash); @@ -389,10 +389,10 @@ describe('WalletDB ChainState', function() { removeBlocks.push(await progressWithNoTX(wdb)); for (let i = 0; i < blocksPerAction; i++) { - const blockAndTxs = await progressWithTX(wdb); + const blockAndTXs = await progressWithTX(wdb); if (!firstBlock) - firstBlock = blockAndTxs.block; - removeBlocks.push(blockAndTxs); + firstBlock = blockAndTXs.block; + removeBlocks.push(blockAndTXs); } assert.strictEqual(wdb.state.startHeight, firstBlock.height); @@ -416,10 +416,10 @@ describe('WalletDB ChainState', function() { firstBlock = null; for (let i = 0; i < blocksPerAction; i++) { - const blockAndTxs = await progressWithTX(wdb); + const blockAndTXs = await progressWithTX(wdb); if (!firstBlock) - firstBlock = blockAndTxs.block; + firstBlock = blockAndTXs.block; assert.strictEqual(wdb.state.startHeight, firstBlock.height); assert.strictEqual(wdb.state.startHash, firstBlock.hash); @@ -445,10 +445,10 @@ describe('WalletDB ChainState', function() { await progressWithNoTX(wdb); for (let i = 0; i < blocksPerAction * 2; i++) { - const blockAndTxs = await progressWithTX(wdb); + const blockAndTXs = await progressWithTX(wdb); if (!firstBlock) - firstBlock = blockAndTxs.block; - removeBlocks.push(blockAndTxs); + firstBlock = blockAndTXs.block; + removeBlocks.push(blockAndTXs); } assert.strictEqual(wdb.state.startHeight, firstBlock.height); @@ -487,10 +487,10 @@ describe('WalletDB ChainState', function() { firstBlock = null; for (let i = 0; i < blocksPerAction; i++) { - const blockAndTxs = await progressWithTX(wdb); + const blockAndTXs = await progressWithTX(wdb); if (!firstBlock) - firstBlock = blockAndTxs.block; - removeBlocks.push(blockAndTxs); + firstBlock = blockAndTXs.block; + removeBlocks.push(blockAndTXs); assert.strictEqual(wdb.state.startHeight, firstBlock.height); assert.strictEqual(wdb.state.startHash, firstBlock.hash); diff --git a/test/wallet-http-test.js b/test/wallet-http-test.js index ea0a3d266..873a354e1 100644 --- a/test/wallet-http-test.js +++ b/test/wallet-http-test.js @@ -1190,7 +1190,7 @@ describe('Wallet HTTP', function() { const bidValue = 1000000; const lockupValue = 5000000; - const auctionTxs = await wallet.client.post( + const auctionTXs = await wallet.client.post( `/wallet/${wallet.id}/auction`, { name: name, @@ -1204,7 +1204,7 @@ describe('Wallet HTTP', function() { let walletAuction = await wallet.getAuctionByName(name); const bidFromWallet = walletAuction.bids.find( - b => b.prevout.hash === auctionTxs.bid.hash + b => b.prevout.hash === auctionTXs.bid.hash ); assert(bidFromWallet); @@ -1216,7 +1216,7 @@ describe('Wallet HTTP', function() { assert.equal(b5.lockedConfirmed - lockConfirmedBeforeTest, lockupValue); assert.equal(b5.lockedUnconfirmed - lockUnconfirmedBeforeTest, lockupValue); - await nclient.broadcast(auctionTxs.reveal.hex); + await nclient.broadcast(auctionTXs.reveal.hex); await nodeCtx.mineBlocks(1, cbAddress); // Confirmed REVEAL with highest bid makes wallet the owner @@ -1224,7 +1224,7 @@ describe('Wallet HTTP', function() { walletAuction = await wallet.getAuctionByName(name); const revealFromWallet = walletAuction.reveals.find( - b => b.prevout.hash === auctionTxs.reveal.hash + b => b.prevout.hash === auctionTXs.reveal.hash ); assert(revealFromWallet); diff --git a/test/wallet-test.js b/test/wallet-test.js index e335971cb..d89b03438 100644 --- a/test/wallet-test.js +++ b/test/wallet-test.js @@ -3300,11 +3300,11 @@ describe('Wallet', function() { assert.strictEqual(bal.ulocked, lockup); assert.strictEqual(bal.clocked, lockup); - const auctionsTxs = await wallet.createAuctionTxs(name, value, lockup, { + const auctionsTXs = await wallet.createAuctionTXs(name, value, lockup, { hardFee: fee }); - const winningBidUnsent = auctionsTxs.bid; - unsentReveal = auctionsTxs.reveal; + const winningBidUnsent = auctionsTXs.bid; + unsentReveal = auctionsTXs.reveal; const winningBid = await wallet.sendMTX(winningBidUnsent, null); uTXCount++;