Skip to content

Commit 45acc95

Browse files
committed
Add separate constructor for IbcReceiveResponse
1 parent e88ee72 commit 45acc95

File tree

2 files changed

+14
-16
lines changed

2 files changed

+14
-16
lines changed

packages/std/src/ibc.rs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -638,7 +638,20 @@ impl<T> IbcReceiveResponse<T> {
638638
/// ```
639639
pub fn new(ack: impl Into<Binary>) -> Self {
640640
Self {
641-
acknowledgement: ack.into(),
641+
acknowledgement: Some(ack.into()),
642+
messages: vec![],
643+
attributes: vec![],
644+
events: vec![],
645+
}
646+
}
647+
648+
/// Creates a new response without an acknowledgement.
649+
///
650+
/// This allows you to send the acknowledgement asynchronously later using [`IbcMsg::WriteAcknowledgement`].
651+
/// If you want to send the acknowledgement immediately, use [`IbcReceiveResponse::new`].
652+
pub fn without_ack() -> Self {
653+
Self {
654+
acknowledgement: None,
642655
messages: vec![],
643656
attributes: vec![],
644657
events: vec![],

packages/std/src/stdack.rs

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -118,12 +118,6 @@ impl From<StdAck> for Binary {
118118
}
119119
}
120120

121-
impl From<StdAck> for Option<Binary> {
122-
fn from(original: StdAck) -> Option<Binary> {
123-
Some(original.into())
124-
}
125-
}
126-
127121
#[cfg(test)]
128122
mod tests {
129123
use super::*;
@@ -166,13 +160,4 @@ mod tests {
166160
let ack2 = StdAck::error("kaputt");
167161
assert_eq!(ack2.to_binary(), br#"{"error":"kaputt"}"#);
168162
}
169-
170-
#[test]
171-
fn stdack_to_option_binary_works() {
172-
let ack1 = StdAck::success(b"\x01");
173-
assert_eq!(Option::<Binary>::from(ack1.clone()), Some(ack1.to_binary()));
174-
175-
let ack2 = StdAck::error("kaputt");
176-
assert_eq!(Option::<Binary>::from(ack2.clone()), Some(ack2.to_binary()));
177-
}
178163
}

0 commit comments

Comments
 (0)