From c36ef7824029a2a8eb6b1a538f340ff9a6c8d732 Mon Sep 17 00:00:00 2001 From: str-mv Date: Fri, 11 Dec 2020 14:40:55 +0000 Subject: [PATCH] Update custom types --- --- a/pallets/nft/src/lib.rs +++ b/pallets/nft/src/lib.rs @@ -186,10 +186,10 @@ impl Default for CollectionLimits { fn default() -> CollectionLimits { CollectionLimits { - account_token_ownership_limit: 0, - token_limit: 0, - sponsored_data_size: 0, - sponsor_transfer_timeout: 0 } + account_token_ownership_limit: u32::max_value(), + token_limit: u32::max_value(), + sponsored_data_size: u32::max_value(), + sponsor_transfer_timeout: u32::max_value() } } } @@ -1417,7 +1417,7 @@ #[weight = 0] pub fn set_collection_limits( origin, - collection_id: u64, + collection_id: u32, limits: CollectionLimits, ) -> DispatchResult { let sender = ensure_signed(origin)?; @@ -1439,9 +1439,9 @@ if !Self::is_owner_or_admin_permissions(collection_id, sender.clone()) { // check token limit and account token limit - let total_items: u64 = ItemListIndex::get(collection_id); + let total_items: u32 = ItemListIndex::get(collection_id); let account_items: u32 = >::get(collection_id, sender.clone()).len() as u32; - ensure!(collection.limits.token_limit as u64 > total_items, Error::::CollectionTokenLimitExceeded); + ensure!(collection.limits.token_limit > total_items, Error::::CollectionTokenLimitExceeded); ensure!(collection.limits.account_token_ownership_limit > account_items, Error::::AccountTokenLimitExceeded); ensure!(collection.mint_mode == true, Error::::PublicMintingNotAllowed); Self::check_white_list(collection_id, owner)?; --- a/pallets/nft/src/tests.rs +++ b/pallets/nft/src/tests.rs @@ -3,7 +3,7 @@ use crate::mock::*; use crate::{AccessMode, ApprovePermissions, CollectionMode, Ownership, ChainLimits, CreateItemData, CreateNftData, CreateFungibleData, CreateReFungibleData, - CollectionId, TokenId, MAX_DECIMAL_POINTS}; //Err + CollectionId, TokenId, MAX_DECIMAL_POINTS}; use frame_support::{assert_noop, assert_ok}; use frame_system::{ RawOrigin }; --- a/runtime_types.json +++ b/runtime_types.json @@ -46,20 +46,11 @@ "Owner": "AccountId", "Value": "u128" }, - "ReFungibleItemType": { - "Collection": "CollectionId", - "Owner": "Vec", - "Data": "Vec" - }, "NftItemType": { "Collection": "CollectionId", "Owner": "AccountId", "ConstData": "Vec", "VariableData": "Vec" - }, - "Ownership": { - "owner": "AccountId", - "fraction": "u128" }, "ReFungibleItemType": { "Collection": "CollectionId", @@ -79,6 +70,7 @@ "OffchainSchema": "Vec", "Sponsor": "AccountId", "UnconfirmedSponsor": "AccountId", + "Limits": "CollectionLimits", "VariableOnChainSchema": "Vec", "ConstOnChainSchema": "Vec" }, @@ -120,6 +112,12 @@ "nft_sponsor_transfer_timeout": "u32", "fungible_sponsor_transfer_timeout": "u32", "refungible_sponsor_transfer_timeout": "u32" + }, + "CollectionLimits": { + "AccountTokenOwnershipLimit": "u32", + "SponsoredDataSize": "u32", + "TokenLimit": "u32", + "SponsorTransferTimeout": "u32" } } \ No newline at end of file -- gitstuff