Skip to content

Commit

Permalink
fix: rename new fields
Browse files Browse the repository at this point in the history
  • Loading branch information
heilhead committed Jan 20, 2025
1 parent 7ef7422 commit 40d5c39
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 32 deletions.
5 changes: 2 additions & 3 deletions relay_client/src/http.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
use {
crate::{
error::{BoxError, ClientError, Error},
ConnectionOptions,
MessageIdGenerator,
ConnectionOptions, MessageIdGenerator,
},
http::{HeaderMap, StatusCode},
relay_rpc::{
Expand Down Expand Up @@ -125,7 +124,7 @@ impl Client {
ttl_secs,
tag,
prompt,
tvf_data: None,
analytics: None,
})
.await
.map(|_| ())
Expand Down
23 changes: 5 additions & 18 deletions relay_client/src/websocket.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,9 @@ use {
relay_rpc::{
domain::{MessageId, SubscriptionId, Topic},
rpc::{
BatchFetchMessages,
BatchReceiveMessages,
BatchSubscribe,
BatchSubscribeBlocking,
BatchUnsubscribe,
FetchMessages,
Publish,
Receipt,
Subscribe,
SubscribeBlocking,
Subscription,
SubscriptionError,
Unsubscribe,
BatchFetchMessages, BatchReceiveMessages, BatchSubscribe, BatchSubscribeBlocking,
BatchUnsubscribe, FetchMessages, Publish, Receipt, Subscribe, SubscribeBlocking,
Subscription, SubscriptionError, Unsubscribe,
},
},
std::{future::Future, sync::Arc, time::Duration},
Expand All @@ -29,10 +19,7 @@ use {
},
};
pub use {
fetch::*,
inbound::*,
outbound::*,
stream::*,
fetch::*, inbound::*, outbound::*, stream::*,
tokio_tungstenite::tungstenite::protocol::CloseFrame,
};

Expand Down Expand Up @@ -168,7 +155,7 @@ impl Client {
ttl_secs: ttl.as_secs() as u32,
tag,
prompt,
tvf_data: None,
analytics: None,
});

self.request(request);
Expand Down
6 changes: 3 additions & 3 deletions relay_rpc/src/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -528,7 +528,7 @@ impl ServiceRequest for BatchReceiveMessages {

#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct TvfData {
pub struct AnalyticsData {
pub correlation_id: Option<Arc<str>>,
pub chain_id: Option<Arc<str>>,
pub rpc_methods: Option<Vec<Arc<str>>>,
Expand Down Expand Up @@ -563,7 +563,7 @@ pub struct Publish {
pub prompt: bool,

#[serde(default, flatten, skip_serializing_if = "is_default")]
pub tvf_data: Option<TvfData>,
pub analytics: Option<AnalyticsData>,
}

impl Publish {
Expand Down Expand Up @@ -882,7 +882,7 @@ impl Request {

pub fn strip_analytics(&mut self) {
if let Params::Publish(params) = &mut self.params {
params.tvf_data = None;
params.analytics = None;
}
}
}
18 changes: 10 additions & 8 deletions relay_rpc/src/rpc/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ fn request() {
ttl_secs: 12,
tag: 0,
prompt: false,
tvf_data: Some(TvfData {
analytics: Some(AnalyticsData {
correlation_id: Some("correlation_id".into()),
chain_id: Some("chain_id".into()),
rpc_methods: Some(vec!["rpc_method".into()]),
Expand Down Expand Up @@ -75,12 +75,14 @@ fn response_result() {

#[test]
fn response_error() {
let payload: Payload =
Payload::Response(Response::Error(ErrorResponse::new(1.into(), ErrorData {
let payload: Payload = Payload::Response(Response::Error(ErrorResponse::new(
1.into(),
ErrorData {
code: 32,
data: None,
message: "some message".into(),
})));
},
)));

let serialized = serde_json::to_string(&payload).unwrap();

Expand Down Expand Up @@ -301,7 +303,7 @@ fn validation() {
ttl_secs: 0,
tag: 0,
prompt: false,
tvf_data: None,
analytics: None,
}),
};
assert_eq!(request.validate(), Err(PayloadError::InvalidRequestId));
Expand All @@ -317,7 +319,7 @@ fn validation() {
ttl_secs: 0,
tag: 0,
prompt: false,
tvf_data: None,
analytics: None,
}),
};
assert_eq!(request.validate(), Err(PayloadError::InvalidJsonRpcVersion));
Expand All @@ -333,7 +335,7 @@ fn validation() {
ttl_secs: 0,
tag: 0,
prompt: false,
tvf_data: None,
analytics: None,
}),
};
assert_eq!(request.validate(), Ok(()));
Expand All @@ -349,7 +351,7 @@ fn validation() {
ttl_secs: 0,
tag: 0,
prompt: false,
tvf_data: None,
analytics: None,
}),
};
assert_eq!(request.validate(), Err(PayloadError::InvalidTopic));
Expand Down

0 comments on commit 40d5c39

Please sign in to comment.