Git Product home page Git Product logo

Comments (5)

ShravanSunder avatar ShravanSunder commented on August 11, 2024 1

pushed a change to update the signer field on change

from eth-ui.

stephancill avatar stephancill commented on August 11, 2024

I think this is also related to the useSignerAddress hook because with the fix implemented in #178, running the test scenario again, logging ethersContext.signer when it changes:

Initial connect:
Screenshot 2022-02-12 at 23 27 22

After changing accounts, the signer on ethersContext is correct but the result of useSignerAddress is still outdated:
Screenshot 2022-02-12 at 23 27 37

from eth-ui.

dvinubius avatar dvinubius commented on August 11, 2024

I've been experiencing this issue for many days now and didn't know what was going on.

But it came with another symptom, and I kept blaming Metamask for it: my transactions would fail with a Metamask error saying RPC Error: Invalid parameters: must provide an Ethereum address

Only accidentally I discovered that it was occurring when I was changing accounts in metamask:

The header account was always updating correctly, so I never considered to check the context values.
But indeed the ethersContext.signer would keep the old address.

Only a page reload would fix the mismatch...

Screenshot 2022-02-23 at 00 39 40

from eth-ui.

dvinubius avatar dvinubius commented on August 11, 2024

@ShravanSunder I've looked into it just a bit and it seems to be a bug in web3-react, rather than in eth-hooks

from eth-ui.

dvinubius avatar dvinubius commented on August 11, 2024

@stephancill have you found a suitable workaround?

For anyone having this issue and looking for a quick fix:

Create a helper like

export const getCurrentSigner = async () => {
  const ethereum = window.ethereum;
  // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
  const provider = new ethers.providers.Web3Provider(ethereum);
  await provider.send('eth_requestAccounts', []);
  return provider.getSigner();
};

It works without making any other changes than this:

Instead of
contract.functionCall(arg1, arg2)
you can
contract.connect(await getCurrentSigner()).functionCall(arg1, arg2)

from eth-ui.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.