Make arweave-js more robust against axios default changes (such as from erdjs) #97
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.
Main change is in
src/common/transactions.ts
But I had problems getting npm 7 to compile, so I had to change the unmaintained BabelMinify to TerserPlugin
npm test passes with all 46 tests suceeding
The challenge is using arweave along with elrond's erdjs. While there is nothing "wrong" with arweave-js, there is a simple tweak that can be done to prevent errors.
erdjs introduces a changes in 2 files to axios which causes arweave-js to fail
https://github.com/ElrondNetwork/elrond-sdk-erdjs/blob/main/src/apiProvider.ts#L94
https://github.com/ElrondNetwork/elrond-sdk-erdjs/blob/main/src/proxyProvider.ts#L184
This leads to trouble when arweave-js tries to get a string from https://arweave.net/tx_anchor which results in a string which can't parse into JSON.
Example Response:
Example Error:
Pulling out the axios main packge into window.axx, then forcing the defaults.transformResponse to [] fixes the issue
Since we know that arweave-js will interoperate with many more other libaries, we can make arweave-js more robust by ensuring transformResponse = [] where we know it is not necessary. As such, we can start with get("tx_anchor") which we know has an issue.