difftreelog
chore fix cargo check warnings
in: master
10 files changed
Cargo.tomldiffbeforeafterboth--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,5 +1,3 @@
-cargo-features = ["workspace-inheritance"]
-
[workspace]
resolver = "2"
members = [
pallets/common/src/erc.rsdiffbeforeafterboth--- a/pallets/common/src/erc.rs
+++ b/pallets/common/src/erc.rs
@@ -701,29 +701,6 @@
}
}
-/// ### Note
-/// Do not forget to add: `self.consume_store_reads(1)?;`
-fn check_is_owner_or_admin<T: Config>(
- caller: caller,
- collection: &CollectionHandle<T>,
-) -> Result<T::CrossAccountId> {
- let caller = T::CrossAccountId::from_eth(caller);
- collection
- .check_is_owner_or_admin(&caller)
- .map_err(dispatch_to_evm::<T>)?;
- Ok(caller)
-}
-
-/// ### Note
-/// Do not forget to add: `self.consume_store_writes(1)?;`
-fn save<T: Config>(collection: &CollectionHandle<T>) -> Result<void> {
- collection
- .check_is_internal()
- .map_err(dispatch_to_evm::<T>)?;
- collection.save().map_err(dispatch_to_evm::<T>)?;
- Ok(())
-}
-
/// Contains static property keys and values.
pub mod static_property {
use evm_coder::{
pallets/common/src/eth.rsdiffbeforeafterboth1// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.2// This file is part of Unique Network.34// Unique Network is free software: you can redistribute it and/or modify5// it under the terms of the GNU General Public License as published by6// the Free Software Foundation, either version 3 of the License, or7// (at your option) any later version.89// Unique Network is distributed in the hope that it will be useful,10// but WITHOUT ANY WARRANTY; without even the implied warranty of11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the12// GNU General Public License for more details.1314// You should have received a copy of the GNU General Public License15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.1617//! The module contains a number of functions for converting and checking ethereum identifiers.1819use evm_coder::{20 AbiCoder,21 types::{uint256, address},22};23pub use pallet_evm::{Config, account::CrossAccountId};24use sp_core::H160;25use up_data_structs::CollectionId;2627// 0x17c4e6453Cc49AAAaEACA894e6D9683e00000001 - collection 128// TODO: Unhardcode prefix29const ETH_COLLECTION_PREFIX: [u8; 16] = [30 0x17, 0xc4, 0xe6, 0x45, 0x3c, 0xc4, 0x9a, 0xaa, 0xae, 0xac, 0xa8, 0x94, 0xe6, 0xd9, 0x68, 0x3e,31];3233/// Maps the ethereum address of the collection in substrate.34pub fn map_eth_to_id(eth: &H160) -> Option<CollectionId> {35 if eth[0..16] != ETH_COLLECTION_PREFIX {36 return None;37 }38 let mut id_bytes = [0; 4];39 id_bytes.copy_from_slice(ð[16..20]);40 Some(CollectionId(u32::from_be_bytes(id_bytes)))41}4243/// Maps the substrate collection id in ethereum.44pub fn collection_id_to_address(id: CollectionId) -> H160 {45 let mut out = [0; 20];46 out[0..16].copy_from_slice(Ð_COLLECTION_PREFIX);47 out[16..20].copy_from_slice(&u32::to_be_bytes(id.0));48 H160(out)49}5051/// Check if the ethereum address is a collection.52pub fn is_collection(address: &H160) -> bool {53 address[0..16] == ETH_COLLECTION_PREFIX54}5556/// Convert `CrossAccountId` to `uint256`.57pub fn convert_cross_account_to_uint256<T: Config>(from: &T::CrossAccountId) -> uint25658where59 T::AccountId: AsRef<[u8; 32]>,60{61 let slice = from.as_sub().as_ref();62 uint256::from_big_endian(slice)63}6465/// Convert `uint256` to `CrossAccountId`.66pub fn convert_uint256_to_cross_account<T: Config>(from: uint256) -> T::CrossAccountId67where68 T::AccountId: From<[u8; 32]>,69{70 let mut new_admin_arr = [0_u8; 32];71 from.to_big_endian(&mut new_admin_arr);72 let account_id = T::AccountId::from(new_admin_arr);73 T::CrossAccountId::from_sub(account_id)74}7576/// Convert `CrossAccountId` to `(address, uint256)`.77pub fn convert_cross_account_to_tuple<T: Config>(78 cross_account_id: &T::CrossAccountId,79) -> (address, uint256)80where81 T::AccountId: AsRef<[u8; 32]>,82{83 if cross_account_id.is_canonical_substrate() {84 let sub = convert_cross_account_to_uint256::<T>(cross_account_id);85 (Default::default(), sub)86 } else {87 let eth = *cross_account_id.as_eth();88 (eth, Default::default())89 }90}9192/// Convert tuple `(address, uint256)` to `CrossAccountId`.93///94/// If `address` in the tuple has *default* value, then the canonical form is substrate,95/// if `uint256` has *default* value, then the ethereum form is canonical,96/// if both values are *default* or *non default*, then this is considered an invalid address and `Error` is returned.97pub fn convert_tuple_to_cross_account<T: Config>(98 eth_cross_account_id: (address, uint256),99) -> evm_coder::execution::Result<T::CrossAccountId>100where101 T::AccountId: From<[u8; 32]>,102{103 if eth_cross_account_id == Default::default() {104 Err("All fields of cross account is zeroed".into())105 } else if eth_cross_account_id.0 == Default::default() {106 Ok(convert_uint256_to_cross_account::<T>(107 eth_cross_account_id.1,108 ))109 } else if eth_cross_account_id.1 == Default::default() {110 Ok(T::CrossAccountId::from_eth(eth_cross_account_id.0))111 } else {112 Err("All fields of cross account is non zeroed".into())113 }114}115116/// Cross account struct117#[derive(Debug, Default, AbiCoder)]118pub struct EthCrossAccount {119 pub(crate) eth: address,120 pub(crate) sub: uint256,121}122123impl EthCrossAccount {124 pub fn from_sub_cross_account<T>(cross_account_id: &T::CrossAccountId) -> Self125 where126 T: pallet_evm::Config,127 T::AccountId: AsRef<[u8; 32]>,128 {129 if cross_account_id.is_canonical_substrate() {130 Self {131 eth: Default::default(),132 sub: convert_cross_account_to_uint256::<T>(cross_account_id),133 }134 } else {135 Self {136 eth: *cross_account_id.as_eth(),137 sub: Default::default(),138 }139 }140 }141142 pub fn into_sub_cross_account<T>(&self) -> evm_coder::execution::Result<T::CrossAccountId>143 where144 T: pallet_evm::Config,145 T::AccountId: From<[u8; 32]>,146 {147 if self.eth == Default::default() && self.sub == Default::default() {148 Err("All fields of cross account is zeroed".into())149 } else if self.eth == Default::default() {150 Ok(convert_uint256_to_cross_account::<T>(self.sub))151 } else if self.sub == Default::default() {152 Ok(T::CrossAccountId::from_eth(self.eth))153 } else {154 Err("All fields of cross account is non zeroed".into())155 }156 }157}158#[derive(Default, Debug, Clone, Copy, AbiCoder)]159#[repr(u8)]160pub enum CollectionPermissions {161 #[default]162 CollectionAdmin,163 TokenOwner,164}1// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.2// This file is part of Unique Network.34// Unique Network is free software: you can redistribute it and/or modify5// it under the terms of the GNU General Public License as published by6// the Free Software Foundation, either version 3 of the License, or7// (at your option) any later version.89// Unique Network is distributed in the hope that it will be useful,10// but WITHOUT ANY WARRANTY; without even the implied warranty of11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the12// GNU General Public License for more details.1314// You should have received a copy of the GNU General Public License15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.1617//! The module contains a number of functions for converting and checking ethereum identifiers.1819use evm_coder::{20 AbiCoder,21 types::{uint256, address},22};23pub use pallet_evm::{Config, account::CrossAccountId};24use sp_core::H160;25use up_data_structs::CollectionId;2627// 0x17c4e6453Cc49AAAaEACA894e6D9683e00000001 - collection 128// TODO: Unhardcode prefix29const ETH_COLLECTION_PREFIX: [u8; 16] = [30 0x17, 0xc4, 0xe6, 0x45, 0x3c, 0xc4, 0x9a, 0xaa, 0xae, 0xac, 0xa8, 0x94, 0xe6, 0xd9, 0x68, 0x3e,31];3233/// Maps the ethereum address of the collection in substrate.34pub fn map_eth_to_id(eth: &H160) -> Option<CollectionId> {35 if eth[0..16] != ETH_COLLECTION_PREFIX {36 return None;37 }38 let mut id_bytes = [0; 4];39 id_bytes.copy_from_slice(ð[16..20]);40 Some(CollectionId(u32::from_be_bytes(id_bytes)))41}4243/// Maps the substrate collection id in ethereum.44pub fn collection_id_to_address(id: CollectionId) -> H160 {45 let mut out = [0; 20];46 out[0..16].copy_from_slice(Ð_COLLECTION_PREFIX);47 out[16..20].copy_from_slice(&u32::to_be_bytes(id.0));48 H160(out)49}5051/// Check if the ethereum address is a collection.52pub fn is_collection(address: &H160) -> bool {53 address[0..16] == ETH_COLLECTION_PREFIX54}5556/// Convert `CrossAccountId` to `uint256`.57pub fn convert_cross_account_to_uint256<T: Config>(from: &T::CrossAccountId) -> uint25658where59 T::AccountId: AsRef<[u8; 32]>,60{61 let slice = from.as_sub().as_ref();62 uint256::from_big_endian(slice)63}6465/// Convert `uint256` to `CrossAccountId`.66pub fn convert_uint256_to_cross_account<T: Config>(from: uint256) -> T::CrossAccountId67where68 T::AccountId: From<[u8; 32]>,69{70 let mut new_admin_arr = [0_u8; 32];71 from.to_big_endian(&mut new_admin_arr);72 let account_id = T::AccountId::from(new_admin_arr);73 T::CrossAccountId::from_sub(account_id)74}7576/// Convert `CrossAccountId` to `(address, uint256)`.77pub fn convert_cross_account_to_tuple<T: Config>(78 cross_account_id: &T::CrossAccountId,79) -> (address, uint256)80where81 T::AccountId: AsRef<[u8; 32]>,82{83 if cross_account_id.is_canonical_substrate() {84 let sub = convert_cross_account_to_uint256::<T>(cross_account_id);85 (Default::default(), sub)86 } else {87 let eth = *cross_account_id.as_eth();88 (eth, Default::default())89 }90}9192/// Convert tuple `(address, uint256)` to `CrossAccountId`.93///94/// If `address` in the tuple has *default* value, then the canonical form is substrate,95/// if `uint256` has *default* value, then the ethereum form is canonical,96/// if both values are *default* or *non default*, then this is considered an invalid address and `Error` is returned.97pub fn convert_tuple_to_cross_account<T: Config>(98 eth_cross_account_id: (address, uint256),99) -> evm_coder::execution::Result<T::CrossAccountId>100where101 T::AccountId: From<[u8; 32]>,102{103 if eth_cross_account_id == Default::default() {104 Err("All fields of cross account is zeroed".into())105 } else if eth_cross_account_id.0 == Default::default() {106 Ok(convert_uint256_to_cross_account::<T>(107 eth_cross_account_id.1,108 ))109 } else if eth_cross_account_id.1 == Default::default() {110 Ok(T::CrossAccountId::from_eth(eth_cross_account_id.0))111 } else {112 Err("All fields of cross account is non zeroed".into())113 }114}115116/// Cross account struct117#[derive(Debug, Default, AbiCoder)]118pub struct EthCrossAccount {119 pub(crate) eth: address,120 pub(crate) sub: uint256,121}122123impl EthCrossAccount {124 /// Converts `CrossAccountId` to `EthCrossAccount` to be correctly usable with Ethereum.125 pub fn from_sub_cross_account<T>(cross_account_id: &T::CrossAccountId) -> Self126 where127 T: pallet_evm::Config,128 T::AccountId: AsRef<[u8; 32]>,129 {130 if cross_account_id.is_canonical_substrate() {131 Self {132 eth: Default::default(),133 sub: convert_cross_account_to_uint256::<T>(cross_account_id),134 }135 } else {136 Self {137 eth: *cross_account_id.as_eth(),138 sub: Default::default(),139 }140 }141 }142143 /// Converts `EthCrossAccount` to `CrossAccountId` to be correctly usable with Substrate.144 pub fn into_sub_cross_account<T>(&self) -> evm_coder::execution::Result<T::CrossAccountId>145 where146 T: pallet_evm::Config,147 T::AccountId: From<[u8; 32]>,148 {149 if self.eth == Default::default() && self.sub == Default::default() {150 Err("All fields of cross account is zeroed".into())151 } else if self.eth == Default::default() {152 Ok(convert_uint256_to_cross_account::<T>(self.sub))153 } else if self.sub == Default::default() {154 Ok(T::CrossAccountId::from_eth(self.eth))155 } else {156 Err("All fields of cross account is non zeroed".into())157 }158 }159}160161/// Descriptor of the kind of user to be used within collection permissions on certain operations.162#[derive(Default, Debug, Clone, Copy, AbiCoder)]163#[repr(u8)]164pub enum CollectionPermissions {165 /// Collection admin.166 #[default]167 CollectionAdmin,168 /// Owner of a token.169 TokenOwner,170}pallets/foreign-assets/Cargo.tomldiffbeforeafterboth--- a/pallets/foreign-assets/Cargo.toml
+++ b/pallets/foreign-assets/Cargo.toml
@@ -1,5 +1,3 @@
-cargo-features = ["workspace-inheritance"]
-
[package]
name = "pallet-foreign-assets"
version = "0.1.0"
pallets/refungible/src/lib.rsdiffbeforeafterboth--- a/pallets/refungible/src/lib.rs
+++ b/pallets/refungible/src/lib.rs
@@ -90,12 +90,11 @@
use crate::erc_token::ERC20Events;
use crate::erc::ERC721Events;
-use codec::{Encode, Decode, MaxEncodedLen};
use core::ops::Deref;
use derivative::Derivative;
use evm_coder::ToLog;
use frame_support::{
- BoundedBTreeMap, BoundedVec, ensure, fail, storage::with_transaction, transactional,
+ BoundedBTreeMap, ensure, fail, storage::with_transaction, transactional,
pallet_prelude::ConstU32,
};
use pallet_evm::{account::CrossAccountId, Pallet as PalletEvm};
@@ -105,15 +104,14 @@
Event as CommonEvent, Pallet as PalletCommon, erc::CollectionHelpersEvents,
};
use pallet_structure::Pallet as PalletStructure;
-use scale_info::TypeInfo;
use sp_core::{Get, H160};
use sp_runtime::{ArithmeticError, DispatchError, DispatchResult, TransactionOutcome};
use sp_std::{vec::Vec, vec, collections::btree_map::BTreeMap};
use up_data_structs::{
AccessMode, budget::Budget, CollectionId, CollectionFlags, CollectionPropertiesVec,
- CreateCollectionData, CustomDataLimit, mapping::TokenAddressMapping, MAX_ITEMS_PER_BATCH,
- MAX_REFUNGIBLE_PIECES, Property, PropertyKey, PropertyKeyPermission, PropertyPermission,
- PropertyScope, PropertyValue, TokenId, TrySetProperty,
+ CreateCollectionData, mapping::TokenAddressMapping, MAX_ITEMS_PER_BATCH, MAX_REFUNGIBLE_PIECES,
+ Property, PropertyKey, PropertyKeyPermission, PropertyPermission, PropertyScope, PropertyValue,
+ TokenId, TrySetProperty,
};
pub use pallet::*;
@@ -133,17 +131,6 @@
}
pub(crate) type SelfWeightOf<T> = <T as Config>::WeightInfo;
-/// Token data, stored independently from other data used to describe it
-/// for the convenience of database access. Notably contains the token metadata.
-#[struct_versioning::versioned(version = 2, upper)]
-#[derive(Encode, Decode, Default, TypeInfo, MaxEncodedLen)]
-pub struct ItemData {
- pub const_data: BoundedVec<u8, CustomDataLimit>,
-
- #[version(..2)]
- pub variable_data: BoundedVec<u8, CustomDataLimit>,
-}
-
#[frame_support::pallet]
pub mod pallet {
use super::*;
@@ -151,7 +138,6 @@
Blake2_128, Blake2_128Concat, Twox64Concat, pallet_prelude::*, storage::Key,
traits::StorageVersion,
};
- use frame_system::pallet_prelude::*;
use up_data_structs::{CollectionId, TokenId};
use super::weights::WeightInfo;
@@ -192,16 +178,6 @@
#[pallet::storage]
pub type TokensBurnt<T: Config> =
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,
- QueryKind = ValueQuery,
- >;
/// Amount of pieces a refungible token is split into.
#[pallet::storage]
@@ -284,20 +260,6 @@
Value = bool,
QueryKind = ValueQuery,
>;
-
- #[pallet::hooks]
- impl<T: Config> Hooks<BlockNumberFor<T>> for Pallet<T> {
- fn on_runtime_upgrade() -> Weight {
- let storage_version = StorageVersion::get::<Pallet<T>>();
- if storage_version < StorageVersion::new(2) {
- #[allow(deprecated)]
- let _ = <TokenData<T>>::clear(u32::MAX, None);
- }
- StorageVersion::new(2).put::<Pallet<T>>();
-
- Weight::zero()
- }
- }
}
pub struct RefungibleHandle<T: Config>(pallet_common::CollectionHandle<T>);
pallets/unique/src/lib.rsdiffbeforeafterboth--- a/pallets/unique/src/lib.rs
+++ b/pallets/unique/src/lib.rs
@@ -74,7 +74,7 @@
extern crate alloc;
use frame_support::{
- decl_module, decl_storage, decl_error, decl_event,
+ decl_module, decl_storage, decl_error,
dispatch::DispatchResult,
ensure, fail,
weights::{Weight},
@@ -91,7 +91,7 @@
CreateItemData, CollectionLimits, CollectionPermissions, CollectionId, CollectionMode, TokenId,
CreateCollectionData, CreateItemExData, budget, Property, PropertyKey, PropertyKeyPermission,
};
-use pallet_evm::{account::CrossAccountId};
+use pallet_evm::account::CrossAccountId;
use pallet_common::{
CollectionHandle, Pallet as PalletCommon, CommonWeightInfo, dispatch::dispatch_tx,
dispatch::CollectionDispatch, RefungibleExtensionsWeightInfo,
runtime/common/config/pallets/app_promotion.rsdiffbeforeafterboth--- a/runtime/common/config/pallets/app_promotion.rs
+++ b/runtime/common/config/pallets/app_promotion.rs
@@ -22,7 +22,7 @@
use frame_support::{parameter_types, PalletId};
use sp_arithmetic::Perbill;
use up_common::{
- constants::{UNIQUE, RELAY_DAYS, DAYS},
+ constants::{UNIQUE, RELAY_DAYS},
types::Balance,
};
runtime/opal/Cargo.tomldiffbeforeafterboth--- a/runtime/opal/Cargo.toml
+++ b/runtime/opal/Cargo.toml
@@ -1,8 +1,6 @@
################################################################################
# Package
-cargo-features = ["workspace-inheritance"]
-
[package]
authors = ['Unique Network <support@uniquenetwork.io>']
build = 'build.rs'
runtime/quartz/Cargo.tomldiffbeforeafterboth--- a/runtime/quartz/Cargo.toml
+++ b/runtime/quartz/Cargo.toml
@@ -1,8 +1,6 @@
################################################################################
# Package
-cargo-features = ["workspace-inheritance"]
-
[package]
authors = ['Unique Network <support@uniquenetwork.io>']
build = 'build.rs'
runtime/unique/Cargo.tomldiffbeforeafterboth--- a/runtime/unique/Cargo.toml
+++ b/runtime/unique/Cargo.toml
@@ -1,8 +1,6 @@
################################################################################
# Package
-cargo-features = ["workspace-inheritance"]
-
[package]
authors = ['Unique Network <support@uniquenetwork.io>']
build = 'build.rs'