v0.2.11-pre.004

This commit is contained in:
2026-08-25 21:47:47 +02:00
parent f4413ebbb0
commit 60afb51451
23 changed files with 1862 additions and 117 deletions

View File

@@ -1,5 +1,5 @@
// file: crates/ksp-offchain-transport-lib/src/market_price_decimal.rs
// version: 3
// version: 4
/// Maximum accepted UTF-8 byte length for one textual decimal input.
pub const MARKET_PRICE_DECIMAL_MAX_INPUT_BYTES: usize = 96;
@@ -63,6 +63,19 @@ impl MarketPriceDecimal {
return std::result::Result::Ok(Self { coefficient, scale });
}
/// Parses one provider JSON number or string while preserving the original numeric lexeme.
pub(crate) fn parse_json_raw(raw: &serde_json::value::RawValue) -> ksp_core_lib::Result<Self> {
let source = raw.get();
if source.starts_with('"') {
let decoded = match serde_json::from_str::<std::string::String>(source) {
std::result::Result::Ok(value) => value,
std::result::Result::Err(_) => return std::result::Result::Err(invalid_decimal_error()),
};
return crate::MarketPriceDecimal::parse(decoded.as_str());
}
return crate::MarketPriceDecimal::parse(source);
}
/// Returns the normalized integer coefficient.
#[must_use]
pub const fn coefficient(&self) -> u128 {