Skip to content

Commit

Permalink
chore: include admin_pkh in new game and add player responses
Browse files Browse the repository at this point in the history
  • Loading branch information
yHSJ committed Nov 12, 2024
1 parent ac059ed commit 00e6a03
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 5 deletions.
3 changes: 1 addition & 2 deletions crates/rpc/src/model/cluster/node.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
use std::{collections::HashMap, sync::Arc, time::Duration};

use anyhow::{anyhow, Context, Result};
use hex::FromHex;
use pallas::{
Expand All @@ -9,6 +7,7 @@ use pallas::{
use reqwest::Url;
use serde::{Deserialize, Serialize};
use serde_json::Value;
use std::{collections::HashMap, sync::Arc, time::Duration};
use tracing::debug;

use crate::model::{
Expand Down
7 changes: 4 additions & 3 deletions crates/rpc/src/model/tx_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -429,9 +429,10 @@ mod tests {
// I did this just to confirm the transaction is built as I expected manually
#[test]
fn test_build_new_game() {
let admin_key: KeyEnvelope =
serde_json::from_reader(File::open("preprod.sk").expect("Failed to open key file"))
.expect("unable to parse key file");
let admin_key: KeyEnvelope = serde_json::from_reader(
File::open("keys/preprod.sk").expect("Failed to open key file"),
)
.expect("unable to parse key file");
let tx_builder = TxBuilder::new(admin_key.try_into().expect("Failed to create SecretKey"));

let player = match Address::from_bech32(
Expand Down
2 changes: 2 additions & 0 deletions crates/rpc/src/routes/add_player.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ use crate::model::cluster::{ClusterState, NodeClient};
pub struct AddPlayerResponse {
ip: String,
player_state: String,
admin_pkh: String,
}

#[get("/add_player?<address>&<id>")]
Expand Down Expand Up @@ -44,5 +45,6 @@ pub async fn add_player(
Ok(Json(AddPlayerResponse {
ip,
player_state: format!("{}#1", hex::encode(tx_hash)),
admin_pkh: hex::encode(client.tx_builder.admin_pkh),
}))
}
2 changes: 2 additions & 0 deletions crates/rpc/src/routes/new_game.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ pub struct NewGameResponse {
game_id: String,
ip: String,
player_state: String,
admin_pkh: String,
}

#[get("/new_game?<address>")]
Expand Down Expand Up @@ -48,5 +49,6 @@ pub async fn new_game(address: &str, state: &State<ClusterState>) -> Result<Json
game_id: node_id,
ip,
player_state: format!("{}#1", hex::encode(tx_hash)),
admin_pkh: hex::encode(client.tx_builder.admin_pkh),
}))
}

0 comments on commit 00e6a03

Please sign in to comment.