This commit is contained in:
Ajinkya Kulkarni 2024-12-05 15:22:57 +01:00
parent 4ea6528d42
commit d78c2559aa

View file

@ -1,6 +1,8 @@
use cw_client::{CliClient, CwClient};
use quartz_tcbinfo_msgs::{QueryMsg, ExecuteMsg};
use quoted_string::strip_dquotes;
use quoted_string::test_utils::TestSpec;
use quoted_string::to_content;
use reqwest::Url;
use serde_json::{json, Value};
@ -55,7 +57,7 @@ async fn upsert_tcbinfo() -> Result<(), &'static str> {
.expect("failed to parse contract address");
let query_msg = QueryMsg::GetTcbInfo { fmspc: fmspc.clone() };
let tcbinfo_on_chain_json: Value = client.query_smart(&contract_address, json!(query_msg)).await.expect("contract query failed");
let tcbinfo_on_chain = strip_dquotes(format!("{}", tcbinfo_on_chain_json["data"]["tcb_info"]).as_ref()).unwrap().to_string();
let tcbinfo_on_chain = format_json_string(tcbinfo_on_chain_json);
println!("{tcbinfo_on_chain} \n {tcbinfo_from_api}");
if tcbinfo_on_chain != tcbinfo_from_api {
println!("updating on-chain TCBInfo for FMSPC: {fmspc}");
@ -86,7 +88,11 @@ async fn upsert_tcbinfo() -> Result<(), &'static str> {
Ok(())
}
fn format_json_string(input: Value) -> String {
let without_end_quotes = strip_dquotes(format!("{}", input["data"]["tcb_info"]).as_ref()).unwrap().to_string();
let content = to_content::<TestSpec>(&without_end_quotes).unwrap().to_string();
content
}
#[tokio::main]
pub async fn main() {