difftreelog
major: move RFT const data to depricated.
in: master
9 files changed
Cargo.lockdiffbeforeafterboth--- 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",
pallets/refungible/CHANGELOG.mddiffbeforeafterboth--- 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
pallets/refungible/Cargo.tomldiffbeforeafterboth--- 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"
pallets/refungible/src/common.rsdiffbeforeafterboth--- 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<CreateRefungibleExData<T::CrossAccountId>, 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<TokenId> {
- <TokenData<T>>::iter_prefix((self.id,))
+ <TotalSupply<T>>::iter_prefix((self.id,))
.map(|(id, _)| id)
.collect()
}
pallets/refungible/src/lib.rsdiffbeforeafterboth123/// for the convenience of database access. Notably contains the token metadata.123/// for the convenience of database access. Notably contains the token metadata.124#[struct_versioning::versioned(version = 2, upper)]124#[struct_versioning::versioned(version = 2, upper)]125#[derive(Encode, Decode, Default, TypeInfo, MaxEncodedLen)]125#[derive(Encode, Decode, Default, TypeInfo, MaxEncodedLen)]126#[deprecated(since = "0.2.0", note = "ItemData is no more contains usefull data")]126pub struct ItemData {127pub struct ItemData {127 pub const_data: BoundedVec<u8, CustomDataLimit>,128 pub const_data: BoundedVec<u8, CustomDataLimit>,128129180 StorageMap<Hasher = Twox64Concat, Key = CollectionId, Value = u32, QueryKind = ValueQuery>;181 StorageMap<Hasher = Twox64Concat, Key = CollectionId, Value = u32, QueryKind = ValueQuery>;181182182 /// Token data, used to partially describe a token.183 /// Token data, used to partially describe a token.184 // TODO: remove183 #[pallet::storage]185 #[pallet::storage]186 #[deprecated(since = "0.2.0", note = "ItemData is no more contains usefull data")]184 pub type TokenData<T: Config> = StorageNMap<187 pub type TokenData<T: Config> = StorageNMap<185 Key = (Key<Twox64Concat, CollectionId>, Key<Twox64Concat, TokenId>),188 Key = (Key<Twox64Concat, CollectionId>, Key<Twox64Concat, TokenId>),186 Value = ItemData,189 Value = ItemData,260 #[pallet::hooks]263 #[pallet::hooks]261 impl<T: Config> Hooks<BlockNumberFor<T>> for Pallet<T> {264 impl<T: Config> Hooks<BlockNumberFor<T>> for Pallet<T> {262 fn on_runtime_upgrade() -> Weight {265 fn on_runtime_upgrade() -> Weight {263 if StorageVersion::get::<Pallet<T>>() < StorageVersion::new(1) {266 let storage_version = StorageVersion::get::<Pallet<T>>();267 if storage_version < StorageVersion::new(1) {264 <TokenData<T>>::translate_values::<ItemDataVersion1, _>(|v| {268 <TokenData<T>>::translate_values::<ItemDataVersion1, _>(|v| {265 Some(<ItemDataVersion2>::from(v))269 Some(<ItemDataVersion2>::from(v))266 })270 })267 }271 } else if storage_version < StorageVersion::new(2) {272 <TokenData<T>>::remove_all(None);273 }268274269 0275 0270 }276 }377383378 <TokensMinted<T>>::remove(id);384 <TokensMinted<T>>::remove(id);379 <TokensBurnt<T>>::remove(id);385 <TokensBurnt<T>>::remove(id);380 <TokenData<T>>::remove_prefix((id,), None);381 <TotalSupply<T>>::remove_prefix((id,), None);386 <TotalSupply<T>>::remove_prefix((id,), None);382 <Balance<T>>::remove_prefix((id,), None);387 <Balance<T>>::remove_prefix((id,), None);383 <Allowance<T>>::remove_prefix((id,), None);388 <Allowance<T>>::remove_prefix((id,), None);387 }392 }388393389 fn collection_has_tokens(collection_id: CollectionId) -> bool {394 fn collection_has_tokens(collection_id: CollectionId) -> bool {390 <TokenData<T>>::iter_prefix((collection_id,))395 <TotalSupply<T>>::iter_prefix((collection_id,))391 .next()396 .next()392 .is_some()397 .is_some()393 }398 }401 .ok_or(ArithmeticError::Overflow)?;406 .ok_or(ArithmeticError::Overflow)?;402407403 <TokensBurnt<T>>::insert(collection.id, burnt);408 <TokensBurnt<T>>::insert(collection.id, burnt);404 <TokenData<T>>::remove((collection.id, token_id));405 <TokenProperties<T>>::remove((collection.id, token_id));409 <TokenProperties<T>>::remove((collection.id, token_id));406 <TotalSupply<T>>::remove((collection.id, token_id));410 <TotalSupply<T>>::remove((collection.id, token_id));407 <Balance<T>>::remove_prefix((collection.id, token_id), None);411 <Balance<T>>::remove_prefix((collection.id, token_id), None);883 let token_id = first_token_id + i as u32 + 1;887 let token_id = first_token_id + i as u32 + 1;884 <TotalSupply<T>>::insert((collection.id, token_id), totals[i]);888 <TotalSupply<T>>::insert((collection.id, token_id), totals[i]);885886 <TokenData<T>>::insert(887 (collection.id, token_id),888 ItemData {889 const_data: data.const_data.clone(),890 },891 );892889893 for (user, amount) in data.users.iter() {890 for (user, amount) in data.users.iter() {894 if *amount == 0 {891 if *amount == 0 {primitives/data-structs/CHANGELOG.mddiffbeforeafterboth--- 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
primitives/data-structs/Cargo.tomldiffbeforeafterboth--- 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 = [
primitives/data-structs/src/lib.rsdiffbeforeafterboth--- 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<u8, CustomDataLimit>,
-
- /// 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<CrossAccountId> {
- /// Custom data stored in token.
- #[derivative(Debug(format_with = "bounded::vec_debug"))]
- pub const_data: BoundedVec<u8, CustomDataLimit>,
-
- /// Users who will be assigned the specified number of token parts.
#[derivative(Debug(format_with = "bounded::map_debug"))]
pub users: BoundedBTreeMap<CrossAccountId, u128, ConstU32<MAX_ITEMS_PER_BATCH>>,
#[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
}
}
runtime/tests/src/tests.rsdiffbeforeafterboth--- 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 = <pallet_refungible::TokenData<Test>>::get((collection_id, TokenId(1)));
let balance =
<pallet_refungible::Balance<Test>>::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 =
<pallet_refungible::Balance<Test>>::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 = <pallet_refungible::TokenData<Test>>::get((collection_id, TokenId(1)));
- assert_eq!(item.const_data, data.const_data.into_inner());
assert_eq!(
<pallet_refungible::AccountBalance<Test>>::get((collection_id, account(1))),
1