From cc1809b24226474c934d84aa6417e3209edb2af9 Mon Sep 17 00:00:00 2001 From: Chris Troutner Date: Wed, 26 Nov 2025 13:15:07 -0800 Subject: [PATCH] fix(script.js): Trying to satisfy ESM, linter, and minify packager at the same time --- src/electrumx.js | 2 -- src/script.js | 13 ++++++++++--- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/electrumx.js b/src/electrumx.js index df37dfb..e6a876d 100644 --- a/src/electrumx.js +++ b/src/electrumx.js @@ -534,8 +534,6 @@ class ElectrumX { */ async txData (txid) { try { - console.log('bch-js txData() restURL: ', this.restURL) - // Handle single transaction. if (typeof txid === 'string') { const response = await this.axios.get( diff --git a/src/script.js b/src/script.js index 2f039fc..d2e7bc7 100644 --- a/src/script.js +++ b/src/script.js @@ -1,7 +1,14 @@ +import { readFileSync } from 'fs' +import { fileURLToPath } from 'url' +import { dirname, join } from 'path' import Bitcoin from '@psf/bitcoincashjs-lib' -import { createRequire } from 'module' -const require = createRequire(import.meta.url) -const opcodes = require('@psf/bitcoincash-ops') + +// Import the bitcoincash-ops library using ESM methods that don't piss off +// the standard linter. +const __dirname = dirname(fileURLToPath(import.meta.url)) +const opcodes = JSON.parse( + readFileSync(join(__dirname, '../node_modules/@psf/bitcoincash-ops/index.json'), 'utf8') +) class Script { constructor () {