omgnetwork / optimism

Monorepo implementing the Optimistic Ethereum protocol
https://optimism.io
MIT License
16 stars 6 forks source link

Wallet issues and weaknesses - Need to login/logout to change chains #62

Open CAPtheorem opened 3 years ago

CAPtheorem commented 3 years ago

I understand why this is, but there has got to be a better, more user-friendly solution. For example, when someone selects an action that's on the other chain - fire up a popup that says - To do this you need to change chains. Click here to switch to {otherChain}

CAPtheorem commented 3 years ago

ToDo - 1/ best practices for helping people to navigate multiple chains 2/ Metamask integration - how do we make chain switching as natural as possible? 3/ What changes are needed to networkServices to support on-the-fly choice of changes on a per action level?

CAPtheorem commented 3 years ago

Example - this is how we send the correct L2 chain parameters to MetaMask right now:

  async addL2Network() {
    const nw = getAllNetworks();
    const chainParam = {
      chainId: '0x' + nw.rinkeby.L2.chainId.toString(16),
      chainName: "OMGX L2",
      rpcUrls: [nw.rinkeby.L2.rpcUrl]
    }

    this.provider = await web3Modal.connect();
    this.web3Provider = new Web3Provider(this.provider);
    this.web3Provider.jsonRpcFetchFunc(
      'wallet_addEthereumChain',
      [chainParam, this.account],
    );
  }
CAPtheorem commented 3 years ago

Related information: https://eips.ethereum.org/EIPS/eip-3085

https://docs.metamask.io/guide/rpc-api.html#other-rpc-methods