DistributedCollective / Sovryn-frontend

Frontend DApp for Sovryn trading and lending platform.
https://alpha.sovryn.app
MIT License
79 stars 65 forks source link

Improve asking users to change network modal for MM wallets #1027

Closed creed-victor closed 3 years ago

creed-victor commented 3 years ago

Metamask now has a feature which allows dapps to add new network and ask for network change if user is in the wrong one:

window.ethereum.request({
  method: 'wallet_addEthereumChain',
  params: [{
    chainId: '0x38',
    chainName: 'Binance Smart Chain',
    nativeCurrency: { name: 'BNB', symbol: 'BNB', decimals: 18 },
    rpcUrls: ['https://bsc-dataseed.binance.org/'],
    blockExplorerUrls: ['https://bscscan.com/']
  }],
})

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

https://consensys.net/blog/metamask/connect-users-to-layer-2-networks-with-the-metamask-custom-networks-api/ https://eips.ethereum.org/EIPS/eip-3085

tiltom commented 3 years ago

Regarding to the documentation (https://docs.metamask.io/guide/rpc-api.html#other-rpc-methods), this method should be called only after some user action (such as a button click). What is your proposed flow @t-z-u ?

t-z-u commented 3 years ago

I will have to look into this next week

t-z-u commented 3 years ago

https://xd.adobe.com/view/be4b50de-2b99-4506-5663-270ce738ee5f-c87a/

tiltom commented 3 years ago

On hold until the FISH Sale is not ready.

tiltom commented 3 years ago

Deployed.