v0.2.11-pre.004-fix.001
This commit is contained in:
@@ -1,10 +1,10 @@
|
||||
// file: crates/ksp-offchain-transport-lib/src/error.rs
|
||||
// version: 6
|
||||
// version: 7
|
||||
|
||||
/// Stable off-chain transport error when local provider admission defers a request.
|
||||
pub const ERROR_CODE_HTTP_ADMISSION_DEFERRED: ksp_core_lib::ErrorCode = ksp_core_lib::ErrorCode::new("offchain_transport", "http_admission_deferred");
|
||||
/// Stable off-chain transport error for HTTP 401/403 access denial.
|
||||
pub const ERROR_CODE_HTTP_ACCESS_DENIED: ksp_core_lib::ErrorCode = ksp_core_lib::ErrorCode::new("offchain_transport", "http_access_denied");
|
||||
/// Stable off-chain transport error when local provider admission defers a request.
|
||||
pub const ERROR_CODE_HTTP_ADMISSION_DEFERRED: ksp_core_lib::ErrorCode = ksp_core_lib::ErrorCode::new("offchain_transport", "http_admission_deferred");
|
||||
/// Stable off-chain transport error when the hardened reqwest client cannot be initialized.
|
||||
pub const ERROR_CODE_HTTP_CLIENT_BUILD_FAILED: ksp_core_lib::ErrorCode = ksp_core_lib::ErrorCode::new("offchain_transport", "http_client_build_failed");
|
||||
/// Stable off-chain transport error for a connection failure without exposing the provider URL.
|
||||
@@ -29,15 +29,15 @@ pub const ERROR_CODE_HTTP_TEMPORARY_FAILURE: ksp_core_lib::ErrorCode = ksp_core_
|
||||
pub const ERROR_CODE_HTTP_TIMEOUT: ksp_core_lib::ErrorCode = ksp_core_lib::ErrorCode::new("offchain_transport", "http_timeout");
|
||||
/// Stable off-chain transport error for an invalid exact market-price decimal.
|
||||
pub const ERROR_CODE_MARKET_PRICE_DECIMAL_INVALID: ksp_core_lib::ErrorCode = ksp_core_lib::ErrorCode::new("offchain_transport", "market_price_decimal_invalid");
|
||||
/// Stable off-chain transport error when a disabled market-price provider is invoked directly.
|
||||
pub const ERROR_CODE_MARKET_PRICE_PROVIDER_DISABLED: ksp_core_lib::ErrorCode =
|
||||
ksp_core_lib::ErrorCode::new("offchain_transport", "market_price_provider_disabled");
|
||||
/// Stable off-chain transport error for an invalid normalized market-price observation.
|
||||
pub const ERROR_CODE_MARKET_PRICE_OBSERVATION_INVALID: ksp_core_lib::ErrorCode =
|
||||
ksp_core_lib::ErrorCode::new("offchain_transport", "market_price_observation_invalid");
|
||||
/// Stable off-chain transport error for an invalid market-price provider descriptor.
|
||||
pub const ERROR_CODE_MARKET_PRICE_PROVIDER_DESCRIPTOR_INVALID: ksp_core_lib::ErrorCode =
|
||||
ksp_core_lib::ErrorCode::new("offchain_transport", "market_price_provider_descriptor_invalid");
|
||||
/// Stable off-chain transport error when a disabled market-price provider is invoked directly.
|
||||
pub const ERROR_CODE_MARKET_PRICE_PROVIDER_DISABLED: ksp_core_lib::ErrorCode =
|
||||
ksp_core_lib::ErrorCode::new("offchain_transport", "market_price_provider_disabled");
|
||||
/// Stable off-chain transport error for an invalid market-price provider identifier.
|
||||
pub const ERROR_CODE_MARKET_PRICE_PROVIDER_ID_INVALID: ksp_core_lib::ErrorCode =
|
||||
ksp_core_lib::ErrorCode::new("offchain_transport", "market_price_provider_id_invalid");
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// file: crates/ksp-offchain-transport-lib/src/market_price_coingecko.rs
|
||||
// version: 1
|
||||
// version: 2
|
||||
|
||||
//! CoinGecko SOL/USD market-price adapter using the official REST API directly through `reqwest`.
|
||||
|
||||
@@ -158,10 +158,10 @@ fn build_request(settings: &crate::MarketPriceCoinGeckoSettings) -> ksp_core_lib
|
||||
request.append_query_pair("ids", "solana");
|
||||
request.append_query_pair("vs_currencies", "usd");
|
||||
request.append_query_pair("include_last_updated_at", "true");
|
||||
if let std::option::Option::Some(api_key) = settings.api_key() {
|
||||
if let std::result::Result::Err(error) = request.insert_sensitive_header(COINGECKO_DEMO_API_KEY_HEADER, api_key.as_str()) {
|
||||
return std::result::Result::Err(error);
|
||||
}
|
||||
if let std::option::Option::Some(api_key) = settings.api_key()
|
||||
&& let std::result::Result::Err(error) = request.insert_sensitive_header(COINGECKO_DEMO_API_KEY_HEADER, api_key.as_str())
|
||||
{
|
||||
return std::result::Result::Err(error);
|
||||
}
|
||||
return std::result::Result::Ok(request);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// file: crates/ksp-offchain-transport-lib/src/market_price_coinmarketcap.rs
|
||||
// version: 1
|
||||
// version: 2
|
||||
|
||||
//! CoinMarketCap SOL/USD market-price adapter using the current Simple Price V2 REST surface.
|
||||
|
||||
@@ -168,10 +168,10 @@ fn build_request(settings: &crate::MarketPriceCoinMarketCapSettings) -> ksp_core
|
||||
request.append_query_pair("ids", "5426");
|
||||
request.append_query_pair("convert", "USD");
|
||||
request.append_query_pair("include_last_updated", "true");
|
||||
if let std::option::Option::Some(api_key) = settings.api_key() {
|
||||
if let std::result::Result::Err(error) = request.insert_sensitive_header(COINMARKETCAP_API_KEY_HEADER, api_key.as_str()) {
|
||||
return std::result::Result::Err(error);
|
||||
}
|
||||
if let std::option::Option::Some(api_key) = settings.api_key()
|
||||
&& let std::result::Result::Err(error) = request.insert_sensitive_header(COINMARKETCAP_API_KEY_HEADER, api_key.as_str())
|
||||
{
|
||||
return std::result::Result::Err(error);
|
||||
}
|
||||
return std::result::Result::Ok(request);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// file: crates/ksp-offchain-transport-lib/unit_tests/market_price_coinmarketcap.rs
|
||||
// version: 1
|
||||
// version: 2
|
||||
|
||||
#[test]
|
||||
fn coinmarketcap_modes_use_v2_and_map_exact_free_capabilities() -> ksp_core_lib::Result<()> {
|
||||
@@ -53,7 +53,7 @@ fn coinmarketcap_v2_fixture_normalizes_string_status_and_exact_price() -> ksp_co
|
||||
let observation = match super::parse_response(
|
||||
concat!(
|
||||
r#"{"data":[{"id":5426,"symbol":"SOL","quotes":[{"symbol":"USD","price":151.987654321012345678,"#,
|
||||
r#"last_updated":"2026-04-01T00:00:00.000Z"}]}],"status":{"error_code":"0"}}"#,
|
||||
r#""last_updated":"2026-04-01T00:00:00.000Z"}]}],"status":{"error_code":"0"}}"#,
|
||||
)
|
||||
.as_bytes(),
|
||||
provider_id,
|
||||
|
||||
Reference in New Issue
Block a user