Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[r2r] tendermint missing implementations #1526

Merged
merged 52 commits into from
Dec 4, 2022
Merged
Show file tree
Hide file tree
Changes from 51 commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
3f37204
increase simulated gas to predict better values for real tx operations
onur-ozkan Oct 28, 2022
9b43af6
remove couple TODO notes and impelement `lp_coins::wait_for_confirmat…
onur-ozkan Oct 29, 2022
60b34af
create new fn `tendermint_coin::get_tx_status_code_or_none`
onur-ozkan Oct 29, 2022
9df1043
if no `gui_auth` was given, consider it as `false`
onur-ozkan Oct 29, 2022
f0dab01
implement `get_sender_trade_fee`
onur-ozkan Nov 1, 2022
6db1133
implement `trade_fee` functionalities for cosmos
onur-ozkan Nov 2, 2022
ddb9eb8
Merge branch 'dev' of github.com:KomodoPlatform/atomicDEX-API into ir…
onur-ozkan Nov 4, 2022
8e856f8
group wasm and native rpcs under the rpc mod
onur-ozkan Nov 4, 2022
4fdda30
Create TendermintResultOrder and impl it's required traits
onur-ozkan Nov 4, 2022
55c2eaf
fix wasm compilation
onur-ozkan Nov 4, 2022
39849af
fix avg_blocktime confusion
onur-ozkan Nov 9, 2022
6159da1
save dev state
onur-ozkan Nov 10, 2022
3e203aa
save dev state
onur-ozkan Nov 11, 2022
88c6dfb
save dev state
onur-ozkan Nov 14, 2022
fa2cfe3
Merge branch 'dev' of github.com:KomodoPlatform/atomicDEX-API into ir…
onur-ozkan Nov 14, 2022
e389050
add iris mod
onur-ozkan Nov 14, 2022
d67d952
fix wasm compilation
onur-ozkan Nov 15, 2022
64b35f4
save dev state
onur-ozkan Nov 15, 2022
69e0760
save dev state
onur-ozkan Nov 15, 2022
272b43f
add TODO notes
onur-ozkan Nov 15, 2022
1629f68
add TODO note
onur-ozkan Nov 15, 2022
7c778c9
avoid memory pressure, skip existed txs in tx_history, add fee_details
onur-ozkan Nov 15, 2022
8569d08
remove no-longer required notes
onur-ozkan Nov 15, 2022
ab44185
save dev state
onur-ozkan Nov 16, 2022
d1f2013
implement `WaitForHistoryUpdateTrigger` for tendermint tx_history v2
onur-ozkan Nov 16, 2022
5a68ea9
remove not required todo notes
onur-ozkan Nov 16, 2022
676bb42
update `fn process_history_loop`
onur-ozkan Nov 16, 2022
0a9ea7a
update TODO notes of tendermint_token
onur-ozkan Nov 16, 2022
b94a4b1
save dev state
onur-ozkan Nov 16, 2022
b9d4d02
complete tx_history_v2 functionality for tendermint
onur-ozkan Nov 16, 2022
ed6322e
move token insert to right before of result returning
onur-ozkan Nov 16, 2022
db25d4a
implement better error handling for tx_history v2 on tendermint
onur-ozkan Nov 17, 2022
0ad2fc4
shorten `fn is_tx_exists`
onur-ozkan Nov 17, 2022
e4a527b
Merge branch 'dev' of github.com:KomodoPlatform/atomicDEX-API into ir…
onur-ozkan Nov 21, 2022
a1f0f93
rename `iris_swap_poc` into `iris_swap` remove ingored flag from the …
onur-ozkan Nov 21, 2022
f3b6ca9
update name of the iris swap test function
onur-ozkan Nov 21, 2022
99eafff
Merge branch 'dev' of github.com:KomodoPlatform/atomicDEX-API into ir…
onur-ozkan Nov 21, 2022
0742161
re-ignore iris swap integration tests because of iris bug
onur-ozkan Nov 21, 2022
f010c0e
fix review notes
onur-ozkan Nov 26, 2022
9ca93ef
Merge branch 'dev' of github.com:KomodoPlatform/atomicDEX-API into ir…
onur-ozkan Nov 28, 2022
f0049e9
show extra tx for platform fees on token txs
onur-ozkan Nov 28, 2022
df6227e
partial fixes for review notes
onur-ozkan Nov 28, 2022
8a7af6f
update expected log for tendermint tx history test
onur-ozkan Nov 28, 2022
e4deb1d
read highest height for tendermint history
onur-ozkan Nov 29, 2022
eba32b0
remap tx amounts and insert all possible assets for tendermint
onur-ozkan Nov 29, 2022
9a51ac5
fix balance problem
onur-ozkan Nov 29, 2022
b4c64ec
skip `uamount` field for `TendermintFeeDetails`
onur-ozkan Nov 29, 2022
a808a1a
parse multiple tx events
onur-ozkan Nov 29, 2022
8f9f78e
save dev state
onur-ozkan Nov 30, 2022
fd6daba
remove debug lines
onur-ozkan Nov 30, 2022
e5308d9
refactor tendermit tx history test
onur-ozkan Nov 30, 2022
9f88a65
fix review notes
onur-ozkan Dec 2, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion mm2src/coins/eth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3258,7 +3258,7 @@ impl MmCoin for EthCoin {
})
}

fn get_receiver_trade_fee(&self, stage: FeeApproxStage) -> TradePreimageFut<TradeFee> {
fn get_receiver_trade_fee(&self, _send_amount: BigDecimal, stage: FeeApproxStage) -> TradePreimageFut<TradeFee> {
let coin = self.clone();
let fut = async move {
let gas_price = coin.get_gas_price().compat().await?;
Expand Down
2 changes: 1 addition & 1 deletion mm2src/coins/eth/eth_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -932,7 +932,7 @@ fn get_receiver_trade_preimage() {
};

let actual = coin
.get_receiver_trade_fee(FeeApproxStage::WithoutApprox)
.get_receiver_trade_fee(Default::default(), FeeApproxStage::WithoutApprox)
.wait()
.expect("!get_sender_trade_fee");
assert_eq!(actual, expected_fee);
Expand Down
2 changes: 1 addition & 1 deletion mm2src/coins/lightning.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1056,7 +1056,7 @@ impl MmCoin for LightningCoin {
}

// Todo: This uses dummy data for now for the sake of swap P.O.C., this should be implemented probably after agreeing on how fees will work for lightning
fn get_receiver_trade_fee(&self, _stage: FeeApproxStage) -> TradePreimageFut<TradeFee> {
fn get_receiver_trade_fee(&self, _send_amount: BigDecimal, _stage: FeeApproxStage) -> TradePreimageFut<TradeFee> {
Box::new(futures01::future::ok(TradeFee {
coin: self.ticker().to_owned(),
amount: Default::default(),
Expand Down
3 changes: 2 additions & 1 deletion mm2src/coins/lp_coins.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1042,6 +1042,7 @@ pub enum TransactionType {
RemoveDelegation,
StandardTransfer,
TokenTransfer(BytesJson),
Fee(BytesJson),
}

impl Default for TransactionType {
Expand Down Expand Up @@ -1908,7 +1909,7 @@ pub trait MmCoin: SwapOps + WatcherOps + MarketCoinOps + Send + Sync + 'static {
) -> TradePreimageResult<TradeFee>;

/// Get fee to be paid by receiver per whole swap and check if the wallet has sufficient balance to pay the fee.
fn get_receiver_trade_fee(&self, stage: FeeApproxStage) -> TradePreimageFut<TradeFee>;
fn get_receiver_trade_fee(&self, send_amount: BigDecimal, stage: FeeApproxStage) -> TradePreimageFut<TradeFee>;

/// Get transaction fee the Taker has to pay to send a `TakerFee` transaction and check if the wallet has sufficient balance to pay the fee.
async fn get_fee_to_send_taker_fee(
Expand Down
87 changes: 68 additions & 19 deletions mm2src/coins/my_tx_history_v2.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
use crate::hd_wallet::{AddressDerivingError, InvalidBip44ChainError};
use crate::tendermint::{TENDERMINT_ASSET_PROTOCOL_TYPE, TENDERMINT_COIN_PROTOCOL_TYPE};
use crate::tx_history_storage::{CreateTxHistoryStorageError, FilteringAddresses, GetTxHistoryFilters,
TxHistoryStorageBuilder, WalletId};
use crate::{lp_coinfind_or_err, BlockHeightAndTime, CoinFindError, HDAccountAddressId, HistorySyncState, MmCoin,
MmCoinEnum, Transaction, TransactionDetails, TransactionType, TxFeeDetails, UtxoRpcError};
use crate::utxo::utxo_common::big_decimal_from_sat_unsigned;
use crate::{coin_conf, lp_coinfind_or_err, BlockHeightAndTime, CoinFindError, HDAccountAddressId, HistorySyncState,
MmCoin, MmCoinEnum, Transaction, TransactionDetails, TransactionType, TxFeeDetails, UtxoRpcError};
use async_trait::async_trait;
use bitcrypto::sha256;
use common::{calc_total_pages, ten, HttpStatusCode, PagingOptionsEnum, StatusCode};
Expand All @@ -13,8 +15,10 @@ use keys::{Address, CashAddress};
use mm2_core::mm_ctx::MmArc;
use mm2_err_handle::prelude::*;
use mm2_number::BigDecimal;
use num_traits::ToPrimitive;
use rpc::v1::types::{Bytes as BytesJson, ToTxHash};
use std::collections::HashSet;
use std::mem::discriminant;

#[derive(Debug)]
pub enum RemoveTxResult {
Expand Down Expand Up @@ -69,6 +73,9 @@ pub trait TxHistoryStorage: Send + Sync + 'static {
internal_id: &BytesJson,
) -> Result<Option<TransactionDetails>, MmError<Self::Error>>;

/// Gets the highest block_height from the selected wallet's history
async fn get_highest_block_height(&self, wallet_id: &WalletId) -> Result<Option<u32>, MmError<Self::Error>>;

/// Returns whether the history contains unconfirmed transactions.
async fn history_contains_unconfirmed_txes(
&self,
Expand Down Expand Up @@ -210,7 +217,7 @@ impl<'a, Addr: Clone + DisplayAddress + Eq + std::hash::Hash, Tx: Transaction> T

let tx_hash = self.tx.tx_hash();
let internal_id = match &self.transaction_type {
TransactionType::TokenTransfer(token_id) => {
TransactionType::TokenTransfer(token_id) | TransactionType::Fee(token_id) => {
let mut bytes_for_hash = tx_hash.0.clone();
bytes_for_hash.extend_from_slice(&token_id.0);
sha256(&bytes_for_hash).to_vec().into()
Expand Down Expand Up @@ -375,6 +382,8 @@ pub async fn my_tx_history_v2_rpc(
MmCoinEnum::SlpToken(slp_token) => my_tx_history_v2_impl(ctx, &slp_token, request).await,
MmCoinEnum::UtxoCoin(utxo) => my_tx_history_v2_impl(ctx, &utxo, request).await,
MmCoinEnum::QtumCoin(qtum) => my_tx_history_v2_impl(ctx, &qtum, request).await,
MmCoinEnum::Tendermint(tendermint) => my_tx_history_v2_impl(ctx, &tendermint, request).await,
MmCoinEnum::TendermintToken(tendermint_token) => my_tx_history_v2_impl(ctx, &tendermint_token, request).await,
other => MmError::err(MyTxHistoryErrorV2::NotSupportedFor(other.ticker().to_owned())),
}
}
Expand Down Expand Up @@ -406,22 +415,62 @@ where
.get_history(&wallet_id, filters, request.paging_options.clone(), request.limit)
.await?;

let transactions = history
.transactions
.into_iter()
.map(|mut details| {
// it can be the platform ticker instead of the token ticker for a pre-saved record
if details.coin != request.coin {
details.coin = request.coin.clone();
}
let confirmations = if details.block_height == 0 || details.block_height > current_block {
0
} else {
current_block + 1 - details.block_height
};
MyTxHistoryDetails { confirmations, details }
})
.collect();
let coin_conf = coin_conf(&ctx, coin.ticker());
let protocol_type = coin_conf["protocol"]["type"].as_str().unwrap_or_default();
Comment on lines +427 to +428
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of getting the protocol type from config, why not add fn requires_remapping(&self) -> bool to CoinWithTxHistoryV2 and return true for Tendermint coin/asset.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There also could be CoinWithTxHistoryV2::remap_tx_if_required(&self, details: &mut TransactionDetails). So this remapping logic is performed on the coin's level.
What do you think?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree, this is better :)

Copy link
Member Author

@onur-ozkan onur-ozkan Dec 2, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There also could be CoinWithTxHistoryV2::remap_tx_if_required(&self, details: &mut TransactionDetails). So this remapping logic is performed on the coin's level. What do you think?

This is actually pretty good idea. However, we already have mapping for all v2 history implementations. So I will need to do this change for all. Should I cover it in this PR? I left a TODO note here
https://github.com/KomodoPlatform/atomicDEX-API/blob/452fc50b38ef4b73f6d20c058fb1b637a7885d0d/mm2src/coins/my_tx_history_v2.rs#L439-L443

Please let me know if this change is blocker and if I should cover it.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a non-blocker, you can do it in the next PR for sure.

let decimals = coin.decimals();

let transactions =
history
.transactions
.into_iter()
.map(|mut details| {
// checking if transaction type is not `Fee`
if discriminant(&details.transaction_type) != discriminant(&TransactionType::Fee(BytesJson::default()))
{
// it can be the platform ticker instead of the token ticker for a pre-saved record
if details.coin != request.coin {
details.coin = request.coin.clone();
}

match protocol_type {
// for tendermint, tx_history_v2 implementation doesn't include amount parsing logic.
// therefore, re-mapping is required
TENDERMINT_COIN_PROTOCOL_TYPE | TENDERMINT_ASSET_PROTOCOL_TYPE => {
// In order to use error result instead of panicking, we should do an extra iteration above this map.
// Because all the values are inserted by u64 convertion in tx_history_v2 implementation, using `panic`
// shouldn't harm.

let u_total_amount = details.total_amount.to_u64().unwrap_or_else(|| {
panic!("Parsing '{}' into u64 should not fail", details.total_amount)
});
details.total_amount = big_decimal_from_sat_unsigned(u_total_amount, decimals);

let u_spent_by_me = details.spent_by_me.to_u64().unwrap_or_else(|| {
panic!("Parsing '{}' into u64 should not fail", details.spent_by_me)
});
details.spent_by_me = big_decimal_from_sat_unsigned(u_spent_by_me, decimals);

let u_received_by_me = details.received_by_me.to_u64().unwrap_or_else(|| {
panic!("Parsing '{}' into u64 should not fail", details.received_by_me)
});
details.received_by_me = big_decimal_from_sat_unsigned(u_received_by_me, decimals);

// Because this can be negative values, no need to read and parse
// this since it's always 0 from tx_history_v2 implementation.
details.my_balance_change = &details.received_by_me - &details.spent_by_me;
},
_ => {},
};
}

let confirmations = if details.block_height == 0 || details.block_height > current_block {
0
} else {
current_block + 1 - details.block_height
};
MyTxHistoryDetails { confirmations, details }
})
.collect();

Ok(MyTxHistoryResponseV2 {
coin: request.coin,
Expand Down
2 changes: 1 addition & 1 deletion mm2src/coins/qrc20.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1316,7 +1316,7 @@ impl MmCoin for Qrc20Coin {
})
}

fn get_receiver_trade_fee(&self, stage: FeeApproxStage) -> TradePreimageFut<TradeFee> {
fn get_receiver_trade_fee(&self, _send_amount: BigDecimal, stage: FeeApproxStage) -> TradePreimageFut<TradeFee> {
let selfi = self.clone();
let fut = async move {
// pass the dummy params
Expand Down
2 changes: 1 addition & 1 deletion mm2src/coins/qrc20/qrc20_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -876,7 +876,7 @@ fn test_receiver_trade_preimage() {
check_tx_fee(&coin, ActualTxFee::FixedPerKb(EXPECTED_TX_FEE as u64));

let actual = coin
.get_receiver_trade_fee(FeeApproxStage::WithoutApprox)
.get_receiver_trade_fee(Default::default(), FeeApproxStage::WithoutApprox)
.wait()
.expect("!get_receiver_trade_fee");
// only one contract call should be included into the expected trade fee
Expand Down
12 changes: 7 additions & 5 deletions mm2src/coins/solana.rs
Original file line number Diff line number Diff line change
Expand Up @@ -672,18 +672,20 @@ impl MmCoin for SolanaCoin {

async fn get_sender_trade_fee(
&self,
value: TradePreimageValue,
stage: FeeApproxStage,
_value: TradePreimageValue,
_stage: FeeApproxStage,
) -> TradePreimageResult<TradeFee> {
unimplemented!()
}

fn get_receiver_trade_fee(&self, _stage: FeeApproxStage) -> TradePreimageFut<TradeFee> { unimplemented!() }
fn get_receiver_trade_fee(&self, _send_amount: BigDecimal, _stage: FeeApproxStage) -> TradePreimageFut<TradeFee> {
unimplemented!()
}

async fn get_fee_to_send_taker_fee(
&self,
dex_fee_amount: BigDecimal,
stage: FeeApproxStage,
_dex_fee_amount: BigDecimal,
_stage: FeeApproxStage,
) -> TradePreimageResult<TradeFee> {
unimplemented!()
}
Expand Down
4 changes: 3 additions & 1 deletion mm2src/coins/solana/spl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,9 @@ impl MmCoin for SplToken {
unimplemented!()
}

fn get_receiver_trade_fee(&self, _stage: FeeApproxStage) -> TradePreimageFut<TradeFee> { unimplemented!() }
fn get_receiver_trade_fee(&self, _send_amount: BigDecimal, _stage: FeeApproxStage) -> TradePreimageFut<TradeFee> {
unimplemented!()
}

async fn get_fee_to_send_taker_fee(
&self,
Expand Down
5 changes: 2 additions & 3 deletions mm2src/coins/tendermint/iris/htlc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
// check this page https://www.irisnet.org/docs/get-started/testnet.html#faucet

use super::htlc_proto::{ClaimHtlcProtoRep, CreateHtlcProtoRep};

use crate::tendermint::type_urls::{CLAIM_HTLC_TYPE_URL, CREATE_HTLC_TYPE_URL};
use cosmrs::{tx::{Msg, MsgProto},
AccountId, Coin, ErrorReport};
use std::convert::TryFrom;
Expand All @@ -30,9 +32,6 @@ pub const HTLC_STATE_OPEN: i32 = 0;
pub const HTLC_STATE_COMPLETED: i32 = 1;
pub const HTLC_STATE_REFUNDED: i32 = 2;

const CREATE_HTLC_TYPE_URL: &str = "/irismod.htlc.MsgCreateHTLC";
const CLAIM_HTLC_TYPE_URL: &str = "/irismod.htlc.MsgClaimHTLC";

#[allow(dead_code)]
pub(crate) struct IrisHtlc {
/// Generated HTLC's ID.
Expand Down
4 changes: 2 additions & 2 deletions mm2src/coins/tendermint/iris/htlc_proto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,14 @@ pub(crate) struct QueryHtlcRequestProto {

#[derive(prost::Enumeration, Debug)]
#[repr(i32)]
pub(crate) enum HtlcState {
pub enum HtlcState {
Open = 0,
Completed = 1,
Refunded = 2,
}

#[derive(prost::Message)]
pub(crate) struct HtlcProto {
pub struct HtlcProto {
#[prost(string, tag = "1")]
pub(crate) id: prost::alloc::string::String,
#[prost(string, tag = "2")]
Expand Down
2 changes: 2 additions & 0 deletions mm2src/coins/tendermint/iris/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
pub(crate) mod htlc;
pub(crate) mod htlc_proto;
16 changes: 12 additions & 4 deletions mm2src/coins/tendermint/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,19 @@
// Useful resources
// https://docs.cosmos.network/

#[path = "iris/htlc.rs"] mod htlc;
#[path = "iris/htlc_proto.rs"] mod htlc_proto;
mod iris;
mod rpc;
mod tendermint_coin;
#[cfg(not(target_arch = "wasm32"))] mod tendermint_native_rpc;
mod tendermint_token;
#[cfg(target_arch = "wasm32")] mod tendermint_wasm_rpc;
pub mod tendermint_tx_history_v2;

pub use tendermint_coin::*;
pub use tendermint_token::*;

pub(crate) const TENDERMINT_COIN_PROTOCOL_TYPE: &str = "TENDERMINT";
pub(crate) const TENDERMINT_ASSET_PROTOCOL_TYPE: &str = "TENDERMINTTOKEN";

pub(crate) mod type_urls {
pub(crate) const CREATE_HTLC_TYPE_URL: &str = "/irismod.htlc.MsgCreateHTLC";
pub(crate) const CLAIM_HTLC_TYPE_URL: &str = "/irismod.htlc.MsgClaimHTLC";
}
23 changes: 23 additions & 0 deletions mm2src/coins/tendermint/rpc/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#[cfg(not(target_arch = "wasm32"))] mod tendermint_native_rpc;
#[cfg(not(target_arch = "wasm32"))]
pub use tendermint_native_rpc::*;

#[cfg(target_arch = "wasm32")] mod tendermint_wasm_rpc;
#[cfg(target_arch = "wasm32")] pub use tendermint_wasm_rpc::*;

pub(crate) const TX_SUCCESS_CODE: u32 = 0;

#[repr(u8)]
pub enum TendermintResultOrder {
Ascending = 0,
Descending,
}

impl From<TendermintResultOrder> for Order {
fn from(order: TendermintResultOrder) -> Self {
match order {
TendermintResultOrder::Ascending => Self::Ascending,
TendermintResultOrder::Descending => Self::Descending,
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ use tendermint_rpc::endpoint::*;
pub use tendermint_rpc::endpoint::{abci_query::Request as AbciRequest, health::Request as HealthRequest,
tx_search::Request as TxSearchRequest};
use tendermint_rpc::Paging;
pub use tendermint_rpc::{query::Query as TendermintQuery, Error, Order as TendermintResultOrder, Scheme,
SimpleRequest, Url};
pub use tendermint_rpc::{query::Query as TendermintQuery, Error, Order, Scheme, SimpleRequest, Url};
use tokio::time;

/// Provides lightweight access to the Tendermint RPC. It gives access to all
Expand Down Expand Up @@ -80,7 +79,7 @@ pub trait Client {
query: TendermintQuery,
page: u32,
per_page: u8,
order: TendermintResultOrder,
order: Order,
) -> Result<block_search::Response, Error> {
self.perform(block_search::Request::new(query, page, per_page, order))
.await
Expand Down Expand Up @@ -229,7 +228,7 @@ pub trait Client {
prove: bool,
page: u32,
per_page: u8,
order: TendermintResultOrder,
order: Order,
) -> Result<tx_search::Response, Error> {
self.perform(tx_search::Request::new(query, prove, page, per_page, order))
.await
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,16 @@ pub use tendermint_rpc::endpoint::{abci_query::{AbciQuery, Request as AbciReques
use tendermint_rpc::error::Error as TendermintRpcError;
pub use tendermint_rpc::query::Query as TendermintQuery;
use tendermint_rpc::request::SimpleRequest;
pub use tendermint_rpc::Order as TendermintResultOrder;
pub use tendermint_rpc::Order;
use tendermint_rpc::Response;

#[derive(Debug, Clone)]
pub(super) struct HttpClient {
pub struct HttpClient {
uri: String,
}

#[derive(Debug, Display)]
pub(super) enum HttpClientInitError {
pub(crate) enum HttpClientInitError {
InvalidUri(InvalidUri),
}

Expand All @@ -34,7 +34,7 @@ impl From<InvalidUri> for HttpClientInitError {
}

#[derive(Debug, Display)]
pub(super) enum PerformError {
pub enum PerformError {
TendermintRpc(TendermintRpcError),
Slurp(SlurpError),
#[display(fmt = "Request failed with status code {}, response {}", status_code, response)]
Expand All @@ -53,12 +53,12 @@ impl From<TendermintRpcError> for PerformError {
}

impl HttpClient {
pub(super) fn new(url: &str) -> Result<Self, HttpClientInitError> {
pub(crate) fn new(url: &str) -> Result<Self, HttpClientInitError> {
Uri::from_str(url)?;
Ok(HttpClient { uri: url.to_owned() })
}

pub(super) async fn perform<R>(&self, request: R) -> Result<R::Response, PerformError>
pub(crate) async fn perform<R>(&self, request: R) -> Result<R::Response, PerformError>
where
R: SimpleRequest,
{
Expand Down
Loading