Skip to content

Commit

Permalink
chain-id
Browse files Browse the repository at this point in the history
  • Loading branch information
dzmitry-lahoda committed Mar 27, 2024
1 parent de808ab commit e359a79
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 9 deletions.
9 changes: 6 additions & 3 deletions mantis/node/src/bin/mantis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,14 +139,17 @@ async fn simulate_orders(simulate_args: &SimulateArgs) {
.coins
.choose(&mut rand::thread_rng())
.expect("some");

let rpc = CosmosChainInfo {
rpc: args.rpc_centauri.clone(),
chain_id: args.main_chain_id.clone(),
};
simulate::simulate_order(
&mut write_client,
&mut cosmos_query_client,
args.order_contract.clone(),
pair,
&signer,
&args.rpc_centauri,
&rpc,
&tip,
gas,
)
Expand Down Expand Up @@ -217,7 +220,7 @@ async fn send_solution(
let result = tx_broadcast_single_signed_msg(
msg.to_any().expect("proto"),
auth_info,
rpc,
panic!(), // rpc,
signing_key,
tip,
)
Expand Down
3 changes: 3 additions & 0 deletions mantis/node/src/mantis/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ pub enum AssetCommands {

#[derive(clap::Parser, Debug)]
pub struct SharedArgs {
#[arg(long)]
pub main_chain_id: String,

/// the node hosting order contract
#[arg(long)]
pub rpc_centauri: String,
Expand Down
2 changes: 1 addition & 1 deletion mantis/node/src/mantis/autopilot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ pub async fn cleanup(
tx_broadcast_single_signed_msg(
msg.to_any().expect("proto"),
auth_info,
rpc,
panic!(),
signing_key,
tip,
)
Expand Down
12 changes: 9 additions & 3 deletions mantis/node/src/mantis/cosmos/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,10 +136,16 @@ pub async fn sign_and_tx_tendermint(
result
}

#[derive(Debug, Clone)]
pub struct CosmosChainInfo {
pub rpc: String,
pub chain_id: String,
}

pub async fn tx_broadcast_single_signed_msg(
msg: Any,
auth_info: tx::AuthInfo,
rpc: &str,
rpc: &CosmosChainInfo,
signing_key: &cosmrs::crypto::secp256k1::SigningKey,
tip: &Tip,
) -> cosmrs::rpc::endpoint::broadcast::tx_commit::Response {
Expand All @@ -148,12 +154,12 @@ pub async fn tx_broadcast_single_signed_msg(
let sign_doc = SignDoc::new(
&tx_body,
&auth_info,
&chain::Id::try_from("centauri-1").expect("id"),
&chain::Id::try_from(rpc.chain_id.as_ref()).expect("chain_id"),
tip.account.account_number,
)
.unwrap();

sign_and_tx_tendermint(rpc, sign_doc, signing_key).await
sign_and_tx_tendermint(&rpc.rpc, sign_doc, signing_key).await
}

/// simulates tx and ensure fees are within limits
Expand Down
4 changes: 2 additions & 2 deletions mantis/node/src/mantis/simulate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use crate::{
};

use super::cosmos::{
client::{timeout, CosmWasmWriteClient, CosmosQueryClient, Tip},
client::{timeout, CosmWasmWriteClient, CosmosChainInfo, CosmosQueryClient, Tip},
cosmwasm::parse_coin_pair,
};

Expand Down Expand Up @@ -68,7 +68,7 @@ pub async fn simulate_order(
order_contract: String,
coins_pair: &String,
signing_key: &cosmrs::crypto::secp256k1::SigningKey,
rpc: &str,
rpc: &CosmosChainInfo,
tip: &Tip,
gas: Gas,
) {
Expand Down

0 comments on commit e359a79

Please sign in to comment.