GithubHelp home page GithubHelp logo

Comments (4)

nhynes avatar nhynes commented on August 23, 2024

I don't use react, but I'm happy to provide an integration. Would you mind posting your manual wrapper as a PR in the clients/web3-react folder? I can help get it ready for merging in. Thanks!

from sapphire-paratime.

BerkliumBirb avatar BerkliumBirb commented on August 23, 2024

The problem with our current solution is that it only allows using sapphire. So I was wondering if you have any ideas of how to implement a wrapper connector that only wraps provider if it's connected to sapphire supported chains. And that can automatically unwrap if chain is changed by user (e.g. user changes it in MetaMask).

from sapphire-paratime.

nhynes avatar nhynes commented on August 23, 2024

You could check and then listen to the chain ID, then monkey patch when required. When the chain ID is 0x5aff or 0x5afe (saff or safe), then wrap (storing the original provider), otherwise set the object back to the original one.

The specifics of how to monkey patch depend on how clients access the object. For example, to patch metamask directly, you'd need to replace its send method, as clients may already have captured a reference to the original window.ethereum (so you can't replace it directly). If it's in some react store, and accesses to it are reactive, you can replace the object since there's one layer of indirection.

If you post some almost-working code, we can discuss and get it to a fully working state.

from sapphire-paratime.

nhynes avatar nhynes commented on August 23, 2024

Here's an example of doing that https://github.com/oasislabs/wordleish/blob/main/frontend/src/stores/ethereum.ts. I think that using a store (or equivalent) is the canonical solution, so I'm going to close this issue. If using a store ends up not working, I'm more than happy to reopen it.

from sapphire-paratime.

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.