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

feat: establish ICS-721 boilerplate, ready for new additions #1012

Merged
merged 2 commits into from
Dec 20, 2023
Merged
Show file tree
Hide file tree
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
4 changes: 4 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ members = [
"ibc-clients",
"ibc-apps/ics20-transfer/types",
"ibc-apps/ics20-transfer",
"ibc-apps/ics721-nft-transfer/types",
"ibc-apps/ics721-nft-transfer",
"ibc-apps",
"ibc-core/ics24-host/cosmos",
"ibc-data-types",
Expand Down Expand Up @@ -73,6 +75,7 @@ ibc-core-handler = { version = "0.48.1", path = "./ibc-core/ics25-handler",
ibc-core-router = { version = "0.48.1", path = "./ibc-core/ics26-routing", default-features = false }
ibc-client-tendermint = { version = "0.48.1", path = "./ibc-clients/ics07-tendermint", default-features = false }
ibc-app-transfer = { version = "0.48.1", path = "./ibc-apps/ics20-transfer", default-features = false }
ibc-app-nft-transfer = { version = "0.48.1", path = "./ibc-apps/ics721-nft-transfer", default-features = false }

ibc-core-client-context = { version = "0.48.1", path = "./ibc-core/ics02-client/context", default-features = false }
ibc-core-client-types = { version = "0.48.1", path = "./ibc-core/ics02-client/types", default-features = false }
Expand All @@ -85,6 +88,7 @@ ibc-core-handler-types = { version = "0.48.1", path = "./ibc-core/ics25-han
ibc-core-router-types = { version = "0.48.1", path = "./ibc-core/ics26-routing/types", default-features = false }
ibc-client-tendermint-types = { version = "0.48.1", path = "./ibc-clients/ics07-tendermint/types", default-features = false }
ibc-app-transfer-types = { version = "0.48.1", path = "./ibc-apps/ics20-transfer/types", default-features = false }
ibc-app-nft-transfer-types = { version = "0.48.1", path = "./ibc-apps/ics721-nft-transfer/types", default-features = false }

ibc-proto = { version = "0.39.1", default-features = false }

Expand Down
8 changes: 7 additions & 1 deletion ibc-apps/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,24 +17,30 @@ description = """
all-features = true

[dependencies]
ibc-app-transfer = { workspace = true }
ibc-app-transfer = { workspace = true }
ibc-app-nft-transfer = { workspace = true }

[features]
default = ["std"]
std = [
"ibc-app-transfer/std",
"ibc-app-nft-transfer/std",
]
serde = [
"ibc-app-transfer/serde",
"ibc-app-nft-transfer/serde",
]
schema = [
"ibc-app-transfer/schema",
"ibc-app-nft-transfer/schema",
"serde",
"std",
]
borsh = [
"ibc-app-transfer/borsh",
"ibc-app-nft-transfer/borsh",
]
parity-scale-codec = [
"ibc-app-transfer/parity-scale-codec",
"ibc-app-nft-transfer/parity-scale-codec",
]
5 changes: 5 additions & 0 deletions ibc-apps/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ applications:
- [ibc-app-transfer](./../ibc-apps/ics20-transfer)
- [ibc-app-transfer-types](./../ibc-apps/ics20-transfer/types)

### ICS-721: Non-Fungible Token Transfer Application

- [ibc-app-nft-transfer](./../ibc-apps/ics721-nft-transfer)
- [ibc-app-nft-transfer-types](./../ibc-apps/ics721-nft-transfer/types)

## Contributing

IBC is specified in English in the [cosmos/ibc
Expand Down
53 changes: 53 additions & 0 deletions ibc-apps/ics721-nft-transfer/Cargo.toml
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",
]
8 changes: 8 additions & 0 deletions ibc-apps/ics721-nft-transfer/src/context.rs
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 {}
2 changes: 2 additions & 0 deletions ibc-apps/ics721-nft-transfer/src/handler/mod.rs
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.
30 changes: 30 additions & 0 deletions ibc-apps/ics721-nft-transfer/src/lib.rs
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::*;
}
167 changes: 167 additions & 0 deletions ibc-apps/ics721-nft-transfer/src/module.rs
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!()
}

Check warning on line 24 in ibc-apps/ics721-nft-transfer/src/module.rs

View check run for this annotation

Codecov / codecov/patch

ibc-apps/ics721-nft-transfer/src/module.rs#L14-L24

Added lines #L14 - L24 were not covered by tests

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!()
}

Check warning on line 36 in ibc-apps/ics721-nft-transfer/src/module.rs

View check run for this annotation

Codecov / codecov/patch

ibc-apps/ics721-nft-transfer/src/module.rs#L26-L36

Added lines #L26 - L36 were not covered by tests

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!()
}

Check warning on line 48 in ibc-apps/ics721-nft-transfer/src/module.rs

View check run for this annotation

Codecov / codecov/patch

ibc-apps/ics721-nft-transfer/src/module.rs#L38-L48

Added lines #L38 - L48 were not covered by tests

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!()
}

Check warning on line 60 in ibc-apps/ics721-nft-transfer/src/module.rs

View check run for this annotation

Codecov / codecov/patch

ibc-apps/ics721-nft-transfer/src/module.rs#L50-L60

Added lines #L50 - L60 were not covered by tests

pub fn on_chan_open_ack_validate(
_ctx: &impl NftTransferExecutionContext,
_port_id: &PortId,
_channel_id: &ChannelId,
_counterparty_version: &Version,
) -> Result<(), NftTransferError> {
unimplemented!()
}

Check warning on line 69 in ibc-apps/ics721-nft-transfer/src/module.rs

View check run for this annotation

Codecov / codecov/patch

ibc-apps/ics721-nft-transfer/src/module.rs#L62-L69

Added lines #L62 - L69 were not covered by tests

pub fn on_chan_open_ack_execute(
_ctx: &mut impl NftTransferExecutionContext,
_port_id: &PortId,
_channel_id: &ChannelId,
_counterparty_version: &Version,
) -> Result<ModuleExtras, NftTransferError> {
unimplemented!()
}

Check warning on line 78 in ibc-apps/ics721-nft-transfer/src/module.rs

View check run for this annotation

Codecov / codecov/patch

ibc-apps/ics721-nft-transfer/src/module.rs#L71-L78

Added lines #L71 - L78 were not covered by tests

pub fn on_chan_open_confirm_validate(
_ctx: &impl NftTransferValidationContext,
_port_id: &PortId,
_channel_id: &ChannelId,
) -> Result<(), NftTransferError> {
unimplemented!()
}

Check warning on line 86 in ibc-apps/ics721-nft-transfer/src/module.rs

View check run for this annotation

Codecov / codecov/patch

ibc-apps/ics721-nft-transfer/src/module.rs#L80-L86

Added lines #L80 - L86 were not covered by tests

pub fn on_chan_open_confirm_execute(
_ctx: &mut impl NftTransferExecutionContext,
_port_id: &PortId,
_channel_id: &ChannelId,
) -> Result<ModuleExtras, NftTransferError> {
unimplemented!()
}

Check warning on line 94 in ibc-apps/ics721-nft-transfer/src/module.rs

View check run for this annotation

Codecov / codecov/patch

ibc-apps/ics721-nft-transfer/src/module.rs#L88-L94

Added lines #L88 - L94 were not covered by tests

pub fn on_chan_close_init_validate(
_ctx: &impl NftTransferValidationContext,
_port_id: &PortId,
_channel_id: &ChannelId,
) -> Result<(), NftTransferError> {
unimplemented!()
}

Check warning on line 102 in ibc-apps/ics721-nft-transfer/src/module.rs

View check run for this annotation

Codecov / codecov/patch

ibc-apps/ics721-nft-transfer/src/module.rs#L96-L102

Added lines #L96 - L102 were not covered by tests

pub fn on_chan_close_init_execute(
_ctx: &mut impl NftTransferExecutionContext,
_port_id: &PortId,
_channel_id: &ChannelId,
) -> Result<ModuleExtras, NftTransferError> {
unimplemented!()
}

Check warning on line 110 in ibc-apps/ics721-nft-transfer/src/module.rs

View check run for this annotation

Codecov / codecov/patch

ibc-apps/ics721-nft-transfer/src/module.rs#L104-L110

Added lines #L104 - L110 were not covered by tests

pub fn on_chan_close_confirm_validate(
_ctx: &impl NftTransferValidationContext,
_port_id: &PortId,
_channel_id: &ChannelId,
) -> Result<(), NftTransferError> {
unimplemented!()
}

Check warning on line 118 in ibc-apps/ics721-nft-transfer/src/module.rs

View check run for this annotation

Codecov / codecov/patch

ibc-apps/ics721-nft-transfer/src/module.rs#L112-L118

Added lines #L112 - L118 were not covered by tests

pub fn on_chan_close_confirm_execute(
_ctx: &mut impl NftTransferExecutionContext,
_port_id: &PortId,
_channel_id: &ChannelId,
) -> Result<ModuleExtras, NftTransferError> {
unimplemented!()
}

Check warning on line 126 in ibc-apps/ics721-nft-transfer/src/module.rs

View check run for this annotation

Codecov / codecov/patch

ibc-apps/ics721-nft-transfer/src/module.rs#L120-L126

Added lines #L120 - L126 were not covered by tests

pub fn on_recv_packet_execute(
_ctx_b: &mut impl NftTransferExecutionContext,
_packet: &Packet,
) -> (ModuleExtras, Acknowledgement) {
unimplemented!()
}

Check warning on line 133 in ibc-apps/ics721-nft-transfer/src/module.rs

View check run for this annotation

Codecov / codecov/patch

ibc-apps/ics721-nft-transfer/src/module.rs#L128-L133

Added lines #L128 - L133 were not covered by tests

pub fn on_acknowledgement_packet_validate<Ctx>(
_ctx: &impl NftTransferValidationContext,
_packet: &Packet,
_acknowledgement: &Acknowledgement,
_relayer: &Signer,
) -> Result<(), NftTransferError> {
unimplemented!()
}

Check warning on line 142 in ibc-apps/ics721-nft-transfer/src/module.rs

View check run for this annotation

Codecov / codecov/patch

ibc-apps/ics721-nft-transfer/src/module.rs#L135-L142

Added lines #L135 - L142 were not covered by tests

pub fn on_acknowledgement_packet_execute(
_ctx: &mut impl NftTransferExecutionContext,
_packet: &Packet,
_acknowledgement: &Acknowledgement,
_relayer: &Signer,
) -> (ModuleExtras, Result<(), NftTransferError>) {
unimplemented!()
}

Check warning on line 151 in ibc-apps/ics721-nft-transfer/src/module.rs

View check run for this annotation

Codecov / codecov/patch

ibc-apps/ics721-nft-transfer/src/module.rs#L144-L151

Added lines #L144 - L151 were not covered by tests

pub fn on_timeout_packet_validate(
_ctx: &impl NftTransferValidationContext,
_packet: &Packet,
_relayer: &Signer,
) -> Result<(), NftTransferError> {
unimplemented!()
}

Check warning on line 159 in ibc-apps/ics721-nft-transfer/src/module.rs

View check run for this annotation

Codecov / codecov/patch

ibc-apps/ics721-nft-transfer/src/module.rs#L153-L159

Added lines #L153 - L159 were not covered by tests

pub fn on_timeout_packet_execute(
_ctx: &mut impl NftTransferExecutionContext,
_packet: &Packet,
_relayer: &Signer,
) -> (ModuleExtras, Result<(), NftTransferError>) {
unimplemented!()
}

Check warning on line 167 in ibc-apps/ics721-nft-transfer/src/module.rs

View check run for this annotation

Codecov / codecov/patch

ibc-apps/ics721-nft-transfer/src/module.rs#L161-L167

Added lines #L161 - L167 were not covered by tests
Loading
Loading