From 12c2f962dd87f72c79d98c5a20ed3528da451709 Mon Sep 17 00:00:00 2001 From: Quinine Date: Tue, 11 Feb 2025 17:04:10 +0100 Subject: [PATCH] fix grpc --- crates/utils/tcbinfo-updater/Cargo.toml | 2 ++ crates/utils/tcbinfo-updater/src/main.rs | 17 +++++++++++------ 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/crates/utils/tcbinfo-updater/Cargo.toml b/crates/utils/tcbinfo-updater/Cargo.toml index ee82d5c..5802022 100644 --- a/crates/utils/tcbinfo-updater/Cargo.toml +++ b/crates/utils/tcbinfo-updater/Cargo.toml @@ -23,3 +23,5 @@ mc-attestation-verifier.workspace = true p256.workspace = true x509-cert = "0.2.5" der.workspace = true +anyhow.workspace = true +hex.workspace = true diff --git a/crates/utils/tcbinfo-updater/src/main.rs b/crates/utils/tcbinfo-updater/src/main.rs index cb911b8..6810e53 100644 --- a/crates/utils/tcbinfo-updater/src/main.rs +++ b/crates/utils/tcbinfo-updater/src/main.rs @@ -1,6 +1,7 @@ -use cw_client::{CliClient, CwClient}; +use cw_client::{GrpcClient, CwClient}; use quartz_tcbinfo_msgs::{QueryMsg, ExecuteMsg}; use quoted_string::strip_dquotes; +use anyhow::{anyhow, Result}; use quoted_string::test_utils::TestSpec; use quoted_string::to_content; use reqwest::Url; @@ -41,11 +42,14 @@ async fn get_fmspc_list() -> Vec { fmspc_list } -async fn upsert_tcbinfo(url: &str, contract_addr: &str, chain_id : Id, sender: &str, gas: u64, fees: &str) -> Result<(), &'static str> { +async fn upsert_tcbinfo(url: &str, contract_addr: &str, chain_id : Id, sender: &str, gas: u64, fees: &str, sk: &str) -> Result<(), &'static str> { - let testnet = Url::parse(url).expect("couldn't parse network URL"); - - let client = CliClient::neutrond(testnet); + let network = Url::parse(url).expect("couldn't parse network URL"); + let skey = hex::decode(sk).expect("couldn't read signing key") + .as_slice() + .try_into() + .map_err(|e| anyhow!("failed to read/parse sk: {}", e)).expect("couldn't extract result value"); + let client = GrpcClient::new(skey, network); let fmspc_list = get_fmspc_list().await; for fmspc in fmspc_list { @@ -104,7 +108,8 @@ pub async fn main() { let sender: &str = &args[4]; let gas: &u64 = &args[5].parse().expect("gas must be a u64 value"); let fees: &str = &args[6]; - upsert_tcbinfo(url, contract_address, Id::try_from(chain_id.clone()).expect("invalid chain id"), sender, *gas, fees).await.expect("TCBInfo update failed"); + let sk: &str = &args[7]; + upsert_tcbinfo(url, contract_address, Id::try_from(chain_id.clone()).expect("invalid chain id"), sender, *gas, fees, sk).await.expect("TCBInfo update failed"); } /*let url =;