This commit is contained in:
Ajinkya Kulkarni 2024-12-05 15:47:54 +01:00
parent 95286858b0
commit 87193616f6

View file

@ -57,8 +57,16 @@ async fn upsert_tcbinfo() -> Result<(), &'static str> {
.parse()
.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 = to_content::<TestSpec>(&tcbinfo_on_chain_json["data"]["tcb_info"].to_string()).unwrap().to_string();
let tcbinfo_on_chain = { if let Ok(res) = client.query_smart::<Value>(&contract_address, json!(query_msg)).await {
to_content::<TestSpec>(&res["data"]["tcb_info"].to_string()).unwrap().to_string()
} else {
"".to_string()
}
};
println!("{tcbinfo_on_chain} \n {tcbinfo_from_api}");
if tcbinfo_on_chain != tcbinfo_from_api {
println!("updating on-chain TCBInfo for FMSPC: {fmspc}");