Skip to content

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

refactor(wallet): move wire request conversion into From impl

Steven Enamakel78e0485e8559
diff --git a/crates/openhuman-core/src/modules/wallet_backend.rs b/crates/openhuman-core/src/modules/wallet_backend.rs
index f188d8e96a..229d775fec 100644
--- a/crates/openhuman-core/src/modules/wallet_backend.rs
+++ b/crates/openhuman-core/src/modules/wallet_backend.rs
@@ -31,6 +31,17 @@ pub enum WalletBackendCall {
BridgeTransaction(Value),
}
+impl From<tinywallet_bus::wire::WalletBackendRequest> for WalletBackendCall {
+ fn from(request: tinywallet_bus::wire::WalletBackendRequest) -> Self {
+ use tinywallet_bus::wire::WalletBackendRequest as Request;
+ match request {
+ Request::Routes => Self::Routes,
+ Request::SwapTransaction { body } => Self::SwapTransaction(body),
+ Request::BridgeTransaction { body } => Self::BridgeTransaction(body),
+ }
+ }
+}
+
/// The pending answer of a [`WalletBackendHandler`].
pub type WalletBackendFuture = Pin<Box<dyn Future<Output = Result<Value, String>> + Send>>;
diff --git a/crates/openhuman-core/src/modules/wallet_host.rs b/crates/openhuman-core/src/modules/wallet_host.rs
index 655184efd3..25a03690ec 100644
--- a/crates/openhuman-core/src/modules/wallet_host.rs
+++ b/crates/openhuman-core/src/modules/wallet_host.rs
@@ -641,16 +641,7 @@ impl WalletHost {
.load_config()
.await
.map_err(callback_error)?;
- let call = match request {
- WalletBackendRequest::Routes => super::wallet_backend::WalletBackendCall::Routes,
- WalletBackendRequest::SwapTransaction { body } => {
- super::wallet_backend::WalletBackendCall::SwapTransaction(body)
- }
- WalletBackendRequest::BridgeTransaction { body } => {
- super::wallet_backend::WalletBackendCall::BridgeTransaction(body)
- }
- };
- let data = super::wallet_backend::call_wallet_backend(config, call)
+ let data = super::wallet_backend::call_wallet_backend(config, request.into())
.await
.map_err(callback_error)?;
Ok(HostResponse::WalletBackend(WalletBackendResponse { data }))