mirror of
https://github.com/Permissionless-Software-Foundation/psf-bch-api-base.git
synced 2026-09-21 16:52:00 -07:00
fix(startup): Ensuring REST URL is passed correctly to bch-js on startup
This commit is contained in:
@@ -4,8 +4,9 @@
|
||||
|
||||
import wlogger from '../../../adapters/wlogger.js'
|
||||
import BCHJS from '@psf/bch-js'
|
||||
import config from '../../../config/index.js'
|
||||
|
||||
const bchjs = new BCHJS()
|
||||
const bchjs = new BCHJS({ restURL: config.restURL })
|
||||
|
||||
class FulcrumRESTController {
|
||||
constructor (localConfig = {}) {
|
||||
|
||||
@@ -4,8 +4,9 @@
|
||||
|
||||
import wlogger from '../../../adapters/wlogger.js'
|
||||
import BCHJS from '@psf/bch-js'
|
||||
import config from '../../../config/index.js'
|
||||
|
||||
const bchjs = new BCHJS()
|
||||
const bchjs = new BCHJS({ restURL: config.restURL })
|
||||
|
||||
class SlpRESTController {
|
||||
constructor (localConfig = {}) {
|
||||
@@ -201,6 +202,7 @@ class SlpRESTController {
|
||||
const result = await this.slpUseCases.getTokenData({ tokenId, withTxHistory })
|
||||
return res.status(200).json(result)
|
||||
} catch (err) {
|
||||
console.log('Error in /v6/slp/token/data getTokenData(): ', err)
|
||||
return this.handleError(err, res)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,8 +4,9 @@
|
||||
|
||||
import wlogger from '../adapters/wlogger.js'
|
||||
import BCHJS from '@psf/bch-js'
|
||||
import config from '../config/index.js'
|
||||
|
||||
const bchjs = new BCHJS()
|
||||
const bchjs = new BCHJS({ restURL: config.restURL })
|
||||
|
||||
class FulcrumUseCases {
|
||||
constructor (localConfig = {}) {
|
||||
@@ -53,7 +54,14 @@ class FulcrumUseCases {
|
||||
}
|
||||
|
||||
async getTransactionDetails ({ txid }) {
|
||||
return this.fulcrum.get(`electrumx/tx/data/${txid}`)
|
||||
try {
|
||||
const response = await this.fulcrum.get(`electrumx/tx/data/${txid}`)
|
||||
console.log(`getTransactionDetails() TXID ${txid}: ${JSON.stringify(response, null, 2)}`)
|
||||
return response
|
||||
} catch (err) {
|
||||
wlogger.error('Error in FulcrumUseCases.getTransactionDetails()', err)
|
||||
throw err
|
||||
}
|
||||
}
|
||||
|
||||
async getTransactionDetailsBulk ({ txids, verbose }) {
|
||||
|
||||
@@ -9,7 +9,7 @@ import SlpTokenMedia from 'slp-token-media'
|
||||
import axios from 'axios'
|
||||
import config from '../config/index.js'
|
||||
|
||||
const bchjs = new BCHJS()
|
||||
const bchjs = new BCHJS({ restURL: config.restURL })
|
||||
|
||||
class SlpUseCases {
|
||||
constructor (localConfig = {}) {
|
||||
@@ -259,6 +259,7 @@ class SlpUseCases {
|
||||
|
||||
return mutableCid
|
||||
} catch (err) {
|
||||
console.log('Error in SlpUseCases.getMutableCid()', err)
|
||||
wlogger.error('Error in SlpUseCases.getMutableCid()', err)
|
||||
return false
|
||||
}
|
||||
@@ -271,7 +272,9 @@ class SlpUseCases {
|
||||
}
|
||||
|
||||
// Get transaction data
|
||||
console.log('Decoding OP_RETURN for TXID: ', txid)
|
||||
const txData = await this.bchjs.Electrumx.txData(txid)
|
||||
console.log(`TXID ${txid}: ${JSON.stringify(txData, null, 2)}`)
|
||||
let data = false
|
||||
|
||||
// Map the vout of the transaction in search of an OP_RETURN
|
||||
@@ -291,6 +294,7 @@ class SlpUseCases {
|
||||
|
||||
return data
|
||||
} catch (error) {
|
||||
console.log('Error in SlpUseCases.decodeOpReturn()', error)
|
||||
wlogger.error('Error in SlpUseCases.decodeOpReturn()', error)
|
||||
throw error
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user