Skip to content

Wallet cannot receive dapp's request #136

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
lvshaoping007 opened this issue Mar 26, 2025 · 21 comments · May be fixed by #148
Closed

Wallet cannot receive dapp's request #136

lvshaoping007 opened this issue Mar 26, 2025 · 21 comments · May be fixed by #148

Comments

@lvshaoping007
Copy link

SDK Affected
reown_walletkit: 1.1.3

Both, i use reown_walletkit 1.1.3 and @walletconnect/sign-client 2.19.1

Describe the bug
The dapp can report the request message, but the wallet cannot receive the message.

To Reproduce

  1. Init wallet connect on the mobile browser,
  2. click connect,
  3. request wallet link through deeplink,
  4. back to browser and request signMessage through deeplink

Expected behavior

  1. The wallet debug log shows that the message can be received

Reproducible code

const client = await SignClient.init({
    projectId: "",
    metadata: {
      name: "xxxx",
      description: "xxxx",
      url: window.location.origin,
      icons: ["https://www.xxx.com/imgs/xx.png"],
    },
    logger:"error"
  });



  try {
      const paymentRequest = {
        topic: session.topic,
        chainId: selectedChain,

        request: {
          method: "signMessage",
          params: {
            from: account,
            message: "Hello, wallet",
          },
        },
      };
      const result = await client.request(paymentRequest);
_walletKit = ReownWalletKit(
      core: ReownCore(
        projectId: projectId,
        logLevel: LogLevel.all,
      ),
      metadata: const PairingMetadata(
        name: 'Wallet',
        description: 'xxx',
        url: 'https://www.xxx.com/',
        icons: ['https://www.xxx.com/imgs/aurxxo.png'],
        redirect: Redirect(
          native: 'demo://',
          universal: 'https://www.demo.com/applinks',
          linkMode: true,
        ),
      ),
    );

    _setupListeners();
    await _walletKit.init();


_walletKit.onSessionRequest.subscribe(onSessionRequest);

Smartphone (please complete the following information):

  • Device: xiaomi 14
  • Browser browser

Additional context
The connection request is work well , but nothing else works.
The same code fails most of the time, but sometimes it can receive a message, that is, the log of wallect connect in the wallet will print out the request content.
Trying to switch the project id doesn't work either.

Copy link

linear bot commented Mar 26, 2025

@quetool
Copy link
Member

quetool commented Apr 3, 2025

Hello @lvshaoping007, sorry for the delay on this! Are you running flutter walletkit on the web? Can you clarify a bit? I'm confused

@lvshaoping007
Copy link
Author

Hello @lvshaoping007, sorry for the delay on this! Are you running flutter walletkit on the web? Can you clarify a bit? I'm confused

Hi, no, I use @walletconnect/sign-client on the web page
The mobile app uses reown_walletkit
Now there is no problem with scanning the code(in PC) to login and the interaction after login

But when opening the web in the mobile browser and linking the mobile app through deeplink, all requests cannot be used normally, and the mobile app wallect connect event listener cannot receive the reported signMessage and other requests

@quetool
Copy link
Member

quetool commented Apr 14, 2025

So you have a native mobile Wallet written with flutter using reown_walletkit
You also have a web DApp using @walletconnect/sign-client.
You want to connect this DApp with the Wallet using mobile browser so the interaction is
"Dapp on mobile browser <> Wallet on mobile native"
Am I correct?
Do you see any errors in the console either on your flutter console in wallet side or your chrome console on Dapp side?
Could you perhaps record a video?

@lvshaoping007
Copy link
Author

Yes, you are right.
dapp uses this function to listen to the send event, which prints the log as shown in the figure.
When I send a request, this function will print the corresponding parameters. but flutter wallet listener will not be trigger

client.on("session_request_sent", (event: any) => {
console.error("WalletConnect session session_request_sent:", event);
});

Image

this is my flutter wallet code, use reown_walletkit: 1.1.3
https://github.com/aurowallet/auro-wallet-mobile-app/blob/feature/walletconnect/lib/service/WalletConnectService.dart

@quetool
Copy link
Member

quetool commented Apr 14, 2025

You mean the onSessionRequest even subscription is not being called on wallet side?

@lvshaoping007
Copy link
Author

You mean the onSessionRequest even subscription is not being called on wallet side?

Yes, but when I open the same webpage on PC and scan the code to use, the onSessionRequest of flutter wallet will be called.

Only on the mobile browser, onSessionRequest is not called

@quetool
Copy link
Member

quetool commented Apr 14, 2025

I'm still really confused. When you say "Only on the mobile browser, onSessionRequest is not called" it makes me think you are running reown_walletkit on web wallet, not native mobile wallet, correct?

I'd like precise steps to reproduce this issue please.

@lvshaoping007
Copy link
Author

lvshaoping007 commented Apr 14, 2025

Hi, here are the specific steps again,

  1. Open the dapp in the mobile browser and click the request link,
  2. Pull up the flutter wallet and confirm the authorization
  3. After returning to the dapp, it shows that it is connected (the linked account is obtained through wallet connect)
  4. Click request signMessage
    The dapp listener prints out the relevant parameters of this request,
client.on("session_request_sent", (event: any) => {
  console.error("WalletConnect session session_request_sent:", event);
});

But the onSessionRequest (flutter wallet event listener) of the flutter wallet did not receive the parameters of this request

The recorded video does not show any abnormality, because there is only the error in the above web screenshot, and there is no obvious error prompt or display abnormality

@quetool
Copy link
Member

quetool commented Apr 14, 2025

Can you try implementing this section in your wallet? https://docs.reown.com/walletkit/flutter/usage#namespace-builder

@lvshaoping007
Copy link
Author

Can you try implementing this section in your wallet? https://docs.reown.com/walletkit/flutter/usage#namespace-builder

https://github.com/aurowallet/auro-wallet-mobile-app/blob/feature/walletconnect/lib/service/WalletConnectService.dart#L54

Sure, I am now using the document integration
Using onSessionRequest on mobile wallet to monitor the request sent by the dapp. But mobile wallet can't receive the request sent by the dapp opened in the mobile browser.

@quetool
Copy link
Member

quetool commented Apr 15, 2025

I mean implementing this section of the docs

Image

I don't see any of this in your code and that might be the reason why you don't get the request.
However, I have found a bug related to onSessionRequest that I will be fixing soon but this bug only affect you IF YOU DON'T implement the appointed section (which would be mostly sure your case).

@quetool
Copy link
Member

quetool commented Apr 15, 2025

Can I clone your repo and run it to try reproduce it?

@quetool
Copy link
Member

quetool commented Apr 15, 2025

I have checked deeply our SDK and there's no bug actually. I order to get the session request (method request) through onSessionRequest you have to at least register accounts with _walletKit.registerAccount(). I don't see you do this in your code. Check this block or our wallet

@lvshaoping007
Copy link
Author

I mean implementing this section of the docs

Image

I don't see any of this in your code and that might be the reason why you don't get the request. However, I have found a bug related to onSessionRequest that I will be fixing soon but this bug only affect you IF YOU DON'T implement the appointed section (which would be mostly sure your case).

in fact, I tried to activate registerEventEmitter, but after using it, walletconnect does not work properly, only after removing it can it work properly.

@lvshaoping007
Copy link
Author

Can I clone your repo and run it to try reproduce it?

Sure, this is a dapp for testing requests,
https://feature-sharedarraybufferche.auro-token-web.pages.dev/?useCache=false

@lvshaoping007
Copy link
Author

I have checked deeply our SDK and there's no bug actually. I order to get the session request (method request) through onSessionRequest you have to at least register accounts with _walletKit.registerAccount(). I don't see you do this in your code. Check this block or our wallet

reown_flutter/packages/reown_walletkit/example/lib/dependencies/walletkit_service.dart

Line 104 in 7908df6

for (final chainKey in chainKeys) {

You means add registerAccount? But I tried flutter wallet, and it worked fine in some cases.

  • If I use a PC browser to open the above DApp, and then use the same flutter wallet to communicate, all requests are normal.

  • When the mobile browser opens the above DApp, and then uses the same flutter wallet to communicate, flutter wallet can't get the request information (the connection has been successful)

@quetool
Copy link
Member

quetool commented Apr 15, 2025

But I tried flutter wallet, and it worked fine in some cases.

Which flutter wallet? Our flutter wallet?

If I use a PC browser to open the above DApp, and then use the same flutter wallet to communicate, all requests are normal.

You do this by scanning the QR code in your dapp with the wallet?

When the mobile browser opens the above DApp, and then uses the same flutter wallet to communicate, flutter wallet can't get the request information (the connection has been successful)

Are you 100% that the request is not being opened in the wallet? Did you actually opened the wallet after triggering the request to confirm this?

@quetool
Copy link
Member

quetool commented Apr 15, 2025

I would like to run your wallet and test it myself, you can write me on Telegram

@lvshaoping007
Copy link
Author

But I tried flutter wallet, and it worked fine in some cases.

Which flutter wallet? Our flutter wallet?

If I use a PC browser to open the above DApp, and then use the same flutter wallet to communicate, all requests are normal.

You do this by scanning the QR code in your dapp with the wallet?

When the mobile browser opens the above DApp, and then uses the same flutter wallet to communicate, flutter wallet can't get the request information (the connection has been successful)

Are you 100% that the request is not being opened in the wallet? Did you actually opened the wallet after triggering the request to confirm this?

No, it is the wallet we developed
The PC side scans the QR code to link the wallet. The mobile side links the wallet through deeplink.

The log of flutter wallet is seen through the log of flutter in the terminal.
When scanning the code to log in, you can see that onSessionRequest outputs the request log of DApp (I opened the debug log of wallect connect).

but the mobile browser only has the log of successful connection, and no log of signMesssage, etc. is output.

Yes, I am sure, because when the signMessage event is triggered by clicking on the dapp, I opened the flutter wallet through deeplink after the session_request_sent is triggered, but I have not received any report information in flutter mobile wallet.

@lvshaoping007
Copy link
Author

lvshaoping007 commented Apr 15, 2025

I would like to run your wallet and test it myself, you can write me on Telegram

Thanks a lot, I have sent a DM request

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants