diff --git a/packages/std/src/ibc.rs b/packages/std/src/ibc.rs index f56944691c..d3afd68887 100644 --- a/packages/std/src/ibc.rs +++ b/packages/std/src/ibc.rs @@ -666,6 +666,17 @@ impl IbcReceiveResponse { } /// Set the acknowledgement for this response. + /// + /// ## Examples + /// + /// ``` + /// use cosmwasm_std::{StdAck, IbcReceiveResponse}; + /// + /// fn make_response_with_ack() -> IbcReceiveResponse { + /// let ack = StdAck::success(b"\x01"); // 0x01 is a FungibleTokenPacketSuccess from ICS-20. + /// IbcReceiveResponse::new().set_ack(ack) + /// } + /// ``` pub fn set_ack(mut self, ack: impl Into) -> Self { self.acknowledgement = ack.into(); self diff --git a/packages/std/src/stdack.rs b/packages/std/src/stdack.rs index 46acad3a2b..e933257a08 100644 --- a/packages/std/src/stdack.rs +++ b/packages/std/src/stdack.rs @@ -82,15 +82,17 @@ impl StdAck { /// /// Set acknowledgement field in `IbcReceiveResponse`: /// - /// ```ignore + /// ``` /// use cosmwasm_std::{StdAck, IbcReceiveResponse}; /// /// let ack = StdAck::success(b"\x01"); // 0x01 is a FungibleTokenPacketSuccess from ICS-20. /// - /// let res = IbcReceiveResponse::new().set_ack(ack.to_binary()); - /// let res = IbcReceiveResponse::new().set_ack(ack); // Does the same but consumes the instance + /// let res: IbcReceiveResponse = IbcReceiveResponse::new().set_ack(ack.to_binary()); + /// let res: IbcReceiveResponse = IbcReceiveResponse::new().set_ack(ack); // Does the same but consumes the instance /// ``` pub fn to_binary(&self) -> Binary { + // We need a non-failing StdAck -> Binary conversion to allow using StdAck in + // `impl Into` arguments. // Pretty sure this cannot fail. If that changes we can create a non-failing implementation here. to_binary(&self).unwrap() }