Skip to content

Commit

Permalink
Return game tx hash
Browse files Browse the repository at this point in the history
  • Loading branch information
Quantumplation committed Dec 10, 2024
1 parent 75640c6 commit 154d148
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
4 changes: 3 additions & 1 deletion crates/rpc/src/bin/metric_exporter/routes/game/new_game.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,11 @@ pub async fn elimination_game(

let client = NodeClient::new(state.hydra.clone(), state.admin_key.clone(), state.network);

let tx_hash = client.new_game(None, 2, 0).await.context("error creating new game");
let tx_hash = client.new_game(None, 2, 0).await.context("error creating new game")?;
Ok(Json(NewGameLocalResponse {
player_state: None,
admin_pkh: hex::encode(client.tx_builder.admin_pkh),
game_tx_hash: hex::encode(tx_hash),
}))
}

Expand Down Expand Up @@ -46,5 +47,6 @@ pub async fn new_game(
Ok(Json(NewGameLocalResponse {
player_state: Some(format!("{}#1", hex::encode(tx_hash))),
admin_pkh: hex::encode(client.tx_builder.admin_pkh),
game_tx_hash: hex::encode(tx_hash),
}))
}
1 change: 1 addition & 0 deletions crates/rpc/src/model/cluster/shared/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use serde::{Deserialize, Serialize};
pub struct NewGameLocalResponse {
pub player_state: Option<String>,
pub admin_pkh: String,
pub game_tx_hash: String,
}

#[derive(Serialize, Deserialize, Debug)]
Expand Down
3 changes: 3 additions & 0 deletions crates/rpc/src/routes/new_game.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ pub struct NewGameResponse {
ip: String,
player_state: Option<String>,
admin_pkh: String,
game_tx_hash: String,
}

pub async fn do_new_game(
Expand Down Expand Up @@ -60,6 +61,7 @@ pub async fn do_new_game(
ip: external_url,
player_state: body.player_state,
admin_pkh: body.admin_pkh,
game_tx_hash: body.game_tx_hash,
}))
}

Expand Down Expand Up @@ -98,6 +100,7 @@ pub async fn do_elimination(node: Arc<HydraDoomNode>) -> Result<Json<NewGameResp
ip: external_url,
player_state: body.player_state,
admin_pkh: body.admin_pkh,
game_tx_hash: body.game_tx_hash,
}))
}

Expand Down

0 comments on commit 154d148

Please sign in to comment.