mirror of
https://github.com/Permissionless-Software-Foundation/bch-js.git
synced 2026-09-21 16:51:59 -07:00
feat(REST URL): removing default REST URL anti-pattern. Error thrown if URL is not specified at startup
This commit is contained in:
+1
-1
@@ -10,7 +10,7 @@
|
|||||||
],
|
],
|
||||||
"main": "src/bch-js.js",
|
"main": "src/bch-js.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "c8 mocha --trace-warnings --unhandled-rejections=strict --timeout 30000 test/unit/",
|
"test": "export RESTURL=http://localhost:5942/v6/ && c8 mocha --trace-warnings --unhandled-rejections=strict --timeout 30000 test/unit/",
|
||||||
"test:integration": "npm run test:integration:local:noauth",
|
"test:integration": "npm run test:integration:local:noauth",
|
||||||
"test:integration:nft": "export RESTURL=https://bchn.fullstack.cash/v6/ && export IS_USING_FREE_TIER=true && mocha --timeout 30000 -g '#nft1' test/integration/slp.js",
|
"test:integration:nft": "export RESTURL=https://bchn.fullstack.cash/v6/ && export IS_USING_FREE_TIER=true && mocha --timeout 30000 -g '#nft1' test/integration/slp.js",
|
||||||
"test:integration:bchn": "export RESTURL=https://bchn.fullstack.cash/v6/ && export IS_USING_FREE_TIER=true && mocha --timeout 30000 test/integration/",
|
"test:integration:bchn": "export RESTURL=https://bchn.fullstack.cash/v6/ && export IS_USING_FREE_TIER=true && mocha --timeout 30000 test/integration/",
|
||||||
|
|||||||
+5
-2
@@ -45,7 +45,6 @@ import Ecash from './ecash.js'
|
|||||||
// Indexers
|
// Indexers
|
||||||
import Electrumx from './electrumx.js'
|
import Electrumx from './electrumx.js'
|
||||||
import PsfSlpIndexer from './psf-slp-indexer.js'
|
import PsfSlpIndexer from './psf-slp-indexer.js'
|
||||||
const DEFAULT_REST_API = 'https://api.fullstack.cash/v6/'
|
|
||||||
|
|
||||||
class BCHJS {
|
class BCHJS {
|
||||||
constructor (config) {
|
constructor (config) {
|
||||||
@@ -54,7 +53,11 @@ class BCHJS {
|
|||||||
this.restURL = config.restURL
|
this.restURL = config.restURL
|
||||||
} else if (process.env.RESTURL && process.env.RESTURL !== '') {
|
} else if (process.env.RESTURL && process.env.RESTURL !== '') {
|
||||||
this.restURL = process.env.RESTURL
|
this.restURL = process.env.RESTURL
|
||||||
} else this.restURL = DEFAULT_REST_API
|
} else {
|
||||||
|
throw new Error(
|
||||||
|
'REST API URL is required. Provide config.restURL or set the RESTURL environment variable.'
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
// Retrieve the Bearer token for simple token authentication.
|
// Retrieve the Bearer token for simple token authentication.
|
||||||
this.bearerToken = '' // default value.
|
this.bearerToken = '' // default value.
|
||||||
|
|||||||
@@ -534,6 +534,8 @@ class ElectrumX {
|
|||||||
*/
|
*/
|
||||||
async txData (txid) {
|
async txData (txid) {
|
||||||
try {
|
try {
|
||||||
|
console.log('bch-js txData() restURL: ', this.restURL)
|
||||||
|
|
||||||
// Handle single transaction.
|
// Handle single transaction.
|
||||||
if (typeof txid === 'string') {
|
if (typeof txid === 'string') {
|
||||||
const response = await this.axios.get(
|
const response = await this.axios.get(
|
||||||
|
|||||||
Reference in New Issue
Block a user