Skip to content

Commit

Permalink
Add amalgamation traits for NFT CollectionId and ItemId (paritytech#1…
Browse files Browse the repository at this point in the history
…3514)

* Add amalgamation traits for NFT CollectionId, ItemId, and DestroyWitness

* Apply @bkchr suggests

* ".git/.scripts/commands/fmt/fmt.sh"

---------

Co-authored-by: command-bot <>
  • Loading branch information
jasl authored and nathanwhit committed Jul 19, 2023
1 parent e41c208 commit c8d73c2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
7 changes: 5 additions & 2 deletions frame/support/src/traits/tokens/nonfungible_v2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,18 @@
//! use.
use super::nonfungibles_v2 as nonfungibles;
use crate::{dispatch::DispatchResult, traits::Get};
use crate::{
dispatch::{DispatchResult, Parameter},
traits::Get,
};
use codec::{Decode, Encode};
use sp_runtime::TokenError;
use sp_std::prelude::*;

/// Trait for providing an interface to a read-only NFT-like item.
pub trait Inspect<AccountId> {
/// Type for identifying an item.
type ItemId;
type ItemId: Parameter;

/// Returns the owner of `item`, or `None` if the item doesn't exist or has no
/// owner.
Expand Down
8 changes: 4 additions & 4 deletions frame/support/src/traits/tokens/nonfungibles_v2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,19 +27,19 @@
//! Implementations of these traits may be converted to implementations of corresponding
//! `nonfungible` traits by using the `nonfungible::ItemOf` type adapter.
use crate::dispatch::{DispatchError, DispatchResult};
use crate::dispatch::{DispatchError, DispatchResult, Parameter};
use codec::{Decode, Encode};
use sp_runtime::TokenError;
use sp_std::prelude::*;

/// Trait for providing an interface to many read-only NFT-like sets of items.
pub trait Inspect<AccountId> {
/// Type for identifying an item.
type ItemId;
type ItemId: Parameter;

/// Type for identifying a collection (an identifier for an independent collection of
/// items).
type CollectionId;
type CollectionId: Parameter;

/// Returns the owner of `item` of `collection`, or `None` if the item doesn't exist
/// (or somehow has no owner).
Expand Down Expand Up @@ -193,7 +193,7 @@ pub trait Create<AccountId, CollectionConfig>: Inspect<AccountId> {
/// Trait for providing the ability to destroy collections of nonfungible items.
pub trait Destroy<AccountId>: Inspect<AccountId> {
/// The witness data needed to destroy an item.
type DestroyWitness;
type DestroyWitness: Parameter;

/// Provide the appropriate witness data needed to destroy an item.
fn get_destroy_witness(collection: &Self::CollectionId) -> Option<Self::DestroyWitness>;
Expand Down

0 comments on commit c8d73c2

Please sign in to comment.