Skip to content

Commit

Permalink
tests compile
Browse files Browse the repository at this point in the history
  • Loading branch information
jawoznia committed Sep 9, 2024
1 parent 4f359ed commit b1ec725
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 6 deletions.
12 changes: 8 additions & 4 deletions sylvia-derive/src/contract/communication/reply.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
8 changes: 7 additions & 1 deletion sylvia/tests/messages_generation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down Expand Up @@ -147,7 +148,12 @@ mod contract {
}

#[sv::msg(reply)]
fn my_reply(&self, _ctx: ReplyCtx<MyQuery>, _reply: Reply) -> StdResult<Response> {
fn my_reply(
&self,
_ctx: ReplyCtx<MyQuery>,
_result: SubMsgResult,
_payload: Binary,
) -> StdResult<Response> {
Ok(Response::new())
}

Expand Down
7 changes: 6 additions & 1 deletion sylvia/tests/reply.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Response> {
fn reply_on(
&self,
_ctx: ReplyCtx,
_data: Option<Binary>,
_payload: Binary,
) -> StdResult<Response> {
Ok(Response::new())
}

Expand Down

0 comments on commit b1ec725

Please sign in to comment.