optimism icon indicating copy to clipboard operation
optimism copied to clipboard

SDK does not support Ethers.js providers that do not extend JsonRpcProvider

Open raymondfeng opened this issue 2 years ago • 2 comments

Describe the bug

The CrossChainMessenger constructor accepts L1/L2 providers but some of the methods blindly cast them to JsonRpcProvider to call send(). As a result, it throws an error saying provider.send is not a function.

To Reproduce Steps to reproduce the behavior:

  1. Create an instance of CrossChainMessenger with FallbackProvider from Ethers.js
  2. Call withdrawERC20()

Expected behavior Ethers.js providers that implements providers.Provider interface should be supported.

Screenshots N/A

System Specs:

  • OS: MacOS
  • Package Version (or commit hash): "@eth-optimism/sdk": "^1.10.1"

Additional context We're testing Optimism ERC20 token deposit from L1 to L2 and withdraw from L2 back to L1.

raymondfeng avatar Feb 12 '23 16:02 raymondfeng

@smartcontracts and I had ran into this before but haven't had the bandwith yet to fix the issue. The workaround we did was to use a JSONRPC provider for only withdrawals.

fwiw it's bad design that ethers.js have these niche incompatibilities between their providers. All providers should inherit from JsonRpcProviders. I'm hoping they fixed this in v6.

roninjin10 avatar Feb 12 '23 18:02 roninjin10

I think this is realistically a "won't fix" for ethers v5. I don't see a good way to handle this because we need to make JSON RPC calls to specific RPC methods that ethers v5 providers don't expose. We simply can't make those queries without being able to call the JSON RPC directly.

Going to keep this open mostly because I hope to see an ethers v6 version of everything that does work as you would expect.

smartcontracts avatar Mar 05 '24 19:03 smartcontracts

The sdk has been deprecated

tynes avatar Jun 17 '24 21:06 tynes