The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.
Rust agent-orchestrationai-agentsai-assistantdesktopllmlocal-firstmcppersonal-aiprivacyrustsecond-braintauri
refactor(web3/x402): extract budget response builder
Steven Enamakel131b0b82ba0d
diff --git a/crates/openhuman-core/src/web3/x402/schemas.rs b/crates/openhuman-core/src/web3/x402/schemas.rsindex d425ac3ff9..379efdac3b 100644--- a/crates/openhuman-core/src/web3/x402/schemas.rs+++ b/crates/openhuman-core/src/web3/x402/schemas.rs@@ -171,13 +171,11 @@ fn handle_update_budget(params: Map<String, Value>) -> ControllerFuture {.await.map_err(|error| format!("x402 update_budget: {error}"))?;- Ok(json!({- "budget": {- "perRequestMaxAtomic": summary.per_request_max_atomic,- "dailyMaxAtomic": summary.daily_max_atomic,- "monthlyMaxAtomic": summary.monthly_max_atomic,- }- }))+ Ok(budget_value(+ summary.per_request_max_atomic,+ summary.daily_max_atomic,+ summary.monthly_max_atomic,+ ))})}@@ -199,6 +197,16 @@ fn summary_value(summary: tinywallet_bus::wire::X402DetailedSpendingSummary) ->})}+fn budget_value(per_request_max_atomic: u64, daily_max_atomic: u64, monthly_max_atomic: u64) -> Value {+ json!({+ "budget": {+ "perRequestMaxAtomic": per_request_max_atomic,+ "dailyMaxAtomic": daily_max_atomic,+ "monthlyMaxAtomic": monthly_max_atomic,+ }+ })+}+#[cfg(test)]#[path = "schemas_tests.rs"]mod tests;diff --git a/crates/openhuman-core/src/web3/x402/schemas_tests.rs b/crates/openhuman-core/src/web3/x402/schemas_tests.rsindex 57ed529fe7..6d984e02b4 100644--- a/crates/openhuman-core/src/web3/x402/schemas_tests.rs+++ b/crates/openhuman-core/src/web3/x402/schemas_tests.rs@@ -34,3 +34,17 @@ fn summary_response_preserves_legacy_camel_case_rpc_shape() {}));}++#[test]+fn budget_response_preserves_legacy_camel_case_rpc_shape() {+ assert_eq!(+ budget_value(1, 20, 300),+ json!({+ "budget": {+ "perRequestMaxAtomic": 1,+ "dailyMaxAtomic": 20,+ "monthlyMaxAtomic": 300,+ }+ })+ );+}