diff --git a/crates/utils/cw-client/src/cli.rs b/crates/utils/cw-client/src/cli.rs index a352be4..cfbb555 100644 --- a/crates/utils/cw-client/src/cli.rs +++ b/crates/utils/cw-client/src/cli.rs @@ -1,5 +1,5 @@ use std::process::Command; - +use serde_json::Value; use color_eyre::{eyre::eyre, Help, Report, Result}; use cosmrs::{tendermint::chain::Id, AccountId}; use reqwest::Url; @@ -47,15 +47,7 @@ impl CliClient { } } - pub fn neutrond(url: Url) -> Self { - Self { - kind: CliClientType::Neutrond, - url, - gas_price: "0.0053untrn".to_string(), - } - } - - fn new_command(&self) -> Result { + fn new_command(&self) -> Result { let bin = self.kind.bin(); if !self.is_bin_available(&bin) { return Err(eyre!("Binary '{}' not found in PATH", bin)).suggestion(format!( @@ -65,7 +57,29 @@ impl CliClient { } Ok(Command::new(self.kind.bin())) + } + + pub fn neutrond( url: Url) -> Self { + let mut command = Command::new("neutrond"); + let command = command + .arg("q") + .arg("feemarket") + .arg("gas-price") + .arg("untrn") + .arg ("-o") + .arg("json"); + let output = command.output().expect("command output failed").stdout; + let output_str: String = std::str::from_utf8(&output).expect("unable to parse command output").to_string(); + let json: Value = serde_json::from_str(&output_str).expect("could not convert to JSON"); + let gas_price = &json["price"]["amount"]; + + Self { + kind: CliClientType::Neutrond, + url, + gas_price: gas_price.to_string(), + } } + fn is_bin_available(&self, bin: &str) -> bool { Command::new("which") .arg(bin) @@ -149,10 +163,9 @@ impl CwClient for CliClient { &self, contract: &Self::Address, chain_id: &Id, - gas: u64, + _gas: u64, sender: &str, msg: M, - fees: &str, ) -> Result { let mut command = self.new_command()?; let command = command @@ -160,12 +173,13 @@ impl CwClient for CliClient { .args(["--chain-id", chain_id.as_ref()]) .args(["tx", "wasm"]) .args(["execute", contract.as_ref(), &msg.to_string()]) - .args(["--gas", &gas.to_string()]) - .args(["--fees", fees]) + .args(["--gas", "auto"]) + .args(["--gas-prices", &self.gas_price]) .args(["--from", sender]) + .args(["--gas-adjustment", "1.3"]) + .args(["--output", "json"]) .arg("-y"); - let output = command.output()?; if !output.status.success() { @@ -221,7 +235,7 @@ impl CwClient for CliClient { .args(["--from", sender]) .arg("--no-admin") .args(["--chain-id", chain_id.as_ref()]) - .args(["--gas-prices", &self.gas_price]) + .args(["--gas-prices", "0.0053untrn"]) .args(["--gas", "auto"]) .args(["--gas-adjustment", "1.3"]) .args(["-o", "json"]) diff --git a/crates/utils/cw-client/src/grpc.rs b/crates/utils/cw-client/src/grpc.rs index 00eb4c2..e8d8bf0 100644 --- a/crates/utils/cw-client/src/grpc.rs +++ b/crates/utils/cw-client/src/grpc.rs @@ -87,8 +87,7 @@ impl CwClient for GrpcClient { chain_id: &TmChainId, gas: u64, _sender: &str, - msg: M, - _fees: &str, + msg: M ) -> Result { let tm_pubkey = self.sk.public_key(); let sender = tm_pubkey diff --git a/crates/utils/cw-client/src/lib.rs b/crates/utils/cw-client/src/lib.rs index 70ecb59..3141457 100644 --- a/crates/utils/cw-client/src/lib.rs +++ b/crates/utils/cw-client/src/lib.rs @@ -36,8 +36,7 @@ pub trait CwClient { chain_id: &Id, gas: u64, sender: &str, - msg: M, - fees: &str, + msg: M ) -> Result; fn deploy( diff --git a/crates/utils/tcbinfo-updater/src/main.rs b/crates/utils/tcbinfo-updater/src/main.rs index 7440a95..36e53c7 100644 --- a/crates/utils/tcbinfo-updater/src/main.rs +++ b/crates/utils/tcbinfo-updater/src/main.rs @@ -1,7 +1,6 @@ use cw_client::{CliClient, 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; @@ -42,7 +41,7 @@ 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) -> Result<(), &'static str> { let network = Url::parse(url).expect("couldn't parse network URL"); let client = CliClient::neutrond(network); @@ -82,8 +81,7 @@ async fn upsert_tcbinfo(url: &str, contract_addr: &str, chain_id : Id, sender: & &chain_id, gas, sender, - json!(execute_msg), - fees + json!(execute_msg) ) .await; println!("{res:?}"); @@ -103,8 +101,7 @@ pub async fn main() { let contract_address : &str = &args[3]; 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"); + upsert_tcbinfo(url, contract_address, Id::try_from(chain_id.clone()).expect("invalid chain id"), sender, *gas).await.expect("TCBInfo update failed"); } /*let url =;