wagmi: [bug] WalletConnect Transaction promises not returning

Is there an existing issue for this?

  • I have searched the existing issues

Package Version

0.2.1

Current Behavior

I am using the package in my next.js application.

When I send transactions to a wallet connected with WalletConnect, the transaction promise never returns.

In the following code snippet, the transaction is picked up by the wallet and will successfully send, but the notifications aren’t displayed and the receipt isn’t logged.

I tried this with multiple wallets (Metamask and Valora) and neither of them work. Metamask works as expected.

  const setStorage = async (values) => {
    let tx = await contract.store(values.number);

    notification.open({
      message: "Updating Storage",
      description: `Contract storage updating to: ${values.number}`,
    });

    let receipt = await tx.wait();
    console.log("receipt", receipt);
}

Expected Behavior

I expect the transaction promise to resolve when it is sent by the wallet.

Steps To Reproduce

No response

Anything else?

No response

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 4
  • Comments: 55 (12 by maintainers)

Most upvoted comments

@maxx6262 i am able to connect using the testnet wallet and Valora. I am testing on this site

Got it to work with chainId: chain.id in case somebody find it useful but still using env variable to force rinkeby wagmi 0.3.0-next.13

import { chain, defaultChains } from 'wagmi'
import { InjectedConnector } from 'wagmi/connectors/injected'
import { WalletConnectConnector } from 'wagmi/connectors/walletConnect'
import { CoinbaseWalletConnector } from 'wagmi/connectors/coinbaseWallet'

const infuraId = process.env.NEXT_PUBLIC_INFURA_ID
const env = process.env.NODE_ENV
const chains = defaultChains
const defaultChain =  env === "development" ? chain.rinkeby : chain.mainnet

const connectors = ({ chainId }) => {
  const chain = chains.find((x) => x.id === chainId) ?? defaultChain
  const rpcUrl = chain.rpcUrls.infura
      ? `${chain.rpcUrls.infura}/${infuraId}`
      : typeof chain.rpcUrls.default === 'string'
      ? chain.rpcUrls.default
      : chain.rpcUrls.default[0]

  return [
    new InjectedConnector({
      chains,
      options: { shimDisconnect: true },
    }),
    new WalletConnectConnector({
      options: {
        qrcode: true,
        chainId: chain.id,
        rpc: {
          [chain.id]: rpcUrl,
        },
      },
    }),
    new CoinbaseWalletConnector({
      options: {
        appName: 'My wagmi app',
        chainId: chain.id,
        jsonRpcUrl: rpcUrl,
      },
    }),
  ]
}

export default connectors;

Got it. Thanks for the info. Don’t be sad, the next version isn’t out yet! Will look into this more.

Possible that there’s a WalletConnect issue somewhere in the stack here, signer/connector is getting stale in wagmi, etc. (Would check out this one too since you are using gnosis. Just something to be aware of.)

Check out the upcoming version of wagmi 0.3.0-next.13 (and corresponding docs). This might be solved there.

@maxx6262 ya,

  1. i think the “unexpected token i in json” problem is probably due to the useSigner() returns the signer with mainnet rpc.
  2. yes, it’s related with walletconnect. i’m checking the relevant walletconnect logics as well.