From 9186c836ba1051fcecedd582f0db1830e4ffade5 Mon Sep 17 00:00:00 2001 From: Meshiest Date: Mon, 9 Dec 2024 02:24:55 -0500 Subject: [PATCH] fix(controlplane,actions): fix aleo adding new standard out to execute API --- crates/cli/src/commands/env/action/mod.rs | 1 + .../controlplane/src/server/actions/deploy.rs | 17 ++++++++++++++--- .../controlplane/src/server/actions/execute.rs | 17 ++++++++++++++--- 3 files changed, 29 insertions(+), 6 deletions(-) diff --git a/crates/cli/src/commands/env/action/mod.rs b/crates/cli/src/commands/env/action/mod.rs index 8fe22c47..9050cdd6 100644 --- a/crates/cli/src/commands/env/action/mod.rs +++ b/crates/cli/src/commands/env/action/mod.rs @@ -383,6 +383,7 @@ pub async fn post_and_wait_tx(url: &str, req: RequestBuilder) -> Result<()> { use snops_common::events::EventFilter::*; let tx_id: String = req.send().await?.json().await?; + eprintln!("transaction id: {tx_id}"); let mut events = EventsClient::open_with_filter(url, TransactionIs(Arc::new(tx_id))).await?; diff --git a/crates/controlplane/src/server/actions/deploy.rs b/crates/controlplane/src/server/actions/deploy.rs index 43175054..f316087d 100644 --- a/crates/controlplane/src/server/actions/deploy.rs +++ b/crates/controlplane/src/server/actions/deploy.rs @@ -91,7 +91,7 @@ pub async fn deploy_inner( let compute_bin = env.storage.resolve_compute_binary(state).await?; // authorize the transaction let aot = AotCmd::new(compute_bin, env.network); - let auth_str = aot + let mut auth_str = aot .authorize_deploy( &resolved_pk, resolved_fee_pk.as_ref(), @@ -104,9 +104,20 @@ pub async fn deploy_inner( ) .await?; + // Truncate the output to the first { + // because Aleo decided to print execute + // status to stdout... + if let Some(index) = auth_str.find("{") { + auth_str = auth_str.split_off(index); + } + // parse the json and bundle it up - let authorization: Authorization = - serde_json::from_str(&auth_str).map_err(AuthorizeError::Json)?; + let authorization: Authorization = serde_json::from_str(&auth_str) + .inspect_err(|e| { + tracing::error!("failed to parse authorization json: {e}"); + tracing::error!("authorization json: {auth_str}"); + }) + .map_err(AuthorizeError::Json)?; // proxy it to a listen cannon let tx_id = cannon.proxy_auth(authorization).await?; diff --git a/crates/controlplane/src/server/actions/execute.rs b/crates/controlplane/src/server/actions/execute.rs index 854fb0cc..bac95b1b 100644 --- a/crates/controlplane/src/server/actions/execute.rs +++ b/crates/controlplane/src/server/actions/execute.rs @@ -166,7 +166,7 @@ pub async fn execute_inner( // authorize the transaction let compute_bin = env.storage.resolve_compute_binary(state).await?; let aot = AotCmd::new(compute_bin, env.network); - let auth_str = aot + let mut auth_str = aot .authorize_program( &resolved_pk, resolved_fee_pk.as_ref(), @@ -181,9 +181,20 @@ pub async fn execute_inner( ) .await?; + // Truncate the output to the first { + // because Aleo decided to print execute + // status to stdout... + if let Some(index) = auth_str.find("{") { + auth_str = auth_str.split_off(index); + } + // parse the json and bundle it up - let authorization: Authorization = - serde_json::from_str(&auth_str).map_err(AuthorizeError::Json)?; + let authorization: Authorization = serde_json::from_str(&auth_str) + .inspect_err(|e| { + tracing::error!("failed to parse authorization json: {e}"); + tracing::error!("authorization json: {auth_str}"); + }) + .map_err(AuthorizeError::Json)?; // proxy it to a listen cannon let tx_id = cannon.proxy_auth(authorization).await?;