incorrect from address when switching account with Metamask
cds-amal opened this issue · 2 comments
cds-amal commented
With Metamask primed with multiple accounts
- create a new drizzle box (
truffle unbox drizzle
), deploy contracts, start react app - switch account in Metamask and DO NOT refresh page.
- 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 currentProvider
s selected address (the correct address) and the options
member which has the previously selected address.
(edit: simplify reproduction)
cds-amal commented
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.