web3.js icon indicating copy to clipboard operation
web3.js copied to clipboard

Not getting success callback/ receipt with walletconnect with web3.js 1.3.3

Open imaksp opened this issue 5 years ago • 56 comments

Expected behavior

  • It should give success callback & receipt if used with WalletConnect

Actual behavior

  • After 1.3.x update (tried with 1.3.3 & 1.3.4 rc.1), it is working upto below callback
.on('transactionHash', function(hash){
    ...
}) 

on 'receipt' OR below one

.then(function(receipt){
    // receipt can also be a new contract instance, when coming from a "contract.deploy({...}).send()"
});

Never gets called but it is working fine with web3.js 1.2.11.

Steps to reproduce the behavior

  1. Connect wallet by scanning QR code with Metamask mobile or WalletConnect supported wallet app
  2. Do any contract interaction Txn (using myMethod(123).send)
  3. See if its calling final success callback with receipt

Logs

Environment

WalletConnect web3 provider: tried 1.3.1 & current latest 1.3.4 Node: 14.15.x web3.js: 1.3.3 & 1.3.4.rc1 OS: Mac OS 11.1

If possible please release new 1.2.x version with Metamask hotfix, if it can't be fixed quickly with 1.3.x

imaksp avatar Jan 29 '21 05:01 imaksp

By chance do you have a demo app?

GregTheGreek avatar Jan 29 '21 05:01 GregTheGreek

No I don't have demo app, let me know if it is required, will make it tomorrow.

imaksp avatar Jan 29 '21 05:01 imaksp

For a sanity check, I tested this locally using ganache-cli by deploying the SimpleStorage.sol contract and submitted a set transaction - I received the transactionHash, the receipt, and the confirmation events

Spacesai1or avatar Feb 01 '21 17:02 Spacesai1or

No I don't have demo app, let me know if it is required, will make it tomorrow.

If you could provide a demo app, it would help debugging tremendously

Spacesai1or avatar Feb 01 '21 17:02 Spacesai1or

@spacesailor24 Ok will try to make demo, btw I tried approve method of ERC20 contract & wallet was connected using metamask mobile app on Android using Walletconnect QR code, on rinkeby test network.

Btw it is working as expected with metamask browser extension but not with Walletconnect so we downgraded app to 1.2.11.

imaksp avatar Feb 01 '21 17:02 imaksp

I am having the same issue with ganache-cli. The contract deploys but the transactionHash is always undefined. The then callback is never called too. The issue is happening on [email protected].

ujal avatar Feb 03 '21 18:02 ujal

@spacesailor24 Hi, here is the demo app for the issue, please see README for steps, don't forget to set 'REACT_APP_INFURA_ID' in '.env' before connecting. Demo link: https://github.com/aksdevac/wc-web3-demo

imaksp avatar Feb 04 '21 09:02 imaksp

I am having the same issue with ganache-cli. The contract deploys but the transactionHash is always undefined. The then callback is never called too. The issue is happening on [email protected].

Could you provide a code snippet of what's not working? I can do the same for code that was working using ganache-cli

Spacesai1or avatar Feb 04 '21 15:02 Spacesai1or

Forgot to @ujal ^

Spacesai1or avatar Feb 04 '21 15:02 Spacesai1or

@spacesailor24 Hi, here is the demo app for the issue, please see README for steps, don't forget to set 'REACT_APP_INFURA_ID' in '.env' before connecting.

Demo link: https://github.com/aksdevac/wc-web3-demo

Awesome, thank you! I'll be taking a look at this shortly

Spacesai1or avatar Feb 04 '21 15:02 Spacesai1or

@spacesailor24

contract.deploy({ data: bytecode }).send({ from: account }, function(err, transactionHash) {
  console.log(transactionHash)
}).then(function(newContract) {
  console.log(newContract.options.address)
});

ujal avatar Feb 04 '21 16:02 ujal

@ujal Here is a working example

Spacesai1or avatar Feb 04 '21 18:02 Spacesai1or

Thank you for providing the test repo :heart:

It looks like I received the tx hash using [email protected]

image

Spacesai1or avatar Feb 04 '21 19:02 Spacesai1or

Thank you for providing the test repo :heart:

It looks like I received the tx hash using [email protected]

image

Yes txHash is received but receipt is never received with 1.3.4 so loading never stops.

imaksp avatar Feb 05 '21 03:02 imaksp

Oops I misread! @ujal said the tx hash was never received

I'll have to take a look at it further tomorrow morning, sorry for the inconvenience!

Spacesai1or avatar Feb 05 '21 03:02 Spacesai1or

Ok @ujal issue might be different but if you check code he posted, he is not listening for transactionHash event, so may be he didn't checked for it. I was also not listening for transactionHash event before as I can show success only after receipt is received & Receipt also has txHash, txHash event is added just for debugging purpose. Goal is to receive the receipt after transaction is confirmed on blockchain.

imaksp avatar Feb 05 '21 04:02 imaksp

I updated my example repo above to include the receipt listeners here Both .on('receipt', receipt => {...}) and .then(receipt => {...}) work, so my suspicion is a miscommunication between WalletConnect and Web3.js

Spacesai1or avatar Feb 05 '21 17:02 Spacesai1or

@pedrouid can you see if @walletconnect/web3-provider is causing this issue?

GregTheGreek avatar Feb 05 '21 17:02 GregTheGreek

@spacesailor24 yes there must be some miscommunication but as it was working with web3 1.2.11, I have created an issue here.

imaksp avatar Feb 06 '21 06:02 imaksp

it is perfectly working on version 1.2.11 .1.3 version has some issues in getting the receipt hook

avinashbuddana avatar Feb 23 '21 08:02 avinashbuddana