tronprotocol / tronweb

Javascript API Library for interacting with the TRON Network
MIT License
413 stars 271 forks source link

fix: TronWeb not usable within ServiceWorkers in Browser extensions #471

Closed wsdt closed 6 months ago

wsdt commented 7 months ago

Identical to: https://github.com/tronprotocol/tronweb/pull/438

Just updated to Typescript and merged with Upstream.

Tested again on 19 January 2024, with the latest tronweb release as well as the upcoming 6.0.0-beta.0 release.

When using the built in adapter it works.


TronWeb currently can't be used in Browser Extension Service Workers due to Axios incompatibility with it.

There are usually two ways to fix this:

Convert to fetch Add a fetch-adapter Tests seem to run as they did before (some did fail for me before changing anything already).

Had to directly include https://github.com/vespaiach/axios-fetch-adapter as it wasn't possible to use the package as is.

start940315 commented 6 months ago

You can write your own provider to do it. We are not going to accept it cause it works only in Browser extensions.

wsdt commented 6 months ago

@start940315 How shall we replace the provider of your library? We had to fork tronweb to make it work.