Open kev1n-peters opened 6 months ago
I suspect that registerSigner
is setting the source chain's provider as a reference to signer.provider
which is problematic when switching chains (because different chains reference the same provider). https://github.com/wormhole-foundation/wormhole-connect/blob/f52e719da48d81c8e5bb2630445aa0ef94bf3203/wormhole-connect/src/utils/wallet/index.ts#L65. Calling wh.registerProviders()
before switching chains fixes this, but it seems like a potential bug in the @nomad-xyz/multi-provider package.
The issue stems from the @nomad-xyz/multi-provider package. When calling registerSigner
, if the call to signer.connect
fails, then the provider
for the domain
will be set to signer.provider
. https://github.com/nomad-xyz/monorepo/blob/9b6f68278cf687f9f19065d52b0fac6a128346b1/packages/multi-provider/src/provider.ts#L242-L256 This is an issue, because signer.provider
may be connected to a chain different than the domain
. This is the exception thrown when signer.connect
is called: https://github.com/ethers-io/ethers.js/issues/1088#issuecomment-704347898
Steps to reproduce:
Approve a TX for any route and then reject the TX from Metamask. Now swap the chains and approve the TX again. Notice that
wh.mustGetProvider(sourceChain)
andwh.mustGetProvider(targetChain)
are the same provider (have the same EVM chain ID).