trufflesuite/drizzle-legacy

incorrect from address when switching account with Metamask

cds-amal opened this issue · 2 comments

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)

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.

Confirmed duplicate of #191.