--- a/Cargo.lock +++ b/Cargo.lock @@ -6320,7 +6320,7 @@ [[package]] name = "pallet-refungible" -version = "0.1.2" +version = "0.2.0" dependencies = [ "ethereum", "evm-coder", @@ -12737,7 +12737,7 @@ [[package]] name = "up-data-structs" -version = "0.1.2" +version = "0.2.0" dependencies = [ "derivative", "frame-support", --- a/pallets/refungible/CHANGELOG.md +++ b/pallets/refungible/CHANGELOG.md @@ -2,6 +2,11 @@ All notable changes to this project will be documented in this file. +## [v0.2.0] - 2022-08-01 +### Deprecated +- `ItemData` +- `TokenData` + ## [v0.1.2] - 2022-07-14 ### Other changes --- a/pallets/refungible/Cargo.toml +++ b/pallets/refungible/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "pallet-refungible" -version = "0.1.2" +version = "0.2.0" license = "GPLv3" edition = "2021" --- a/pallets/refungible/src/common.rs +++ b/pallets/refungible/src/common.rs @@ -32,7 +32,7 @@ use crate::{ AccountBalance, Allowance, Balance, Config, Error, Owned, Pallet, RefungibleHandle, - SelfWeightOf, TokenData, weights::WeightInfo, TokensMinted, + SelfWeightOf, TokenData, weights::WeightInfo, TokensMinted, TotalSupply, }; macro_rules! max_weight_of { @@ -155,7 +155,6 @@ ) -> Result, DispatchError> { match data { up_data_structs::CreateItemData::ReFungible(data) => Ok(CreateRefungibleExData { - const_data: data.const_data, users: { let mut out = BTreeMap::new(); out.insert(to.clone(), data.pieces); @@ -421,7 +420,7 @@ } fn collection_tokens(&self) -> Vec { - >::iter_prefix((self.id,)) + >::iter_prefix((self.id,)) .map(|(id, _)| id) .collect() } --- a/pallets/refungible/src/lib.rs +++ b/pallets/refungible/src/lib.rs @@ -123,6 +123,7 @@ /// for the convenience of database access. Notably contains the token metadata. #[struct_versioning::versioned(version = 2, upper)] #[derive(Encode, Decode, Default, TypeInfo, MaxEncodedLen)] +#[deprecated(since = "0.2.0", note = "ItemData is no more contains usefull data")] pub struct ItemData { pub const_data: BoundedVec, @@ -180,7 +181,9 @@ StorageMap; /// Token data, used to partially describe a token. + // TODO: remove #[pallet::storage] + #[deprecated(since = "0.2.0", note = "ItemData is no more contains usefull data")] pub type TokenData = StorageNMap< Key = (Key, Key), Value = ItemData, @@ -260,10 +263,13 @@ #[pallet::hooks] impl Hooks> for Pallet { fn on_runtime_upgrade() -> Weight { - if StorageVersion::get::>() < StorageVersion::new(1) { + let storage_version = StorageVersion::get::>(); + if storage_version < StorageVersion::new(1) { >::translate_values::(|v| { Some(::from(v)) }) + } else if storage_version < StorageVersion::new(2) { + >::remove_all(None); } 0 @@ -377,7 +383,6 @@ >::remove(id); >::remove(id); - >::remove_prefix((id,), None); >::remove_prefix((id,), None); >::remove_prefix((id,), None); >::remove_prefix((id,), None); @@ -387,7 +392,7 @@ } fn collection_has_tokens(collection_id: CollectionId) -> bool { - >::iter_prefix((collection_id,)) + >::iter_prefix((collection_id,)) .next() .is_some() } @@ -401,7 +406,6 @@ .ok_or(ArithmeticError::Overflow)?; >::insert(collection.id, burnt); - >::remove((collection.id, token_id)); >::remove((collection.id, token_id)); >::remove((collection.id, token_id)); >::remove_prefix((collection.id, token_id), None); @@ -882,13 +886,6 @@ for (i, data) in data.iter().enumerate() { let token_id = first_token_id + i as u32 + 1; >::insert((collection.id, token_id), totals[i]); - - >::insert( - (collection.id, token_id), - ItemData { - const_data: data.const_data.clone(), - }, - ); for (user, amount) in data.users.iter() { if *amount == 0 { --- a/primitives/data-structs/CHANGELOG.md +++ b/primitives/data-structs/CHANGELOG.md @@ -2,6 +2,9 @@ All notable changes to this project will be documented in this file. +## [v0.2.0] - 2022-08-01 +### Deprecated +- `CreateReFungibleData::const_data` ## [v0.1.2] - 2022-07-25 ### Added --- a/primitives/data-structs/Cargo.toml +++ b/primitives/data-structs/Cargo.toml @@ -6,7 +6,7 @@ license = 'GPLv3' homepage = "https://unique.network" repository = 'https://github.com/UniqueNetwork/unique-chain' -version = '0.1.2' +version = '0.2.0' [dependencies] scale-info = { version = "2.0.1", default-features = false, features = [ --- a/primitives/data-structs/src/lib.rs +++ b/primitives/data-structs/src/lib.rs @@ -780,12 +780,7 @@ #[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))] #[derivative(Debug)] pub struct CreateReFungibleData { - /// Immutable metadata of the token - #[cfg_attr(feature = "serde1", serde(with = "bounded::vec_serde"))] - #[derivative(Debug(format_with = "bounded::vec_debug"))] - pub const_data: BoundedVec, - - /// Pieces of created token. + /// Number of pieces the RFT is split into pub pieces: u128, /// Key-value pairs used to describe the token as metadata @@ -832,11 +827,6 @@ #[derive(Encode, Decode, MaxEncodedLen, PartialEq, Clone, TypeInfo, Derivative)] #[derivative(Debug(bound = "CrossAccountId: fmt::Debug + Ord"))] pub struct CreateRefungibleExData { - /// Custom data stored in token. - #[derivative(Debug(format_with = "bounded::vec_debug"))] - pub const_data: BoundedVec, - - /// Users who will be assigned the specified number of token parts. #[derivative(Debug(format_with = "bounded::map_debug"))] pub users: BoundedBTreeMap>, #[derivative(Debug(format_with = "bounded::vec_debug"))] @@ -874,10 +864,7 @@ impl CreateItemData { /// Get size of custom data. pub fn data_size(&self) -> usize { - match self { - CreateItemData::ReFungible(data) => data.const_data.len(), - _ => 0, - } + 0 } } --- a/runtime/tests/src/tests.rs +++ b/runtime/tests/src/tests.rs @@ -62,7 +62,6 @@ fn default_re_fungible_data() -> CreateReFungibleData { CreateReFungibleData { - const_data: vec![1, 2, 3].try_into().unwrap(), pieces: 1023, properties: vec![Property { key: b"test-prop".to_vec().try_into().unwrap(), @@ -298,7 +297,6 @@ let item = >::get((collection_id, TokenId(1))); let balance = >::get((collection_id, TokenId(1), account(1))); - assert_eq!(item.const_data, data.const_data.into_inner()); assert_eq!(balance, 1023); }); } @@ -333,7 +331,6 @@ )); let balance = >::get((CollectionId(1), TokenId(1), account(1))); - assert_eq!(item.const_data.to_vec(), data.const_data.into_inner()); assert_eq!(balance, 1023); } }); @@ -446,7 +443,6 @@ let data = default_re_fungible_data(); create_test_item(collection_id, &data.clone().into()); let item = >::get((collection_id, TokenId(1))); - assert_eq!(item.const_data, data.const_data.into_inner()); assert_eq!( >::get((collection_id, account(1))), 1