difftreelog
Merge commit '2074c933e3ff90b7ea5fc778111ead850fd4a5ea' into release-v922000
in: master
20 files changed
client/rpc/src/lib.rsdiffbeforeafterboth--- a/client/rpc/src/lib.rs
+++ b/client/rpc/src/lib.rs
@@ -25,7 +25,7 @@
use anyhow::anyhow;
use up_data_structs::{
RpcCollection, CollectionId, CollectionStats, CollectionLimits, TokenId, Property,
- PropertyKeyPermission, TokenData,
+ PropertyKeyPermission, TokenData, TokenChild,
};
use sp_api::{BlockId, BlockT, ProvideRuntimeApi, ApiExt};
use sp_blockchain::HeaderBackend;
@@ -77,6 +77,13 @@
token: TokenId,
at: Option<BlockHash>,
) -> Result<Option<CrossAccountId>>;
+ #[method(name = "unique_tokenChildren")]
+ fn token_children(
+ &self,
+ collection: CollectionId,
+ token: TokenId,
+ at: Option<BlockHash>,
+ ) -> Result<Vec<TokenChild>>;
#[method(name = "unique_collectionProperties")]
fn collection_properties(
@@ -394,6 +401,7 @@
pass_method!(
topmost_token_owner(collection: CollectionId, token: TokenId) -> Option<CrossAccountId>, unique_api
);
+ pass_method!(token_children(collection: CollectionId, token: TokenId) -> Vec<TokenChild>, unique_api);
pass_method!(total_supply(collection: CollectionId) -> u32, unique_api);
pass_method!(account_balance(collection: CollectionId, account: CrossAccountId) -> u32, unique_api);
pass_method!(balance(collection: CollectionId, account: CrossAccountId, token: TokenId) -> String => |v| v.to_string(), unique_api);
pallets/common/src/lib.rsdiffbeforeafterboth--- a/pallets/common/src/lib.rs
+++ b/pallets/common/src/lib.rs
@@ -40,6 +40,7 @@
MAX_TOKEN_PREFIX_LENGTH,
COLLECTION_ADMINS_LIMIT,
TokenId,
+ TokenChild,
CollectionStats,
MAX_TOKEN_OWNERSHIP,
CollectionMode,
@@ -502,6 +503,7 @@
CollectionStats,
CollectionId,
TokenId,
+ TokenChild,
PhantomType<(
TokenData<T::CrossAccountId>,
RpcCollection<T::AccountId>,
pallets/nonfungible/src/lib.rsdiffbeforeafterboth--- a/pallets/nonfungible/src/lib.rs
+++ b/pallets/nonfungible/src/lib.rs
@@ -22,7 +22,7 @@
use up_data_structs::{
AccessMode, CollectionId, CustomDataLimit, TokenId, CreateCollectionData, CreateNftExData,
mapping::TokenAddressMapping, NestingRule, budget::Budget, Property, PropertyPermission,
- PropertyKey, PropertyKeyPermission, Properties, PropertyScope, TrySetProperty,
+ PropertyKey, PropertyKeyPermission, Properties, PropertyScope, TrySetProperty, TokenChild,
};
use pallet_evm::{account::CrossAccountId, Pallet as PalletEvm};
use pallet_common::{
@@ -604,7 +604,7 @@
// =========
- <PalletStructure<T>>::unnest_if_nested(from, collection.id, token);
+ <PalletStructure<T>>::unnest_if_nested(&token_data.owner, collection.id, token);
<TokenData<T>>::insert(
(collection.id, token),
@@ -988,6 +988,15 @@
.is_some()
}
+ pub fn token_children_ids(collection_id: CollectionId, token_id: TokenId) -> Vec<TokenChild> {
+ <TokenChildren<T>>::iter_prefix((collection_id, token_id))
+ .map(|((child_collection_id, child_id), _)| TokenChild {
+ collection: child_collection_id,
+ token: child_id,
+ })
+ .collect()
+ }
+
/// Delegated to `create_multiple_items`
pub fn create_item(
collection: &NonfungibleHandle<T>,
pallets/structure/src/lib.rsdiffbeforeafterboth--- a/pallets/structure/src/lib.rs
+++ b/pallets/structure/src/lib.rs
@@ -191,8 +191,8 @@
token_id: TokenId,
nesting_budget: &dyn Budget,
) -> DispatchResult {
- Self::try_exec_if_owner_is_valid_nft(under, |d, parent_id| {
- d.check_nesting(from, (collection_id, token_id), parent_id, nesting_budget)
+ Self::try_exec_if_owner_is_valid_nft(under, |collection, parent_id| {
+ collection.check_nesting(from, (collection_id, token_id), parent_id, nesting_budget)
})
}
@@ -203,10 +203,10 @@
token_id: TokenId,
nesting_budget: &dyn Budget,
) -> DispatchResult {
- Self::try_exec_if_owner_is_valid_nft(under, |d, parent_id| {
- d.check_nesting(from, (collection_id, token_id), parent_id, nesting_budget)?;
+ Self::try_exec_if_owner_is_valid_nft(under, |collection, parent_id| {
+ collection.check_nesting(from, (collection_id, token_id), parent_id, nesting_budget)?;
- d.nest(parent_id, (collection_id, token_id));
+ collection.nest(parent_id, (collection_id, token_id));
Ok(())
})
@@ -217,8 +217,8 @@
collection_id: CollectionId,
token_id: TokenId,
) {
- Self::exec_if_owner_is_valid_nft(owner, |d, parent_id| {
- d.nest(parent_id, (collection_id, token_id))
+ Self::exec_if_owner_is_valid_nft(owner, |collection, parent_id| {
+ collection.nest(parent_id, (collection_id, token_id))
});
}
@@ -227,8 +227,8 @@
collection_id: CollectionId,
token_id: TokenId,
) {
- Self::exec_if_owner_is_valid_nft(owner, |d, parent_id| {
- d.unnest(parent_id, (collection_id, token_id))
+ Self::exec_if_owner_is_valid_nft(owner, |collection, parent_id| {
+ collection.unnest(parent_id, (collection_id, token_id))
});
}
@@ -236,8 +236,8 @@
account: &T::CrossAccountId,
action: impl FnOnce(&dyn CommonCollectionOperations<T>, TokenId),
) {
- Self::try_exec_if_owner_is_valid_nft(account, |d, id| {
- action(d, id);
+ Self::try_exec_if_owner_is_valid_nft(account, |collection, id| {
+ action(collection, id);
Ok(())
})
.unwrap();
primitives/data-structs/src/lib.rsdiffbeforeafterboth--- a/primitives/data-structs/src/lib.rs
+++ b/primitives/data-structs/src/lib.rs
@@ -585,6 +585,14 @@
#[derive(Encode, Decode, MaxEncodedLen, PartialEq, Clone, Debug, TypeInfo)]
#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))]
+// todo possibly rename to be used generally as an address pair
+pub struct TokenChild {
+ pub token: TokenId,
+ pub collection: CollectionId,
+}
+
+#[derive(Encode, Decode, MaxEncodedLen, PartialEq, Clone, Debug, TypeInfo)]
+#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))]
pub struct CollectionStats {
pub created: u32,
pub destroyed: u32,
primitives/rpc/src/lib.rsdiffbeforeafterboth--- a/primitives/rpc/src/lib.rs
+++ b/primitives/rpc/src/lib.rs
@@ -18,7 +18,7 @@
use up_data_structs::{
CollectionId, TokenId, RpcCollection, CollectionStats, CollectionLimits, Property,
- PropertyKeyPermission, TokenData,
+ PropertyKeyPermission, TokenData, TokenChild,
};
use sp_std::vec::Vec;
use codec::Decode;
@@ -41,6 +41,7 @@
fn token_owner(collection: CollectionId, token: TokenId) -> Result<Option<CrossAccountId>>;
fn topmost_token_owner(collection: CollectionId, token: TokenId) -> Result<Option<CrossAccountId>>;
+ fn token_children(collection: CollectionId, token: TokenId) -> Result<Vec<TokenChild>>;
fn collection_properties(collection: CollectionId, properties: Option<Vec<Vec<u8>>>) -> Result<Vec<Property>>;
runtime/common/src/runtime_apis.rsdiffbeforeafterboth--- a/runtime/common/src/runtime_apis.rs
+++ b/runtime/common/src/runtime_apis.rs
@@ -29,7 +29,9 @@
Ok(Some(<pallet_structure::Pallet<Runtime>>::find_topmost_owner(collection, token, &budget)?))
}
-
+ fn token_children(collection: CollectionId, token: TokenId) -> Result<Vec<TokenChild>, DispatchError> {
+ Ok(<pallet_nonfungible::Pallet<Runtime>>::token_children_ids(collection, token))
+ }
fn collection_properties(
collection: CollectionId,
keys: Option<Vec<Vec<u8>>>
runtime/opal/src/lib.rsdiffbeforeafterboth--- a/runtime/opal/src/lib.rs
+++ b/runtime/opal/src/lib.rs
@@ -73,6 +73,7 @@
CollectionId, TokenId, TokenData, Property, PropertyKeyPermission, CollectionLimits,
CollectionStats, RpcCollection,
mapping::{EvmTokenAddressMapping, CrossTokenAddressMapping},
+ TokenChild,
};
// use pallet_contracts::weights::WeightInfo;
runtime/quartz/src/lib.rsdiffbeforeafterboth--- a/runtime/quartz/src/lib.rs
+++ b/runtime/quartz/src/lib.rs
@@ -72,7 +72,8 @@
use up_data_structs::{
CollectionId, TokenId, TokenData, Property, PropertyKeyPermission, CollectionLimits,
CollectionStats, RpcCollection,
- mapping::{EvmTokenAddressMapping, CrossTokenAddressMapping}
+ mapping::{EvmTokenAddressMapping, CrossTokenAddressMapping},
+ TokenChild,
};
// use pallet_contracts::weights::WeightInfo;
runtime/tests/src/tests.rsdiffbeforeafterboth1// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.2// This file is part of Unique Network.34// Unique Network is free software: you can redistribute it and/or modify5// it under the terms of the GNU General Public License as published by6// the Free Software Foundation, either version 3 of the License, or7// (at your option) any later version.89// Unique Network is distributed in the hope that it will be useful,10// but WITHOUT ANY WARRANTY; without even the implied warranty of11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the12// GNU General Public License for more details.1314// You should have received a copy of the GNU General Public License15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.1617// Tests to be written here18use crate::{Test, TestCrossAccountId, CollectionCreationPrice, Origin, Unique, new_test_ext};19use up_data_structs::{20 COLLECTION_NUMBER_LIMIT, CollectionId, CreateItemData, CreateFungibleData, CreateNftData,21 CreateReFungibleData, MAX_DECIMAL_POINTS, COLLECTION_ADMINS_LIMIT, TokenId,22 MAX_TOKEN_OWNERSHIP, CreateCollectionData, CollectionMode, AccessMode, CollectionPermissions,23 PropertyKeyPermission, PropertyPermission, Property, CollectionPropertiesVec,24 CollectionPropertiesPermissionsVec,25};26use frame_support::{assert_noop, assert_ok, assert_err};27use sp_std::convert::TryInto;28use pallet_evm::account::CrossAccountId;29use pallet_common::Error as CommonError;30use pallet_unique::Error as UniqueError;3132fn add_balance(user: u64, value: u64) {33 const DONOR_USER: u64 = 999;34 assert_ok!(<pallet_balances::Pallet<Test>>::set_balance(35 Origin::root(),36 DONOR_USER,37 value,38 039 ));40 assert_ok!(<pallet_balances::Pallet<Test>>::force_transfer(41 Origin::root(),42 DONOR_USER,43 user,44 value45 ));46}4748fn default_nft_data() -> CreateNftData {49 CreateNftData {50 properties: vec![Property {51 key: b"test-prop".to_vec().try_into().unwrap(),52 value: b"test-nft-prop".to_vec().try_into().unwrap(),53 }]54 .try_into()55 .unwrap(),56 }57}5859fn default_fungible_data() -> CreateFungibleData {60 CreateFungibleData { value: 5 }61}6263fn default_re_fungible_data() -> CreateReFungibleData {64 CreateReFungibleData {65 const_data: vec![1, 2, 3].try_into().unwrap(),66 pieces: 1023,67 }68}6970fn create_test_collection_for_owner(71 mode: &CollectionMode,72 owner: u64,73 id: CollectionId,74) -> CollectionId {75 add_balance(owner, CollectionCreationPrice::get() as u64 + 1);7677 let col_name1: Vec<u16> = "Test1\0".encode_utf16().collect::<Vec<u16>>();78 let col_desc1: Vec<u16> = "TestDescription1\0".encode_utf16().collect::<Vec<u16>>();79 let token_prefix1: Vec<u8> = b"token_prefix1\0".to_vec();80 let token_property_permissions: CollectionPropertiesPermissionsVec =81 vec![PropertyKeyPermission {82 key: b"test-prop".to_vec().try_into().unwrap(),83 permission: PropertyPermission {84 mutable: true,85 collection_admin: false,86 token_owner: true,87 },88 }]89 .try_into()90 .unwrap();91 let properties: CollectionPropertiesVec = vec![Property {92 key: b"test-collection-prop".to_vec().try_into().unwrap(),93 value: b"test-collection-value".to_vec().try_into().unwrap(),94 }]95 .try_into()96 .unwrap();9798 let data: CreateCollectionData<u64> = CreateCollectionData {99 name: col_name1.try_into().unwrap(),100 description: col_desc1.try_into().unwrap(),101 token_prefix: token_prefix1.try_into().unwrap(),102 mode: mode.clone(),103 token_property_permissions: token_property_permissions.clone(),104 properties: properties.clone(),105 ..Default::default()106 };107108 let origin1 = Origin::signed(owner);109 assert_ok!(Unique::create_collection_ex(origin1, data));110111 let saved_col_name: Vec<u16> = "Test1\0".encode_utf16().collect::<Vec<u16>>();112 let saved_description: Vec<u16> = "TestDescription1\0".encode_utf16().collect::<Vec<u16>>();113 let saved_prefix: Vec<u8> = b"token_prefix1\0".to_vec();114 assert_eq!(115 <pallet_common::CollectionById<Test>>::get(id)116 .unwrap()117 .owner,118 owner119 );120 assert_eq!(121 <pallet_common::CollectionById<Test>>::get(id).unwrap().name,122 saved_col_name123 );124 assert_eq!(125 <pallet_common::CollectionById<Test>>::get(id).unwrap().mode,126 *mode127 );128 assert_eq!(129 <pallet_common::CollectionById<Test>>::get(id)130 .unwrap()131 .description,132 saved_description133 );134 assert_eq!(135 <pallet_common::CollectionById<Test>>::get(id)136 .unwrap()137 .token_prefix,138 saved_prefix139 );140 assert_eq!(141 get_collection_property_permissions(id).as_slice(),142 token_property_permissions.as_slice()143 );144 assert_eq!(145 get_collection_properties(id).as_slice(),146 properties.as_slice()147 );148 id149}150151fn get_collection_property_permissions(collection_id: CollectionId) -> Vec<PropertyKeyPermission> {152 <pallet_common::Pallet<Test>>::property_permissions(collection_id)153 .into_iter()154 .map(|(key, permission)| PropertyKeyPermission { key, permission })155 .collect()156}157158fn get_collection_properties(collection_id: CollectionId) -> Vec<Property> {159 <pallet_common::Pallet<Test>>::collection_properties(collection_id)160 .into_iter()161 .map(|(key, value)| Property { key, value })162 .collect()163}164165fn get_token_properties(collection_id: CollectionId, token_id: TokenId) -> Vec<Property> {166 <pallet_nonfungible::Pallet<Test>>::token_properties((collection_id, token_id))167 .into_iter()168 .map(|(key, value)| Property { key, value })169 .collect()170}171172fn create_test_collection(mode: &CollectionMode, id: CollectionId) -> CollectionId {173 create_test_collection_for_owner(&mode, 1, id)174}175176fn create_test_item(collection_id: CollectionId, data: &CreateItemData) {177 let origin1 = Origin::signed(1);178 assert_ok!(Unique::create_item(179 origin1,180 collection_id,181 account(1),182 data.clone()183 ));184}185186fn account(sub: u64) -> TestCrossAccountId {187 TestCrossAccountId::from_sub(sub)188}189190// Use cases tests region191// #region192193#[test]194fn check_not_sufficient_founds() {195 new_test_ext().execute_with(|| {196 let acc: u64 = 1;197 <pallet_balances::Pallet<Test>>::set_balance(Origin::root(), acc, 0, 0).unwrap();198199 let name: Vec<u16> = "Test1\0".encode_utf16().collect::<Vec<u16>>();200 let description: Vec<u16> = "TestDescription1\0".encode_utf16().collect::<Vec<u16>>();201 let token_prefix: Vec<u8> = b"token_prefix1\0".to_vec();202203 let data: CreateCollectionData<<Test as frame_system::Config>::AccountId> =204 CreateCollectionData {205 name: name.try_into().unwrap(),206 description: description.try_into().unwrap(),207 token_prefix: token_prefix.try_into().unwrap(),208 mode: CollectionMode::NFT,209 ..Default::default()210 };211212 let result = Unique::create_collection_ex(Origin::signed(acc), data);213 assert_err!(result, <CommonError<Test>>::NotSufficientFounds);214 });215}216217#[test]218fn create_fungible_collection_fails_with_large_decimal_numbers() {219 new_test_ext().execute_with(|| {220 let col_name1: Vec<u16> = "Test1\0".encode_utf16().collect::<Vec<u16>>();221 let col_desc1: Vec<u16> = "TestDescription1\0".encode_utf16().collect::<Vec<u16>>();222 let token_prefix1: Vec<u8> = b"token_prefix1\0".to_vec();223224 let data: CreateCollectionData<u64> = CreateCollectionData {225 name: col_name1.try_into().unwrap(),226 description: col_desc1.try_into().unwrap(),227 token_prefix: token_prefix1.try_into().unwrap(),228 mode: CollectionMode::Fungible(MAX_DECIMAL_POINTS + 1),229 ..Default::default()230 };231232 let origin1 = Origin::signed(1);233 assert_noop!(234 Unique::create_collection_ex(origin1, data),235 UniqueError::<Test>::CollectionDecimalPointLimitExceeded236 );237 });238}239240#[test]241fn create_nft_item() {242 new_test_ext().execute_with(|| {243 let collection_id = create_test_collection(&CollectionMode::NFT, CollectionId(1));244245 let data = default_nft_data();246 create_test_item(collection_id, &data.clone().into());247248 assert_eq!(249 get_token_properties(collection_id, TokenId(1)).as_slice(),250 data.properties.as_slice(),251 );252 });253}254255// Use cases tests region256// #region257#[test]258fn create_nft_multiple_items() {259 new_test_ext().execute_with(|| {260 create_test_collection(&CollectionMode::NFT, CollectionId(1));261262 let origin1 = Origin::signed(1);263264 let items_data = vec![default_nft_data(), default_nft_data(), default_nft_data()];265266 assert_ok!(Unique::create_multiple_items(267 origin1,268 CollectionId(1),269 account(1),270 items_data271 .clone()272 .into_iter()273 .map(|d| { d.into() })274 .collect()275 ));276 for (index, data) in items_data.into_iter().enumerate() {277 assert_eq!(278 get_token_properties(CollectionId(1), TokenId(index as u32 + 1)).as_slice(),279 data.properties.as_slice()280 );281 }282 });283}284285#[test]286fn create_refungible_item() {287 new_test_ext().execute_with(|| {288 let collection_id = create_test_collection(&CollectionMode::ReFungible, CollectionId(1));289290 let data = default_re_fungible_data();291 create_test_item(collection_id, &data.clone().into());292 let item = <pallet_refungible::TokenData<Test>>::get((collection_id, TokenId(1)));293 let balance =294 <pallet_refungible::Balance<Test>>::get((collection_id, TokenId(1), account(1)));295 assert_eq!(item.const_data, data.const_data.into_inner());296 assert_eq!(balance, 1023);297 });298}299300#[test]301fn create_multiple_refungible_items() {302 new_test_ext().execute_with(|| {303 create_test_collection(&CollectionMode::ReFungible, CollectionId(1));304305 let origin1 = Origin::signed(1);306307 let items_data = vec![308 default_re_fungible_data(),309 default_re_fungible_data(),310 default_re_fungible_data(),311 ];312313 assert_ok!(Unique::create_multiple_items(314 origin1,315 CollectionId(1),316 account(1),317 items_data318 .clone()319 .into_iter()320 .map(|d| { d.into() })321 .collect()322 ));323 for (index, data) in items_data.into_iter().enumerate() {324 let item = <pallet_refungible::TokenData<Test>>::get((325 CollectionId(1),326 TokenId((index + 1) as u32),327 ));328 let balance =329 <pallet_refungible::Balance<Test>>::get((CollectionId(1), TokenId(1), account(1)));330 assert_eq!(item.const_data.to_vec(), data.const_data.into_inner());331 assert_eq!(balance, 1023);332 }333 });334}335336#[test]337fn create_fungible_item() {338 new_test_ext().execute_with(|| {339 let collection_id = create_test_collection(&CollectionMode::Fungible(3), CollectionId(1));340341 let data = default_fungible_data();342 create_test_item(collection_id, &data.into());343344 assert_eq!(345 <pallet_fungible::Balance<Test>>::get((collection_id, account(1))),346 5347 );348 });349}350351//#[test]352// fn create_multiple_fungible_items() {353// new_test_ext().execute_with(|| {354// default_limits();355356// create_test_collection(&CollectionMode::Fungible(3), CollectionId(1));357358// let origin1 = Origin::signed(1);359360// let items_data = vec![default_fungible_data(), default_fungible_data(), default_fungible_data()];361362// assert_ok!(Unique::create_multiple_items(363// origin1.clone(),364// 1,365// 1,366// items_data.clone().into_iter().map(|d| { d.into() }).collect()367// ));368369// for (index, _) in items_data.iter().enumerate() {370// assert_eq!(Unique::fungible_item_id(1, (index + 1) as TokenId).value, 5);371// }372// assert_eq!(Unique::balance_count(1, 1), 3000);373// assert_eq!(Unique::address_tokens(1, 1), [1, 2, 3]);374// });375// }376377#[test]378fn transfer_fungible_item() {379 new_test_ext().execute_with(|| {380 let collection_id = create_test_collection(&CollectionMode::Fungible(3), CollectionId(1));381382 let origin1 = Origin::signed(1);383 let origin2 = Origin::signed(2);384385 let data = default_fungible_data();386 create_test_item(collection_id, &data.into());387388 assert_eq!(389 <pallet_fungible::Balance<Test>>::get((CollectionId(1), account(1))),390 5391 );392393 // change owner scenario394 assert_ok!(Unique::transfer(395 origin1,396 account(2),397 CollectionId(1),398 TokenId(0),399 5400 ));401 assert_eq!(402 <pallet_fungible::Balance<Test>>::get((CollectionId(1), account(1))),403 0404 );405406 // split item scenario407 assert_ok!(Unique::transfer(408 origin2.clone(),409 account(3),410 CollectionId(1),411 TokenId(0),412 3413 ));414415 // split item and new owner has account scenario416 assert_ok!(Unique::transfer(417 origin2,418 account(3),419 CollectionId(1),420 TokenId(0),421 1422 ));423 assert_eq!(424 <pallet_fungible::Balance<Test>>::get((CollectionId(1), account(2))),425 1426 );427 assert_eq!(428 <pallet_fungible::Balance<Test>>::get((CollectionId(1), account(3))),429 4430 );431 });432}433434#[test]435fn transfer_refungible_item() {436 new_test_ext().execute_with(|| {437 let collection_id = create_test_collection(&CollectionMode::ReFungible, CollectionId(1));438439 // Create RFT 1 in 1023 pieces for account 1440 let data = default_re_fungible_data();441 create_test_item(collection_id, &data.clone().into());442 let item = <pallet_refungible::TokenData<Test>>::get((collection_id, TokenId(1)));443 assert_eq!(item.const_data, data.const_data.into_inner());444 assert_eq!(445 <pallet_refungible::AccountBalance<Test>>::get((collection_id, account(1))),446 1447 );448 assert_eq!(449 <pallet_refungible::Balance<Test>>::get((collection_id, TokenId(1), account(1))),450 1023451 );452 assert_eq!(453 <pallet_refungible::Owned<Test>>::get((collection_id, account(1), TokenId(1))),454 true455 );456457 // Account 1 transfers all 1023 pieces of RFT 1 to account 2458 let origin1 = Origin::signed(1);459 let origin2 = Origin::signed(2);460 assert_ok!(Unique::transfer(461 origin1,462 account(2),463 CollectionId(1),464 TokenId(1),465 1023466 ));467 assert_eq!(468 <pallet_refungible::Balance<Test>>::get((collection_id, TokenId(1), account(2))),469 1023470 );471 assert_eq!(472 <pallet_refungible::AccountBalance<Test>>::get((collection_id, account(1))),473 0474 );475 assert_eq!(476 <pallet_refungible::AccountBalance<Test>>::get((collection_id, account(2))),477 1478 );479 assert_eq!(480 <pallet_refungible::Owned<Test>>::get((collection_id, account(1), TokenId(1))),481 false482 );483 assert_eq!(484 <pallet_refungible::Owned<Test>>::get((collection_id, account(2), TokenId(1))),485 true486 );487488 // Account 2 transfers 500 pieces of RFT 1 to account 3489 assert_ok!(Unique::transfer(490 origin2.clone(),491 account(3),492 CollectionId(1),493 TokenId(1),494 500495 ));496 assert_eq!(497 <pallet_refungible::Balance<Test>>::get((collection_id, TokenId(1), account(2))),498 523499 );500 assert_eq!(501 <pallet_refungible::Balance<Test>>::get((collection_id, TokenId(1), account(3))),502 500503 );504 assert_eq!(505 <pallet_refungible::AccountBalance<Test>>::get((collection_id, account(2))),506 1507 );508 assert_eq!(509 <pallet_refungible::AccountBalance<Test>>::get((collection_id, account(3))),510 1511 );512 assert_eq!(513 <pallet_refungible::Owned<Test>>::get((collection_id, account(2), TokenId(1))),514 true515 );516 assert_eq!(517 <pallet_refungible::Owned<Test>>::get((collection_id, account(3), TokenId(1))),518 true519 );520521 // Account 2 transfers 200 more pieces of RFT 1 to account 3 with pre-existing balance522 assert_ok!(Unique::transfer(523 origin2,524 account(3),525 CollectionId(1),526 TokenId(1),527 200528 ));529 assert_eq!(530 <pallet_refungible::Balance<Test>>::get((collection_id, TokenId(1), account(2))),531 323532 );533 assert_eq!(534 <pallet_refungible::Balance<Test>>::get((collection_id, TokenId(1), account(3))),535 700536 );537 assert_eq!(538 <pallet_refungible::AccountBalance<Test>>::get((collection_id, account(2))),539 1540 );541 assert_eq!(542 <pallet_refungible::AccountBalance<Test>>::get((collection_id, account(3))),543 1544 );545 assert_eq!(546 <pallet_refungible::Owned<Test>>::get((collection_id, account(2), TokenId(1))),547 true548 );549 assert_eq!(550 <pallet_refungible::Owned<Test>>::get((collection_id, account(3), TokenId(1))),551 true552 );553 });554}555556#[test]557fn transfer_nft_item() {558 new_test_ext().execute_with(|| {559 let collection_id = create_test_collection(&CollectionMode::NFT, CollectionId(1));560561 let data = default_nft_data();562 create_test_item(collection_id, &data.into());563 assert_eq!(564 <pallet_nonfungible::AccountBalance<Test>>::get((collection_id, account(1))),565 1566 );567 assert_eq!(568 <pallet_nonfungible::Owned<Test>>::get((collection_id, account(1), TokenId(1))),569 true570 );571572 let origin1 = Origin::signed(1);573 // default scenario574 assert_ok!(Unique::transfer(575 origin1,576 account(2),577 CollectionId(1),578 TokenId(1),579 1580 ));581 assert_eq!(582 <pallet_nonfungible::AccountBalance<Test>>::get((collection_id, account(1))),583 0584 );585 assert_eq!(586 <pallet_nonfungible::AccountBalance<Test>>::get((collection_id, account(2))),587 1588 );589 assert_eq!(590 <pallet_nonfungible::Owned<Test>>::get((collection_id, account(1), TokenId(1))),591 false592 );593 assert_eq!(594 <pallet_nonfungible::Owned<Test>>::get((collection_id, account(2), TokenId(1))),595 true596 );597 });598}599600#[test]601fn transfer_nft_item_wrong_value() {602 new_test_ext().execute_with(|| {603 let collection_id = create_test_collection(&CollectionMode::NFT, CollectionId(1));604605 let data = default_nft_data();606 create_test_item(collection_id, &data.into());607 assert_eq!(608 <pallet_nonfungible::AccountBalance<Test>>::get((collection_id, account(1))),609 1610 );611 assert_eq!(612 <pallet_nonfungible::Owned<Test>>::get((collection_id, account(1), TokenId(1))),613 true614 );615616 let origin1 = Origin::signed(1);617618 assert_noop!(619 Unique::transfer(origin1, account(2), CollectionId(1), TokenId(1), 2)620 .map_err(|e| e.error),621 <pallet_nonfungible::Error::<Test>>::NonfungibleItemsHaveNoAmount622 );623 });624}625626#[test]627fn transfer_nft_item_zero_value() {628 new_test_ext().execute_with(|| {629 let collection_id = create_test_collection(&CollectionMode::NFT, CollectionId(1));630631 let data = default_nft_data();632 create_test_item(collection_id, &data.into());633 assert_eq!(634 <pallet_nonfungible::AccountBalance<Test>>::get((collection_id, account(1))),635 1636 );637 assert_eq!(638 <pallet_nonfungible::Owned<Test>>::get((collection_id, account(1), TokenId(1))),639 true640 );641642 let origin1 = Origin::signed(1);643644 // Transferring 0 amount works on NFT...645 assert_ok!(Unique::transfer(646 origin1,647 account(2),648 CollectionId(1),649 TokenId(1),650 0651 ));652 // ... and results in no transfer653 assert_eq!(654 <pallet_nonfungible::AccountBalance<Test>>::get((collection_id, account(1))),655 1656 );657 assert_eq!(658 <pallet_nonfungible::Owned<Test>>::get((collection_id, account(1), TokenId(1))),659 true660 );661 });662}663664#[test]665fn nft_approve_and_transfer_from() {666 new_test_ext().execute_with(|| {667 let collection_id = create_test_collection(&CollectionMode::NFT, CollectionId(1));668669 let data = default_nft_data();670 create_test_item(collection_id, &data.into());671672 let origin1 = Origin::signed(1);673 let origin2 = Origin::signed(2);674675 assert_eq!(676 <pallet_nonfungible::AccountBalance<Test>>::get((collection_id, account(1))),677 1678 );679 assert_eq!(680 <pallet_nonfungible::Owned<Test>>::get((collection_id, account(1), TokenId(1))),681 true682 );683684 // neg transfer_from685 assert_noop!(686 Unique::transfer_from(687 origin2.clone(),688 account(1),689 account(2),690 CollectionId(1),691 TokenId(1),692 1693 )694 .map_err(|e| e.error),695 CommonError::<Test>::ApprovedValueTooLow696 );697698 // do approve699 assert_ok!(Unique::approve(700 origin1,701 account(2),702 CollectionId(1),703 TokenId(1),704 1705 ));706 assert_eq!(707 <pallet_nonfungible::Allowance<Test>>::get((CollectionId(1), TokenId(1))).unwrap(),708 account(2)709 );710711 assert_ok!(Unique::transfer_from(712 origin2,713 account(1),714 account(3),715 CollectionId(1),716 TokenId(1),717 1718 ));719 assert!(720 <pallet_nonfungible::Allowance<Test>>::get((CollectionId(1), TokenId(1))).is_none()721 );722 });723}724725#[test]726fn nft_approve_and_transfer_from_allow_list() {727 new_test_ext().execute_with(|| {728 let collection_id = create_test_collection(&CollectionMode::NFT, CollectionId(1));729730 let origin1 = Origin::signed(1);731 let origin2 = Origin::signed(2);732733 // Create NFT 1 for account 1734 let data = default_nft_data();735 create_test_item(collection_id, &data.clone().into());736 assert_eq!(737 <pallet_nonfungible::AccountBalance<Test>>::get((collection_id, account(1))),738 1739 );740 assert_eq!(741 <pallet_nonfungible::Owned<Test>>::get((collection_id, account(1), TokenId(1))),742 true743 );744745 // Allow allow-list users to mint and add accounts 1, 2, and 3 to allow-list746 assert_ok!(Unique::set_collection_permissions(747 origin1.clone(),748 CollectionId(1),749 CollectionPermissions {750 mint_mode: Some(true),751 access: Some(AccessMode::AllowList),752 nesting: None,753 }754 ));755 assert_ok!(Unique::add_to_allow_list(756 origin1.clone(),757 CollectionId(1),758 account(1)759 ));760 assert_ok!(Unique::add_to_allow_list(761 origin1.clone(),762 CollectionId(1),763 account(2)764 ));765 assert_ok!(Unique::add_to_allow_list(766 origin1.clone(),767 CollectionId(1),768 account(3)769 ));770771 // Account 1 approves account 2 for NFT 1772 assert_ok!(Unique::approve(773 origin1.clone(),774 account(2),775 CollectionId(1),776 TokenId(1),777 1778 ));779 assert_eq!(780 <pallet_nonfungible::Allowance<Test>>::get((CollectionId(1), TokenId(1))).unwrap(),781 account(2)782 );783784 // Account 2 transfers NFT 1 from account 1 to account 3785 assert_ok!(Unique::transfer_from(786 origin2,787 account(1),788 account(3),789 CollectionId(1),790 TokenId(1),791 1792 ));793 assert!(794 <pallet_nonfungible::Allowance<Test>>::get((CollectionId(1), TokenId(1))).is_none()795 );796 });797}798799#[test]800fn refungible_approve_and_transfer_from() {801 new_test_ext().execute_with(|| {802 let collection_id = create_test_collection(&CollectionMode::ReFungible, CollectionId(1));803804 let origin1 = Origin::signed(1);805 let origin2 = Origin::signed(2);806807 // Create RFT 1 in 1023 pieces for account 1808 let data = default_re_fungible_data();809 create_test_item(collection_id, &data.into());810811 assert_eq!(812 <pallet_refungible::AccountBalance<Test>>::get((collection_id, account(1))),813 1814 );815 assert_eq!(816 <pallet_refungible::Balance<Test>>::get((collection_id, TokenId(1), account(1))),817 1023818 );819 assert_eq!(820 <pallet_refungible::Owned<Test>>::get((collection_id, account(1), TokenId(1))),821 true822 );823824 // Allow public minting, enable allow-list and add accounts 1, 2, 3 to allow-list825 assert_ok!(Unique::set_collection_permissions(826 origin1.clone(),827 CollectionId(1),828 CollectionPermissions {829 mint_mode: Some(true),830 access: Some(AccessMode::AllowList),831 nesting: None,832 }833 ));834 assert_ok!(Unique::add_to_allow_list(835 origin1.clone(),836 CollectionId(1),837 account(1)838 ));839 assert_ok!(Unique::add_to_allow_list(840 origin1.clone(),841 CollectionId(1),842 account(2)843 ));844 assert_ok!(Unique::add_to_allow_list(845 origin1.clone(),846 CollectionId(1),847 account(3)848 ));849850 // Account 1 approves account 2 for 1023 pieces of RFT 1851 assert_ok!(Unique::approve(852 origin1,853 account(2),854 CollectionId(1),855 TokenId(1),856 1023857 ));858 assert_eq!(859 <pallet_refungible::Allowance<Test>>::get((860 CollectionId(1),861 TokenId(1),862 account(1),863 account(2)864 )),865 1023866 );867868 // Account 2 transfers 100 pieces of RFT 1 from account 1 to account 3869 assert_ok!(Unique::transfer_from(870 origin2,871 account(1),872 account(3),873 CollectionId(1),874 TokenId(1),875 100876 ));877 assert_eq!(878 <pallet_refungible::AccountBalance<Test>>::get((collection_id, account(1))),879 1880 );881 assert_eq!(882 <pallet_refungible::AccountBalance<Test>>::get((collection_id, account(3))),883 1884 );885 assert_eq!(886 <pallet_refungible::Balance<Test>>::get((collection_id, TokenId(1), account(1))),887 923888 );889 assert_eq!(890 <pallet_refungible::Balance<Test>>::get((collection_id, TokenId(1), account(3))),891 100892 );893 assert_eq!(894 <pallet_refungible::Owned<Test>>::get((collection_id, account(1), TokenId(1))),895 true896 );897 assert_eq!(898 <pallet_refungible::Owned<Test>>::get((collection_id, account(1), TokenId(1))),899 true900 );901 assert_eq!(902 <pallet_refungible::Allowance<Test>>::get((903 CollectionId(1),904 TokenId(1),905 account(1),906 account(2)907 )),908 923909 );910 });911}912913#[test]914fn fungible_approve_and_transfer_from() {915 new_test_ext().execute_with(|| {916 let collection_id = create_test_collection(&CollectionMode::Fungible(3), CollectionId(1));917918 let data = default_fungible_data();919 create_test_item(collection_id, &data.into());920921 let origin1 = Origin::signed(1);922 let origin2 = Origin::signed(2);923924 assert_ok!(Unique::set_collection_permissions(925 origin1.clone(),926 CollectionId(1),927 CollectionPermissions {928 mint_mode: Some(true),929 access: Some(AccessMode::AllowList),930 nesting: None,931 }932 ));933 assert_ok!(Unique::add_to_allow_list(934 origin1.clone(),935 CollectionId(1),936 account(1)937 ));938 assert_ok!(Unique::add_to_allow_list(939 origin1.clone(),940 CollectionId(1),941 account(2)942 ));943 assert_ok!(Unique::add_to_allow_list(944 origin1.clone(),945 CollectionId(1),946 account(3)947 ));948949 // do approve950 assert_ok!(Unique::approve(951 origin1.clone(),952 account(2),953 CollectionId(1),954 TokenId(0),955 5956 ));957 assert_eq!(958 <pallet_fungible::Allowance<Test>>::get((CollectionId(1), account(1), account(2))),959 5960 );961 assert_ok!(Unique::approve(962 origin1,963 account(3),964 CollectionId(1),965 TokenId(0),966 5967 ));968 assert_eq!(969 <pallet_fungible::Allowance<Test>>::get((CollectionId(1), account(1), account(2))),970 5971 );972 assert_eq!(973 <pallet_fungible::Allowance<Test>>::get((CollectionId(1), account(1), account(3))),974 5975 );976977 assert_ok!(Unique::transfer_from(978 origin2.clone(),979 account(1),980 account(3),981 CollectionId(1),982 TokenId(0),983 4984 ));985986 assert_eq!(987 <pallet_fungible::Allowance<Test>>::get((CollectionId(1), account(1), account(2))),988 1989 );990991 assert_noop!(992 Unique::transfer_from(993 origin2,994 account(1),995 account(3),996 CollectionId(1),997 TokenId(0),998 4999 )1000 .map_err(|e| e.error),1001 CommonError::<Test>::ApprovedValueTooLow1002 );1003 });1004}10051006#[test]1007fn change_collection_owner() {1008 new_test_ext().execute_with(|| {1009 let collection_id = create_test_collection(&CollectionMode::NFT, CollectionId(1));10101011 let origin1 = Origin::signed(1);1012 assert_ok!(Unique::change_collection_owner(origin1, collection_id, 2));1013 assert_eq!(1014 <pallet_common::CollectionById<Test>>::get(collection_id)1015 .unwrap()1016 .owner,1017 21018 );1019 });1020}10211022#[test]1023fn destroy_collection() {1024 new_test_ext().execute_with(|| {1025 let collection_id = create_test_collection(&CollectionMode::NFT, CollectionId(1));10261027 let origin1 = Origin::signed(1);1028 assert_ok!(Unique::destroy_collection(origin1, collection_id));1029 });1030}10311032#[test]1033fn burn_nft_item() {1034 new_test_ext().execute_with(|| {1035 let collection_id = create_test_collection(&CollectionMode::NFT, CollectionId(1));10361037 let origin1 = Origin::signed(1);10381039 let data = default_nft_data();1040 create_test_item(collection_id, &data.into());10411042 // check balance (collection with id = 1, user id = 1)1043 assert_eq!(1044 <pallet_nonfungible::AccountBalance<Test>>::get((collection_id, account(1))),1045 11046 );10471048 // burn item1049 assert_ok!(Unique::burn_item(1050 origin1.clone(),1051 collection_id,1052 TokenId(1),1053 11054 ));1055 assert_eq!(1056 <pallet_nonfungible::AccountBalance<Test>>::get((collection_id, account(1))),1057 01058 );1059 });1060}10611062#[test]1063fn burn_same_nft_item_twice() {1064 new_test_ext().execute_with(|| {1065 let collection_id = create_test_collection(&CollectionMode::NFT, CollectionId(1));10661067 let origin1 = Origin::signed(1);10681069 let data = default_nft_data();1070 create_test_item(collection_id, &data.into());10711072 // check balance (collection with id = 1, user id = 1)1073 assert_eq!(1074 <pallet_nonfungible::AccountBalance<Test>>::get((collection_id, account(1))),1075 11076 );10771078 // burn item1079 assert_ok!(Unique::burn_item(1080 origin1.clone(),1081 collection_id,1082 TokenId(1),1083 11084 ));10851086 // burn item again1087 assert_noop!(1088 Unique::burn_item(origin1, collection_id, TokenId(1), 1).map_err(|e| e.error),1089 CommonError::<Test>::TokenNotFound1090 );10911092 assert_eq!(1093 <pallet_nonfungible::AccountBalance<Test>>::get((collection_id, account(1))),1094 01095 );1096 });1097}10981099#[test]1100fn burn_fungible_item() {1101 new_test_ext().execute_with(|| {1102 let collection_id = create_test_collection(&CollectionMode::Fungible(3), CollectionId(1));11031104 let origin1 = Origin::signed(1);1105 assert_ok!(Unique::add_collection_admin(1106 origin1.clone(),1107 collection_id,1108 account(2)1109 ));11101111 let data = default_fungible_data();1112 create_test_item(collection_id, &data.into());11131114 // check balance (collection with id = 1, user id = 1)1115 assert_eq!(1116 <pallet_fungible::Balance<Test>>::get((collection_id, account(1))),1117 51118 );11191120 // burn item1121 assert_ok!(Unique::burn_item(1122 origin1.clone(),1123 CollectionId(1),1124 TokenId(0),1125 51126 ));1127 assert_noop!(1128 Unique::burn_item(origin1, CollectionId(1), TokenId(0), 5).map_err(|e| e.error),1129 CommonError::<Test>::TokenValueTooLow1130 );11311132 assert_eq!(1133 <pallet_fungible::Balance<Test>>::get((collection_id, account(1))),1134 01135 );1136 });1137}11381139#[test]1140fn burn_fungible_item_with_token_id() {1141 new_test_ext().execute_with(|| {1142 let collection_id = create_test_collection(&CollectionMode::Fungible(3), CollectionId(1));11431144 let origin1 = Origin::signed(1);1145 assert_ok!(Unique::add_collection_admin(1146 origin1.clone(),1147 collection_id,1148 account(2)1149 ));11501151 let data = default_fungible_data();1152 create_test_item(collection_id, &data.into());11531154 // check balance (collection with id = 1, user id = 1)1155 assert_eq!(1156 <pallet_fungible::Balance<Test>>::get((collection_id, account(1))),1157 51158 );11591160 // Try to burn item using Token ID1161 assert_noop!(1162 Unique::burn_item(origin1, CollectionId(1), TokenId(1), 5).map_err(|e| e.error),1163 <pallet_fungible::Error::<Test>>::FungibleItemsHaveNoId1164 );1165 });1166}1167#[test]1168fn burn_refungible_item() {1169 new_test_ext().execute_with(|| {1170 let collection_id = create_test_collection(&CollectionMode::ReFungible, CollectionId(1));1171 let origin1 = Origin::signed(1);11721173 assert_ok!(Unique::set_collection_permissions(1174 origin1.clone(),1175 collection_id,1176 CollectionPermissions {1177 mint_mode: Some(true),1178 access: Some(AccessMode::AllowList),1179 nesting: None,1180 }1181 ));1182 assert_ok!(Unique::add_to_allow_list(1183 origin1.clone(),1184 collection_id,1185 account(1)1186 ));11871188 assert_ok!(Unique::add_collection_admin(1189 origin1.clone(),1190 collection_id,1191 account(2)1192 ));11931194 let data = default_re_fungible_data();1195 create_test_item(collection_id, &data.into());11961197 // check balance (collection with id = 1, user id = 2)1198 assert_eq!(1199 <pallet_refungible::AccountBalance<Test>>::get((collection_id, account(1))),1200 11201 );1202 assert_eq!(1203 <pallet_refungible::Balance<Test>>::get((collection_id, TokenId(1), account(1))),1204 10231205 );12061207 // burn item1208 assert_ok!(Unique::burn_item(1209 origin1.clone(),1210 collection_id,1211 TokenId(1),1212 10231213 ));1214 assert_noop!(1215 Unique::burn_item(origin1, collection_id, TokenId(1), 1023).map_err(|e| e.error),1216 CommonError::<Test>::TokenValueTooLow1217 );12181219 assert_eq!(1220 <pallet_refungible::Balance<Test>>::get((collection_id, TokenId(1), account(1))),1221 01222 );1223 });1224}12251226#[test]1227fn add_collection_admin() {1228 new_test_ext().execute_with(|| {1229 let collection1_id =1230 create_test_collection_for_owner(&CollectionMode::NFT, 1, CollectionId(1));1231 let origin1 = Origin::signed(1);12321233 // Add collection admins1234 assert_ok!(Unique::add_collection_admin(1235 origin1.clone(),1236 collection1_id,1237 account(2)1238 ));1239 assert_ok!(Unique::add_collection_admin(1240 origin1,1241 collection1_id,1242 account(3)1243 ));12441245 // Owner is not an admin by default1246 assert_eq!(1247 <pallet_common::IsAdmin<Test>>::get((CollectionId(1), account(1))),1248 false1249 );1250 assert!(<pallet_common::IsAdmin<Test>>::get((1251 CollectionId(1),1252 account(2)1253 )));1254 assert!(<pallet_common::IsAdmin<Test>>::get((1255 CollectionId(1),1256 account(3)1257 )));1258 });1259}12601261#[test]1262fn remove_collection_admin() {1263 new_test_ext().execute_with(|| {1264 let collection1_id =1265 create_test_collection_for_owner(&CollectionMode::NFT, 1, CollectionId(1));1266 let origin1 = Origin::signed(1);1267 let origin2 = Origin::signed(2);12681269 // Add collection admins 2 and 31270 assert_ok!(Unique::add_collection_admin(1271 origin1.clone(),1272 collection1_id,1273 account(2)1274 ));1275 assert_ok!(Unique::add_collection_admin(1276 origin1,1277 collection1_id,1278 account(3)1279 ));12801281 assert!(<pallet_common::IsAdmin<Test>>::get((1282 CollectionId(1),1283 account(2)1284 )));1285 assert!(<pallet_common::IsAdmin<Test>>::get((1286 CollectionId(1),1287 account(3)1288 )));12891290 // remove admin 31291 assert_ok!(Unique::remove_collection_admin(1292 origin2,1293 CollectionId(1),1294 account(3)1295 ));12961297 // 2 is still admin, 3 is not an admin anymore1298 assert!(<pallet_common::IsAdmin<Test>>::get((1299 CollectionId(1),1300 account(2)1301 )));1302 assert_eq!(1303 <pallet_common::IsAdmin<Test>>::get((CollectionId(1), account(3))),1304 false1305 );1306 });1307}13081309#[test]1310fn balance_of() {1311 new_test_ext().execute_with(|| {1312 let nft_collection_id = create_test_collection(&CollectionMode::NFT, CollectionId(1));1313 let fungible_collection_id =1314 create_test_collection(&CollectionMode::Fungible(3), CollectionId(2));1315 let re_fungible_collection_id =1316 create_test_collection(&CollectionMode::ReFungible, CollectionId(3));13171318 // check balance before1319 assert_eq!(1320 <pallet_nonfungible::AccountBalance<Test>>::get((nft_collection_id, account(1))),1321 01322 );1323 assert_eq!(1324 <pallet_fungible::Balance<Test>>::get((fungible_collection_id, account(1))),1325 01326 );1327 assert_eq!(1328 <pallet_refungible::AccountBalance<Test>>::get((re_fungible_collection_id, account(1))),1329 01330 );13311332 let nft_data = default_nft_data();1333 create_test_item(nft_collection_id, &nft_data.into());13341335 let fungible_data = default_fungible_data();1336 create_test_item(fungible_collection_id, &fungible_data.into());13371338 let re_fungible_data = default_re_fungible_data();1339 create_test_item(re_fungible_collection_id, &re_fungible_data.into());13401341 // check balance (collection with id = 1, user id = 1)1342 assert_eq!(1343 <pallet_nonfungible::AccountBalance<Test>>::get((nft_collection_id, account(1))),1344 11345 );1346 assert_eq!(1347 <pallet_fungible::Balance<Test>>::get((fungible_collection_id, account(1))),1348 51349 );1350 assert_eq!(1351 <pallet_refungible::AccountBalance<Test>>::get((re_fungible_collection_id, account(1))),1352 11353 );13541355 assert_eq!(1356 <pallet_nonfungible::Owned<Test>>::get((nft_collection_id, account(1), TokenId(1))),1357 true1358 );1359 assert_eq!(1360 <pallet_refungible::Owned<Test>>::get((1361 re_fungible_collection_id,1362 account(1),1363 TokenId(1)1364 )),1365 true1366 );1367 });1368}13691370#[test]1371fn approve() {1372 new_test_ext().execute_with(|| {1373 let collection_id = create_test_collection(&CollectionMode::NFT, CollectionId(1));13741375 let data = default_nft_data();1376 create_test_item(collection_id, &data.into());13771378 let origin1 = Origin::signed(1);13791380 // approve1381 assert_ok!(Unique::approve(1382 origin1,1383 account(2),1384 CollectionId(1),1385 TokenId(1),1386 11387 ));1388 assert_eq!(1389 <pallet_nonfungible::Allowance<Test>>::get((CollectionId(1), TokenId(1))).unwrap(),1390 account(2)1391 );1392 });1393}13941395#[test]1396fn transfer_from() {1397 new_test_ext().execute_with(|| {1398 let collection_id = create_test_collection(&CollectionMode::NFT, CollectionId(1));1399 let origin1 = Origin::signed(1);1400 let origin2 = Origin::signed(2);14011402 let data = default_nft_data();1403 create_test_item(collection_id, &data.into());14041405 // approve1406 assert_ok!(Unique::approve(1407 origin1.clone(),1408 account(2),1409 CollectionId(1),1410 TokenId(1),1411 11412 ));1413 assert_eq!(1414 <pallet_nonfungible::Allowance<Test>>::get((CollectionId(1), TokenId(1))).unwrap(),1415 account(2)1416 );14171418 assert_ok!(Unique::set_collection_permissions(1419 origin1.clone(),1420 CollectionId(1),1421 CollectionPermissions {1422 mint_mode: Some(true),1423 access: Some(AccessMode::AllowList),1424 nesting: None,1425 }1426 ));1427 assert_ok!(Unique::add_to_allow_list(1428 origin1.clone(),1429 CollectionId(1),1430 account(1)1431 ));1432 assert_ok!(Unique::add_to_allow_list(1433 origin1.clone(),1434 CollectionId(1),1435 account(2)1436 ));1437 assert_ok!(Unique::add_to_allow_list(1438 origin1,1439 CollectionId(1),1440 account(3)1441 ));14421443 assert_ok!(Unique::transfer_from(1444 origin2,1445 account(1),1446 account(2),1447 CollectionId(1),1448 TokenId(1),1449 11450 ));14511452 // after transfer1453 assert_eq!(1454 <pallet_nonfungible::AccountBalance<Test>>::get((CollectionId(1), account(1))),1455 01456 );1457 assert_eq!(1458 <pallet_nonfungible::AccountBalance<Test>>::get((CollectionId(1), account(2))),1459 11460 );1461 });1462}14631464// #endregion14651466// Coverage tests region1467// #region14681469#[test]1470fn owner_can_add_address_to_allow_list() {1471 new_test_ext().execute_with(|| {1472 let collection_id = create_test_collection(&CollectionMode::NFT, CollectionId(1));14731474 let origin1 = Origin::signed(1);1475 assert_ok!(Unique::add_to_allow_list(1476 origin1,1477 collection_id,1478 account(2)1479 ));1480 assert!(<pallet_common::Allowlist<Test>>::get((1481 collection_id,1482 account(2)1483 )));1484 });1485}14861487#[test]1488fn admin_can_add_address_to_allow_list() {1489 new_test_ext().execute_with(|| {1490 let collection_id = create_test_collection(&CollectionMode::NFT, CollectionId(1));1491 let origin1 = Origin::signed(1);1492 let origin2 = Origin::signed(2);14931494 assert_ok!(Unique::add_collection_admin(1495 origin1,1496 collection_id,1497 account(2)1498 ));1499 assert_ok!(Unique::add_to_allow_list(1500 origin2,1501 collection_id,1502 account(3)1503 ));1504 assert!(<pallet_common::Allowlist<Test>>::get((1505 collection_id,1506 account(3)1507 )));1508 });1509}15101511#[test]1512fn nonprivileged_user_cannot_add_address_to_allow_list() {1513 new_test_ext().execute_with(|| {1514 let collection_id = create_test_collection(&CollectionMode::NFT, CollectionId(1));15151516 let origin2 = Origin::signed(2);1517 assert_noop!(1518 Unique::add_to_allow_list(origin2, collection_id, account(3)),1519 CommonError::<Test>::NoPermission1520 );1521 });1522}15231524#[test]1525fn nobody_can_add_address_to_allow_list_of_nonexisting_collection() {1526 new_test_ext().execute_with(|| {1527 let origin1 = Origin::signed(1);15281529 assert_noop!(1530 Unique::add_to_allow_list(origin1, CollectionId(1), account(2)),1531 CommonError::<Test>::CollectionNotFound1532 );1533 });1534}15351536#[test]1537fn nobody_can_add_address_to_allow_list_of_deleted_collection() {1538 new_test_ext().execute_with(|| {1539 let collection_id = create_test_collection(&CollectionMode::NFT, CollectionId(1));15401541 let origin1 = Origin::signed(1);1542 assert_ok!(Unique::destroy_collection(origin1.clone(), collection_id));1543 assert_noop!(1544 Unique::add_to_allow_list(origin1, collection_id, account(2)),1545 CommonError::<Test>::CollectionNotFound1546 );1547 });1548}15491550// If address is already added to allow list, nothing happens1551#[test]1552fn address_is_already_added_to_allow_list() {1553 new_test_ext().execute_with(|| {1554 let collection_id = create_test_collection(&CollectionMode::NFT, CollectionId(1));1555 let origin1 = Origin::signed(1);15561557 assert_ok!(Unique::add_to_allow_list(1558 origin1.clone(),1559 collection_id,1560 account(2)1561 ));1562 assert_ok!(Unique::add_to_allow_list(1563 origin1,1564 collection_id,1565 account(2)1566 ));1567 assert!(<pallet_common::Allowlist<Test>>::get((1568 collection_id,1569 account(2)1570 )));1571 });1572}15731574#[test]1575fn owner_can_remove_address_from_allow_list() {1576 new_test_ext().execute_with(|| {1577 let collection_id = create_test_collection(&CollectionMode::NFT, CollectionId(1));15781579 let origin1 = Origin::signed(1);1580 assert_ok!(Unique::add_to_allow_list(1581 origin1.clone(),1582 collection_id,1583 account(2)1584 ));1585 assert_ok!(Unique::remove_from_allow_list(1586 origin1,1587 collection_id,1588 account(2)1589 ));1590 assert_eq!(1591 <pallet_common::Allowlist<Test>>::get((collection_id, account(2))),1592 false1593 );1594 });1595}15961597#[test]1598fn admin_can_remove_address_from_allow_list() {1599 new_test_ext().execute_with(|| {1600 let collection_id = create_test_collection(&CollectionMode::NFT, CollectionId(1));1601 let origin1 = Origin::signed(1);1602 let origin2 = Origin::signed(2);16031604 // Owner adds admin1605 assert_ok!(Unique::add_collection_admin(1606 origin1.clone(),1607 collection_id,1608 account(2)1609 ));16101611 // Owner adds address 3 to allow list1612 assert_ok!(Unique::add_to_allow_list(1613 origin1,1614 collection_id,1615 account(3)1616 ));16171618 // Admin removes address 3 from allow list1619 assert_ok!(Unique::remove_from_allow_list(1620 origin2,1621 collection_id,1622 account(3)1623 ));1624 assert_eq!(1625 <pallet_common::Allowlist<Test>>::get((collection_id, account(3))),1626 false1627 );1628 });1629}16301631#[test]1632fn nonprivileged_user_cannot_remove_address_from_allow_list() {1633 new_test_ext().execute_with(|| {1634 let collection_id = create_test_collection(&CollectionMode::NFT, CollectionId(1));1635 let origin1 = Origin::signed(1);1636 let origin2 = Origin::signed(2);16371638 assert_ok!(Unique::add_to_allow_list(1639 origin1,1640 collection_id,1641 account(2)1642 ));1643 assert_noop!(1644 Unique::remove_from_allow_list(origin2, collection_id, account(2)),1645 CommonError::<Test>::NoPermission1646 );1647 assert!(<pallet_common::Allowlist<Test>>::get((1648 collection_id,1649 account(2)1650 )));1651 });1652}16531654#[test]1655fn nobody_can_remove_address_from_allow_list_of_nonexisting_collection() {1656 new_test_ext().execute_with(|| {1657 let origin1 = Origin::signed(1);16581659 assert_noop!(1660 Unique::remove_from_allow_list(origin1, CollectionId(1), account(2)),1661 CommonError::<Test>::CollectionNotFound1662 );1663 });1664}16651666#[test]1667fn nobody_can_remove_address_from_allow_list_of_deleted_collection() {1668 new_test_ext().execute_with(|| {1669 let collection_id = create_test_collection(&CollectionMode::NFT, CollectionId(1));1670 let origin1 = Origin::signed(1);1671 let origin2 = Origin::signed(2);16721673 // Add account 2 to allow list1674 assert_ok!(Unique::add_to_allow_list(1675 origin1.clone(),1676 collection_id,1677 account(2)1678 ));16791680 // Account 2 is in collection allow-list1681 assert!(<pallet_common::Allowlist<Test>>::get((1682 collection_id,1683 account(2)1684 )));16851686 // Destroy collection1687 assert_ok!(Unique::destroy_collection(origin1, collection_id));16881689 // Attempt to remove account 2 from collection allow-list => error1690 assert_noop!(1691 Unique::remove_from_allow_list(origin2, collection_id, account(2)),1692 CommonError::<Test>::CollectionNotFound1693 );16941695 // Account 2 is not found in collection allow-list anyway1696 assert_eq!(1697 <pallet_common::Allowlist<Test>>::get((collection_id, account(2))),1698 false1699 );1700 });1701}17021703// If address is already removed from allow list, nothing happens1704#[test]1705fn address_is_already_removed_from_allow_list() {1706 new_test_ext().execute_with(|| {1707 let collection_id = create_test_collection(&CollectionMode::NFT, CollectionId(1));1708 let origin1 = Origin::signed(1);17091710 assert_ok!(Unique::add_to_allow_list(1711 origin1.clone(),1712 collection_id,1713 account(2)1714 ));1715 assert_ok!(Unique::remove_from_allow_list(1716 origin1.clone(),1717 collection_id,1718 account(2)1719 ));1720 assert_eq!(1721 <pallet_common::Allowlist<Test>>::get((collection_id, account(2))),1722 false1723 );1724 assert_ok!(Unique::remove_from_allow_list(1725 origin1,1726 collection_id,1727 account(2)1728 ));1729 assert_eq!(1730 <pallet_common::Allowlist<Test>>::get((collection_id, account(2))),1731 false1732 );1733 });1734}17351736// If Public Access mode is set to AllowList, tokens can’t be transferred from a non-allowlisted address with transfer or transferFrom (2 tests)1737#[test]1738fn allow_list_test_1() {1739 new_test_ext().execute_with(|| {1740 let collection_id = create_test_collection(&CollectionMode::NFT, CollectionId(1));17411742 let origin1 = Origin::signed(1);17431744 let data = default_nft_data();1745 create_test_item(collection_id, &data.into());17461747 assert_ok!(Unique::set_collection_permissions(1748 origin1.clone(),1749 collection_id,1750 CollectionPermissions {1751 mint_mode: None,1752 access: Some(AccessMode::AllowList),1753 nesting: None,1754 }1755 ));1756 assert_ok!(Unique::add_to_allow_list(1757 origin1.clone(),1758 collection_id,1759 account(2)1760 ));17611762 assert_noop!(1763 Unique::transfer(origin1, account(3), CollectionId(1), TokenId(1), 1)1764 .map_err(|e| e.error),1765 CommonError::<Test>::AddressNotInAllowlist1766 );1767 });1768}17691770#[test]1771fn allow_list_test_2() {1772 new_test_ext().execute_with(|| {1773 let collection_id = create_test_collection(&CollectionMode::NFT, CollectionId(1));1774 let origin1 = Origin::signed(1);17751776 let data = default_nft_data();1777 create_test_item(collection_id, &data.into());17781779 assert_ok!(Unique::set_collection_permissions(1780 origin1.clone(),1781 collection_id,1782 CollectionPermissions {1783 mint_mode: None,1784 access: Some(AccessMode::AllowList),1785 nesting: None,1786 }1787 ));1788 assert_ok!(Unique::add_to_allow_list(1789 origin1.clone(),1790 collection_id,1791 account(1)1792 ));1793 assert_ok!(Unique::add_to_allow_list(1794 origin1.clone(),1795 collection_id,1796 account(2)1797 ));17981799 // do approve1800 assert_ok!(Unique::approve(1801 origin1.clone(),1802 account(1),1803 collection_id,1804 TokenId(1),1805 11806 ));1807 assert_eq!(1808 <pallet_nonfungible::Allowance<Test>>::get((CollectionId(1), TokenId(1))).unwrap(),1809 account(1)1810 );18111812 assert_ok!(Unique::remove_from_allow_list(1813 origin1.clone(),1814 collection_id,1815 account(1)1816 ));18171818 assert_noop!(1819 Unique::transfer_from(1820 origin1,1821 account(1),1822 account(3),1823 CollectionId(1),1824 TokenId(1),1825 11826 )1827 .map_err(|e| e.error),1828 CommonError::<Test>::AddressNotInAllowlist1829 );1830 });1831}18321833// If Public Access mode is set to AllowList, tokens can’t be transferred to a non-allowlisted address with transfer or transferFrom (2 tests)1834#[test]1835fn allow_list_test_3() {1836 new_test_ext().execute_with(|| {1837 let collection_id = create_test_collection(&CollectionMode::NFT, CollectionId(1));18381839 let origin1 = Origin::signed(1);18401841 let data = default_nft_data();1842 create_test_item(collection_id, &data.into());18431844 assert_ok!(Unique::set_collection_permissions(1845 origin1.clone(),1846 collection_id,1847 CollectionPermissions {1848 mint_mode: None,1849 access: Some(AccessMode::AllowList),1850 nesting: None,1851 }1852 ));1853 assert_ok!(Unique::add_to_allow_list(1854 origin1.clone(),1855 collection_id,1856 account(1)1857 ));18581859 assert_noop!(1860 Unique::transfer(origin1, account(3), collection_id, TokenId(1), 1)1861 .map_err(|e| e.error),1862 CommonError::<Test>::AddressNotInAllowlist1863 );1864 });1865}18661867#[test]1868fn allow_list_test_4() {1869 new_test_ext().execute_with(|| {1870 let collection_id = create_test_collection(&CollectionMode::NFT, CollectionId(1));18711872 let origin1 = Origin::signed(1);18731874 let data = default_nft_data();1875 create_test_item(collection_id, &data.into());18761877 assert_ok!(Unique::set_collection_permissions(1878 origin1.clone(),1879 collection_id,1880 CollectionPermissions {1881 mint_mode: None,1882 access: Some(AccessMode::AllowList),1883 nesting: None,1884 }1885 ));1886 assert_ok!(Unique::add_to_allow_list(1887 origin1.clone(),1888 collection_id,1889 account(1)1890 ));1891 assert_ok!(Unique::add_to_allow_list(1892 origin1.clone(),1893 collection_id,1894 account(2)1895 ));18961897 // do approve1898 assert_ok!(Unique::approve(1899 origin1.clone(),1900 account(1),1901 collection_id,1902 TokenId(1),1903 11904 ));1905 assert_eq!(1906 <pallet_nonfungible::Allowance<Test>>::get((CollectionId(1), TokenId(1))).unwrap(),1907 account(1)1908 );19091910 assert_ok!(Unique::remove_from_allow_list(1911 origin1.clone(),1912 collection_id,1913 account(2)1914 ));19151916 assert_noop!(1917 Unique::transfer_from(1918 origin1,1919 account(1),1920 account(3),1921 collection_id,1922 TokenId(1),1923 11924 )1925 .map_err(|e| e.error),1926 CommonError::<Test>::AddressNotInAllowlist1927 );1928 });1929}19301931// If Public Access mode is set to AllowList, tokens can’t be destroyed by a non-allowlisted address (even if it owned them before enabling AllowList mode)1932#[test]1933fn allow_list_test_5() {1934 new_test_ext().execute_with(|| {1935 let collection_id = create_test_collection(&CollectionMode::NFT, CollectionId(1));19361937 let origin1 = Origin::signed(1);19381939 let data = default_nft_data();1940 create_test_item(collection_id, &data.into());19411942 assert_ok!(Unique::set_collection_permissions(1943 origin1.clone(),1944 collection_id,1945 CollectionPermissions {1946 mint_mode: None,1947 access: Some(AccessMode::AllowList),1948 nesting: None,1949 }1950 ));1951 assert_noop!(1952 Unique::burn_item(origin1.clone(), CollectionId(1), TokenId(1), 1).map_err(|e| e.error),1953 CommonError::<Test>::AddressNotInAllowlist1954 );1955 });1956}19571958// If Public Access mode is set to AllowList, token transfers can’t be Approved by a non-allowlisted address (see Approve method).1959#[test]1960fn allow_list_test_6() {1961 new_test_ext().execute_with(|| {1962 let collection_id = create_test_collection(&CollectionMode::NFT, CollectionId(1));19631964 let origin1 = Origin::signed(1);19651966 let data = default_nft_data();1967 create_test_item(collection_id, &data.into());19681969 assert_ok!(Unique::set_collection_permissions(1970 origin1.clone(),1971 collection_id,1972 CollectionPermissions {1973 mint_mode: None,1974 access: Some(AccessMode::AllowList),1975 nesting: None,1976 }1977 ));19781979 // do approve1980 assert_noop!(1981 Unique::approve(origin1, account(1), CollectionId(1), TokenId(1), 1)1982 .map_err(|e| e.error),1983 CommonError::<Test>::AddressNotInAllowlist1984 );1985 });1986}19871988// If Public Access mode is set to AllowList, tokens can be transferred from a allowlisted address with transfer or transferFrom (2 tests) and1989// tokens can be transferred from a allowlisted address with transfer or transferFrom (2 tests)1990#[test]1991fn allow_list_test_7() {1992 new_test_ext().execute_with(|| {1993 let collection_id = create_test_collection(&CollectionMode::NFT, CollectionId(1));19941995 let data = default_nft_data();1996 create_test_item(collection_id, &data.into());19971998 let origin1 = Origin::signed(1);19992000 assert_ok!(Unique::set_collection_permissions(2001 origin1.clone(),2002 collection_id,2003 CollectionPermissions {2004 mint_mode: None,2005 access: Some(AccessMode::AllowList),2006 nesting: None,2007 }2008 ));2009 assert_ok!(Unique::add_to_allow_list(2010 origin1.clone(),2011 collection_id,2012 account(1)2013 ));2014 assert_ok!(Unique::add_to_allow_list(2015 origin1.clone(),2016 collection_id,2017 account(2)2018 ));20192020 assert_ok!(Unique::transfer(2021 origin1,2022 account(2),2023 CollectionId(1),2024 TokenId(1),2025 12026 ));2027 });2028}20292030#[test]2031fn allow_list_test_8() {2032 new_test_ext().execute_with(|| {2033 let collection_id = create_test_collection(&CollectionMode::NFT, CollectionId(1));20342035 // Create NFT for account 12036 let data = default_nft_data();2037 create_test_item(collection_id, &data.into());20382039 let origin1 = Origin::signed(1);20402041 // Toggle Allow List mode and add accounts 1 and 22042 assert_ok!(Unique::set_collection_permissions(2043 origin1.clone(),2044 collection_id,2045 CollectionPermissions {2046 mint_mode: None,2047 access: Some(AccessMode::AllowList),2048 nesting: None,2049 }2050 ));2051 assert_ok!(Unique::add_to_allow_list(2052 origin1.clone(),2053 collection_id,2054 account(1)2055 ));2056 assert_ok!(Unique::add_to_allow_list(2057 origin1.clone(),2058 collection_id,2059 account(2)2060 ));20612062 // Sself-approve account 1 for NFT 12063 assert_ok!(Unique::approve(2064 origin1.clone(),2065 account(1),2066 CollectionId(1),2067 TokenId(1),2068 12069 ));2070 assert_eq!(2071 <pallet_nonfungible::Allowance<Test>>::get((CollectionId(1), TokenId(1))).unwrap(),2072 account(1)2073 );20742075 // Transfer from 1 to 22076 assert_ok!(Unique::transfer_from(2077 origin1,2078 account(1),2079 account(2),2080 CollectionId(1),2081 TokenId(1),2082 12083 ));2084 });2085}20862087// If Public Access mode is set to AllowList, and Mint Permission is set to false, tokens can be created by owner.2088#[test]2089fn allow_list_test_9() {2090 new_test_ext().execute_with(|| {2091 let collection_id = create_test_collection(&CollectionMode::NFT, CollectionId(1));2092 let origin1 = Origin::signed(1);20932094 assert_ok!(Unique::set_collection_permissions(2095 origin1.clone(),2096 collection_id,2097 CollectionPermissions {2098 mint_mode: Some(false),2099 access: Some(AccessMode::AllowList),2100 nesting: None,2101 }2102 ));21032104 let data = default_nft_data();2105 create_test_item(collection_id, &data.into());2106 });2107}21082109// If Public Access mode is set to AllowList, and Mint Permission is set to false, tokens can be created by admin.2110#[test]2111fn allow_list_test_10() {2112 new_test_ext().execute_with(|| {2113 let collection_id = create_test_collection(&CollectionMode::NFT, CollectionId(1));21142115 let origin1 = Origin::signed(1);2116 let origin2 = Origin::signed(2);21172118 assert_ok!(Unique::set_collection_permissions(2119 origin1.clone(),2120 collection_id,2121 CollectionPermissions {2122 mint_mode: Some(false),2123 access: Some(AccessMode::AllowList),2124 nesting: None,2125 }2126 ));21272128 assert_ok!(Unique::add_collection_admin(2129 origin1,2130 collection_id,2131 account(2)2132 ));21332134 assert_ok!(Unique::create_item(2135 origin2,2136 collection_id,2137 account(2),2138 default_nft_data().into()2139 ));2140 });2141}21422143// If Public Access mode is set to AllowList, and Mint Permission is set to false, tokens cannot be created by non-privileged and allow listed address.2144#[test]2145fn allow_list_test_11() {2146 new_test_ext().execute_with(|| {2147 let collection_id = create_test_collection(&CollectionMode::NFT, CollectionId(1));21482149 let origin1 = Origin::signed(1);2150 let origin2 = Origin::signed(2);21512152 assert_ok!(Unique::set_collection_permissions(2153 origin1.clone(),2154 collection_id,2155 CollectionPermissions {2156 mint_mode: Some(false),2157 access: Some(AccessMode::AllowList),2158 nesting: None,2159 }2160 ));2161 assert_ok!(Unique::add_to_allow_list(2162 origin1,2163 collection_id,2164 account(2)2165 ));21662167 assert_noop!(2168 Unique::create_item(2169 origin2,2170 CollectionId(1),2171 account(2),2172 default_nft_data().into()2173 )2174 .map_err(|e| e.error),2175 CommonError::<Test>::PublicMintingNotAllowed2176 );2177 });2178}21792180// If Public Access mode is set to AllowList, and Mint Permission is set to false, tokens cannot be created by non-privileged and non-allow listed address.2181#[test]2182fn allow_list_test_12() {2183 new_test_ext().execute_with(|| {2184 let collection_id = create_test_collection(&CollectionMode::NFT, CollectionId(1));21852186 let origin1 = Origin::signed(1);2187 let origin2 = Origin::signed(2);21882189 assert_ok!(Unique::set_collection_permissions(2190 origin1.clone(),2191 collection_id,2192 CollectionPermissions {2193 mint_mode: Some(false),2194 access: Some(AccessMode::AllowList),2195 nesting: None,2196 }2197 ));21982199 assert_noop!(2200 Unique::create_item(2201 origin2,2202 CollectionId(1),2203 account(2),2204 default_nft_data().into()2205 )2206 .map_err(|e| e.error),2207 CommonError::<Test>::PublicMintingNotAllowed2208 );2209 });2210}22112212// If Public Access mode is set to AllowList, and Mint Permission is set to true, tokens can be created by owner.2213#[test]2214fn allow_list_test_13() {2215 new_test_ext().execute_with(|| {2216 let collection_id = create_test_collection(&CollectionMode::NFT, CollectionId(1));22172218 let origin1 = Origin::signed(1);22192220 assert_ok!(Unique::set_collection_permissions(2221 origin1.clone(),2222 collection_id,2223 CollectionPermissions {2224 mint_mode: Some(true),2225 access: Some(AccessMode::AllowList),2226 nesting: None,2227 }2228 ));22292230 let data = default_nft_data();2231 create_test_item(collection_id, &data.into());2232 });2233}22342235// If Public Access mode is set to AllowList, and Mint Permission is set to true, tokens can be created by admin.2236#[test]2237fn allow_list_test_14() {2238 new_test_ext().execute_with(|| {2239 let collection_id = create_test_collection(&CollectionMode::NFT, CollectionId(1));22402241 let origin1 = Origin::signed(1);2242 let origin2 = Origin::signed(2);22432244 assert_ok!(Unique::set_collection_permissions(2245 origin1.clone(),2246 collection_id,2247 CollectionPermissions {2248 mint_mode: Some(true),2249 access: Some(AccessMode::AllowList),2250 nesting: None,2251 }2252 ));22532254 assert_ok!(Unique::add_collection_admin(2255 origin1,2256 collection_id,2257 account(2)2258 ));22592260 assert_ok!(Unique::create_item(2261 origin2,2262 collection_id,2263 account(2),2264 default_nft_data().into()2265 ));2266 });2267}22682269// If Public Access mode is set to AllowList, and Mint Permission is set to true, tokens cannot be created by non-privileged and non-allow listed address.2270#[test]2271fn allow_list_test_15() {2272 new_test_ext().execute_with(|| {2273 let collection_id = create_test_collection(&CollectionMode::NFT, CollectionId(1));22742275 let origin1 = Origin::signed(1);2276 let origin2 = Origin::signed(2);22772278 assert_ok!(Unique::set_collection_permissions(2279 origin1.clone(),2280 collection_id,2281 CollectionPermissions {2282 mint_mode: Some(true),2283 access: Some(AccessMode::AllowList),2284 nesting: None,2285 }2286 ));22872288 assert_noop!(2289 Unique::create_item(2290 origin2,2291 collection_id,2292 account(2),2293 default_nft_data().into()2294 )2295 .map_err(|e| e.error),2296 CommonError::<Test>::AddressNotInAllowlist2297 );2298 });2299}23002301// If Public Access mode is set to AllowList, and Mint Permission is set to true, tokens can be created by non-privileged and allow listed address.2302#[test]2303fn allow_list_test_16() {2304 new_test_ext().execute_with(|| {2305 let collection_id = create_test_collection(&CollectionMode::NFT, CollectionId(1));23062307 let origin1 = Origin::signed(1);2308 let origin2 = Origin::signed(2);23092310 assert_ok!(Unique::set_collection_permissions(2311 origin1.clone(),2312 collection_id,2313 CollectionPermissions {2314 mint_mode: Some(true),2315 access: Some(AccessMode::AllowList),2316 nesting: None,2317 }2318 ));2319 assert_ok!(Unique::add_to_allow_list(2320 origin1,2321 collection_id,2322 account(2)2323 ));23242325 assert_ok!(Unique::create_item(2326 origin2,2327 collection_id,2328 account(2),2329 default_nft_data().into()2330 ));2331 });2332}23332334// Total number of collections. Positive test2335#[test]2336fn total_number_collections_bound() {2337 new_test_ext().execute_with(|| {2338 create_test_collection(&CollectionMode::NFT, CollectionId(1));2339 });2340}23412342#[test]2343fn create_max_collections() {2344 new_test_ext().execute_with(|| {2345 for i in 1..COLLECTION_NUMBER_LIMIT {2346 create_test_collection(&CollectionMode::NFT, CollectionId(i));2347 }2348 });2349}23502351// Total number of collections. Negative test2352#[test]2353fn total_number_collections_bound_neg() {2354 new_test_ext().execute_with(|| {2355 let origin1 = Origin::signed(1);23562357 for i in 1..=COLLECTION_NUMBER_LIMIT {2358 create_test_collection(&CollectionMode::NFT, CollectionId(i));2359 }23602361 let col_name1: Vec<u16> = "Test1\0".encode_utf16().collect::<Vec<u16>>();2362 let col_desc1: Vec<u16> = "TestDescription1\0".encode_utf16().collect::<Vec<u16>>();2363 let token_prefix1: Vec<u8> = b"token_prefix1\0".to_vec();23642365 let data: CreateCollectionData<u64> = CreateCollectionData {2366 name: col_name1.try_into().unwrap(),2367 description: col_desc1.try_into().unwrap(),2368 token_prefix: token_prefix1.try_into().unwrap(),2369 mode: CollectionMode::NFT,2370 ..Default::default()2371 };23722373 // 11-th collection in chain. Expects error2374 assert_noop!(2375 Unique::create_collection_ex(origin1, data),2376 CommonError::<Test>::TotalCollectionsLimitExceeded2377 );2378 });2379}23802381// Owned tokens by a single address. Positive test2382#[test]2383fn owned_tokens_bound() {2384 new_test_ext().execute_with(|| {2385 let collection_id = create_test_collection(&CollectionMode::NFT, CollectionId(1));23862387 let data = default_nft_data();2388 create_test_item(collection_id, &data.clone().into());2389 create_test_item(collection_id, &data.into());2390 });2391}23922393// Owned tokens by a single address. Negotive test2394#[test]2395fn owned_tokens_bound_neg() {2396 new_test_ext().execute_with(|| {2397 let collection_id = create_test_collection(&CollectionMode::NFT, CollectionId(1));23982399 let origin1 = Origin::signed(1);24002401 for _ in 1..=MAX_TOKEN_OWNERSHIP {2402 let data = default_nft_data();2403 create_test_item(collection_id, &data.clone().into());2404 }24052406 let data = default_nft_data();2407 assert_noop!(2408 Unique::create_item(origin1, CollectionId(1), account(1), data.into())2409 .map_err(|e| e.error),2410 CommonError::<Test>::AccountTokenLimitExceeded2411 );2412 });2413}24142415// Number of collection admins. Positive test2416#[test]2417fn collection_admins_bound() {2418 new_test_ext().execute_with(|| {2419 let collection_id = create_test_collection(&CollectionMode::NFT, CollectionId(1));24202421 let origin1 = Origin::signed(1);24222423 assert_ok!(Unique::add_collection_admin(2424 origin1.clone(),2425 collection_id,2426 account(2)2427 ));2428 assert_ok!(Unique::add_collection_admin(2429 origin1,2430 collection_id,2431 account(3)2432 ));2433 });2434}24352436// Number of collection admins. Negotive test2437#[test]2438fn collection_admins_bound_neg() {2439 new_test_ext().execute_with(|| {2440 let collection_id = create_test_collection(&CollectionMode::NFT, CollectionId(1));24412442 let origin1 = Origin::signed(1);24432444 for i in 0..COLLECTION_ADMINS_LIMIT {2445 assert_ok!(Unique::add_collection_admin(2446 origin1.clone(),2447 collection_id,2448 account((2 + i).into())2449 ));2450 }2451 assert_noop!(2452 Unique::add_collection_admin(2453 origin1,2454 collection_id,2455 account((3 + COLLECTION_ADMINS_LIMIT).into())2456 ),2457 CommonError::<Test>::CollectionAdminCountExceeded2458 );2459 });2460}2461// #endregion24622463#[test]2464fn collection_transfer_flag_works() {2465 new_test_ext().execute_with(|| {2466 let origin1 = Origin::signed(1);24672468 let collection_id = create_test_collection(&CollectionMode::NFT, CollectionId(1));2469 assert_ok!(Unique::set_transfers_enabled_flag(2470 origin1,2471 collection_id,2472 true2473 ));24742475 let data = default_nft_data();2476 create_test_item(collection_id, &data.into());2477 assert_eq!(2478 <pallet_nonfungible::AccountBalance<Test>>::get((collection_id, account(1))),2479 12480 );2481 assert_eq!(2482 <pallet_nonfungible::Owned<Test>>::get((collection_id, account(1), TokenId(1))),2483 true2484 );24852486 let origin1 = Origin::signed(1);24872488 // default scenario2489 assert_ok!(Unique::transfer(2490 origin1,2491 account(2),2492 collection_id,2493 TokenId(1),2494 12495 ));2496 assert_eq!(2497 <pallet_nonfungible::Owned<Test>>::get((collection_id, account(1), TokenId(1))),2498 false2499 );2500 assert_eq!(2501 <pallet_nonfungible::Owned<Test>>::get((collection_id, account(2), TokenId(1))),2502 true2503 );2504 assert_eq!(2505 <pallet_nonfungible::AccountBalance<Test>>::get((collection_id, account(1))),2506 02507 );2508 assert_eq!(2509 <pallet_nonfungible::AccountBalance<Test>>::get((collection_id, account(2))),2510 12511 );2512 });2513}25142515#[test]2516fn collection_transfer_flag_works_neg() {2517 new_test_ext().execute_with(|| {2518 let origin1 = Origin::signed(1);25192520 let collection_id = create_test_collection(&CollectionMode::NFT, CollectionId(1));2521 assert_ok!(Unique::set_transfers_enabled_flag(2522 origin1,2523 collection_id,2524 false2525 ));25262527 let data = default_nft_data();2528 create_test_item(collection_id, &data.into());2529 assert_eq!(2530 <pallet_nonfungible::AccountBalance<Test>>::get((collection_id, account(1))),2531 12532 );2533 assert_eq!(2534 <pallet_nonfungible::Owned<Test>>::get((collection_id, account(1), TokenId(1))),2535 true2536 );25372538 let origin1 = Origin::signed(1);25392540 // default scenario2541 assert_noop!(2542 Unique::transfer(origin1, account(2), CollectionId(1), TokenId(1), 1)2543 .map_err(|e| e.error),2544 CommonError::<Test>::TransferNotAllowed2545 );2546 assert_eq!(2547 <pallet_nonfungible::AccountBalance<Test>>::get((collection_id, account(1))),2548 12549 );2550 assert_eq!(2551 <pallet_nonfungible::AccountBalance<Test>>::get((collection_id, account(2))),2552 02553 );2554 assert_eq!(2555 <pallet_nonfungible::Owned<Test>>::get((collection_id, account(1), TokenId(1))),2556 true2557 );2558 assert_eq!(2559 <pallet_nonfungible::Owned<Test>>::get((collection_id, account(2), TokenId(1))),2560 false2561 );2562 });2563}25642565#[test]2566fn collection_sponsoring() {2567 new_test_ext().execute_with(|| {2568 // default_limits();2569 let user1 = 1_u64;2570 let user2 = 777_u64;2571 let origin1 = Origin::signed(user1);2572 let origin2 = Origin::signed(user2);2573 let account2 = account(user2);25742575 let collection_id =2576 create_test_collection_for_owner(&CollectionMode::NFT, user1, CollectionId(1));2577 assert_ok!(Unique::set_collection_sponsor(2578 origin1.clone(),2579 collection_id,2580 user12581 ));2582 assert_ok!(Unique::confirm_sponsorship(origin1.clone(), collection_id));25832584 // Expect error while have no permissions2585 assert!(Unique::create_item(2586 origin2.clone(),2587 collection_id,2588 account2.clone(),2589 default_nft_data().into()2590 )2591 .is_err());25922593 assert_ok!(Unique::set_collection_permissions(2594 origin1.clone(),2595 collection_id,2596 CollectionPermissions {2597 mint_mode: Some(true),2598 access: Some(AccessMode::AllowList),2599 nesting: None,2600 }2601 ));2602 assert_ok!(Unique::add_to_allow_list(2603 origin1.clone(),2604 collection_id,2605 account2.clone()2606 ));26072608 assert_ok!(Unique::create_item(2609 origin2,2610 collection_id,2611 account2,2612 default_nft_data().into()2613 ));2614 });2615}tests/src/interfaces/augment-api-query.tsdiffbeforeafterboth--- a/tests/src/interfaces/augment-api-query.ts
+++ b/tests/src/interfaces/augment-api-query.ts
@@ -5,7 +5,7 @@
import type { BTreeMap, Bytes, Option, U256, Vec, bool, u128, u16, u32, u64 } from '@polkadot/types-codec';
import type { AnyNumber, ITuple } from '@polkadot/types-codec/types';
import type { AccountId32, H160, H256 } from '@polkadot/types/interfaces/runtime';
-import type { CumulusPalletDmpQueueConfigData, CumulusPalletDmpQueuePageIndexData, CumulusPalletParachainSystemRelayStateSnapshotMessagingStateSnapshot, CumulusPalletXcmpQueueInboundChannelDetails, CumulusPalletXcmpQueueOutboundChannelDetails, CumulusPalletXcmpQueueQueueConfigData, EthereumBlock, EthereumLog, EthereumReceiptReceiptV3, EthereumTransactionTransactionV2, FpRpcTransactionStatus, FrameSupportWeightsPerDispatchClassU64, FrameSystemAccountInfo, FrameSystemEventRecord, FrameSystemLastRuntimeUpgradeInfo, FrameSystemPhase, OrmlVestingVestingSchedule, PalletBalancesAccountData, PalletBalancesBalanceLock, PalletBalancesReleases, PalletBalancesReserveData, PalletEvmAccountBasicCrossAccountIdRepr, PalletEvmContractHelpersSponsoringModeT, PalletNonfungibleItemData, PalletRefungibleItemData, PalletTransactionPaymentReleases, PalletTreasuryProposal, PhantomTypeUpDataStructs, PolkadotCorePrimitivesOutboundHrmpMessage, PolkadotPrimitivesV2AbridgedHostConfiguration, PolkadotPrimitivesV2PersistedValidationData, PolkadotPrimitivesV2UpgradeRestriction, SpRuntimeDigest, SpTrieStorageProof, UpDataStructsCollection, UpDataStructsCollectionStats, UpDataStructsProperties, UpDataStructsPropertiesMapPropertyPermission, UpDataStructsPropertyPermission } from '@polkadot/types/lookup';
+import type { CumulusPalletDmpQueueConfigData, CumulusPalletDmpQueuePageIndexData, CumulusPalletParachainSystemRelayStateSnapshotMessagingStateSnapshot, CumulusPalletXcmpQueueInboundChannelDetails, CumulusPalletXcmpQueueOutboundChannelDetails, CumulusPalletXcmpQueueQueueConfigData, EthereumBlock, EthereumLog, EthereumReceiptReceiptV3, EthereumTransactionTransactionV2, FpRpcTransactionStatus, FrameSupportWeightsPerDispatchClassU64, FrameSystemAccountInfo, FrameSystemEventRecord, FrameSystemLastRuntimeUpgradeInfo, FrameSystemPhase, OrmlVestingVestingSchedule, PalletBalancesAccountData, PalletBalancesBalanceLock, PalletBalancesReleases, PalletBalancesReserveData, PalletEvmAccountBasicCrossAccountIdRepr, PalletEvmContractHelpersSponsoringModeT, PalletNonfungibleItemData, PalletRefungibleItemData, PalletTransactionPaymentReleases, PalletTreasuryProposal, PhantomTypeUpDataStructs, PolkadotCorePrimitivesOutboundHrmpMessage, PolkadotPrimitivesV2AbridgedHostConfiguration, PolkadotPrimitivesV2PersistedValidationData, PolkadotPrimitivesV2UpgradeRestriction, SpRuntimeDigest, SpTrieStorageProof, UpDataStructsCollection, UpDataStructsCollectionStats, UpDataStructsProperties, UpDataStructsPropertiesMapPropertyPermission, UpDataStructsPropertyPermission, UpDataStructsTokenChild } from '@polkadot/types/lookup';
import type { Observable } from '@polkadot/types/types';
declare module '@polkadot/api-base/types/storage' {
@@ -88,7 +88,7 @@
/**
* Not used by code, exists only to provide some types to metadata
**/
- dummyStorageValue: AugmentedQuery<ApiType, () => Observable<Option<ITuple<[UpDataStructsCollectionStats, u32, u32, PhantomTypeUpDataStructs]>>>, []> & QueryableStorageEntry<ApiType, []>;
+ dummyStorageValue: AugmentedQuery<ApiType, () => Observable<Option<ITuple<[UpDataStructsCollectionStats, u32, u32, UpDataStructsTokenChild, PhantomTypeUpDataStructs]>>>, []> & QueryableStorageEntry<ApiType, []>;
/**
* List of collection admins
**/
tests/src/interfaces/augment-api-rpc.tsdiffbeforeafterboth--- a/tests/src/interfaces/augment-api-rpc.ts
+++ b/tests/src/interfaces/augment-api-rpc.ts
@@ -1,7 +1,7 @@
// Auto-generated via `yarn polkadot-types-from-chain`, do not edit
/* eslint-disable */
-import type { PalletEvmAccountBasicCrossAccountIdRepr, UpDataStructsCollectionLimits, UpDataStructsCollectionStats, UpDataStructsProperty, UpDataStructsPropertyKeyPermission, UpDataStructsRpcCollection, UpDataStructsTokenData } from './default';
+import type { PalletEvmAccountBasicCrossAccountIdRepr, UpDataStructsCollectionLimits, UpDataStructsCollectionStats, UpDataStructsProperty, UpDataStructsPropertyKeyPermission, UpDataStructsRpcCollection, UpDataStructsTokenChild, UpDataStructsTokenData } from './default';
import type { AugmentedRpc } from '@polkadot/rpc-core/types';
import type { Metadata, StorageKey } from '@polkadot/types';
import type { Bytes, HashMap, Json, Null, Option, Text, U256, U64, Vec, bool, u128, u32, u64 } from '@polkadot/types-codec';
@@ -639,6 +639,10 @@
**/
propertyPermissions: AugmentedRpc<(collection: u32 | AnyNumber | Uint8Array, propertyKeys?: Vec<Text> | (Text | string)[], at?: Hash | string | Uint8Array) => Observable<Vec<UpDataStructsPropertyKeyPermission>>>;
/**
+ * Get tokens nested directly into the token
+ **/
+ tokenChildren: AugmentedRpc<(collection: u32 | AnyNumber | Uint8Array, tokenId: u32 | AnyNumber | Uint8Array, at?: Hash | string | Uint8Array) => Observable<Vec<UpDataStructsTokenChild>>>;
+ /**
* Get token data
**/
tokenData: AugmentedRpc<(collection: u32 | AnyNumber | Uint8Array, tokenId: u32 | AnyNumber | Uint8Array, propertyKeys?: Vec<Text> | (Text | string)[], at?: Hash | string | Uint8Array) => Observable<UpDataStructsTokenData>>;
tests/src/interfaces/augment-types.tsdiffbeforeafterboth--- a/tests/src/interfaces/augment-types.ts
+++ b/tests/src/interfaces/augment-types.ts
@@ -1,7 +1,7 @@
// Auto-generated via `yarn polkadot-types-from-defs`, do not edit
/* eslint-disable */
-import type { CumulusPalletDmpQueueCall, CumulusPalletDmpQueueConfigData, CumulusPalletDmpQueueError, CumulusPalletDmpQueueEvent, CumulusPalletDmpQueuePageIndexData, CumulusPalletParachainSystemCall, CumulusPalletParachainSystemError, CumulusPalletParachainSystemEvent, CumulusPalletParachainSystemRelayStateSnapshotMessagingStateSnapshot, CumulusPalletXcmCall, CumulusPalletXcmError, CumulusPalletXcmEvent, CumulusPalletXcmpQueueCall, CumulusPalletXcmpQueueError, CumulusPalletXcmpQueueEvent, CumulusPalletXcmpQueueInboundChannelDetails, CumulusPalletXcmpQueueInboundState, CumulusPalletXcmpQueueOutboundChannelDetails, CumulusPalletXcmpQueueOutboundState, CumulusPalletXcmpQueueQueueConfigData, CumulusPrimitivesParachainInherentParachainInherentData, EthbloomBloom, EthereumBlock, EthereumHeader, EthereumLog, EthereumReceiptEip658ReceiptData, EthereumReceiptReceiptV3, EthereumTransactionAccessListItem, EthereumTransactionEip1559Transaction, EthereumTransactionEip2930Transaction, EthereumTransactionLegacyTransaction, EthereumTransactionTransactionAction, EthereumTransactionTransactionSignature, EthereumTransactionTransactionV2, EthereumTypesHashH64, EvmCoreErrorExitError, EvmCoreErrorExitFatal, EvmCoreErrorExitReason, EvmCoreErrorExitRevert, EvmCoreErrorExitSucceed, FpRpcTransactionStatus, FrameSupportPalletId, FrameSupportTokensMiscBalanceStatus, FrameSupportWeightsDispatchClass, FrameSupportWeightsDispatchInfo, FrameSupportWeightsPays, FrameSupportWeightsPerDispatchClassU32, FrameSupportWeightsPerDispatchClassU64, FrameSupportWeightsPerDispatchClassWeightsPerClass, FrameSupportWeightsRuntimeDbWeight, FrameSupportWeightsWeightToFeeCoefficient, FrameSystemAccountInfo, FrameSystemCall, FrameSystemError, FrameSystemEvent, FrameSystemEventRecord, FrameSystemExtensionsCheckGenesis, FrameSystemExtensionsCheckNonce, FrameSystemExtensionsCheckSpecVersion, FrameSystemExtensionsCheckWeight, FrameSystemLastRuntimeUpgradeInfo, FrameSystemLimitsBlockLength, FrameSystemLimitsBlockWeights, FrameSystemLimitsWeightsPerClass, FrameSystemPhase, OpalRuntimeRuntime, OrmlVestingModuleCall, OrmlVestingModuleError, OrmlVestingModuleEvent, OrmlVestingVestingSchedule, PalletBalancesAccountData, PalletBalancesBalanceLock, PalletBalancesCall, PalletBalancesError, PalletBalancesEvent, PalletBalancesReasons, PalletBalancesReleases, PalletBalancesReserveData, PalletCommonError, PalletCommonEvent, PalletEthereumCall, PalletEthereumError, PalletEthereumEvent, PalletEthereumFakeTransactionFinalizer, PalletEvmAccountBasicCrossAccountIdRepr, PalletEvmCall, PalletEvmCoderSubstrateError, PalletEvmContractHelpersError, PalletEvmContractHelpersSponsoringModeT, PalletEvmError, PalletEvmEvent, PalletEvmMigrationCall, PalletEvmMigrationError, PalletFungibleError, PalletInflationCall, PalletNonfungibleError, PalletNonfungibleItemData, PalletRefungibleError, PalletRefungibleItemData, PalletStructureCall, PalletStructureError, PalletStructureEvent, PalletSudoCall, PalletSudoError, PalletSudoEvent, PalletTemplateTransactionPaymentCall, PalletTemplateTransactionPaymentChargeTransactionPayment, PalletTimestampCall, PalletTransactionPaymentReleases, PalletTreasuryCall, PalletTreasuryError, PalletTreasuryEvent, PalletTreasuryProposal, PalletUniqueCall, PalletUniqueError, PalletUniqueRawEvent, PalletXcmCall, PalletXcmError, PalletXcmEvent, PhantomTypeUpDataStructs, PolkadotCorePrimitivesInboundDownwardMessage, PolkadotCorePrimitivesInboundHrmpMessage, PolkadotCorePrimitivesOutboundHrmpMessage, PolkadotParachainPrimitivesXcmpMessageFormat, PolkadotPrimitivesV2AbridgedHostConfiguration, PolkadotPrimitivesV2AbridgedHrmpChannel, PolkadotPrimitivesV2PersistedValidationData, PolkadotPrimitivesV2UpgradeRestriction, SpCoreEcdsaSignature, SpCoreEd25519Signature, SpCoreSr25519Signature, SpRuntimeArithmeticError, SpRuntimeDigest, SpRuntimeDigestDigestItem, SpRuntimeDispatchError, SpRuntimeModuleError, SpRuntimeMultiSignature, SpRuntimeTokenError, SpRuntimeTransactionalError, SpTrieStorageProof, SpVersionRuntimeVersion, UpDataStructsAccessMode, UpDataStructsCollection, UpDataStructsCollectionLimits, UpDataStructsCollectionMode, UpDataStructsCollectionPermissions, UpDataStructsCollectionStats, UpDataStructsCreateCollectionData, UpDataStructsCreateFungibleData, UpDataStructsCreateItemData, UpDataStructsCreateItemExData, UpDataStructsCreateNftData, UpDataStructsCreateNftExData, UpDataStructsCreateReFungibleData, UpDataStructsCreateRefungibleExData, UpDataStructsNestingRule, UpDataStructsProperties, UpDataStructsPropertiesMapBoundedVec, UpDataStructsPropertiesMapPropertyPermission, UpDataStructsProperty, UpDataStructsPropertyKeyPermission, UpDataStructsPropertyPermission, UpDataStructsRmrkAccountIdOrCollectionNftTuple, UpDataStructsRmrkBaseInfo, UpDataStructsRmrkBasicResource, UpDataStructsRmrkCollectionInfo, UpDataStructsRmrkComposableResource, UpDataStructsRmrkEquippableList, UpDataStructsRmrkFixedPart, UpDataStructsRmrkNftChild, UpDataStructsRmrkNftInfo, UpDataStructsRmrkPartType, UpDataStructsRmrkPropertyInfo, UpDataStructsRmrkResourceInfo, UpDataStructsRmrkResourceTypes, UpDataStructsRmrkRoyaltyInfo, UpDataStructsRmrkSlotPart, UpDataStructsRmrkSlotResource, UpDataStructsRmrkTheme, UpDataStructsRmrkThemeProperty, UpDataStructsRpcCollection, UpDataStructsSponsoringRateLimit, UpDataStructsSponsorshipState, UpDataStructsTokenData, XcmDoubleEncoded, XcmV0Junction, XcmV0JunctionBodyId, XcmV0JunctionBodyPart, XcmV0JunctionNetworkId, XcmV0MultiAsset, XcmV0MultiLocation, XcmV0Order, XcmV0OriginKind, XcmV0Response, XcmV0Xcm, XcmV1Junction, XcmV1MultiAsset, XcmV1MultiLocation, XcmV1MultiassetAssetId, XcmV1MultiassetAssetInstance, XcmV1MultiassetFungibility, XcmV1MultiassetMultiAssetFilter, XcmV1MultiassetMultiAssets, XcmV1MultiassetWildFungibility, XcmV1MultiassetWildMultiAsset, XcmV1MultilocationJunctions, XcmV1Order, XcmV1Response, XcmV1Xcm, XcmV2Instruction, XcmV2Response, XcmV2TraitsError, XcmV2TraitsOutcome, XcmV2WeightLimit, XcmV2Xcm, XcmVersionedMultiAssets, XcmVersionedMultiLocation, XcmVersionedXcm } from './default';
+import type { CumulusPalletDmpQueueCall, CumulusPalletDmpQueueConfigData, CumulusPalletDmpQueueError, CumulusPalletDmpQueueEvent, CumulusPalletDmpQueuePageIndexData, CumulusPalletParachainSystemCall, CumulusPalletParachainSystemError, CumulusPalletParachainSystemEvent, CumulusPalletParachainSystemRelayStateSnapshotMessagingStateSnapshot, CumulusPalletXcmCall, CumulusPalletXcmError, CumulusPalletXcmEvent, CumulusPalletXcmpQueueCall, CumulusPalletXcmpQueueError, CumulusPalletXcmpQueueEvent, CumulusPalletXcmpQueueInboundChannelDetails, CumulusPalletXcmpQueueInboundState, CumulusPalletXcmpQueueOutboundChannelDetails, CumulusPalletXcmpQueueOutboundState, CumulusPalletXcmpQueueQueueConfigData, CumulusPrimitivesParachainInherentParachainInherentData, EthbloomBloom, EthereumBlock, EthereumHeader, EthereumLog, EthereumReceiptEip658ReceiptData, EthereumReceiptReceiptV3, EthereumTransactionAccessListItem, EthereumTransactionEip1559Transaction, EthereumTransactionEip2930Transaction, EthereumTransactionLegacyTransaction, EthereumTransactionTransactionAction, EthereumTransactionTransactionSignature, EthereumTransactionTransactionV2, EthereumTypesHashH64, EvmCoreErrorExitError, EvmCoreErrorExitFatal, EvmCoreErrorExitReason, EvmCoreErrorExitRevert, EvmCoreErrorExitSucceed, FpRpcTransactionStatus, FrameSupportPalletId, FrameSupportTokensMiscBalanceStatus, FrameSupportWeightsDispatchClass, FrameSupportWeightsDispatchInfo, FrameSupportWeightsPays, FrameSupportWeightsPerDispatchClassU32, FrameSupportWeightsPerDispatchClassU64, FrameSupportWeightsPerDispatchClassWeightsPerClass, FrameSupportWeightsRuntimeDbWeight, FrameSupportWeightsWeightToFeeCoefficient, FrameSystemAccountInfo, FrameSystemCall, FrameSystemError, FrameSystemEvent, FrameSystemEventRecord, FrameSystemExtensionsCheckGenesis, FrameSystemExtensionsCheckNonce, FrameSystemExtensionsCheckSpecVersion, FrameSystemExtensionsCheckWeight, FrameSystemLastRuntimeUpgradeInfo, FrameSystemLimitsBlockLength, FrameSystemLimitsBlockWeights, FrameSystemLimitsWeightsPerClass, FrameSystemPhase, OpalRuntimeRuntime, OrmlVestingModuleCall, OrmlVestingModuleError, OrmlVestingModuleEvent, OrmlVestingVestingSchedule, PalletBalancesAccountData, PalletBalancesBalanceLock, PalletBalancesCall, PalletBalancesError, PalletBalancesEvent, PalletBalancesReasons, PalletBalancesReleases, PalletBalancesReserveData, PalletCommonError, PalletCommonEvent, PalletEthereumCall, PalletEthereumError, PalletEthereumEvent, PalletEthereumFakeTransactionFinalizer, PalletEvmAccountBasicCrossAccountIdRepr, PalletEvmCall, PalletEvmCoderSubstrateError, PalletEvmContractHelpersError, PalletEvmContractHelpersSponsoringModeT, PalletEvmError, PalletEvmEvent, PalletEvmMigrationCall, PalletEvmMigrationError, PalletFungibleError, PalletInflationCall, PalletNonfungibleError, PalletNonfungibleItemData, PalletRefungibleError, PalletRefungibleItemData, PalletStructureCall, PalletStructureError, PalletStructureEvent, PalletSudoCall, PalletSudoError, PalletSudoEvent, PalletTemplateTransactionPaymentCall, PalletTemplateTransactionPaymentChargeTransactionPayment, PalletTimestampCall, PalletTransactionPaymentReleases, PalletTreasuryCall, PalletTreasuryError, PalletTreasuryEvent, PalletTreasuryProposal, PalletUniqueCall, PalletUniqueError, PalletUniqueRawEvent, PalletXcmCall, PalletXcmError, PalletXcmEvent, PhantomTypeUpDataStructs, PolkadotCorePrimitivesInboundDownwardMessage, PolkadotCorePrimitivesInboundHrmpMessage, PolkadotCorePrimitivesOutboundHrmpMessage, PolkadotParachainPrimitivesXcmpMessageFormat, PolkadotPrimitivesV2AbridgedHostConfiguration, PolkadotPrimitivesV2AbridgedHrmpChannel, PolkadotPrimitivesV2PersistedValidationData, PolkadotPrimitivesV2UpgradeRestriction, SpCoreEcdsaSignature, SpCoreEd25519Signature, SpCoreSr25519Signature, SpRuntimeArithmeticError, SpRuntimeDigest, SpRuntimeDigestDigestItem, SpRuntimeDispatchError, SpRuntimeModuleError, SpRuntimeMultiSignature, SpRuntimeTokenError, SpRuntimeTransactionalError, SpTrieStorageProof, SpVersionRuntimeVersion, UpDataStructsAccessMode, UpDataStructsCollection, UpDataStructsCollectionLimits, UpDataStructsCollectionMode, UpDataStructsCollectionPermissions, UpDataStructsCollectionStats, UpDataStructsCreateCollectionData, UpDataStructsCreateFungibleData, UpDataStructsCreateItemData, UpDataStructsCreateItemExData, UpDataStructsCreateNftData, UpDataStructsCreateNftExData, UpDataStructsCreateReFungibleData, UpDataStructsCreateRefungibleExData, UpDataStructsNestingRule, UpDataStructsProperties, UpDataStructsPropertiesMapBoundedVec, UpDataStructsPropertiesMapPropertyPermission, UpDataStructsProperty, UpDataStructsPropertyKeyPermission, UpDataStructsPropertyPermission, UpDataStructsRmrkAccountIdOrCollectionNftTuple, UpDataStructsRmrkBaseInfo, UpDataStructsRmrkBasicResource, UpDataStructsRmrkCollectionInfo, UpDataStructsRmrkComposableResource, UpDataStructsRmrkEquippableList, UpDataStructsRmrkFixedPart, UpDataStructsRmrkNftChild, UpDataStructsRmrkNftInfo, UpDataStructsRmrkPartType, UpDataStructsRmrkPropertyInfo, UpDataStructsRmrkResourceInfo, UpDataStructsRmrkResourceTypes, UpDataStructsRmrkRoyaltyInfo, UpDataStructsRmrkSlotPart, UpDataStructsRmrkSlotResource, UpDataStructsRmrkTheme, UpDataStructsRmrkThemeProperty, UpDataStructsRpcCollection, UpDataStructsSponsoringRateLimit, UpDataStructsSponsorshipState, UpDataStructsTokenChild, UpDataStructsTokenData, XcmDoubleEncoded, XcmV0Junction, XcmV0JunctionBodyId, XcmV0JunctionBodyPart, XcmV0JunctionNetworkId, XcmV0MultiAsset, XcmV0MultiLocation, XcmV0Order, XcmV0OriginKind, XcmV0Response, XcmV0Xcm, XcmV1Junction, XcmV1MultiAsset, XcmV1MultiLocation, XcmV1MultiassetAssetId, XcmV1MultiassetAssetInstance, XcmV1MultiassetFungibility, XcmV1MultiassetMultiAssetFilter, XcmV1MultiassetMultiAssets, XcmV1MultiassetWildFungibility, XcmV1MultiassetWildMultiAsset, XcmV1MultilocationJunctions, XcmV1Order, XcmV1Response, XcmV1Xcm, XcmV2Instruction, XcmV2Response, XcmV2TraitsError, XcmV2TraitsOutcome, XcmV2WeightLimit, XcmV2Xcm, XcmVersionedMultiAssets, XcmVersionedMultiLocation, XcmVersionedXcm } from './default';
import type { Data, StorageKey } from '@polkadot/types';
import type { BitVec, Bool, Bytes, I128, I16, I256, I32, I64, I8, Json, Null, OptionBool, Raw, Text, Type, U128, U16, U256, U32, U64, U8, USize, bool, i128, i16, i256, i32, i64, i8, u128, u16, u256, u32, u64, u8, usize } from '@polkadot/types-codec';
import type { AssetApproval, AssetApprovalKey, AssetBalance, AssetDestroyWitness, AssetDetails, AssetMetadata, TAssetBalance, TAssetDepositBalance } from '@polkadot/types/interfaces/assets';
@@ -1210,6 +1210,7 @@
UpDataStructsRpcCollection: UpDataStructsRpcCollection;
UpDataStructsSponsoringRateLimit: UpDataStructsSponsoringRateLimit;
UpDataStructsSponsorshipState: UpDataStructsSponsorshipState;
+ UpDataStructsTokenChild: UpDataStructsTokenChild;
UpDataStructsTokenData: UpDataStructsTokenData;
UpgradeGoAhead: UpgradeGoAhead;
UpgradeRestriction: UpgradeRestriction;
tests/src/interfaces/default/types.tsdiffbeforeafterboth--- a/tests/src/interfaces/default/types.ts
+++ b/tests/src/interfaces/default/types.ts
@@ -1588,7 +1588,7 @@
}
/** @name PhantomTypeUpDataStructs */
-export interface PhantomTypeUpDataStructs extends Vec<ITuple<[UpDataStructsTokenData, UpDataStructsRpcCollection, PalletEvmAccountBasicCrossAccountIdRepr, UpDataStructsRmrkCollectionInfo, UpDataStructsRmrkNftInfo, UpDataStructsRmrkResourceInfo, UpDataStructsRmrkPropertyInfo, UpDataStructsRmrkBaseInfo, UpDataStructsRmrkPartType, UpDataStructsRmrkTheme, UpDataStructsRmrkNftChild]>> {}
+export interface PhantomTypeUpDataStructs extends Vec<ITuple<[UpDataStructsTokenData, UpDataStructsRpcCollection, UpDataStructsRmrkCollectionInfo, UpDataStructsRmrkNftInfo, UpDataStructsRmrkResourceInfo, UpDataStructsRmrkPropertyInfo, UpDataStructsRmrkBaseInfo, UpDataStructsRmrkPartType, UpDataStructsRmrkTheme, UpDataStructsRmrkNftChild]>> {}
/** @name PolkadotCorePrimitivesInboundDownwardMessage */
export interface PolkadotCorePrimitivesInboundDownwardMessage extends Struct {
@@ -1861,7 +1861,6 @@
/** @name UpDataStructsCreateNftData */
export interface UpDataStructsCreateNftData extends Struct {
- readonly constData: Bytes;
readonly properties: Vec<UpDataStructsProperty>;
}
@@ -2101,6 +2100,12 @@
readonly type: 'Disabled' | 'Unconfirmed' | 'Confirmed';
}
+/** @name UpDataStructsTokenChild */
+export interface UpDataStructsTokenChild extends Struct {
+ readonly token: u32;
+ readonly collection: u32;
+}
+
/** @name UpDataStructsTokenData */
export interface UpDataStructsTokenData extends Struct {
readonly properties: Vec<UpDataStructsProperty>;
tests/src/interfaces/lookup.tsdiffbeforeafterboth--- a/tests/src/interfaces/lookup.ts
+++ b/tests/src/interfaces/lookup.ts
@@ -1479,17 +1479,16 @@
* Lookup186: up_data_structs::CreateNftData
**/
UpDataStructsCreateNftData: {
- constData: 'Bytes',
properties: 'Vec<UpDataStructsProperty>'
},
/**
- * Lookup188: up_data_structs::CreateFungibleData
+ * Lookup187: up_data_structs::CreateFungibleData
**/
UpDataStructsCreateFungibleData: {
value: 'u128'
},
/**
- * Lookup189: up_data_structs::CreateReFungibleData
+ * Lookup188: up_data_structs::CreateReFungibleData
**/
UpDataStructsCreateReFungibleData: {
constData: 'Bytes',
@@ -2282,18 +2281,25 @@
alive: 'u32'
},
/**
- * Lookup323: PhantomType::up_data_structs<T>
+ * Lookup323: up_data_structs::TokenChild
**/
- PhantomTypeUpDataStructs: '[(UpDataStructsTokenData,UpDataStructsRpcCollection,PalletEvmAccountBasicCrossAccountIdRepr,UpDataStructsRmrkCollectionInfo,UpDataStructsRmrkNftInfo,UpDataStructsRmrkResourceInfo,UpDataStructsRmrkPropertyInfo,UpDataStructsRmrkBaseInfo,UpDataStructsRmrkPartType,UpDataStructsRmrkTheme,UpDataStructsRmrkNftChild);0]',
+ UpDataStructsTokenChild: {
+ token: 'u32',
+ collection: 'u32'
+ },
+ /**
+ * Lookup324: PhantomType::up_data_structs<T>
+ **/
+ PhantomTypeUpDataStructs: '[(UpDataStructsTokenData,UpDataStructsRpcCollection,UpDataStructsRmrkCollectionInfo,UpDataStructsRmrkNftInfo,UpDataStructsRmrkResourceInfo,UpDataStructsRmrkPropertyInfo,UpDataStructsRmrkBaseInfo,UpDataStructsRmrkPartType,UpDataStructsRmrkTheme,UpDataStructsRmrkNftChild);0]',
/**
- * Lookup325: up_data_structs::TokenData<pallet_evm::account::BasicCrossAccountIdRepr<sp_core::crypto::AccountId32>>
+ * Lookup326: up_data_structs::TokenData<pallet_evm::account::BasicCrossAccountIdRepr<sp_core::crypto::AccountId32>>
**/
UpDataStructsTokenData: {
properties: 'Vec<UpDataStructsProperty>',
owner: 'Option<PalletEvmAccountBasicCrossAccountIdRepr>'
},
/**
- * Lookup327: up_data_structs::RpcCollection<sp_core::crypto::AccountId32>
+ * Lookup328: up_data_structs::RpcCollection<sp_core::crypto::AccountId32>
**/
UpDataStructsRpcCollection: {
owner: 'AccountId32',
@@ -2308,7 +2314,7 @@
properties: 'Vec<UpDataStructsProperty>'
},
/**
- * Lookup328: up_data_structs::rmrk::CollectionInfo<frame_support::storage::bounded_vec::BoundedVec<T, S>, frame_support::storage::bounded_vec::BoundedVec<T, S>, sp_core::crypto::AccountId32>
+ * Lookup329: up_data_structs::rmrk::CollectionInfo<frame_support::storage::bounded_vec::BoundedVec<T, S>, frame_support::storage::bounded_vec::BoundedVec<T, S>, sp_core::crypto::AccountId32>
**/
UpDataStructsRmrkCollectionInfo: {
issuer: 'AccountId32',
@@ -2318,7 +2324,7 @@
nftsCount: 'u32'
},
/**
- * Lookup331: up_data_structs::rmrk::NftInfo<sp_core::crypto::AccountId32, sp_arithmetic::per_things::Permill, frame_support::storage::bounded_vec::BoundedVec<T, S>>
+ * Lookup332: up_data_structs::rmrk::NftInfo<sp_core::crypto::AccountId32, sp_arithmetic::per_things::Permill, frame_support::storage::bounded_vec::BoundedVec<T, S>>
**/
UpDataStructsRmrkNftInfo: {
owner: 'UpDataStructsRmrkAccountIdOrCollectionNftTuple',
@@ -2328,7 +2334,7 @@
pending: 'bool'
},
/**
- * Lookup332: up_data_structs::rmrk::AccountIdOrCollectionNftTuple<sp_core::crypto::AccountId32>
+ * Lookup333: up_data_structs::rmrk::AccountIdOrCollectionNftTuple<sp_core::crypto::AccountId32>
**/
UpDataStructsRmrkAccountIdOrCollectionNftTuple: {
_enum: {
@@ -2337,14 +2343,14 @@
}
},
/**
- * Lookup334: up_data_structs::rmrk::RoyaltyInfo<sp_core::crypto::AccountId32, sp_arithmetic::per_things::Permill>
+ * Lookup335: up_data_structs::rmrk::RoyaltyInfo<sp_core::crypto::AccountId32, sp_arithmetic::per_things::Permill>
**/
UpDataStructsRmrkRoyaltyInfo: {
recipient: 'AccountId32',
amount: 'Permill'
},
/**
- * Lookup335: up_data_structs::rmrk::ResourceInfo<frame_support::storage::bounded_vec::BoundedVec<T, S>, frame_support::storage::bounded_vec::BoundedVec<T, S>, frame_support::storage::bounded_vec::BoundedVec<T, S>>
+ * Lookup336: up_data_structs::rmrk::ResourceInfo<frame_support::storage::bounded_vec::BoundedVec<T, S>, frame_support::storage::bounded_vec::BoundedVec<T, S>, frame_support::storage::bounded_vec::BoundedVec<T, S>>
**/
UpDataStructsRmrkResourceInfo: {
id: 'Bytes',
@@ -2353,7 +2359,7 @@
pendingRemoval: 'bool'
},
/**
- * Lookup338: up_data_structs::rmrk::ResourceTypes<frame_support::storage::bounded_vec::BoundedVec<T, S>, frame_support::storage::bounded_vec::BoundedVec<T, S>>
+ * Lookup339: up_data_structs::rmrk::ResourceTypes<frame_support::storage::bounded_vec::BoundedVec<T, S>, frame_support::storage::bounded_vec::BoundedVec<T, S>>
**/
UpDataStructsRmrkResourceTypes: {
_enum: {
@@ -2363,7 +2369,7 @@
}
},
/**
- * Lookup339: up_data_structs::rmrk::BasicResource<frame_support::storage::bounded_vec::BoundedVec<T, S>>
+ * Lookup340: up_data_structs::rmrk::BasicResource<frame_support::storage::bounded_vec::BoundedVec<T, S>>
**/
UpDataStructsRmrkBasicResource: {
src: 'Option<Bytes>',
@@ -2372,7 +2378,7 @@
thumb: 'Option<Bytes>'
},
/**
- * Lookup341: up_data_structs::rmrk::ComposableResource<frame_support::storage::bounded_vec::BoundedVec<T, S>, frame_support::storage::bounded_vec::BoundedVec<T, S>>
+ * Lookup342: up_data_structs::rmrk::ComposableResource<frame_support::storage::bounded_vec::BoundedVec<T, S>, frame_support::storage::bounded_vec::BoundedVec<T, S>>
**/
UpDataStructsRmrkComposableResource: {
parts: 'Vec<u32>',
@@ -2383,7 +2389,7 @@
thumb: 'Option<Bytes>'
},
/**
- * Lookup342: up_data_structs::rmrk::SlotResource<frame_support::storage::bounded_vec::BoundedVec<T, S>>
+ * Lookup343: up_data_structs::rmrk::SlotResource<frame_support::storage::bounded_vec::BoundedVec<T, S>>
**/
UpDataStructsRmrkSlotResource: {
base: 'u32',
@@ -2394,14 +2400,14 @@
thumb: 'Option<Bytes>'
},
/**
- * Lookup343: up_data_structs::rmrk::PropertyInfo<frame_support::storage::bounded_vec::BoundedVec<T, S>, frame_support::storage::bounded_vec::BoundedVec<T, S>>
+ * Lookup344: up_data_structs::rmrk::PropertyInfo<frame_support::storage::bounded_vec::BoundedVec<T, S>, frame_support::storage::bounded_vec::BoundedVec<T, S>>
**/
UpDataStructsRmrkPropertyInfo: {
key: 'Bytes',
value: 'Bytes'
},
/**
- * Lookup346: up_data_structs::rmrk::BaseInfo<sp_core::crypto::AccountId32, frame_support::storage::bounded_vec::BoundedVec<T, S>>
+ * Lookup347: up_data_structs::rmrk::BaseInfo<sp_core::crypto::AccountId32, frame_support::storage::bounded_vec::BoundedVec<T, S>>
**/
UpDataStructsRmrkBaseInfo: {
issuer: 'AccountId32',
@@ -2409,7 +2415,7 @@
symbol: 'Bytes'
},
/**
- * Lookup347: up_data_structs::rmrk::PartType<frame_support::storage::bounded_vec::BoundedVec<T, S>, frame_support::storage::bounded_vec::BoundedVec<T, S>>
+ * Lookup348: up_data_structs::rmrk::PartType<frame_support::storage::bounded_vec::BoundedVec<T, S>, frame_support::storage::bounded_vec::BoundedVec<T, S>>
**/
UpDataStructsRmrkPartType: {
_enum: {
@@ -2418,7 +2424,7 @@
}
},
/**
- * Lookup349: up_data_structs::rmrk::FixedPart<frame_support::storage::bounded_vec::BoundedVec<T, S>>
+ * Lookup350: up_data_structs::rmrk::FixedPart<frame_support::storage::bounded_vec::BoundedVec<T, S>>
**/
UpDataStructsRmrkFixedPart: {
id: 'u32',
@@ -2426,7 +2432,7 @@
src: 'Bytes'
},
/**
- * Lookup350: up_data_structs::rmrk::SlotPart<frame_support::storage::bounded_vec::BoundedVec<T, S>, frame_support::storage::bounded_vec::BoundedVec<T, S>>
+ * Lookup351: up_data_structs::rmrk::SlotPart<frame_support::storage::bounded_vec::BoundedVec<T, S>, frame_support::storage::bounded_vec::BoundedVec<T, S>>
**/
UpDataStructsRmrkSlotPart: {
id: 'u32',
@@ -2435,7 +2441,7 @@
z: 'u32'
},
/**
- * Lookup351: up_data_structs::rmrk::EquippableList<frame_support::storage::bounded_vec::BoundedVec<T, S>>
+ * Lookup352: up_data_structs::rmrk::EquippableList<frame_support::storage::bounded_vec::BoundedVec<T, S>>
**/
UpDataStructsRmrkEquippableList: {
_enum: {
@@ -2445,7 +2451,7 @@
}
},
/**
- * Lookup352: up_data_structs::rmrk::Theme<frame_support::storage::bounded_vec::BoundedVec<T, S>, PropertyList>
+ * Lookup353: up_data_structs::rmrk::Theme<frame_support::storage::bounded_vec::BoundedVec<T, S>, PropertyList>
**/
UpDataStructsRmrkTheme: {
name: 'Bytes',
@@ -2453,69 +2459,69 @@
inherit: 'bool'
},
/**
- * Lookup354: up_data_structs::rmrk::ThemeProperty<frame_support::storage::bounded_vec::BoundedVec<T, S>>
+ * Lookup355: up_data_structs::rmrk::ThemeProperty<frame_support::storage::bounded_vec::BoundedVec<T, S>>
**/
UpDataStructsRmrkThemeProperty: {
key: 'Bytes',
value: 'Bytes'
},
/**
- * Lookup355: up_data_structs::rmrk::NftChild
+ * Lookup356: up_data_structs::rmrk::NftChild
**/
UpDataStructsRmrkNftChild: {
collectionId: 'u32',
nftId: 'u32'
},
/**
- * Lookup357: pallet_common::pallet::Error<T>
+ * Lookup358: pallet_common::pallet::Error<T>
**/
PalletCommonError: {
_enum: ['CollectionNotFound', 'MustBeTokenOwner', 'NoPermission', 'CantDestroyNotEmptyCollection', 'PublicMintingNotAllowed', 'AddressNotInAllowlist', 'CollectionNameLimitExceeded', 'CollectionDescriptionLimitExceeded', 'CollectionTokenPrefixLimitExceeded', 'TotalCollectionsLimitExceeded', 'CollectionAdminCountExceeded', 'CollectionLimitBoundsExceeded', 'OwnerPermissionsCantBeReverted', 'TransferNotAllowed', 'AccountTokenLimitExceeded', 'CollectionTokenLimitExceeded', 'MetadataFlagFrozen', 'TokenNotFound', 'TokenValueTooLow', 'ApprovedValueTooLow', 'CantApproveMoreThanOwned', 'AddressIsZero', 'UnsupportedOperation', 'NotSufficientFounds', 'NestingIsDisabled', 'OnlyOwnerAllowedToNest', 'SourceCollectionIsNotAllowedToNest', 'CollectionFieldSizeExceeded', 'NoSpaceForProperty', 'PropertyLimitReached', 'PropertyKeyIsTooLong', 'InvalidCharacterInPropertyKey', 'EmptyPropertyKey']
},
/**
- * Lookup359: pallet_fungible::pallet::Error<T>
+ * Lookup360: pallet_fungible::pallet::Error<T>
**/
PalletFungibleError: {
_enum: ['NotFungibleDataUsedToMintFungibleCollectionToken', 'FungibleItemsHaveNoId', 'FungibleItemsDontHaveData', 'FungibleDisallowsNesting', 'SettingPropertiesNotAllowed']
},
/**
- * Lookup360: pallet_refungible::ItemData
+ * Lookup361: pallet_refungible::ItemData
**/
PalletRefungibleItemData: {
constData: 'Bytes'
},
/**
- * Lookup364: pallet_refungible::pallet::Error<T>
+ * Lookup365: pallet_refungible::pallet::Error<T>
**/
PalletRefungibleError: {
_enum: ['NotRefungibleDataUsedToMintFungibleCollectionToken', 'WrongRefungiblePieces', 'RefungibleDisallowsNesting', 'SettingPropertiesNotAllowed']
},
/**
- * Lookup365: pallet_nonfungible::ItemData<pallet_evm::account::BasicCrossAccountIdRepr<sp_core::crypto::AccountId32>>
+ * Lookup366: pallet_nonfungible::ItemData<pallet_evm::account::BasicCrossAccountIdRepr<sp_core::crypto::AccountId32>>
**/
PalletNonfungibleItemData: {
owner: 'PalletEvmAccountBasicCrossAccountIdRepr'
},
/**
- * Lookup367: pallet_nonfungible::pallet::Error<T>
+ * Lookup368: pallet_nonfungible::pallet::Error<T>
**/
PalletNonfungibleError: {
_enum: ['NotNonfungibleDataUsedToMintFungibleCollectionToken', 'NonfungibleItemsHaveNoAmount', 'CantBurnNftWithChildren']
},
/**
- * Lookup368: pallet_structure::pallet::Error<T>
+ * Lookup369: pallet_structure::pallet::Error<T>
**/
PalletStructureError: {
_enum: ['OuroborosDetected', 'DepthLimit', 'TokenNotFound']
},
/**
- * Lookup371: pallet_evm::pallet::Error<T>
+ * Lookup372: pallet_evm::pallet::Error<T>
**/
PalletEvmError: {
_enum: ['BalanceLow', 'FeeOverflow', 'PaymentOverflow', 'WithdrawFailed', 'GasPriceTooLow', 'InvalidNonce']
},
/**
- * Lookup374: fp_rpc::TransactionStatus
+ * Lookup375: fp_rpc::TransactionStatus
**/
FpRpcTransactionStatus: {
transactionHash: 'H256',
@@ -2527,11 +2533,11 @@
logsBloom: 'EthbloomBloom'
},
/**
- * Lookup376: ethbloom::Bloom
+ * Lookup377: ethbloom::Bloom
**/
EthbloomBloom: '[u8;256]',
/**
- * Lookup378: ethereum::receipt::ReceiptV3
+ * Lookup379: ethereum::receipt::ReceiptV3
**/
EthereumReceiptReceiptV3: {
_enum: {
@@ -2541,7 +2547,7 @@
}
},
/**
- * Lookup379: ethereum::receipt::EIP658ReceiptData
+ * Lookup380: ethereum::receipt::EIP658ReceiptData
**/
EthereumReceiptEip658ReceiptData: {
statusCode: 'u8',
@@ -2550,7 +2556,7 @@
logs: 'Vec<EthereumLog>'
},
/**
- * Lookup380: ethereum::block::Block<ethereum::transaction::TransactionV2>
+ * Lookup381: ethereum::block::Block<ethereum::transaction::TransactionV2>
**/
EthereumBlock: {
header: 'EthereumHeader',
@@ -2558,7 +2564,7 @@
ommers: 'Vec<EthereumHeader>'
},
/**
- * Lookup381: ethereum::header::Header
+ * Lookup382: ethereum::header::Header
**/
EthereumHeader: {
parentHash: 'H256',
@@ -2578,41 +2584,41 @@
nonce: 'EthereumTypesHashH64'
},
/**
- * Lookup382: ethereum_types::hash::H64
+ * Lookup383: ethereum_types::hash::H64
**/
EthereumTypesHashH64: '[u8;8]',
/**
- * Lookup387: pallet_ethereum::pallet::Error<T>
+ * Lookup388: pallet_ethereum::pallet::Error<T>
**/
PalletEthereumError: {
_enum: ['InvalidSignature', 'PreLogExists']
},
/**
- * Lookup388: pallet_evm_coder_substrate::pallet::Error<T>
+ * Lookup389: pallet_evm_coder_substrate::pallet::Error<T>
**/
PalletEvmCoderSubstrateError: {
_enum: ['OutOfGas', 'OutOfFund']
},
/**
- * Lookup389: pallet_evm_contract_helpers::SponsoringModeT
+ * Lookup390: pallet_evm_contract_helpers::SponsoringModeT
**/
PalletEvmContractHelpersSponsoringModeT: {
_enum: ['Disabled', 'Allowlisted', 'Generous']
},
/**
- * Lookup391: pallet_evm_contract_helpers::pallet::Error<T>
+ * Lookup392: pallet_evm_contract_helpers::pallet::Error<T>
**/
PalletEvmContractHelpersError: {
_enum: ['NoPermission']
},
/**
- * Lookup392: pallet_evm_migration::pallet::Error<T>
+ * Lookup393: pallet_evm_migration::pallet::Error<T>
**/
PalletEvmMigrationError: {
_enum: ['AccountNotEmpty', 'AccountIsNotMigrating']
},
/**
- * Lookup394: sp_runtime::MultiSignature
+ * Lookup395: sp_runtime::MultiSignature
**/
SpRuntimeMultiSignature: {
_enum: {
@@ -2622,43 +2628,43 @@
}
},
/**
- * Lookup395: sp_core::ed25519::Signature
+ * Lookup396: sp_core::ed25519::Signature
**/
SpCoreEd25519Signature: '[u8;64]',
/**
- * Lookup397: sp_core::sr25519::Signature
+ * Lookup398: sp_core::sr25519::Signature
**/
SpCoreSr25519Signature: '[u8;64]',
/**
- * Lookup398: sp_core::ecdsa::Signature
+ * Lookup399: sp_core::ecdsa::Signature
**/
SpCoreEcdsaSignature: '[u8;65]',
/**
- * Lookup401: frame_system::extensions::check_spec_version::CheckSpecVersion<T>
+ * Lookup402: frame_system::extensions::check_spec_version::CheckSpecVersion<T>
**/
FrameSystemExtensionsCheckSpecVersion: 'Null',
/**
- * Lookup402: frame_system::extensions::check_genesis::CheckGenesis<T>
+ * Lookup403: frame_system::extensions::check_genesis::CheckGenesis<T>
**/
FrameSystemExtensionsCheckGenesis: 'Null',
/**
- * Lookup405: frame_system::extensions::check_nonce::CheckNonce<T>
+ * Lookup406: frame_system::extensions::check_nonce::CheckNonce<T>
**/
FrameSystemExtensionsCheckNonce: 'Compact<u32>',
/**
- * Lookup406: frame_system::extensions::check_weight::CheckWeight<T>
+ * Lookup407: frame_system::extensions::check_weight::CheckWeight<T>
**/
FrameSystemExtensionsCheckWeight: 'Null',
/**
- * Lookup407: pallet_template_transaction_payment::ChargeTransactionPayment<opal_runtime::Runtime>
+ * Lookup408: pallet_template_transaction_payment::ChargeTransactionPayment<opal_runtime::Runtime>
**/
PalletTemplateTransactionPaymentChargeTransactionPayment: 'Compact<u128>',
/**
- * Lookup408: opal_runtime::Runtime
+ * Lookup409: opal_runtime::Runtime
**/
OpalRuntimeRuntime: 'Null',
/**
- * Lookup409: pallet_ethereum::FakeTransactionFinalizer<opal_runtime::Runtime>
+ * Lookup410: pallet_ethereum::FakeTransactionFinalizer<opal_runtime::Runtime>
**/
PalletEthereumFakeTransactionFinalizer: 'Null'
};
tests/src/interfaces/registry.tsdiffbeforeafterboth--- a/tests/src/interfaces/registry.ts
+++ b/tests/src/interfaces/registry.ts
@@ -1,7 +1,7 @@
// Auto-generated via `yarn polkadot-types-from-defs`, do not edit
/* eslint-disable */
-import type { CumulusPalletDmpQueueCall, CumulusPalletDmpQueueConfigData, CumulusPalletDmpQueueError, CumulusPalletDmpQueueEvent, CumulusPalletDmpQueuePageIndexData, CumulusPalletParachainSystemCall, CumulusPalletParachainSystemError, CumulusPalletParachainSystemEvent, CumulusPalletParachainSystemRelayStateSnapshotMessagingStateSnapshot, CumulusPalletXcmCall, CumulusPalletXcmError, CumulusPalletXcmEvent, CumulusPalletXcmpQueueCall, CumulusPalletXcmpQueueError, CumulusPalletXcmpQueueEvent, CumulusPalletXcmpQueueInboundChannelDetails, CumulusPalletXcmpQueueInboundState, CumulusPalletXcmpQueueOutboundChannelDetails, CumulusPalletXcmpQueueOutboundState, CumulusPalletXcmpQueueQueueConfigData, CumulusPrimitivesParachainInherentParachainInherentData, EthbloomBloom, EthereumBlock, EthereumHeader, EthereumLog, EthereumReceiptEip658ReceiptData, EthereumReceiptReceiptV3, EthereumTransactionAccessListItem, EthereumTransactionEip1559Transaction, EthereumTransactionEip2930Transaction, EthereumTransactionLegacyTransaction, EthereumTransactionTransactionAction, EthereumTransactionTransactionSignature, EthereumTransactionTransactionV2, EthereumTypesHashH64, EvmCoreErrorExitError, EvmCoreErrorExitFatal, EvmCoreErrorExitReason, EvmCoreErrorExitRevert, EvmCoreErrorExitSucceed, FpRpcTransactionStatus, FrameSupportPalletId, FrameSupportTokensMiscBalanceStatus, FrameSupportWeightsDispatchClass, FrameSupportWeightsDispatchInfo, FrameSupportWeightsPays, FrameSupportWeightsPerDispatchClassU32, FrameSupportWeightsPerDispatchClassU64, FrameSupportWeightsPerDispatchClassWeightsPerClass, FrameSupportWeightsRuntimeDbWeight, FrameSupportWeightsWeightToFeeCoefficient, FrameSystemAccountInfo, FrameSystemCall, FrameSystemError, FrameSystemEvent, FrameSystemEventRecord, FrameSystemExtensionsCheckGenesis, FrameSystemExtensionsCheckNonce, FrameSystemExtensionsCheckSpecVersion, FrameSystemExtensionsCheckWeight, FrameSystemLastRuntimeUpgradeInfo, FrameSystemLimitsBlockLength, FrameSystemLimitsBlockWeights, FrameSystemLimitsWeightsPerClass, FrameSystemPhase, OpalRuntimeRuntime, OrmlVestingModuleCall, OrmlVestingModuleError, OrmlVestingModuleEvent, OrmlVestingVestingSchedule, PalletBalancesAccountData, PalletBalancesBalanceLock, PalletBalancesCall, PalletBalancesError, PalletBalancesEvent, PalletBalancesReasons, PalletBalancesReleases, PalletBalancesReserveData, PalletCommonError, PalletCommonEvent, PalletEthereumCall, PalletEthereumError, PalletEthereumEvent, PalletEthereumFakeTransactionFinalizer, PalletEvmAccountBasicCrossAccountIdRepr, PalletEvmCall, PalletEvmCoderSubstrateError, PalletEvmContractHelpersError, PalletEvmContractHelpersSponsoringModeT, PalletEvmError, PalletEvmEvent, PalletEvmMigrationCall, PalletEvmMigrationError, PalletFungibleError, PalletInflationCall, PalletNonfungibleError, PalletNonfungibleItemData, PalletRefungibleError, PalletRefungibleItemData, PalletStructureCall, PalletStructureError, PalletStructureEvent, PalletSudoCall, PalletSudoError, PalletSudoEvent, PalletTemplateTransactionPaymentCall, PalletTemplateTransactionPaymentChargeTransactionPayment, PalletTimestampCall, PalletTransactionPaymentReleases, PalletTreasuryCall, PalletTreasuryError, PalletTreasuryEvent, PalletTreasuryProposal, PalletUniqueCall, PalletUniqueError, PalletUniqueRawEvent, PalletXcmCall, PalletXcmError, PalletXcmEvent, PhantomTypeUpDataStructs, PolkadotCorePrimitivesInboundDownwardMessage, PolkadotCorePrimitivesInboundHrmpMessage, PolkadotCorePrimitivesOutboundHrmpMessage, PolkadotParachainPrimitivesXcmpMessageFormat, PolkadotPrimitivesV2AbridgedHostConfiguration, PolkadotPrimitivesV2AbridgedHrmpChannel, PolkadotPrimitivesV2PersistedValidationData, PolkadotPrimitivesV2UpgradeRestriction, SpCoreEcdsaSignature, SpCoreEd25519Signature, SpCoreSr25519Signature, SpRuntimeArithmeticError, SpRuntimeDigest, SpRuntimeDigestDigestItem, SpRuntimeDispatchError, SpRuntimeModuleError, SpRuntimeMultiSignature, SpRuntimeTokenError, SpRuntimeTransactionalError, SpTrieStorageProof, SpVersionRuntimeVersion, UpDataStructsAccessMode, UpDataStructsCollection, UpDataStructsCollectionLimits, UpDataStructsCollectionMode, UpDataStructsCollectionPermissions, UpDataStructsCollectionStats, UpDataStructsCreateCollectionData, UpDataStructsCreateFungibleData, UpDataStructsCreateItemData, UpDataStructsCreateItemExData, UpDataStructsCreateNftData, UpDataStructsCreateNftExData, UpDataStructsCreateReFungibleData, UpDataStructsCreateRefungibleExData, UpDataStructsNestingRule, UpDataStructsProperties, UpDataStructsPropertiesMapBoundedVec, UpDataStructsPropertiesMapPropertyPermission, UpDataStructsProperty, UpDataStructsPropertyKeyPermission, UpDataStructsPropertyPermission, UpDataStructsRmrkAccountIdOrCollectionNftTuple, UpDataStructsRmrkBaseInfo, UpDataStructsRmrkBasicResource, UpDataStructsRmrkCollectionInfo, UpDataStructsRmrkComposableResource, UpDataStructsRmrkEquippableList, UpDataStructsRmrkFixedPart, UpDataStructsRmrkNftChild, UpDataStructsRmrkNftInfo, UpDataStructsRmrkPartType, UpDataStructsRmrkPropertyInfo, UpDataStructsRmrkResourceInfo, UpDataStructsRmrkResourceTypes, UpDataStructsRmrkRoyaltyInfo, UpDataStructsRmrkSlotPart, UpDataStructsRmrkSlotResource, UpDataStructsRmrkTheme, UpDataStructsRmrkThemeProperty, UpDataStructsRpcCollection, UpDataStructsSponsoringRateLimit, UpDataStructsSponsorshipState, UpDataStructsTokenData, XcmDoubleEncoded, XcmV0Junction, XcmV0JunctionBodyId, XcmV0JunctionBodyPart, XcmV0JunctionNetworkId, XcmV0MultiAsset, XcmV0MultiLocation, XcmV0Order, XcmV0OriginKind, XcmV0Response, XcmV0Xcm, XcmV1Junction, XcmV1MultiAsset, XcmV1MultiLocation, XcmV1MultiassetAssetId, XcmV1MultiassetAssetInstance, XcmV1MultiassetFungibility, XcmV1MultiassetMultiAssetFilter, XcmV1MultiassetMultiAssets, XcmV1MultiassetWildFungibility, XcmV1MultiassetWildMultiAsset, XcmV1MultilocationJunctions, XcmV1Order, XcmV1Response, XcmV1Xcm, XcmV2Instruction, XcmV2Response, XcmV2TraitsError, XcmV2TraitsOutcome, XcmV2WeightLimit, XcmV2Xcm, XcmVersionedMultiAssets, XcmVersionedMultiLocation, XcmVersionedXcm } from '@polkadot/types/lookup';
+import type { CumulusPalletDmpQueueCall, CumulusPalletDmpQueueConfigData, CumulusPalletDmpQueueError, CumulusPalletDmpQueueEvent, CumulusPalletDmpQueuePageIndexData, CumulusPalletParachainSystemCall, CumulusPalletParachainSystemError, CumulusPalletParachainSystemEvent, CumulusPalletParachainSystemRelayStateSnapshotMessagingStateSnapshot, CumulusPalletXcmCall, CumulusPalletXcmError, CumulusPalletXcmEvent, CumulusPalletXcmpQueueCall, CumulusPalletXcmpQueueError, CumulusPalletXcmpQueueEvent, CumulusPalletXcmpQueueInboundChannelDetails, CumulusPalletXcmpQueueInboundState, CumulusPalletXcmpQueueOutboundChannelDetails, CumulusPalletXcmpQueueOutboundState, CumulusPalletXcmpQueueQueueConfigData, CumulusPrimitivesParachainInherentParachainInherentData, EthbloomBloom, EthereumBlock, EthereumHeader, EthereumLog, EthereumReceiptEip658ReceiptData, EthereumReceiptReceiptV3, EthereumTransactionAccessListItem, EthereumTransactionEip1559Transaction, EthereumTransactionEip2930Transaction, EthereumTransactionLegacyTransaction, EthereumTransactionTransactionAction, EthereumTransactionTransactionSignature, EthereumTransactionTransactionV2, EthereumTypesHashH64, EvmCoreErrorExitError, EvmCoreErrorExitFatal, EvmCoreErrorExitReason, EvmCoreErrorExitRevert, EvmCoreErrorExitSucceed, FpRpcTransactionStatus, FrameSupportPalletId, FrameSupportTokensMiscBalanceStatus, FrameSupportWeightsDispatchClass, FrameSupportWeightsDispatchInfo, FrameSupportWeightsPays, FrameSupportWeightsPerDispatchClassU32, FrameSupportWeightsPerDispatchClassU64, FrameSupportWeightsPerDispatchClassWeightsPerClass, FrameSupportWeightsRuntimeDbWeight, FrameSupportWeightsWeightToFeeCoefficient, FrameSystemAccountInfo, FrameSystemCall, FrameSystemError, FrameSystemEvent, FrameSystemEventRecord, FrameSystemExtensionsCheckGenesis, FrameSystemExtensionsCheckNonce, FrameSystemExtensionsCheckSpecVersion, FrameSystemExtensionsCheckWeight, FrameSystemLastRuntimeUpgradeInfo, FrameSystemLimitsBlockLength, FrameSystemLimitsBlockWeights, FrameSystemLimitsWeightsPerClass, FrameSystemPhase, OpalRuntimeRuntime, OrmlVestingModuleCall, OrmlVestingModuleError, OrmlVestingModuleEvent, OrmlVestingVestingSchedule, PalletBalancesAccountData, PalletBalancesBalanceLock, PalletBalancesCall, PalletBalancesError, PalletBalancesEvent, PalletBalancesReasons, PalletBalancesReleases, PalletBalancesReserveData, PalletCommonError, PalletCommonEvent, PalletEthereumCall, PalletEthereumError, PalletEthereumEvent, PalletEthereumFakeTransactionFinalizer, PalletEvmAccountBasicCrossAccountIdRepr, PalletEvmCall, PalletEvmCoderSubstrateError, PalletEvmContractHelpersError, PalletEvmContractHelpersSponsoringModeT, PalletEvmError, PalletEvmEvent, PalletEvmMigrationCall, PalletEvmMigrationError, PalletFungibleError, PalletInflationCall, PalletNonfungibleError, PalletNonfungibleItemData, PalletRefungibleError, PalletRefungibleItemData, PalletStructureCall, PalletStructureError, PalletStructureEvent, PalletSudoCall, PalletSudoError, PalletSudoEvent, PalletTemplateTransactionPaymentCall, PalletTemplateTransactionPaymentChargeTransactionPayment, PalletTimestampCall, PalletTransactionPaymentReleases, PalletTreasuryCall, PalletTreasuryError, PalletTreasuryEvent, PalletTreasuryProposal, PalletUniqueCall, PalletUniqueError, PalletUniqueRawEvent, PalletXcmCall, PalletXcmError, PalletXcmEvent, PhantomTypeUpDataStructs, PolkadotCorePrimitivesInboundDownwardMessage, PolkadotCorePrimitivesInboundHrmpMessage, PolkadotCorePrimitivesOutboundHrmpMessage, PolkadotParachainPrimitivesXcmpMessageFormat, PolkadotPrimitivesV2AbridgedHostConfiguration, PolkadotPrimitivesV2AbridgedHrmpChannel, PolkadotPrimitivesV2PersistedValidationData, PolkadotPrimitivesV2UpgradeRestriction, SpCoreEcdsaSignature, SpCoreEd25519Signature, SpCoreSr25519Signature, SpRuntimeArithmeticError, SpRuntimeDigest, SpRuntimeDigestDigestItem, SpRuntimeDispatchError, SpRuntimeModuleError, SpRuntimeMultiSignature, SpRuntimeTokenError, SpRuntimeTransactionalError, SpTrieStorageProof, SpVersionRuntimeVersion, UpDataStructsAccessMode, UpDataStructsCollection, UpDataStructsCollectionLimits, UpDataStructsCollectionMode, UpDataStructsCollectionPermissions, UpDataStructsCollectionStats, UpDataStructsCreateCollectionData, UpDataStructsCreateFungibleData, UpDataStructsCreateItemData, UpDataStructsCreateItemExData, UpDataStructsCreateNftData, UpDataStructsCreateNftExData, UpDataStructsCreateReFungibleData, UpDataStructsCreateRefungibleExData, UpDataStructsNestingRule, UpDataStructsProperties, UpDataStructsPropertiesMapBoundedVec, UpDataStructsPropertiesMapPropertyPermission, UpDataStructsProperty, UpDataStructsPropertyKeyPermission, UpDataStructsPropertyPermission, UpDataStructsRmrkAccountIdOrCollectionNftTuple, UpDataStructsRmrkBaseInfo, UpDataStructsRmrkBasicResource, UpDataStructsRmrkCollectionInfo, UpDataStructsRmrkComposableResource, UpDataStructsRmrkEquippableList, UpDataStructsRmrkFixedPart, UpDataStructsRmrkNftChild, UpDataStructsRmrkNftInfo, UpDataStructsRmrkPartType, UpDataStructsRmrkPropertyInfo, UpDataStructsRmrkResourceInfo, UpDataStructsRmrkResourceTypes, UpDataStructsRmrkRoyaltyInfo, UpDataStructsRmrkSlotPart, UpDataStructsRmrkSlotResource, UpDataStructsRmrkTheme, UpDataStructsRmrkThemeProperty, UpDataStructsRpcCollection, UpDataStructsSponsoringRateLimit, UpDataStructsSponsorshipState, UpDataStructsTokenChild, UpDataStructsTokenData, XcmDoubleEncoded, XcmV0Junction, XcmV0JunctionBodyId, XcmV0JunctionBodyPart, XcmV0JunctionNetworkId, XcmV0MultiAsset, XcmV0MultiLocation, XcmV0Order, XcmV0OriginKind, XcmV0Response, XcmV0Xcm, XcmV1Junction, XcmV1MultiAsset, XcmV1MultiLocation, XcmV1MultiassetAssetId, XcmV1MultiassetAssetInstance, XcmV1MultiassetFungibility, XcmV1MultiassetMultiAssetFilter, XcmV1MultiassetMultiAssets, XcmV1MultiassetWildFungibility, XcmV1MultiassetWildMultiAsset, XcmV1MultilocationJunctions, XcmV1Order, XcmV1Response, XcmV1Xcm, XcmV2Instruction, XcmV2Response, XcmV2TraitsError, XcmV2TraitsOutcome, XcmV2WeightLimit, XcmV2Xcm, XcmVersionedMultiAssets, XcmVersionedMultiLocation, XcmVersionedXcm } from '@polkadot/types/lookup';
declare module '@polkadot/types/types/registry' {
export interface InterfaceTypes {
@@ -188,6 +188,7 @@
UpDataStructsRpcCollection: UpDataStructsRpcCollection;
UpDataStructsSponsoringRateLimit: UpDataStructsSponsoringRateLimit;
UpDataStructsSponsorshipState: UpDataStructsSponsorshipState;
+ UpDataStructsTokenChild: UpDataStructsTokenChild;
UpDataStructsTokenData: UpDataStructsTokenData;
XcmDoubleEncoded: XcmDoubleEncoded;
XcmV0Junction: XcmV0Junction;
tests/src/interfaces/types-lookup.tsdiffbeforeafterboth--- a/tests/src/interfaces/types-lookup.ts
+++ b/tests/src/interfaces/types-lookup.ts
@@ -1604,16 +1604,15 @@
/** @name UpDataStructsCreateNftData (186) */
export interface UpDataStructsCreateNftData extends Struct {
- readonly constData: Bytes;
readonly properties: Vec<UpDataStructsProperty>;
}
- /** @name UpDataStructsCreateFungibleData (188) */
+ /** @name UpDataStructsCreateFungibleData (187) */
export interface UpDataStructsCreateFungibleData extends Struct {
readonly value: u128;
}
- /** @name UpDataStructsCreateReFungibleData (189) */
+ /** @name UpDataStructsCreateReFungibleData (188) */
export interface UpDataStructsCreateReFungibleData extends Struct {
readonly constData: Bytes;
readonly pieces: u128;
@@ -2469,16 +2468,22 @@
readonly alive: u32;
}
- /** @name PhantomTypeUpDataStructs (323) */
- export interface PhantomTypeUpDataStructs extends Vec<ITuple<[UpDataStructsTokenData, UpDataStructsRpcCollection, PalletEvmAccountBasicCrossAccountIdRepr, UpDataStructsRmrkCollectionInfo, UpDataStructsRmrkNftInfo, UpDataStructsRmrkResourceInfo, UpDataStructsRmrkPropertyInfo, UpDataStructsRmrkBaseInfo, UpDataStructsRmrkPartType, UpDataStructsRmrkTheme, UpDataStructsRmrkNftChild]>> {}
+ /** @name UpDataStructsTokenChild (323) */
+ export interface UpDataStructsTokenChild extends Struct {
+ readonly token: u32;
+ readonly collection: u32;
+ }
+
+ /** @name PhantomTypeUpDataStructs (324) */
+ export interface PhantomTypeUpDataStructs extends Vec<ITuple<[UpDataStructsTokenData, UpDataStructsRpcCollection, UpDataStructsRmrkCollectionInfo, UpDataStructsRmrkNftInfo, UpDataStructsRmrkResourceInfo, UpDataStructsRmrkPropertyInfo, UpDataStructsRmrkBaseInfo, UpDataStructsRmrkPartType, UpDataStructsRmrkTheme, UpDataStructsRmrkNftChild]>> {}
- /** @name UpDataStructsTokenData (325) */
+ /** @name UpDataStructsTokenData (326) */
export interface UpDataStructsTokenData extends Struct {
readonly properties: Vec<UpDataStructsProperty>;
readonly owner: Option<PalletEvmAccountBasicCrossAccountIdRepr>;
}
- /** @name UpDataStructsRpcCollection (327) */
+ /** @name UpDataStructsRpcCollection (328) */
export interface UpDataStructsRpcCollection extends Struct {
readonly owner: AccountId32;
readonly mode: UpDataStructsCollectionMode;
@@ -2492,7 +2497,7 @@
readonly properties: Vec<UpDataStructsProperty>;
}
- /** @name UpDataStructsRmrkCollectionInfo (328) */
+ /** @name UpDataStructsRmrkCollectionInfo (329) */
export interface UpDataStructsRmrkCollectionInfo extends Struct {
readonly issuer: AccountId32;
readonly metadata: Bytes;
@@ -2501,7 +2506,7 @@
readonly nftsCount: u32;
}
- /** @name UpDataStructsRmrkNftInfo (331) */
+ /** @name UpDataStructsRmrkNftInfo (332) */
export interface UpDataStructsRmrkNftInfo extends Struct {
readonly owner: UpDataStructsRmrkAccountIdOrCollectionNftTuple;
readonly royalty: Option<UpDataStructsRmrkRoyaltyInfo>;
@@ -2510,7 +2515,7 @@
readonly pending: bool;
}
- /** @name UpDataStructsRmrkAccountIdOrCollectionNftTuple (332) */
+ /** @name UpDataStructsRmrkAccountIdOrCollectionNftTuple (333) */
export interface UpDataStructsRmrkAccountIdOrCollectionNftTuple extends Enum {
readonly isAccountId: boolean;
readonly asAccountId: AccountId32;
@@ -2519,13 +2524,13 @@
readonly type: 'AccountId' | 'CollectionAndNftTuple';
}
- /** @name UpDataStructsRmrkRoyaltyInfo (334) */
+ /** @name UpDataStructsRmrkRoyaltyInfo (335) */
export interface UpDataStructsRmrkRoyaltyInfo extends Struct {
readonly recipient: AccountId32;
readonly amount: Permill;
}
- /** @name UpDataStructsRmrkResourceInfo (335) */
+ /** @name UpDataStructsRmrkResourceInfo (336) */
export interface UpDataStructsRmrkResourceInfo extends Struct {
readonly id: Bytes;
readonly resource: UpDataStructsRmrkResourceTypes;
@@ -2533,7 +2538,7 @@
readonly pendingRemoval: bool;
}
- /** @name UpDataStructsRmrkResourceTypes (338) */
+ /** @name UpDataStructsRmrkResourceTypes (339) */
export interface UpDataStructsRmrkResourceTypes extends Enum {
readonly isBasic: boolean;
readonly asBasic: UpDataStructsRmrkBasicResource;
@@ -2544,7 +2549,7 @@
readonly type: 'Basic' | 'Composable' | 'Slot';
}
- /** @name UpDataStructsRmrkBasicResource (339) */
+ /** @name UpDataStructsRmrkBasicResource (340) */
export interface UpDataStructsRmrkBasicResource extends Struct {
readonly src: Option<Bytes>;
readonly metadata: Option<Bytes>;
@@ -2552,7 +2557,7 @@
readonly thumb: Option<Bytes>;
}
- /** @name UpDataStructsRmrkComposableResource (341) */
+ /** @name UpDataStructsRmrkComposableResource (342) */
export interface UpDataStructsRmrkComposableResource extends Struct {
readonly parts: Vec<u32>;
readonly base: u32;
@@ -2562,7 +2567,7 @@
readonly thumb: Option<Bytes>;
}
- /** @name UpDataStructsRmrkSlotResource (342) */
+ /** @name UpDataStructsRmrkSlotResource (343) */
export interface UpDataStructsRmrkSlotResource extends Struct {
readonly base: u32;
readonly src: Option<Bytes>;
@@ -2572,20 +2577,20 @@
readonly thumb: Option<Bytes>;
}
- /** @name UpDataStructsRmrkPropertyInfo (343) */
+ /** @name UpDataStructsRmrkPropertyInfo (344) */
export interface UpDataStructsRmrkPropertyInfo extends Struct {
readonly key: Bytes;
readonly value: Bytes;
}
- /** @name UpDataStructsRmrkBaseInfo (346) */
+ /** @name UpDataStructsRmrkBaseInfo (347) */
export interface UpDataStructsRmrkBaseInfo extends Struct {
readonly issuer: AccountId32;
readonly baseType: Bytes;
readonly symbol: Bytes;
}
- /** @name UpDataStructsRmrkPartType (347) */
+ /** @name UpDataStructsRmrkPartType (348) */
export interface UpDataStructsRmrkPartType extends Enum {
readonly isFixedPart: boolean;
readonly asFixedPart: UpDataStructsRmrkFixedPart;
@@ -2594,14 +2599,14 @@
readonly type: 'FixedPart' | 'SlotPart';
}
- /** @name UpDataStructsRmrkFixedPart (349) */
+ /** @name UpDataStructsRmrkFixedPart (350) */
export interface UpDataStructsRmrkFixedPart extends Struct {
readonly id: u32;
readonly z: u32;
readonly src: Bytes;
}
- /** @name UpDataStructsRmrkSlotPart (350) */
+ /** @name UpDataStructsRmrkSlotPart (351) */
export interface UpDataStructsRmrkSlotPart extends Struct {
readonly id: u32;
readonly equippable: UpDataStructsRmrkEquippableList;
@@ -2609,7 +2614,7 @@
readonly z: u32;
}
- /** @name UpDataStructsRmrkEquippableList (351) */
+ /** @name UpDataStructsRmrkEquippableList (352) */
export interface UpDataStructsRmrkEquippableList extends Enum {
readonly isAll: boolean;
readonly isEmpty: boolean;
@@ -2618,26 +2623,26 @@
readonly type: 'All' | 'Empty' | 'Custom';
}
- /** @name UpDataStructsRmrkTheme (352) */
+ /** @name UpDataStructsRmrkTheme (353) */
export interface UpDataStructsRmrkTheme extends Struct {
readonly name: Bytes;
readonly properties: Vec<UpDataStructsRmrkThemeProperty>;
readonly inherit: bool;
}
- /** @name UpDataStructsRmrkThemeProperty (354) */
+ /** @name UpDataStructsRmrkThemeProperty (355) */
export interface UpDataStructsRmrkThemeProperty extends Struct {
readonly key: Bytes;
readonly value: Bytes;
}
- /** @name UpDataStructsRmrkNftChild (355) */
+ /** @name UpDataStructsRmrkNftChild (356) */
export interface UpDataStructsRmrkNftChild extends Struct {
readonly collectionId: u32;
readonly nftId: u32;
}
- /** @name PalletCommonError (357) */
+ /** @name PalletCommonError (358) */
export interface PalletCommonError extends Enum {
readonly isCollectionNotFound: boolean;
readonly isMustBeTokenOwner: boolean;
@@ -2675,7 +2680,7 @@
readonly type: 'CollectionNotFound' | 'MustBeTokenOwner' | 'NoPermission' | 'CantDestroyNotEmptyCollection' | 'PublicMintingNotAllowed' | 'AddressNotInAllowlist' | 'CollectionNameLimitExceeded' | 'CollectionDescriptionLimitExceeded' | 'CollectionTokenPrefixLimitExceeded' | 'TotalCollectionsLimitExceeded' | 'CollectionAdminCountExceeded' | 'CollectionLimitBoundsExceeded' | 'OwnerPermissionsCantBeReverted' | 'TransferNotAllowed' | 'AccountTokenLimitExceeded' | 'CollectionTokenLimitExceeded' | 'MetadataFlagFrozen' | 'TokenNotFound' | 'TokenValueTooLow' | 'ApprovedValueTooLow' | 'CantApproveMoreThanOwned' | 'AddressIsZero' | 'UnsupportedOperation' | 'NotSufficientFounds' | 'NestingIsDisabled' | 'OnlyOwnerAllowedToNest' | 'SourceCollectionIsNotAllowedToNest' | 'CollectionFieldSizeExceeded' | 'NoSpaceForProperty' | 'PropertyLimitReached' | 'PropertyKeyIsTooLong' | 'InvalidCharacterInPropertyKey' | 'EmptyPropertyKey';
}
- /** @name PalletFungibleError (359) */
+ /** @name PalletFungibleError (360) */
export interface PalletFungibleError extends Enum {
readonly isNotFungibleDataUsedToMintFungibleCollectionToken: boolean;
readonly isFungibleItemsHaveNoId: boolean;
@@ -2685,12 +2690,12 @@
readonly type: 'NotFungibleDataUsedToMintFungibleCollectionToken' | 'FungibleItemsHaveNoId' | 'FungibleItemsDontHaveData' | 'FungibleDisallowsNesting' | 'SettingPropertiesNotAllowed';
}
- /** @name PalletRefungibleItemData (360) */
+ /** @name PalletRefungibleItemData (361) */
export interface PalletRefungibleItemData extends Struct {
readonly constData: Bytes;
}
- /** @name PalletRefungibleError (364) */
+ /** @name PalletRefungibleError (365) */
export interface PalletRefungibleError extends Enum {
readonly isNotRefungibleDataUsedToMintFungibleCollectionToken: boolean;
readonly isWrongRefungiblePieces: boolean;
@@ -2699,12 +2704,12 @@
readonly type: 'NotRefungibleDataUsedToMintFungibleCollectionToken' | 'WrongRefungiblePieces' | 'RefungibleDisallowsNesting' | 'SettingPropertiesNotAllowed';
}
- /** @name PalletNonfungibleItemData (365) */
+ /** @name PalletNonfungibleItemData (366) */
export interface PalletNonfungibleItemData extends Struct {
readonly owner: PalletEvmAccountBasicCrossAccountIdRepr;
}
- /** @name PalletNonfungibleError (367) */
+ /** @name PalletNonfungibleError (368) */
export interface PalletNonfungibleError extends Enum {
readonly isNotNonfungibleDataUsedToMintFungibleCollectionToken: boolean;
readonly isNonfungibleItemsHaveNoAmount: boolean;
@@ -2712,7 +2717,7 @@
readonly type: 'NotNonfungibleDataUsedToMintFungibleCollectionToken' | 'NonfungibleItemsHaveNoAmount' | 'CantBurnNftWithChildren';
}
- /** @name PalletStructureError (368) */
+ /** @name PalletStructureError (369) */
export interface PalletStructureError extends Enum {
readonly isOuroborosDetected: boolean;
readonly isDepthLimit: boolean;
@@ -2720,7 +2725,7 @@
readonly type: 'OuroborosDetected' | 'DepthLimit' | 'TokenNotFound';
}
- /** @name PalletEvmError (371) */
+ /** @name PalletEvmError (372) */
export interface PalletEvmError extends Enum {
readonly isBalanceLow: boolean;
readonly isFeeOverflow: boolean;
@@ -2731,7 +2736,7 @@
readonly type: 'BalanceLow' | 'FeeOverflow' | 'PaymentOverflow' | 'WithdrawFailed' | 'GasPriceTooLow' | 'InvalidNonce';
}
- /** @name FpRpcTransactionStatus (374) */
+ /** @name FpRpcTransactionStatus (375) */
export interface FpRpcTransactionStatus extends Struct {
readonly transactionHash: H256;
readonly transactionIndex: u32;
@@ -2742,10 +2747,10 @@
readonly logsBloom: EthbloomBloom;
}
- /** @name EthbloomBloom (376) */
+ /** @name EthbloomBloom (377) */
export interface EthbloomBloom extends U8aFixed {}
- /** @name EthereumReceiptReceiptV3 (378) */
+ /** @name EthereumReceiptReceiptV3 (379) */
export interface EthereumReceiptReceiptV3 extends Enum {
readonly isLegacy: boolean;
readonly asLegacy: EthereumReceiptEip658ReceiptData;
@@ -2756,7 +2761,7 @@
readonly type: 'Legacy' | 'Eip2930' | 'Eip1559';
}
- /** @name EthereumReceiptEip658ReceiptData (379) */
+ /** @name EthereumReceiptEip658ReceiptData (380) */
export interface EthereumReceiptEip658ReceiptData extends Struct {
readonly statusCode: u8;
readonly usedGas: U256;
@@ -2764,14 +2769,14 @@
readonly logs: Vec<EthereumLog>;
}
- /** @name EthereumBlock (380) */
+ /** @name EthereumBlock (381) */
export interface EthereumBlock extends Struct {
readonly header: EthereumHeader;
readonly transactions: Vec<EthereumTransactionTransactionV2>;
readonly ommers: Vec<EthereumHeader>;
}
- /** @name EthereumHeader (381) */
+ /** @name EthereumHeader (382) */
export interface EthereumHeader extends Struct {
readonly parentHash: H256;
readonly ommersHash: H256;
@@ -2790,24 +2795,24 @@
readonly nonce: EthereumTypesHashH64;
}
- /** @name EthereumTypesHashH64 (382) */
+ /** @name EthereumTypesHashH64 (383) */
export interface EthereumTypesHashH64 extends U8aFixed {}
- /** @name PalletEthereumError (387) */
+ /** @name PalletEthereumError (388) */
export interface PalletEthereumError extends Enum {
readonly isInvalidSignature: boolean;
readonly isPreLogExists: boolean;
readonly type: 'InvalidSignature' | 'PreLogExists';
}
- /** @name PalletEvmCoderSubstrateError (388) */
+ /** @name PalletEvmCoderSubstrateError (389) */
export interface PalletEvmCoderSubstrateError extends Enum {
readonly isOutOfGas: boolean;
readonly isOutOfFund: boolean;
readonly type: 'OutOfGas' | 'OutOfFund';
}
- /** @name PalletEvmContractHelpersSponsoringModeT (389) */
+ /** @name PalletEvmContractHelpersSponsoringModeT (390) */
export interface PalletEvmContractHelpersSponsoringModeT extends Enum {
readonly isDisabled: boolean;
readonly isAllowlisted: boolean;
@@ -2815,20 +2820,20 @@
readonly type: 'Disabled' | 'Allowlisted' | 'Generous';
}
- /** @name PalletEvmContractHelpersError (391) */
+ /** @name PalletEvmContractHelpersError (392) */
export interface PalletEvmContractHelpersError extends Enum {
readonly isNoPermission: boolean;
readonly type: 'NoPermission';
}
- /** @name PalletEvmMigrationError (392) */
+ /** @name PalletEvmMigrationError (393) */
export interface PalletEvmMigrationError extends Enum {
readonly isAccountNotEmpty: boolean;
readonly isAccountIsNotMigrating: boolean;
readonly type: 'AccountNotEmpty' | 'AccountIsNotMigrating';
}
- /** @name SpRuntimeMultiSignature (394) */
+ /** @name SpRuntimeMultiSignature (395) */
export interface SpRuntimeMultiSignature extends Enum {
readonly isEd25519: boolean;
readonly asEd25519: SpCoreEd25519Signature;
@@ -2839,34 +2844,34 @@
readonly type: 'Ed25519' | 'Sr25519' | 'Ecdsa';
}
- /** @name SpCoreEd25519Signature (395) */
+ /** @name SpCoreEd25519Signature (396) */
export interface SpCoreEd25519Signature extends U8aFixed {}
- /** @name SpCoreSr25519Signature (397) */
+ /** @name SpCoreSr25519Signature (398) */
export interface SpCoreSr25519Signature extends U8aFixed {}
- /** @name SpCoreEcdsaSignature (398) */
+ /** @name SpCoreEcdsaSignature (399) */
export interface SpCoreEcdsaSignature extends U8aFixed {}
- /** @name FrameSystemExtensionsCheckSpecVersion (401) */
+ /** @name FrameSystemExtensionsCheckSpecVersion (402) */
export type FrameSystemExtensionsCheckSpecVersion = Null;
- /** @name FrameSystemExtensionsCheckGenesis (402) */
+ /** @name FrameSystemExtensionsCheckGenesis (403) */
export type FrameSystemExtensionsCheckGenesis = Null;
- /** @name FrameSystemExtensionsCheckNonce (405) */
+ /** @name FrameSystemExtensionsCheckNonce (406) */
export interface FrameSystemExtensionsCheckNonce extends Compact<u32> {}
- /** @name FrameSystemExtensionsCheckWeight (406) */
+ /** @name FrameSystemExtensionsCheckWeight (407) */
export type FrameSystemExtensionsCheckWeight = Null;
- /** @name PalletTemplateTransactionPaymentChargeTransactionPayment (407) */
+ /** @name PalletTemplateTransactionPaymentChargeTransactionPayment (408) */
export interface PalletTemplateTransactionPaymentChargeTransactionPayment extends Compact<u128> {}
- /** @name OpalRuntimeRuntime (408) */
+ /** @name OpalRuntimeRuntime (409) */
export type OpalRuntimeRuntime = Null;
- /** @name PalletEthereumFakeTransactionFinalizer (409) */
+ /** @name PalletEthereumFakeTransactionFinalizer (410) */
export type PalletEthereumFakeTransactionFinalizer = Null;
} // declare module
tests/src/interfaces/unique/definitions.tsdiffbeforeafterboth--- a/tests/src/interfaces/unique/definitions.ts
+++ b/tests/src/interfaces/unique/definitions.ts
@@ -50,6 +50,7 @@
allowance: fun('Get allowed amount', [collectionParam, crossAccountParam('sender'), crossAccountParam('spender'), tokenParam], 'u128'),
tokenOwner: fun('Get token owner', [collectionParam, tokenParam], `Option<${CROSS_ACCOUNT_ID_TYPE}>`),
topmostTokenOwner: fun('Get token owner, in case of nested token - find parent recursive', [collectionParam, tokenParam], `Option<${CROSS_ACCOUNT_ID_TYPE}>`),
+ tokenChildren: fun('Get tokens nested directly into the token', [collectionParam, tokenParam], 'Vec<UpDataStructsTokenChild>'),
constMetadata: fun('Get token constant metadata', [collectionParam, tokenParam], 'Vec<u8>'),
variableMetadata: fun('Get token variable metadata', [collectionParam, tokenParam], 'Vec<u8>'),
collectionProperties: fun(
tests/src/nesting/nest.test.tsdiffbeforeafterboth--- a/tests/src/nesting/nest.test.ts
+++ b/tests/src/nesting/nest.test.ts
@@ -7,6 +7,7 @@
createItemExpectSuccess,
enableAllowListExpectSuccess,
enablePublicMintingExpectSuccess,
+ getTokenChildren,
getTokenOwner,
getTopmostTokenOwner,
normalizeAccountId,
@@ -76,8 +77,8 @@
api,
alice,
api.tx.unique.transferFrom(
- normalizeAccountId({Ethereum: tokenIdToAddress(collection, tokenA)}),
- normalizeAccountId({Ethereum: tokenIdToAddress(collection, tokenB)}),
+ normalizeAccountId({Ethereum: tokenIdToAddress(collection, tokenA)}),
+ normalizeAccountId({Ethereum: tokenIdToAddress(collection, tokenB)}),
collection,
tokenC,
1,
@@ -88,6 +89,63 @@
});
});
+ it('Checks token children', async () => {
+ await usingApi(async api => {
+ const collectionA = await createCollectionExpectSuccess({mode: {type: 'NFT'}});
+ await setCollectionPermissionsExpectSuccess(alice, collectionA, {nesting: 'Owner'});
+ const collectionB = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});
+
+ const targetToken = await createItemExpectSuccess(alice, collectionA, 'NFT');
+ const targetAddress = {Ethereum: tokenIdToAddress(collectionA, targetToken)};
+ let children = await getTokenChildren(api, collectionA, targetToken);
+ expect(children.length).to.be.equal(0, 'Children length check at creation');
+
+ // Create a nested NFT token
+ const tokenA = await createItemExpectSuccess(alice, collectionA, 'NFT', targetAddress);
+ children = await getTokenChildren(api, collectionA, targetToken);
+ expect(children.length).to.be.equal(1, 'Children length check at nesting #1');
+ expect(children).to.have.deep.members([
+ {token: tokenA, collection: collectionA},
+ ], 'Children contents check at nesting #1');
+
+ // Create then nest
+ const tokenB = await createItemExpectSuccess(alice, collectionA, 'NFT');
+ await transferExpectSuccess(collectionA, tokenB, alice, targetAddress);
+ children = await getTokenChildren(api, collectionA, targetToken);
+ expect(children.length).to.be.equal(2, 'Children length check at nesting #2');
+ expect(children).to.have.deep.members([
+ {token: tokenA, collection: collectionA},
+ {token: tokenB, collection: collectionA},
+ ], 'Children contents check at nesting #2');
+
+ // Move token B to a different user outside the nesting tree
+ await transferExpectSuccess(collectionA, tokenB, alice, bob);
+ children = await getTokenChildren(api, collectionA, targetToken);
+ expect(children.length).to.be.equal(1, 'Children length check at unnesting');
+ expect(children).to.be.have.deep.members([
+ {token: tokenA, collection: collectionA},
+ ], 'Children contents check at unnesting');
+
+ // Create a fungible token in another collection and then nest
+ const tokenC = await createItemExpectSuccess(alice, collectionB, 'Fungible');
+ await transferExpectSuccess(collectionB, tokenC, alice, targetAddress, 1, 'Fungible');
+ children = await getTokenChildren(api, collectionA, targetToken);
+ expect(children.length).to.be.equal(2, 'Children length check at nesting #3 (from another collection)');
+ expect(children).to.be.have.deep.members([
+ {token: tokenA, collection: collectionA},
+ {token: tokenC, collection: collectionB},
+ ], 'Children contents check at nesting #3 (from another collection)');
+
+ // Move the fungible token inside token A deeper in the nesting tree
+ await transferFromExpectSuccess(collectionB, tokenC, alice, targetAddress, {Ethereum: tokenIdToAddress(collectionA, tokenA)}, 1, 'Fungible');
+ children = await getTokenChildren(api, collectionA, targetToken);
+ expect(children.length).to.be.equal(1, 'Children length check at deeper nesting');
+ expect(children).to.be.have.deep.members([
+ {token: tokenA, collection: collectionA},
+ ], 'Children contents check at deeper nesting');
+ });
+ });
+
// ---------- Non-Fungible ----------
it('NFT: allows an Owner to nest/unnest their token', async () => {
tests/src/util/helpers.tsdiffbeforeafterboth--- a/tests/src/util/helpers.ts
+++ b/tests/src/util/helpers.ts
@@ -27,6 +27,7 @@
import {default as usingApi, executeTransaction, submitTransactionAsync, submitTransactionExpectFailAsync} from '../substrate/substrate-api';
import {hexToStr, strToUTF16, utf16ToStr} from './util';
import {UpDataStructsRpcCollection, UpDataStructsCreateItemData, UpDataStructsProperty} from '@polkadot/types/lookup';
+import {UpDataStructsTokenChild} from '../interfaces';
chai.use(chaiAsPromised);
const expect = chai.expect;
@@ -1165,6 +1166,13 @@
if (owner == null) throw new Error('owner == null');
return normalizeAccountId(owner);
}
+export async function getTokenChildren(
+ api: ApiPromise,
+ collectionId: number,
+ tokenId: number,
+): Promise<UpDataStructsTokenChild[]> {
+ return (await api.rpc.unique.tokenChildren(collectionId, tokenId)).toJSON() as any;
+}
export async function isTokenExists(
api: ApiPromise,
collectionId: number,