MetaMask / KeyringController

A module for managing groups of Ethereum accounts and using them.
ISC License
230 stars 133 forks source link

Document what is needed to use this library in Webpack #199

Open mcmire opened 1 year ago

mcmire commented 1 year ago

Although we use Browserify, many people use Webpack, so we should document how to use this library with Webpack.

mcmire commented 1 year ago

According to #198, you may need:

resolve: {
  extensions: ['.ts', '.js'],
  fallback: {
    stream: require.resolve('stream-browserify'),
    buffer: require.resolve('buffer'),
    crypto: require.resolve('crypto-browserify'),
    global: require.resolve('globalthis'),
    process: require.resolve('process')
  }
},
plugins: [
  new CopyWebpackPlugin({
    patterns: [
      {
        from: 'node_modules/webextension-polyfill/dist/browser-polyfill.js'
      }
    ]
  }),
  new webpack.ProvidePlugin({
    global: require.resolve('globalthis')
  }),
  new webpack.ProvidePlugin({
    process: require.resolve('process')
  })
]

We should investigate whether this is truly the minimal set of configuration needed or whether we can make this simpler.

ko1ebayev commented 1 year ago

@mcmire Since I have fixed instantiating keyring controller, his methods don't work correctly. Ex. in service worker environment Im trying to call createNewVaultAndKeychain(), documentation says that this method creates 1 new random account so under the hood @scure/bip39 lib's methods getting called and this gives another error:

image

Error's entry point is in /@metamask/browser-passworder/dist/index.js

image

Any idea or recommendations how can I completely setup keyring controller?