trufflesuite / drizzle-legacy

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

incorrect from address when switching account with Metamask #202

Closed cds-amal closed 5 years ago

cds-amal commented 5 years ago

With Metamask primed with multiple accounts

  1. create a new drizzle box (truffle unbox drizzle), deploy contracts, start react app
  2. switch account in Metamask and DO NOT refresh page.
  3. submit a new value for SimpleStorage and the following error with manifest.
inpage.js:1 MetaMask - RPC Error: Error: WalletMiddleware - Invalid "from" address.
    at f (chrome-extension://nkbihfbeogaeaoehlefnkodbefgpgknn/background.js:1:1103606) {code: -32603, message: "Error: WalletMiddleware - Invalid "from" address.↵…ogaeaoehlefnkodbefgpgknn/background.js:1:1103606)"}

Notes: The web3 contract object in SEND_CONTRACT_TX shows inequality between the currentProviders selected address (the correct address) and the options member which has the previously selected address.

(edit: simplify reproduction)

cds-amal commented 5 years ago

Using this space to keep track of notes on this issue. Assumptions may change pending further investigation.

Drizzle constructs and keeps a web3.eth.Contract instance with a from: set to the defaultAccount (accounts[0]) at set up time. This doesn't change when account is updated.

Note. There are two contract creation methods in our API - instantiateWeb3Contract and instantiateContract that would have to be addressed in a solution.

cds-amal commented 5 years ago

Confirmed duplicate of #191.