Skip to content

Commit

Permalink
imp: adjust module encapsulations
Browse files Browse the repository at this point in the history
  • Loading branch information
Farhad-Shabani committed Aug 25, 2023
1 parent 16e30fb commit e7f23d3
Show file tree
Hide file tree
Showing 15 changed files with 63 additions and 51 deletions.
2 changes: 1 addition & 1 deletion crates/app/src/bin/basecoin/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
use basecoin_app::{
cli::command::{BasecoinCli, Commands, QueryCmd, UpgradeCmd},
default_app_runner,
modules::query_upgrade_plan,
modules::upgrade::query_upgrade_plan,
types::config::load_config,
};

Expand Down
2 changes: 1 addition & 1 deletion crates/app/src/builder.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
use crate::modules::context::prefix;
use crate::modules::context::Identifiable;
use crate::modules::context::Module;
use crate::modules::ibc::impls::Ibc;
use crate::modules::types::IdentifiedModule;
use crate::modules::types::ModuleList;
use crate::modules::types::ModuleStore;
use crate::modules::Ibc;
use crate::types::error::Error;

use basecoin_store::context::ProvableStore;
Expand Down
8 changes: 5 additions & 3 deletions crates/app/src/modules/auth/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
pub(crate) mod account;
pub mod context;
pub mod impls;
pub mod service;
pub(crate) mod context;
pub(crate) mod impls;
pub(crate) mod service;

pub use impls::{Auth, AuthAccountKeeper, AuthAccountReader};
12 changes: 7 additions & 5 deletions crates/app/src/modules/bank/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
pub mod context;
pub mod error;
pub mod impls;
pub mod service;
pub mod util;
pub(crate) mod context;
pub(crate) mod error;
pub(crate) mod impls;
pub(crate) mod service;
pub(crate) mod util;

pub use impls::Bank;
3 changes: 2 additions & 1 deletion crates/app/src/modules/gov/impls.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
use super::path::ProposalPath;
use super::proposal::Proposal;
use super::service::GovernanceService;
use crate::modules::context::Module;
use crate::modules::gov::msg::MsgSubmitProposal;
use crate::modules::{context::Module, Upgrade};
use crate::modules::upgrade::Upgrade;
use crate::types::error::Error as AppError;
use crate::types::QueryResult;

Expand Down
14 changes: 8 additions & 6 deletions crates/app/src/modules/gov/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
pub mod error;
pub mod impls;
pub mod msg;
pub mod path;
pub mod proposal;
pub mod service;
pub(crate) mod error;
pub(crate) mod impls;
pub(crate) mod msg;
pub(crate) mod path;
pub(crate) mod proposal;
pub(crate) mod service;

pub use impls::Governance;
6 changes: 4 additions & 2 deletions crates/app/src/modules/ibc/impls.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
use crate::modules::bank::impls::BankBalanceKeeper;
use crate::modules::context::Identifiable;
use crate::modules::context::Module;
use crate::modules::ibc::router::IbcRouter;
use crate::modules::ibc::service::{IbcChannelService, IbcClientService, IbcConnectionService};
use crate::modules::{bank::impls::BankBalanceKeeper, IbcTransferModule};
use crate::modules::ibc::transfer::IbcTransferModule;
use crate::types::error::Error as AppError;
use crate::types::QueryResult;

Expand Down Expand Up @@ -124,7 +125,6 @@ where
pub fn process_message(&mut self, message: Any) -> Result<Vec<IbcEvent>, AppError> {
if let Ok(msg) = MsgEnvelope::try_from(message.clone()) {
debug!("Dispatching IBC message: {:?}", msg);

let mut router = self.router();

dispatch(&mut self.ctx, &mut router, msg)?;
Expand Down Expand Up @@ -248,9 +248,11 @@ where
header.time,
header.next_validators_hash,
);

self.ctx
.consensus_states
.insert(header.height.value(), consensus_state);

vec![]
}

Expand Down
5 changes: 5 additions & 0 deletions crates/app/src/modules/ibc/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,8 @@ pub mod impls;
mod router;
pub mod service;
pub mod transfer;

pub use impls::AnyConsensusState;
pub use impls::Ibc;
pub use impls::IbcContext;
pub use transfer::IbcTransferModule;
3 changes: 2 additions & 1 deletion crates/app/src/modules/ibc/router.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use crate::modules::{bank::impls::BankBalanceKeeper, IbcTransferModule};
use crate::modules::bank::impls::BankBalanceKeeper;
use crate::modules::ibc::transfer::IbcTransferModule;

use basecoin_store::context::Store;
use ibc::applications::transfer::MODULE_ID_STR as IBC_TRANSFER_MODULE_ID;
Expand Down
21 changes: 6 additions & 15 deletions crates/app/src/modules/mod.rs
Original file line number Diff line number Diff line change
@@ -1,17 +1,8 @@
pub(crate) mod auth;
pub(crate) mod bank;
pub(crate) mod gov;
pub(crate) mod ibc;
pub(crate) mod staking;
pub(crate) mod upgrade;

pub mod auth;
pub mod bank;
pub mod context;
pub mod gov;
pub mod ibc;
pub mod staking;
pub mod types;

pub use self::ibc::{impls::Ibc, impls::IbcContext, transfer::IbcTransferModule};
pub use auth::impls::{Auth, AuthAccountKeeper, AuthAccountReader};
pub use bank::impls::Bank;
pub use gov::impls::Governance;
pub use staking::impls::Staking;
pub use upgrade::impls::Upgrade;
pub use upgrade::query::*;
pub mod upgrade;
6 changes: 4 additions & 2 deletions crates/app/src/modules/staking/mod.rs
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
pub mod impls;
pub mod service;
pub(crate) mod impls;
pub(crate) mod service;

pub use impls::Staking;
3 changes: 2 additions & 1 deletion crates/app/src/modules/upgrade/impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,10 @@ use tendermint::abci::Event;
use tendermint::merkle::proof::ProofOp;

use super::path::UpgradePlanPath;
use super::query::UPGRADE_PLAN_QUERY_PATH;
use super::service::UpgradeService;
use crate::modules::context::Module;
use crate::modules::ibc::impls::{AnyConsensusState, IbcContext};
use crate::modules::{context::Module, UPGRADE_PLAN_QUERY_PATH};
use crate::types::error::Error as AppError;
use crate::types::query::QueryResult;

Expand Down
11 changes: 7 additions & 4 deletions crates/app/src/modules/upgrade/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
pub mod impls;
pub mod path;
pub mod query;
pub mod service;
pub(crate) mod impls;
pub(crate) mod path;
pub(crate) mod query;
pub(crate) mod service;

pub use impls::Upgrade;
pub use query::*;
12 changes: 6 additions & 6 deletions crates/app/src/runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ use ibc_proto::cosmos::base::tendermint::v1beta1::service_server::ServiceServer
use ibc_proto::cosmos::tx::v1beta1::service_server::ServiceServer as TxServer;

use crate::builder::Builder;
use crate::modules::auth::Auth;
use crate::modules::bank::Bank;
use crate::modules::context::prefix;
use crate::modules::context::Identifiable;
use crate::modules::Auth;
use crate::modules::Bank;
use crate::modules::Governance;
use crate::modules::Ibc;
use crate::modules::Staking;
use crate::modules::Upgrade;
use crate::modules::gov::Governance;
use crate::modules::ibc::Ibc;
use crate::modules::staking::Staking;
use crate::modules::upgrade::Upgrade;
use crate::types::config::ServerConfig;

#[cfg(all(feature = "v0_38", not(feature = "v0_37")))]
Expand Down
6 changes: 3 additions & 3 deletions crates/app/src/types/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ pub enum Error {
NotHandled,
/// custom error: `{reason}`
Custom { reason: String },
/// bank module error
/// bank module error: `{0}`
Bank(BankError),
/// IBC module error
/// IBC module error: `{0}`
Ibc(IbcError),
/// Governance module error
/// Governance module error: `{0}`
Gov(GovError),
}

Expand Down

0 comments on commit e7f23d3

Please sign in to comment.