v0.2.4-pre.002-fix.001

This commit is contained in:
2026-08-18 20:21:01 +02:00
parent cf8d79567d
commit 033800f897
4 changed files with 196 additions and 4 deletions

View File

@@ -1,5 +1,5 @@
// file: crates/ksp-onchain-transport-lib/src/rpc_blocks.rs
// version: 1
// version: 2
/// Transaction detail level accepted by modern `getBlock` requests.
#[derive(Clone, Copy, Debug, Default, Eq, Hash, PartialEq)]
@@ -82,6 +82,7 @@ impl SolanaGetBlockConfig {
}
/// Returns whether this config would serialize to an empty object.
#[cfg(test)]
pub(crate) const fn is_empty(&self) -> bool {
return self.commitment.is_none()
&& self.encoding.is_none()
@@ -92,6 +93,7 @@ impl SolanaGetBlockConfig {
/// Serializes this config to the exact Solana JSON-RPC object.
#[must_use]
#[cfg(test)]
pub(crate) fn to_json_value(self) -> serde_json::Value {
let mut object = serde_json::Map::new();
if let std::option::Option::Some(commitment) = self.commitment {
@@ -141,6 +143,7 @@ impl SolanaBlockProductionRange {
/// Serializes this range to the exact Solana JSON-RPC object.
#[must_use]
#[cfg(test)]
pub(crate) fn to_json_value(self) -> serde_json::Value {
let mut object = serde_json::Map::new();
object.insert("firstSlot".to_owned(), serde_json::Value::Number(self.first_slot.into()));
@@ -189,12 +192,14 @@ impl SolanaBlockProductionConfig {
}
/// Returns whether this config would serialize to an empty object.
#[cfg(test)]
pub(crate) const fn is_empty(&self) -> bool {
return self.commitment.is_none() && self.identity.is_none() && self.range.is_none();
}
/// Serializes this config to the exact Solana JSON-RPC object.
#[must_use]
#[cfg(test)]
pub(crate) fn to_json_value(&self) -> serde_json::Value {
let mut object = serde_json::Map::new();
if let std::option::Option::Some(commitment) = self.commitment {
@@ -231,6 +236,7 @@ impl SolanaBlockCommitment {
}
/// Decodes a block-commitment result from its Solana JSON wire shape.
#[cfg(test)]
pub(crate) fn decode_wire(method: &str, value: serde_json::Value) -> ksp_core_lib::Result<Self> {
let decoded = crate::decode_wire_json::<WireBlockCommitment>(method, value);
return match decoded {
@@ -282,6 +288,7 @@ impl SolanaBlockProduction {
}
/// Decodes a block-production result from its Solana JSON wire shape.
#[cfg(test)]
pub(crate) fn decode_wire(method: &str, value: serde_json::Value) -> ksp_core_lib::Result<Self> {
let decoded = crate::decode_wire_json::<WireBlockProduction>(method, value);
let wire = match decoded {
@@ -352,6 +359,7 @@ impl SolanaBlockReward {
return &self.commission_bps;
}
#[cfg(test)]
fn decode_wire(method: &str, value: serde_json::Value) -> ksp_core_lib::Result<Self> {
let decoded = crate::decode_wire_json::<WireBlockReward>(method, value);
let wire = match decoded {
@@ -400,6 +408,7 @@ impl SolanaBlockTransaction {
return &self.version;
}
#[cfg(test)]
fn decode_wire(method: &str, value: serde_json::Value) -> ksp_core_lib::Result<Self> {
let decoded = crate::decode_wire_json::<WireBlockTransaction>(method, value);
let wire = match decoded {
@@ -489,6 +498,7 @@ impl SolanaConfirmedBlock {
}
/// Decodes a confirmed block from its Solana JSON wire shape.
#[cfg(test)]
pub(crate) fn decode_wire(method: &str, value: serde_json::Value) -> ksp_core_lib::Result<Self> {
let decoded = crate::decode_wire_json::<WireConfirmedBlock>(method, value);
let wire = match decoded {
@@ -561,6 +571,7 @@ impl SolanaPerformanceSample {
}
/// Decodes one performance sample from its Solana JSON wire shape.
#[cfg(test)]
pub(crate) fn decode_wire(method: &str, value: serde_json::Value) -> ksp_core_lib::Result<Self> {
let decoded = crate::decode_wire_json::<WirePerformanceSample>(method, value);
return match decoded {
@@ -576,6 +587,7 @@ impl SolanaPerformanceSample {
}
}
#[cfg(test)]
fn decode_block_transaction_version(
method: &str,
field: crate::SolanaWireField<serde_json::Value>,
@@ -593,6 +605,7 @@ fn decode_block_transaction_version(
};
}
#[cfg(test)]
fn decode_block_transactions(
method: &str,
field: crate::SolanaWireField<std::vec::Vec<serde_json::Value>>,
@@ -613,6 +626,7 @@ fn decode_block_transactions(
return std::result::Result::Ok(crate::SolanaWireField::Value(transactions));
}
#[cfg(test)]
fn decode_block_rewards(
method: &str,
field: crate::SolanaWireField<std::vec::Vec<serde_json::Value>>,
@@ -633,6 +647,7 @@ fn decode_block_rewards(
return std::result::Result::Ok(crate::SolanaWireField::Value(rewards));
}
#[cfg(test)]
#[derive(serde::Deserialize)]
#[serde(rename_all = "camelCase")]
struct WireBlockCommitment {
@@ -640,6 +655,7 @@ struct WireBlockCommitment {
total_stake: u64,
}
#[cfg(test)]
#[derive(serde::Deserialize)]
#[serde(rename_all = "camelCase")]
struct WireBlockProductionRange {
@@ -647,6 +663,7 @@ struct WireBlockProductionRange {
last_slot: u64,
}
#[cfg(test)]
#[derive(serde::Deserialize)]
#[serde(rename_all = "camelCase")]
struct WireBlockProduction {
@@ -654,6 +671,7 @@ struct WireBlockProduction {
range: WireBlockProductionRange,
}
#[cfg(test)]
#[derive(serde::Deserialize)]
#[serde(rename_all = "camelCase")]
struct WireBlockReward {
@@ -668,6 +686,7 @@ struct WireBlockReward {
commission_bps: crate::SolanaWireField<u16>,
}
#[cfg(test)]
#[derive(serde::Deserialize)]
#[serde(rename_all = "camelCase")]
struct WireBlockTransaction {
@@ -678,6 +697,7 @@ struct WireBlockTransaction {
version: crate::SolanaWireField<serde_json::Value>,
}
#[cfg(test)]
#[derive(serde::Deserialize)]
#[serde(rename_all = "camelCase")]
struct WireConfirmedBlock {
@@ -696,6 +716,7 @@ struct WireConfirmedBlock {
block_height: std::option::Option<u64>,
}
#[cfg(test)]
#[derive(serde::Deserialize)]
#[serde(rename_all = "camelCase")]
struct WirePerformanceSample {

View File

@@ -1,5 +1,5 @@
// file: crates/ksp-onchain-transport-lib/src/rpc_economics.rs
// version: 1
// version: 2
/// Inflation-governor values returned by `getInflationGovernor`.
#[derive(Clone, Copy, Debug, PartialEq)]
@@ -43,6 +43,7 @@ impl SolanaInflationGovernor {
}
/// Decodes an inflation-governor result from its Solana JSON wire shape.
#[cfg(test)]
pub(crate) fn decode_wire(method: &str, value: serde_json::Value) -> ksp_core_lib::Result<Self> {
let decoded = crate::decode_wire_json::<WireInflationGovernor>(method, value);
return match decoded {
@@ -93,6 +94,7 @@ impl SolanaInflationRate {
}
/// Decodes an inflation-rate result from its Solana JSON wire shape.
#[cfg(test)]
pub(crate) fn decode_wire(method: &str, value: serde_json::Value) -> ksp_core_lib::Result<Self> {
let decoded = crate::decode_wire_json::<WireInflationRate>(method, value);
return match decoded {
@@ -142,12 +144,14 @@ impl SolanaInflationRewardConfig {
}
/// Returns whether this config would serialize to an empty object.
#[cfg(test)]
pub(crate) const fn is_empty(&self) -> bool {
return self.epoch.is_none() && self.commitment.is_none() && self.min_context_slot.is_none();
}
/// Serializes this config to the exact Solana JSON-RPC object.
#[must_use]
#[cfg(test)]
pub(crate) fn to_json_value(self) -> serde_json::Value {
let mut object = serde_json::Map::new();
if let std::option::Option::Some(epoch) = self.epoch {
@@ -212,6 +216,7 @@ impl SolanaInflationReward {
}
/// Decodes one non-null inflation reward from its Solana JSON wire shape.
#[cfg(test)]
pub(crate) fn decode_wire(method: &str, value: serde_json::Value) -> ksp_core_lib::Result<Self> {
let decoded = crate::decode_wire_json::<WireInflationReward>(method, value);
return match decoded {
@@ -255,12 +260,14 @@ impl SolanaSupplyConfig {
}
/// Returns whether this config would serialize to an empty object.
#[cfg(test)]
pub(crate) const fn is_empty(&self) -> bool {
return self.commitment.is_none() && self.exclude_non_circulating_accounts_list.is_none();
}
/// Serializes this config to the exact Solana JSON-RPC object.
#[must_use]
#[cfg(test)]
pub(crate) fn to_json_value(self) -> serde_json::Value {
let mut object = serde_json::Map::new();
if let std::option::Option::Some(commitment) = self.commitment {
@@ -308,6 +315,7 @@ impl SolanaSupply {
}
/// Decodes a supply result from its Solana JSON wire shape.
#[cfg(test)]
pub(crate) fn decode_wire(method: &str, value: serde_json::Value) -> ksp_core_lib::Result<Self> {
let decoded = crate::decode_wire_json::<WireSupply>(method, value);
let wire = match decoded {
@@ -331,6 +339,7 @@ impl SolanaSupply {
}
}
#[cfg(test)]
#[derive(serde::Deserialize)]
#[serde(rename_all = "camelCase")]
struct WireInflationGovernor {
@@ -341,6 +350,7 @@ struct WireInflationGovernor {
foundation_term: f64,
}
#[cfg(test)]
#[derive(serde::Deserialize)]
#[serde(rename_all = "camelCase")]
struct WireInflationRate {
@@ -350,6 +360,7 @@ struct WireInflationRate {
epoch: u64,
}
#[cfg(test)]
#[derive(serde::Deserialize)]
#[serde(rename_all = "camelCase")]
struct WireInflationReward {
@@ -363,6 +374,7 @@ struct WireInflationReward {
commission_bps: crate::SolanaWireField<u16>,
}
#[cfg(test)]
#[derive(serde::Deserialize)]
#[serde(rename_all = "camelCase")]
struct WireSupply {