optimism
optimism copied to clipboard
SDK does not support Ethers.js providers that do not extend JsonRpcProvider
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:
- Create an instance of CrossChainMessenger with FallbackProvider from Ethers.js
- 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.
@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.
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.
The sdk has been deprecated