tomusdrw / rust-web3

Ethereum JSON-RPC multi-transport client. Rust implementation of web3 library. ENS address: rust-web3.eth
MIT License
1.45k stars 465 forks source link

Add the wallet_switchEthereumChain method to the eip1193 transport #657

Open monomadic opened 2 years ago

monomadic commented 2 years ago

This adds support for eip3326, calling wallet_switchEthereumChain. It will allow a dapp to request a chain switch for a user with a eip1193 transport (such as metamask).

There are other methods that go alongside this method, but I'm not sure if this is the canonical way to implement this into rust-web3, so I only implemented the smallest (simplest) method first.

To check the functionality (where 0x01 is the hexadecimal chain id for ethereum):

        let transport = Eip1193::new(self.provider.clone());
        transport.switch_chain("0x01")

I'm not sure if the return values are ideomatic to your api either. Any guidance would be helpful as these functions are critical for any user wishing to develop web3 dapps in rust with a eip1193 transport.

monomadic commented 2 years ago

is this repository maintained any more? seems like there's open PRs from months back...