@psf/bch-js 5.3.1 → 5.3.2

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@psf/bch-js",
3
- "version": "5.3.1",
3
+ "version": "5.3.2",
4
4
  "description": "The FullStack.cash JavaScript library for Bitcoin Cash and SLP Tokens",
5
5
  "author": "Chris Troutner <chris.troutner@gmail.com>",
6
6
  "contributors": [
@@ -155,11 +155,13 @@ class PsfSlpIndexer {
155
155
  * @apiName Token Stats
156
156
  * @apiGroup PSF SLP
157
157
  * @apiDescription Return list stats for a single slp token.
158
+ * The second input is a Boolean, which determins the the transaction history
159
+ * of the token is included in the returned data. The default is false.
158
160
  *
159
161
  * @apiExample Example usage:
160
162
  * (async () => {
161
163
  * try {
162
- * let tokenStats = await bchjs.PsfSlpIndexer.tokenStats('a4fb5c2da1aa064e25018a43f9165040071d9e984ba190c222a7f59053af84b2');
164
+ * let tokenStats = await bchjs.PsfSlpIndexer.tokenStats('a4fb5c2da1aa064e25018a43f9165040071d9e984ba190c222a7f59053af84b2', true);
163
165
  * console.log(tokenStats);
164
166
  * } catch(error) {
165
167
  * console.error(error)
@@ -194,13 +196,13 @@ class PsfSlpIndexer {
194
196
  *
195
197
  */
196
198
 
197
- async tokenStats (tokenId) {
199
+ async tokenStats (tokenId, withTxHistory = false) {
198
200
  try {
199
201
  // Handle single address.
200
202
  if (typeof tokenId === 'string') {
201
203
  const response = await axios.post(
202
204
  `${this.restURL}psf/slp/token`,
203
- { tokenId },
205
+ { tokenId, withTxHistory },
204
206
  this.axiosOptions
205
207
  )
206
208
  return response.data
@@ -40,13 +40,24 @@ describe('#psf-slp-indexer', () => {
40
40
  })
41
41
 
42
42
  describe('#tokenStats', () => {
43
- it('should get stats on a token', async () => {
43
+ it('should get stats on a token, without tx history', async () => {
44
44
  const tokenId =
45
45
  '38e97c5d7d3585a2cbf3f9580c82ca33985f9cb0845d4dcce220cb709f9538b0'
46
46
 
47
47
  const result = await bchjs.PsfSlpIndexer.tokenStats(tokenId)
48
48
  // console.log('result: ', result)
49
49
 
50
+ assert.property(result.tokenData, 'documentUri')
51
+ assert.property(result.tokenData, 'totalBurned')
52
+ })
53
+
54
+ it('should get stats on a token, with tx history', async () => {
55
+ const tokenId =
56
+ '38e97c5d7d3585a2cbf3f9580c82ca33985f9cb0845d4dcce220cb709f9538b0'
57
+
58
+ const result = await bchjs.PsfSlpIndexer.tokenStats(tokenId, true)
59
+ // console.log('result: ', result)
60
+
50
61
  assert.property(result.tokenData, 'documentUri')
51
62
  assert.property(result.tokenData, 'txs')
52
63
  assert.property(result.tokenData, 'totalBurned')
@@ -5,8 +5,8 @@
5
5
  const assert = require('chai').assert
6
6
 
7
7
  const BCHJS = require('../../../../src/bch-js')
8
- // const bchjs = new BCHJS()
9
- const bchjs = new BCHJS({ restURL: 'http://192.168.2.129:3000/v5/' })
8
+ const bchjs = new BCHJS()
9
+ // const bchjs = new BCHJS({ restURL: 'http://192.168.2.129:3000/v5/' })
10
10
 
11
11
  describe('#UTXO', () => {
12
12
  beforeEach(async () => {