Skip to content

Commit

Permalink
refactor(host,sgx): import the json macro
Browse files Browse the repository at this point in the history
  • Loading branch information
petarvujovic98 committed Sep 12, 2024
1 parent 8508214 commit 7b48300
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 10 deletions.
7 changes: 2 additions & 5 deletions host/src/server/api/v1/mod.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use axum::{response::IntoResponse, Router};
use raiko_lib::input::GuestOutput;
use serde::{Deserialize, Serialize};
use serde_json::Value;
use serde_json::{json, Value};
use tower::ServiceBuilder;
use utoipa::{OpenApi, ToSchema};
use utoipa_scalar::{Scalar, Servable};
Expand Down Expand Up @@ -62,10 +62,7 @@ pub struct ProofResponse {

impl ProofResponse {
pub fn to_response(&self) -> Value {
serde_json::json!({
"status": "ok",
"data": self
})
json!({ "status": "ok", "data": self })
}
}

Expand Down
7 changes: 4 additions & 3 deletions host/tests/common/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use raiko_core::interfaces::{ProofRequestOpt, ProofType, ProverSpecificOpts};
use raiko_host::{server::serve, ProverState};
use raiko_lib::consts::{Network, SupportedChainSpecs};
use serde::Deserialize;
use serde_json::json;
use tokio_util::sync::CancellationToken;

mod client;
Expand Down Expand Up @@ -38,7 +39,7 @@ pub async fn find_recent_block(network: Network) -> anyhow::Result<u64> {

let response = client
.post(beacon.clone())
.json(&serde_json::json!({
.json(&json!({
"jsonrpc": "2.0",
"method": "eth_blockNumber",
"params": [],
Expand All @@ -58,7 +59,7 @@ pub async fn find_recent_block(network: Network) -> anyhow::Result<u64> {
for block_number in latest_blocks {
let response = client
.post(beacon.clone())
.json(&serde_json::json!({
.json(&json!({
"jsonrpc": "2.0",
"method": "eth_getBlockByNumber",
"params": [format!("0x{block_number:x}"), false],
Expand Down Expand Up @@ -130,7 +131,7 @@ pub async fn make_request() -> anyhow::Result<ProofRequestOpt> {
prover_args: ProverSpecificOpts {
native: None,
sgx: None,
sp1: Some(serde_json::json!({ "verify": false })),
sp1: Some(json!({ "verify": false })),
risc0: None,
},
})
Expand Down
5 changes: 3 additions & 2 deletions provers/sgx/guest/src/one_shot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ use raiko_lib::{
};
use secp256k1::{Keypair, SecretKey};
use serde::Serialize;
use serde_json::json;

base64_serde_type!(Base64Standard, base64::engine::general_purpose::STANDARD);

Expand Down Expand Up @@ -68,7 +69,7 @@ fn save_bootstrap_details(
quote: hex::encode(quote),
};

println!("{}", serde_json::json!(&bootstrap_details));
println!("{}", json!(&bootstrap_details));
let json = serde_json::to_string_pretty(&bootstrap_details)?;
fs::write(bootstrap_details_file_path, json).context(format!(
"Saving bootstrap data file {} failed",
Expand Down Expand Up @@ -155,7 +156,7 @@ pub async fn one_shot(global_opts: GlobalOpts, args: OneShotArgs) -> Result<()>

// Print out the proof and updated public info
let quote = get_sgx_quote()?;
let data = serde_json::json!({
let data = json!({
"proof": format!("0x{proof}"),
"quote": hex::encode(quote),
"public_key": format!("0x{new_pubkey}"),
Expand Down

0 comments on commit 7b48300

Please sign in to comment.