Skip to content
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

Pass chainId to registerRequestHandler #258

Closed
Rimantovas opened this issue Feb 1, 2024 · 6 comments
Closed

Pass chainId to registerRequestHandler #258

Rimantovas opened this issue Feb 1, 2024 · 6 comments

Comments

@Rimantovas
Copy link

Is your feature request related to a problem? Please describe.
When having multiple EVM chains connected, it is hard to determine which chain to interact with

Describe the solution you'd like
Pass chainId parameter to registerRequestHandler handler function. Since we already have it in _onSessionRequest, it won't be hard to implement.

@quetool
Copy link
Collaborator

quetool commented Feb 2, 2024

Hello @Rimantovas, not sure I follow your concern 🤔 Could you elaborate a bit more?

@Rimantovas
Copy link
Author

The following method passes the session topic and request parameters to the handler. It would be nice to also get the chainId

 @override
  void registerRequestHandler({
    required String chainId,
    required String method,
    dynamic Function(String, dynamic)? handler,
  }) {
    try {
      return signEngine.registerRequestHandler(
        chainId: chainId,
        method: method,
        handler: handler,
      );
    } catch (e) {
      rethrow;
    }
  }

@quetool
Copy link
Collaborator

quetool commented Feb 3, 2024

Ok but what do you mean by "having multiple EVM chains connected"? You can not have "multiple EVM chains connected". Your paired session between dapp/wallet always works on the current active chain.

@Rimantovas
Copy link
Author

Yes, you can only have one active chain at a time, but you can pass multiple chains as optional namespaces.

@Rimantovas
Copy link
Author

Rimantovas commented Feb 6, 2024

Created a pull request that solves this issue @quetool

@quetool
Copy link
Collaborator

quetool commented Feb 22, 2024

Hello @Rimantovas! Here you can see the PR that would fix your issue! TL;DR: After this PR is merged you will have to handle your methods with onSessionRequest subscription (as it was supposed to be originally but was broken). method handlers registration will still work perfectly but if you want to access the current chainId then onSessionRequest subscription is your way to go #269

@quetool quetool closed this as completed Feb 22, 2024
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