Skip to content

Commit b4683d7

Browse files
authored
feat: add message id to watch event payload (#57)
1 parent d2a772f commit b4683d7

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

relay_rpc/src/rpc/watch.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use {
22
crate::{
3-
domain::Topic,
3+
domain::{MessageId, Topic},
44
jwt::{JwtBasicClaims, VerifyableClaims},
55
},
66
serde::{Deserialize, Serialize},
@@ -77,6 +77,8 @@ impl VerifyableClaims for WatchUnregisterClaims {
7777
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
7878
#[serde(rename_all = "camelCase")]
7979
pub struct WatchEventPayload {
80+
/// Message ID.
81+
pub message_id: MessageId,
8082
/// Webhook status. Either `accepted`, `queued` or `delivered`.
8183
pub status: WatchStatus,
8284
/// Topic of the message that triggered the watch event.
@@ -220,6 +222,7 @@ mod test {
220222
whu: "https://example.com".to_owned(),
221223
typ: WatchType::Subscriber,
222224
evt: WatchEventPayload {
225+
message_id: 12345678.into(),
223226
status: WatchStatus::Accepted,
224227
topic,
225228
message: Arc::from("test message"),
@@ -232,7 +235,7 @@ mod test {
232235
// lowercase.
233236
assert_eq!(
234237
serde_json::to_string(&claims).unwrap(),
235-
r#"{"iss":"did:key:z6Mku3wsRZTAHjr6xrYWVUfyGeNSNz1GJRVfazp3N76AL9gE","aud":"wss://relay.walletconnect.com","sub":"https://example.com","iat":946684800,"exp":32503680000,"act":"irn_watchEvent","typ":"subscriber","whu":"https://example.com","evt":{"status":"accepted","topic":"474e88153f4db893de42c35e1891dc0e37a02e11961385de0475460fb48b8639","message":"test message","publishedAt":946684800,"tag":1100}}"#
238+
r#"{"iss":"did:key:z6Mku3wsRZTAHjr6xrYWVUfyGeNSNz1GJRVfazp3N76AL9gE","aud":"wss://relay.walletconnect.com","sub":"https://example.com","iat":946684800,"exp":32503680000,"act":"irn_watchEvent","typ":"subscriber","whu":"https://example.com","evt":{"messageId":12345678,"status":"accepted","topic":"474e88153f4db893de42c35e1891dc0e37a02e11961385de0475460fb48b8639","message":"test message","publishedAt":946684800,"tag":1100}}"#
236239
);
237240

238241
// Verify that the claims can be encoded and decoded correctly.

0 commit comments

Comments
 (0)