Skip to content

fix: add instanceof fallback for cases of duplicated module resolution #982

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from

Conversation

joe-p
Copy link
Contributor

@joe-p joe-p commented May 27, 2025

We've recently had reports of not an Address error from people building on Algorand: algorandfoundation/algokit-utils-ts#399

The cause seems to be two different Address classes being imported from the SDK. From the user's perspective, they are using the right algosdk.Address class, but depending on how dependencies import this class it might not properly evaluate in instanceof checks.

I've personally encountered this when using the tinyman sdk. The fix would seemingly be to have every library that uses algosdk to list it as a peerDependency but even with this change the same error was still happening. This is despite npm ls algosdk showing every module being dedpued. Perhaps it has to do with how it's imported.

Keeping this PR as draft while we discuss the best way to properly fix this.

To reproduce, clone this repo: https://github.com/joe-p/arc84_poc and run the following commands (main has the fix, which is an override using this PR)

git checkout 53d63e9c0a62b16abfc3f3803649894502ea7ec5
rm -rf node_modules && npm i
bun scripts/headless_demo.ts

Error:

error: Not an address: LAIXFJCAPMTKK5ZYQVWJE7F5P73PJ24QMJE774DHTVGRVH4JAS4RHD6VGQ
    at ensureAddress (/Users/joe/git/joe-p/arc11550_poc/projects/demo/node_modules/algosdk/dist/esm/transaction.js:45:11)
    at new Transaction (/Users/joe/git/joe-p/arc11550_poc/projects/demo/node_modules/algosdk/dist/esm/transaction.js:135:23)
    at makeApplicationCallTxnFromObject (/Users/joe/git/joe-p/arc11550_poc/projects/demo/node_modules/algosdk/dist/esm/makeTxn.js:209:12)
    at addMethodCall (/Users/joe/git/joe-p/arc11550_poc/projects/demo/node_modules/algosdk/dist/esm/composer.js:260:18)
    at <anonymous> (/Users/joe/git/joe-p/arc11550_poc/projects/demo/node_modules/@algorandfoundation/algokit-utils/types/composer.mjs:1045:23)
    at commonTxnBuildStep (/Users/joe/git/joe-p/arc11550_poc/projects/demo/node_modules/@algorandfoundation/algokit-utils/types/composer.mjs:893:21)
    at <anonymous> (/Users/joe/git/joe-p/arc11550_poc/projects/demo/node_modules/@algorandfoundation/algokit-utils/types/composer.mjs:1044:29)

npm ls output:

[email protected] /Users/joe/git/joe-p/arc11550_poc/projects/demo
├─┬ @algorandfoundation/[email protected]
│ └── [email protected] deduped
├─┬ @algorandfoundation/[email protected]
│ └── [email protected] deduped
├─┬ @blockshake/[email protected]
│ └── [email protected] deduped
├─┬ @perawallet/[email protected]
│ └── [email protected] deduped
├─┬ @tinymanorg/[email protected]
│ └── [email protected] deduped
├─┬ @txnlab/[email protected]
│ └── [email protected] deduped
├─┬ @txnlab/[email protected]
│ └── [email protected] deduped
└── [email protected]

@joe-p
Copy link
Contributor Author

joe-p commented Jun 23, 2025

Closed in favor of #990

@joe-p joe-p closed this Jun 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant