wevm/wagmi

waitForTrasaction function is not working.

Closed this issue · 1 comments

Check existing issues

Describe the bug

Hi, How are you?
While working with functions on wagmi-core, I have one problem on waitForTransaction.
In a one project, this function working differently.
In the first case, this function working well. Here is codebase of that case.

const changeAddressHash = await writeContract({
        address: `0x${contractAddress}`,
        abi: seedRoundMMTAbi,
        functionName: "updateUserAddress",
        args: [sourceAddress, targetAddress]
      })

    await waitForTransaction({
      hash: changeAddressHash.hash
    })

But on other function, it is not working well and return the error. Here is code base and error message.

  • codebase
const approveHash = await writeContract({
    address: `0x${mmtContractAddress}`,
    abi: mmtContractAbi,
    functionName: 'approve',
    args: [`0x${contractAddress}`, parseEther(totalAmount.toString())],
  });
  
  await waitForTransaction({
    hash: approveHash.hash,
  });

-Error message:

TransactionNotFoundError
    at getTransaction (getTransaction.js:58:15)
    at async delay.count.count (waitForTransactionReceipt.js:98:47)
    at async attemptRetry (withRetry.js:17:30)
------------------------------------------------------------------------------
TransactionNotFoundError
    at getTransaction (getTransaction.js:58:15)
    at async delay.count.count (waitForTransactionReceipt.js:98:47)
    at async attemptRetry (withRetry.js:17:30)

What is the reason of this error and how to fix this?
Hope your kind support.
Thanks

Link to Minimal Reproducible Example

No response

Steps To Reproduce

No response

What Wagmi package(s) are you using?

@wagmi/core

Wagmi Version

1.4.1

Viem Version

1.10.9

TypeScript Version

5.0.4

Anything else?

No response

tmm commented

Recommend upgrading to wagmi@2