0.5.1-pre.007

This commit is contained in:
2026-08-10 09:28:57 +02:00
parent 34a670eaec
commit a2820062eb
81 changed files with 3357 additions and 2381 deletions

View File

@@ -1,5 +1,5 @@
// file: ks-config/src/settings.rs
// version: 21
// version: 22
//! Resolved runtime configuration models retained during the `0.5.1` source-document split.
@@ -31,8 +31,6 @@ pub struct ProfileConfig {
pub app: AppSectionConfig,
/// Database configuration.
pub database: DatabaseConfig,
/// Local data directories.
pub data: DataConfig,
/// Solana endpoint and listener configuration.
pub solana: SolanaConfig,
/// Wallet configuration.
@@ -54,8 +52,6 @@ pub struct AppSectionConfig {
pub name: std::string::String,
/// Environment name.
pub environment: std::string::String,
/// Default auto reconnect flag used when a transport does not override it.
pub auto_reconnect_default: bool,
}
/// Database backend configuration.
@@ -112,16 +108,6 @@ pub struct SqliteConfig {
pub use_wal: bool,
}
/// Local data directory configuration.
#[derive(Clone, Debug, serde::Deserialize, Eq, PartialEq, serde::Serialize, TS)]
#[ts(export, export_to = "../frontend/ts/bindings/ks_config/settings/DataConfig.ts")]
pub struct DataConfig {
/// Wallet directory path.
pub wallets_directory: std::string::String,
/// Logs directory path.
pub logs_directory: std::string::String,
}
/// Solana endpoints and listener configuration.
#[derive(Clone, Debug, serde::Deserialize, Eq, PartialEq, serde::Serialize, TS)]
#[ts(export, export_to = "../frontend/ts/bindings/ks_config/settings/SolanaConfig.ts")]
@@ -317,14 +303,6 @@ pub struct WalletConfig {
pub temporary_wallet_alias: std::string::String,
/// Persists the managed temporary wallet between process restarts.
pub temporary_wallet_persist: bool,
/// Enables local validator transaction sending.
pub localnet_send_enabled: bool,
/// Enables devnet transaction sending.
pub devnet_send_enabled: bool,
/// Enables testnet transaction sending.
pub testnet_send_enabled: bool,
/// Enables mainnet transaction sending.
pub mainnet_send_enabled: bool,
}
/// Execution safety configuration.
@@ -334,6 +312,14 @@ pub struct WalletConfig {
export_to = "../frontend/ts/bindings/ks_config/settings/ExecutionConfig.ts"
)]
pub struct ExecutionConfig {
/// Enables local validator transaction sending.
pub localnet_send_enabled: bool,
/// Enables devnet transaction sending.
pub devnet_send_enabled: bool,
/// Enables testnet transaction sending.
pub testnet_send_enabled: bool,
/// Enables mainnet transaction sending.
pub mainnet_send_enabled: bool,
/// Enables dry-run for newly prepared execution policies.
pub dry_run_default: bool,
/// Requires simulation before send.
@@ -598,10 +584,6 @@ fn validate_profile(profile: &ProfileConfig) -> ks_core::Result<()> {
std::result::Result::Ok(()) => (),
std::result::Result::Err(error) => return std::result::Result::Err(error),
}
match validate_data(&profile.data) {
std::result::Result::Ok(()) => (),
std::result::Result::Err(error) => return std::result::Result::Err(error),
}
match validate_solana(&profile.solana) {
std::result::Result::Ok(()) => (),
std::result::Result::Err(error) => return std::result::Result::Err(error),
@@ -625,7 +607,7 @@ fn validate_app_section(config: &AppSectionConfig) -> ks_core::Result<()> {
return require_non_empty(&config.environment, "app.environment");
}
fn validate_database(config: &DatabaseConfig) -> ks_core::Result<()> {
pub(crate) fn validate_database(config: &DatabaseConfig) -> ks_core::Result<()> {
if config.backend != "postgres" && config.backend != "sqlite" {
return std::result::Result::Err(ks_core::Error::new(
"database_backend_invalid",
@@ -651,14 +633,6 @@ fn validate_database(config: &DatabaseConfig) -> ks_core::Result<()> {
return require_non_empty(&config.sqlite.path, "database.sqlite.path");
}
fn validate_data(config: &DataConfig) -> ks_core::Result<()> {
match require_non_empty(&config.wallets_directory, "data.wallets_directory") {
std::result::Result::Ok(()) => (),
std::result::Result::Err(error) => return std::result::Result::Err(error),
}
return require_non_empty(&config.logs_directory, "data.logs_directory");
}
fn validate_solana(config: &SolanaConfig) -> ks_core::Result<()> {
if config.http_endpoints.is_empty() {
return std::result::Result::Err(ks_core::Error::new(
@@ -889,7 +863,7 @@ fn validate_account_listener(config: &AccountListenerConfig) -> ks_core::Result<
return require_non_empty(&config.account_pubkey, "account_listener.account_pubkey");
}
fn validate_wallet(config: &WalletConfig) -> ks_core::Result<()> {
pub(crate) fn validate_wallet(config: &WalletConfig) -> ks_core::Result<()> {
match require_non_empty(&config.wallet_dir, "wallet.wallet_dir") {
std::result::Result::Ok(()) => (),
std::result::Result::Err(error) => return std::result::Result::Err(error),
@@ -935,7 +909,7 @@ fn validate_wallet_alias(value: &str) -> ks_core::Result<()> {
return std::result::Result::Ok(());
}
fn validate_execution(config: &ExecutionConfig) -> ks_core::Result<()> {
pub(crate) fn validate_execution(config: &ExecutionConfig) -> ks_core::Result<()> {
let configured_spend = config
.localnet_max_spend_lamports
.saturating_add(config.devnet_max_spend_lamports)
@@ -985,11 +959,15 @@ fn validate_wallet_execution_pair(
execution: &ExecutionConfig,
) -> ks_core::Result<()> {
for (enabled, limit, cluster) in [
(wallet.localnet_send_enabled, execution.localnet_max_spend_lamports, "localnet"),
(wallet.devnet_send_enabled, execution.devnet_max_spend_lamports, "devnet"),
(wallet.testnet_send_enabled, execution.testnet_max_spend_lamports, "testnet"),
(
wallet.mainnet_send_enabled,
execution.localnet_send_enabled,
execution.localnet_max_spend_lamports,
"localnet",
),
(execution.devnet_send_enabled, execution.devnet_max_spend_lamports, "devnet"),
(execution.testnet_send_enabled, execution.testnet_max_spend_lamports, "testnet"),
(
execution.mainnet_send_enabled,
execution.mainnet_max_spend_lamports,
"mainnet-beta",
),
@@ -1001,7 +979,7 @@ fn validate_wallet_execution_pair(
));
}
}
if wallet.mainnet_send_enabled && !execution.require_operator_confirmation {
if execution.mainnet_send_enabled && !execution.require_operator_confirmation {
return std::result::Result::Err(ks_core::Error::new(
"execution_mainnet_send_without_confirmation",
"mainnet sending requires operator confirmation",