Skip to content

[Bug]: addNewChain always sets the app's provider RPC URL #1020

@katspaugh

Description

@katspaugh

Current Behavior

In onboard.setChain, when the user doesn't have that chain in their wallet, onboard suggests to add it.

To achieve that, it passes the app's provider configuration to the wallet.

In a typical web3 app, that uses a custom Infura endpoint with an individual project id, it's not desirable that the user has this custom RPC URL in their wallet.

Expected Behavior

There should be a way to specify an RPC URL to give to the wallet when adding a new chain. That would typically be a public RPC.

Steps To Reproduce

  • Use MetaMask
  • Remove Polygon if you have it in your MetaMask already
  • Initialize onboard with a custom Polygon RPC
  • Call onboard.setChain({ chainId: 137 })
  • Observe that it offers the user to install Polygon with that RPC

Onboard Version

2

Node Version

16

What browsers are you seeing the problem on?

No response

Relevant log output

No response

Anything else?

I would suggest to add a new field in the Chain configuration, publicRpc, and use that when calling wallet_addEthereumChain. Or maybe just a new param for the setChain method.

Metadata

Metadata

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions