ibc_app_nft_transfer_types/
lib.rs

1//! Implementation of the IBC [Non-Fungible Token
2//! Transfer](https://github.com/cosmos/ibc/blob/main/spec/app/ics-721-nft-transfer/README.md)
3//! (ICS-721) data structures.
4#![no_std]
5#![forbid(unsafe_code)]
6#![cfg_attr(not(test), deny(clippy::unwrap_used))]
7#![cfg_attr(not(test), deny(clippy::disallowed_methods, clippy::disallowed_types))]
8#![deny(
9    warnings,
10    trivial_casts,
11    trivial_numeric_casts,
12    unused_import_braces,
13    unused_qualifications,
14    rust_2018_idioms
15)]
16
17#[cfg(any(test, feature = "std"))]
18extern crate std;
19
20mod class;
21mod data;
22mod memo;
23mod token;
24
25pub mod events;
26pub mod msgs;
27pub use class::*;
28pub use data::*;
29pub mod packet;
30pub use memo::*;
31pub use token::*;
32pub mod error;
33
34/// Re-exports ICS-721 NFT transfer proto types from the `ibc-proto` crate.
35pub mod proto {
36    pub use ibc_proto::ibc::apps::nft_transfer;
37}
38
39/// Module identifier for the ICS-721 application.
40pub const MODULE_ID_STR: &str = "nft_transfer";
41
42/// The port identifier that the ICS-721 applications typically bind with.
43pub const PORT_ID_STR: &str = "nft-transfer";
44
45/// ICS-721 application current version.
46pub const VERSION: &str = "ics721-1";
47
48/// The successful string, used for creating an acknowledgement status.
49/// It is equivalent to `base64::encode(0x01)`.
50pub const ACK_SUCCESS_B64: &str = "AQ==";
51
52use ibc_core::channel::types::acknowledgement::StatusValue;
53
54/// Returns a successful acknowledgement status for the NFT transfer application.
55pub fn ack_success_b64() -> StatusValue {
56    StatusValue::new(ACK_SUCCESS_B64).expect("ack status value is never supposed to be empty")
57}
58
59#[cfg(feature = "arbitrary")]
60fn arb_uri(u: &mut arbitrary::Unstructured<'_>) -> arbitrary::Result<http::Uri> {
61    let raw: std::string::String = arbitrary::Arbitrary::arbitrary(u)?;
62    http::Uri::try_from(&raw).map_err(|_| arbitrary::Error::IncorrectFormat)
63}