Skip to content
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

Package does not work in browser due to Brotli dependency (Arbitrum one/goerli) #662

Open
ethanrushh opened this issue Aug 17, 2024 · 1 comment · May be fixed by #663
Open

Package does not work in browser due to Brotli dependency (Arbitrum one/goerli) #662

ethanrushh opened this issue Aug 17, 2024 · 1 comment · May be fixed by #663

Comments

@ethanrushh
Copy link

  • I'm submitting a ...
    [X] bug report
    [ ] feature request
    [X] question about the decisions made in the repository
    [ ] question about how to use this project

  • Summary

When using Arbitrum One / Arbitrum Goerli, Brotli is used to help estimate the gas within the getL2ToL1GasUsed function of gas-factory-helpers.js. Brotli.js is abandoned and has no browser support. From looking around, it seems like the most appropriate replacement would be brotli-wasm.

I would like to know the thoughts of the project maintainers regarding migrating from brotli.js to brotli-wasm. I would like to work on that myself if possible and submit a PR when complete.

@ethanrushh ethanrushh linked a pull request Aug 17, 2024 that will close this issue
@namedotget
Copy link

namedotget commented Sep 21, 2024

I was able to get past this issue by adding this script to index.html

          <script
            dangerouslySetInnerHTML={{
              __html: `globalThis.Browser = { T: () => {} };`,
            }}
          />

I'm now running into this error when I try to create a route on Arbitrum One :

TypeError: brotli._malloc is not a function
    at module.exports [as compress] (compress.js:24:1)
    at getArbitrumBytes (gas-factory-helpers.js:119:24)
    at getL2ToL1GasUsed (gas-factory-helpers.js:154:1)
    at calculateArbitrumToL1FeeFromCalldata (gas-factory-helpers.js:134:1)
    at calculateArbitrumToL1SecurityFee (gas-factory-helpers.js:384:1)
    at calculateL1GasFeesHelper (gas-factory-helpers.js:326:1)
    at Object.calculateL1GasFees (v3-heuristic-gas-model.js:39:50)
    at getBestSwapRouteBy (best-swap-route.js:320:1)
    at getBestSwapRoute (best-swap-route.js:40:1)
    at AlphaRouter.getSwapRouteFromChain (alpha-router.js:800:53)
    at async Promise.all (index 1)
    at async AlphaRouter.route (alpha-router.js:497:1)
    at async generateRoute (useUniversalRouter.tsx:42:21)

I'm using version ^3.19.2

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 a pull request may close this issue.

2 participants