0.7.25
This commit is contained in:
@@ -73,9 +73,9 @@ pub fn parse_kb_solana_ws_typed_notification(
|
||||
>(notification.params.result.clone());
|
||||
return match parse_result {
|
||||
Ok(value) => Ok(KbSolanaWsTypedNotification::Logs(value)),
|
||||
Err(error) => Err(crate::KbError::Json(format!(
|
||||
"cannot parse logsNotification payload: {error}"
|
||||
))),
|
||||
Err(error) => {
|
||||
Err(crate::KbError::Json(format!("cannot parse logsNotification payload: {error}")))
|
||||
},
|
||||
};
|
||||
}
|
||||
if notification.method == "programNotification" {
|
||||
@@ -119,9 +119,9 @@ pub fn parse_kb_solana_ws_typed_notification(
|
||||
);
|
||||
return match parse_result {
|
||||
Ok(value) => Ok(KbSolanaWsTypedNotification::Slot(value)),
|
||||
Err(error) => Err(crate::KbError::Json(format!(
|
||||
"cannot parse slotNotification payload: {error}"
|
||||
))),
|
||||
Err(error) => {
|
||||
Err(crate::KbError::Json(format!("cannot parse slotNotification payload: {error}")))
|
||||
},
|
||||
};
|
||||
}
|
||||
if notification.method == "slotsUpdatesNotification" {
|
||||
@@ -141,15 +141,15 @@ pub fn parse_kb_solana_ws_typed_notification(
|
||||
);
|
||||
return match parse_result {
|
||||
Ok(value) => Ok(KbSolanaWsTypedNotification::Vote(value)),
|
||||
Err(error) => Err(crate::KbError::Json(format!(
|
||||
"cannot parse voteNotification payload: {error}"
|
||||
))),
|
||||
Err(error) => {
|
||||
Err(crate::KbError::Json(format!("cannot parse voteNotification payload: {error}")))
|
||||
},
|
||||
};
|
||||
}
|
||||
Err(crate::KbError::Json(format!(
|
||||
return Err(crate::KbError::Json(format!(
|
||||
"unsupported Solana websocket notification method '{}'",
|
||||
notification.method
|
||||
)))
|
||||
)));
|
||||
}
|
||||
|
||||
/// Parses a typed Solana PubSub notification from a generic websocket event.
|
||||
@@ -165,29 +165,29 @@ pub fn parse_kb_solana_ws_typed_notification_from_event(
|
||||
crate::WsEvent::SubscriptionNotification { notification, .. } => {
|
||||
let parse_result = parse_kb_solana_ws_typed_notification(notification);
|
||||
match parse_result {
|
||||
Ok(value) => Ok(Some(value)),
|
||||
Err(error) => Err(error),
|
||||
Ok(value) => return Ok(Some(value)),
|
||||
Err(error) => return Err(error),
|
||||
}
|
||||
}
|
||||
},
|
||||
crate::WsEvent::JsonRpcNotificationWithoutSubscription { notification, .. } => {
|
||||
let parse_result = parse_kb_solana_ws_typed_notification(notification);
|
||||
match parse_result {
|
||||
Ok(value) => Ok(Some(value)),
|
||||
Err(error) => Err(error),
|
||||
Ok(value) => return Ok(Some(value)),
|
||||
Err(error) => return Err(error),
|
||||
}
|
||||
}
|
||||
},
|
||||
crate::WsEvent::JsonRpcMessage { message, .. } => match message {
|
||||
crate::KbJsonRpcWsIncomingMessage::Notification(notification) => {
|
||||
let parse_result = parse_kb_solana_ws_typed_notification(notification);
|
||||
match parse_result {
|
||||
Ok(value) => Ok(Some(value)),
|
||||
Err(error) => Err(error),
|
||||
Ok(value) => return Ok(Some(value)),
|
||||
Err(error) => return Err(error),
|
||||
}
|
||||
}
|
||||
crate::KbJsonRpcWsIncomingMessage::SuccessResponse(_) => Ok(None),
|
||||
crate::KbJsonRpcWsIncomingMessage::ErrorResponse(_) => Ok(None),
|
||||
},
|
||||
crate::KbJsonRpcWsIncomingMessage::SuccessResponse(_) => return Ok(None),
|
||||
crate::KbJsonRpcWsIncomingMessage::ErrorResponse(_) => return Ok(None),
|
||||
},
|
||||
_ => Ok(None),
|
||||
_ => return Ok(None),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -204,7 +204,7 @@ impl crate::WsClient {
|
||||
Ok(config_value) => config_value,
|
||||
Err(error) => return Err(error),
|
||||
};
|
||||
self.account_subscribe_raw(pubkey, config_value).await
|
||||
return self.account_subscribe_raw(pubkey, config_value).await;
|
||||
}
|
||||
|
||||
/// Typed helper for `blockSubscribe`.
|
||||
@@ -224,7 +224,7 @@ impl crate::WsClient {
|
||||
Ok(config_value) => config_value,
|
||||
Err(error) => return Err(error),
|
||||
};
|
||||
self.block_subscribe_raw(filter_value, config_value).await
|
||||
return self.block_subscribe_raw(filter_value, config_value).await;
|
||||
}
|
||||
|
||||
/// Typed helper for `logsSubscribe`.
|
||||
@@ -244,7 +244,7 @@ impl crate::WsClient {
|
||||
Ok(config_value) => config_value,
|
||||
Err(error) => return Err(error),
|
||||
};
|
||||
self.logs_subscribe_raw(filter_value, config_value).await
|
||||
return self.logs_subscribe_raw(filter_value, config_value).await;
|
||||
}
|
||||
|
||||
/// Typed helper for `programSubscribe`.
|
||||
@@ -259,7 +259,7 @@ impl crate::WsClient {
|
||||
Ok(config_value) => config_value,
|
||||
Err(error) => return Err(error),
|
||||
};
|
||||
self.program_subscribe_raw(program_id, config_value).await
|
||||
return self.program_subscribe_raw(program_id, config_value).await;
|
||||
}
|
||||
|
||||
/// Typed helper for `signatureSubscribe`.
|
||||
@@ -274,7 +274,7 @@ impl crate::WsClient {
|
||||
Ok(config_value) => config_value,
|
||||
Err(error) => return Err(error),
|
||||
};
|
||||
self.signature_subscribe_raw(signature, config_value).await
|
||||
return self.signature_subscribe_raw(signature, config_value).await;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -287,11 +287,10 @@ where
|
||||
{
|
||||
let value_result = serde_json::to_value(value);
|
||||
match value_result {
|
||||
Ok(value) => Ok(value),
|
||||
Err(error) => Err(crate::KbError::Json(format!(
|
||||
"cannot serialize {}: {error}",
|
||||
label
|
||||
))),
|
||||
Ok(value) => return Ok(value),
|
||||
Err(error) => {
|
||||
return Err(crate::KbError::Json(format!("cannot serialize {}: {error}", label)));
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -306,14 +305,16 @@ where
|
||||
Some(value) => {
|
||||
let value_result = serde_json::to_value(value);
|
||||
match value_result {
|
||||
Ok(value) => Ok(Some(value)),
|
||||
Err(error) => Err(crate::KbError::Json(format!(
|
||||
"cannot serialize {}: {error}",
|
||||
label
|
||||
))),
|
||||
Ok(value) => return Ok(Some(value)),
|
||||
Err(error) => {
|
||||
return Err(crate::KbError::Json(format!(
|
||||
"cannot serialize {}: {error}",
|
||||
label
|
||||
)));
|
||||
},
|
||||
}
|
||||
}
|
||||
None => Ok(None),
|
||||
},
|
||||
None => return Ok(None),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -335,7 +336,7 @@ mod tests {
|
||||
event_channel_capacity: 32,
|
||||
auto_reconnect: false,
|
||||
};
|
||||
crate::WsClient::new(endpoint).expect("client creation must succeed")
|
||||
return crate::WsClient::new(endpoint).expect("client creation must succeed");
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -353,10 +354,10 @@ mod tests {
|
||||
match parsed {
|
||||
crate::KbSolanaWsTypedNotification::Root(root) => {
|
||||
assert_eq!(root, 123);
|
||||
}
|
||||
},
|
||||
other => {
|
||||
panic!("unexpected parsed notification: {other:?}");
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -382,10 +383,10 @@ mod tests {
|
||||
assert_eq!(slot_info.parent, 10);
|
||||
assert_eq!(slot_info.root, 11);
|
||||
assert_eq!(slot_info.slot, 12);
|
||||
}
|
||||
},
|
||||
other => {
|
||||
panic!("unexpected parsed notification: {other:?}");
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -396,10 +397,10 @@ mod tests {
|
||||
.account_subscribe_typed("11111111111111111111111111111111".to_string(), None)
|
||||
.await;
|
||||
match result {
|
||||
Err(crate::KbError::NotConnected(_)) => {}
|
||||
Err(crate::KbError::NotConnected(_)) => {},
|
||||
other => {
|
||||
panic!("unexpected result: {other:?}");
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -413,10 +414,10 @@ mod tests {
|
||||
)
|
||||
.await;
|
||||
match result {
|
||||
Err(crate::KbError::NotConnected(_)) => {}
|
||||
Err(crate::KbError::NotConnected(_)) => {},
|
||||
other => {
|
||||
panic!("unexpected result: {other:?}");
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user