WalletConnectFlutterV2 icon indicating copy to clipboard operation
WalletConnectFlutterV2 copied to clipboard

signEngine.metadata is final, but I want unique redirects for each Sign session.

Open bobwith2bees opened this issue 2 years ago • 3 comments

What I am trying to do:

Have my Dapp allow the user to connect to multiple wallets. I will have a tab in the UI for each wallet so the user can manage them separately as needed. When I sent a transaction to a specific wallet Sign session , I want the redirect URI to be unique so that my app hand handle the deep link and open the corresponding tab in the UI for that wallet.

I see the pairingInfo is marked final, and it managed at the Core level and not the Session level. I was hoping I could re-use the Web3App instance, just update the paringInfo metatdata for the redirect before each new Sign Session. There is no need to change the redirect once the Sign session has been established.

Protocol wise - I don't see the need to have a Web3 / Core instance per wallet (what the code can do today.) Looking for thoughts/guidance?

Priority - Low (for me) - Again I am just writing a class and this would have been nice to show off the capabilities. (Also assumes wallets actually pay attention to the peerMetadata redirect :-p)

bobwith2bees avatar Aug 10 '23 14:08 bobwith2bees

Each session has pairingMetadata for both dapp and wallet that should let you do as you're requesting.

They are embedded in the peer and self objects.

You can launch the peer's url or native link (If provided), or query it from the explorer and launch it that way.

Luzzotica avatar Aug 11 '23 03:08 Luzzotica

@Luzzotica - I am referring to the PairingMetadata (which includes redirect) passed into the WebApp instance and is not modifiable (marked final). (i.e. The PeerInfo that my app advertises to the wallet.)

https://github.com/WalletConnect/WalletConnectFlutterV2/blob/3b27b06b29219ba71f5189c4d9ef5ec33dc3155d/lib/apis/core/core.dart#L119C9-L119C9

On my app deep link support, I have a unique path supporting navigating to specific pages(tabs)

  • returnToMyApp//tab1 - advertised in the Sign session to wallet 1
  • returnToMyApp//tab2 - advertised in the Sign session to wallet 2
  • returnToMyApp//tab3 - advertised in the Sign session to wallet 3

Leveraging a package like https://pub.dev/packages/go_router.

// was hoping I could pass a custom redirect in this call
web3App.signEngine.connect()

// or perhaps after the ConnectResponse was returned before launching the URI - but this is not allowed 
web3App.signEngine.metadata = web3App.signEngine.metadata.copyWith(redirect: Redirect(native: '$kNativeLink$sessionNumber'));

bobwith2bees avatar Aug 11 '23 14:08 bobwith2bees

Deleted the idea that didn't work. But I did learn you can modify the peer metadata, and fix any errors. (Metamask - I am talking to you.)

// be sure you have the pairing topic not the session topic 
await web3App.core.pairing.updateMetadata(topic: pairingTopic, metadata: updatedPairingMetadata);

bobwith2bees avatar Aug 11 '23 15:08 bobwith2bees