From b5c288059eacd4a81f872d7a4335f1debb159d63 Mon Sep 17 00:00:00 2001 From: cyberhoward Date: Mon, 13 May 2024 19:47:59 -0400 Subject: [PATCH] address nits and comments --- contracts/client/src/dependencies.rs | 9 +++------ contracts/client/src/handlers/execute.rs | 3 +++ contracts/client/src/handlers/query.rs | 2 -- contracts/server/src/contract.rs | 6 +----- packages/ibcmail/src/lib.rs | 4 +++- 5 files changed, 10 insertions(+), 14 deletions(-) diff --git a/contracts/client/src/dependencies.rs b/contracts/client/src/dependencies.rs index 5462957..198f6e1 100644 --- a/contracts/client/src/dependencies.rs +++ b/contracts/client/src/dependencies.rs @@ -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 = @@ -19,7 +16,7 @@ impl abstract_interface::DependencyCreation _configuration: Self::DependenciesConfig, ) -> Result, 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, ); diff --git a/contracts/client/src/handlers/execute.rs b/contracts/client/src/handlers/execute.rs index 4408694..d88075f 100644 --- a/contracts/client/src/handlers/execute.rs +++ b/contracts/client/src/handlers/execute.rs @@ -45,6 +45,7 @@ fn send_msg( let hash = ::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(), @@ -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 @@ -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(); diff --git a/contracts/client/src/handlers/query.rs b/contracts/client/src/handlers/query.rs index 8b1c6a0..58d6147 100644 --- a/contracts/client/src/handlers/query.rs +++ b/contracts/client/src/handlers/query.rs @@ -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, diff --git a/contracts/server/src/contract.rs b/contracts/server/src/contract.rs index 353ca65..9b2adba 100644 --- a/contracts/server/src/contract.rs +++ b/contracts/server/src/contract.rs @@ -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")] diff --git a/packages/ibcmail/src/lib.rs b/packages/ibcmail/src/lib.rs index 3ff2d1d..b647241 100644 --- a/packages/ibcmail/src/lib.rs +++ b/packages/ibcmail/src/lib.rs @@ -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; @@ -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,