always using http client in v034 compat mode
This commit is contained in:
@@ -2,9 +2,9 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
use cosmrs::bank::MsgSend;
|
||||
use cosmrs::rpc::HttpClient;
|
||||
use cosmrs::tx::Msg;
|
||||
use cosmrs::{tx, AccountId, Coin, Denom};
|
||||
use nym_validator_client::http_client;
|
||||
use nym_validator_client::nyxd::CosmWasmClient;
|
||||
use nym_validator_client::signing::direct_wallet::DirectSecp256k1HdWallet;
|
||||
use nym_validator_client::signing::tx_signer::TxSigner;
|
||||
@@ -27,7 +27,7 @@ async fn main() {
|
||||
|
||||
// possibly remote client that doesn't do ANY signing
|
||||
// (only broadcasts + queries for sequence numbers)
|
||||
let broadcaster = HttpClient::new(validator).unwrap();
|
||||
let broadcaster = http_client(validator).unwrap();
|
||||
|
||||
// get signer information
|
||||
let sequence_response = broadcaster.get_sequence(&signer_address).await.unwrap();
|
||||
|
||||
@@ -26,6 +26,7 @@ pub use nym_mixnet_contract_common::{
|
||||
// re-export the type to not break existing imports
|
||||
pub use crate::coconut::CoconutApiClient;
|
||||
|
||||
use crate::rpc::http_client;
|
||||
#[cfg(feature = "http-client")]
|
||||
use crate::{DirectSigningHttpRpcValidatorClient, HttpRpcClient, QueryHttpRpcValidatorClient};
|
||||
|
||||
@@ -95,7 +96,7 @@ impl Client<HttpRpcClient, DirectSecp256k1HdWallet> {
|
||||
config: Config,
|
||||
mnemonic: bip39::Mnemonic,
|
||||
) -> Result<DirectSigningHttpRpcValidatorClient, ValidatorClientError> {
|
||||
let rpc_client = HttpRpcClient::new(config.nyxd_url.as_str())?;
|
||||
let rpc_client = http_client(config.nyxd_url.as_str())?;
|
||||
let prefix = &config.nyxd_config.chain_details.bech32_account_prefix;
|
||||
let wallet = DirectSecp256k1HdWallet::from_mnemonic(prefix, mnemonic);
|
||||
|
||||
@@ -126,7 +127,7 @@ impl Client<ReqwestRpcClient, DirectSecp256k1HdWallet> {
|
||||
#[cfg(feature = "http-client")]
|
||||
impl Client<HttpRpcClient> {
|
||||
pub fn new_query(config: Config) -> Result<QueryHttpRpcValidatorClient, ValidatorClientError> {
|
||||
let rpc_client = HttpRpcClient::new(config.nyxd_url.as_str())?;
|
||||
let rpc_client = http_client(config.nyxd_url.as_str())?;
|
||||
Ok(Self::new_with_rpc_client(config, rpc_client))
|
||||
}
|
||||
|
||||
|
||||
@@ -20,6 +20,8 @@ pub use nym_api_requests::*;
|
||||
|
||||
#[cfg(feature = "http-client")]
|
||||
pub use cosmrs::rpc::HttpClient as HttpRpcClient;
|
||||
#[cfg(feature = "http-client")]
|
||||
pub use rpc::http_client;
|
||||
|
||||
// some type aliasing
|
||||
|
||||
|
||||
@@ -10,11 +10,14 @@ use crate::signing::{
|
||||
AccountData,
|
||||
};
|
||||
use async_trait::async_trait;
|
||||
use cosmrs::tx::{Raw, SignDoc};
|
||||
use std::fmt::Debug;
|
||||
use tendermint_rpc::{Error as TendermintRpcError, SimpleRequest};
|
||||
|
||||
#[cfg(feature = "http-client")]
|
||||
use crate::http_client;
|
||||
#[cfg(feature = "http-client")]
|
||||
use cosmrs::rpc::{HttpClient, HttpClientUrl};
|
||||
use cosmrs::tx::{Raw, SignDoc};
|
||||
|
||||
pub mod client_traits;
|
||||
mod helpers;
|
||||
@@ -73,7 +76,7 @@ impl<S> MaybeSigningClient<HttpClient, S> {
|
||||
where
|
||||
U: TryInto<HttpClientUrl, Error = TendermintRpcError>,
|
||||
{
|
||||
self.client = HttpClient::new(new_endpoint)?;
|
||||
self.client = http_client(new_endpoint)?;
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,9 +50,12 @@ use crate::signing::direct_wallet::DirectSecp256k1HdWallet;
|
||||
#[cfg(feature = "http-client")]
|
||||
use crate::{DirectSigningHttpRpcNyxdClient, QueryHttpRpcNyxdClient};
|
||||
use crate::{DirectSigningReqwestRpcNyxdClient, QueryReqwestRpcNyxdClient, ReqwestRpcClient};
|
||||
use url::Url;
|
||||
|
||||
#[cfg(feature = "http-client")]
|
||||
use crate::http_client;
|
||||
#[cfg(feature = "http-client")]
|
||||
use cosmrs::rpc::{HttpClient, HttpClientUrl};
|
||||
use url::Url;
|
||||
|
||||
pub mod coin;
|
||||
pub mod contract_traits;
|
||||
@@ -97,7 +100,7 @@ impl NyxdClient<HttpClient> {
|
||||
where
|
||||
U: TryInto<HttpClientUrl, Error = TendermintRpcError>,
|
||||
{
|
||||
let client = HttpClient::new(endpoint)?;
|
||||
let client = http_client(endpoint)?;
|
||||
|
||||
Ok(NyxdClient {
|
||||
client: MaybeSigningClient::new(client, (&config).into()),
|
||||
@@ -140,7 +143,7 @@ impl NyxdClient<HttpClient, DirectSecp256k1HdWallet> {
|
||||
where
|
||||
U: TryInto<HttpClientUrl, Error = TendermintRpcError>,
|
||||
{
|
||||
let client = HttpClient::new(endpoint)?;
|
||||
let client = http_client(endpoint)?;
|
||||
|
||||
let prefix = &config.chain_details.bech32_account_prefix;
|
||||
let wallet = DirectSecp256k1HdWallet::from_mnemonic(prefix, mnemonic);
|
||||
|
||||
@@ -11,8 +11,27 @@ use tendermint_rpc::{
|
||||
Error, Order, Paging, SimpleRequest,
|
||||
};
|
||||
|
||||
#[cfg(feature = "http-client")]
|
||||
use crate::error::TendermintRpcError;
|
||||
#[cfg(feature = "http-client")]
|
||||
use crate::HttpRpcClient;
|
||||
#[cfg(feature = "http-client")]
|
||||
use tendermint_rpc::client::CompatMode;
|
||||
#[cfg(feature = "http-client")]
|
||||
use tendermint_rpc::HttpClientUrl;
|
||||
|
||||
pub mod reqwest;
|
||||
|
||||
#[cfg(feature = "http-client")]
|
||||
pub fn http_client<U>(url: U) -> Result<HttpRpcClient, TendermintRpcError>
|
||||
where
|
||||
U: TryInto<HttpClientUrl, Error = Error>,
|
||||
{
|
||||
HttpRpcClient::builder(url.try_into()?)
|
||||
.compat_mode(CompatMode::V0_34)
|
||||
.build()
|
||||
}
|
||||
|
||||
// we have to create a sealed trait since `TendermintClient` needs T: Send (due to how async trait is created)
|
||||
// which we can't do in wasm
|
||||
#[cfg_attr(target_arch = "wasm32", async_trait(?Send))]
|
||||
|
||||
Reference in New Issue
Block a user