Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve docs for IbcReceiveResponse constructors #2185

Merged
merged 1 commit into from
Jul 11, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 40 additions & 6 deletions packages/std/src/ibc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -656,11 +656,23 @@ impl<T> IbcReceiveResponse<T> {
/// ## Examples
///
/// ```
/// use cosmwasm_std::{StdAck, IbcReceiveResponse};
///
/// // 0x01 is a FungibleTokenPacketSuccess from ICS-20.
/// let resp: IbcReceiveResponse = IbcReceiveResponse::new(StdAck::success(b"\x01"));
/// assert_eq!(resp.acknowledgement.unwrap(), b"{\"result\":\"AQ==\"}");
/// # use cosmwasm_std::{
/// # Storage, Api, Querier, DepsMut, Deps, entry_point, Env, StdError, MessageInfo,
/// # Never, Response, QueryResponse, StdAck, IbcPacketReceiveMsg
/// # };
/// use cosmwasm_std::IbcReceiveResponse;
///
/// #[entry_point]
/// pub fn ibc_packet_receive(
/// deps: DepsMut,
/// env: Env,
/// msg: IbcPacketReceiveMsg,
/// ) -> Result<IbcReceiveResponse, Never> {
/// // ...
///
/// // 0x01 is a FungibleTokenPacketSuccess from ICS-20.
/// Ok(IbcReceiveResponse::new(StdAck::success(b"\x01")))
/// }
/// ```
pub fn new(ack: impl Into<Binary>) -> Self {
Self {
Expand All @@ -673,8 +685,30 @@ impl<T> IbcReceiveResponse<T> {

/// Creates a new response without an acknowledgement.
///
/// This allows you to send the acknowledgement asynchronously later using [`IbcMsg::WriteAcknowledgement`].
/// This allows you to send the acknowledgement asynchronously later using
/// [`IbcMsg::WriteAcknowledgement`][self::IbcMsg#variant.WriteAcknowledgement].
/// If you want to send the acknowledgement immediately, use [`IbcReceiveResponse::new`].
///
/// ## Examples
///
/// ```
/// # use cosmwasm_std::{
/// # Storage, Api, Querier, DepsMut, Deps, entry_point, Env, StdError, MessageInfo,
/// # Never, Response, QueryResponse, StdAck, IbcPacketReceiveMsg
/// # };
/// use cosmwasm_std::IbcReceiveResponse;
///
/// #[entry_point]
/// pub fn ibc_packet_receive(
/// deps: DepsMut,
/// env: Env,
/// msg: IbcPacketReceiveMsg,
/// ) -> Result<IbcReceiveResponse, Never> {
/// // ...
///
/// Ok(IbcReceiveResponse::without_ack())
/// }
/// ```
pub fn without_ack() -> Self {
Self {
acknowledgement: None,
Expand Down