diff --git a/sylvia-derive/src/contract/communication/reply.rs b/sylvia-derive/src/contract/communication/reply.rs index 7ee79ae4..5bf8f6f7 100644 --- a/sylvia-derive/src/contract/communication/reply.rs +++ b/sylvia-derive/src/contract/communication/reply.rs @@ -151,19 +151,24 @@ impl<'a> Reply<'a> { } } }); + let cosmosmsg_methods_implementation = wasmmsg_methods_implementation.clone(); quote! { - pub trait SubMsgMethods { - #(#methods_declaration)* - } + pub trait SubMsgMethods { + #(#methods_declaration)* + } - impl SubMsgMethods for #sylvia ::cw_std::SubMsg { - #(#submsg_methods_implementation)* - } + impl SubMsgMethods for #sylvia ::cw_std::SubMsg { + #(#submsg_methods_implementation)* + } - impl SubMsgMethods for #sylvia ::cw_std::WasmMsg { - #(#wasmmsg_methods_implementation)* - } + impl SubMsgMethods for #sylvia ::cw_std::WasmMsg { + #(#wasmmsg_methods_implementation)* + } + + impl SubMsgMethods for #sylvia ::cw_std::CosmosMsg { + #(#cosmosmsg_methods_implementation)* + } } } } diff --git a/sylvia/tests/reply.rs b/sylvia/tests/reply.rs index 7765e689..db94581b 100644 --- a/sylvia/tests/reply.rs +++ b/sylvia/tests/reply.rs @@ -1,6 +1,6 @@ #![cfg(feature = "sv_replies")] -use cosmwasm_std::{Empty, SubMsgResult}; +use cosmwasm_std::{BankMsg, CosmosMsg, Empty, SubMsgResult}; use cw_storage_plus::Item; use cw_utils::{parse_instantiate_response_data, ParseReplyError}; use noop_contract::sv::{Executor, NoopContractInstantiateBuilder}; @@ -246,6 +246,17 @@ where Ok(Response::new()) } + + #[sv::msg(exec)] + fn send_cosmos_messages(&self, ctx: ExecCtx) -> Result, ContractError> { + let remote_addr = self.remote.load(ctx.deps.storage)?; + let cosmos_msg = CosmosMsg::Bank(BankMsg::Send { + to_address: remote_addr.as_ref().to_string(), + amount: vec![], + }); + let submsg = cosmos_msg.always(); + Ok(Response::new().add_submessage(submsg)) + } } mod tests {