Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 1 addition & 6 deletions .changeset/ripe-heads-stop.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
'@xchainjs/xchain-ethereum': patch
'@xchainjs/xchain-litecoin': patch
'@xchainjs/xchain-bitcoin': patch
'xchainjs-estimate-swap': patch
'@xchainjs/xchain-cosmos': patch
'@xchainjs/xchain-kujira': patch
'@xchainjs/xchain-wallet': patch
Expand All @@ -17,16 +16,12 @@
'@xchainjs/xchain-util': patch
'@xchainjs/xchain-bsc': patch
'@xchainjs/xchain-evm': patch
'xchainjs-liquidity': patch
'xchainjs-check-tx': patch
'xchainjs-loans': patch
'txJammer': patch
---

Fix ESM (ECMAScript Module) compatibility issues

- Update bignumber.js to 9.1.2 for proper ESM support
- Change bitcore-lib-cash imports from namespace to default imports for ESM compatibility
- Change bitcore-lib-cash imports from namespace to default imports for ESM compatibility
- Change @dashevo/dashcore-lib imports from namespace to default imports for ESM compatibility
Comment on lines +24 to 25
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Verification agent

🧩 Analysis chain

Default import for bitcore-lib-cash may be unsafe.

If bitcore-lib-cash is CommonJS, default imports require TS esModuleInterop/syntheticDefaultImports or an actual ESM default export. Please confirm the library/version and tsconfig flags.


🌐 Web query:

Does "bitcore-lib-cash" provide an ESM build or a default export usable via `import bitcore from 'bitcore-lib-cash'`?

💡 Result:

No. bitcore-lib-cash is published as CommonJS (package.json has "main":"index.js" and no "module"/ESM export) and its type defs use export = (CommonJS style). Import with require() or a named/namespace import (e.g. import * as bitcore from 'bitcore-lib-cash') rather than a native default ESM import. [1][2]

Sources:
[1] package.json from the published package (shows "main": "index.js" and no "module" field). [unpkg]. (app.unpkg.com)
[2] DefinitelyTyped / @types/bitcore-lib-cash indicates CJS-style export (= export =). (npmjs.com)

Citations:


Don't switch bitcore-lib-cash to a default ESM import — it's CommonJS

bitcore-lib-cash is published as CommonJS (package.json only has "main" and types use export =), so import bitcore from 'bitcore-lib-cash' is unsafe. Revert/update the changeset entry (.changeset/ripe-heads-stop.md lines 24–25) and either keep the namespace import (import * as bitcore from 'bitcore-lib-cash'), enable esModuleInterop/allowSyntheticDefaultImports in tsconfig, or only switch once the package provides an ESM default export. Confirm which approach you choose.

🤖 Prompt for AI Agents
In .changeset/ripe-heads-stop.md around lines 24–25, revert or update the
changeset entry that switched bitcore-lib-cash to a default ESM import because
bitcore-lib-cash is CommonJS; restore the namespace form (or remove the line) so
the changeset reflects using import * as bitcore from 'bitcore-lib-cash', or
explicitly state that the project will enable
esModuleInterop/allowSyntheticDefaultImports in tsconfig if you want
default-style imports; update the file to reflect which approach you choose and
confirm that the changeset now matches the chosen import strategy.

- Add .js extensions to coinselect/accumulative imports for ESM
- Add .js extensions to cosmjs-types imports for ESM
Comment on lines 26 to 27
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Verification agent

🧩 Analysis chain

Audit repo for missing .js extensions on ESM-only paths.

Ensure all coinselect/accumulative and cosmjs-types imports include .js where required.

Run:


🏁 Script executed:

#!/bin/bash
# Find potential imports missing ".js" for the noted modules
rg -nP --type=ts --type=tsx --type=js --type=mjs $'from\\s+[\'"](coinselect/accumulative|cosmjs-types[^\'"]*)[\'"]' -S

Length of output: 27


🏁 Script executed:

#!/bin/bash
set -uo pipefail

echo "Searching repository for imports/requires/dynamic-imports referencing coinselect/accumulative or cosmjs-types (looking for missing .js extensions)..."

# Search common source file extensions (ts, tsx, js, mjs, jsx)
rg -nP -S -g '**/*.{ts,tsx,js,mjs,jsx}' "from\s+['\"][^'\"]*(?:coinselect/accumulative|cosmjs-types[^'\"]*)['\"]" || true
rg -nP -S -g '**/*.{ts,tsx,js,mjs,jsx}' "require\(['\"][^'\"]*(?:coinselect/accumulative|cosmjs-types[^'\"]*)['\"]\)" || true
rg -nP -S -g '**/*.{ts,tsx,js,mjs,jsx}' "import\(['\"][^'\"]*(?:coinselect/accumulative|cosmjs-types[^'\"]*)['\"]\)" || true

echo "Search complete."

Length of output: 1037


Add missing .js extension to a cosmjs-types import

  • packages/xchain-cosmos/e2e/cosmos-client.e2e.ts:14 — change
    import { TxRaw } from 'cosmjs-types/cosmos/tx/v1beta1/tx'
    to
    import { TxRaw } from 'cosmjs-types/cosmos/tx/v1beta1/tx.js'
  • No occurrences of coinselect/accumulative found.
🤖 Prompt for AI Agents
In .changeset/ripe-heads-stop.md around lines 26 to 27: update the note to
reflect that the import in packages/xchain-cosmos/__e2e__/cosmos-client.e2e.ts
(line ~14) must use the ESM .js extension by changing the import of TxRaw from
'cosmjs-types/cosmos/tx/v1beta1/tx' to 'cosmjs-types/cosmos/tx/v1beta1/tx.js';
verify the file compiles under ESM and remove any mention of
coinselect/accumulative since there are no occurrences.

Expand Down
2 changes: 1 addition & 1 deletion examples/check-tx/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"@xchainjs/xchain-thorchain-query": "workspace:*",
"@xchainjs/xchain-thornode": "workspace:*",
"@xchainjs/xchain-util": "workspace:*",
"axios": "1.8.4",
"axios": "1.12.1",
"axios-retry": "^3.2.5",
"bignumber.js": "^9.1.2",
"rimraf": "~3.0.2"
Expand Down
2 changes: 1 addition & 1 deletion examples/do-swap/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"@xchainjs/xchain-utxo": "workspace:*",
"@xchainjs/xchain-utxo-providers": "workspace:*",
"@xchainjs/xchain-wallet": "workspace:*",
"axios": "1.8.4",
"axios": "1.12.1",
"axios-retry": "^3.3.1",
"bech32-buffer": "^0.2.0",
"bitcoinjs-lib": "^6.1.7",
Expand Down
2 changes: 1 addition & 1 deletion examples/estimate-swap/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"@xchainjs/xchain-thorchain-query": "workspace:*",
"@xchainjs/xchain-thornode": "workspace:*",
"@xchainjs/xchain-util": "workspace:*",
"axios": "1.8.4",
"axios": "1.12.1",
"axios-retry": "^3.2.5",
"bignumber.js": "^9.1.2",
"rimraf": "~3.0.2"
Expand Down
2 changes: 1 addition & 1 deletion examples/liquidity/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"@xchainjs/xchain-thorchain-query": "workspace:*",
"@xchainjs/xchain-thornode": "workspace:*",
"@xchainjs/xchain-util": "workspace:*",
"axios": "1.8.4",
"axios": "1.12.1",
"axios-retry": "^3.2.5",
"bignumber.js": "^9.1.2",
"rimraf": "~3.0.2"
Expand Down
2 changes: 1 addition & 1 deletion examples/wallet/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"@xchainjs/xchain-thorchain": "workspace:*",
"@xchainjs/xchain-util": "workspace:*",
"@xchainjs/xchain-wallet": "workspace:*",
"axios": "1.8.4",
"axios": "1.12.1",
"axios-retry": "^3.3.1",
"bech32-buffer": "^0.2.0",
"bitcoinjs-lib": "^6.1.7",
Expand Down
2 changes: 1 addition & 1 deletion packages/xchain-cosmos/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
"@xchainjs/xchain-cosmos-sdk": "workspace:*",
"@xchainjs/xchain-crypto": "workspace:*",
"@xchainjs/xchain-util": "workspace:*",
"axios": "1.8.4",
"axios": "1.12.1",
"bignumber.js": "^9.1.2",
"cosmjs-types": "0.9.0",
"protobufjs": "6.11.4"
Expand Down
2 changes: 1 addition & 1 deletion packages/xchain-mayachain-query/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"@xchainjs/xchain-mayamidgard-query": "workspace:*",
"@xchainjs/xchain-mayanode": "workspace:*",
"@xchainjs/xchain-util": "workspace:*",
"axios": "1.8.4",
"axios": "1.12.1",
"axios-retry": "3.2.5",
"bignumber.js": "^9.1.2"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/xchain-mayachain/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
"@xchainjs/xchain-cosmos-sdk": "workspace:*",
"@xchainjs/xchain-crypto": "workspace:*",
"@xchainjs/xchain-util": "workspace:*",
"axios": "1.8.4",
"axios": "1.12.1",
"bignumber.js": "^9.1.2",
"cosmjs-types": "0.9.0",
"protobufjs": "6.11.4"
Expand Down
2 changes: 1 addition & 1 deletion packages/xchain-thorchain-query/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"@xchainjs/xchain-midgard-query": "workspace:*",
"@xchainjs/xchain-thornode": "workspace:*",
"@xchainjs/xchain-util": "workspace:*",
"axios": "1.8.4",
"axios": "1.12.1",
"axios-retry": "3.2.5",
"bignumber.js": "^9.1.2"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/xchain-thorchain/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
"@xchainjs/xchain-cosmos-sdk": "workspace:*",
"@xchainjs/xchain-crypto": "workspace:*",
"@xchainjs/xchain-util": "workspace:*",
"axios": "1.8.4",
"axios": "1.12.1",
"bignumber.js": "^9.1.2",
"cosmjs-types": "0.9.0",
"protobufjs": "6.11.4"
Expand Down
47 changes: 29 additions & 18 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4020,7 +4020,7 @@ __metadata:
"@xchainjs/xchain-cosmos-sdk": "workspace:*"
"@xchainjs/xchain-crypto": "workspace:*"
"@xchainjs/xchain-util": "workspace:*"
axios: "npm:1.8.4"
axios: "npm:1.12.1"
bignumber.js: "npm:^9.1.2"
cosmjs-types: "npm:0.9.0"
protobufjs: "npm:6.11.4"
Expand Down Expand Up @@ -4202,7 +4202,7 @@ __metadata:
"@xchainjs/xchain-mayamidgard-query": "workspace:*"
"@xchainjs/xchain-mayanode": "workspace:*"
"@xchainjs/xchain-util": "workspace:*"
axios: "npm:1.8.4"
axios: "npm:1.12.1"
axios-mock-adapter: "npm:2.1.0"
axios-retry: "npm:3.2.5"
bignumber.js: "npm:^9.1.2"
Expand All @@ -4225,7 +4225,7 @@ __metadata:
"@xchainjs/xchain-cosmos-sdk": "workspace:*"
"@xchainjs/xchain-crypto": "workspace:*"
"@xchainjs/xchain-util": "workspace:*"
axios: "npm:1.8.4"
axios: "npm:1.12.1"
bignumber.js: "npm:^9.1.2"
cosmjs-types: "npm:0.9.0"
protobufjs: "npm:6.11.4"
Expand Down Expand Up @@ -4370,7 +4370,7 @@ __metadata:
"@xchainjs/xchain-midgard-query": "workspace:*"
"@xchainjs/xchain-thornode": "workspace:*"
"@xchainjs/xchain-util": "workspace:*"
axios: "npm:1.8.4"
axios: "npm:1.12.1"
axios-mock-adapter: "npm:2.1.0"
axios-retry: "npm:3.2.5"
bignumber.js: "npm:^9.1.2"
Expand All @@ -4396,7 +4396,7 @@ __metadata:
"@xchainjs/xchain-cosmos-sdk": "workspace:*"
"@xchainjs/xchain-crypto": "workspace:*"
"@xchainjs/xchain-util": "workspace:*"
axios: "npm:1.8.4"
axios: "npm:1.12.1"
bignumber.js: "npm:^9.1.2"
cosmjs-types: "npm:0.9.0"
protobufjs: "npm:6.11.4"
Expand Down Expand Up @@ -4891,6 +4891,17 @@ __metadata:
languageName: node
linkType: hard

"axios@npm:1.12.1":
version: 1.12.1
resolution: "axios@npm:1.12.1"
dependencies:
follow-redirects: "npm:^1.15.6"
form-data: "npm:^4.0.4"
proxy-from-env: "npm:^1.1.0"
checksum: 10c0/eda4dff56c02d13b950fd9487b678ac197ce5f21dfc98df73632df29e45d8dd24602a34e8d9b6e016d84a41ef7fd7fc4a7618060a72cc536b91cda1eaa9cd907
languageName: node
linkType: hard

"axios@npm:1.7.7":
version: 1.7.7
resolution: "axios@npm:1.7.7"
Expand All @@ -4902,25 +4913,25 @@ __metadata:
languageName: node
linkType: hard

"axios@npm:1.8.4, axios@npm:^1.8.4":
version: 1.8.4
resolution: "axios@npm:1.8.4"
"axios@npm:1.9.0, axios@npm:^1.7.9":
version: 1.9.0
resolution: "axios@npm:1.9.0"
dependencies:
follow-redirects: "npm:^1.15.6"
form-data: "npm:^4.0.0"
proxy-from-env: "npm:^1.1.0"
checksum: 10c0/450993c2ba975ffccaf0d480b68839a3b2435a5469a71fa2fb0b8a55cdb2c2ae47e609360b9c1e2b2534b73dfd69e2733a1cf9f8215bee0bcd729b72f801b0ce
checksum: 10c0/9371a56886c2e43e4ff5647b5c2c3c046ed0a3d13482ef1d0135b994a628c41fbad459796f101c655e62f0c161d03883454474d2e435b2e021b1924d9f24994c
languageName: node
linkType: hard

"axios@npm:1.9.0, axios@npm:^1.7.9":
version: 1.9.0
resolution: "axios@npm:1.9.0"
"axios@npm:^1.8.4":
version: 1.8.4
resolution: "axios@npm:1.8.4"
dependencies:
follow-redirects: "npm:^1.15.6"
form-data: "npm:^4.0.0"
proxy-from-env: "npm:^1.1.0"
checksum: 10c0/9371a56886c2e43e4ff5647b5c2c3c046ed0a3d13482ef1d0135b994a628c41fbad459796f101c655e62f0c161d03883454474d2e435b2e021b1924d9f24994c
checksum: 10c0/450993c2ba975ffccaf0d480b68839a3b2435a5469a71fa2fb0b8a55cdb2c2ae47e609360b9c1e2b2534b73dfd69e2733a1cf9f8215bee0bcd729b72f801b0ce
languageName: node
linkType: hard

Expand Down Expand Up @@ -13337,7 +13348,7 @@ __metadata:
"@xchainjs/xchain-thorchain-query": "workspace:*"
"@xchainjs/xchain-thornode": "workspace:*"
"@xchainjs/xchain-util": "workspace:*"
axios: "npm:1.8.4"
axios: "npm:1.12.1"
axios-retry: "npm:^3.2.5"
bignumber.js: "npm:^9.1.2"
rimraf: "npm:~3.0.2"
Expand Down Expand Up @@ -13375,7 +13386,7 @@ __metadata:
"@xchainjs/xchain-utxo": "workspace:*"
"@xchainjs/xchain-utxo-providers": "workspace:*"
"@xchainjs/xchain-wallet": "workspace:*"
axios: "npm:1.8.4"
axios: "npm:1.12.1"
axios-retry: "npm:^3.3.1"
bech32-buffer: "npm:^0.2.0"
bitcoinjs-lib: "npm:^6.1.7"
Expand All @@ -13398,7 +13409,7 @@ __metadata:
"@xchainjs/xchain-thorchain-query": "workspace:*"
"@xchainjs/xchain-thornode": "workspace:*"
"@xchainjs/xchain-util": "workspace:*"
axios: "npm:1.8.4"
axios: "npm:1.12.1"
axios-retry: "npm:^3.2.5"
bignumber.js: "npm:^9.1.2"
rimraf: "npm:~3.0.2"
Expand All @@ -13420,7 +13431,7 @@ __metadata:
"@xchainjs/xchain-thorchain-query": "workspace:*"
"@xchainjs/xchain-thornode": "workspace:*"
"@xchainjs/xchain-util": "workspace:*"
axios: "npm:1.8.4"
axios: "npm:1.12.1"
axios-retry: "npm:^3.2.5"
bignumber.js: "npm:^9.1.2"
rimraf: "npm:~3.0.2"
Expand Down Expand Up @@ -13542,7 +13553,7 @@ __metadata:
"@xchainjs/xchain-thorchain": "workspace:*"
"@xchainjs/xchain-util": "workspace:*"
"@xchainjs/xchain-wallet": "workspace:*"
axios: "npm:1.8.4"
axios: "npm:1.12.1"
axios-retry: "npm:^3.3.1"
bech32-buffer: "npm:^0.2.0"
bitcoinjs-lib: "npm:^6.1.7"
Expand Down
Loading