Describe the bug
The current setup for connecting to a smart contract does not play well with MetaMask. The JSON-RPC signer exposed by MetaMask does not allow the connect function to be used. A given signer can thus not connect to a provider.
To Reproduce
Steps to reproduce the behavior:
Integrate the @nahmii/sdk.
Call the relayL2ToL1Messages function with a signer retrieved from a JSON-RPC provider exposed by Ethers.
The following error will be thrown:
index.ts:225 Uncaught (in promise) Error: cannot alter JSON-RPC Signer connection (operation="connect", code=UNSUPPORTED_OPERATION, version=providers/5.5.1)
at Logger.makeError (index.ts:225)
at Logger.throwError (index.ts:237)
at JsonRpcSigner.connect (json-rpc-provider.ts:145)
at relayL2ToL1Messages (l2-to-L1-message-relaying.js:94)
at async TransactionTable.claimFunds (Account.svelte:105)
Expected behavior
The function can be called without throwing the above mentioned error.
Additional context
The problem can be resolved by not relying on the connect function, but instead pass a JSON-RPC provider that is also a signer. This is a small refactor where every connect call will be removed and instead the called smart contracts are instantiated and the JSON-RPC signer is passed into the instantiation call.
Describe the bug The current setup for connecting to a smart contract does not play well with MetaMask. The JSON-RPC signer exposed by MetaMask does not allow the
connect
function to be used. A given signer can thus not connect to a provider.To Reproduce Steps to reproduce the behavior:
@nahmii/sdk
.relayL2ToL1Messages
function with a signer retrieved from a JSON-RPC provider exposed by Ethers.Expected behavior The function can be called without throwing the above mentioned error.
Additional context The problem can be resolved by not relying on the
connect
function, but instead pass a JSON-RPC provider that is also a signer. This is a small refactor where everyconnect
call will be removed and instead the called smart contracts are instantiated and the JSON-RPC signer is passed into the instantiation call.