Skip to content

Commit

Permalink
fix: rebase & update integration tests
Browse files Browse the repository at this point in the history
  • Loading branch information
chungquantin committed Nov 18, 2024
1 parent 325e8d3 commit 3c9ccd9
Show file tree
Hide file tree
Showing 8 changed files with 335 additions and 139 deletions.
38 changes: 8 additions & 30 deletions pallets/api/src/nonfungibles/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,37 +11,17 @@ pub use pallet_nfts::{
CollectionSetting, CollectionSettings, DestroyWitness, ItemDeposit, ItemDetails, ItemMetadata,
ItemSetting, MintSettings, MintType, MintWitness,
};
use sp_runtime::traits::StaticLookup;
use sp_runtime::{traits::StaticLookup, BoundedVec};
use types::*;
use weights::WeightInfo;

#[cfg(feature = "runtime-benchmarks")]
mod benchmarking;
#[cfg(test)]
mod tests;
pub mod types;

Check warning on line 22 in pallets/api/src/nonfungibles/mod.rs

View workflow job for this annotation

GitHub Actions / clippy

missing documentation for a module

warning: missing documentation for a module --> pallets/api/src/nonfungibles/mod.rs:22:1 | 22 | pub mod types; | ^^^^^^^^^^^^^
pub mod weights;

type AccountIdOf<T> = <T as frame_system::Config>::AccountId;
type NftsOf<T> = pallet_nfts::Pallet<T, NftsInstanceOf<T>>;
type NftsErrorOf<T> = pallet_nfts::Error<T, NftsInstanceOf<T>>;
type NftsWeightInfoOf<T> = <T as pallet_nfts::Config<NftsInstanceOf<T>>>::WeightInfo;
type NftsInstanceOf<T> = <T as Config>::NftsInstance;
type BalanceOf<T> = <<T as pallet_nfts::Config<NftsInstanceOf<T>>>::Currency as Currency<
<T as frame_system::Config>::AccountId,
>>::Balance;
type CollectionIdOf<T> =
<NftsOf<T> as Inspect<<T as frame_system::Config>::AccountId>>::CollectionId;
type ItemIdOf<T> = <NftsOf<T> as Inspect<<T as frame_system::Config>::AccountId>>::ItemId;
type ItemPriceOf<T> = BalanceOf<T>;
type CollectionDetailsFor<T> = CollectionDetails<AccountIdOf<T>, BalanceOf<T>>;
type AttributeNamespaceOf<T> = AttributeNamespace<AccountIdOf<T>>;
type CollectionConfigFor<T> =
CollectionConfig<ItemPriceOf<T>, BlockNumberFor<T>, CollectionIdOf<T>>;
// Type aliases for pallet-nfts storage items.
pub(super) type AccountBalanceOf<T> = pallet_nfts::AccountBalance<T, NftsInstanceOf<T>>;
pub(super) type AttributeOf<T> = pallet_nfts::Attribute<T, NftsInstanceOf<T>>;
pub(super) type NextCollectionIdOf<T> = pallet_nfts::NextCollectionId<T, NftsInstanceOf<T>>;
pub(super) type CollectionOf<T> = pallet_nfts::Collection<T, NftsInstanceOf<T>>;

#[frame_support::pallet]

Check warning on line 25 in pallets/api/src/nonfungibles/mod.rs

View workflow job for this annotation

GitHub Actions / clippy

missing documentation for an associated function

warning: missing documentation for an associated function --> pallets/api/src/nonfungibles/mod.rs:25:1 | 25 | #[frame_support::pallet] | ^^^^^^^^^^^^^^^^^^^^^^^^ | = note: this warning originates in the attribute macro `frame_support::pallet` (in Nightly builds, run with -Z macro-backtrace for more info)
pub mod pallet {
use frame_support::{
Expand All @@ -50,8 +30,6 @@ pub mod pallet {
traits::Incrementable,
};
use frame_system::pallet_prelude::*;
use pallet_nfts::{CancelAttributesApprovalWitness, DestroyWitness, MintWitness};
use sp_runtime::BoundedVec;
use sp_std::vec::Vec;

use super::*;
Expand Down Expand Up @@ -104,7 +82,7 @@ pub mod pallet {
/// The namespace of the attribute.
namespace: AttributeNamespaceOf<T>,
/// The key of the attribute.
key: BoundedVec<u8, T::KeyLimit>,
key: AttributeKey<T>,
},
/// Details of a specified collection.
#[codec(index = 9)]
Expand Down Expand Up @@ -354,8 +332,8 @@ pub mod pallet {
collection: CollectionIdOf<T>,
item: Option<ItemIdOf<T>>,
namespace: AttributeNamespaceOf<T>,
key: BoundedVec<u8, T::KeyLimit>,
value: BoundedVec<u8, T::ValueLimit>,
key: AttributeKey<T>,
value: AttributeValue<T>,
) -> DispatchResult {
NftsOf::<T>::set_attribute(origin, collection, item, namespace, key, value)
}
Expand All @@ -374,7 +352,7 @@ pub mod pallet {
collection: CollectionIdOf<T>,
item: Option<ItemIdOf<T>>,
namespace: AttributeNamespaceOf<T>,
key: BoundedVec<u8, T::KeyLimit>,
key: AttributeKey<T>,
) -> DispatchResult {
NftsOf::<T>::clear_attribute(origin, collection, item, namespace, key)
}
Expand All @@ -391,7 +369,7 @@ pub mod pallet {
origin: OriginFor<T>,
collection: CollectionIdOf<T>,
item: ItemIdOf<T>,
data: BoundedVec<u8, T::StringLimit>,
data: MetadataData<T>,
) -> DispatchResult {
NftsOf::<T>::set_metadata(origin, collection, item, data)
}
Expand Down
31 changes: 31 additions & 0 deletions pallets/api/src/nonfungibles/types.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
use super::*;

pub(super) type AccountIdOf<T> = <T as frame_system::Config>::AccountId;
pub(super) type NftsOf<T> = pallet_nfts::Pallet<T, NftsInstanceOf<T>>;
pub(super) type NftsErrorOf<T> = pallet_nfts::Error<T, NftsInstanceOf<T>>;
pub(super) type NftsWeightInfoOf<T> = <T as pallet_nfts::Config<NftsInstanceOf<T>>>::WeightInfo;
pub(super) type NftsInstanceOf<T> = <T as Config>::NftsInstance;
pub(super) type BalanceOf<T> =
<<T as pallet_nfts::Config<NftsInstanceOf<T>>>::Currency as Currency<
<T as frame_system::Config>::AccountId,
>>::Balance;
pub(super) type CollectionIdOf<T> =
<NftsOf<T> as Inspect<<T as frame_system::Config>::AccountId>>::CollectionId;
pub(super) type ItemIdOf<T> =
<NftsOf<T> as Inspect<<T as frame_system::Config>::AccountId>>::ItemId;
pub(super) type ItemPriceOf<T> = BalanceOf<T>;
pub(super) type CollectionDetailsFor<T> = CollectionDetails<AccountIdOf<T>, BalanceOf<T>>;
pub(super) type AttributeNamespaceOf<T> = AttributeNamespace<AccountIdOf<T>>;
pub(super) type CollectionConfigFor<T> =
CollectionConfig<ItemPriceOf<T>, BlockNumberFor<T>, CollectionIdOf<T>>;
// Public due to pop-api integration tests crate.
pub type AccountBalanceOf<T> = pallet_nfts::AccountBalance<T, NftsInstanceOf<T>>;

Check warning on line 22 in pallets/api/src/nonfungibles/types.rs

View workflow job for this annotation

GitHub Actions / clippy

missing documentation for a type alias

warning: missing documentation for a type alias --> pallets/api/src/nonfungibles/types.rs:22:1 | 22 | pub type AccountBalanceOf<T> = pallet_nfts::AccountBalance<T, NftsInstanceOf<T>>; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
pub type AttributeOf<T> = pallet_nfts::Attribute<T, NftsInstanceOf<T>>;

Check warning on line 23 in pallets/api/src/nonfungibles/types.rs

View workflow job for this annotation

GitHub Actions / clippy

missing documentation for a type alias

warning: missing documentation for a type alias --> pallets/api/src/nonfungibles/types.rs:23:1 | 23 | pub type AttributeOf<T> = pallet_nfts::Attribute<T, NftsInstanceOf<T>>; | ^^^^^^^^^^^^^^^^^^^^^^^
pub type AttributeKey<T> = BoundedVec<u8, <T as pallet_nfts::Config<NftsInstanceOf<T>>>::KeyLimit>;

Check warning on line 24 in pallets/api/src/nonfungibles/types.rs

View workflow job for this annotation

GitHub Actions / clippy

missing documentation for a type alias

warning: missing documentation for a type alias --> pallets/api/src/nonfungibles/types.rs:24:1 | 24 | pub type AttributeKey<T> = BoundedVec<u8, <T as pallet_nfts::Config<NftsInstanceOf<T>>>::KeyLimit>; | ^^^^^^^^^^^^^^^^^^^^^^^^
pub type AttributeValue<T> =

Check warning on line 25 in pallets/api/src/nonfungibles/types.rs

View workflow job for this annotation

GitHub Actions / clippy

missing documentation for a type alias

warning: missing documentation for a type alias --> pallets/api/src/nonfungibles/types.rs:25:1 | 25 | pub type AttributeValue<T> = | ^^^^^^^^^^^^^^^^^^^^^^^^^^
BoundedVec<u8, <T as pallet_nfts::Config<NftsInstanceOf<T>>>::ValueLimit>;
pub type CollectionOf<T> = pallet_nfts::Collection<T, NftsInstanceOf<T>>;

Check warning on line 27 in pallets/api/src/nonfungibles/types.rs

View workflow job for this annotation

GitHub Actions / clippy

missing documentation for a type alias

warning: missing documentation for a type alias --> pallets/api/src/nonfungibles/types.rs:27:1 | 27 | pub type CollectionOf<T> = pallet_nfts::Collection<T, NftsInstanceOf<T>>; | ^^^^^^^^^^^^^^^^^^^^^^^^
pub type CollectionConfigOf<T> = pallet_nfts::CollectionConfigOf<T, NftsInstanceOf<T>>;

Check warning on line 28 in pallets/api/src/nonfungibles/types.rs

View workflow job for this annotation

GitHub Actions / clippy

missing documentation for a type alias

warning: missing documentation for a type alias --> pallets/api/src/nonfungibles/types.rs:28:1 | 28 | pub type CollectionConfigOf<T> = pallet_nfts::CollectionConfigOf<T, NftsInstanceOf<T>>; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
pub type NextCollectionIdOf<T> = pallet_nfts::NextCollectionId<T, NftsInstanceOf<T>>;

Check warning on line 29 in pallets/api/src/nonfungibles/types.rs

View workflow job for this annotation

GitHub Actions / clippy

missing documentation for a type alias

warning: missing documentation for a type alias --> pallets/api/src/nonfungibles/types.rs:29:1 | 29 | pub type NextCollectionIdOf<T> = pallet_nfts::NextCollectionId<T, NftsInstanceOf<T>>; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
pub type MetadataData<T> =

Check warning on line 30 in pallets/api/src/nonfungibles/types.rs

View workflow job for this annotation

GitHub Actions / clippy

missing documentation for a type alias

warning: missing documentation for a type alias --> pallets/api/src/nonfungibles/types.rs:30:1 | 30 | pub type MetadataData<T> = | ^^^^^^^^^^^^^^^^^^^^^^^^
BoundedVec<u8, <T as pallet_nfts::Config<NftsInstanceOf<T>>>::StringLimit>;
2 changes: 2 additions & 0 deletions pop-api/integration-tests/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ frame-support = { version = "36.0.0", default-features = false }
frame-support-procedural = { version = "=30.0.1", default-features = false }
frame-system = { version = "36.1.0", default-features = false }
log = "0.4.22"
pallet-api = { path = "../../pallets/api", default-features = false }
pallet-assets = { version = "37.0.0", default-features = false }
pallet-balances = { version = "37.0.0", default-features = false }
pallet-contracts = { version = "35.0.0", default-features = false }
Expand All @@ -38,6 +39,7 @@ devnet = [ ]
std = [
"frame-support/std",
"frame-system/std",
"pallet-api/std",
"pallet-assets/std",
"pallet-balances/std",
"pallet-contracts/std",
Expand Down
4 changes: 2 additions & 2 deletions pop-api/integration-tests/contracts/nonfungibles/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,11 @@ mod nonfungibles {
pub fn allowance(
&self,
collection: CollectionId,
item: Option<ItemId>,
owner: AccountId,
operator: AccountId,
item: Option<ItemId>,
) -> Result<bool> {
api::allowance(collection, owner, operator, item)
api::allowance(collection, item, owner, operator)
}

#[ink(message)]
Expand Down
Loading

0 comments on commit 3c9ccd9

Please sign in to comment.