diff --git a/sylvia-derive/src/contract/communication/reply.rs b/sylvia-derive/src/contract/communication/reply.rs index db78c0e6..1613b477 100644 --- a/sylvia-derive/src/contract/communication/reply.rs +++ b/sylvia-derive/src/contract/communication/reply.rs @@ -241,18 +241,22 @@ trait ReplyOnMethods { impl ReplyOnMethods for ReplyOn { fn emit_match_arm(&self) -> TokenStream { + let sylvia = crate_module(); + match self { - ReplyOn::Success => quote! { Ok(response) }, - ReplyOn::Failure => quote! { Err(error) }, + ReplyOn::Success => quote! { #sylvia ::cw_std::SubMsgResult::Ok(response) }, + ReplyOn::Failure => quote! { #sylvia ::cw_std::SubMsgResult::Err(error) }, ReplyOn::Always => quote! { _ }, } } fn emit_match_arm_body(&self, function_name: &Ident, contract: &Type) -> TokenStream { + let sylvia = crate_module(); + match self { ReplyOn::Success => quote! { - let SubMsgResponse { events, data } = response; - #contract ::new(). #function_name ((deps, env, gas_used, events, data).into(), data, payload) + let #sylvia ::cw_std::SubMsgResponse { events, data, msg_responses} = response; + #contract ::new(). #function_name ((deps, env, gas_used, events, msg_responses).into(), data, payload) }, ReplyOn::Failure => quote! { #contract ::new(). #function_name ((deps, env, gas_used, vec![], vec![]).into(), error, payload) diff --git a/sylvia/tests/messages_generation.rs b/sylvia/tests/messages_generation.rs index a752ee6a..c4584a77 100644 --- a/sylvia/tests/messages_generation.rs +++ b/sylvia/tests/messages_generation.rs @@ -65,6 +65,7 @@ pub mod interface { } mod contract { + use cosmwasm_std::{Binary, SubMsgResult}; use sylvia::contract; use sylvia::cw_std::{Addr, Reply, Response, StdResult}; use sylvia::types::{ExecCtx, InstantiateCtx, MigrateCtx, QueryCtx, ReplyCtx, SudoCtx}; @@ -147,7 +148,12 @@ mod contract { } #[sv::msg(reply)] - fn my_reply(&self, _ctx: ReplyCtx, _reply: Reply) -> StdResult { + fn my_reply( + &self, + _ctx: ReplyCtx, + _result: SubMsgResult, + _payload: Binary, + ) -> StdResult { Ok(Response::new()) } diff --git a/sylvia/tests/reply.rs b/sylvia/tests/reply.rs index 43dbc10e..2cd5014a 100644 --- a/sylvia/tests/reply.rs +++ b/sylvia/tests/reply.rs @@ -39,7 +39,12 @@ impl Contract { #[allow(dead_code)] #[sv::msg(reply, reply_on = success)] - fn reply_on(&self, _ctx: ReplyCtx, _data: Binary, _payload: Binary) -> StdResult { + fn reply_on( + &self, + _ctx: ReplyCtx, + _data: Option, + _payload: Binary, + ) -> StdResult { Ok(Response::new()) }