Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

refactor(wallet): route rpc overrides and tx lookups through shared helpers

Steven Enamakelcab9b9e4509d
diff --git a/crates/openhuman-core/src/modules/wallet_service.rs b/crates/openhuman-core/src/modules/wallet_service.rs
index 71aaf880ae..0741a626e6 100644
--- a/crates/openhuman-core/src/modules/wallet_service.rs
+++ b/crates/openhuman-core/src/modules/wallet_service.rs
@@ -347,9 +347,9 @@ fn finish_shutdown_hook_registration(registered: &AtomicBool) {
pub(super) fn native_wallet_config_request() -> NativeWalletConfigRequest {
let mut overridden_endpoints = Vec::new();
for network in EvmNetwork::ALL {
- let name = crate::web3::wallet::endpoints::evm_rpc_env_var(network);
- if nonempty_env(name) {
- overridden_endpoints.push(RpcEndpointKey::Evm { network });
+ let key = RpcEndpointKey::Evm { network };
+ if crate::web3::wallet::endpoints::override_for_endpoint(key).is_some() {
+ overridden_endpoints.push(key);
}
}
for key in [
diff --git a/crates/openhuman-core/src/modules/x402_service.rs b/crates/openhuman-core/src/modules/x402_service.rs
index 0d950875c6..acc14730ba 100644
--- a/crates/openhuman-core/src/modules/x402_service.rs
+++ b/crates/openhuman-core/src/modules/x402_service.rs
@@ -3,6 +3,7 @@
use std::path::PathBuf;
use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::OnceLock;
+use zeroize::Zeroize;
use tinywallet_bus::names::methods;
use tinywallet_bus::wire::{
diff --git a/crates/openhuman-core/src/tools/ops.rs b/crates/openhuman-core/src/tools/ops.rs
index a540dae9cf..4a0cf1f4ab 100644
--- a/crates/openhuman-core/src/tools/ops.rs
+++ b/crates/openhuman-core/src/tools/ops.rs
@@ -318,8 +318,6 @@ pub fn all_tools_with_runtime(
Box::new(FlowMemoryRememberTool::new(security.clone())),
// Wallet tools use bus-owned declarations and route every operation
// through the loaded TinyWallet module.
- #[cfg(feature = "web3")]
- tools.extend(crate::web3::wallet::tools::all_agent_tools()),
Box::new(ScheduleTool::new(security.clone(), root_config.clone())),
Box::new(ProxyConfigTool::new(config.clone(), security.clone())),
Box::new(UpdateCheckTool::new()),
@@ -487,6 +485,11 @@ pub fn all_tools_with_runtime(
Box::new(WorkspaceInitTool),
];
+ // Wallet tools are added after the fixed registry literal because each
+ // bus-backed declaration expands into an owned adapter.
+ #[cfg(feature = "web3")]
+ tools.extend(crate::web3::wallet::tools::all_agent_tools());
+
// The single `memory` tool (recall | fetch | learn | forget), registered
// only while memory is on: with no usable engine (signed out, no CortexDB
// key) the model is not offered a tool that can only fail.
diff --git a/crates/openhuman-core/src/web3/wallet/tools.rs b/crates/openhuman-core/src/web3/wallet/tools.rs
index 17323bc610..3192598021 100644
--- a/crates/openhuman-core/src/web3/wallet/tools.rs
+++ b/crates/openhuman-core/src/web3/wallet/tools.rs
@@ -76,26 +76,32 @@ impl Tool for WalletModuleTool {
}
};
let result = match self.name() {
- "wallet_tx_status" => {
- crate::web3::wallet::tx_status(query.chain, query.evm_network, &query.hash)
- .await
- .map(|outcome| outcome.value)
- }
- "wallet_tx_receipt" => {
- crate::web3::wallet::tx_receipt(query.chain, query.evm_network, &query.hash)
- .await
- .map(|outcome| outcome.value)
- }
- _ => {
- crate::web3::wallet::lookup_tx(query.chain, query.evm_network, &query.hash)
- .await
- .map(|outcome| outcome.value)
- }
+ "wallet_tx_status" => outcome_value(
+ crate::web3::wallet::tx_status(
+ query.chain,
+ query.evm_network,
+ &query.hash,
+ )
+ .await,
+ ),
+ "wallet_tx_receipt" => outcome_value(
+ crate::web3::wallet::tx_receipt(
+ query.chain,
+ query.evm_network,
+ &query.hash,
+ )
+ .await,
+ ),
+ _ => outcome_value(
+ crate::web3::wallet::lookup_tx(
+ query.chain,
+ query.evm_network,
+ &query.hash,
+ )
+ .await,
+ ),
};
- result.and_then(|value| {
- serde_json::to_value(value)
- .map_err(|error| format!("failed to serialize wallet result: {error}"))
- })
+ result
}
_ => return Ok(ToolResult::error("unknown wallet tool")),
};