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

Failing url dependency in the browser #35

Open
gomezgoiri opened this issue Oct 14, 2021 · 3 comments
Open

Failing url dependency in the browser #35

gomezgoiri opened this issue Oct 14, 2021 · 3 comments

Comments

@gomezgoiri
Copy link

When I pass a privateUrl to the Web3Quorum constructor in the browser, the url dependency fails here.

I checked the dependencies of web3js-quorum and there is no "url" defined.

After checking my project's dependencies, I see that it react-scripts transitively adds [email protected].
This is probably not the dependency Web3Quorum should be using because it does not have any constructor (you should use Url.parse() instead).

I see different solutions:

  • Adding the original dependency to Web3Quorum.

  • Using [email protected] and explicitly defining it as Web3Quorum's dependency

- const { URL } = require("url");
+ const Url = require("url");
...
-    const { protocol } = new URL(privateEndpoint);
+    const { protocol } = Url.parse(privateEndpoint);
  • Use a package like universal-url or iso-url to rely on browser's URL implementation whenever it is possible and to use a different implementation on NodeJS. For example:
- const { URL } = require("url");
+ require('universal-url').shim();
...
    const { protocol } = new URL(privateEndpoint);
@peterkruty
Copy link

Sorry unrelated request, but did you solved this? @gomezgoiri ?
Also could you please post a short guide, how to build web3js-quorum for browser? Can't make it work.

@gomezgoiri
Copy link
Author

Sorry, I was just testing web3js-quorum at that time and I ended up not using privateEndpoint (and therefore the ptm module).

Priv is enough for our solution, so I simply specify the endpoint of the Besu node (not GoQuorum) which talks to Tessera and use it like this:

const EEAClient = require("web3js-quorum")
...
const web3 = new EEAClient(new Web3(endpoint), chainId)
web3.priv.whatever()

@peterkruty
Copy link

Thanks!

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

No branches or pull requests

2 participants