walletconnect-sdk 0.2.3

Implementation of WalletConnect Specifications in Rust
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
/// Types
///
/// All the RPC types and logic to encode and decode. There are some tests with
/// actual payloads to ensure that the logic works.
///
use std::collections::HashMap;
use std::fmt::{self, Display};

use alloy::primitives::Address;
use alloy::rpc::types::TransactionRequest;
use serde::de::{MapAccess, Visitor};
use serde::ser::SerializeSeq;
use serde::{Deserialize, Deserializer, Serialize};
use serde_json::Number;
use serde_json::Value;

use crate::cacao::Cacao;
use crate::error::Result;

#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum Id {
    String(String),
    Number(Number),
    U128(u128),
}

impl From<String> for Id {
    fn from(value: String) -> Self {
        Id::String(value)
    }
}

impl From<u128> for Id {
    fn from(value: u128) -> Self {
        Id::String(value.to_string())
    }
}

impl Id {
    #[allow(dead_code)]
    pub fn to_u128(&self) -> Result<u128> {
        match self {
            Id::String(s) => Ok(s.parse::<u128>()?),
            Id::Number(n) => n.as_u128().ok_or("number too big".into()),
            Id::U128(n) => Ok(*n),
        }
    }
}

impl PartialEq for Id {
    fn eq(&self, other: &Self) -> bool {
        self.to_u128().unwrap().eq(&other.to_u128().unwrap())
    }
}

#[derive(Clone, Debug, Serialize, Deserialize)]
pub struct JsonRpcRequest<ParamType = Value> {
    pub jsonrpc: String,
    pub method: JsonRpcMethod,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub params: Option<ParamType>,
    pub id: Id,
}

impl Display for JsonRpcRequest {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        write!(f, "{}", serde_json::to_string(self).unwrap())
    }
}

#[derive(Serialize, Deserialize, Debug)]
pub struct JsonRpcResponse<ResultType = Value> {
    #[allow(dead_code)]
    pub jsonrpc: String,
    #[serde(default)]
    pub result: Option<ResultType>,
    #[serde(default)]
    pub error: Option<JsonRpcError>,
    #[serde(default)]
    #[allow(dead_code)]
    pub id: Option<Id>,
}

#[derive(Serialize, Deserialize, Debug)]
#[allow(dead_code)]
pub struct JsonRpcError {
    code: i64,
    message: String,
    #[serde(default)]
    data: Option<Value>,
}

#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[repr(u16)]
#[serde(try_from = "u16", into = "u16")]
pub enum IrnTag {
    // https://specs.walletconnect.com/2.0/specs/clients/core/pairing/rpc-methods#methods
    UnsupportedMethod = 0,

    PairingDelete = 1000,
    PairingDeleteResponse = 1001,

    PairingPing = 1002,
    PairingPingResponse = 1003,

    PairingExtend = 1004,
    PairingExtendResponse = 1005,

    // https://specs.walletconnect.com/2.0/specs/clients/sign/rpc-methods#methods
    SessionPropose = 1100,
    SessionProposeApproveResponse = 1101,
    SessionProposeRejectResponse = 1120,
    SessionProposeAutoRejectResponse = 1121,

    SessionSettle = 1102,
    SessionSettleResponse = 1103,

    SessionUpdate = 1104,
    SessionUpdateResponse = 1105,

    SessionExtend = 1106,
    SessionExtendResponse = 1107,

    SessionRequest = 1108,
    SessionRequestResponse = 1109,

    SessionEvent = 1110,
    SessionEventResponse = 1111,

    SessionDelete = 1112,
    SessionDeleteResponse = 1113,

    SessionPing = 1114,
    SessionPingResponse = 1115,

    SessionAuthenticate = 1116,
    SessionAuthenticateApproveResponse = 1117,
    SessionAuthenticateRejectResponse = 1118,
    SessionAuthenticateAutoRejectResponse = 1119,
}

impl From<IrnTag> for u16 {
    fn from(tag: IrnTag) -> Self {
        tag as u16
    }
}

impl TryFrom<u16> for IrnTag {
    type Error = String;

    fn try_from(value: u16) -> Result<Self, Self::Error> {
        match value {
            0 => Ok(IrnTag::UnsupportedMethod),

            1000 => Ok(IrnTag::PairingDelete),
            1001 => Ok(IrnTag::PairingDeleteResponse),

            1002 => Ok(IrnTag::PairingPing),
            1003 => Ok(IrnTag::PairingPingResponse),

            1004 => Ok(IrnTag::PairingExtend),
            1005 => Ok(IrnTag::PairingExtendResponse),

            1100 => Ok(IrnTag::SessionPropose),
            1101 => Ok(IrnTag::SessionProposeApproveResponse),
            1120 => Ok(IrnTag::SessionProposeRejectResponse),
            1121 => Ok(IrnTag::SessionProposeAutoRejectResponse),

            1102 => Ok(IrnTag::SessionSettle),
            1103 => Ok(IrnTag::SessionSettleResponse),

            1104 => Ok(IrnTag::SessionUpdate),
            1105 => Ok(IrnTag::SessionUpdateResponse),

            1106 => Ok(IrnTag::SessionExtend),
            1107 => Ok(IrnTag::SessionExtendResponse),

            1108 => Ok(IrnTag::SessionRequest),
            1109 => Ok(IrnTag::SessionRequestResponse),

            1110 => Ok(IrnTag::SessionEvent),
            1111 => Ok(IrnTag::SessionEventResponse),

            1112 => Ok(IrnTag::SessionDelete),
            1113 => Ok(IrnTag::SessionDeleteResponse),

            1114 => Ok(IrnTag::SessionPing),
            1115 => Ok(IrnTag::SessionPingResponse),

            1116 => Ok(IrnTag::SessionAuthenticate),
            1117 => Ok(IrnTag::SessionAuthenticateApproveResponse),

            1118 => Ok(IrnTag::SessionAuthenticateRejectResponse),
            1119 => Ok(IrnTag::SessionAuthenticateAutoRejectResponse),

            _ => Err(format!("{:?}", crate::Error::InvalidIrnTag(value))),
        }
    }
}

#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
pub enum JsonRpcMethod {
    #[serde(rename = "irn_publish")]
    IrnPublish,

    #[serde(rename = "irn_subscribe")]
    IrnSubscribe,

    #[serde(rename = "irn_subscription")]
    IrnSubscription,

    #[serde(rename = "irn_fetchMessages")]
    IrnFetchMessages,
}

#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
pub struct IrnPublishParams {
    pub topic: String,
    pub message: String,
    pub ttl: u64,
    pub prompt: bool,
    pub tag: IrnTag,
}

#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
pub struct IrnSubscriptionParams {
    pub id: Id,
    pub data: IrnSubscriptionData,
}

#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
pub struct IrnSubscriptionData {
    pub topic: String,
    pub message: String,
    #[serde(rename = "publishedAt")]
    pub published_at: Id,
    pub tag: IrnTag,
}

#[derive(Debug, Default, Serialize, Deserialize)]
pub struct IrnFetchMessageResult {
    #[serde(rename = "hasMore")]
    pub has_more: bool,
    pub messages: Vec<EncryptedMessage>,
}

#[derive(Debug, Serialize, Deserialize)]
pub struct EncryptedMessage {
    pub topic: String,
    pub message: String,
    pub tag: u16,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub ttl: Option<u64>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub prompt: Option<bool>,
    #[serde(rename = "publishedAt")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub published_at: Option<u64>,
    // TODO verify this thing on every response
    #[serde(skip_serializing_if = "Option::is_none")]
    pub attestation: Option<String>,
}

impl EncryptedMessage {
    pub fn new(topic: String, message: String, tag: IrnTag, ttl: u64) -> Self {
        Self {
            topic,
            message,
            tag: tag as u16,
            ttl: Some(ttl),
            prompt: Some(false),
            published_at: None,
            attestation: None,
        }
    }
}

#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
pub struct SessionProposeParams {
    #[serde(rename = "requiredNamespaces")]
    pub required_namespaces: HashMap<String, Namespace>,
    #[serde(rename = "optionalNamespaces")]
    pub optional_namespaces: HashMap<String, Namespace>,
    pub relays: Vec<Relay>,
    #[serde(rename = "pairingTopic")]
    pub pairing_topic: String,
    pub proposer: Participant,
    #[serde(rename = "expiryTimestamp")]
    pub expiry_timestamp: u64,
}

#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
pub struct SessionProposeResponse {
    pub relay: Relay,
    #[serde(rename = "responderPublicKey")]
    pub responder_public_key: String,
}

#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
pub struct Namespace {
    #[serde(skip_serializing_if = "Option::is_none")]
    pub accounts: Option<Vec<String>>,
    pub chains: Vec<String>,
    pub events: Vec<String>,
    pub methods: Vec<String>,
}

#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
pub struct Relay {
    pub protocol: String,
}

#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
pub struct SessionAuthenticateParams {
    #[serde(rename = "authPayload")]
    pub auth_payload: AuthPayload,
    pub requester: Participant,
    #[serde(rename = "expiryTimestamp")]
    pub expiry_timestamp: u64,
}

#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
pub struct AuthPayload {
    #[serde(rename = "type")]
    pub payload_type: String,
    pub chains: Vec<String>,
    pub statement: String,
    pub aud: String,
    pub domain: String,
    pub version: String,
    pub nonce: String,
    pub iat: String,
    pub resources: Vec<String>,
}

#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
pub struct Participant {
    #[serde(rename = "publicKey")]
    pub public_key: String,
    pub metadata: Metadata,
}

#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
pub struct Metadata {
    pub name: String,
    pub description: String,
    pub url: String,
    pub icons: Vec<String>,
}

#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
pub struct SessionAuthenticateResponse {
    pub cacaos: Vec<Cacao>,
    pub responder: Participant,
}

#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
pub struct SessionSettleParams {
    pub controller: Participant,
    pub expiry: u64,
    pub namespaces: HashMap<String, Namespace>,
    pub relay: Relay,
    #[serde(rename = "sessionProperties")]
    pub session_properties: Option<SessionSettleProperties>,
}

#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
pub struct SessionSettleProperties {
    pub capabilities: String,
}

#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
pub struct SessionRequestParams {
    #[serde(rename = "sessionId")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub session_id: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub scope: Option<String>,
    pub request: SessionRequestObject,
    #[serde(rename = "chainId")]
    pub chain_id: String,
}

#[derive(Clone, Debug, Serialize, PartialEq)]
pub struct SessionRequestObject {
    pub method: SessionRequestMethod,
    pub params: SessionRequestData,
    #[serde(rename = "expiryTimestamp")]
    pub expiry_timestamp: u64,
}

#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
pub enum SessionRequestMethod {
    #[serde(rename = "personal_sign")]
    PersonalSign,
    #[serde(rename = "eth_sendTransaction")]
    EthSendTransaction,
    #[serde(rename = "eth_signTypedData_v4")]
    EthSignTypedDataV4,
}

#[derive(Clone, Debug, PartialEq)]
pub enum SessionRequestData {
    EthSendTransaction(Box<TransactionRequest>),
    PersonalSign { message: String, account: Address },
    EthSignTypedDataV4 { account: Address, typed_data: Value },
}

impl Serialize for SessionRequestData {
    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
    where
        S: serde::Serializer,
    {
        match self {
            SessionRequestData::EthSendTransaction(tx) => {
                let mut seq = serializer.serialize_seq(Some(1))?;
                seq.serialize_element(tx)?;
                seq.end()
            }
            SessionRequestData::PersonalSign { message, account } => {
                let mut seq = serializer.serialize_seq(Some(2))?;
                seq.serialize_element(&message)?;
                seq.serialize_element(&account)?;
                seq.end()
            }
            SessionRequestData::EthSignTypedDataV4 {
                account,
                typed_data,
            } => {
                let mut seq = serializer.serialize_seq(Some(2))?;
                seq.serialize_element(account)?;
                seq.serialize_element(typed_data)?;
                seq.end()
            }
        }
    }
}

impl<'de> Deserialize<'de> for SessionRequestObject {
    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
    where
        D: Deserializer<'de>,
    {
        #[derive(Deserialize)]
        #[serde(field_identifier, rename_all = "camelCase")]
        enum Field {
            Method,
            Params,
            ExpiryTimestamp,
        }

        struct SessionRequestVisitor;

        impl<'de> Visitor<'de> for SessionRequestVisitor {
            type Value = SessionRequestObject;

            fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
                formatter.write_str("SessionRequestObject with method, params, and expiryTimestamp")
            }

            fn visit_map<V>(
                self,
                mut map: V,
            ) -> Result<SessionRequestObject, V::Error>
            where
                V: MapAccess<'de>,
            {
                use serde_json::Value;

                let mut method: Option<SessionRequestMethod> = None;
                let mut raw_params: Option<Value> = None;
                let mut expiry: Option<u64> = None;

                while let Some(key) = map.next_key()? {
                    match key {
                        Field::Method => method = Some(map.next_value()?),
                        Field::Params => raw_params = Some(map.next_value()?),
                        Field::ExpiryTimestamp => {
                            expiry = Some(map.next_value()?)
                        }
                    }
                }

                let method = method
                    .ok_or_else(|| serde::de::Error::missing_field("method"))?;
                let raw_params = raw_params
                    .ok_or_else(|| serde::de::Error::missing_field("params"))?;
                let expiry = expiry.ok_or_else(|| {
                    serde::de::Error::missing_field("expiryTimestamp")
                })?;

                // Deserialize the params based on the method
                let params = match method {
                    SessionRequestMethod::EthSendTransaction => {
                        let tx: [Box<TransactionRequest>; 1] =
                            serde_json::from_value(raw_params)
                                .map_err(serde::de::Error::custom)?;
                        SessionRequestData::EthSendTransaction(tx[0].clone())
                    }
                    SessionRequestMethod::PersonalSign => {
                        let (message, account) =
                            serde_json::from_value(raw_params)
                                .map_err(serde::de::Error::custom)?;
                        SessionRequestData::PersonalSign { message, account }
                    }
                    SessionRequestMethod::EthSignTypedDataV4 => {
                        if let Ok((account, typed_data)) =
                            serde_json::from_value(raw_params.clone())
                        {
                            SessionRequestData::EthSignTypedDataV4 {
                                account,
                                typed_data,
                            }
                        } else {
                            // Fallback: second item is a string that itself is JSON
                            let (account, typed_data_str): (Address, String) =
                                serde_json::from_value(raw_params)
                                    .map_err(serde::de::Error::custom)?;
                            let typed_data: Value =
                                serde_json::from_str(&typed_data_str)
                                    .map_err(serde::de::Error::custom)?;
                            SessionRequestData::EthSignTypedDataV4 {
                                account,
                                typed_data,
                            }
                        }
                    }
                };

                Ok(SessionRequestObject {
                    method,
                    params,
                    expiry_timestamp: expiry,
                })
            }
        }

        deserializer.deserialize_map(SessionRequestVisitor)
    }
}

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn test_decode_id() {
        let result = serde_json::from_str::<Id>("\"1234\"").unwrap();
        println!("result {result:?}");

        let result = serde_json::from_str::<Id>("1234").unwrap();
        println!("result {result:?}");
    }

    #[test]
    fn test_decode_fetch_messages() {
        let resp = "{\"id\":1744205603590064025,\"jsonrpc\":\"2.0\",\"result\":{\"hasMore\":false,\"messages\":[{\"attestation\":\"eyJhbGciOiJFUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE3NDQyMDkxOTAsImlkIjoiZWRhYjVmMjQyNTNmZGUyYTVkYzI4NTcyZmRkNGE4NTViYTJhZjRkOGM2ZmQxMjQxN2NlMWUwNDMzODY5MjcwMCIsIm9yaWdpbiI6Imh0dHBzOi8vYXBwa2l0LWxhYi5yZW93bi5jb20iLCJpc1NjYW0iOmZhbHNlLCJpc1ZlcmlmaWVkIjp0cnVlfQ.zeNQehxpiQ0JqVBHTlkxgDwValU2NhGEsUMT5irJgiM92d1M361ifoxRIJfh1_EF2dVBqyr6zLV4cbp3g4jLSQ\",\"message\":\"ALW+zRyGiw5kj8hlp/Xv1jQ3vGFNcFNsfp4PyyVPbkcbMohD0sGhUejguhlNRA0fXnCfzQ9/hdI5xcmy1SubXts/Db6Kt1cStgOgIXSGReS3jP2AgldAv5WR77dfXDytJzYmg6af9lbKMYCuI+4qWyuaswKvsO4cyeRaT1jVsITT6uy+z2A50H0uBuNcnE4YGKia8yxlZYfLj0dbJ1Q/zX8d9DF/YLBQzUhLOD6P9ajCDUTNs7S24lDtB1xglkKHyxG4/cSktAGmvu7QWcYzkzeLmGcqxK7TxO3+N8baOMf4bq0n2tJjFCQPrs31d/mrQc1e7d7GwmndZjvbWRL+ab+B2INkfs6cEkLTtwu10TXGAScQCrrVtBR/apIiGFpg27YD+KbbM7hCmFoOIxJc1DXH8psf+MjDhwLqQRVxMe26DYbL50jwqQmDu71qvi4DHZgRyAq/wWSIHe+BGqfZKzK45zK7cz72WsZhuEjOqmDK0gZePbHzWaVvI9uApzpVXGVPOwp4eeZOBYbED+Oucq6CovHRjVIw0CZitjQH14yv0XNIFZ1U1/byB/jWgvQwW42O3v9M3cmljeXTeuEaao+b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T8LfEWM2DqWPZ+A65z6fHzVZh2TPuHaWt7mv2l+89SrHHqH6seyJRht5cswfDRPPuvjmy2cBsA9kCj2J/d0anCekc2CD7Od6NXd7swG2NwqCH5U9r2BaAOgEzaa2kP0BTDLU42Y4KdU+NXeeUNhPbXbucsCRKv3SYaDw==\",\"publishedAt\":1744205591323,\"tag\":1116,\"topic\":\"74818ca920a949b9adad9ed0c5bdfa1f5e6ea5e5b1a18e71a7ba1ac9923295e5\"}]}}";
        let result = serde_json::from_str::<
            JsonRpcResponse<IrnFetchMessageResult>,
        >(resp)
        .unwrap();
        println!("result {result:?}");
    }
}