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
style: apply rustfmt formatting to wallet and web3 modules
Steven Enamakel1cccf46a24c1
diff --git a/crates/openhuman-core/src/modules/wallet_host.rs b/crates/openhuman-core/src/modules/wallet_host.rsindex 37da64003e..fd2272d170 100644--- a/crates/openhuman-core/src/modules/wallet_host.rs+++ b/crates/openhuman-core/src/modules/wallet_host.rs@@ -10,12 +10,12 @@ use std::future::Future;use std::sync::{Mutex, OnceLock};use tinybus::ObjectPath;+use tinywallet_bus::wire::HostEndpointReference;use tinywallet_bus::wire::{AuthorizationResult, AuthorizeNativeWalletExecutionRequest, AuthorizeWeb3ExecutionRequest,AuthorizeX402PaymentRequest, ChainTransportRequest, ChainTransportResult, HostResponse,WalletAccountInfo, WalletAccountsResponse, WalletBackendRequest, WalletBackendResponse,};-use tinywallet_bus::wire::HostEndpointReference;const HOST_ERROR_NAME: &str = "ai.tinyhumans.tinywallet.Host.Error.CallbackFailed";@@ -38,9 +38,7 @@ static NATIVE_APPROVAL_QUOTES: OnceLock<static WEB3_APPROVAL_QUOTES: OnceLock<Mutex<HashMap<String, tinywallet_bus::wire::Web3QuoteResponse>>,> = OnceLock::new();-static ENDPOINT_REFERENCES: OnceLock<- Mutex<HashMap<String, EndpointReference>>,-> = OnceLock::new();+static ENDPOINT_REFERENCES: OnceLock<Mutex<HashMap<String, EndpointReference>>> = OnceLock::new();#[derive(Debug, Clone)]struct EndpointReference {@@ -58,8 +56,8 @@ fn native_approval_quotes(NATIVE_APPROVAL_QUOTES.get_or_init(|| Mutex::new(HashMap::new()))}-fn web3_approval_quotes(-) -> &'static Mutex<HashMap<String, tinywallet_bus::wire::Web3QuoteResponse>> {+fn web3_approval_quotes() -> &'static Mutex<HashMap<String, tinywallet_bus::wire::Web3QuoteResponse>>+{WEB3_APPROVAL_QUOTES.get_or_init(|| Mutex::new(HashMap::new()))}@@ -93,11 +91,14 @@ pub(crate) fn bind_endpoint_references(};if endpoint.reference.trim().is_empty()|| resolved- .insert(endpoint.reference.clone(), EndpointReference {- service: service.to_owned(),- key: endpoint.key,- url,- })+ .insert(+ endpoint.reference.clone(),+ EndpointReference {+ service: service.to_owned(),+ key: endpoint.key,+ url,+ },+ ).is_some(){return Err("wallet module returned an invalid endpoint reference".into());@@ -223,7 +224,7 @@ fn web3_approval_matches_request(quote: &tinywallet_bus::wire::Web3QuoteResponse,request: &AuthorizeWeb3ExecutionRequest,) -> bool {- use tinywallet_bus::wire::{Web3ExecutionIntent, Web3QuoteKind, WalletChain};+ use tinywallet_bus::wire::{WalletChain, Web3ExecutionIntent, Web3QuoteKind};let operation_matches = matches!((quote.kind, request.operation.as_str()),@@ -281,9 +282,7 @@ fn web3_approval_matches_request(.get("to").and_then(serde_json::Value::as_str).is_some_and(|expected| expected.eq_ignore_ascii_case(to))- && transaction- .get("data")- .and_then(serde_json::Value::as_str)+ && transaction.get("data").and_then(serde_json::Value::as_str)== data.as_deref()&& decimal_json(transaction.get("value")).as_deref()== Some(value.as_str())@@ -291,10 +290,7 @@ fn web3_approval_matches_request(}}}- (- Web3ExecutionIntent::Solana { tx_blob_hex },- WalletChain::Solana,- ) => {+ (Web3ExecutionIntent::Solana { tx_blob_hex }, WalletChain::Solana) => {let expected = quote.quote.get("tx")@@ -308,9 +304,9 @@ fn web3_approval_matches_request(}fn known_evm_chain(network: &str, chain_id: u64) -> bool {- tinywallet_bus::wire::EvmNetwork::ALL.into_iter().any(|known| {- known.as_str() == network && known.chain_id() == chain_id- })+ tinywallet_bus::wire::EvmNetwork::ALL+ .into_iter()+ .any(|known| known.as_str() == network && known.chain_id() == chain_id)}fn decimal_json(value: Option<&serde_json::Value>) -> Option<String> {@@ -470,12 +466,7 @@ pub(crate) async fn with_confirmed_execution<F: Future>(expected_web3_quote: Option<tinywallet_bus::wire::Web3QuoteResponse>,future: F,) -> F::Output {- let _permit = ApprovalPermit::new(- kind,- quote_id,- expected_native_quote,- expected_web3_quote,- );+ let _permit = ApprovalPermit::new(kind, quote_id, expected_native_quote, expected_web3_quote);future.await}@@ -578,16 +569,14 @@ impl WalletHost {body,content_type,..- } => {- crate::web3::wallet::rpc::rest_post_text(- &join_endpoint(&endpoint_url, &path),- &body,- &content_type,- )- .await- .map(serde_json::Value::String)- .map_err(classify_transport_error)- }+ } => crate::web3::wallet::rpc::rest_post_text(+ &join_endpoint(&endpoint_url, &path),+ &body,+ &content_type,+ )+ .await+ .map(serde_json::Value::String)+ .map_err(classify_transport_error),};let response = match result {Ok(body) => ChainTransportResult::Ok { body },diff --git a/crates/openhuman-core/src/modules/wallet_host_tests.rs b/crates/openhuman-core/src/modules/wallet_host_tests.rsindex 95519a7ee2..4862a47c6c 100644--- a/crates/openhuman-core/src/modules/wallet_host_tests.rs+++ b/crates/openhuman-core/src/modules/wallet_host_tests.rs@@ -4,8 +4,8 @@ use super::{};use tinywallet_bus::wire::{AuthorizeNativeWalletExecutionRequest, AuthorizeWeb3ExecutionRequest, EvmNetwork,- NativeWalletExecutionIntent, PreparedKind, PreparedStatus, PreparedTransaction, TransactionSpec,- WalletChain, Web3ExecutionIntent, Web3QuoteKind, Web3QuoteResponse,+ NativeWalletExecutionIntent, PreparedKind, PreparedStatus, PreparedTransaction,+ TransactionSpec, WalletChain, Web3ExecutionIntent, Web3QuoteKind, Web3QuoteResponse,};#[test]@@ -27,12 +27,8 @@ fn execution_authorization_is_bound_to_one_confirmed_quote_id() {fn an_unconsumed_confirmation_is_removed_when_the_execution_ends() {{let quote = native_quote("quote-cancelled");- let _permit = ApprovalPermit::new(- ApprovalKind::Native,- "quote-cancelled",- Some(quote),- None,- );+ let _permit =+ ApprovalPermit::new(ApprovalKind::Native, "quote-cancelled", Some(quote), None);}assert!(!consume_approval(ApprovalKind::Native, "quote-cancelled"));}@@ -90,7 +86,12 @@ fn native_approval_accepts_the_exact_confirmed_quote_and_signer_intent_once() {#[test]fn web3_approval_requires_the_cached_quote_operation_chain_and_transaction() {let quote = web3_quote("web3-valid-quote");- let permit = ApprovalPermit::new(ApprovalKind::Web3, "e.quote_id, None, Some(quote.clone()));+ let permit = ApprovalPermit::new(+ ApprovalKind::Web3,+ "e.quote_id,+ None,+ Some(quote.clone()),+ );let request = AuthorizeWeb3ExecutionRequest {quote_id: quote.quote_id.clone(),operation: "dapp_call".into(),@@ -113,7 +114,12 @@ fn web3_approval_requires_the_cached_quote_operation_chain_and_transaction() {#[test]fn web3_approval_rejects_changed_quote_intent_before_signing() {let quote = web3_quote("web3-changed-quote");- let permit = ApprovalPermit::new(ApprovalKind::Web3, "e.quote_id, None, Some(quote.clone()));+ let permit = ApprovalPermit::new(+ ApprovalKind::Web3,+ "e.quote_id,+ None,+ Some(quote.clone()),+ );let request = AuthorizeWeb3ExecutionRequest {quote_id: quote.quote_id.clone(),operation: "dapp_call".into(),diff --git a/crates/openhuman-core/src/modules/wallet_service_tests.rs b/crates/openhuman-core/src/modules/wallet_service_tests.rsindex 0ed1a166eb..0f992035ec 100644--- a/crates/openhuman-core/src/modules/wallet_service_tests.rs+++ b/crates/openhuman-core/src/modules/wallet_service_tests.rs@@ -85,7 +85,7 @@ async fn explicit_close_retains_state_for_retry_then_releases_user_state_once()&configured.service.handle,&configured.endpoint_references,)- .expect("fixture endpoint alias should bind");+ .expect("fixture endpoint alias should bind");let close_calls = Arc::new(AtomicUsize::new(0));let observed_calls = close_calls.clone();diff --git a/crates/openhuman-core/src/modules/web3_service.rs b/crates/openhuman-core/src/modules/web3_service.rsindex bd66923969..058d6e4ed7 100644--- a/crates/openhuman-core/src/modules/web3_service.rs+++ b/crates/openhuman-core/src/modules/web3_service.rs@@ -42,14 +42,11 @@ async fn ensure_service(solana_cluster: native_configuration.solana_cluster,overridden_endpoints: native_configuration.overridden_endpoints,};- if active- .as_ref()- .is_some_and(|current| {- current.workspace != workspace- || current.accounts != accounts- || current.configuration != configuration- })- {+ if active.as_ref().is_some_and(|current| {+ current.workspace != workspace+ || current.accounts != accounts+ || current.configuration != configuration+ }) {if let Some(current) = active.as_ref() {wallet::call::<_, ()>(config,diff --git a/crates/openhuman-core/src/web3/module_tools.rs b/crates/openhuman-core/src/web3/module_tools.rsindex 5a4efa1d43..65010c8f71 100644--- a/crates/openhuman-core/src/web3/module_tools.rs+++ b/crates/openhuman-core/src/web3/module_tools.rs@@ -40,51 +40,43 @@ impl Tool for Web3ModuleTool {Err(error) => return Ok(ToolResult::error(error)),};let result: anyhow::Result<Value> = match self.name() {- "web3_swap_quote" => {- crate::modules::web3_service::quote(- &config,- tinywallet_bus::names::methods::WEB3_SWAP_QUOTE,- args,- )- .await- .map_err(|error| anyhow::anyhow!(error.to_string()))- .and_then(|value| serde_json::to_value(value).map_err(Into::into))- }- "web3_bridge_quote" => {- crate::modules::web3_service::quote(- &config,- tinywallet_bus::names::methods::WEB3_BRIDGE_QUOTE,- args,- )- .await- .map_err(|error| anyhow::anyhow!(error.to_string()))- .and_then(|value| serde_json::to_value(value).map_err(Into::into))- }- "web3_dapp_call" => {- crate::modules::web3_service::quote(- &config,- tinywallet_bus::names::methods::WEB3_DAPP_QUOTE,- args,- )- .await- .map_err(|error| anyhow::anyhow!(error.to_string()))- .and_then(|value| serde_json::to_value(value).map_err(Into::into))- }+ "web3_swap_quote" => crate::modules::web3_service::quote(+ &config,+ tinywallet_bus::names::methods::WEB3_SWAP_QUOTE,+ args,+ )+ .await+ .map_err(|error| anyhow::anyhow!(error.to_string()))+ .and_then(|value| serde_json::to_value(value).map_err(Into::into)),+ "web3_bridge_quote" => crate::modules::web3_service::quote(+ &config,+ tinywallet_bus::names::methods::WEB3_BRIDGE_QUOTE,+ args,+ )+ .await+ .map_err(|error| anyhow::anyhow!(error.to_string()))+ .and_then(|value| serde_json::to_value(value).map_err(Into::into)),+ "web3_dapp_call" => crate::modules::web3_service::quote(+ &config,+ tinywallet_bus::names::methods::WEB3_DAPP_QUOTE,+ args,+ )+ .await+ .map_err(|error| anyhow::anyhow!(error.to_string()))+ .and_then(|value| serde_json::to_value(value).map_err(Into::into)),"web3_swap_routes" => crate::modules::web3_service::routes(&config).await.map_err(|error| anyhow::anyhow!(error.to_string())),"web3_swap_execute" | "web3_bridge_execute" | "web3_dapp_execute" => {match serde_json::from_value::<crate::modules::web3_service::ExecuteParams>(args) {- Ok(params) => {- crate::modules::web3_service::execute(- &config,- params.quote_id,- params.confirmed,- )- .await- .map_err(|error| anyhow::anyhow!(error.to_string()))- .and_then(|value| serde_json::to_value(value).map_err(Into::into))- }+ Ok(params) => crate::modules::web3_service::execute(+ &config,+ params.quote_id,+ params.confirmed,+ )+ .await+ .map_err(|error| anyhow::anyhow!(error.to_string()))+ .and_then(|value| serde_json::to_value(value).map_err(Into::into)),Err(error) => {return Ok(ToolResult::error(format!("invalid arguments: {error}")));}