mirror of
https://github.com/Permissionless-Software-Foundation/bch-js.git
synced 2026-09-21 16:51:59 -07:00
fix(getTokenData): Adding ability to retrieve tx history
This commit is contained in:
+1
-1
@@ -12,7 +12,7 @@
|
|||||||
"test": "nyc mocha --trace-warnings --unhandled-rejections=strict --timeout 30000 test/unit/",
|
"test": "nyc mocha --trace-warnings --unhandled-rejections=strict --timeout 30000 test/unit/",
|
||||||
"test:integration": "npm run test:integration:bchn",
|
"test:integration": "npm run test:integration:bchn",
|
||||||
"test:integration:nft": "export RESTURL=https://bchn.fullstack.cash/v5/ && export IS_USING_FREE_TIER=true && mocha --timeout 30000 -g '#nft1' test/integration/chains/bchn/slp.js",
|
"test:integration:nft": "export RESTURL=https://bchn.fullstack.cash/v5/ && export IS_USING_FREE_TIER=true && mocha --timeout 30000 -g '#nft1' test/integration/chains/bchn/slp.js",
|
||||||
"test:integration:abc": "export RESTURL=https://abc.fullstack.cash/v5/ && export IS_USING_FREE_TIER=true && mocha --timeout 30000 test/integration/ && mocha --timeout 30000 test/integration/chains/abc/",
|
"test:integration:abc": "export RESTURL=https://abc.fullstack.cash/v5/ && mocha --timeout 30000 test/integration/ && mocha --timeout 30000 test/integration/chains/abc/",
|
||||||
"test:integration:bchn": "export RESTURL=https://bchn.fullstack.cash/v5/ && export IS_USING_FREE_TIER=true && mocha --timeout 30000 test/integration/ && mocha --timeout 30000 test/integration/chains/bchn/",
|
"test:integration:bchn": "export RESTURL=https://bchn.fullstack.cash/v5/ && export IS_USING_FREE_TIER=true && mocha --timeout 30000 test/integration/ && mocha --timeout 30000 test/integration/chains/bchn/",
|
||||||
"test:integration:bchn:slpdb": "export TESTSLP=1 && export RESTURL=https://bchn.fullstack.cash/v5/ && export IS_USING_FREE_TIER=true && mocha --timeout 30000 test/integration/ && mocha --timeout 30000 test/integration/chains/bchn/",
|
"test:integration:bchn:slpdb": "export TESTSLP=1 && export RESTURL=https://bchn.fullstack.cash/v5/ && export IS_USING_FREE_TIER=true && mocha --timeout 30000 test/integration/ && mocha --timeout 30000 test/integration/chains/bchn/",
|
||||||
"test:integration:local:abc": "export RESTURL=http://localhost:3000/v5/ && mocha --timeout 30000 test/integration && mocha --timeout 30000 test/integration/chains/abc/",
|
"test:integration:local:abc": "export RESTURL=http://localhost:3000/v5/ && mocha --timeout 30000 test/integration && mocha --timeout 30000 test/integration/chains/abc/",
|
||||||
|
|||||||
@@ -194,6 +194,7 @@ class PsfSlpIndexer {
|
|||||||
* }
|
* }
|
||||||
* }
|
* }
|
||||||
*
|
*
|
||||||
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
async tokenStats (tokenId, withTxHistory = false) {
|
async tokenStats (tokenId, withTxHistory = false) {
|
||||||
@@ -420,7 +421,7 @@ class PsfSlpIndexer {
|
|||||||
* }
|
* }
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
async getTokenData (tokenId) {
|
async getTokenData (tokenId, withTxHistory = false) {
|
||||||
try {
|
try {
|
||||||
const url = `${this.restURL}psf/slp/token/data`
|
const url = `${this.restURL}psf/slp/token/data`
|
||||||
// console.log(`url: ${url}`)
|
// console.log(`url: ${url}`)
|
||||||
@@ -430,7 +431,7 @@ class PsfSlpIndexer {
|
|||||||
const response = await axios.post(
|
const response = await axios.post(
|
||||||
// 'https://bchn.fullstack.cash/v5/psf/slp/token/data/',
|
// 'https://bchn.fullstack.cash/v5/psf/slp/token/data/',
|
||||||
url,
|
url,
|
||||||
{ tokenId },
|
{ tokenId, withTxHistory },
|
||||||
this.axiosOptions
|
this.axiosOptions
|
||||||
)
|
)
|
||||||
return response.data
|
return response.data
|
||||||
|
|||||||
@@ -145,6 +145,15 @@ describe('#psf-slp-indexer', () => {
|
|||||||
assert.isString(result.immutableData)
|
assert.isString(result.immutableData)
|
||||||
assert.isString(result.mutableData)
|
assert.isString(result.mutableData)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it('should get token data with a transaction history', async () => {
|
||||||
|
const tokenId = '43eddfb11c9941edffb8c8815574bb0a43969a7b1de39ad14cd043eaa24fd38d'
|
||||||
|
|
||||||
|
const result = await bchjs.PsfSlpIndexer.getTokenData(tokenId, true)
|
||||||
|
// console.log('result: ', result)
|
||||||
|
|
||||||
|
assert.isArray(result.genesisData.txs)
|
||||||
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user