Skip to content

Commit 58a0f48

Browse files
authored
Merge pull request #2185 from CosmWasm/improve-IbcReceiveResponse-constructor-docs
Improve docs for IbcReceiveResponse constructors
2 parents db3987d + 5ae1b87 commit 58a0f48

File tree

1 file changed

+40
-6
lines changed

1 file changed

+40
-6
lines changed

packages/std/src/ibc.rs

Lines changed: 40 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -656,11 +656,23 @@ impl<T> IbcReceiveResponse<T> {
656656
/// ## Examples
657657
///
658658
/// ```
659-
/// use cosmwasm_std::{StdAck, IbcReceiveResponse};
660-
///
661-
/// // 0x01 is a FungibleTokenPacketSuccess from ICS-20.
662-
/// let resp: IbcReceiveResponse = IbcReceiveResponse::new(StdAck::success(b"\x01"));
663-
/// assert_eq!(resp.acknowledgement.unwrap(), b"{\"result\":\"AQ==\"}");
659+
/// # use cosmwasm_std::{
660+
/// # Storage, Api, Querier, DepsMut, Deps, entry_point, Env, StdError, MessageInfo,
661+
/// # Never, Response, QueryResponse, StdAck, IbcPacketReceiveMsg
662+
/// # };
663+
/// use cosmwasm_std::IbcReceiveResponse;
664+
///
665+
/// #[entry_point]
666+
/// pub fn ibc_packet_receive(
667+
/// deps: DepsMut,
668+
/// env: Env,
669+
/// msg: IbcPacketReceiveMsg,
670+
/// ) -> Result<IbcReceiveResponse, Never> {
671+
/// // ...
672+
///
673+
/// // 0x01 is a FungibleTokenPacketSuccess from ICS-20.
674+
/// Ok(IbcReceiveResponse::new(StdAck::success(b"\x01")))
675+
/// }
664676
/// ```
665677
pub fn new(ack: impl Into<Binary>) -> Self {
666678
Self {
@@ -673,8 +685,30 @@ impl<T> IbcReceiveResponse<T> {
673685

674686
/// Creates a new response without an acknowledgement.
675687
///
676-
/// This allows you to send the acknowledgement asynchronously later using [`IbcMsg::WriteAcknowledgement`].
688+
/// This allows you to send the acknowledgement asynchronously later using
689+
/// [`IbcMsg::WriteAcknowledgement`][self::IbcMsg#variant.WriteAcknowledgement].
677690
/// If you want to send the acknowledgement immediately, use [`IbcReceiveResponse::new`].
691+
///
692+
/// ## Examples
693+
///
694+
/// ```
695+
/// # use cosmwasm_std::{
696+
/// # Storage, Api, Querier, DepsMut, Deps, entry_point, Env, StdError, MessageInfo,
697+
/// # Never, Response, QueryResponse, StdAck, IbcPacketReceiveMsg
698+
/// # };
699+
/// use cosmwasm_std::IbcReceiveResponse;
700+
///
701+
/// #[entry_point]
702+
/// pub fn ibc_packet_receive(
703+
/// deps: DepsMut,
704+
/// env: Env,
705+
/// msg: IbcPacketReceiveMsg,
706+
/// ) -> Result<IbcReceiveResponse, Never> {
707+
/// // ...
708+
///
709+
/// Ok(IbcReceiveResponse::without_ack())
710+
/// }
711+
/// ```
678712
pub fn without_ack() -> Self {
679713
Self {
680714
acknowledgement: None,

0 commit comments

Comments
 (0)