@psf/bch-js 7.1.8 → 7.1.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +2 -2
- package/src/psf-slp-indexer.js +18 -0
- package/test/integration/price.js +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@psf/bch-js",
|
|
3
|
-
"version": "7.1.
|
|
3
|
+
"version": "7.1.10",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "A JavaScript library for working with Bitcoin Cash and SLP Tokens",
|
|
6
6
|
"author": "Chris Troutner <chris.troutner@gmail.com>",
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
"slp-mdm": "0.0.7",
|
|
53
53
|
"slp-parser": "0.0.4",
|
|
54
54
|
"wif": "2.0.6",
|
|
55
|
-
"x402-bch-axios": "2.
|
|
55
|
+
"x402-bch-axios": "2.2.1"
|
|
56
56
|
},
|
|
57
57
|
"devDependencies": {
|
|
58
58
|
"apidoc": "1.2.0",
|
package/src/psf-slp-indexer.js
CHANGED
|
@@ -12,6 +12,7 @@ import axios from 'axios'
|
|
|
12
12
|
// Local libraries
|
|
13
13
|
import RawTransaction from './raw-transactions.js'
|
|
14
14
|
import SlpUtils from './slp/utils.js'
|
|
15
|
+
import Blockchain from './blockchain.js'
|
|
15
16
|
|
|
16
17
|
// let _this
|
|
17
18
|
|
|
@@ -31,6 +32,7 @@ class PsfSlpIndexer {
|
|
|
31
32
|
// Encapsulate dependencies
|
|
32
33
|
this.rawTransaction = new RawTransaction(config)
|
|
33
34
|
this.slpUtils = new SlpUtils(config)
|
|
35
|
+
this.blockchain = new Blockchain(config)
|
|
34
36
|
}
|
|
35
37
|
|
|
36
38
|
/**
|
|
@@ -317,6 +319,22 @@ class PsfSlpIndexer {
|
|
|
317
319
|
const txDetails = await this.rawTransaction.getTxData(txid)
|
|
318
320
|
// console.log(`txDetails: ${JSON.stringify(txDetails, null, 2)}`)
|
|
319
321
|
|
|
322
|
+
// Add blockheight, height, time, and blocktime to the txDetails object.
|
|
323
|
+
if (txDetails.height === null) {
|
|
324
|
+
// Get current block height and increment by 1
|
|
325
|
+
const currentBlockHeight = await this.blockchain.getBlockCount()
|
|
326
|
+
const estimatedHeight = currentBlockHeight + 1
|
|
327
|
+
|
|
328
|
+
// Set height and blockheight
|
|
329
|
+
txDetails.height = estimatedHeight
|
|
330
|
+
txDetails.blockheight = estimatedHeight
|
|
331
|
+
|
|
332
|
+
// Set time and blocktime to current unix timestamp
|
|
333
|
+
const currentTime = Math.floor(Date.now() / 1000)
|
|
334
|
+
txDetails.time = currentTime
|
|
335
|
+
txDetails.blocktime = currentTime
|
|
336
|
+
}
|
|
337
|
+
|
|
320
338
|
if (isInBlacklist) {
|
|
321
339
|
txDetails.isValidSlp = null
|
|
322
340
|
} else {
|
|
@@ -18,7 +18,7 @@ describe('#price', () => {
|
|
|
18
18
|
})
|
|
19
19
|
|
|
20
20
|
describe('#getPsffppPrice', () => {
|
|
21
|
-
it('should get the price
|
|
21
|
+
it('should get the price to write 1MB to the PSFFPP', async () => {
|
|
22
22
|
const result = await bchjs.Price.getPsffppPrice()
|
|
23
23
|
// console.log(result)
|
|
24
24
|
|