WIP
This commit is contained in:
parent
4ea6528d42
commit
d78c2559aa
1 changed files with 8 additions and 2 deletions
|
@ -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() {
|
||||
|
|
Loading…
Reference in a new issue