Skip to content

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

feat(web3): add schema definitions for bridge, dapp, and swap

Steven Enamakel5608c2effd4d
diff --git a/crates/openhuman-core/src/web3/bridge/schemas.rs b/crates/openhuman-core/src/web3/bridge/schemas.rs
index a6ee060c2b..836714f164 100644
--- a/crates/openhuman-core/src/web3/bridge/schemas.rs
+++ b/crates/openhuman-core/src/web3/bridge/schemas.rs
@@ -94,7 +94,7 @@ pub fn schema(function: &str) -> ControllerSchema {
fn handle_quote(params: Map<String, Value>) -> ControllerFuture {
Box::pin(async move {
let config = config_rpc::load_config_with_timeout().await?;
- let quote = web3_service::quote(&config, methods::WEB3_BRIDGE_QUOTE, Value::Object(params))
+ let quote = web3_service::quote(&config, None, methods::WEB3_BRIDGE_QUOTE, Value::Object(params))
.await
.map_err(|error| error.to_string())?;
Outcome::new(quote, vec!["web3 bridge prepared".to_string()]).into_cli_compatible_json()
@@ -106,7 +106,7 @@ fn handle_execute(params: Map<String, Value>) -> ControllerFuture {
let parsed: web3_service::ExecuteParams = serde_json::from_value(Value::Object(params))
.map_err(|e| format!("invalid params: {e}"))?;
let config = config_rpc::load_config_with_timeout().await?;
- let result = web3_service::execute(&config, parsed.quote_id, parsed.confirmed)
+ let result = web3_service::execute(&config, None, parsed.quote_id, parsed.confirmed)
.await
.map_err(|error| error.to_string())?;
Outcome::new(result, vec!["web3 transaction broadcast".to_string()])
diff --git a/crates/openhuman-core/src/web3/dapp/schemas.rs b/crates/openhuman-core/src/web3/dapp/schemas.rs
index dffb156e59..0ab785872e 100644
--- a/crates/openhuman-core/src/web3/dapp/schemas.rs
+++ b/crates/openhuman-core/src/web3/dapp/schemas.rs
@@ -77,7 +77,7 @@ pub fn schema(function: &str) -> ControllerSchema {
fn handle_call(params: Map<String, Value>) -> ControllerFuture {
Box::pin(async move {
let config = config_rpc::load_config_with_timeout().await?;
- let quote = web3_service::quote(&config, methods::WEB3_DAPP_QUOTE, Value::Object(params))
+ let quote = web3_service::quote(&config, None, methods::WEB3_DAPP_QUOTE, Value::Object(params))
.await
.map_err(|error| error.to_string())?;
Outcome::new(quote, vec!["web3 dapp call prepared".to_string()]).into_cli_compatible_json()
@@ -89,7 +89,7 @@ fn handle_execute(params: Map<String, Value>) -> ControllerFuture {
let parsed: web3_service::ExecuteParams = serde_json::from_value(Value::Object(params))
.map_err(|e| format!("invalid params: {e}"))?;
let config = config_rpc::load_config_with_timeout().await?;
- let result = web3_service::execute(&config, parsed.quote_id, parsed.confirmed)
+ let result = web3_service::execute(&config, None, parsed.quote_id, parsed.confirmed)
.await
.map_err(|error| error.to_string())?;
Outcome::new(result, vec!["web3 transaction broadcast".to_string()])
diff --git a/crates/openhuman-core/src/web3/swap/schemas.rs b/crates/openhuman-core/src/web3/swap/schemas.rs
index 49884540db..da1ed011b4 100644
--- a/crates/openhuman-core/src/web3/swap/schemas.rs
+++ b/crates/openhuman-core/src/web3/swap/schemas.rs
@@ -105,7 +105,7 @@ fn unknown_schema() -> ControllerSchema {
fn handle_quote(params: Map<String, Value>) -> ControllerFuture {
Box::pin(async move {
let config = config_rpc::load_config_with_timeout().await?;
- let quote = web3_service::quote(&config, methods::WEB3_SWAP_QUOTE, Value::Object(params))
+ let quote = web3_service::quote(&config, None, methods::WEB3_SWAP_QUOTE, Value::Object(params))
.await
.map_err(|error| error.to_string())?;
Outcome::new(quote, vec!["web3 swap prepared".to_string()]).into_cli_compatible_json()
@@ -117,7 +117,7 @@ fn handle_execute(params: Map<String, Value>) -> ControllerFuture {
let parsed: web3_service::ExecuteParams = serde_json::from_value(Value::Object(params))
.map_err(|e| format!("invalid params: {e}"))?;
let config = config_rpc::load_config_with_timeout().await?;
- let result = web3_service::execute(&config, parsed.quote_id, parsed.confirmed)
+ let result = web3_service::execute(&config, None, parsed.quote_id, parsed.confirmed)
.await
.map_err(|error| error.to_string())?;
Outcome::new(result, vec!["web3 transaction broadcast".to_string()])
diff --git a/crates/openhuman-core/src/web3/wallet/execution.rs b/crates/openhuman-core/src/web3/wallet/execution.rs
index 517bf74272..c4d52d0099 100644
--- a/crates/openhuman-core/src/web3/wallet/execution.rs
+++ b/crates/openhuman-core/src/web3/wallet/execution.rs
@@ -97,14 +97,9 @@ pub async fn balances() -> Result<Outcome<Vec<BalanceInfo>>, String> {
/// Validate a transfer and store a quote for it.
pub async fn prepare_transfer(
params: PrepareTransferParams,
+ owner: Option<tinywallet_bus::wire::QuoteOwner>,
) -> Result<Outcome<PreparedTransaction>, String> {
let config = config_rpc::load_config_with_timeout().await?;
- let owner = crate::security::approval::APPROVAL_CHAT_CONTEXT
- .try_with(|context| tinywallet_bus::wire::QuoteOwner {
- thread_id: context.thread_id.clone(),
- client_id: context.client_id.clone(),
- })
- .ok();
let quote = wallet_service::prepare_native_transfer(&config, owner, params)
.await
.map_err(|error| error.to_string())?;
@@ -117,14 +112,9 @@ pub async fn prepare_transfer(
/// Confirm and execute a prepared transfer.
pub async fn execute_prepared(
params: ExecutePreparedParams,
+ owner: Option<tinywallet_bus::wire::QuoteOwner>,
) -> Result<Outcome<ExecutionResult>, String> {
let config = config_rpc::load_config_with_timeout().await?;
- let owner = crate::security::approval::APPROVAL_CHAT_CONTEXT
- .try_with(|context| tinywallet_bus::wire::QuoteOwner {
- thread_id: context.thread_id.clone(),
- client_id: context.client_id.clone(),
- })
- .ok();
let result = wallet_service::execute_native_transfer(&config, owner, params)
.await
.map_err(|error| error.to_string())?;