fix: add instanceof fallback for cases of duplicated module resolution #982
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
We've recently had reports of
not an Addresserror from people building on Algorand: algorandfoundation/algokit-utils-ts#399The cause seems to be two different
Addressclasses being imported from the SDK. From the user's perspective, they are using the rightalgosdk.Addressclass, but depending on how dependencies import this class it might not properly evaluate ininstanceofchecks.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
peerDependencybut even with this change the same error was still happening. This is despitenpm ls algosdkshowing 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 (
mainhas the fix, which is an override using this PR)git checkout 53d63e9c0a62b16abfc3f3803649894502ea7ec5 rm -rf node_modules && npm i bun scripts/headless_demo.tsError:
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: