Skip to content

Commit

Permalink
address nits and comments
Browse files Browse the repository at this point in the history
  • Loading branch information
CyberHoward committed May 13, 2024
1 parent 8c06157 commit b5c2880
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 14 deletions.
9 changes: 3 additions & 6 deletions contracts/client/src/dependencies.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
use abstract_app::objects::dependency::StaticDependency;
use abstract_app::objects::module::ModuleInfo;

use abstract_app::std::manager::ModuleInstallConfig;

use crate::APP_VERSION;
#[cfg(feature = "interface")]
use abstract_app::{std::manager::ModuleInstallConfig, objects::module::ModuleInfo};
use ibcmail::IBCMAIL_SERVER_ID;

pub const MAIL_SERVER_DEP: StaticDependency =
Expand All @@ -19,7 +16,7 @@ impl<Chain: cw_orch::environment::CwEnv> abstract_interface::DependencyCreation
_configuration: Self::DependenciesConfig,
) -> Result<Vec<ModuleInstallConfig>, abstract_interface::AbstractInterfaceError> {
let adapter_install_config = ModuleInstallConfig::new(
ModuleInfo::from_id(ibcmail::IBCMAIL_SERVER_ID, APP_VERSION.into())?,
ModuleInfo::from_id(ibcmail::IBCMAIL_SERVER_ID, crate::APP_VERSION.into())?,
None,
);

Expand Down
3 changes: 3 additions & 0 deletions contracts/client/src/handlers/execute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ fn send_msg(
let hash = <sha2::Sha256 as sha2::Digest>::digest(to_hash);

let to_send = Message {
// TODO: base64 encode this
id: format!("{:x}", hash),
sender: Sender::account(
app.account_id(deps.as_ref()).unwrap(),
Expand All @@ -67,6 +68,7 @@ fn send_msg(

/// Receive a message from the server
fn receive_msg(deps: DepsMut, info: MessageInfo, msg: Message, app: App) -> ClientResult {
// TODO: remove print
println!("Received message: {:?}", msg);
// check that the message sender is the server... this requires the server to be the proper version
let sender_module = app
Expand All @@ -82,6 +84,7 @@ fn receive_msg(deps: DepsMut, info: MessageInfo, msg: Message, app: App) -> Clie
ensure_correct_recipient(deps.as_ref(), &msg.recipient, &app)?;

RECEIVED.save(deps.storage, msg.id.clone(), &msg)?;
// TODO: remove, could run out of gas!!
let len = RECEIVED
.keys(deps.storage, None, None, Order::Ascending)
.count();
Expand Down
2 changes: 0 additions & 2 deletions contracts/client/src/handlers/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ use ibcmail::client::msg::{MessageFilter, MessagesResponse};
use ibcmail::client::state::{RECEIVED, SENT, TEST};
use ibcmail::{MessageId, MessageStatus};

pub const DEFAULT_LIMIT: u32 = 50;

pub fn query_handler(
deps: Deps,
_env: Env,
Expand Down
6 changes: 1 addition & 5 deletions contracts/server/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,7 @@ const ADAPTER: Adapter = Adapter::new(IBCMAIL_SERVER_ID, APP_VERSION, None)
.with_instantiate(handlers::instantiate_handler)
.with_execute(handlers::execute_handler)
.with_query(handlers::query_handler)
.with_module_ibc(handlers::module_ibc_handler)
.with_dependencies(&[
// As we call the IBC client directly, we don't need to depend on the IBC client
// IBC_CLIENT_DEP
]);
.with_module_ibc(handlers::module_ibc_handler);

// Export handlers
#[cfg(feature = "export")]
Expand Down
4 changes: 3 additions & 1 deletion packages/ibcmail/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ use abstract_sdk::std::objects::AccountId;
use abstract_std::objects::account::AccountTrace;
use abstract_std::objects::chain_name::ChainName;
use abstract_std::objects::namespace::Namespace;
// TODO: this crate is 75kb. should we really include it for this basic functionality?
// https://crates.io/crates/const_format
use const_format::concatcp;

use cosmwasm_std::Timestamp;
Expand All @@ -16,7 +18,7 @@ pub const IBCMAIL_SERVER_ID: &str = concatcp!(IBCMAIL_NAMESPACE, ":", "server");

pub type MessageId = String;

/// STruct representing new message to send to another client
/// Struct representing new message to send to another client
#[cosmwasm_schema::cw_serde]
pub struct NewMessage {
pub recipient: Recipient,
Expand Down

0 comments on commit b5c2880

Please sign in to comment.