Skip to content

Commit

Permalink
make features additive
Browse files Browse the repository at this point in the history
  • Loading branch information
rnbguy committed May 2, 2024

Verified

This commit was signed with the committer’s verified signature. The key has expired.
sbihel Simon Bihel
1 parent 53c53a5 commit c413716
Showing 2 changed files with 14 additions and 11 deletions.
4 changes: 2 additions & 2 deletions basecoin/app/src/abci/mod.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
//! Contains various ABCI implementations to interact with different version of
//! underlying consensus engine (CometBFT)
#[cfg(all(feature = "v0_37", not(feature = "v0_38")))]
#[cfg(feature = "v0_37")]
pub mod v0_37;

#[cfg(any(feature = "v0_38", not(feature = "v0_37")))]
#[cfg(feature = "v0_38")]
pub mod v0_38;
21 changes: 12 additions & 9 deletions basecoin/app/src/error.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
#[cfg(any(feature = "v0_38", not(feature = "v0_37")))]
use tendermint_proto::abci::{ResponseCheckTx, ResponseQuery};
#[cfg(all(feature = "v0_37", not(feature = "v0_38")))]
use tendermint_proto::v0_37::abci::{ResponseCheckTx, ResponseDeliverTx, ResponseQuery};

#[cfg(any(feature = "v0_37", feature = "v0_38"))]
pub(crate) trait ResponseFromErrorExt {
fn from_error(code: u32, log: impl ToString) -> Self;
}

#[cfg(any(feature = "v0_37", feature = "v0_38"))]
macro_rules! impl_response_error_for {
($($resp:ty),+) => {
$(impl ResponseFromErrorExt for $resp {
@@ -22,8 +19,14 @@ macro_rules! impl_response_error_for {
};
}

#[cfg(all(feature = "v0_37", not(feature = "v0_38")))]
impl_response_error_for!(ResponseQuery, ResponseCheckTx, ResponseDeliverTx);
#[cfg(feature = "v0_37")]
const _: () = {
use tendermint_proto::v0_37::abci::{ResponseCheckTx, ResponseDeliverTx, ResponseQuery};
impl_response_error_for!(ResponseQuery, ResponseCheckTx, ResponseDeliverTx);
};

#[cfg(any(feature = "v0_38", not(feature = "v0_37")))]
impl_response_error_for!(ResponseQuery, ResponseCheckTx);
#[cfg(feature = "v0_38")]
const _: () = {
use tendermint_proto::abci::{ResponseCheckTx, ResponseQuery};
impl_response_error_for!(ResponseQuery, ResponseCheckTx);
};

0 comments on commit c413716

Please sign in to comment.