From 92f104e11d931e0a033a5b4673955f131cefa3d8 Mon Sep 17 00:00:00 2001 From: Buckram Date: Tue, 28 May 2024 10:29:36 +0300 Subject: [PATCH 1/3] taplo format --- Cargo.toml | 1 - contracts/client/Cargo.toml | 5 +---- contracts/server/Cargo.toml | 5 +---- packages/ibcmail/Cargo.toml | 4 ++-- tests/Cargo.toml | 2 +- 5 files changed, 5 insertions(+), 12 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 2f9fe2d..d5e86ec 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -38,4 +38,3 @@ debug-assertions = false codegen-units = 1 panic = 'abort' incremental = false - diff --git a/contracts/client/Cargo.toml b/contracts/client/Cargo.toml index 31b246c..342cba3 100644 --- a/contracts/client/Cargo.toml +++ b/contracts/client/Cargo.toml @@ -35,10 +35,7 @@ required-features = ["daemon"] default = ["export"] export = [] schema = ["abstract-app/schema"] -interface = [ - "export", - "dep:cw-orch", -] +interface = ["export", "dep:cw-orch"] daemon = ["interface", "cw-orch/daemon"] [dependencies] diff --git a/contracts/server/Cargo.toml b/contracts/server/Cargo.toml index 667bd28..5e262f0 100644 --- a/contracts/server/Cargo.toml +++ b/contracts/server/Cargo.toml @@ -35,10 +35,7 @@ required-features = ["daemon"] default = ["export"] export = [] schema = ["abstract-adapter/schema"] -interface = [ - "export", - "dep:cw-orch", -] +interface = ["export", "dep:cw-orch"] daemon = ["interface", "cw-orch/daemon"] [dependencies] diff --git a/packages/ibcmail/Cargo.toml b/packages/ibcmail/Cargo.toml index d3bcc45..732b83d 100644 --- a/packages/ibcmail/Cargo.toml +++ b/packages/ibcmail/Cargo.toml @@ -12,8 +12,8 @@ default = [] cosmwasm-std = { workspace = true } cosmwasm-schema = { workspace = true } cw-storage-plus = { workspace = true } -abstract-app = { version = "0.22"} -abstract-adapter = { version = "0.22"} +abstract-app = { version = "0.22" } +abstract-adapter = { version = "0.22" } cw-orch = { workspace = true } thiserror = { workspace = true } cw-asset = { workspace = true } diff --git a/tests/Cargo.toml b/tests/Cargo.toml index 1d0dbe3..6ab99a5 100644 --- a/tests/Cargo.toml +++ b/tests/Cargo.toml @@ -23,4 +23,4 @@ cw-asset = { workspace = true } client = { workspace = true, features = ["interface"] } speculoos = { workspace = true } server = { workspace = true, features = ["interface"] } -abstract-client = { workspace = true } \ No newline at end of file +abstract-client = { workspace = true } From 3c4157ab22c4e8845af0b096c9a140353eebd185 Mon Sep 17 00:00:00 2001 From: Buckram Date: Tue, 28 May 2024 10:54:20 +0300 Subject: [PATCH 2/3] app adapter bump and move to workspace dep --- Cargo.toml | 2 ++ contracts/client/Cargo.toml | 6 +++--- contracts/server/Cargo.toml | 2 +- contracts/server/src/handlers/execute.rs | 2 +- packages/ibcmail/Cargo.toml | 4 ++-- tests/Cargo.toml | 2 +- 6 files changed, 10 insertions(+), 8 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index d5e86ec..ed690f4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -20,6 +20,8 @@ cw-orch = "0.22" ibcmail = { path = "packages/ibcmail", package = "ibcmail" } client = { path = "contracts/client", package = "ibcmail-client" } server = { path = "contracts/server", package = "ibcmail-server" } +abstract-app = { version = "0.22.2" } +abstract-adapter = { version = "0.22.2" } abstract-client = "0.22.1" speculoos = "0.11.0" semver = "1.0" diff --git a/contracts/client/Cargo.toml b/contracts/client/Cargo.toml index 342cba3..b94f192 100644 --- a/contracts/client/Cargo.toml +++ b/contracts/client/Cargo.toml @@ -46,10 +46,10 @@ cw-storage-plus = { workspace = true } thiserror = { workspace = true } schemars = { workspace = true } cw-asset = { workspace = true } -abstract-app = "0.22" +abstract-app = { workspace = true } ibcmail = { workspace = true } cw-paginate = { workspace = true } -base64 = { version = "0.22.1", default-features = false } +base64 = { version = "0.22.1", default-features = false, features = ["alloc"] } # Dependencies for interface cw-orch = { workspace = true, optional = true } @@ -59,7 +59,7 @@ sha2 = { version = "0.10.8", default-features = false } client = { workspace = true, features = ["interface"] } server = { workspace = true, features = ["interface"] } abstract-client = { workspace = true } -abstract-app = { version = "0.22", features = ["test-utils"] } +abstract-app = { workspace = true, features = ["test-utils"] } semver = { workspace = true } dotenv = { workspace = true } env_logger = { workspace = true } diff --git a/contracts/server/Cargo.toml b/contracts/server/Cargo.toml index 5e262f0..a218817 100644 --- a/contracts/server/Cargo.toml +++ b/contracts/server/Cargo.toml @@ -39,7 +39,7 @@ interface = ["export", "dep:cw-orch"] daemon = ["interface", "cw-orch/daemon"] [dependencies] -abstract-adapter = "0.22" +abstract-adapter = { workspace = true } ibcmail = { workspace = true } cosmwasm-std = { workspace = true } diff --git a/contracts/server/src/handlers/execute.rs b/contracts/server/src/handlers/execute.rs index eedbd27..790f539 100644 --- a/contracts/server/src/handlers/execute.rs +++ b/contracts/server/src/handlers/execute.rs @@ -176,7 +176,7 @@ fn route_to_local_account( }?; let acc_base = app.account_registry(deps)?.account_base(&account_id)?; - (*app).target_account = Some(acc_base); + app.target_account = Some(acc_base); let mail_client = app.mail_client(deps); diff --git a/packages/ibcmail/Cargo.toml b/packages/ibcmail/Cargo.toml index 732b83d..4a9f63c 100644 --- a/packages/ibcmail/Cargo.toml +++ b/packages/ibcmail/Cargo.toml @@ -12,8 +12,8 @@ default = [] cosmwasm-std = { workspace = true } cosmwasm-schema = { workspace = true } cw-storage-plus = { workspace = true } -abstract-app = { version = "0.22" } -abstract-adapter = { version = "0.22" } +abstract-app = { workspace = true } +abstract-adapter = { workspace = true } cw-orch = { workspace = true } thiserror = { workspace = true } cw-asset = { workspace = true } diff --git a/tests/Cargo.toml b/tests/Cargo.toml index 6ab99a5..312bb07 100644 --- a/tests/Cargo.toml +++ b/tests/Cargo.toml @@ -9,7 +9,7 @@ edition = "2021" default = [] [dependencies] -abstract-app = { version = "0.22", features = ["test-utils"] } +abstract-app = { workspace = true, features = ["test-utils"] } abstract-cw-orch-polytone = "2.0.0" abstract-interchain-tests = { git = "https://github.com/AbstractSDK/abstract", version = "0.22.1", branch = "removemm" } cw-orch = { package = "cw-orch-interchain", git = "ssh://git@github.com/AbstractSDK/cw-orch-interchain.git", tag = "v0.22.0" } From 4e87bd3108735a4f9b6abb2d433ce54335ff2464 Mon Sep 17 00:00:00 2001 From: Buckram Date: Tue, 28 May 2024 13:37:08 +0300 Subject: [PATCH 3/3] small nits --- contracts/client/src/dependencies.rs | 4 +-- contracts/client/src/handlers/execute.rs | 7 ++-- contracts/server/src/contract.rs | 4 ++- contracts/server/src/handlers/execute.rs | 40 ++++++++++----------- contracts/server/src/handlers/module_ibc.rs | 6 ++-- 5 files changed, 29 insertions(+), 32 deletions(-) diff --git a/contracts/client/src/dependencies.rs b/contracts/client/src/dependencies.rs index 9546150..311aa36 100644 --- a/contracts/client/src/dependencies.rs +++ b/contracts/client/src/dependencies.rs @@ -1,10 +1,10 @@ use abstract_app::objects::dependency::StaticDependency; #[cfg(feature = "interface")] use abstract_app::{objects::module::ModuleInfo, std::manager::ModuleInstallConfig}; -use ibcmail::IBCMAIL_SERVER_ID; +use ibcmail::{EMAIL_VERSION, IBCMAIL_SERVER_ID}; pub const MAIL_SERVER_DEP: StaticDependency = - StaticDependency::new(IBCMAIL_SERVER_ID, &[">=0.0.1"]); + StaticDependency::new(IBCMAIL_SERVER_ID, &[EMAIL_VERSION]); #[cfg(feature = "interface")] impl abstract_app::abstract_interface::DependencyCreation diff --git a/contracts/client/src/handlers/execute.rs b/contracts/client/src/handlers/execute.rs index bad4a4b..3e9c932 100644 --- a/contracts/client/src/handlers/execute.rs +++ b/contracts/client/src/handlers/execute.rs @@ -46,15 +46,12 @@ fn send_msg( app: ClientApp, ) -> ClientResult { // validate basic fields of message, construct message to send to server - let to_hash = format!("{:?}{:?}{:?}", env.block.time, msg.subject, msg.recipient); + let to_hash = format!("{}{}{:?}", env.block.time, msg.subject, msg.recipient); let hash = ::digest(to_hash); let base_64_hash = BASE64_STANDARD.encode(hash); let to_send = IbcMailMessage { id: base_64_hash, - sender: Sender::account( - app.account_id(deps.as_ref()).unwrap(), - Some(ChainName::new(&env)), - ), + sender: Sender::account(app.account_id(deps.as_ref())?, Some(ChainName::new(&env))), message: Message { recipient: msg.recipient, subject: msg.subject, diff --git a/contracts/server/src/contract.rs b/contracts/server/src/contract.rs index 75b44af..7d39b0f 100644 --- a/contracts/server/src/contract.rs +++ b/contracts/server/src/contract.rs @@ -1,5 +1,6 @@ use cosmwasm_std::Response; pub use ibcmail::server::ServerAdapter as Adapter; +use ibcmail::EMAIL_VERSION; use ibcmail::{server::error::ServerError, IBCMAIL_SERVER_ID}; use ibcmail::{server::msg::ServerInstantiateMsg, IBCMAIL_CLIENT_ID}; @@ -7,7 +8,8 @@ use crate::{handlers, APP_VERSION}; use abstract_adapter::objects::dependency::StaticDependency; -pub const MAIL_CLIENT: StaticDependency = StaticDependency::new(IBCMAIL_CLIENT_ID, &[]); +pub const MAIL_CLIENT: StaticDependency = + StaticDependency::new(IBCMAIL_CLIENT_ID, &[EMAIL_VERSION]); /// The type of the result returned by your client's entry points. pub type ServerResult = Result; diff --git a/contracts/server/src/handlers/execute.rs b/contracts/server/src/handlers/execute.rs index 790f539..34f066b 100644 --- a/contracts/server/src/handlers/execute.rs +++ b/contracts/server/src/handlers/execute.rs @@ -11,10 +11,7 @@ use abstract_adapter::traits::AbstractResponse; use cosmwasm_std::{to_json_binary, wasm_execute, CosmosMsg, Deps, DepsMut, Env, MessageInfo}; use ibcmail::{ client::api::ClientInterface, - server::{ - msg::{ServerExecuteMsg, ServerIbcMessage}, - ServerAdapter, - }, + server::msg::{ServerExecuteMsg, ServerIbcMessage}, Header, IbcMailMessage, Recipient, Route, }; @@ -27,12 +24,12 @@ pub fn execute_handler( deps: DepsMut, env: Env, info: MessageInfo, - app: Adapter, + adapter: Adapter, msg: ServerExecuteMsg, ) -> ServerResult { match msg { ServerExecuteMsg::ProcessMessage { msg, route } => { - process_message(deps, env, info, msg, route, app) + process_message(deps, env, info, msg, route, adapter) } } } @@ -43,7 +40,7 @@ fn process_message( _info: MessageInfo, msg: IbcMailMessage, route: Option, - mut app: Adapter, + mut adapter: Adapter, ) -> ServerResult { println!("processing message: {:?} with route {:?}", msg, route); @@ -84,30 +81,31 @@ fn process_message( route, }; - let msg = route_msg(deps, msg, metadata, &mut app)?; + let msg = route_msg(deps, msg, metadata, &mut adapter)?; - Ok(app.response("route").add_message(msg)) + Ok(adapter.response("route").add_message(msg)) } pub(crate) fn route_msg( deps: DepsMut, msg: IbcMailMessage, header: Header, - app: &mut ServerAdapter, + adapter: &mut Adapter, ) -> ServerResult { println!("routing message: {:?}, metadata: {:?}", msg, header); match header.route { - AccountTrace::Local => route_to_local_account(deps.as_ref(), msg, header, app), + AccountTrace::Local => route_to_local_account(deps.as_ref(), msg, header, adapter), AccountTrace::Remote(ref chains) => { println!("routing to chains: {:?}", chains); // check index of hop. If we are on the final hop, route to local account if header.current_hop == chains.len() as u32 { - return route_to_local_account(deps.as_ref(), msg.clone(), header, app); + return route_to_local_account(deps.as_ref(), msg.clone(), header, adapter); } - // TODO verify that the chain is a valid chain + // TODO: verify that the chain is a valid chain - let current_module_info = ModuleInfo::from_id(app.module_id(), app.version().into())?; + let current_module_info = + ModuleInfo::from_id(adapter.module_id(), adapter.version().into())?; let dest_chain = chains .get(header.current_hop as usize) @@ -132,14 +130,14 @@ pub(crate) fn route_msg( // TODO: We could additionally have something like to avoid having to create the module info object // let ibc_msg = app.ibc_client().self_module_ibc_action(chain, msg, callback) - let ibc_client_addr = app + let ibc_client_addr = adapter .module_registry(deps.as_ref())? .query_module(ModuleInfo::from_id_latest(IBC_CLIENT)?)? .reference .unwrap_native()?; let exec_msg = wasm_execute(ibc_client_addr, &ibc_msg, vec![])?.into(); - Ok::(exec_msg) + Ok(exec_msg) } } } @@ -148,7 +146,7 @@ fn route_to_local_account( deps: Deps, msg: IbcMailMessage, header: Header, - app: &mut ServerAdapter, + adapter: &mut Adapter, ) -> ServerResult { println!("routing to local account: {:?}", msg.message.recipient); // This is a local message @@ -160,7 +158,7 @@ fn route_to_local_account( Recipient::Namespace { namespace, .. } => { // TODO: this only allows for addressing recipients via namespace of their email account directly. // If they have the email application installed on a sub-account, this will not be able to identify the sub-account. - let namespace_status = app + let namespace_status = adapter .module_registry(deps)? .query_namespace(namespace.clone())?; match namespace_status { @@ -175,10 +173,10 @@ fn route_to_local_account( )), }?; - let acc_base = app.account_registry(deps)?.account_base(&account_id)?; - app.target_account = Some(acc_base); + let acc_base = adapter.account_registry(deps)?.account_base(&account_id)?; + adapter.target_account = Some(acc_base); - let mail_client = app.mail_client(deps); + let mail_client = adapter.mail_client(deps); Ok(mail_client.receive_msg(msg, header)?) } diff --git a/contracts/server/src/handlers/module_ibc.rs b/contracts/server/src/handlers/module_ibc.rs index 020a4ab..4ef1ad4 100644 --- a/contracts/server/src/handlers/module_ibc.rs +++ b/contracts/server/src/handlers/module_ibc.rs @@ -11,7 +11,7 @@ use crate::{contract::ServerResult, handlers::execute::route_msg}; pub fn module_ibc_handler( deps: DepsMut, _env: Env, - mut app: ServerAdapter, + mut adapter: ServerAdapter, ibc_msg: ModuleIbcMsg, ) -> ServerResult { println!("module_ibc_handler 1 : {:?}", ibc_msg); @@ -31,11 +31,11 @@ pub fn module_ibc_handler( ServerIbcMessage::RouteMessage { msg, mut header } => { // We've hopped one more time header.current_hop += 1; - let msg = dbg!(route_msg(deps, msg, header, &mut app))?; + let msg = dbg!(route_msg(deps, msg, header, &mut adapter))?; println!("routed_msg: {:?}", msg); - Ok(app.response("module_ibc").add_message(msg)) + Ok(adapter.response("module_ibc").add_message(msg)) } _ => Err(ServerError::UnauthorizedIbcMessage {}), }