difftreelog
feat split large fields out of Collection
in: master
7 files changed
client/rpc/src/lib.rsdiffbeforeafterboth19use codec::Decode;19use codec::Decode;20use jsonrpc_core::{Error as RpcError, ErrorCode, Result};20use jsonrpc_core::{Error as RpcError, ErrorCode, Result};21use jsonrpc_derive::rpc;21use jsonrpc_derive::rpc;22use up_data_structs::{Collection, CollectionId, CollectionStats, CollectionLimits, TokenId};22use up_data_structs::{RpcCollection, Collection, CollectionId, CollectionStats, CollectionLimits, TokenId};23use sp_api::{BlockId, BlockT, ProvideRuntimeApi, ApiExt};23use sp_api::{BlockId, BlockT, ProvideRuntimeApi, ApiExt};24use sp_blockchain::HeaderBackend;24use sp_blockchain::HeaderBackend;25use up_rpc::UniqueApi as UniqueRuntimeApi;25use up_rpc::UniqueApi as UniqueRuntimeApi;116 &self,116 &self,117 collection: CollectionId,117 collection: CollectionId,118 at: Option<BlockHash>,118 at: Option<BlockHash>,119 ) -> Result<Option<Collection<AccountId>>>;119 ) -> Result<Option<RpcCollection<AccountId>>>;120 #[rpc(name = "unique_collectionStats")]120 #[rpc(name = "unique_collectionStats")]121 fn collection_stats(&self, at: Option<BlockHash>) -> Result<CollectionStats>;121 fn collection_stats(&self, at: Option<BlockHash>) -> Result<CollectionStats>;122122235 pass_method!(allowlist(collection: CollectionId) -> Vec<CrossAccountId>);235 pass_method!(allowlist(collection: CollectionId) -> Vec<CrossAccountId>);236 pass_method!(allowed(collection: CollectionId, user: CrossAccountId) -> bool);236 pass_method!(allowed(collection: CollectionId, user: CrossAccountId) -> bool);237 pass_method!(last_token_id(collection: CollectionId) -> TokenId);237 pass_method!(last_token_id(collection: CollectionId) -> TokenId);238 pass_method!(collection_by_id(collection: CollectionId) -> Option<Collection<AccountId>>);238 pass_method!(collection_by_id(collection: CollectionId) -> Option<RpcCollection<AccountId>>);239 pass_method!(collection_stats() -> CollectionStats);239 pass_method!(collection_stats() -> CollectionStats);240 pass_method!(next_sponsored(collection: CollectionId, account: CrossAccountId, token: TokenId) -> Option<u64>);240 pass_method!(next_sponsored(collection: CollectionId, account: CrossAccountId, token: TokenId) -> Option<u64>);241 pass_method!(effective_collection_limits(collection_id: CollectionId) -> Option<CollectionLimits>);241 pass_method!(effective_collection_limits(collection_id: CollectionId) -> Option<CollectionLimits>);pallets/common/src/lib.rsdiffbeforeafterboth29};29};30use pallet_evm::GasWeightMapping;30use pallet_evm::GasWeightMapping;31use up_data_structs::{31use up_data_structs::{32 COLLECTION_NUMBER_LIMIT, Collection, CollectionId, CreateItemData, MAX_TOKEN_PREFIX_LENGTH,32 COLLECTION_NUMBER_LIMIT, Collection, RpcCollection, CollectionId, CreateItemData, MAX_TOKEN_PREFIX_LENGTH,33 COLLECTION_ADMINS_LIMIT, MetaUpdatePermission, TokenId, CollectionStats, MAX_TOKEN_OWNERSHIP,33 COLLECTION_ADMINS_LIMIT, MetaUpdatePermission, TokenId, CollectionStats, MAX_TOKEN_OWNERSHIP,34 CollectionMode, NFT_SPONSOR_TRANSFER_TIMEOUT, FUNGIBLE_SPONSOR_TRANSFER_TIMEOUT,34 CollectionMode, NFT_SPONSOR_TRANSFER_TIMEOUT, FUNGIBLE_SPONSOR_TRANSFER_TIMEOUT,35 REFUNGIBLE_SPONSOR_TRANSFER_TIMEOUT, MAX_SPONSOR_TIMEOUT, CUSTOM_DATA_LIMIT, CollectionLimits,35 REFUNGIBLE_SPONSOR_TRANSFER_TIMEOUT, MAX_SPONSOR_TIMEOUT, CUSTOM_DATA_LIMIT, CollectionLimits,36 CustomDataLimit, CreateCollectionData, SponsorshipState, CreateItemExData, SponsoringRateLimit, budget::Budget,36 CustomDataLimit, CreateCollectionData, SponsorshipState, CreateItemExData, SponsoringRateLimit, budget::Budget, COLLECTION_FIELD_LIMIT, CollectionField,37};37};38pub use pallet::*;38pub use pallet::*;39use sp_core::H160;39use sp_core::H160;353 /// Only tokens from specific collections may nest tokens under this353 /// Only tokens from specific collections may nest tokens under this354 SourceCollectionIsNotAllowedToNest,354 SourceCollectionIsNotAllowedToNest,355356 /// Tried to store more data than allowed in collection field357 CollectionFieldSizeExceeded,355 }358 }356359357 #[pallet::storage]360 #[pallet::storage]369 QueryKind = OptionQuery,372 QueryKind = OptionQuery,370 >;373 >;374375 /// Large variable-size collection fields are extracted here376 #[pallet::storage]377 pub type CollectionData<T> = StorageNMap<378 Key = (379 Key<Twox64Concat, CollectionId>,380 Key<Twox64Concat, CollectionField>,381 ),382 Value = BoundedVec<u8, ConstU32<COLLECTION_FIELD_LIMIT>>,383 QueryKind = ValueQuery,384 >;371385372 #[pallet::storage]386 #[pallet::storage]373 pub type AdminAmount<T> = StorageMap<387 pub type AdminAmount<T> = StorageMap<409 fn on_runtime_upgrade() -> Weight {423 fn on_runtime_upgrade() -> Weight {410 if StorageVersion::get::<Pallet<T>>() < StorageVersion::new(1) {424 if StorageVersion::get::<Pallet<T>>() < StorageVersion::new(1) {411 use up_data_structs::{CollectionVersion1, CollectionVersion2};425 use up_data_structs::{CollectionVersion1, CollectionVersion2};412 <CollectionById<T>>::translate_values::<CollectionVersion1<T::AccountId>, _>(|v| {426 <CollectionById<T>>::translate::<CollectionVersion1<T::AccountId>, _>(|id, v| {427 Self::set_field_raw(428 id,429 CollectionField::OffchainSchema,430 v.offchain_schema.clone().into_inner(),431 )432 .expect("data has lower bounds than field");433 Self::set_field_raw(434 id,435 CollectionField::VariableOnChainSchema,436 v.variable_on_chain_schema.clone().into_inner(),437 )438 .expect("data has lower bounds than field");439 Self::set_field_raw(440 id,441 CollectionField::ConstOnChainSchema,442 v.const_on_chain_schema.clone().into_inner(),443 )444 .expect("data has lower bounds than field");445413 Some(CollectionVersion2::from(v))446 Some(CollectionVersion2::from(v))414 });447 });484 Some(effective_limits)517 Some(effective_limits)485 }518 }519520 pub fn rpc_collection(collection: CollectionId) -> Option<RpcCollection<T::AccountId>> {521 let Collection {522 name,523 description,524 owner,525 mode,526 access,527 token_prefix,528 mint_mode,529 schema_version,530 sponsorship,531 limits,532 meta_update_permission,533 } = <CollectionById<T>>::get(collection)?;534 Some(RpcCollection {535 name: name.into_inner(),536 description: description.into_inner(),537 owner,538 mode,539 access,540 token_prefix: token_prefix.into_inner(),541 mint_mode,542 schema_version,543 sponsorship,544 limits,545 meta_update_permission,546 offchain_schema: <CollectionData<T>>::get((547 collection,548 CollectionField::OffchainSchema,549 ))550 .into_inner(),551 const_on_chain_schema: <CollectionData<T>>::get((552 collection,553 CollectionField::ConstOnChainSchema,554 ))555 .into_inner(),556 variable_on_chain_schema: <CollectionData<T>>::get((557 collection,558 CollectionField::VariableOnChainSchema,559 ))560 .into_inner(),561 })562 }486}563}487564488impl<T: Config> Pallet<T> {565impl<T: Config> Pallet<T> {520 access: data.access.unwrap_or_default(),597 access: data.access.unwrap_or_default(),521 description: data.description,598 description: data.description,522 token_prefix: data.token_prefix,599 token_prefix: data.token_prefix,523 offchain_schema: data.offchain_schema,524 schema_version: data.schema_version.unwrap_or_default(),600 schema_version: data.schema_version.unwrap_or_default(),525 sponsorship: data601 sponsorship: data526 .pending_sponsor602 .pending_sponsor527 .map(SponsorshipState::Unconfirmed)603 .map(SponsorshipState::Unconfirmed)528 .unwrap_or_default(),604 .unwrap_or_default(),529 variable_on_chain_schema: data.variable_on_chain_schema,530 const_on_chain_schema: data.const_on_chain_schema,531 limits: data605 limits: data532 .limits606 .limits533 .map(|limits| Self::clamp_limits(data.mode.clone(), &Default::default(), limits))607 .map(|limits| Self::clamp_limits(data.mode.clone(), &Default::default(), limits))557 <CreatedCollectionCount<T>>::put(created_count);631 <CreatedCollectionCount<T>>::put(created_count);558 <Pallet<T>>::deposit_event(Event::CollectionCreated(id, data.mode.id(), owner.clone()));632 <Pallet<T>>::deposit_event(Event::CollectionCreated(id, data.mode.id(), owner.clone()));559 <CollectionById<T>>::insert(id, collection);633 <CollectionById<T>>::insert(id, collection);634 Self::set_field_raw(635 id,636 CollectionField::OffchainSchema,637 data.offchain_schema.into_inner(),638 )639 .expect("data has lower bounds than field");640 Self::set_field_raw(641 id,642 CollectionField::VariableOnChainSchema,643 data.variable_on_chain_schema.into_inner(),644 )645 .expect("data has lower bounds than field");646 Self::set_field_raw(647 id,648 CollectionField::ConstOnChainSchema,649 data.const_on_chain_schema.into_inner(),650 )651 .expect("data has lower bounds than field");560 Ok(id)652 Ok(id)561 }653 }562654579671580 <DestroyedCollectionCount<T>>::put(destroyed_collections);672 <DestroyedCollectionCount<T>>::put(destroyed_collections);581 <CollectionById<T>>::remove(collection.id);673 <CollectionById<T>>::remove(collection.id);674 <CollectionData<T>>::remove_prefix((collection.id,), None);582 <AdminAmount<T>>::remove(collection.id);675 <AdminAmount<T>>::remove(collection.id);583 <IsAdmin<T>>::remove_prefix((collection.id,), None);676 <IsAdmin<T>>::remove_prefix((collection.id,), None);584 <Allowlist<T>>::remove_prefix((collection.id,), None);677 <Allowlist<T>>::remove_prefix((collection.id,), None);587 Ok(())680 Ok(())588 }681 }682683 fn set_field_raw(684 collection_id: CollectionId,685 field: CollectionField,686 value: Vec<u8>,687 ) -> DispatchResult {688 if !value.is_empty() {689 <CollectionData<T>>::insert(690 (collection_id, field),691 BoundedVec::try_from(value).map_err(|_| <Error<T>>::CollectionFieldSizeExceeded)?,692 )693 } else {694 <CollectionData<T>>::remove((collection_id, field));695 }696 Ok(())697 }698699 pub fn set_field(700 collection: &CollectionHandle<T>,701 sender: &T::CrossAccountId,702 field: CollectionField,703 value: Vec<u8>,704 ) -> DispatchResult {705 collection.check_is_owner_or_admin(sender)?;706707 // =========708709 Self::set_field_raw(collection.id, field, value)710 }589711590 pub fn toggle_allowlist(712 pub fn toggle_allowlist(591 collection: &CollectionHandle<T>,713 collection: &CollectionHandle<T>,pallets/unique/src/lib.rsdiffbeforeafterboth43 MAX_COLLECTION_NAME_LENGTH, MAX_COLLECTION_DESCRIPTION_LENGTH, MAX_TOKEN_PREFIX_LENGTH,43 MAX_COLLECTION_NAME_LENGTH, MAX_COLLECTION_DESCRIPTION_LENGTH, MAX_TOKEN_PREFIX_LENGTH,44 AccessMode, CreateItemData, CollectionLimits, CollectionId, CollectionMode, TokenId,44 AccessMode, CreateItemData, CollectionLimits, CollectionId, CollectionMode, TokenId,45 SchemaVersion, SponsorshipState, MetaUpdatePermission, CreateCollectionData, CustomDataLimit,45 SchemaVersion, SponsorshipState, MetaUpdatePermission, CreateCollectionData, CustomDataLimit,46 CreateItemExData, budget,46 CreateItemExData, budget, CollectionField,47};47};48use pallet_evm::account::CrossAccountId;48use pallet_evm::account::CrossAccountId;49use pallet_common::{49use pallet_common::{1004 schema: BoundedVec<u8, ConstU32<OFFCHAIN_SCHEMA_LIMIT>>,1004 schema: BoundedVec<u8, ConstU32<OFFCHAIN_SCHEMA_LIMIT>>,1005 ) -> DispatchResult {1005 ) -> DispatchResult {1006 let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);1006 let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);1007 let mut target_collection = <CollectionHandle<T>>::try_get(collection_id)?;1007 let collection = <CollectionHandle<T>>::try_get(collection_id)?;10081009 // =========10101008 target_collection.check_is_owner_or_admin(&sender)?;1011 <PalletCommon<T>>::set_field(&collection, &sender, CollectionField::OffchainSchema, schema.into_inner())?;10091010 target_collection.offchain_schema = schema;101110121012 <Pallet<T>>::deposit_event(Event::<T>::OffchainSchemaSet(1013 <Pallet<T>>::deposit_event(Event::<T>::OffchainSchemaSet(1013 collection_id1014 collection_id1014 ));1015 ));10151016 target_collection.save()1016 Ok(())1017 }1017 }101810181019 /// Set const on-chain data schema.1019 /// Set const on-chain data schema.1036 schema: BoundedVec<u8, ConstU32<CONST_ON_CHAIN_SCHEMA_LIMIT>>1036 schema: BoundedVec<u8, ConstU32<CONST_ON_CHAIN_SCHEMA_LIMIT>>1037 ) -> DispatchResult {1037 ) -> DispatchResult {1038 let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);1038 let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);1039 let mut target_collection = <CollectionHandle<T>>::try_get(collection_id)?;1039 let collection = <CollectionHandle<T>>::try_get(collection_id)?;10401041 // =========10421040 target_collection.check_is_owner_or_admin(&sender)?;1043 <PalletCommon<T>>::set_field(&collection, &sender, CollectionField::ConstOnChainSchema, schema.into_inner())?;10411042 target_collection.const_on_chain_schema = schema;104310441044 <Pallet<T>>::deposit_event(Event::<T>::ConstOnChainSchemaSet(1045 <Pallet<T>>::deposit_event(Event::<T>::ConstOnChainSchemaSet(1045 collection_id1046 collection_id1046 ));1047 ));10471048 target_collection.save()1048 Ok(())1049 }1049 }105010501051 /// Set variable on-chain data schema.1051 /// Set variable on-chain data schema.1068 schema: BoundedVec<u8, ConstU32<VARIABLE_ON_CHAIN_SCHEMA_LIMIT>>1068 schema: BoundedVec<u8, ConstU32<VARIABLE_ON_CHAIN_SCHEMA_LIMIT>>1069 ) -> DispatchResult {1069 ) -> DispatchResult {1070 let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);1070 let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);1071 let mut target_collection = <CollectionHandle<T>>::try_get(collection_id)?;1071 let collection = <CollectionHandle<T>>::try_get(collection_id)?;10721073 // =========10741072 target_collection.check_is_owner_or_admin(&sender)?;1075 <PalletCommon<T>>::set_field(&collection, &sender, CollectionField::VariableOnChainSchema, schema.into_inner())?;10731074 target_collection.variable_on_chain_schema = schema;107510761076 <Pallet<T>>::deposit_event(Event::<T>::VariableOnChainSchemaSet(1077 <Pallet<T>>::deposit_event(Event::<T>::VariableOnChainSchemaSet(1077 collection_id1078 collection_id1078 ));1079 ));10791080 target_collection.save()1080 Ok(())1081 }1081 }108210821083 #[weight = <SelfWeightOf<T>>::set_collection_limits()]1083 #[weight = <SelfWeightOf<T>>::set_collection_limits()]primitives/data-structs/src/lib.rsdiffbeforeafterboth78pub const VARIABLE_ON_CHAIN_SCHEMA_LIMIT: u32 = 8192;78pub const VARIABLE_ON_CHAIN_SCHEMA_LIMIT: u32 = 8192;79pub const CONST_ON_CHAIN_SCHEMA_LIMIT: u32 = 32768;79pub const CONST_ON_CHAIN_SCHEMA_LIMIT: u32 = 32768;8081pub const COLLECTION_FIELD_LIMIT: u32 = CONST_ON_CHAIN_SCHEMA_LIMIT;82// u32::max is not const: OFFCHAIN_SCHEMA_LIMIT.max(VARIABLE_ON_CHAIN_SCHEMA_LIMIT).max(CONST_ON_CHAIN_SCHEMA_LIMIT);808381pub const MAX_COLLECTION_NAME_LENGTH: u32 = 64;84pub const MAX_COLLECTION_NAME_LENGTH: u32 = 64;82pub const MAX_COLLECTION_DESCRIPTION_LENGTH: u32 = 256;85pub const MAX_COLLECTION_DESCRIPTION_LENGTH: u32 = 256;248 }251 }249}252}250253254/// Used in storage251#[struct_versioning::versioned(version = 2, upper)]255#[struct_versioning::versioned(version = 2, upper)]252#[derive(Encode, Decode, Clone, PartialEq, TypeInfo, MaxEncodedLen)]256#[derive(Encode, Decode, Clone, PartialEq, TypeInfo, MaxEncodedLen)]253#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))]254pub struct Collection<AccountId> {257pub struct Collection<AccountId> {255 pub owner: AccountId,258 pub owner: AccountId,256 pub mode: CollectionMode,259 pub mode: CollectionMode,257 pub access: AccessMode,260 pub access: AccessMode,258 #[cfg_attr(feature = "serde1", serde(with = "bounded::vec_serde"))]259 pub name: BoundedVec<u16, ConstU32<MAX_COLLECTION_NAME_LENGTH>>,261 pub name: BoundedVec<u16, ConstU32<MAX_COLLECTION_NAME_LENGTH>>,260 #[cfg_attr(feature = "serde1", serde(with = "bounded::vec_serde"))]261 pub description: BoundedVec<u16, ConstU32<MAX_COLLECTION_DESCRIPTION_LENGTH>>,262 pub description: BoundedVec<u16, ConstU32<MAX_COLLECTION_DESCRIPTION_LENGTH>>,262 #[cfg_attr(feature = "serde1", serde(with = "bounded::vec_serde"))]263 pub token_prefix: BoundedVec<u8, ConstU32<MAX_TOKEN_PREFIX_LENGTH>>,263 pub token_prefix: BoundedVec<u8, ConstU32<MAX_TOKEN_PREFIX_LENGTH>>,264 pub mint_mode: bool,264 pub mint_mode: bool,265265 #[cfg_attr(feature = "serde1", serde(with = "bounded::vec_serde"))]266 #[version(..2)]266 pub offchain_schema: BoundedVec<u8, ConstU32<OFFCHAIN_SCHEMA_LIMIT>>,267 pub offchain_schema: BoundedVec<u8, ConstU32<OFFCHAIN_SCHEMA_LIMIT>>,268267 pub schema_version: SchemaVersion,269 pub schema_version: SchemaVersion,272 #[version(2.., upper(limits.into()))]274 #[version(2.., upper(limits.into()))]273 pub limits: CollectionLimitsVersion2,275 pub limits: CollectionLimitsVersion2,274276275 #[cfg_attr(feature = "serde1", serde(with = "bounded::vec_serde"))]277 #[version(..2)]276 pub variable_on_chain_schema: BoundedVec<u8, ConstU32<VARIABLE_ON_CHAIN_SCHEMA_LIMIT>>,278 pub variable_on_chain_schema: BoundedVec<u8, ConstU32<VARIABLE_ON_CHAIN_SCHEMA_LIMIT>>,277 #[cfg_attr(feature = "serde1", serde(with = "bounded::vec_serde"))]279 #[version(..2)]278 pub const_on_chain_schema: BoundedVec<u8, ConstU32<CONST_ON_CHAIN_SCHEMA_LIMIT>>,280 pub const_on_chain_schema: BoundedVec<u8, ConstU32<CONST_ON_CHAIN_SCHEMA_LIMIT>>,281279 pub meta_update_permission: MetaUpdatePermission,282 pub meta_update_permission: MetaUpdatePermission,280}283}284285/// Used in RPC calls286#[derive(Encode, Decode, Clone, PartialEq, TypeInfo)]287#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))]288pub struct RpcCollection<AccountId> {289 pub owner: AccountId,290 pub mode: CollectionMode,291 pub access: AccessMode,292 pub name: Vec<u16>,293 pub description: Vec<u16>,294 pub token_prefix: Vec<u8>,295 pub mint_mode: bool,296 pub offchain_schema: Vec<u8>,297 pub schema_version: SchemaVersion,298 pub sponsorship: SponsorshipState<AccountId>,299 pub limits: CollectionLimits,300 pub variable_on_chain_schema: Vec<u8>,301 pub const_on_chain_schema: Vec<u8>,302 pub meta_update_permission: MetaUpdatePermission,303}304305#[derive(Encode, Decode, Clone, PartialEq, TypeInfo, MaxEncodedLen)]306#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))]307pub enum CollectionField {308 VariableOnChainSchema,309 ConstOnChainSchema,310 OffchainSchema,311}281312282#[derive(Encode, Decode, Clone, PartialEq, TypeInfo, Debug, Derivative, MaxEncodedLen)]313#[derive(Encode, Decode, Clone, PartialEq, TypeInfo, Debug, Derivative, MaxEncodedLen)]283#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))]314#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))]primitives/rpc/src/lib.rsdiffbeforeafterboth161617#![cfg_attr(not(feature = "std"), no_std)]17#![cfg_attr(not(feature = "std"), no_std)]181819use up_data_structs::{CollectionId, TokenId, Collection, CollectionStats, CollectionLimits};19use up_data_structs::{CollectionId, TokenId, RpcCollection, Collection, CollectionStats, CollectionLimits};20use sp_std::vec::Vec;20use sp_std::vec::Vec;21use codec::Decode;21use codec::Decode;22use sp_runtime::DispatchError;22use sp_runtime::DispatchError;53 fn allowlist(collection: CollectionId) -> Result<Vec<CrossAccountId>>;53 fn allowlist(collection: CollectionId) -> Result<Vec<CrossAccountId>>;54 fn allowed(collection: CollectionId, user: CrossAccountId) -> Result<bool>;54 fn allowed(collection: CollectionId, user: CrossAccountId) -> Result<bool>;55 fn last_token_id(collection: CollectionId) -> Result<TokenId>;55 fn last_token_id(collection: CollectionId) -> Result<TokenId>;56 fn collection_by_id(collection: CollectionId) -> Result<Option<Collection<AccountId>>>;56 fn collection_by_id(collection: CollectionId) -> Result<Option<RpcCollection<AccountId>>>;57 fn collection_stats() -> Result<CollectionStats>;57 fn collection_stats() -> Result<CollectionStats>;58 fn next_sponsored(collection: CollectionId, account: CrossAccountId, token: TokenId) -> Result<Option<u64>>;58 fn next_sponsored(collection: CollectionId, account: CrossAccountId, token: TokenId) -> Result<Option<u64>>;59 fn effective_collection_limits(collection_id: CollectionId) -> Result<Option<CollectionLimits>>;59 fn effective_collection_limits(collection_id: CollectionId) -> Result<Option<CollectionLimits>>;runtime/common/src/runtime_apis.rsdiffbeforeafterboth58 fn last_token_id(collection: CollectionId) -> Result<TokenId, DispatchError> {58 fn last_token_id(collection: CollectionId) -> Result<TokenId, DispatchError> {59 dispatch_unique_runtime!(collection.last_token_id())59 dispatch_unique_runtime!(collection.last_token_id())60 }60 }61 fn collection_by_id(collection: CollectionId) -> Result<Option<Collection<AccountId>>, DispatchError> {61 fn collection_by_id(collection: CollectionId) -> Result<Option<RpcCollection<AccountId>>, DispatchError> {62 Ok(<pallet_common::CollectionById<Runtime>>::get(collection))62 Ok(<pallet_common::Pallet<Runtime>>::rpc_collection(collection))63 }63 }64 fn collection_stats() -> Result<CollectionStats, DispatchError> {64 fn collection_stats() -> Result<CollectionStats, DispatchError> {65 Ok(<pallet_common::Pallet<Runtime>>::collection_stats())65 Ok(<pallet_common::Pallet<Runtime>>::collection_stats())runtime/opal/src/lib.rsdiffbeforeafterboth67 },67 },68};68};69use up_data_structs::mapping::{EvmTokenAddressMapping, CrossTokenAddressMapping};69use up_data_structs::mapping::{EvmTokenAddressMapping, CrossTokenAddressMapping};70use up_data_structs::{CollectionId, TokenId, CollectionStats, Collection};70use up_data_structs::{CollectionId, TokenId, CollectionStats, Collection, RpcCollection};71// use pallet_contracts::weights::WeightInfo;71// use pallet_contracts::weights::WeightInfo;72// #[cfg(any(feature = "std", test))]72// #[cfg(any(feature = "std", test))]73use frame_system::{73use frame_system::{