trufflesuite / drizzle-legacy

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

Refactor/use mw for drizzle instance #208

Closed cds-amal closed 5 years ago

cds-amal commented 5 years ago

This PR fixes #191 the issue of not being able to update web3 contracts' from address when a new selected account is detected. It also unifies state mutation concerns - Drizzle class now mutates its own state which was previously done in a saga/generator function.

Background

Drizzle currently splits state concerns in two locations 1) Redux store, to handle POJO state, and 2) the Drizzle Class instance for syncing Web3 Contract instance details.

This is necessary because web3 Contracts are non-serializable, as the trade offs are not worth it. See this Redux FAQ

Problem

Web3 Contracts have a mutable sendAccount property that web3 uses to sign send transactions. This value should reflect the current account designated by the wallet provider and it currently is not synchronized by drizzle.

The architecture makes it difficult to sync drizzle's contract list (maintained in the Drizzle class) with redux actions originating from web3 which, rightly, have no reference to drizzle's instance.

adrianmcli commented 5 years ago

@cds-amal LGTM, go ahead and merge!

sushmitsarmah commented 5 years ago

This issue is closed but whats the solution? I am still getting this error.

I currently replaced drizzleState.accounts[0] with drizzle.web3.eth.accounts.givenProvider.selectedAddress

adrianmcli commented 5 years ago

@sushmitsarmah I don't think we have made a release yet. @cds-amal let's put that on the table this week.

davidanoel commented 5 years ago

Hi all, when is the next release expected ?