--- a/pallets/nft/src/lib.rs +++ b/pallets/nft/src/lib.rs @@ -48,6 +48,9 @@ // Structs // #region +pub type CollectionId = u32; +pub type TokenId = u32; + #[derive(Encode, Decode, Eq, Debug, Clone, PartialEq)] #[cfg_attr(feature = "std", derive(Serialize, Deserialize))] pub enum CollectionMode { @@ -116,7 +119,7 @@ #[derive(Encode, Decode, Default, Debug, Clone, PartialEq)] #[cfg_attr(feature = "std", derive(Serialize, Deserialize))] pub struct NftItemType { - pub collection: u64, + pub collection: CollectionId, pub owner: AccountId, pub const_data: Vec, pub variable_data: Vec, @@ -125,7 +128,7 @@ #[derive(Encode, Decode, Default, Debug, Clone, PartialEq)] #[cfg_attr(feature = "std", derive(Serialize, Deserialize))] pub struct FungibleItemType { - pub collection: u64, + pub collection: CollectionId, pub owner: AccountId, pub value: u128, } @@ -133,7 +136,7 @@ #[derive(Encode, Decode, Default, Debug, Clone, PartialEq)] #[cfg_attr(feature = "std", derive(Serialize, Deserialize))] pub struct ReFungibleItemType { - pub collection: u64, + pub collection: CollectionId, pub owner: Vec>, pub const_data: Vec, pub variable_data: Vec, @@ -151,8 +154,8 @@ pub struct VestingItem { pub sender: AccountId, pub recipient: AccountId, - pub collection_id: u64, - pub item_id: u64, + pub collection_id: CollectionId, + pub item_id: TokenId, pub amount: u64, pub vesting_date: Moment, } @@ -167,8 +170,8 @@ #[derive(Encode, Decode, Default, Debug, Clone, PartialEq)] #[cfg_attr(feature = "std", derive(Serialize, Deserialize))] pub struct ChainLimits { - pub collection_numbers_limit: u64, - pub account_token_ownership_limit: u64, + pub collection_numbers_limit: u32, + pub account_token_ownership_limit: u32, pub collections_admins_limit: u64, pub custom_data_limit: u32, @@ -341,41 +344,41 @@ trait Store for Module as Nft { // Private members - NextCollectionID: u64; - CreatedCollectionCount: u64; + NextCollectionID: CollectionId; + CreatedCollectionCount: u32; ChainVersion: u64; - ItemListIndex: map hasher(blake2_128_concat) u64 => u64; + ItemListIndex: map hasher(blake2_128_concat) CollectionId => TokenId; // Chain limits struct pub ChainLimit get(fn chain_limit) config(): ChainLimits; // Bound counters - CollectionCount: u64; - pub AccountItemCount get(fn account_item_count): map hasher(identity) T::AccountId => u64; + CollectionCount: u32; + pub AccountItemCount get(fn account_item_count): map hasher(identity) T::AccountId => u32; // Basic collections - pub Collection get(fn collection) config(): map hasher(identity) u64 => CollectionType; - pub AdminList get(fn admin_list_collection): map hasher(identity) u64 => Vec; - pub WhiteList get(fn white_list): map hasher(identity) u64 => Vec; + pub Collection get(fn collection) config(): map hasher(identity) CollectionId => CollectionType; + pub AdminList get(fn admin_list_collection): map hasher(identity) CollectionId => Vec; + pub WhiteList get(fn white_list): map hasher(identity) CollectionId => Vec; /// Balance owner per collection map - pub Balance get(fn balance_count): double_map hasher(blake2_128_concat) u64, hasher(blake2_128_concat) T::AccountId => u64; + pub Balance get(fn balance_count): double_map hasher(blake2_128_concat) CollectionId, hasher(blake2_128_concat) T::AccountId => u64; /// second parameter: item id + owner account id - pub ApprovedList get(fn approved): double_map hasher(blake2_128_concat) u64, hasher(blake2_128_concat) (u64, T::AccountId) => Vec>; + pub ApprovedList get(fn approved): double_map hasher(blake2_128_concat) CollectionId, hasher(blake2_128_concat) (TokenId, T::AccountId) => Vec>; /// Item collections - pub NftItemList get(fn nft_item_id) config(): double_map hasher(blake2_128_concat) u64, hasher(blake2_128_concat) u64 => NftItemType; - pub FungibleItemList get(fn fungible_item_id) config(): double_map hasher(blake2_128_concat) u64, hasher(blake2_128_concat) u64 => FungibleItemType; - pub ReFungibleItemList get(fn refungible_item_id) config(): double_map hasher(blake2_128_concat) u64, hasher(blake2_128_concat) u64 => ReFungibleItemType; + pub NftItemList get(fn nft_item_id) config(): double_map hasher(blake2_128_concat) CollectionId, hasher(blake2_128_concat) TokenId => NftItemType; + pub FungibleItemList get(fn fungible_item_id) config(): double_map hasher(blake2_128_concat) CollectionId, hasher(blake2_128_concat) TokenId => FungibleItemType; + pub ReFungibleItemList get(fn refungible_item_id) config(): double_map hasher(blake2_128_concat) CollectionId, hasher(blake2_128_concat) TokenId => ReFungibleItemType; /// Index list - pub AddressTokens get(fn address_tokens): double_map hasher(blake2_128_concat) u64, hasher(blake2_128_concat) T::AccountId => Vec; + pub AddressTokens get(fn address_tokens): double_map hasher(blake2_128_concat) CollectionId, hasher(blake2_128_concat) T::AccountId => Vec; /// Tokens transfer baskets - pub NftTransferBasket get(fn nft_transfer_basket): double_map hasher(blake2_128_concat) u64, hasher(blake2_128_concat) u64 => T::BlockNumber; - pub FungibleTransferBasket get(fn fungible_transfer_basket): double_map hasher(blake2_128_concat) u64, hasher(blake2_128_concat) u64 => Vec>; - pub ReFungibleTransferBasket get(fn refungible_transfer_basket): double_map hasher(blake2_128_concat) u64, hasher(blake2_128_concat) u64 => T::BlockNumber; + pub NftTransferBasket get(fn nft_transfer_basket): double_map hasher(blake2_128_concat) CollectionId, hasher(blake2_128_concat) TokenId => T::BlockNumber; + pub FungibleTransferBasket get(fn fungible_transfer_basket): double_map hasher(blake2_128_concat) CollectionId, hasher(blake2_128_concat) TokenId => Vec>; + pub ReFungibleTransferBasket get(fn refungible_transfer_basket): double_map hasher(blake2_128_concat) CollectionId, hasher(blake2_128_concat) TokenId => T::BlockNumber; // Contract Sponsorship and Ownership pub ContractOwner get(fn contract_owner): map hasher(twox_64_concat) T::AccountId => T::AccountId; @@ -419,7 +422,7 @@ /// * mode: [CollectionMode] converted into u8. /// /// * account_id: Collection owner. - Created(u64, u8, AccountId), + Created(CollectionId, u8, AccountId), /// New item was created. /// @@ -428,7 +431,7 @@ /// * collection_id: Id of the collection where item was created. /// /// * item_id: Id of an item. Unique within the collection. - ItemCreated(u64, u64), + ItemCreated(CollectionId, TokenId), /// Collection item was burned. /// @@ -437,7 +440,7 @@ /// collection_id. /// /// item_id: Identifier of burned NFT. - ItemDestroyed(u64, u64), + ItemDestroyed(CollectionId, TokenId), } ); @@ -558,7 +561,7 @@ /// /// * collection_id: collection to destroy. #[weight = T::WeightInfo::destroy_collection()] - pub fn destroy_collection(origin, collection_id: u64) -> DispatchResult { + pub fn destroy_collection(origin, collection_id: CollectionId) -> DispatchResult { let sender = ensure_signed(origin)?; Self::check_owner_permissions(collection_id, sender)?; @@ -605,7 +608,7 @@ /// /// * address. #[weight = T::WeightInfo::add_to_white_list()] - pub fn add_to_white_list(origin, collection_id: u64, address: T::AccountId) -> DispatchResult{ + pub fn add_to_white_list(origin, collection_id: CollectionId, address: T::AccountId) -> DispatchResult{ let sender = ensure_signed(origin)?; Self::check_owner_or_admin_permissions(collection_id, sender)?; @@ -640,7 +643,7 @@ /// /// * address. #[weight = T::WeightInfo::remove_from_white_list()] - pub fn remove_from_white_list(origin, collection_id: u64, address: T::AccountId) -> DispatchResult{ + pub fn remove_from_white_list(origin, collection_id: CollectionId, address: T::AccountId) -> DispatchResult{ let sender = ensure_signed(origin)?; Self::check_owner_or_admin_permissions(collection_id, sender)?; @@ -669,7 +672,7 @@ /// /// * mode: [AccessMode] #[weight = T::WeightInfo::set_public_access_mode()] - pub fn set_public_access_mode(origin, collection_id: u64, mode: AccessMode) -> DispatchResult + pub fn set_public_access_mode(origin, collection_id: CollectionId, mode: AccessMode) -> DispatchResult { let sender = ensure_signed(origin)?; @@ -695,7 +698,7 @@ /// /// * mint_permission: Boolean parameter. If True, allows minting to Anyone with conditions above. #[weight = T::WeightInfo::set_mint_permission()] - pub fn set_mint_permission(origin, collection_id: u64, mint_permission: bool) -> DispatchResult + pub fn set_mint_permission(origin, collection_id: CollectionId, mint_permission: bool) -> DispatchResult { let sender = ensure_signed(origin)?; @@ -719,7 +722,7 @@ /// /// * new_owner. #[weight = T::WeightInfo::change_collection_owner()] - pub fn change_collection_owner(origin, collection_id: u64, new_owner: T::AccountId) -> DispatchResult { + pub fn change_collection_owner(origin, collection_id: CollectionId, new_owner: T::AccountId) -> DispatchResult { let sender = ensure_signed(origin)?; Self::check_owner_permissions(collection_id, sender)?; @@ -744,7 +747,7 @@ /// /// * new_admin_id: Address of new admin to add. #[weight = T::WeightInfo::add_collection_admin()] - pub fn add_collection_admin(origin, collection_id: u64, new_admin_id: T::AccountId) -> DispatchResult { + pub fn add_collection_admin(origin, collection_id: CollectionId, new_admin_id: T::AccountId) -> DispatchResult { let sender = ensure_signed(origin)?; Self::check_owner_or_admin_permissions(collection_id, sender)?; @@ -778,7 +781,7 @@ /// /// * account_id: Address of admin to remove. #[weight = T::WeightInfo::remove_collection_admin()] - pub fn remove_collection_admin(origin, collection_id: u64, account_id: T::AccountId) -> DispatchResult { + pub fn remove_collection_admin(origin, collection_id: CollectionId, account_id: T::AccountId) -> DispatchResult { let sender = ensure_signed(origin)?; Self::check_owner_or_admin_permissions(collection_id, sender)?; @@ -803,7 +806,7 @@ /// /// * new_sponsor. #[weight = T::WeightInfo::set_collection_sponsor()] - pub fn set_collection_sponsor(origin, collection_id: u64, new_sponsor: T::AccountId) -> DispatchResult { + pub fn set_collection_sponsor(origin, collection_id: CollectionId, new_sponsor: T::AccountId) -> DispatchResult { let sender = ensure_signed(origin)?; ensure!(>::contains_key(collection_id), Error::::CollectionNotFound); @@ -825,7 +828,7 @@ /// /// * collection_id. #[weight = T::WeightInfo::confirm_sponsorship()] - pub fn confirm_sponsorship(origin, collection_id: u64) -> DispatchResult { + pub fn confirm_sponsorship(origin, collection_id: CollectionId) -> DispatchResult { let sender = ensure_signed(origin)?; ensure!(>::contains_key(collection_id), Error::::CollectionNotFound); @@ -850,7 +853,7 @@ /// /// * collection_id. #[weight = T::WeightInfo::remove_collection_sponsor()] - pub fn remove_collection_sponsor(origin, collection_id: u64) -> DispatchResult { + pub fn remove_collection_sponsor(origin, collection_id: CollectionId) -> DispatchResult { let sender = ensure_signed(origin)?; ensure!(>::contains_key(collection_id), Error::::CollectionNotFound); @@ -889,7 +892,7 @@ // .saturating_add(RocksDbWeight::get().writes(8 as Weight))] #[weight = T::WeightInfo::create_item(data.len())] - pub fn create_item(origin, collection_id: u64, owner: T::AccountId, data: CreateItemData) -> DispatchResult { + pub fn create_item(origin, collection_id: CollectionId, owner: T::AccountId, data: CreateItemData) -> DispatchResult { let sender = ensure_signed(origin)?; @@ -925,7 +928,7 @@ #[weight = T::WeightInfo::create_item(items_data.into_iter() .map(|data| { data.len() }) .sum())] - pub fn create_multiple_items(origin, collection_id: u64, owner: T::AccountId, items_data: Vec) -> DispatchResult { + pub fn create_multiple_items(origin, collection_id: CollectionId, owner: T::AccountId, items_data: Vec) -> DispatchResult { ensure!(items_data.len() > 0, Error::::EmptyArgument); let sender = ensure_signed(origin)?; @@ -959,7 +962,7 @@ /// /// * item_id: ID of NFT to burn. #[weight = T::WeightInfo::burn_item()] - pub fn burn_item(origin, collection_id: u64, item_id: u64) -> DispatchResult { + pub fn burn_item(origin, collection_id: CollectionId, item_id: TokenId) -> DispatchResult { let sender = ensure_signed(origin)?; Self::collection_exists(collection_id)?; @@ -1012,7 +1015,7 @@ /// * Fungible Mode: Must specify transferred amount /// * Re-Fungible Mode: Must specify transferred portion (between 0 and 1) #[weight = T::WeightInfo::transfer()] - pub fn transfer(origin, recipient: T::AccountId, collection_id: u64, item_id: u64, value: u64) -> DispatchResult { + pub fn transfer(origin, recipient: T::AccountId, collection_id: CollectionId, item_id: TokenId, value: u64) -> DispatchResult { let sender = ensure_signed(origin)?; @@ -1054,7 +1057,7 @@ /// /// * item_id: ID of the item. #[weight = T::WeightInfo::approve()] - pub fn approve(origin, approved: T::AccountId, collection_id: u64, item_id: u64) -> DispatchResult { + pub fn approve(origin, approved: T::AccountId, collection_id: CollectionId, item_id: TokenId) -> DispatchResult { let sender = ensure_signed(origin)?; @@ -1112,7 +1115,7 @@ /// /// * value: Amount to transfer. #[weight = T::WeightInfo::transfer_from()] - pub fn transfer_from(origin, from: T::AccountId, recipient: T::AccountId, collection_id: u64, item_id: u64, value: u64 ) -> DispatchResult { + pub fn transfer_from(origin, from: T::AccountId, recipient: T::AccountId, collection_id: CollectionId, item_id: TokenId, value: u64 ) -> DispatchResult { let sender = ensure_signed(origin)?; let mut appoved_transfer = false; @@ -1157,7 +1160,7 @@ /// #[weight = 0] - pub fn safe_transfer_from(origin, collection_id: u64, item_id: u64, new_owner: T::AccountId) -> DispatchResult { + pub fn safe_transfer_from(origin, collection_id: CollectionId, item_id: TokenId, new_owner: T::AccountId) -> DispatchResult { // let no_perm_mes = "You do not have permissions to modify this collection"; // ensure!(>::contains_key((collection_id, item_id)), no_perm_mes); @@ -1186,8 +1189,8 @@ #[weight = T::WeightInfo::set_variable_meta_data()] pub fn set_variable_meta_data ( origin, - collection_id: u64, - item_id: u64, + collection_id: CollectionId, + item_id: TokenId, data: Vec ) -> DispatchResult { let sender = ensure_signed(origin)?; @@ -1231,7 +1234,7 @@ #[weight = T::WeightInfo::set_offchain_schema()] pub fn set_offchain_schema( origin, - collection_id: u64, + collection_id: CollectionId, schema: Vec ) -> DispatchResult { let sender = ensure_signed(origin)?; @@ -1259,7 +1262,7 @@ #[weight = T::WeightInfo::set_const_on_chain_schema()] pub fn set_const_on_chain_schema ( origin, - collection_id: u64, + collection_id: CollectionId, schema: Vec ) -> DispatchResult { let sender = ensure_signed(origin)?; @@ -1287,7 +1290,7 @@ #[weight = T::WeightInfo::set_const_on_chain_schema()] pub fn set_variable_on_chain_schema ( origin, - collection_id: u64, + collection_id: CollectionId, schema: Vec ) -> DispatchResult { let sender = ensure_signed(origin)?; @@ -1396,7 +1399,7 @@ impl Module { - fn can_create_items_in_collection(collection_id: u64, collection: &CollectionType, sender: &T::AccountId, owner: &T::AccountId) -> DispatchResult { + fn can_create_items_in_collection(collection_id: CollectionId, collection: &CollectionType, sender: &T::AccountId, owner: &T::AccountId) -> DispatchResult { if !Self::is_owner_or_admin_permissions(collection_id, sender.clone()) { ensure!(collection.mint_mode == true, Error::::PublicMintingNotAllowed); @@ -1441,7 +1444,7 @@ Ok(()) } - fn create_item_no_validation(collection_id: u64, collection: &CollectionType, owner: T::AccountId, data: CreateItemData) -> DispatchResult { + fn create_item_no_validation(collection_id: CollectionId, collection: &CollectionType, owner: T::AccountId, data: CreateItemData) -> DispatchResult { match data { CreateItemData::NFT(data) => { @@ -1565,8 +1568,8 @@ } fn burn_refungible_item( - collection_id: u64, - item_id: u64, + collection_id: CollectionId, + item_id: TokenId, owner: T::AccountId, ) -> DispatchResult { ensure!( @@ -1596,7 +1599,7 @@ Ok(()) } - fn burn_nft_item(collection_id: u64, item_id: u64) -> DispatchResult { + fn burn_nft_item(collection_id: CollectionId, item_id: TokenId) -> DispatchResult { ensure!( >::contains_key(collection_id, item_id), Error::::TokenNotFound @@ -1617,7 +1620,7 @@ Ok(()) } - fn burn_fungible_item(collection_id: u64, item_id: u64) -> DispatchResult { + fn burn_fungible_item(collection_id: CollectionId, item_id: TokenId) -> DispatchResult { ensure!( >::contains_key(collection_id, item_id), Error::::TokenNotFound @@ -1639,7 +1642,7 @@ Ok(()) } - fn collection_exists(collection_id: u64) -> DispatchResult { + fn collection_exists(collection_id: CollectionId) -> DispatchResult { ensure!( >::contains_key(collection_id), Error::::CollectionNotFound @@ -1647,7 +1650,7 @@ Ok(()) } - fn check_owner_permissions(collection_id: u64, subject: T::AccountId) -> DispatchResult { + fn check_owner_permissions(collection_id: CollectionId, subject: T::AccountId) -> DispatchResult { Self::collection_exists(collection_id)?; let target_collection = >::get(collection_id); @@ -1659,7 +1662,7 @@ Ok(()) } - fn is_owner_or_admin_permissions(collection_id: u64, subject: T::AccountId) -> bool { + fn is_owner_or_admin_permissions(collection_id: CollectionId, subject: T::AccountId) -> bool { let target_collection = >::get(collection_id); let mut result: bool = subject == target_collection.owner; let exists = >::contains_key(collection_id); @@ -1674,7 +1677,7 @@ } fn check_owner_or_admin_permissions( - collection_id: u64, + collection_id: CollectionId, subject: T::AccountId, ) -> DispatchResult { Self::collection_exists(collection_id)?; @@ -1687,7 +1690,7 @@ Ok(()) } - fn is_item_owner(subject: T::AccountId, collection_id: u64, item_id: u64) -> bool { + fn is_item_owner(subject: T::AccountId, collection_id: CollectionId, item_id: TokenId) -> bool { let target_collection = >::get(collection_id); match target_collection.mode { @@ -1707,7 +1710,7 @@ } } - fn check_white_list(collection_id: u64, address: &T::AccountId) -> DispatchResult { + fn check_white_list(collection_id: CollectionId, address: &T::AccountId) -> DispatchResult { let mes = Error::::AddresNotInWhiteList; ensure!(>::contains_key(collection_id), mes); let wl = >::get(collection_id); @@ -1717,8 +1720,8 @@ } fn transfer_fungible( - collection_id: u64, - item_id: u64, + collection_id: CollectionId, + item_id: TokenId, value: u64, owner: T::AccountId, new_owner: T::AccountId, @@ -1806,8 +1809,8 @@ } fn transfer_refungible( - collection_id: u64, - item_id: u64, + collection_id: CollectionId, + item_id: TokenId, value: u64, owner: T::AccountId, new_owner: T::AccountId, @@ -1892,8 +1895,8 @@ } fn transfer_nft( - collection_id: u64, - item_id: u64, + collection_id: CollectionId, + item_id: TokenId, sender: T::AccountId, new_owner: T::AccountId, ) -> DispatchResult { @@ -1934,8 +1937,8 @@ } fn item_exists( - collection_id: u64, - item_id: u64, + collection_id: CollectionId, + item_id: TokenId, mode: &CollectionMode ) -> DispatchResult { match mode { @@ -1949,8 +1952,8 @@ } fn set_re_fungible_variable_data( - collection_id: u64, - item_id: u64, + collection_id: CollectionId, + item_id: TokenId, data: Vec ) -> DispatchResult { let mut item = >::get(collection_id, item_id); @@ -1963,8 +1966,8 @@ } fn set_nft_variable_data( - collection_id: u64, - item_id: u64, + collection_id: CollectionId, + item_id: TokenId, data: Vec ) -> DispatchResult { let mut item = >::get(collection_id, item_id); @@ -2058,7 +2061,7 @@ >::insert(item.collection, owner.clone(), new_balance); } - fn add_token_index(collection_id: u64, item_index: u64, owner: T::AccountId) -> DispatchResult { + fn add_token_index(collection_id: CollectionId, item_index: TokenId, owner: T::AccountId) -> DispatchResult { // add to account limit if >::contains_key(owner.clone()) { @@ -2096,8 +2099,8 @@ } fn remove_token_index( - collection_id: u64, - item_index: u64, + collection_id: CollectionId, + item_index: TokenId, owner: T::AccountId, ) -> DispatchResult { @@ -2123,8 +2126,8 @@ } fn move_token_index( - collection_id: u64, - item_index: u64, + collection_id: CollectionId, + item_index: TokenId, old_owner: T::AccountId, new_owner: T::AccountId, ) -> DispatchResult { --- a/pallets/nft/src/tests.rs +++ b/pallets/nft/src/tests.rs @@ -2,11 +2,12 @@ use super::*; use crate::mock::*; use crate::{AccessMode, ApprovePermissions, CollectionMode, - Ownership, ChainLimits, CreateItemData, CreateNftData, CreateFungibleData, CreateReFungibleData}; //Err + Ownership, ChainLimits, CreateItemData, CreateNftData, CreateFungibleData, CreateReFungibleData, + CollectionId, TokenId}; //Err use frame_support::{assert_noop, assert_ok}; use frame_system::{ RawOrigin }; -fn default_collection_numbers_limit() -> u64 { +fn default_collection_numbers_limit() -> u32 { 10 } @@ -34,7 +35,7 @@ CreateReFungibleData { const_data: vec![1, 2, 3], variable_data: vec![3, 2, 1] } } -fn create_test_collection_for_owner(mode: &CollectionMode, owner: u64, id: u64) -> u64 { +fn create_test_collection_for_owner(mode: &CollectionMode, owner: u64, id: CollectionId) -> CollectionId { let col_name1: Vec = "Test1\0".encode_utf16().collect::>(); let col_desc1: Vec = "TestDescription1\0".encode_utf16().collect::>(); let token_prefix1: Vec = b"token_prefix1\0".to_vec(); @@ -59,11 +60,11 @@ id } -fn create_test_collection(mode: &CollectionMode, id: u64) -> u64 { +fn create_test_collection(mode: &CollectionMode, id: CollectionId) -> CollectionId { create_test_collection_for_owner(&mode, 1, id) } -fn create_test_item(collection_id: u64, data: &CreateItemData) { +fn create_test_item(collection_id: CollectionId, data: &CreateItemData) { let origin1 = Origin::signed(1); assert_ok!(TemplateModule::create_item( origin1.clone(), @@ -109,8 +110,8 @@ items_data.clone().into_iter().map(|d| { d.into() }).collect() )); for (index, data) in items_data.iter().enumerate() { - assert_eq!(TemplateModule::nft_item_id(1, (index + 1) as u64).const_data.to_vec(), data.const_data); - assert_eq!(TemplateModule::nft_item_id(1, (index + 1) as u64).variable_data.to_vec(), data.variable_data); + assert_eq!(TemplateModule::nft_item_id(1, (index + 1) as TokenId).const_data.to_vec(), data.const_data); + assert_eq!(TemplateModule::nft_item_id(1, (index + 1) as TokenId).variable_data.to_vec(), data.variable_data); } }); } @@ -160,7 +161,7 @@ )); for (index, data) in items_data.iter().enumerate() { - let item = TemplateModule::refungible_item_id(1, (index + 1) as u64); + let item = TemplateModule::refungible_item_id(1, (index + 1) as TokenId); assert_eq!(item.const_data.to_vec(), data.const_data); assert_eq!(item.variable_data.to_vec(), data.variable_data); assert_eq!( @@ -207,7 +208,7 @@ )); for (index, _) in items_data.iter().enumerate() { - assert_eq!(TemplateModule::fungible_item_id(1, (index + 1) as u64).owner, 1); + assert_eq!(TemplateModule::fungible_item_id(1, (index + 1) as TokenId).owner, 1); } assert_eq!(TemplateModule::balance_count(1, 1), 3000); assert_eq!(TemplateModule::address_tokens(1, 1), [1, 2, 3]);