Skip to content

Commit

Permalink
fix Tendermint client for Namada
Browse files Browse the repository at this point in the history
  • Loading branch information
yito88 committed Oct 17, 2023
1 parent 526851f commit e8ab47b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
15 changes: 5 additions & 10 deletions crates/relayer/src/chain/namada/tx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,13 @@ use namada::sdk::rpc::TxBroadcastData;
use namada::sdk::wallet::Wallet;
use namada::sdk::{signing, tx};
use namada::tendermint_rpc::endpoint::broadcast::tx_sync::Response as AbciPlusRpcResponse;
use namada::tendermint_rpc::HttpClient;
use namada::tendermint_rpc::{HttpClient, Url};
use namada::types::address::{Address, ImplicitAddress};
use namada::types::chain::ChainId;
use namada::types::io::DefaultIo;
use namada::types::key::RefTo;
use namada::types::transaction::{GasLimit, TxType};
use namada_apps::cli::api::CliClient;
use namada_apps::client::tx::CLIShieldedUtils;
use namada_apps::facade::tendermint_config::net::Address as TendermintAddress;
use namada_apps::wallet::CliWalletUtils;
use tendermint_rpc::endpoint::broadcast::tx_sync::Response;

Expand All @@ -38,13 +36,10 @@ const WAIT_BACKOFF: Duration = Duration::from_millis(300);

impl NamadaChain {
pub fn send_tx(&mut self, proto_msg: &Any) -> Result<Response, Error> {
let mut ledger_address = TendermintAddress::from_str(&format!(
"{}:{}",
self.config.rpc_addr.host(),
self.config.rpc_addr.port()
))
.expect("invalid ledger address");
let client = HttpClient::from_tendermint_address(&mut ledger_address);
// Convert Url for Namada's tendermint-rpc
let url = Url::from_str(&self.config.rpc_addr.to_string()).expect("invalid RPC address");
let client =
HttpClient::new(url.clone()).map_err(|e| Error::namada_tendermint_rpc(url, e))?;

let mut tx_data = vec![];
prost::Message::encode(proto_msg, &mut tx_data)
Expand Down
6 changes: 6 additions & 0 deletions crates/relayer/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ use namada::tendermint::Error as AbciPlusTmError;
use namada::tendermint::Error as NamadaTendermintError;
use namada::tendermint_proto::Error as AbciPlusTmProtoError;
use namada::tendermint_rpc::Error as TendermintAbciPlusRpcError;
use namada::tendermint_rpc::Error as NamadaTmRpcError;
use namada::types::token::Amount;
use prost::{DecodeError, EncodeError};
use regex::Regex;
Expand Down Expand Up @@ -614,6 +615,11 @@ define_error! {
[ NamadaTendermintError ]
|_| { "Tendermint error" },

NamadaTendermintRpc
{ url: namada::tendermint_rpc::Url }
[ NamadaTmRpcError ]
|e| { format!("RPC error to endpoint {}", e.url) },

NamadaQuery
{ description: String }
|e| { format!("Namada query failed: {}", e.description) },
Expand Down

0 comments on commit e8ab47b

Please sign in to comment.