Skip to content
This repository has been archived by the owner on Oct 7, 2024. It is now read-only.

Question: how I can deal with randombytes dependency of eth-keyring-controller? #198

Closed
ko1ebayev opened this issue Feb 20, 2023 · 3 comments

Comments

@ko1ebayev
Copy link

ko1ebayev commented Feb 20, 2023

Hey! Getting this error when trying to instantiate new eth-keyring-controller class in my background script environment:

image

So service worker registration fails, I am using "@metamask/eth-keyring-controller": "^10.0.0"
Pls help!

@mcmire
Copy link
Contributor

mcmire commented Feb 21, 2023

Hi @ko1ebayev. We see some code, but what's the error?

@ko1ebayev
Copy link
Author

ko1ebayev commented Feb 22, 2023

Hey @mcmire ! Sorry for bad pic, updated it. Code that gives an error is just a const keyringController = new KeyringController({}), content on pic is a peace of code after webpack build.
Btw, I solved this yesterday, I guess. The documentation is not clear regarding the complete lib setup. For complete setup we need a lot of polyfills. Im using Webpack 5 and typescript in my project, so the list of polyfills is:
image
And the second thing, I used webpack.ProvidePlugin to setup global and process identifiers for my build:
image

@mcmire
Copy link
Contributor

mcmire commented Feb 22, 2023

Got it, thanks for posting an update and glad you figured it out @ko1ebayev. I agree about the lack of documentation around polyfills. We are revamping this library, but for the time being I've noted this in #199 so it doesn't get lost. Since I answered your question I'll close this issue now!

@mcmire mcmire closed this as completed Feb 22, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants