trufflesuite / drizzle-legacy

Reactive Ethereum datastore for dapp UIs.
http://truffleframework.com/docs/drizzle/getting-started
MIT License
503 stars 128 forks source link

Allow empty drizzleOptions #198

Closed rahulmutt closed 5 years ago

rahulmutt commented 5 years ago

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.

cds-amal commented 5 years ago

Thanks for raising this @rahulmutt ! Would appreciate a PR