Use NODE var in scripts (#89)
Co-authored-by: hu55a1n1 <sufialhussaini@gmail.com>
This commit is contained in:
parent
4ddddf19e4
commit
264f2ee2eb
3 changed files with 19 additions and 11 deletions
|
@ -3,6 +3,7 @@ use std::path::PathBuf;
|
|||
use clap::{Parser, Subcommand};
|
||||
use cosmrs::{tendermint::chain::Id, AccountId};
|
||||
use displaydoc::Display;
|
||||
use reqwest::Url;
|
||||
use subtle_encoding::{bech32::decode as bech32_decode, Error as Bech32DecodeError};
|
||||
use thiserror::Error;
|
||||
|
||||
|
@ -14,12 +15,8 @@ pub struct Cli {
|
|||
pub verbose: bool,
|
||||
|
||||
/// The host to which to bind the API server.
|
||||
#[arg(short = 'H', long, default_value = "0.0.0.0")]
|
||||
pub host: String,
|
||||
|
||||
/// The port to which to bind the API server.
|
||||
#[arg(short, long, default_value = "8000")]
|
||||
pub port: u16,
|
||||
#[arg(short = 'N', long, default_value = "http://127.0.0.1:26657")]
|
||||
pub node: Url,
|
||||
|
||||
/// Path to output CSV file
|
||||
#[arg(short, long)]
|
||||
|
|
|
@ -76,7 +76,7 @@ async fn main() -> Result<(), DynError> {
|
|||
}
|
||||
|
||||
async fn sync_setoffs(cli: Cli) -> Result<(), DynError> {
|
||||
let wasmd_client = CliWasmdClient;
|
||||
let wasmd_client = CliWasmdClient::new(cli.node);
|
||||
let query_result: QueryResult<QueryAllSetoffsResponse> =
|
||||
wasmd_client.query_smart(&cli.contract, json!("get_all_setoffs"))?;
|
||||
let setoffs = query_result.data.setoffs;
|
||||
|
@ -145,7 +145,7 @@ async fn sync_obligations(cli: Cli, epoch_pk: &str) -> Result<(), DynError> {
|
|||
info!("Encrypted {} intents", intents_enc.len());
|
||||
|
||||
let msg = create_wasm_msg(intents_enc);
|
||||
let wasmd_client = CliWasmdClient;
|
||||
let wasmd_client = CliWasmdClient::new(cli.node);
|
||||
wasmd_client.tx_execute(&cli.contract, &cli.chain_id, 3000000, cli.user, msg)?;
|
||||
|
||||
Ok(())
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
use std::{error::Error, process::Command};
|
||||
|
||||
use cosmrs::{tendermint::chain::Id, AccountId};
|
||||
use reqwest::Url;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
pub trait WasmdClient {
|
||||
|
@ -25,9 +26,6 @@ pub trait WasmdClient {
|
|||
) -> Result<(), Self::Error>;
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct CliWasmdClient;
|
||||
|
||||
#[derive(Clone, Debug, Serialize, Deserialize)]
|
||||
pub struct QueryResult<T> {
|
||||
pub data: T,
|
||||
|
@ -43,6 +41,17 @@ impl<T: for<'any> Deserialize<'any>> FromVec for T {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct CliWasmdClient {
|
||||
url: Url,
|
||||
}
|
||||
|
||||
impl CliWasmdClient {
|
||||
pub fn new(url: Url) -> Self {
|
||||
Self { url }
|
||||
}
|
||||
}
|
||||
|
||||
impl WasmdClient for CliWasmdClient {
|
||||
type Address = AccountId;
|
||||
type Query = serde_json::Value;
|
||||
|
@ -56,6 +65,7 @@ impl WasmdClient for CliWasmdClient {
|
|||
) -> Result<R, Self::Error> {
|
||||
let mut wasmd = Command::new("wasmd");
|
||||
let command = wasmd
|
||||
.args(["--node", self.url.as_str()])
|
||||
.args(["query", "wasm"])
|
||||
.args(["contract-state", "smart", contract.as_ref()])
|
||||
.arg(query.to_string())
|
||||
|
@ -78,6 +88,7 @@ impl WasmdClient for CliWasmdClient {
|
|||
) -> Result<(), Self::Error> {
|
||||
let mut wasmd = Command::new("wasmd");
|
||||
let command = wasmd
|
||||
.args(["--node", self.url.as_str()])
|
||||
.args(["tx", "wasm"])
|
||||
.args(["execute", contract.as_ref(), &msg.to_string()])
|
||||
.args(["--chain-id", chain_id.as_ref()])
|
||||
|
|
Loading…
Reference in a new issue