Skip to content

Commit

Permalink
fix(controlplane,actions): fix aleo adding new standard out to execut…
Browse files Browse the repository at this point in the history
…e API
  • Loading branch information
Meshiest committed Dec 9, 2024
1 parent 88073d5 commit 9186c83
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 6 deletions.
1 change: 1 addition & 0 deletions crates/cli/src/commands/env/action/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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?;

Expand Down
17 changes: 14 additions & 3 deletions crates/controlplane/src/server/actions/deploy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand All @@ -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?;
Expand Down
17 changes: 14 additions & 3 deletions crates/controlplane/src/server/actions/execute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand All @@ -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?;
Expand Down

0 comments on commit 9186c83

Please sign in to comment.