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

fix(wc): check active sessions and extend existing pairing if present #4051

Closed
wants to merge 8 commits into from

Conversation

MuckT
Copy link
Collaborator

@MuckT MuckT commented Aug 8, 2023

Description

A fix for the error from wallet connect { context: 'core' }, 'Pairing already exists: <pairingTopic>'. This error was commonly occurring and could be contributing to session mismatches that result in the the following errors describe by @jeanregisser in https://github.com/orgs/WalletConnect/discussions/3291#discussioncomment-6608198.

{ context: 'client' }, 'No matching key. session: 9a05b6099c6cc662ed39dd43795adec83ad64dfc6cfd7779ae1bc3d6470bb5c6'
{ context: 'client' }, [Error: No matching key. session: 9a05b6099c6cc662ed39dd43795adec83ad64dfc6cfd7779ae1bc3d6470bb5c6]

Test plan

  1. The { context: 'core' }, 'Pairing already exists: <pairingTopic>' error is no longer seen.
  2. Dapp action requests continue to populate after transacting with several dapps over two days.

Related issues

Fixes: RET-818

Backwards compatibility

Yes

@codecov
Copy link

codecov bot commented Aug 9, 2023

Codecov Report

Merging #4051 (616af83) into main (2a5b4c8) will decrease coverage by 0.03%.
The diff coverage is 0.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #4051      +/-   ##
==========================================
- Coverage   83.23%   83.20%   -0.03%     
==========================================
  Files         718      718              
  Lines       26735    26741       +6     
  Branches     3634     3634              
==========================================
- Hits        22252    22250       -2     
- Misses       4420     4428       +8     
  Partials       63       63              
Files Changed Coverage Δ
src/walletConnect/saga.ts 45.54% <0.00%> (-1.31%) ⬇️

... and 1 file with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 2a5b4c8...616af83. Read the comment docs.

@MuckT MuckT marked this pull request as ready for review August 9, 2023 00:26
@MuckT MuckT marked this pull request as draft August 9, 2023 05:45
@MuckT MuckT marked this pull request as ready for review August 9, 2023 17:10
@@ -15,6 +15,7 @@ import App from 'src/app/App'
import * as Sentry from '@sentry/react-native'
import 'react-native-gesture-handler'
import { Text, TextInput } from 'react-native'
import '@walletconnect/react-native-compat'
Copy link
Collaborator Author

@MuckT MuckT Aug 10, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is how several other wallets import @walletconnect/react-native-compat: GitHub Search Results.

WalletConnect RN CLI Wallet

// index.js
import './polyfills';

// polyfills.ts
import '@walletconnect/react-native-compat';

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this directly related to the fix?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When the import was in the src/walletconnect/saga, I was seeing more issues with pairings.

@@ -15,6 +15,7 @@ import App from 'src/app/App'
import * as Sentry from '@sentry/react-native'
import 'react-native-gesture-handler'
import { Text, TextInput } from 'react-native'
import '@walletconnect/react-native-compat'
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this directly related to the fix?

@@ -183,9 +182,15 @@ function* createWalletConnectChannel() {
}
}) as EventChannel<WalletConnectActions>
}

/**
* It appears Actions.INITIALISE_PAIRING is emitting on both initial connections and on payload requests
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure I understand this comment. Can you rephrase it? Specifically what/who is emitting? Also, if what/who is emitting erroneously or unexpectedly, should we fix that instead?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like some old assumptions were made on our end here in src/walleconnect/walletconnect.ts about what what is a wallet connect action vs connection request. I agree a fix here is probably more appropriate.


if (foundSession) {
Logger.debug(TAG + '@handleInitialisePairing', 'extending session start')
yield* call([client, 'extendSession'], { topic: foundSession })
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Q: isn't foundSession an instance of Session (vs string which is what I'd expect for topic)?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In testing foundSession is just a string that is the pairingTopic, but I'll double check to be sure.

@MuckT
Copy link
Collaborator Author

MuckT commented Aug 11, 2023

Closing in favor of #4062

@MuckT MuckT closed this Aug 11, 2023
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 this pull request may close these issues.

None yet

2 participants