trufflesuite/drizzle-legacy

Allow empty drizzleOptions

rahulmutt opened this issue · 1 comments

In my use-case, I didn't need to initialize the options (since I am dynamically adding contracts) so I sent an empty object to DrizzleProvider from drizzle-react and I got the following error:

generateContractsInitialState
node_modules/drizzle/dist/drizzle.js:18320
  18317 | // Preloaded state
  18318 | var contractsInitialState = {};
  18319 | 
> 18320 | for (var i = 0; i < options.contracts.length; i++) {
        | ^  18321 |   // Initial contract details
  18322 |   var contractName = options.contracts[i].contractName;
  18323 |   contractsInitialState[contractName] = (0, _generateContractInitialState.generateContractInitialState)(options.contracts[i]);

which seems to be coming from core drizzle.

The workaround is to send:

{ contracts: [] }

Happy to submit a PR if a fix is desirable.

Thanks for raising this @rahulmutt ! Would appreciate a PR