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.rsdiffbeforeafterboth--- 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<u8, CustomDataLimit>,
@@ -180,7 +181,9 @@
StorageMap<Hasher = Twox64Concat, Key = CollectionId, Value = u32, QueryKind = ValueQuery>;
/// 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<T: Config> = StorageNMap<
Key = (Key<Twox64Concat, CollectionId>, Key<Twox64Concat, TokenId>),
Value = ItemData,
@@ -260,10 +263,13 @@
#[pallet::hooks]
impl<T: Config> Hooks<BlockNumberFor<T>> for Pallet<T> {
fn on_runtime_upgrade() -> Weight {
- if StorageVersion::get::<Pallet<T>>() < StorageVersion::new(1) {
+ let storage_version = StorageVersion::get::<Pallet<T>>();
+ if storage_version < StorageVersion::new(1) {
<TokenData<T>>::translate_values::<ItemDataVersion1, _>(|v| {
Some(<ItemDataVersion2>::from(v))
})
+ } else if storage_version < StorageVersion::new(2) {
+ <TokenData<T>>::remove_all(None);
}
0
@@ -377,7 +383,6 @@
<TokensMinted<T>>::remove(id);
<TokensBurnt<T>>::remove(id);
- <TokenData<T>>::remove_prefix((id,), None);
<TotalSupply<T>>::remove_prefix((id,), None);
<Balance<T>>::remove_prefix((id,), None);
<Allowance<T>>::remove_prefix((id,), None);
@@ -387,7 +392,7 @@
}
fn collection_has_tokens(collection_id: CollectionId) -> bool {
- <TokenData<T>>::iter_prefix((collection_id,))
+ <TotalSupply<T>>::iter_prefix((collection_id,))
.next()
.is_some()
}
@@ -401,7 +406,6 @@
.ok_or(ArithmeticError::Overflow)?;
<TokensBurnt<T>>::insert(collection.id, burnt);
- <TokenData<T>>::remove((collection.id, token_id));
<TokenProperties<T>>::remove((collection.id, token_id));
<TotalSupply<T>>::remove((collection.id, token_id));
<Balance<T>>::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;
<TotalSupply<T>>::insert((collection.id, token_id), totals[i]);
-
- <TokenData<T>>::insert(
- (collection.id, token_id),
- ItemData {
- const_data: data.const_data.clone(),
- },
- );
for (user, amount) in data.users.iter() {
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.rsdiffbeforeafterboth626263fn default_re_fungible_data() -> CreateReFungibleData {63fn default_re_fungible_data() -> CreateReFungibleData {64 CreateReFungibleData {64 CreateReFungibleData {65 const_data: vec![1, 2, 3].try_into().unwrap(),66 pieces: 1023,65 pieces: 1023,67 properties: vec![Property {66 properties: vec![Property {68 key: b"test-prop".to_vec().try_into().unwrap(),67 key: b"test-prop".to_vec().try_into().unwrap(),298 let item = <pallet_refungible::TokenData<Test>>::get((collection_id, TokenId(1)));297 let item = <pallet_refungible::TokenData<Test>>::get((collection_id, TokenId(1)));299 let balance =298 let balance =300 <pallet_refungible::Balance<Test>>::get((collection_id, TokenId(1), account(1)));299 <pallet_refungible::Balance<Test>>::get((collection_id, TokenId(1), account(1)));301 assert_eq!(item.const_data, data.const_data.into_inner());302 assert_eq!(balance, 1023);300 assert_eq!(balance, 1023);303 });301 });304}302}333 ));331 ));334 let balance =332 let balance =335 <pallet_refungible::Balance<Test>>::get((CollectionId(1), TokenId(1), account(1)));333 <pallet_refungible::Balance<Test>>::get((CollectionId(1), TokenId(1), account(1)));336 assert_eq!(item.const_data.to_vec(), data.const_data.into_inner());337 assert_eq!(balance, 1023);334 assert_eq!(balance, 1023);338 }335 }339 });336 });446 let data = default_re_fungible_data();443 let data = default_re_fungible_data();447 create_test_item(collection_id, &data.clone().into());444 create_test_item(collection_id, &data.clone().into());448 let item = <pallet_refungible::TokenData<Test>>::get((collection_id, TokenId(1)));445 let item = <pallet_refungible::TokenData<Test>>::get((collection_id, TokenId(1)));449 assert_eq!(item.const_data, data.const_data.into_inner());450 assert_eq!(446 assert_eq!(451 <pallet_refungible::AccountBalance<Test>>::get((collection_id, account(1))),447 <pallet_refungible::AccountBalance<Test>>::get((collection_id, account(1))),452 1448 1