-
Notifications
You must be signed in to change notification settings - Fork 83
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: establish ICS-721 boilerplate, ready for new additions (#1012)
* chore: establish ics721 boilerplate, ready for new additions * nit
- Loading branch information
1 parent
d2a91ea
commit c609f7e
Showing
14 changed files
with
429 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
[package] | ||
name = "ibc-app-nft-transfer" | ||
version = { workspace = true } | ||
authors = { workspace = true } | ||
edition = { workspace = true } | ||
rust-version = { workspace = true } | ||
license = { workspace = true } | ||
repository = { workspace = true } | ||
keywords = ["cosmos", "ibc", "nft", "transfer", "ics721"] | ||
readme = "./../README.md" | ||
description = """ | ||
Maintained by `ibc-rs`, contains the implementation of the ICS-721 Non-Fungible Token Transfer | ||
application logic and re-exports essential data structures and domain types from | ||
`ibc-app-nft-transfer-types` crate. | ||
""" | ||
|
||
[package.metadata.docs.rs] | ||
all-features = true | ||
|
||
[dependencies] | ||
# external dependencies | ||
serde_json = { workspace = true, optional = true } | ||
|
||
# ibc dependencies | ||
ibc-app-nft-transfer-types = { workspace = true } | ||
ibc-core = { workspace = true } | ||
|
||
[features] | ||
default = ["std"] | ||
std = [ | ||
"ibc-app-nft-transfer-types/std", | ||
"ibc-core/std", | ||
"serde_json/std", | ||
] | ||
serde = [ | ||
"ibc-app-nft-transfer-types/serde", | ||
"ibc-core/serde", | ||
"serde_json" | ||
] | ||
schema = [ | ||
"ibc-app-nft-transfer-types/schema", | ||
"ibc-core/schema", | ||
"serde", | ||
"std", | ||
] | ||
borsh = [ | ||
"ibc-app-nft-transfer-types/borsh", | ||
"ibc-core/borsh", | ||
] | ||
parity-scale-codec = [ | ||
"ibc-app-nft-transfer-types/parity-scale-codec", | ||
"ibc-core/parity-scale-codec", | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
//! Defines the required context traits for ICS-721 to interact with host | ||
//! machine. | ||
|
||
/// Read-only methods required in NFT transfer validation context. | ||
pub trait NftTransferValidationContext {} | ||
|
||
/// Read-write methods required in NFT transfer execution context. | ||
pub trait NftTransferExecutionContext: NftTransferValidationContext {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
//! Implements IBC handlers responsible for processing Non-Fungible Token | ||
//! Transfers (ICS-721) messages. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
//! Implementation of the IBC [Non-Fungible Token | ||
//! Transfer](https://github.com/cosmos/ibc/blob/main/spec/app/ics-721-nft-transfer/README.md) | ||
//! (ICS-721) application logic. | ||
#![no_std] | ||
#![forbid(unsafe_code)] | ||
#![cfg_attr(not(test), deny(clippy::unwrap_used))] | ||
#![cfg_attr(not(test), deny(clippy::disallowed_methods, clippy::disallowed_types))] | ||
#![deny( | ||
warnings, | ||
trivial_casts, | ||
trivial_numeric_casts, | ||
unused_import_braces, | ||
unused_qualifications, | ||
rust_2018_idioms | ||
)] | ||
|
||
#[cfg(any(test, feature = "std"))] | ||
extern crate std; | ||
|
||
pub mod context; | ||
pub mod handler; | ||
pub mod module; | ||
|
||
/// Re-exports the implementation of the IBC [Non-Fungible Token | ||
/// Transfer](https://github.com/cosmos/ibc/blob/main/spec/app/ics-020-fungible-token-transfer/README.md) | ||
/// (ICS-721) data structures. | ||
pub mod types { | ||
#[doc(inline)] | ||
pub use ibc_app_nft_transfer_types::*; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,167 @@ | ||
//! Provides IBC module callbacks implementation for the ICS-721 transfer. | ||
|
||
use ibc_app_nft_transfer_types::error::NftTransferError; | ||
use ibc_core::channel::types::acknowledgement::Acknowledgement; | ||
use ibc_core::channel::types::channel::{Counterparty, Order}; | ||
use ibc_core::channel::types::packet::Packet; | ||
use ibc_core::channel::types::Version; | ||
use ibc_core::host::types::identifiers::{ChannelId, ConnectionId, PortId}; | ||
use ibc_core::primitives::Signer; | ||
use ibc_core::router::types::module::ModuleExtras; | ||
|
||
use crate::context::{NftTransferExecutionContext, NftTransferValidationContext}; | ||
|
||
pub fn on_chan_open_init_validate( | ||
_ctx: &impl NftTransferValidationContext, | ||
_order: Order, | ||
_connection_hops: &[ConnectionId], | ||
_port_id: &PortId, | ||
_channel_id: &ChannelId, | ||
_counterparty: &Counterparty, | ||
_version: &Version, | ||
) -> Result<(), NftTransferError> { | ||
unimplemented!() | ||
} | ||
|
||
pub fn on_chan_open_init_execute( | ||
_ctx: &mut impl NftTransferExecutionContext, | ||
_order: Order, | ||
_connection_hops: &[ConnectionId], | ||
_port_id: &PortId, | ||
_channel_id: &ChannelId, | ||
_counterparty: &Counterparty, | ||
_version: &Version, | ||
) -> Result<(ModuleExtras, Version), NftTransferError> { | ||
unimplemented!() | ||
} | ||
|
||
pub fn on_chan_open_try_validate( | ||
_ctx: &impl NftTransferValidationContext, | ||
_order: Order, | ||
_connection_hops: &[ConnectionId], | ||
_port_id: &PortId, | ||
_channel_id: &ChannelId, | ||
_counterparty: &Counterparty, | ||
_counterparty_version: &Version, | ||
) -> Result<(), NftTransferError> { | ||
unimplemented!() | ||
} | ||
|
||
pub fn on_chan_open_try_execute( | ||
_ctx: &mut impl NftTransferExecutionContext, | ||
_order: Order, | ||
_connection_hops: &[ConnectionId], | ||
_port_id: &PortId, | ||
_channel_id: &ChannelId, | ||
_counterparty: &Counterparty, | ||
_counterparty_version: &Version, | ||
) -> Result<(ModuleExtras, Version), NftTransferError> { | ||
unimplemented!() | ||
} | ||
|
||
pub fn on_chan_open_ack_validate( | ||
_ctx: &impl NftTransferExecutionContext, | ||
_port_id: &PortId, | ||
_channel_id: &ChannelId, | ||
_counterparty_version: &Version, | ||
) -> Result<(), NftTransferError> { | ||
unimplemented!() | ||
} | ||
|
||
pub fn on_chan_open_ack_execute( | ||
_ctx: &mut impl NftTransferExecutionContext, | ||
_port_id: &PortId, | ||
_channel_id: &ChannelId, | ||
_counterparty_version: &Version, | ||
) -> Result<ModuleExtras, NftTransferError> { | ||
unimplemented!() | ||
} | ||
|
||
pub fn on_chan_open_confirm_validate( | ||
_ctx: &impl NftTransferValidationContext, | ||
_port_id: &PortId, | ||
_channel_id: &ChannelId, | ||
) -> Result<(), NftTransferError> { | ||
unimplemented!() | ||
} | ||
|
||
pub fn on_chan_open_confirm_execute( | ||
_ctx: &mut impl NftTransferExecutionContext, | ||
_port_id: &PortId, | ||
_channel_id: &ChannelId, | ||
) -> Result<ModuleExtras, NftTransferError> { | ||
unimplemented!() | ||
} | ||
|
||
pub fn on_chan_close_init_validate( | ||
_ctx: &impl NftTransferValidationContext, | ||
_port_id: &PortId, | ||
_channel_id: &ChannelId, | ||
) -> Result<(), NftTransferError> { | ||
unimplemented!() | ||
} | ||
|
||
pub fn on_chan_close_init_execute( | ||
_ctx: &mut impl NftTransferExecutionContext, | ||
_port_id: &PortId, | ||
_channel_id: &ChannelId, | ||
) -> Result<ModuleExtras, NftTransferError> { | ||
unimplemented!() | ||
} | ||
|
||
pub fn on_chan_close_confirm_validate( | ||
_ctx: &impl NftTransferValidationContext, | ||
_port_id: &PortId, | ||
_channel_id: &ChannelId, | ||
) -> Result<(), NftTransferError> { | ||
unimplemented!() | ||
} | ||
|
||
pub fn on_chan_close_confirm_execute( | ||
_ctx: &mut impl NftTransferExecutionContext, | ||
_port_id: &PortId, | ||
_channel_id: &ChannelId, | ||
) -> Result<ModuleExtras, NftTransferError> { | ||
unimplemented!() | ||
} | ||
|
||
pub fn on_recv_packet_execute( | ||
_ctx_b: &mut impl NftTransferExecutionContext, | ||
_packet: &Packet, | ||
) -> (ModuleExtras, Acknowledgement) { | ||
unimplemented!() | ||
} | ||
|
||
pub fn on_acknowledgement_packet_validate<Ctx>( | ||
_ctx: &impl NftTransferValidationContext, | ||
_packet: &Packet, | ||
_acknowledgement: &Acknowledgement, | ||
_relayer: &Signer, | ||
) -> Result<(), NftTransferError> { | ||
unimplemented!() | ||
} | ||
|
||
pub fn on_acknowledgement_packet_execute( | ||
_ctx: &mut impl NftTransferExecutionContext, | ||
_packet: &Packet, | ||
_acknowledgement: &Acknowledgement, | ||
_relayer: &Signer, | ||
) -> (ModuleExtras, Result<(), NftTransferError>) { | ||
unimplemented!() | ||
} | ||
|
||
pub fn on_timeout_packet_validate( | ||
_ctx: &impl NftTransferValidationContext, | ||
_packet: &Packet, | ||
_relayer: &Signer, | ||
) -> Result<(), NftTransferError> { | ||
unimplemented!() | ||
} | ||
|
||
pub fn on_timeout_packet_execute( | ||
_ctx: &mut impl NftTransferExecutionContext, | ||
_packet: &Packet, | ||
_relayer: &Signer, | ||
) -> (ModuleExtras, Result<(), NftTransferError>) { | ||
unimplemented!() | ||
} |
Oops, something went wrong.