trufflesuite/drizzle-legacy

Support Passing Address and Abi Separately

epiqueras opened this issue · 2 comments

Currently, if I did not deploy a contract using truffle, I have to initialize web3 myself to use web3.eth.Contract to get the object for the drizzle config. I don't want to duplicate the web3 initialization that drizzle already does, so I ended up doing something like this:

const options = {
  contracts: [
    {
      ...Contract,
      networks: { 42: { address: process.env.CONTRACT_KOVAN_ADDRESS } }
    }
  ]
}

Ideally, you should be able to pass something like { abi, addresses: { [networkID]: <address> } } as a third option to the web3 contract object and linked truffle artifact.

I can submit a PR if you are happy with it.

Hi @epiqueras, thank you for bringing this up--we'd love to see a PR! 🙂

Actually, now that I think more about this.

All it would do is replace:
networks: { 42: { address: process.env.CONTRACT_KOVAN_ADDRESS } }
with:
addresses: { [networkID]: <address> }

Not really worth the extra complexity.

Check out this PR when you get a chance though trufflesuite/drizzle-react-legacy#46, would be great to have more people testing it.