v0.2.3-pre.006

This commit is contained in:
2026-08-18 12:35:29 +02:00
parent 1e1bc0d421
commit 4439589f0d
12 changed files with 728 additions and 39 deletions

View File

@@ -1,5 +1,5 @@
// file: crates/ksp-onchain-transport-lib/src/rpc_transactions.rs
// version: 5
// version: 6
/// Binary encoding accepted for serialized transaction input payloads.
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
@@ -321,14 +321,12 @@ impl SolanaRequestAirdropConfig {
}
/// Returns whether the airdrop config would serialize to an empty object.
#[cfg(test)]
pub(crate) fn is_empty(&self) -> bool {
return self.recent_blockhash.is_none() && self.commitment.is_none();
}
/// Serializes this config to the Solana JSON-RPC wire 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(blockhash) = self.recent_blockhash.as_ref() {
@@ -395,7 +393,6 @@ impl SolanaSendTransactionConfig {
}
/// Returns whether the send config would serialize to an empty object.
#[cfg(test)]
pub(crate) const fn is_empty(&self) -> bool {
return self.skip_preflight.is_none()
&& self.preflight_commitment.is_none()
@@ -406,7 +403,6 @@ impl SolanaSendTransactionConfig {
/// Serializes this config to the Solana JSON-RPC wire 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(value) = self.skip_preflight {
@@ -1314,6 +1310,53 @@ impl crate::HttpTransportPool {
};
}
/// Executes typed `requestAirdrop` through the common KSP HTTP transport path.
///
/// The RPC creates and submits a faucet transaction, so its audited descriptor is `WriteSubmission / NeverAfterDispatch`. The optional
/// `recentBlockhash` field is retained from the targeted Agave runtime even though the public Solana page currently documents only `commitment`.
pub async fn request_airdrop(
&self,
role: &crate::HttpRoleName,
recipient: &ksp_core_lib::Pubkey,
lamports: u64,
config: std::option::Option<&crate::SolanaRequestAirdropConfig>,
) -> ksp_core_lib::Result<std::string::String> {
let mut params = std::vec![serde_json::Value::String(recipient.to_string()), serde_json::json!(lamports)];
if let std::option::Option::Some(config) = config
&& !config.is_empty()
{
params.push(config.to_json_value());
}
let value = self.execute_transaction_rpc("requestAirdrop", role, params).await;
return match value {
std::result::Result::Ok(value) => crate::decode_wire_json::<std::string::String>("requestAirdrop", value),
std::result::Result::Err(error) => std::result::Result::Err(error),
};
}
/// Executes typed `sendTransaction` through the common KSP HTTP transport path.
///
/// Transport forwards an already serialized and signed transaction without decoding or modifying it. `config.maxRetries` controls node-side
/// retransmission only; KSP's HTTP retry policy remains governed by the central `WriteSubmission / NeverAfterDispatch` descriptor.
pub async fn send_transaction(
&self,
role: &crate::HttpRoleName,
transaction: &str,
config: std::option::Option<&crate::SolanaSendTransactionConfig>,
) -> ksp_core_lib::Result<std::string::String> {
let mut params = std::vec![serde_json::Value::String(transaction.to_owned())];
if let std::option::Option::Some(config) = config
&& !config.is_empty()
{
params.push((*config).to_json_value());
}
let value = self.execute_transaction_rpc("sendTransaction", role, params).await;
return match value {
std::result::Result::Ok(value) => crate::decode_wire_json::<std::string::String>("sendTransaction", value),
std::result::Result::Err(error) => std::result::Result::Err(error),
};
}
/// Executes typed `getTransactionCount` through the common KSP HTTP transport path.
pub async fn get_transaction_count(
&self,