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

feat: implement Pairing API #3

Open
wants to merge 76 commits into
base: kdf
Choose a base branch
from
Open

feat: implement Pairing API #3

wants to merge 76 commits into from

Conversation

borngraced
Copy link
Member

@borngraced borngraced commented Sep 3, 2024

This PR implements the WalletConnect Pairing API, enabling secure communication between dApps and wallets. It manages pairing requests, responses, and lifecycle events (creating, deleting, extending, and pinging pairings).
Key features:

Test overview (cargo run --example pairing):

  • Establishes WebSocket connection
  • Creates pairing with PairingClient
  • Handles pairing requests (delete, extend, ping)
  • Shuts down on Ctrl+C signal

The test demonstrates the full lifecycle of a WalletConnect pairing, from establishment to termination, using the pairing_api and relay_client crates.

https://specs.walletconnect.com/2.0/specs/clients/core/pairing/
https://specs.walletconnect.com/2.0/specs/clients/core/crypto/crypto-keys
https://specs.walletconnect.com/2.0/specs/clients/core/pairing/data-structures
https://specs.walletconnect.com/2.0/specs/clients/core/pairing/pairing-api

@borngraced borngraced self-assigned this Sep 3, 2024
pairing_api/src/pairing.rs Outdated Show resolved Hide resolved
@dimxy
Copy link

dimxy commented Oct 24, 2024

Great PR! (I left few notes above)

pairing_api/src/pairing.rs Outdated Show resolved Hide resolved
@dimxy
Copy link

dimxy commented Oct 26, 2024

I guess, I don't have right in this repo to resolve my review notes. @borngraced would you plz resolve them (including those you did not accept)

@laruh
Copy link
Member

laruh commented Nov 4, 2024

ps: CI fmt and clippy checks fail

Copy link
Collaborator

@shamardy shamardy left a comment

Choose a reason for hiding this comment

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

Huge work! First review iteration from my side.

wc_common/src/crypto.rs Show resolved Hide resolved
wc_common/src/crypto.rs Show resolved Hide resolved
pairing_api/src/pairing.rs Outdated Show resolved Hide resolved
pairing_api/src/pairing.rs Outdated Show resolved Hide resolved
pairing_api/src/pairing.rs Outdated Show resolved Hide resolved
pairing_api/src/pairing.rs Outdated Show resolved Hide resolved
Comment on lines 243 to 253
pub async fn activate(&self, topic: &str) -> Result<(), PairingClientError> {
let expiry = self.expiry()?;

let mut pairings = self.pairings.lock().await;
if let Some(pairing) = pairings.get_mut(topic) {
pairing.pairing.active = true;
pairing.pairing.expiry = expiry + EXPIRY_30_DAYS;
}

Ok(())
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why not use this method above instead of code duplication?

pairing_api/src/pairing.rs Outdated Show resolved Hide resolved
pairing_api/src/pairing.rs Outdated Show resolved Hide resolved
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.

4 participants