difftreelog
fix restore foreign flag, minor fixes
in: master
11 files changed
pallets/common/src/benchmarking.rsdiffbeforeafterboth121 owner,121 owner,122 CollectionMode::NFT,122 CollectionMode::NFT,123 |owner: T::CrossAccountId, data| {123 |owner: T::CrossAccountId, data| {124 <Pallet<T>>::init_collection(owner.clone(), Some(owner), data)124 <Pallet<T>>::init_collection(owner.clone(), Some(owner), false, data)125 },125 },126 |h| h,126 |h| h,127 )127 )pallets/common/src/dispatch.rsdiffbeforeafterboth78 sender: T::CrossAccountId,78 sender: T::CrossAccountId,79 payer: Option<T::CrossAccountId>,79 payer: Option<T::CrossAccountId>,80 data: CreateCollectionData<T::CrossAccountId>,80 data: CreateCollectionData<T::CrossAccountId>,81 ) -> Result<CollectionId, DispatchError>;81 ) -> Result<CollectionId, DispatchError> {82 Self::create_internal(sender, payer, false, data)83 }8485 /// Create a collection. The collection will be created according to the value of [`data.mode`](CreateCollectionData::mode).86 ///87 /// * `sender` - The user who will become the owner of the collection.88 /// * `payer` - If set, the user who pays the collection creation deposit.89 /// * `data` - Description of the created collection.90 /// * `is_special_collection` -- Whether this collection is a system one, i.e. can have special flags set.91 fn create_internal(92 sender: T::CrossAccountId,93 payer: Option<T::CrossAccountId>,94 is_special_collection: bool,95 data: CreateCollectionData<T::CrossAccountId>,96 ) -> Result<CollectionId, DispatchError>;829783 /// Delete the collection.98 /// Delete the collection.84 ///99 ///pallets/common/src/lib.rsdiffbeforeafterboth1088 read_only: flags.external,1088 read_only: flags.external,108910891090 flags: RpcCollectionFlags {1090 flags: RpcCollectionFlags {1091 foreign: flags.foreign,1091 erc721metadata: flags.erc721metadata,1092 erc721metadata: flags.erc721metadata,1092 },1093 },1093 })1094 })1129 /// * `owner` - The owner of the collection.1130 /// * `owner` - The owner of the collection.1130 /// * `payer` - If set, the user that will pay a deposit for the collection creation.1131 /// * `payer` - If set, the user that will pay a deposit for the collection creation.1131 /// * `data` - Description of the created collection.1132 /// * `data` - Description of the created collection.1133 /// * `is_special_collection` -- Whether this collection is a special one, i.e. can have special flags set.1132 pub fn init_collection(1134 pub fn init_collection(1133 owner: T::CrossAccountId,1135 owner: T::CrossAccountId,1134 payer: Option<T::CrossAccountId>,1136 payer: Option<T::CrossAccountId>,1137 is_special_collection: bool,1135 data: CreateCollectionData<T::CrossAccountId>,1138 data: CreateCollectionData<T::CrossAccountId>,1136 ) -> Result<CollectionId, DispatchError> {1139 ) -> Result<CollectionId, DispatchError> {1140 if !is_special_collection {1137 ensure!(data.flags.is_allowed_for_user(), <Error<T>>::NoPermission);1141 ensure!(data.flags.is_allowed_for_user(), <Error<T>>::NoPermission);1142 }113811431139 // Take a (non-refundable) deposit of collection creation1144 // Take a (non-refundable) deposit of collection creation1140 if let Some(payer) = payer {1145 if let Some(payer) = payer {pallets/foreign-assets/src/lib.rsdiffbeforeafterboth153 .expect("description length < max description length; qed");153 .expect("description length < max description length; qed");154154155 let payer = None;155 let payer = None;156 let is_special_collection = true;156 let collection_id = T::CollectionDispatch::create(157 let collection_id = T::CollectionDispatch::create_internal(157 foreign_collection_owner,158 foreign_collection_owner,158 payer,159 payer,160 is_special_collection,159 CreateCollectionData {161 CreateCollectionData {160 name,162 name,161 description,163 description,pallets/fungible/src/benchmarking.rsdiffbeforeafterboth31 owner,31 owner,32 CollectionMode::Fungible(0),32 CollectionMode::Fungible(0),33 |owner: T::CrossAccountId, data| {33 |owner: T::CrossAccountId, data| {34 <PalletCommon<T>>::init_collection(owner.clone(), Some(owner), data)34 <PalletCommon<T>>::init_collection(owner.clone(), Some(owner), false, data)35 },35 },36 FungibleHandle::cast,36 FungibleHandle::cast,37 )37 )pallets/nonfungible/src/benchmarking.rsdiffbeforeafterboth58 owner,58 owner,59 CollectionMode::NFT,59 CollectionMode::NFT,60 |owner: T::CrossAccountId, data| {60 |owner: T::CrossAccountId, data| {61 <PalletCommon<T>>::init_collection(owner.clone(), Some(owner), data)61 <PalletCommon<T>>::init_collection(owner.clone(), Some(owner), false, data)62 },62 },63 NonfungibleHandle::cast,63 NonfungibleHandle::cast,64 )64 )pallets/refungible/src/benchmarking.rsdiffbeforeafterboth20use pallet_common::{20use pallet_common::{21 bench_init,21 bench_init,22 benchmarking::{create_collection_raw, property_key, property_value},22 benchmarking::{create_collection_raw, property_key, property_value},23 Pallet as PalletCommon,23};24};24use sp_std::prelude::*;25use sp_std::prelude::*;25use up_data_structs::{26use up_data_structs::{61 create_collection_raw(62 create_collection_raw(62 owner,63 owner,63 CollectionMode::ReFungible,64 CollectionMode::ReFungible,64 |owner: T::CrossAccountId, data| <Pallet<T>>::init_collection(owner.clone(), owner, data),65 |owner: T::CrossAccountId, data| {66 <PalletCommon<T>>::init_collection(owner.clone(), Some(owner), false, data)67 },65 RefungibleHandle::cast,68 RefungibleHandle::cast,66 )69 )67}70}pallets/refungible/src/lib.rsdiffbeforeafterboth103use sp_runtime::{ArithmeticError, DispatchError, DispatchResult, TransactionOutcome};103use sp_runtime::{ArithmeticError, DispatchError, DispatchResult, TransactionOutcome};104use sp_std::{collections::btree_map::BTreeMap, vec, vec::Vec};104use sp_std::{collections::btree_map::BTreeMap, vec, vec::Vec};105use up_data_structs::{105use up_data_structs::{106 budget::Budget, mapping::TokenAddressMapping, AccessMode, CollectionId, CreateCollectionData,106 budget::Budget, mapping::TokenAddressMapping, AccessMode, CollectionId,107 CreateRefungibleExMultipleOwners, PropertiesPermissionMap, Property, PropertyKey,107 CreateRefungibleExMultipleOwners, PropertiesPermissionMap, Property, PropertyKey,108 PropertyKeyPermission, PropertyScope, PropertyValue, TokenId, TokenOwnerError,108 PropertyKeyPermission, PropertyScope, PropertyValue, TokenId, TokenOwnerError,109 TokenProperties as TokenPropertiesT, MAX_REFUNGIBLE_PIECES,109 TokenProperties as TokenPropertiesT, MAX_REFUNGIBLE_PIECES,296296297// unchecked calls skips any permission checks297// unchecked calls skips any permission checks298impl<T: Config> Pallet<T> {298impl<T: Config> Pallet<T> {299 /// Create RFT collection300 ///301 /// `init_collection` will take non-refundable deposit for collection creation.302 ///303 /// - `data`: Contains settings for collection limits and permissions.304 pub fn init_collection(305 owner: T::CrossAccountId,306 payer: T::CrossAccountId,307 data: CreateCollectionData<T::CrossAccountId>,308 ) -> Result<CollectionId, DispatchError> {309 <PalletCommon<T>>::init_collection(owner, Some(payer), data)310 }311312 /// Destroy RFT collection299 /// Destroy RFT collection313 ///300 ///primitives/data-structs/src/lib.rsdiffbeforeafterboth380pub struct CollectionFlags {380pub struct CollectionFlags {381 /// Reserved flag381 /// Reserved flag382 #[bondrewd(bits = "0..1")]382 #[bondrewd(bits = "0..1")]383 pub reserved_0: bool,383 pub foreign: bool,384 /// Supports ERC721Metadata384 /// Supports ERC721Metadata385 #[bondrewd(bits = "1..2")]385 #[bondrewd(bits = "1..2")]386 pub erc721metadata: bool,386 pub erc721metadata: bool,395395396impl CollectionFlags {396impl CollectionFlags {397 pub fn is_allowed_for_user(self) -> bool {397 pub fn is_allowed_for_user(self) -> bool {398 !self.reserved_0 && !self.external && self.reserved == 0398 !self.foreign && !self.external && self.reserved == 0399 }399 }400}400}401401461461462#[derive(Debug, Encode, Decode, Clone, PartialEq, TypeInfo, Serialize, Deserialize)]462#[derive(Debug, Encode, Decode, Clone, PartialEq, TypeInfo, Serialize, Deserialize)]463pub struct RpcCollectionFlags {463pub struct RpcCollectionFlags {464 /// Is collection is foreign.465 pub foreign: bool,464 /// Collection supports ERC721Metadata.466 /// Collection supports ERC721Metadata.465 pub erc721metadata: bool,467 pub erc721metadata: bool,466}468}503 pub read_only: bool,505 pub read_only: bool,504506505 /// Extra collection flags507 /// Extra collection flags506 #[version(2.., upper(RpcCollectionFlags {erc721metadata: false}))]508 #[version(2.., upper(RpcCollectionFlags {foreign: false, erc721metadata: false}))]507 pub flags: RpcCollectionFlags,509 pub flags: RpcCollectionFlags,508}510}509511540 read_only: true,542 read_only: true,541543542 flags: RpcCollectionFlags {544 flags: RpcCollectionFlags {545 foreign: false,543 erc721metadata: false,546 erc721metadata: false,544 },547 },545 }548 }runtime/common/config/pallets/foreign_asset.rsdiffbeforeafterboth1use frame_support::{parameter_types, PalletId};1use frame_support::{parameter_types, PalletId};2#[cfg(not(feature = "governance"))]3use frame_system::EnsureRoot;2use pallet_evm::account::CrossAccountId;4use pallet_evm::account::CrossAccountId;3use sp_core::H160;5use sp_core::H160;4use staging_xcm::prelude::*;6use staging_xcm::prelude::*;7#[cfg(feature = "governance")]9#[cfg(feature = "governance")]8use crate::runtime_common::config::governance;10use crate::runtime_common::config::governance;910#[cfg(not(feature = "governance"))]11use frame_system::EnsureRoot;1213use crate::{11use crate::{14 runtime_common::config::{12 runtime_common::config::{runtime/common/dispatch.rsdiffbeforeafterboth66 }66 }67 }67 }686869 fn create(69 fn create_internal(70 sender: T::CrossAccountId,70 sender: T::CrossAccountId,71 payer: Option<T::CrossAccountId>,71 payer: Option<T::CrossAccountId>,72 is_special_collection: bool,72 data: CreateCollectionData<T::CrossAccountId>,73 data: CreateCollectionData<T::CrossAccountId>,73 ) -> Result<CollectionId, DispatchError> {74 ) -> Result<CollectionId, DispatchError> {74 match data.mode {75 match data.mode {86 _ => {}87 _ => {}87 };88 };888989 <PalletCommon<T>>::init_collection(sender, payer, data)90 <PalletCommon<T>>::init_collection(sender, payer, is_special_collection, data)90 }91 }919292 fn destroy(sender: T::CrossAccountId, collection_id: CollectionId) -> DispatchResult {93 fn destroy(sender: T::CrossAccountId, collection_id: CollectionId) -> DispatchResult {