git.delta.rocks / unique-network / refs/commits / a66e7a4819dc

difftreelog

Add properties RPC

Daniel Shiposha2022-05-05parent: #a7c09a3.patch.diff
in: master

8 files changed

modifiedclient/rpc/src/lib.rsdiffbeforeafterboth
--- a/client/rpc/src/lib.rs
+++ b/client/rpc/src/lib.rs
@@ -19,7 +19,10 @@
 use codec::Decode;
 use jsonrpc_core::{Error as RpcError, ErrorCode, Result};
 use jsonrpc_derive::rpc;
-use up_data_structs::{RpcCollection, CollectionId, CollectionStats, CollectionLimits, TokenId};
+use up_data_structs::{
+	RpcCollection, CollectionId, CollectionStats, CollectionLimits, TokenId, Property, PropertyKey,
+	PropertyKeyPermission,
+};
 use sp_api::{BlockId, BlockT, ProvideRuntimeApi, ApiExt};
 use sp_blockchain::HeaderBackend;
 use up_rpc::UniqueApi as UniqueRuntimeApi;
@@ -76,6 +79,31 @@
 		at: Option<BlockHash>,
 	) -> Result<Vec<u8>>;
 
+	#[rpc(name = "unique_collectionProperties")]
+	fn collection_properties(
+		&self,
+		collection: CollectionId,
+		keys: Vec<String>,
+		at: Option<BlockHash>,
+	) -> Result<Vec<Property>>;
+
+	#[rpc(name = "unique_tokenProperties")]
+	fn token_properties(
+		&self,
+		collection: CollectionId,
+		token_id: TokenId,
+		properties: Vec<String>,
+		at: Option<BlockHash>,
+	) -> Result<Vec<Property>>;
+
+	#[rpc(name = "unique_propertyPermissions")]
+	fn property_permissions(
+		&self,
+		collection: CollectionId,
+		keys: Vec<String>,
+		at: Option<BlockHash>,
+	) -> Result<Vec<PropertyKeyPermission>>;
+
 	#[rpc(name = "unique_totalSupply")]
 	fn total_supply(&self, collection: CollectionId, at: Option<BlockHash>) -> Result<u32>;
 	#[rpc(name = "unique_accountBalance")]
@@ -177,7 +205,9 @@
 
 macro_rules! pass_method {
 	(
-		$method_name:ident($($name:ident: $ty:ty),* $(,)?) -> $result:ty $(=> $mapper:expr)?
+		$method_name:ident(
+			$($(#[map(|$map_arg:ident| $map:expr)])? $name:ident: $ty:ty),* $(,)?
+		) -> $result:ty $(=> $mapper:expr)?
 		$(; changed_in $ver:expr, $changed_method_name:ident ($($changed_name:expr), * $(,)?) => $fixer:expr)*
 	) => {
 		fn $method_name(
@@ -205,7 +235,7 @@
 			let result = $(if _api_version < $ver {
 				api.$changed_method_name(&at, $($changed_name),*).map(|r| r.map($fixer))
 			} else)*
-			{ api.$method_name(&at, $($name),*) };
+			{ api.$method_name(&at, $($((|$map_arg: $ty| $map))? ($name)),*) };
 
 			let result = result.map_err(|e| RpcError {
 				code: ErrorCode::ServerError(Error::RuntimeError.into()),
@@ -242,6 +272,28 @@
 	pass_method!(const_metadata(collection: CollectionId, token: TokenId) -> Vec<u8>);
 	pass_method!(variable_metadata(collection: CollectionId, token: TokenId) -> Vec<u8>);
 
+	pass_method!(collection_properties(
+		collection: CollectionId,
+
+		#[map(|keys| string_keys_to_bytes_keys(keys))]
+		keys: Vec<String>
+	) -> Vec<Property>);
+
+	pass_method!(token_properties(
+		collection: CollectionId,
+		token_id: TokenId,
+
+		#[map(|keys| string_keys_to_bytes_keys(keys))]
+		properties: Vec<String>
+	) -> Vec<Property>);
+
+	pass_method!(property_permissions(
+		collection: CollectionId,
+
+		#[map(|keys| string_keys_to_bytes_keys(keys))]
+		keys: Vec<String>
+	) -> Vec<PropertyKeyPermission>);
+
 	pass_method!(total_supply(collection: CollectionId) -> u32);
 	pass_method!(account_balance(collection: CollectionId, account: CrossAccountId) -> u32);
 	pass_method!(balance(collection: CollectionId, account: CrossAccountId, token: TokenId) -> String => |v| v.to_string());
@@ -256,3 +308,7 @@
 	pass_method!(next_sponsored(collection: CollectionId, account: CrossAccountId, token: TokenId) -> Option<u64>);
 	pass_method!(effective_collection_limits(collection_id: CollectionId) -> Option<CollectionLimits>);
 }
+
+fn string_keys_to_bytes_keys(keys: Vec<String>) -> Vec<Vec<u8>> {
+	keys.into_iter().map(|key| key.into_bytes()).collect()
+}
modifiedpallets/common/src/lib.rsdiffbeforeafterboth
--- a/pallets/common/src/lib.rs
+++ b/pallets/common/src/lib.rs
@@ -388,6 +388,7 @@
 
 	/// Collection properties
 	#[pallet::storage]
+	#[pallet::getter(fn collection_properties)]
 	pub type CollectionProperties<T> = StorageMap<
 		Hasher = Blake2_128Concat,
 		Key = CollectionId,
@@ -397,7 +398,7 @@
 	>;
 
 	#[pallet::storage]
-	#[pallet::getter(fn property_permission)]
+	#[pallet::getter(fn property_permissions)]
 	pub type CollectionPropertyPermissions<T> = StorageMap<
 		Hasher = Blake2_128Concat,
 		Key = CollectionId,
@@ -656,9 +657,7 @@
 		CollectionProperties::<T>::insert(
 			id,
 			Properties::from_collection_props_vec(data.properties)
-				.map_err(|e| -> Error::<T> {
-					e.into()
-				})?,
+				.map_err(|e| -> Error<T> { e.into() })?,
 		);
 
 		let token_props_permissions: PropertiesPermissionMap = data
@@ -667,9 +666,7 @@
 			.map(|property| (property.key, property.permission))
 			.collect::<BTreeMap<_, _>>()
 			.try_into()
-			.map_err(|_| -> Error::<T> {
-				PropertiesError::PropertyLimitReached.into()
-			})?;
+			.map_err(|_| -> Error<T> { PropertiesError::PropertyLimitReached.into() })?;
 
 		CollectionPropertyPermissions::<T>::insert(id, token_props_permissions);
 
@@ -754,9 +751,7 @@
 		CollectionProperties::<T>::try_mutate(collection.id, |properties| {
 			properties.try_set_property(property.clone())
 		})
-		.map_err(|e| -> Error::<T> {
-			e.into()
-		})?;
+		.map_err(|e| -> Error<T> { e.into() })?;
 
 		Self::deposit_event(Event::CollectionPropertySet(collection.id, property));
 
@@ -786,7 +781,10 @@
 			properties.remove_property(&property_key);
 		});
 
-		Self::deposit_event(Event::CollectionPropertyDeleted(collection.id, property_key));
+		Self::deposit_event(Event::CollectionPropertyDeleted(
+			collection.id,
+			property_key,
+		));
 
 		Ok(())
 	}
@@ -823,9 +821,7 @@
 			let property_permission = property_permission.clone();
 			permissions.try_insert(property_permission.key, property_permission.permission)
 		})
-		.map_err(|_| -> Error::<T> {
-			PropertiesError::PropertyLimitReached.into()
-		})?;
+		.map_err(|_| -> Error<T> { PropertiesError::PropertyLimitReached.into() })?;
 
 		Self::deposit_event(Event::PropertyPermissionSet(
 			collection.id,
modifiedpallets/nonfungible/src/common.rsdiffbeforeafterboth
--- a/pallets/nonfungible/src/common.rs
+++ b/pallets/nonfungible/src/common.rs
@@ -184,7 +184,7 @@
 
 		with_weight(
 			<Pallet<T>>::delete_collection_properties(self, &sender, property_keys),
-			weight
+			weight,
 		)
 	}
 
modifiedpallets/nonfungible/src/lib.rsdiffbeforeafterboth
--- a/pallets/nonfungible/src/lib.rs
+++ b/pallets/nonfungible/src/lib.rs
@@ -96,6 +96,7 @@
 	>;
 
 	#[pallet::storage]
+	#[pallet::getter(fn token_properties)]
 	pub type TokenProperties<T: Config> = StorageNMap<
 		Key = (Key<Twox64Concat, CollectionId>, Key<Twox64Concat, TokenId>),
 		Value = up_data_structs::Properties,
@@ -265,9 +266,8 @@
 
 		<TokenProperties<T>>::try_mutate((collection.id, token_id), |properties| {
 			properties.try_set_property(property.clone())
-		}).map_err(|e| -> CommonError::<T> {
-			e.into()
-		})?;
+		})
+		.map_err(|e| -> CommonError<T> { e.into() })?;
 
 		<PalletCommon<T>>::deposit_event(CommonEvent::TokenPropertySet(
 			collection.id,
@@ -318,7 +318,7 @@
 		token_id: TokenId,
 		property_key: &PropertyKey,
 	) -> DispatchResult {
-		let permission = <PalletCommon<T>>::property_permission(collection.id)
+		let permission = <PalletCommon<T>>::property_permissions(collection.id)
 			.get(property_key)
 			.map(|p| p.clone())
 			.unwrap_or(PropertyPermission::None);
modifiedprimitives/data-structs/src/lib.rsdiffbeforeafterboth
--- a/primitives/data-structs/src/lib.rs
+++ b/primitives/data-structs/src/lib.rs
@@ -634,6 +634,7 @@
 pub type PropertyValue = BoundedVec<u8, ConstU32<MAX_PROPERTY_VALUE_LENGTH>>;
 
 #[derive(Encode, Decode, TypeInfo, Debug, MaxEncodedLen, PartialEq, Clone)]
+#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))]
 pub enum PropertyPermission {
 	None,
 	AdminConst,
@@ -644,14 +645,21 @@
 }
 
 #[derive(Encode, Decode, Debug, TypeInfo, Clone, PartialEq, MaxEncodedLen)]
+#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))]
 pub struct Property {
+	#[cfg_attr(feature = "serde1", serde(with = "bounded::vec_serde"))]
 	pub key: PropertyKey,
+
+	#[cfg_attr(feature = "serde1", serde(with = "bounded::vec_serde"))]
 	pub value: PropertyValue,
 }
 
 #[derive(Encode, Decode, TypeInfo, Debug, MaxEncodedLen, PartialEq, Clone)]
+#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))]
 pub struct PropertyKeyPermission {
+	#[cfg_attr(feature = "serde1", serde(with = "bounded::vec_serde"))]
 	pub key: PropertyKey,
+
 	pub permission: PropertyPermission,
 }
 
@@ -723,6 +731,10 @@
 	pub fn get_property(&self, key: &PropertyKey) -> Option<&PropertyValue> {
 		self.map.get(key)
 	}
+
+	pub fn iter(&self) -> impl Iterator<Item = (&PropertyKey, &PropertyValue)> {
+		self.map.iter()
+	}
 }
 
 pub struct CollectionProperties;
modifiedprimitives/rpc/src/lib.rsdiffbeforeafterboth
--- a/primitives/rpc/src/lib.rs
+++ b/primitives/rpc/src/lib.rs
@@ -16,7 +16,10 @@
 
 #![cfg_attr(not(feature = "std"), no_std)]
 
-use up_data_structs::{CollectionId, TokenId, RpcCollection, CollectionStats, CollectionLimits};
+use up_data_structs::{
+	CollectionId, TokenId, RpcCollection, CollectionStats, CollectionLimits, Property, PropertyKey,
+	PropertyKeyPermission,
+};
 use sp_std::vec::Vec;
 use codec::Decode;
 use sp_runtime::DispatchError;
@@ -41,6 +44,19 @@
 		fn const_metadata(collection: CollectionId, token: TokenId) -> Result<Vec<u8>>;
 		fn variable_metadata(collection: CollectionId, token: TokenId) -> Result<Vec<u8>>;
 
+		fn collection_properties(collection: CollectionId, properties: Vec<Vec<u8>>) -> Result<Vec<Property>>;
+
+		fn token_properties(
+			collection: CollectionId,
+			token_id: TokenId,
+			properties: Vec<Vec<u8>>
+		) -> Result<Vec<Property>>;
+
+		fn property_permissions(
+			collection: CollectionId,
+			properties: Vec<Vec<u8>>
+		) -> Result<Vec<PropertyKeyPermission>>;
+
 		fn total_supply(collection: CollectionId) -> Result<u32>;
 		fn account_balance(collection: CollectionId, account: CrossAccountId) -> Result<u32>;
 		fn balance(collection: CollectionId, account: CrossAccountId, token: TokenId) -> Result<u128>;
modifiedruntime/common/src/runtime_apis.rsdiffbeforeafterboth
before · runtime/common/src/runtime_apis.rs
1#[macro_export]2macro_rules! impl_common_runtime_apis {3    (4        $(5            #![custom_apis]67            $($custom_apis:tt)+8        )?9    ) => {10        impl_runtime_apis! {11            $($($custom_apis)+)?1213            impl up_rpc::UniqueApi<Block, CrossAccountId, AccountId> for Runtime {14                fn account_tokens(collection: CollectionId, account: CrossAccountId) -> Result<Vec<TokenId>, DispatchError> {15                    dispatch_unique_runtime!(collection.account_tokens(account))16                }17                fn collection_tokens(collection: CollectionId) -> Result<Vec<TokenId>, DispatchError> {18                    dispatch_unique_runtime!(collection.collection_tokens())19                }20                fn token_exists(collection: CollectionId, token: TokenId) -> Result<bool, DispatchError> {21                    dispatch_unique_runtime!(collection.token_exists(token))22                }2324                fn token_owner(collection: CollectionId, token: TokenId) -> Result<Option<CrossAccountId>, DispatchError> {25                    dispatch_unique_runtime!(collection.token_owner(token))26                }27                fn topmost_token_owner(collection: CollectionId, token: TokenId) -> Result<Option<CrossAccountId>, DispatchError> {28                    let budget = up_data_structs::budget::Value::new(5);2930                    Ok(Some(<pallet_structure::Pallet<Runtime>>::find_topmost_owner(collection, token, &budget)?))31                }32                fn const_metadata(collection: CollectionId, token: TokenId) -> Result<Vec<u8>, DispatchError> {33                    dispatch_unique_runtime!(collection.const_metadata(token))34                }35                fn variable_metadata(collection: CollectionId, token: TokenId) -> Result<Vec<u8>, DispatchError> {36                    dispatch_unique_runtime!(collection.variable_metadata(token))37                }3839                fn total_supply(collection: CollectionId) -> Result<u32, DispatchError> {40                    dispatch_unique_runtime!(collection.total_supply())41                }42                fn account_balance(collection: CollectionId, account: CrossAccountId) -> Result<u32, DispatchError> {43                    dispatch_unique_runtime!(collection.account_balance(account))44                }45                fn balance(collection: CollectionId, account: CrossAccountId, token: TokenId) -> Result<u128, DispatchError> {46                    dispatch_unique_runtime!(collection.balance(account, token))47                }48                fn allowance(49                    collection: CollectionId,50                    sender: CrossAccountId,51                    spender: CrossAccountId,52                    token: TokenId,53                ) -> Result<u128, DispatchError> {54                    dispatch_unique_runtime!(collection.allowance(sender, spender, token))55                }5657                fn adminlist(collection: CollectionId) -> Result<Vec<CrossAccountId>, DispatchError> {58                    Ok(<pallet_common::Pallet<Runtime>>::adminlist(collection))59                }60                fn allowlist(collection: CollectionId) -> Result<Vec<CrossAccountId>, DispatchError> {61                    Ok(<pallet_common::Pallet<Runtime>>::allowlist(collection))62                }63                fn allowed(collection: CollectionId, user: CrossAccountId) -> Result<bool, DispatchError> {64                    Ok(<pallet_common::Pallet<Runtime>>::allowed(collection, user))65                }66                fn last_token_id(collection: CollectionId) -> Result<TokenId, DispatchError> {67                    dispatch_unique_runtime!(collection.last_token_id())68                }69                fn collection_by_id(collection: CollectionId) -> Result<Option<RpcCollection<AccountId>>, DispatchError> {70                    Ok(<pallet_common::Pallet<Runtime>>::rpc_collection(collection))71                }72                fn collection_stats() -> Result<CollectionStats, DispatchError> {73                    Ok(<pallet_common::Pallet<Runtime>>::collection_stats())74                }75                fn next_sponsored(collection: CollectionId, account: CrossAccountId, token: TokenId) -> Result<Option<u64>, DispatchError> {76                    Ok(<$crate::sponsoring::UniqueSponsorshipPredict<Runtime> as77                            $crate::sponsoring::SponsorshipPredict<Runtime>>::predict(78                        collection,79                        account,80                        token))81                }8283                fn effective_collection_limits(collection: CollectionId) -> Result<Option<CollectionLimits>, DispatchError> {84                    Ok(<pallet_common::Pallet<Runtime>>::effective_collection_limits(collection))85                }86            }8788            impl sp_api::Core<Block> for Runtime {89                fn version() -> RuntimeVersion {90                    VERSION91                }9293                fn execute_block(block: Block) {94                    Executive::execute_block(block)95                }9697                fn initialize_block(header: &<Block as BlockT>::Header) {98                    Executive::initialize_block(header)99                }100            }101102            impl sp_api::Metadata<Block> for Runtime {103                fn metadata() -> OpaqueMetadata {104                    OpaqueMetadata::new(Runtime::metadata().into())105                }106            }107108            impl sp_block_builder::BlockBuilder<Block> for Runtime {109                fn apply_extrinsic(extrinsic: <Block as BlockT>::Extrinsic) -> ApplyExtrinsicResult {110                    Executive::apply_extrinsic(extrinsic)111                }112113                fn finalize_block() -> <Block as BlockT>::Header {114                    Executive::finalize_block()115                }116117                fn inherent_extrinsics(data: sp_inherents::InherentData) -> Vec<<Block as BlockT>::Extrinsic> {118                    data.create_extrinsics()119                }120121                fn check_inherents(122                    block: Block,123                    data: sp_inherents::InherentData,124                ) -> sp_inherents::CheckInherentsResult {125                    data.check_extrinsics(&block)126                }127128                // fn random_seed() -> <Block as BlockT>::Hash {129                //     RandomnessCollectiveFlip::random_seed().0130                // }131            }132133            impl sp_transaction_pool::runtime_api::TaggedTransactionQueue<Block> for Runtime {134                fn validate_transaction(135                    source: TransactionSource,136                    tx: <Block as BlockT>::Extrinsic,137                    hash: <Block as BlockT>::Hash,138                ) -> TransactionValidity {139                    Executive::validate_transaction(source, tx, hash)140                }141            }142143            impl sp_offchain::OffchainWorkerApi<Block> for Runtime {144                fn offchain_worker(header: &<Block as BlockT>::Header) {145                    Executive::offchain_worker(header)146                }147            }148149            impl fp_rpc::EthereumRuntimeRPCApi<Block> for Runtime {150                fn chain_id() -> u64 {151                    <Runtime as pallet_evm::Config>::ChainId::get()152                }153154                fn account_basic(address: H160) -> EVMAccount {155                    EVM::account_basic(&address)156                }157158                fn gas_price() -> U256 {159                    <Runtime as pallet_evm::Config>::FeeCalculator::min_gas_price()160                }161162                fn account_code_at(address: H160) -> Vec<u8> {163                    EVM::account_codes(address)164                }165166                fn author() -> H160 {167                    <pallet_evm::Pallet<Runtime>>::find_author()168                }169170                fn storage_at(address: H160, index: U256) -> H256 {171                    let mut tmp = [0u8; 32];172                    index.to_big_endian(&mut tmp);173                    EVM::account_storages(address, H256::from_slice(&tmp[..]))174                }175176                #[allow(clippy::redundant_closure)]177                fn call(178                    from: H160,179                    to: H160,180                    data: Vec<u8>,181                    value: U256,182                    gas_limit: U256,183                    max_fee_per_gas: Option<U256>,184                    max_priority_fee_per_gas: Option<U256>,185                    nonce: Option<U256>,186                    estimate: bool,187                    access_list: Option<Vec<(H160, Vec<H256>)>>,188                ) -> Result<pallet_evm::CallInfo, sp_runtime::DispatchError> {189                    let config = if estimate {190                        let mut config = <Runtime as pallet_evm::Config>::config().clone();191                        config.estimate = true;192                        Some(config)193                    } else {194                        None195                    };196197                    let is_transactional = false;198                    <Runtime as pallet_evm::Config>::Runner::call(199                        CrossAccountId::from_eth(from),200                        to,201                        data,202                        value,203                        gas_limit.low_u64(),204                        max_fee_per_gas,205                        max_priority_fee_per_gas,206                        nonce,207                        access_list.unwrap_or_default(),208                        is_transactional,209                        config.as_ref().unwrap_or_else(|| <Runtime as pallet_evm::Config>::config()),210                    ).map_err(|err| err.into())211                }212213                #[allow(clippy::redundant_closure)]214                fn create(215                    from: H160,216                    data: Vec<u8>,217                    value: U256,218                    gas_limit: U256,219                    max_fee_per_gas: Option<U256>,220                    max_priority_fee_per_gas: Option<U256>,221                    nonce: Option<U256>,222                    estimate: bool,223                    access_list: Option<Vec<(H160, Vec<H256>)>>,224                ) -> Result<pallet_evm::CreateInfo, sp_runtime::DispatchError> {225                    let config = if estimate {226                        let mut config = <Runtime as pallet_evm::Config>::config().clone();227                        config.estimate = true;228                        Some(config)229                    } else {230                        None231                    };232233                    let is_transactional = false;234                    <Runtime as pallet_evm::Config>::Runner::create(235                        CrossAccountId::from_eth(from),236                        data,237                        value,238                        gas_limit.low_u64(),239                        max_fee_per_gas,240                        max_priority_fee_per_gas,241                        nonce,242                        access_list.unwrap_or_default(),243                        is_transactional,244                        config.as_ref().unwrap_or_else(|| <Runtime as pallet_evm::Config>::config()),245                    ).map_err(|err| err.into())246                }247248                fn current_transaction_statuses() -> Option<Vec<TransactionStatus>> {249                    Ethereum::current_transaction_statuses()250                }251252                fn current_block() -> Option<pallet_ethereum::Block> {253                    Ethereum::current_block()254                }255256                fn current_receipts() -> Option<Vec<pallet_ethereum::Receipt>> {257                    Ethereum::current_receipts()258                }259260                fn current_all() -> (261                    Option<pallet_ethereum::Block>,262                    Option<Vec<pallet_ethereum::Receipt>>,263                    Option<Vec<TransactionStatus>>264                ) {265                    (266                        Ethereum::current_block(),267                        Ethereum::current_receipts(),268                        Ethereum::current_transaction_statuses()269                    )270                }271272                fn extrinsic_filter(xts: Vec<<Block as sp_api::BlockT>::Extrinsic>) -> Vec<pallet_ethereum::Transaction> {273                    xts.into_iter().filter_map(|xt| match xt.0.function {274                        Call::Ethereum(pallet_ethereum::Call::transact { transaction }) => Some(transaction),275                        _ => None276                    }).collect()277                }278279                fn elasticity() -> Option<Permill> {280                    None281                }282            }283284            impl fp_rpc::ConvertTransactionRuntimeApi<Block> for Runtime {285                fn convert_transaction(transaction: pallet_ethereum::Transaction) -> <Block as BlockT>::Extrinsic  {286                    UncheckedExtrinsic::new_unsigned(287                        pallet_ethereum::Call::<Runtime>::transact { transaction }.into(),288                    )289                }290            }291292            impl sp_session::SessionKeys<Block> for Runtime {293                fn decode_session_keys(294                    encoded: Vec<u8>,295                ) -> Option<Vec<(Vec<u8>, KeyTypeId)>> {296                    SessionKeys::decode_into_raw_public_keys(&encoded)297                }298299                fn generate_session_keys(seed: Option<Vec<u8>>) -> Vec<u8> {300                    SessionKeys::generate(seed)301                }302            }303304            impl sp_consensus_aura::AuraApi<Block, AuraId> for Runtime {305                fn slot_duration() -> sp_consensus_aura::SlotDuration {306                    sp_consensus_aura::SlotDuration::from_millis(Aura::slot_duration())307                }308309                fn authorities() -> Vec<AuraId> {310                    Aura::authorities().to_vec()311                }312            }313314            impl cumulus_primitives_core::CollectCollationInfo<Block> for Runtime {315                fn collect_collation_info(header: &<Block as BlockT>::Header) -> cumulus_primitives_core::CollationInfo {316                    ParachainSystem::collect_collation_info(header)317                }318            }319320            impl frame_system_rpc_runtime_api::AccountNonceApi<Block, AccountId, Index> for Runtime {321                fn account_nonce(account: AccountId) -> Index {322                    System::account_nonce(account)323                }324            }325326            impl pallet_transaction_payment_rpc_runtime_api::TransactionPaymentApi<Block, Balance> for Runtime {327                fn query_info(uxt: <Block as BlockT>::Extrinsic, len: u32) -> RuntimeDispatchInfo<Balance> {328                    TransactionPayment::query_info(uxt, len)329                }330                fn query_fee_details(uxt: <Block as BlockT>::Extrinsic, len: u32) -> FeeDetails<Balance> {331                    TransactionPayment::query_fee_details(uxt, len)332                }333            }334335            /*336            impl pallet_contracts_rpc_runtime_api::ContractsApi<Block, AccountId, Balance, BlockNumber, Hash>337                for Runtime338            {339                fn call(340                    origin: AccountId,341                    dest: AccountId,342                    value: Balance,343                    gas_limit: u64,344                    input_data: Vec<u8>,345                ) -> pallet_contracts_primitives::ContractExecResult {346                    Contracts::bare_call(origin, dest, value, gas_limit, input_data, false)347                }348349                fn instantiate(350                    origin: AccountId,351                    endowment: Balance,352                    gas_limit: u64,353                    code: pallet_contracts_primitives::Code<Hash>,354                    data: Vec<u8>,355                    salt: Vec<u8>,356                ) -> pallet_contracts_primitives::ContractInstantiateResult<AccountId, BlockNumber>357                {358                    Contracts::bare_instantiate(origin, endowment, gas_limit, code, data, salt, true, false)359                }360361                fn get_storage(362                    address: AccountId,363                    key: [u8; 32],364                ) -> pallet_contracts_primitives::GetStorageResult {365                    Contracts::get_storage(address, key)366                }367368                fn rent_projection(369                    address: AccountId,370                ) -> pallet_contracts_primitives::RentProjectionResult<BlockNumber> {371                    Contracts::rent_projection(address)372                }373            }374            */375376            #[cfg(feature = "runtime-benchmarks")]377            impl frame_benchmarking::Benchmark<Block> for Runtime {378                fn benchmark_metadata(extra: bool) -> (379                    Vec<frame_benchmarking::BenchmarkList>,380                    Vec<frame_support::traits::StorageInfo>,381                ) {382                    use frame_benchmarking::{list_benchmark, Benchmarking, BenchmarkList};383                    use frame_support::traits::StorageInfoTrait;384385                    let mut list = Vec::<BenchmarkList>::new();386387                    list_benchmark!(list, extra, pallet_evm_migration, EvmMigration);388                    list_benchmark!(list, extra, pallet_unique, Unique);389                    list_benchmark!(list, extra, pallet_structure, Structure);390                    list_benchmark!(list, extra, pallet_inflation, Inflation);391                    list_benchmark!(list, extra, pallet_fungible, Fungible);392                    list_benchmark!(list, extra, pallet_refungible, Refungible);393                    list_benchmark!(list, extra, pallet_nonfungible, Nonfungible);394                    // list_benchmark!(list, extra, pallet_evm_coder_substrate, EvmCoderSubstrate);395396                    let storage_info = AllPalletsReversedWithSystemFirst::storage_info();397398                    return (list, storage_info)399                }400401                fn dispatch_benchmark(402                    config: frame_benchmarking::BenchmarkConfig403                ) -> Result<Vec<frame_benchmarking::BenchmarkBatch>, sp_runtime::RuntimeString> {404                    use frame_benchmarking::{Benchmarking, BenchmarkBatch, add_benchmark, TrackedStorageKey};405406                    let allowlist: Vec<TrackedStorageKey> = vec![407                        // Block Number408                        hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef702a5c1b19ab7a04f536c519aca4983ac").to_vec().into(),409                        // Total Issuance410                        hex_literal::hex!("c2261276cc9d1f8598ea4b6a74b15c2f57c875e4cff74148e4628f264b974c80").to_vec().into(),411                        // Execution Phase412                        hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef7ff553b5a9862a516939d82b3d3d8661a").to_vec().into(),413                        // Event Count414                        hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef70a98fdbe9ce6c55837576c60c7af3850").to_vec().into(),415                        // System Events416                        hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef780d41e5e16056765bc8461851072c9d7").to_vec().into(),417418                        // Transactional depth419                        hex_literal::hex!("3a7472616e73616374696f6e5f6c6576656c3a").to_vec().into(),420                    ];421422                    let mut batches = Vec::<BenchmarkBatch>::new();423                    let params = (&config, &allowlist);424425                    add_benchmark!(params, batches, pallet_evm_migration, EvmMigration);426                    add_benchmark!(params, batches, pallet_unique, Unique);427                    add_benchmark!(params, batches, pallet_structure, Structure);428                    add_benchmark!(params, batches, pallet_inflation, Inflation);429                    add_benchmark!(params, batches, pallet_fungible, Fungible);430                    add_benchmark!(params, batches, pallet_refungible, Refungible);431                    add_benchmark!(params, batches, pallet_nonfungible, Nonfungible);432                    // add_benchmark!(params, batches, pallet_evm_coder_substrate, EvmCoderSubstrate);433434                    if batches.is_empty() { return Err("Benchmark not found for this pallet.".into()) }435                    Ok(batches)436                }437            }438439            #[cfg(feature = "try-runtime")]440            impl frame_try_runtime::TryRuntime<Block> for Runtime {441                fn on_runtime_upgrade() -> (Weight, Weight) {442                    log::info!("try-runtime::on_runtime_upgrade unique-chain.");443                    let weight = Executive::try_runtime_upgrade().unwrap();444                    (weight, RuntimeBlockWeights::get().max_block)445                }446447                fn execute_block_no_check(block: Block) -> Weight {448                    Executive::execute_block_no_check(block)449                }450            }451        }452    }453}
after · runtime/common/src/runtime_apis.rs
1#[macro_export]2macro_rules! impl_common_runtime_apis {3    (4        $(5            #![custom_apis]67            $($custom_apis:tt)+8        )?9    ) => {10        fn bytes_keys_to_property_keys(keys: Vec<Vec<u8>>) -> Result<Vec<PropertyKey>, DispatchError> {11            keys.into_iter()12                .map(|key| -> Result<PropertyKey, DispatchError> {13                    key.try_into().map_err(|_| DispatchError::Other("Can't read property key"))14                })15                .collect::<Result<Vec<PropertyKey>, DispatchError>>()16        }1718        impl_runtime_apis! {19            $($($custom_apis)+)?2021            impl up_rpc::UniqueApi<Block, CrossAccountId, AccountId> for Runtime {22                fn account_tokens(collection: CollectionId, account: CrossAccountId) -> Result<Vec<TokenId>, DispatchError> {23                    dispatch_unique_runtime!(collection.account_tokens(account))24                }25                fn collection_tokens(collection: CollectionId) -> Result<Vec<TokenId>, DispatchError> {26                    dispatch_unique_runtime!(collection.collection_tokens())27                }28                fn token_exists(collection: CollectionId, token: TokenId) -> Result<bool, DispatchError> {29                    dispatch_unique_runtime!(collection.token_exists(token))30                }3132                fn token_owner(collection: CollectionId, token: TokenId) -> Result<Option<CrossAccountId>, DispatchError> {33                    dispatch_unique_runtime!(collection.token_owner(token))34                }35                fn topmost_token_owner(collection: CollectionId, token: TokenId) -> Result<Option<CrossAccountId>, DispatchError> {36                    let budget = up_data_structs::budget::Value::new(5);3738                    Ok(Some(<pallet_structure::Pallet<Runtime>>::find_topmost_owner(collection, token, &budget)?))39                }40                fn const_metadata(collection: CollectionId, token: TokenId) -> Result<Vec<u8>, DispatchError> {41                    dispatch_unique_runtime!(collection.const_metadata(token))42                }43                fn variable_metadata(collection: CollectionId, token: TokenId) -> Result<Vec<u8>, DispatchError> {44                    dispatch_unique_runtime!(collection.variable_metadata(token))45                }4647                fn collection_properties(48                    collection: CollectionId,49                    keys: Vec<Vec<u8>>50                ) -> Result<Vec<Property>, DispatchError> {51                    let keys = bytes_keys_to_property_keys(keys)?;5253                    let properties = pallet_common::Pallet::<Runtime>::collection_properties(collection);5455                    let properties = keys.into_iter()56                        .filter_map(|key| {57                            properties.get_property(&key)58                                .map(|value| {59                                    Property {60                                        key,61                                        value: value.clone()62                                    }63                                })64                        })65                        .collect();6667                    Ok(properties)68                }6970                fn token_properties(71                    collection: CollectionId,72                    token_id: TokenId,73                    keys: Vec<Vec<u8>>74                ) -> Result<Vec<Property>, DispatchError> {75                    let keys = bytes_keys_to_property_keys(keys)?;7677                    let properties = pallet_nonfungible::Pallet::<Runtime>::token_properties((collection, token_id));7879                    let properties = keys.into_iter()80                        .filter_map(|key| {81                            properties.get_property(&key)82                                .map(|value| {83                                    Property {84                                        key,85                                        value: value.clone()86                                    }87                                })88                        })89                        .collect();9091                    Ok(properties)92                }9394                fn property_permissions(95                    collection: CollectionId,96                    keys: Vec<Vec<u8>>97                ) -> Result<Vec<PropertyKeyPermission>, DispatchError> {98                    let keys = bytes_keys_to_property_keys(keys)?;99100                    let permissions = pallet_common::Pallet::<Runtime>::property_permissions(collection);101102                    let key_permissions = keys.into_iter()103                        .filter_map(|key| {104                            permissions.get(&key)105                                .map(|permission| {106                                    PropertyKeyPermission {107                                        key,108                                        permission: permission.clone()109                                    }110                                })111                        })112                        .collect();113114                    Ok(key_permissions)115                }116117                fn total_supply(collection: CollectionId) -> Result<u32, DispatchError> {118                    dispatch_unique_runtime!(collection.total_supply())119                }120                fn account_balance(collection: CollectionId, account: CrossAccountId) -> Result<u32, DispatchError> {121                    dispatch_unique_runtime!(collection.account_balance(account))122                }123                fn balance(collection: CollectionId, account: CrossAccountId, token: TokenId) -> Result<u128, DispatchError> {124                    dispatch_unique_runtime!(collection.balance(account, token))125                }126                fn allowance(127                    collection: CollectionId,128                    sender: CrossAccountId,129                    spender: CrossAccountId,130                    token: TokenId,131                ) -> Result<u128, DispatchError> {132                    dispatch_unique_runtime!(collection.allowance(sender, spender, token))133                }134135                fn adminlist(collection: CollectionId) -> Result<Vec<CrossAccountId>, DispatchError> {136                    Ok(<pallet_common::Pallet<Runtime>>::adminlist(collection))137                }138                fn allowlist(collection: CollectionId) -> Result<Vec<CrossAccountId>, DispatchError> {139                    Ok(<pallet_common::Pallet<Runtime>>::allowlist(collection))140                }141                fn allowed(collection: CollectionId, user: CrossAccountId) -> Result<bool, DispatchError> {142                    Ok(<pallet_common::Pallet<Runtime>>::allowed(collection, user))143                }144                fn last_token_id(collection: CollectionId) -> Result<TokenId, DispatchError> {145                    dispatch_unique_runtime!(collection.last_token_id())146                }147                fn collection_by_id(collection: CollectionId) -> Result<Option<RpcCollection<AccountId>>, DispatchError> {148                    Ok(<pallet_common::Pallet<Runtime>>::rpc_collection(collection))149                }150                fn collection_stats() -> Result<CollectionStats, DispatchError> {151                    Ok(<pallet_common::Pallet<Runtime>>::collection_stats())152                }153                fn next_sponsored(collection: CollectionId, account: CrossAccountId, token: TokenId) -> Result<Option<u64>, DispatchError> {154                    Ok(<$crate::sponsoring::UniqueSponsorshipPredict<Runtime> as155                            $crate::sponsoring::SponsorshipPredict<Runtime>>::predict(156                        collection,157                        account,158                        token))159                }160161                fn effective_collection_limits(collection: CollectionId) -> Result<Option<CollectionLimits>, DispatchError> {162                    Ok(<pallet_common::Pallet<Runtime>>::effective_collection_limits(collection))163                }164            }165166            impl sp_api::Core<Block> for Runtime {167                fn version() -> RuntimeVersion {168                    VERSION169                }170171                fn execute_block(block: Block) {172                    Executive::execute_block(block)173                }174175                fn initialize_block(header: &<Block as BlockT>::Header) {176                    Executive::initialize_block(header)177                }178            }179180            impl sp_api::Metadata<Block> for Runtime {181                fn metadata() -> OpaqueMetadata {182                    OpaqueMetadata::new(Runtime::metadata().into())183                }184            }185186            impl sp_block_builder::BlockBuilder<Block> for Runtime {187                fn apply_extrinsic(extrinsic: <Block as BlockT>::Extrinsic) -> ApplyExtrinsicResult {188                    Executive::apply_extrinsic(extrinsic)189                }190191                fn finalize_block() -> <Block as BlockT>::Header {192                    Executive::finalize_block()193                }194195                fn inherent_extrinsics(data: sp_inherents::InherentData) -> Vec<<Block as BlockT>::Extrinsic> {196                    data.create_extrinsics()197                }198199                fn check_inherents(200                    block: Block,201                    data: sp_inherents::InherentData,202                ) -> sp_inherents::CheckInherentsResult {203                    data.check_extrinsics(&block)204                }205206                // fn random_seed() -> <Block as BlockT>::Hash {207                //     RandomnessCollectiveFlip::random_seed().0208                // }209            }210211            impl sp_transaction_pool::runtime_api::TaggedTransactionQueue<Block> for Runtime {212                fn validate_transaction(213                    source: TransactionSource,214                    tx: <Block as BlockT>::Extrinsic,215                    hash: <Block as BlockT>::Hash,216                ) -> TransactionValidity {217                    Executive::validate_transaction(source, tx, hash)218                }219            }220221            impl sp_offchain::OffchainWorkerApi<Block> for Runtime {222                fn offchain_worker(header: &<Block as BlockT>::Header) {223                    Executive::offchain_worker(header)224                }225            }226227            impl fp_rpc::EthereumRuntimeRPCApi<Block> for Runtime {228                fn chain_id() -> u64 {229                    <Runtime as pallet_evm::Config>::ChainId::get()230                }231232                fn account_basic(address: H160) -> EVMAccount {233                    EVM::account_basic(&address)234                }235236                fn gas_price() -> U256 {237                    <Runtime as pallet_evm::Config>::FeeCalculator::min_gas_price()238                }239240                fn account_code_at(address: H160) -> Vec<u8> {241                    EVM::account_codes(address)242                }243244                fn author() -> H160 {245                    <pallet_evm::Pallet<Runtime>>::find_author()246                }247248                fn storage_at(address: H160, index: U256) -> H256 {249                    let mut tmp = [0u8; 32];250                    index.to_big_endian(&mut tmp);251                    EVM::account_storages(address, H256::from_slice(&tmp[..]))252                }253254                #[allow(clippy::redundant_closure)]255                fn call(256                    from: H160,257                    to: H160,258                    data: Vec<u8>,259                    value: U256,260                    gas_limit: U256,261                    max_fee_per_gas: Option<U256>,262                    max_priority_fee_per_gas: Option<U256>,263                    nonce: Option<U256>,264                    estimate: bool,265                    access_list: Option<Vec<(H160, Vec<H256>)>>,266                ) -> Result<pallet_evm::CallInfo, sp_runtime::DispatchError> {267                    let config = if estimate {268                        let mut config = <Runtime as pallet_evm::Config>::config().clone();269                        config.estimate = true;270                        Some(config)271                    } else {272                        None273                    };274275                    let is_transactional = false;276                    <Runtime as pallet_evm::Config>::Runner::call(277                        CrossAccountId::from_eth(from),278                        to,279                        data,280                        value,281                        gas_limit.low_u64(),282                        max_fee_per_gas,283                        max_priority_fee_per_gas,284                        nonce,285                        access_list.unwrap_or_default(),286                        is_transactional,287                        config.as_ref().unwrap_or_else(|| <Runtime as pallet_evm::Config>::config()),288                    ).map_err(|err| err.into())289                }290291                #[allow(clippy::redundant_closure)]292                fn create(293                    from: H160,294                    data: Vec<u8>,295                    value: U256,296                    gas_limit: U256,297                    max_fee_per_gas: Option<U256>,298                    max_priority_fee_per_gas: Option<U256>,299                    nonce: Option<U256>,300                    estimate: bool,301                    access_list: Option<Vec<(H160, Vec<H256>)>>,302                ) -> Result<pallet_evm::CreateInfo, sp_runtime::DispatchError> {303                    let config = if estimate {304                        let mut config = <Runtime as pallet_evm::Config>::config().clone();305                        config.estimate = true;306                        Some(config)307                    } else {308                        None309                    };310311                    let is_transactional = false;312                    <Runtime as pallet_evm::Config>::Runner::create(313                        CrossAccountId::from_eth(from),314                        data,315                        value,316                        gas_limit.low_u64(),317                        max_fee_per_gas,318                        max_priority_fee_per_gas,319                        nonce,320                        access_list.unwrap_or_default(),321                        is_transactional,322                        config.as_ref().unwrap_or_else(|| <Runtime as pallet_evm::Config>::config()),323                    ).map_err(|err| err.into())324                }325326                fn current_transaction_statuses() -> Option<Vec<TransactionStatus>> {327                    Ethereum::current_transaction_statuses()328                }329330                fn current_block() -> Option<pallet_ethereum::Block> {331                    Ethereum::current_block()332                }333334                fn current_receipts() -> Option<Vec<pallet_ethereum::Receipt>> {335                    Ethereum::current_receipts()336                }337338                fn current_all() -> (339                    Option<pallet_ethereum::Block>,340                    Option<Vec<pallet_ethereum::Receipt>>,341                    Option<Vec<TransactionStatus>>342                ) {343                    (344                        Ethereum::current_block(),345                        Ethereum::current_receipts(),346                        Ethereum::current_transaction_statuses()347                    )348                }349350                fn extrinsic_filter(xts: Vec<<Block as sp_api::BlockT>::Extrinsic>) -> Vec<pallet_ethereum::Transaction> {351                    xts.into_iter().filter_map(|xt| match xt.0.function {352                        Call::Ethereum(pallet_ethereum::Call::transact { transaction }) => Some(transaction),353                        _ => None354                    }).collect()355                }356357                fn elasticity() -> Option<Permill> {358                    None359                }360            }361362            impl fp_rpc::ConvertTransactionRuntimeApi<Block> for Runtime {363                fn convert_transaction(transaction: pallet_ethereum::Transaction) -> <Block as BlockT>::Extrinsic  {364                    UncheckedExtrinsic::new_unsigned(365                        pallet_ethereum::Call::<Runtime>::transact { transaction }.into(),366                    )367                }368            }369370            impl sp_session::SessionKeys<Block> for Runtime {371                fn decode_session_keys(372                    encoded: Vec<u8>,373                ) -> Option<Vec<(Vec<u8>, KeyTypeId)>> {374                    SessionKeys::decode_into_raw_public_keys(&encoded)375                }376377                fn generate_session_keys(seed: Option<Vec<u8>>) -> Vec<u8> {378                    SessionKeys::generate(seed)379                }380            }381382            impl sp_consensus_aura::AuraApi<Block, AuraId> for Runtime {383                fn slot_duration() -> sp_consensus_aura::SlotDuration {384                    sp_consensus_aura::SlotDuration::from_millis(Aura::slot_duration())385                }386387                fn authorities() -> Vec<AuraId> {388                    Aura::authorities().to_vec()389                }390            }391392            impl cumulus_primitives_core::CollectCollationInfo<Block> for Runtime {393                fn collect_collation_info(header: &<Block as BlockT>::Header) -> cumulus_primitives_core::CollationInfo {394                    ParachainSystem::collect_collation_info(header)395                }396            }397398            impl frame_system_rpc_runtime_api::AccountNonceApi<Block, AccountId, Index> for Runtime {399                fn account_nonce(account: AccountId) -> Index {400                    System::account_nonce(account)401                }402            }403404            impl pallet_transaction_payment_rpc_runtime_api::TransactionPaymentApi<Block, Balance> for Runtime {405                fn query_info(uxt: <Block as BlockT>::Extrinsic, len: u32) -> RuntimeDispatchInfo<Balance> {406                    TransactionPayment::query_info(uxt, len)407                }408                fn query_fee_details(uxt: <Block as BlockT>::Extrinsic, len: u32) -> FeeDetails<Balance> {409                    TransactionPayment::query_fee_details(uxt, len)410                }411            }412413            /*414            impl pallet_contracts_rpc_runtime_api::ContractsApi<Block, AccountId, Balance, BlockNumber, Hash>415                for Runtime416            {417                fn call(418                    origin: AccountId,419                    dest: AccountId,420                    value: Balance,421                    gas_limit: u64,422                    input_data: Vec<u8>,423                ) -> pallet_contracts_primitives::ContractExecResult {424                    Contracts::bare_call(origin, dest, value, gas_limit, input_data, false)425                }426427                fn instantiate(428                    origin: AccountId,429                    endowment: Balance,430                    gas_limit: u64,431                    code: pallet_contracts_primitives::Code<Hash>,432                    data: Vec<u8>,433                    salt: Vec<u8>,434                ) -> pallet_contracts_primitives::ContractInstantiateResult<AccountId, BlockNumber>435                {436                    Contracts::bare_instantiate(origin, endowment, gas_limit, code, data, salt, true, false)437                }438439                fn get_storage(440                    address: AccountId,441                    key: [u8; 32],442                ) -> pallet_contracts_primitives::GetStorageResult {443                    Contracts::get_storage(address, key)444                }445446                fn rent_projection(447                    address: AccountId,448                ) -> pallet_contracts_primitives::RentProjectionResult<BlockNumber> {449                    Contracts::rent_projection(address)450                }451            }452            */453454            #[cfg(feature = "runtime-benchmarks")]455            impl frame_benchmarking::Benchmark<Block> for Runtime {456                fn benchmark_metadata(extra: bool) -> (457                    Vec<frame_benchmarking::BenchmarkList>,458                    Vec<frame_support::traits::StorageInfo>,459                ) {460                    use frame_benchmarking::{list_benchmark, Benchmarking, BenchmarkList};461                    use frame_support::traits::StorageInfoTrait;462463                    let mut list = Vec::<BenchmarkList>::new();464465                    list_benchmark!(list, extra, pallet_evm_migration, EvmMigration);466                    list_benchmark!(list, extra, pallet_unique, Unique);467                    list_benchmark!(list, extra, pallet_structure, Structure);468                    list_benchmark!(list, extra, pallet_inflation, Inflation);469                    list_benchmark!(list, extra, pallet_fungible, Fungible);470                    list_benchmark!(list, extra, pallet_refungible, Refungible);471                    list_benchmark!(list, extra, pallet_nonfungible, Nonfungible);472                    // list_benchmark!(list, extra, pallet_evm_coder_substrate, EvmCoderSubstrate);473474                    let storage_info = AllPalletsReversedWithSystemFirst::storage_info();475476                    return (list, storage_info)477                }478479                fn dispatch_benchmark(480                    config: frame_benchmarking::BenchmarkConfig481                ) -> Result<Vec<frame_benchmarking::BenchmarkBatch>, sp_runtime::RuntimeString> {482                    use frame_benchmarking::{Benchmarking, BenchmarkBatch, add_benchmark, TrackedStorageKey};483484                    let allowlist: Vec<TrackedStorageKey> = vec![485                        // Block Number486                        hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef702a5c1b19ab7a04f536c519aca4983ac").to_vec().into(),487                        // Total Issuance488                        hex_literal::hex!("c2261276cc9d1f8598ea4b6a74b15c2f57c875e4cff74148e4628f264b974c80").to_vec().into(),489                        // Execution Phase490                        hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef7ff553b5a9862a516939d82b3d3d8661a").to_vec().into(),491                        // Event Count492                        hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef70a98fdbe9ce6c55837576c60c7af3850").to_vec().into(),493                        // System Events494                        hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef780d41e5e16056765bc8461851072c9d7").to_vec().into(),495496                        // Transactional depth497                        hex_literal::hex!("3a7472616e73616374696f6e5f6c6576656c3a").to_vec().into(),498                    ];499500                    let mut batches = Vec::<BenchmarkBatch>::new();501                    let params = (&config, &allowlist);502503                    add_benchmark!(params, batches, pallet_evm_migration, EvmMigration);504                    add_benchmark!(params, batches, pallet_unique, Unique);505                    add_benchmark!(params, batches, pallet_structure, Structure);506                    add_benchmark!(params, batches, pallet_inflation, Inflation);507                    add_benchmark!(params, batches, pallet_fungible, Fungible);508                    add_benchmark!(params, batches, pallet_refungible, Refungible);509                    add_benchmark!(params, batches, pallet_nonfungible, Nonfungible);510                    // add_benchmark!(params, batches, pallet_evm_coder_substrate, EvmCoderSubstrate);511512                    if batches.is_empty() { return Err("Benchmark not found for this pallet.".into()) }513                    Ok(batches)514                }515            }516517            #[cfg(feature = "try-runtime")]518            impl frame_try_runtime::TryRuntime<Block> for Runtime {519                fn on_runtime_upgrade() -> (Weight, Weight) {520                    log::info!("try-runtime::on_runtime_upgrade unique-chain.");521                    let weight = Executive::try_runtime_upgrade().unwrap();522                    (weight, RuntimeBlockWeights::get().max_block)523                }524525                fn execute_block_no_check(block: Block) -> Weight {526                    Executive::execute_block_no_check(block)527                }528            }529        }530    }531}
modifiedruntime/opal/src/lib.rsdiffbeforeafterboth
--- a/runtime/opal/src/lib.rs
+++ b/runtime/opal/src/lib.rs
@@ -67,7 +67,7 @@
 	},
 };
 use up_data_structs::mapping::{EvmTokenAddressMapping, CrossTokenAddressMapping};
-use up_data_structs::{CollectionId, TokenId, CollectionStats, CollectionLimits, RpcCollection};
+use up_data_structs::*;
 // use pallet_contracts::weights::WeightInfo;
 // #[cfg(any(feature = "std", test))]
 use frame_system::{