git.delta.rocks / unique-network / refs/commits / 1d826475f55f

difftreelog

Move runtime apis to common

Daniel Shiposha2022-03-10parent: #8060528.patch.diff
in: master

5 files changed

modifiedruntime/common/src/lib.rsdiffbeforeafterboth
--- a/runtime/common/src/lib.rs
+++ b/runtime/common/src/lib.rs
@@ -1,4 +1,5 @@
 #![cfg_attr(not(feature = "std"), no_std)]
 
+pub mod runtime_apis;
 pub mod constants;
 pub mod types;
addedruntime/common/src/runtime_apis.rsdiffbeforeafterboth
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        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 token_exists(collection: CollectionId, token: TokenId) -> Result<bool, DispatchError> {18                    dispatch_unique_runtime!(collection.token_exists(token))19                }2021                fn token_owner(collection: CollectionId, token: TokenId) -> Result<Option<CrossAccountId>, DispatchError> {22                    dispatch_unique_runtime!(collection.token_owner(token))23                }24                fn const_metadata(collection: CollectionId, token: TokenId) -> Result<Vec<u8>, DispatchError> {25                    dispatch_unique_runtime!(collection.const_metadata(token))26                }27                fn variable_metadata(collection: CollectionId, token: TokenId) -> Result<Vec<u8>, DispatchError> {28                    dispatch_unique_runtime!(collection.variable_metadata(token))29                }3031                fn collection_tokens(collection: CollectionId) -> Result<u32, DispatchError> {32                    dispatch_unique_runtime!(collection.collection_tokens())33                }34                fn account_balance(collection: CollectionId, account: CrossAccountId) -> Result<u32, DispatchError> {35                    dispatch_unique_runtime!(collection.account_balance(account))36                }37                fn balance(collection: CollectionId, account: CrossAccountId, token: TokenId) -> Result<u128, DispatchError> {38                    dispatch_unique_runtime!(collection.balance(account, token))39                }40                fn allowance(41                    collection: CollectionId,42                    sender: CrossAccountId,43                    spender: CrossAccountId,44                    token: TokenId,45                ) -> Result<u128, DispatchError> {46                    dispatch_unique_runtime!(collection.allowance(sender, spender, token))47                }4849                fn eth_contract_code(account: H160) -> Option<Vec<u8>> {50                    <pallet_unique::UniqueErcSupport<Runtime>>::get_code(&account)51                        .or_else(|| <pallet_evm_migration::OnMethodCall<Runtime>>::get_code(&account))52                        .or_else(|| <pallet_evm_contract_helpers::HelpersOnMethodCall<Self>>::get_code(&account))53                }54                fn adminlist(collection: CollectionId) -> Result<Vec<CrossAccountId>, DispatchError> {55                    Ok(<pallet_common::Pallet<Runtime>>::adminlist(collection))56                }57                fn allowlist(collection: CollectionId) -> Result<Vec<CrossAccountId>, DispatchError> {58                    Ok(<pallet_common::Pallet<Runtime>>::allowlist(collection))59                }60                fn allowed(collection: CollectionId, user: CrossAccountId) -> Result<bool, DispatchError> {61                    Ok(<pallet_common::Pallet<Runtime>>::allowed(collection, user))62                }63                fn last_token_id(collection: CollectionId) -> Result<TokenId, DispatchError> {64                    dispatch_unique_runtime!(collection.last_token_id())65                }66                fn collection_by_id(collection: CollectionId) -> Result<Option<Collection<AccountId>>, DispatchError> {67                    Ok(<pallet_common::CollectionById<Runtime>>::get(collection))68                }69                fn collection_stats() -> Result<CollectionStats, DispatchError> {70                    Ok(<pallet_common::Pallet<Runtime>>::collection_stats())71                }72            }7374            impl sp_api::Core<Block> for Runtime {75                fn version() -> RuntimeVersion {76                    VERSION77                }7879                fn execute_block(block: Block) {80                    Executive::execute_block(block)81                }8283                fn initialize_block(header: &<Block as BlockT>::Header) {84                    Executive::initialize_block(header)85                }86            }8788            impl sp_api::Metadata<Block> for Runtime {89                fn metadata() -> OpaqueMetadata {90                    OpaqueMetadata::new(Runtime::metadata().into())91                }92            }9394            impl sp_block_builder::BlockBuilder<Block> for Runtime {95                fn apply_extrinsic(extrinsic: <Block as BlockT>::Extrinsic) -> ApplyExtrinsicResult {96                    Executive::apply_extrinsic(extrinsic)97                }9899                fn finalize_block() -> <Block as BlockT>::Header {100                    Executive::finalize_block()101                }102103                fn inherent_extrinsics(data: sp_inherents::InherentData) -> Vec<<Block as BlockT>::Extrinsic> {104                    data.create_extrinsics()105                }106107                fn check_inherents(108                    block: Block,109                    data: sp_inherents::InherentData,110                ) -> sp_inherents::CheckInherentsResult {111                    data.check_extrinsics(&block)112                }113114                // fn random_seed() -> <Block as BlockT>::Hash {115                //     RandomnessCollectiveFlip::random_seed().0116                // }117            }118119            impl sp_transaction_pool::runtime_api::TaggedTransactionQueue<Block> for Runtime {120                fn validate_transaction(121                    source: TransactionSource,122                    tx: <Block as BlockT>::Extrinsic,123                    hash: <Block as BlockT>::Hash,124                ) -> TransactionValidity {125                    Executive::validate_transaction(source, tx, hash)126                }127            }128129            impl sp_offchain::OffchainWorkerApi<Block> for Runtime {130                fn offchain_worker(header: &<Block as BlockT>::Header) {131                    Executive::offchain_worker(header)132                }133            }134135            impl fp_rpc::EthereumRuntimeRPCApi<Block> for Runtime {136                fn chain_id() -> u64 {137                    <Runtime as pallet_evm::Config>::ChainId::get()138                }139140                fn account_basic(address: H160) -> EVMAccount {141                    EVM::account_basic(&address)142                }143144                fn gas_price() -> U256 {145                    <Runtime as pallet_evm::Config>::FeeCalculator::min_gas_price()146                }147148                fn account_code_at(address: H160) -> Vec<u8> {149                    EVM::account_codes(address)150                }151152                fn author() -> H160 {153                    <pallet_evm::Pallet<Runtime>>::find_author()154                }155156                fn storage_at(address: H160, index: U256) -> H256 {157                    let mut tmp = [0u8; 32];158                    index.to_big_endian(&mut tmp);159                    EVM::account_storages(address, H256::from_slice(&tmp[..]))160                }161162                #[allow(clippy::redundant_closure)]163                fn call(164                    from: H160,165                    to: H160,166                    data: Vec<u8>,167                    value: U256,168                    gas_limit: U256,169                    max_fee_per_gas: Option<U256>,170                    max_priority_fee_per_gas: Option<U256>,171                    nonce: Option<U256>,172                    estimate: bool,173                    access_list: Option<Vec<(H160, Vec<H256>)>>,174                ) -> Result<pallet_evm::CallInfo, sp_runtime::DispatchError> {175                    let config = if estimate {176                        let mut config = <Runtime as pallet_evm::Config>::config().clone();177                        config.estimate = true;178                        Some(config)179                    } else {180                        None181                    };182183                    <Runtime as pallet_evm::Config>::Runner::call(184                        from,185                        to,186                        data,187                        value,188                        gas_limit.low_u64(),189                        max_fee_per_gas,190                        max_priority_fee_per_gas,191                        nonce,192                        access_list.unwrap_or_default(),193                        config.as_ref().unwrap_or_else(|| <Runtime as pallet_evm::Config>::config()),194                    ).map_err(|err| err.into())195                }196197                #[allow(clippy::redundant_closure)]198                fn create(199                    from: H160,200                    data: Vec<u8>,201                    value: U256,202                    gas_limit: U256,203                    max_fee_per_gas: Option<U256>,204                    max_priority_fee_per_gas: Option<U256>,205                    nonce: Option<U256>,206                    estimate: bool,207                    access_list: Option<Vec<(H160, Vec<H256>)>>,208                ) -> Result<pallet_evm::CreateInfo, sp_runtime::DispatchError> {209                    let config = if estimate {210                        let mut config = <Runtime as pallet_evm::Config>::config().clone();211                        config.estimate = true;212                        Some(config)213                    } else {214                        None215                    };216217                    <Runtime as pallet_evm::Config>::Runner::create(218                        from,219                        data,220                        value,221                        gas_limit.low_u64(),222                        max_fee_per_gas,223                        max_priority_fee_per_gas,224                        nonce,225                        access_list.unwrap_or_default(),226                        config.as_ref().unwrap_or_else(|| <Runtime as pallet_evm::Config>::config()),227                    ).map_err(|err| err.into())228                }229230                fn current_transaction_statuses() -> Option<Vec<TransactionStatus>> {231                    Ethereum::current_transaction_statuses()232                }233234                fn current_block() -> Option<pallet_ethereum::Block> {235                    Ethereum::current_block()236                }237238                fn current_receipts() -> Option<Vec<pallet_ethereum::Receipt>> {239                    Ethereum::current_receipts()240                }241242                fn current_all() -> (243                    Option<pallet_ethereum::Block>,244                    Option<Vec<pallet_ethereum::Receipt>>,245                    Option<Vec<TransactionStatus>>246                ) {247                    (248                        Ethereum::current_block(),249                        Ethereum::current_receipts(),250                        Ethereum::current_transaction_statuses()251                    )252                }253254                fn extrinsic_filter(xts: Vec<<Block as sp_api::BlockT>::Extrinsic>) -> Vec<pallet_ethereum::Transaction> {255                    xts.into_iter().filter_map(|xt| match xt.0.function {256                        Call::Ethereum(pallet_ethereum::Call::transact { transaction }) => Some(transaction),257                        _ => None258                    }).collect()259                }260261                fn elasticity() -> Option<Permill> {262                    None263                }264            }265266            impl sp_session::SessionKeys<Block> for Runtime {267                fn decode_session_keys(268                    encoded: Vec<u8>,269                ) -> Option<Vec<(Vec<u8>, KeyTypeId)>> {270                    SessionKeys::decode_into_raw_public_keys(&encoded)271                }272273                fn generate_session_keys(seed: Option<Vec<u8>>) -> Vec<u8> {274                    SessionKeys::generate(seed)275                }276            }277278            impl sp_consensus_aura::AuraApi<Block, AuraId> for Runtime {279                fn slot_duration() -> sp_consensus_aura::SlotDuration {280                    sp_consensus_aura::SlotDuration::from_millis(Aura::slot_duration())281                }282283                fn authorities() -> Vec<AuraId> {284                    Aura::authorities().to_vec()285                }286            }287288            impl cumulus_primitives_core::CollectCollationInfo<Block> for Runtime {289                fn collect_collation_info(header: &<Block as BlockT>::Header) -> cumulus_primitives_core::CollationInfo {290                    ParachainSystem::collect_collation_info(header)291                }292            }293294            impl frame_system_rpc_runtime_api::AccountNonceApi<Block, AccountId, Index> for Runtime {295                fn account_nonce(account: AccountId) -> Index {296                    System::account_nonce(account)297                }298            }299300            impl pallet_transaction_payment_rpc_runtime_api::TransactionPaymentApi<Block, Balance> for Runtime {301                fn query_info(uxt: <Block as BlockT>::Extrinsic, len: u32) -> RuntimeDispatchInfo<Balance> {302                    TransactionPayment::query_info(uxt, len)303                }304                fn query_fee_details(uxt: <Block as BlockT>::Extrinsic, len: u32) -> FeeDetails<Balance> {305                    TransactionPayment::query_fee_details(uxt, len)306                }307            }308309            /*310            impl pallet_contracts_rpc_runtime_api::ContractsApi<Block, AccountId, Balance, BlockNumber, Hash>311                for Runtime312            {313                fn call(314                    origin: AccountId,315                    dest: AccountId,316                    value: Balance,317                    gas_limit: u64,318                    input_data: Vec<u8>,319                ) -> pallet_contracts_primitives::ContractExecResult {320                    Contracts::bare_call(origin, dest, value, gas_limit, input_data, false)321                }322323                fn instantiate(324                    origin: AccountId,325                    endowment: Balance,326                    gas_limit: u64,327                    code: pallet_contracts_primitives::Code<Hash>,328                    data: Vec<u8>,329                    salt: Vec<u8>,330                ) -> pallet_contracts_primitives::ContractInstantiateResult<AccountId, BlockNumber>331                {332                    Contracts::bare_instantiate(origin, endowment, gas_limit, code, data, salt, true, false)333                }334335                fn get_storage(336                    address: AccountId,337                    key: [u8; 32],338                ) -> pallet_contracts_primitives::GetStorageResult {339                    Contracts::get_storage(address, key)340                }341342                fn rent_projection(343                    address: AccountId,344                ) -> pallet_contracts_primitives::RentProjectionResult<BlockNumber> {345                    Contracts::rent_projection(address)346                }347            }348            */349350            #[cfg(feature = "runtime-benchmarks")]351            impl frame_benchmarking::Benchmark<Block> for Runtime {352                fn benchmark_metadata(extra: bool) -> (353                    Vec<frame_benchmarking::BenchmarkList>,354                    Vec<frame_support::traits::StorageInfo>,355                ) {356                    use frame_benchmarking::{list_benchmark, Benchmarking, BenchmarkList};357                    use frame_support::traits::StorageInfoTrait;358359                    let mut list = Vec::<BenchmarkList>::new();360361                    list_benchmark!(list, extra, pallet_evm_migration, EvmMigration);362                    list_benchmark!(list, extra, pallet_unique, Unique);363                    list_benchmark!(list, extra, pallet_inflation, Inflation);364                    list_benchmark!(list, extra, pallet_fungible, Fungible);365                    list_benchmark!(list, extra, pallet_refungible, Refungible);366                    list_benchmark!(list, extra, pallet_nonfungible, Nonfungible);367                    // list_benchmark!(list, extra, pallet_evm_coder_substrate, EvmCoderSubstrate);368369                    let storage_info = AllPalletsReversedWithSystemFirst::storage_info();370371                    return (list, storage_info)372                }373374                fn dispatch_benchmark(375                    config: frame_benchmarking::BenchmarkConfig376                ) -> Result<Vec<frame_benchmarking::BenchmarkBatch>, sp_runtime::RuntimeString> {377                    use frame_benchmarking::{Benchmarking, BenchmarkBatch, add_benchmark, TrackedStorageKey};378379                    let allowlist: Vec<TrackedStorageKey> = vec![380                        // Block Number381                        hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef702a5c1b19ab7a04f536c519aca4983ac").to_vec().into(),382                        // Total Issuance383                        hex_literal::hex!("c2261276cc9d1f8598ea4b6a74b15c2f57c875e4cff74148e4628f264b974c80").to_vec().into(),384                        // Execution Phase385                        hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef7ff553b5a9862a516939d82b3d3d8661a").to_vec().into(),386                        // Event Count387                        hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef70a98fdbe9ce6c55837576c60c7af3850").to_vec().into(),388                        // System Events389                        hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef780d41e5e16056765bc8461851072c9d7").to_vec().into(),390                    ];391392                    let mut batches = Vec::<BenchmarkBatch>::new();393                    let params = (&config, &allowlist);394395                    add_benchmark!(params, batches, pallet_evm_migration, EvmMigration);396                    add_benchmark!(params, batches, pallet_unique, Unique);397                    add_benchmark!(params, batches, pallet_inflation, Inflation);398                    add_benchmark!(params, batches, pallet_fungible, Fungible);399                    add_benchmark!(params, batches, pallet_refungible, Refungible);400                    add_benchmark!(params, batches, pallet_nonfungible, Nonfungible);401                    // add_benchmark!(params, batches, pallet_evm_coder_substrate, EvmCoderSubstrate);402403                    if batches.is_empty() { return Err("Benchmark not found for this pallet.".into()) }404                    Ok(batches)405                }406            }407        }408    }409}
modifiedruntime/opal/src/lib.rsdiffbeforeafterboth
--- a/runtime/opal/src/lib.rs
+++ b/runtime/opal/src/lib.rs
@@ -112,7 +112,7 @@
 //use xcm_executor::traits::MatchesFungible;
 use sp_runtime::traits::CheckedConversion;
 
-use unique_runtime_common::{types::*, constants::*};
+use unique_runtime_common::{impl_common_runtime_apis, types::*, constants::*};
 
 pub const RUNTIME_NAME: &str = "Opal";
 
@@ -1111,404 +1111,8 @@
 		Ok(dispatch.$method($($name),*))
 	}};
 }
-impl_runtime_apis! {
-	impl up_rpc::UniqueApi<Block, CrossAccountId, AccountId>
-		for Runtime
-	{
-		fn account_tokens(collection: CollectionId, account: CrossAccountId) -> Result<Vec<TokenId>, DispatchError> {
-			dispatch_unique_runtime!(collection.account_tokens(account))
-		}
-		fn token_exists(collection: CollectionId, token: TokenId) -> Result<bool, DispatchError> {
-			dispatch_unique_runtime!(collection.token_exists(token))
-		}
 
-		fn token_owner(collection: CollectionId, token: TokenId) -> Result<Option<CrossAccountId>, DispatchError> {
-			dispatch_unique_runtime!(collection.token_owner(token))
-		}
-		fn const_metadata(collection: CollectionId, token: TokenId) -> Result<Vec<u8>, DispatchError> {
-			dispatch_unique_runtime!(collection.const_metadata(token))
-		}
-		fn variable_metadata(collection: CollectionId, token: TokenId) -> Result<Vec<u8>, DispatchError> {
-			dispatch_unique_runtime!(collection.variable_metadata(token))
-		}
-
-		fn collection_tokens(collection: CollectionId) -> Result<u32, DispatchError> {
-			dispatch_unique_runtime!(collection.collection_tokens())
-		}
-		fn account_balance(collection: CollectionId, account: CrossAccountId) -> Result<u32, DispatchError> {
-			dispatch_unique_runtime!(collection.account_balance(account))
-		}
-		fn balance(collection: CollectionId, account: CrossAccountId, token: TokenId) -> Result<u128, DispatchError> {
-			dispatch_unique_runtime!(collection.balance(account, token))
-		}
-		fn allowance(
-			collection: CollectionId,
-			sender: CrossAccountId,
-			spender: CrossAccountId,
-			token: TokenId,
-		) -> Result<u128, DispatchError> {
-			dispatch_unique_runtime!(collection.allowance(sender, spender, token))
-		}
-
-		fn eth_contract_code(account: H160) -> Option<Vec<u8>> {
-			<pallet_unique::UniqueErcSupport<Runtime>>::get_code(&account)
-				.or_else(|| <pallet_evm_migration::OnMethodCall<Runtime>>::get_code(&account))
-				.or_else(|| <pallet_evm_contract_helpers::HelpersOnMethodCall<Self>>::get_code(&account))
-		}
-		fn adminlist(collection: CollectionId) -> Result<Vec<CrossAccountId>, DispatchError> {
-			Ok(<pallet_common::Pallet<Runtime>>::adminlist(collection))
-		}
-		fn allowlist(collection: CollectionId) -> Result<Vec<CrossAccountId>, DispatchError> {
-			Ok(<pallet_common::Pallet<Runtime>>::allowlist(collection))
-		}
-		fn allowed(collection: CollectionId, user: CrossAccountId) -> Result<bool, DispatchError> {
-			Ok(<pallet_common::Pallet<Runtime>>::allowed(collection, user))
-		}
-		fn last_token_id(collection: CollectionId) -> Result<TokenId, DispatchError> {
-			dispatch_unique_runtime!(collection.last_token_id())
-		}
-		fn collection_by_id(collection: CollectionId) -> Result<Option<Collection<AccountId>>, DispatchError> {
-			Ok(<pallet_common::CollectionById<Runtime>>::get(collection))
-		}
-		fn collection_stats() -> Result<CollectionStats, DispatchError> {
-			Ok(<pallet_common::Pallet<Runtime>>::collection_stats())
-		}
-	}
-
-	impl sp_api::Core<Block> for Runtime {
-		fn version() -> RuntimeVersion {
-			VERSION
-		}
-
-		fn execute_block(block: Block) {
-			Executive::execute_block(block)
-		}
-
-		fn initialize_block(header: &<Block as BlockT>::Header) {
-			Executive::initialize_block(header)
-		}
-	}
-
-	impl sp_api::Metadata<Block> for Runtime {
-		fn metadata() -> OpaqueMetadata {
-			OpaqueMetadata::new(Runtime::metadata().into())
-		}
-	}
-
-	impl sp_block_builder::BlockBuilder<Block> for Runtime {
-		fn apply_extrinsic(extrinsic: <Block as BlockT>::Extrinsic) -> ApplyExtrinsicResult {
-			Executive::apply_extrinsic(extrinsic)
-		}
-
-		fn finalize_block() -> <Block as BlockT>::Header {
-			Executive::finalize_block()
-		}
-
-		fn inherent_extrinsics(data: sp_inherents::InherentData) -> Vec<<Block as BlockT>::Extrinsic> {
-			data.create_extrinsics()
-		}
-
-		fn check_inherents(
-			block: Block,
-			data: sp_inherents::InherentData,
-		) -> sp_inherents::CheckInherentsResult {
-			data.check_extrinsics(&block)
-		}
-
-		// fn random_seed() -> <Block as BlockT>::Hash {
-		//     RandomnessCollectiveFlip::random_seed().0
-		// }
-	}
-
-	impl sp_transaction_pool::runtime_api::TaggedTransactionQueue<Block> for Runtime {
-		fn validate_transaction(
-			source: TransactionSource,
-			tx: <Block as BlockT>::Extrinsic,
-			hash: <Block as BlockT>::Hash,
-		) -> TransactionValidity {
-			Executive::validate_transaction(source, tx, hash)
-		}
-	}
-
-	impl sp_offchain::OffchainWorkerApi<Block> for Runtime {
-		fn offchain_worker(header: &<Block as BlockT>::Header) {
-			Executive::offchain_worker(header)
-		}
-	}
-
-	impl fp_rpc::EthereumRuntimeRPCApi<Block> for Runtime {
-		fn chain_id() -> u64 {
-			<Runtime as pallet_evm::Config>::ChainId::get()
-		}
-
-		fn account_basic(address: H160) -> EVMAccount {
-			EVM::account_basic(&address)
-		}
-
-		fn gas_price() -> U256 {
-			<Runtime as pallet_evm::Config>::FeeCalculator::min_gas_price()
-		}
-
-		fn account_code_at(address: H160) -> Vec<u8> {
-			EVM::account_codes(address)
-		}
-
-		fn author() -> H160 {
-			<pallet_evm::Pallet<Runtime>>::find_author()
-		}
-
-		fn storage_at(address: H160, index: U256) -> H256 {
-			let mut tmp = [0u8; 32];
-			index.to_big_endian(&mut tmp);
-			EVM::account_storages(address, H256::from_slice(&tmp[..]))
-		}
-
-		#[allow(clippy::redundant_closure)]
-		fn call(
-			from: H160,
-			to: H160,
-			data: Vec<u8>,
-			value: U256,
-			gas_limit: U256,
-			max_fee_per_gas: Option<U256>,
-			max_priority_fee_per_gas: Option<U256>,
-			nonce: Option<U256>,
-			estimate: bool,
-			access_list: Option<Vec<(H160, Vec<H256>)>>,
-		) -> Result<pallet_evm::CallInfo, sp_runtime::DispatchError> {
-			let config = if estimate {
-				let mut config = <Runtime as pallet_evm::Config>::config().clone();
-				config.estimate = true;
-				Some(config)
-			} else {
-				None
-			};
-
-			<Runtime as pallet_evm::Config>::Runner::call(
-				from,
-				to,
-				data,
-				value,
-				gas_limit.low_u64(),
-				max_fee_per_gas,
-				max_priority_fee_per_gas,
-				nonce,
-				access_list.unwrap_or_default(),
-				config.as_ref().unwrap_or_else(|| <Runtime as pallet_evm::Config>::config()),
-			).map_err(|err| err.into())
-		}
-
-		#[allow(clippy::redundant_closure)]
-		fn create(
-			from: H160,
-			data: Vec<u8>,
-			value: U256,
-			gas_limit: U256,
-			max_fee_per_gas: Option<U256>,
-			max_priority_fee_per_gas: Option<U256>,
-			nonce: Option<U256>,
-			estimate: bool,
-			access_list: Option<Vec<(H160, Vec<H256>)>>,
-		) -> Result<pallet_evm::CreateInfo, sp_runtime::DispatchError> {
-			let config = if estimate {
-				let mut config = <Runtime as pallet_evm::Config>::config().clone();
-				config.estimate = true;
-				Some(config)
-			} else {
-				None
-			};
-
-			<Runtime as pallet_evm::Config>::Runner::create(
-				from,
-				data,
-				value,
-				gas_limit.low_u64(),
-				max_fee_per_gas,
-				max_priority_fee_per_gas,
-				nonce,
-				access_list.unwrap_or_default(),
-				config.as_ref().unwrap_or_else(|| <Runtime as pallet_evm::Config>::config()),
-			).map_err(|err| err.into())
-		}
-
-		fn current_transaction_statuses() -> Option<Vec<TransactionStatus>> {
-			Ethereum::current_transaction_statuses()
-		}
-
-		fn current_block() -> Option<pallet_ethereum::Block> {
-			Ethereum::current_block()
-		}
-
-		fn current_receipts() -> Option<Vec<pallet_ethereum::Receipt>> {
-			Ethereum::current_receipts()
-		}
-
-		fn current_all() -> (
-			Option<pallet_ethereum::Block>,
-			Option<Vec<pallet_ethereum::Receipt>>,
-			Option<Vec<TransactionStatus>>
-		) {
-			(
-				Ethereum::current_block(),
-				Ethereum::current_receipts(),
-				Ethereum::current_transaction_statuses()
-			)
-		}
-
-		fn extrinsic_filter(xts: Vec<<Block as sp_api::BlockT>::Extrinsic>) -> Vec<pallet_ethereum::Transaction> {
-			xts.into_iter().filter_map(|xt| match xt.0.function {
-				Call::Ethereum(pallet_ethereum::Call::transact { transaction }) => Some(transaction),
-				_ => None
-			}).collect()
-		}
-
-		fn elasticity() -> Option<Permill> {
-			None
-		}
-	}
-
-	impl sp_session::SessionKeys<Block> for Runtime {
-		fn decode_session_keys(
-			encoded: Vec<u8>,
-		) -> Option<Vec<(Vec<u8>, KeyTypeId)>> {
-			SessionKeys::decode_into_raw_public_keys(&encoded)
-		}
-
-		fn generate_session_keys(seed: Option<Vec<u8>>) -> Vec<u8> {
-			SessionKeys::generate(seed)
-		}
-	}
-
-	impl sp_consensus_aura::AuraApi<Block, AuraId> for Runtime {
-		fn slot_duration() -> sp_consensus_aura::SlotDuration {
-			sp_consensus_aura::SlotDuration::from_millis(Aura::slot_duration())
-		}
-
-		fn authorities() -> Vec<AuraId> {
-			Aura::authorities().to_vec()
-		}
-	}
-
-	impl cumulus_primitives_core::CollectCollationInfo<Block> for Runtime {
-		fn collect_collation_info(header: &<Block as BlockT>::Header) -> cumulus_primitives_core::CollationInfo {
-			ParachainSystem::collect_collation_info(header)
-		}
-	}
-
-	impl frame_system_rpc_runtime_api::AccountNonceApi<Block, AccountId, Index> for Runtime {
-		fn account_nonce(account: AccountId) -> Index {
-			System::account_nonce(account)
-		}
-	}
-
-	impl pallet_transaction_payment_rpc_runtime_api::TransactionPaymentApi<Block, Balance> for Runtime {
-		fn query_info(uxt: <Block as BlockT>::Extrinsic, len: u32) -> RuntimeDispatchInfo<Balance> {
-			TransactionPayment::query_info(uxt, len)
-		}
-		fn query_fee_details(uxt: <Block as BlockT>::Extrinsic, len: u32) -> FeeDetails<Balance> {
-			TransactionPayment::query_fee_details(uxt, len)
-		}
-	}
-
-	/*
-	impl pallet_contracts_rpc_runtime_api::ContractsApi<Block, AccountId, Balance, BlockNumber, Hash>
-		for Runtime
-	{
-		fn call(
-			origin: AccountId,
-			dest: AccountId,
-			value: Balance,
-			gas_limit: u64,
-			input_data: Vec<u8>,
-		) -> pallet_contracts_primitives::ContractExecResult {
-			Contracts::bare_call(origin, dest, value, gas_limit, input_data, false)
-		}
-
-		fn instantiate(
-			origin: AccountId,
-			endowment: Balance,
-			gas_limit: u64,
-			code: pallet_contracts_primitives::Code<Hash>,
-			data: Vec<u8>,
-			salt: Vec<u8>,
-		) -> pallet_contracts_primitives::ContractInstantiateResult<AccountId, BlockNumber>
-		{
-			Contracts::bare_instantiate(origin, endowment, gas_limit, code, data, salt, true, false)
-		}
-
-		fn get_storage(
-			address: AccountId,
-			key: [u8; 32],
-		) -> pallet_contracts_primitives::GetStorageResult {
-			Contracts::get_storage(address, key)
-		}
-
-		fn rent_projection(
-			address: AccountId,
-		) -> pallet_contracts_primitives::RentProjectionResult<BlockNumber> {
-			Contracts::rent_projection(address)
-		}
-	}
-	*/
-
-	#[cfg(feature = "runtime-benchmarks")]
-	impl frame_benchmarking::Benchmark<Block> for Runtime {
-		fn benchmark_metadata(extra: bool) -> (
-			Vec<frame_benchmarking::BenchmarkList>,
-			Vec<frame_support::traits::StorageInfo>,
-		) {
-			use frame_benchmarking::{list_benchmark, Benchmarking, BenchmarkList};
-			use frame_support::traits::StorageInfoTrait;
-
-			let mut list = Vec::<BenchmarkList>::new();
-
-			list_benchmark!(list, extra, pallet_evm_migration, EvmMigration);
-			list_benchmark!(list, extra, pallet_unique, Unique);
-			list_benchmark!(list, extra, pallet_inflation, Inflation);
-			list_benchmark!(list, extra, pallet_fungible, Fungible);
-			list_benchmark!(list, extra, pallet_refungible, Refungible);
-			list_benchmark!(list, extra, pallet_nonfungible, Nonfungible);
-			// list_benchmark!(list, extra, pallet_evm_coder_substrate, EvmCoderSubstrate);
-
-			let storage_info = AllPalletsReversedWithSystemFirst::storage_info();
-
-			return (list, storage_info)
-		}
-
-		fn dispatch_benchmark(
-			config: frame_benchmarking::BenchmarkConfig
-		) -> Result<Vec<frame_benchmarking::BenchmarkBatch>, sp_runtime::RuntimeString> {
-			use frame_benchmarking::{Benchmarking, BenchmarkBatch, add_benchmark, TrackedStorageKey};
-
-			let allowlist: Vec<TrackedStorageKey> = vec![
-				// Block Number
-				hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef702a5c1b19ab7a04f536c519aca4983ac").to_vec().into(),
-				// Total Issuance
-				hex_literal::hex!("c2261276cc9d1f8598ea4b6a74b15c2f57c875e4cff74148e4628f264b974c80").to_vec().into(),
-				// Execution Phase
-				hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef7ff553b5a9862a516939d82b3d3d8661a").to_vec().into(),
-				// Event Count
-				hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef70a98fdbe9ce6c55837576c60c7af3850").to_vec().into(),
-				// System Events
-				hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef780d41e5e16056765bc8461851072c9d7").to_vec().into(),
-			];
-
-			let mut batches = Vec::<BenchmarkBatch>::new();
-			let params = (&config, &allowlist);
-
-			add_benchmark!(params, batches, pallet_evm_migration, EvmMigration);
-			add_benchmark!(params, batches, pallet_unique, Unique);
-			add_benchmark!(params, batches, pallet_inflation, Inflation);
-			add_benchmark!(params, batches, pallet_fungible, Fungible);
-			add_benchmark!(params, batches, pallet_refungible, Refungible);
-			add_benchmark!(params, batches, pallet_nonfungible, Nonfungible);
-			// add_benchmark!(params, batches, pallet_evm_coder_substrate, EvmCoderSubstrate);
-
-			if batches.is_empty() { return Err("Benchmark not found for this pallet.".into()) }
-			Ok(batches)
-		}
-	}
-}
+impl_common_runtime_apis!();
 
 struct CheckInherents;
 
modifiedruntime/quartz/src/lib.rsdiffbeforeafterboth
--- a/runtime/quartz/src/lib.rs
+++ b/runtime/quartz/src/lib.rs
@@ -112,7 +112,7 @@
 //use xcm_executor::traits::MatchesFungible;
 use sp_runtime::traits::CheckedConversion;
 
-use unique_runtime_common::{types::*, constants::*};
+use unique_runtime_common::{impl_common_runtime_apis, types::*, constants::*};
 
 pub const RUNTIME_NAME: &str = "Quartz";
 
@@ -1115,404 +1115,8 @@
 		Ok(dispatch.$method($($name),*))
 	}};
 }
-impl_runtime_apis! {
-	impl up_rpc::UniqueApi<Block, CrossAccountId, AccountId>
-		for Runtime
-	{
-		fn account_tokens(collection: CollectionId, account: CrossAccountId) -> Result<Vec<TokenId>, DispatchError> {
-			dispatch_unique_runtime!(collection.account_tokens(account))
-		}
-		fn token_exists(collection: CollectionId, token: TokenId) -> Result<bool, DispatchError> {
-			dispatch_unique_runtime!(collection.token_exists(token))
-		}
 
-		fn token_owner(collection: CollectionId, token: TokenId) -> Result<Option<CrossAccountId>, DispatchError> {
-			dispatch_unique_runtime!(collection.token_owner(token))
-		}
-		fn const_metadata(collection: CollectionId, token: TokenId) -> Result<Vec<u8>, DispatchError> {
-			dispatch_unique_runtime!(collection.const_metadata(token))
-		}
-		fn variable_metadata(collection: CollectionId, token: TokenId) -> Result<Vec<u8>, DispatchError> {
-			dispatch_unique_runtime!(collection.variable_metadata(token))
-		}
-
-		fn collection_tokens(collection: CollectionId) -> Result<u32, DispatchError> {
-			dispatch_unique_runtime!(collection.collection_tokens())
-		}
-		fn account_balance(collection: CollectionId, account: CrossAccountId) -> Result<u32, DispatchError> {
-			dispatch_unique_runtime!(collection.account_balance(account))
-		}
-		fn balance(collection: CollectionId, account: CrossAccountId, token: TokenId) -> Result<u128, DispatchError> {
-			dispatch_unique_runtime!(collection.balance(account, token))
-		}
-		fn allowance(
-			collection: CollectionId,
-			sender: CrossAccountId,
-			spender: CrossAccountId,
-			token: TokenId,
-		) -> Result<u128, DispatchError> {
-			dispatch_unique_runtime!(collection.allowance(sender, spender, token))
-		}
-
-		fn eth_contract_code(account: H160) -> Option<Vec<u8>> {
-			<pallet_unique::UniqueErcSupport<Runtime>>::get_code(&account)
-				.or_else(|| <pallet_evm_migration::OnMethodCall<Runtime>>::get_code(&account))
-				.or_else(|| <pallet_evm_contract_helpers::HelpersOnMethodCall<Self>>::get_code(&account))
-		}
-		fn adminlist(collection: CollectionId) -> Result<Vec<CrossAccountId>, DispatchError> {
-			Ok(<pallet_common::Pallet<Runtime>>::adminlist(collection))
-		}
-		fn allowlist(collection: CollectionId) -> Result<Vec<CrossAccountId>, DispatchError> {
-			Ok(<pallet_common::Pallet<Runtime>>::allowlist(collection))
-		}
-		fn allowed(collection: CollectionId, user: CrossAccountId) -> Result<bool, DispatchError> {
-			Ok(<pallet_common::Pallet<Runtime>>::allowed(collection, user))
-		}
-		fn last_token_id(collection: CollectionId) -> Result<TokenId, DispatchError> {
-			dispatch_unique_runtime!(collection.last_token_id())
-		}
-		fn collection_by_id(collection: CollectionId) -> Result<Option<Collection<AccountId>>, DispatchError> {
-			Ok(<pallet_common::CollectionById<Runtime>>::get(collection))
-		}
-		fn collection_stats() -> Result<CollectionStats, DispatchError> {
-			Ok(<pallet_common::Pallet<Runtime>>::collection_stats())
-		}
-	}
-
-	impl sp_api::Core<Block> for Runtime {
-		fn version() -> RuntimeVersion {
-			VERSION
-		}
-
-		fn execute_block(block: Block) {
-			Executive::execute_block(block)
-		}
-
-		fn initialize_block(header: &<Block as BlockT>::Header) {
-			Executive::initialize_block(header)
-		}
-	}
-
-	impl sp_api::Metadata<Block> for Runtime {
-		fn metadata() -> OpaqueMetadata {
-			OpaqueMetadata::new(Runtime::metadata().into())
-		}
-	}
-
-	impl sp_block_builder::BlockBuilder<Block> for Runtime {
-		fn apply_extrinsic(extrinsic: <Block as BlockT>::Extrinsic) -> ApplyExtrinsicResult {
-			Executive::apply_extrinsic(extrinsic)
-		}
-
-		fn finalize_block() -> <Block as BlockT>::Header {
-			Executive::finalize_block()
-		}
-
-		fn inherent_extrinsics(data: sp_inherents::InherentData) -> Vec<<Block as BlockT>::Extrinsic> {
-			data.create_extrinsics()
-		}
-
-		fn check_inherents(
-			block: Block,
-			data: sp_inherents::InherentData,
-		) -> sp_inherents::CheckInherentsResult {
-			data.check_extrinsics(&block)
-		}
-
-		// fn random_seed() -> <Block as BlockT>::Hash {
-		//     RandomnessCollectiveFlip::random_seed().0
-		// }
-	}
-
-	impl sp_transaction_pool::runtime_api::TaggedTransactionQueue<Block> for Runtime {
-		fn validate_transaction(
-			source: TransactionSource,
-			tx: <Block as BlockT>::Extrinsic,
-			hash: <Block as BlockT>::Hash,
-		) -> TransactionValidity {
-			Executive::validate_transaction(source, tx, hash)
-		}
-	}
-
-	impl sp_offchain::OffchainWorkerApi<Block> for Runtime {
-		fn offchain_worker(header: &<Block as BlockT>::Header) {
-			Executive::offchain_worker(header)
-		}
-	}
-
-	impl fp_rpc::EthereumRuntimeRPCApi<Block> for Runtime {
-		fn chain_id() -> u64 {
-			<Runtime as pallet_evm::Config>::ChainId::get()
-		}
-
-		fn account_basic(address: H160) -> EVMAccount {
-			EVM::account_basic(&address)
-		}
-
-		fn gas_price() -> U256 {
-			<Runtime as pallet_evm::Config>::FeeCalculator::min_gas_price()
-		}
-
-		fn account_code_at(address: H160) -> Vec<u8> {
-			EVM::account_codes(address)
-		}
-
-		fn author() -> H160 {
-			<pallet_evm::Pallet<Runtime>>::find_author()
-		}
-
-		fn storage_at(address: H160, index: U256) -> H256 {
-			let mut tmp = [0u8; 32];
-			index.to_big_endian(&mut tmp);
-			EVM::account_storages(address, H256::from_slice(&tmp[..]))
-		}
-
-		#[allow(clippy::redundant_closure)]
-		fn call(
-			from: H160,
-			to: H160,
-			data: Vec<u8>,
-			value: U256,
-			gas_limit: U256,
-			max_fee_per_gas: Option<U256>,
-			max_priority_fee_per_gas: Option<U256>,
-			nonce: Option<U256>,
-			estimate: bool,
-			access_list: Option<Vec<(H160, Vec<H256>)>>,
-		) -> Result<pallet_evm::CallInfo, sp_runtime::DispatchError> {
-			let config = if estimate {
-				let mut config = <Runtime as pallet_evm::Config>::config().clone();
-				config.estimate = true;
-				Some(config)
-			} else {
-				None
-			};
-
-			<Runtime as pallet_evm::Config>::Runner::call(
-				from,
-				to,
-				data,
-				value,
-				gas_limit.low_u64(),
-				max_fee_per_gas,
-				max_priority_fee_per_gas,
-				nonce,
-				access_list.unwrap_or_default(),
-				config.as_ref().unwrap_or_else(|| <Runtime as pallet_evm::Config>::config()),
-			).map_err(|err| err.into())
-		}
-
-		#[allow(clippy::redundant_closure)]
-		fn create(
-			from: H160,
-			data: Vec<u8>,
-			value: U256,
-			gas_limit: U256,
-			max_fee_per_gas: Option<U256>,
-			max_priority_fee_per_gas: Option<U256>,
-			nonce: Option<U256>,
-			estimate: bool,
-			access_list: Option<Vec<(H160, Vec<H256>)>>,
-		) -> Result<pallet_evm::CreateInfo, sp_runtime::DispatchError> {
-			let config = if estimate {
-				let mut config = <Runtime as pallet_evm::Config>::config().clone();
-				config.estimate = true;
-				Some(config)
-			} else {
-				None
-			};
-
-			<Runtime as pallet_evm::Config>::Runner::create(
-				from,
-				data,
-				value,
-				gas_limit.low_u64(),
-				max_fee_per_gas,
-				max_priority_fee_per_gas,
-				nonce,
-				access_list.unwrap_or_default(),
-				config.as_ref().unwrap_or_else(|| <Runtime as pallet_evm::Config>::config()),
-			).map_err(|err| err.into())
-		}
-
-		fn current_transaction_statuses() -> Option<Vec<TransactionStatus>> {
-			Ethereum::current_transaction_statuses()
-		}
-
-		fn current_block() -> Option<pallet_ethereum::Block> {
-			Ethereum::current_block()
-		}
-
-		fn current_receipts() -> Option<Vec<pallet_ethereum::Receipt>> {
-			Ethereum::current_receipts()
-		}
-
-		fn current_all() -> (
-			Option<pallet_ethereum::Block>,
-			Option<Vec<pallet_ethereum::Receipt>>,
-			Option<Vec<TransactionStatus>>
-		) {
-			(
-				Ethereum::current_block(),
-				Ethereum::current_receipts(),
-				Ethereum::current_transaction_statuses()
-			)
-		}
-
-		fn extrinsic_filter(xts: Vec<<Block as sp_api::BlockT>::Extrinsic>) -> Vec<pallet_ethereum::Transaction> {
-			xts.into_iter().filter_map(|xt| match xt.0.function {
-				Call::Ethereum(pallet_ethereum::Call::transact { transaction }) => Some(transaction),
-				_ => None
-			}).collect()
-		}
-
-		fn elasticity() -> Option<Permill> {
-			None
-		}
-	}
-
-	impl sp_session::SessionKeys<Block> for Runtime {
-		fn decode_session_keys(
-			encoded: Vec<u8>,
-		) -> Option<Vec<(Vec<u8>, KeyTypeId)>> {
-			SessionKeys::decode_into_raw_public_keys(&encoded)
-		}
-
-		fn generate_session_keys(seed: Option<Vec<u8>>) -> Vec<u8> {
-			SessionKeys::generate(seed)
-		}
-	}
-
-	impl sp_consensus_aura::AuraApi<Block, AuraId> for Runtime {
-		fn slot_duration() -> sp_consensus_aura::SlotDuration {
-			sp_consensus_aura::SlotDuration::from_millis(Aura::slot_duration())
-		}
-
-		fn authorities() -> Vec<AuraId> {
-			Aura::authorities().to_vec()
-		}
-	}
-
-	impl cumulus_primitives_core::CollectCollationInfo<Block> for Runtime {
-		fn collect_collation_info(header: &<Block as BlockT>::Header) -> cumulus_primitives_core::CollationInfo {
-			ParachainSystem::collect_collation_info(header)
-		}
-	}
-
-	impl frame_system_rpc_runtime_api::AccountNonceApi<Block, AccountId, Index> for Runtime {
-		fn account_nonce(account: AccountId) -> Index {
-			System::account_nonce(account)
-		}
-	}
-
-	impl pallet_transaction_payment_rpc_runtime_api::TransactionPaymentApi<Block, Balance> for Runtime {
-		fn query_info(uxt: <Block as BlockT>::Extrinsic, len: u32) -> RuntimeDispatchInfo<Balance> {
-			TransactionPayment::query_info(uxt, len)
-		}
-		fn query_fee_details(uxt: <Block as BlockT>::Extrinsic, len: u32) -> FeeDetails<Balance> {
-			TransactionPayment::query_fee_details(uxt, len)
-		}
-	}
-
-	/*
-	impl pallet_contracts_rpc_runtime_api::ContractsApi<Block, AccountId, Balance, BlockNumber, Hash>
-		for Runtime
-	{
-		fn call(
-			origin: AccountId,
-			dest: AccountId,
-			value: Balance,
-			gas_limit: u64,
-			input_data: Vec<u8>,
-		) -> pallet_contracts_primitives::ContractExecResult {
-			Contracts::bare_call(origin, dest, value, gas_limit, input_data, false)
-		}
-
-		fn instantiate(
-			origin: AccountId,
-			endowment: Balance,
-			gas_limit: u64,
-			code: pallet_contracts_primitives::Code<Hash>,
-			data: Vec<u8>,
-			salt: Vec<u8>,
-		) -> pallet_contracts_primitives::ContractInstantiateResult<AccountId, BlockNumber>
-		{
-			Contracts::bare_instantiate(origin, endowment, gas_limit, code, data, salt, true, false)
-		}
-
-		fn get_storage(
-			address: AccountId,
-			key: [u8; 32],
-		) -> pallet_contracts_primitives::GetStorageResult {
-			Contracts::get_storage(address, key)
-		}
-
-		fn rent_projection(
-			address: AccountId,
-		) -> pallet_contracts_primitives::RentProjectionResult<BlockNumber> {
-			Contracts::rent_projection(address)
-		}
-	}
-	*/
-
-	#[cfg(feature = "runtime-benchmarks")]
-	impl frame_benchmarking::Benchmark<Block> for Runtime {
-		fn benchmark_metadata(extra: bool) -> (
-			Vec<frame_benchmarking::BenchmarkList>,
-			Vec<frame_support::traits::StorageInfo>,
-		) {
-			use frame_benchmarking::{list_benchmark, Benchmarking, BenchmarkList};
-			use frame_support::traits::StorageInfoTrait;
-
-			let mut list = Vec::<BenchmarkList>::new();
-
-			list_benchmark!(list, extra, pallet_evm_migration, EvmMigration);
-			list_benchmark!(list, extra, pallet_unique, Unique);
-			list_benchmark!(list, extra, pallet_inflation, Inflation);
-			list_benchmark!(list, extra, pallet_fungible, Fungible);
-			list_benchmark!(list, extra, pallet_refungible, Refungible);
-			list_benchmark!(list, extra, pallet_nonfungible, Nonfungible);
-			// list_benchmark!(list, extra, pallet_evm_coder_substrate, EvmCoderSubstrate);
-
-			let storage_info = AllPalletsReversedWithSystemFirst::storage_info();
-
-			return (list, storage_info)
-		}
-
-		fn dispatch_benchmark(
-			config: frame_benchmarking::BenchmarkConfig
-		) -> Result<Vec<frame_benchmarking::BenchmarkBatch>, sp_runtime::RuntimeString> {
-			use frame_benchmarking::{Benchmarking, BenchmarkBatch, add_benchmark, TrackedStorageKey};
-
-			let allowlist: Vec<TrackedStorageKey> = vec![
-				// Block Number
-				hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef702a5c1b19ab7a04f536c519aca4983ac").to_vec().into(),
-				// Total Issuance
-				hex_literal::hex!("c2261276cc9d1f8598ea4b6a74b15c2f57c875e4cff74148e4628f264b974c80").to_vec().into(),
-				// Execution Phase
-				hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef7ff553b5a9862a516939d82b3d3d8661a").to_vec().into(),
-				// Event Count
-				hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef70a98fdbe9ce6c55837576c60c7af3850").to_vec().into(),
-				// System Events
-				hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef780d41e5e16056765bc8461851072c9d7").to_vec().into(),
-			];
-
-			let mut batches = Vec::<BenchmarkBatch>::new();
-			let params = (&config, &allowlist);
-
-			add_benchmark!(params, batches, pallet_evm_migration, EvmMigration);
-			add_benchmark!(params, batches, pallet_unique, Unique);
-			add_benchmark!(params, batches, pallet_inflation, Inflation);
-			add_benchmark!(params, batches, pallet_fungible, Fungible);
-			add_benchmark!(params, batches, pallet_refungible, Refungible);
-			add_benchmark!(params, batches, pallet_nonfungible, Nonfungible);
-			// add_benchmark!(params, batches, pallet_evm_coder_substrate, EvmCoderSubstrate);
-
-			if batches.is_empty() { return Err("Benchmark not found for this pallet.".into()) }
-			Ok(batches)
-		}
-	}
-}
+impl_common_runtime_apis!();
 
 struct CheckInherents;
 
modifiedruntime/unique/src/lib.rsdiffbeforeafterboth
--- a/runtime/unique/src/lib.rs
+++ b/runtime/unique/src/lib.rs
@@ -112,7 +112,7 @@
 //use xcm_executor::traits::MatchesFungible;
 use sp_runtime::traits::CheckedConversion;
 
-use unique_runtime_common::{types::*, constants::*};
+use unique_runtime_common::{impl_common_runtime_apis, types::*, constants::*};
 
 pub const RUNTIME_NAME: &str = "Unique";
 
@@ -1116,404 +1116,8 @@
 		Ok(dispatch.$method($($name),*))
 	}};
 }
-impl_runtime_apis! {
-	impl up_rpc::UniqueApi<Block, CrossAccountId, AccountId>
-		for Runtime
-	{
-		fn account_tokens(collection: CollectionId, account: CrossAccountId) -> Result<Vec<TokenId>, DispatchError> {
-			dispatch_unique_runtime!(collection.account_tokens(account))
-		}
-		fn token_exists(collection: CollectionId, token: TokenId) -> Result<bool, DispatchError> {
-			dispatch_unique_runtime!(collection.token_exists(token))
-		}
 
-		fn token_owner(collection: CollectionId, token: TokenId) -> Result<Option<CrossAccountId>, DispatchError> {
-			dispatch_unique_runtime!(collection.token_owner(token))
-		}
-		fn const_metadata(collection: CollectionId, token: TokenId) -> Result<Vec<u8>, DispatchError> {
-			dispatch_unique_runtime!(collection.const_metadata(token))
-		}
-		fn variable_metadata(collection: CollectionId, token: TokenId) -> Result<Vec<u8>, DispatchError> {
-			dispatch_unique_runtime!(collection.variable_metadata(token))
-		}
-
-		fn collection_tokens(collection: CollectionId) -> Result<u32, DispatchError> {
-			dispatch_unique_runtime!(collection.collection_tokens())
-		}
-		fn account_balance(collection: CollectionId, account: CrossAccountId) -> Result<u32, DispatchError> {
-			dispatch_unique_runtime!(collection.account_balance(account))
-		}
-		fn balance(collection: CollectionId, account: CrossAccountId, token: TokenId) -> Result<u128, DispatchError> {
-			dispatch_unique_runtime!(collection.balance(account, token))
-		}
-		fn allowance(
-			collection: CollectionId,
-			sender: CrossAccountId,
-			spender: CrossAccountId,
-			token: TokenId,
-		) -> Result<u128, DispatchError> {
-			dispatch_unique_runtime!(collection.allowance(sender, spender, token))
-		}
-
-		fn eth_contract_code(account: H160) -> Option<Vec<u8>> {
-			<pallet_unique::UniqueErcSupport<Runtime>>::get_code(&account)
-				.or_else(|| <pallet_evm_migration::OnMethodCall<Runtime>>::get_code(&account))
-				.or_else(|| <pallet_evm_contract_helpers::HelpersOnMethodCall<Self>>::get_code(&account))
-		}
-		fn adminlist(collection: CollectionId) -> Result<Vec<CrossAccountId>, DispatchError> {
-			Ok(<pallet_common::Pallet<Runtime>>::adminlist(collection))
-		}
-		fn allowlist(collection: CollectionId) -> Result<Vec<CrossAccountId>, DispatchError> {
-			Ok(<pallet_common::Pallet<Runtime>>::allowlist(collection))
-		}
-		fn allowed(collection: CollectionId, user: CrossAccountId) -> Result<bool, DispatchError> {
-			Ok(<pallet_common::Pallet<Runtime>>::allowed(collection, user))
-		}
-		fn last_token_id(collection: CollectionId) -> Result<TokenId, DispatchError> {
-			dispatch_unique_runtime!(collection.last_token_id())
-		}
-		fn collection_by_id(collection: CollectionId) -> Result<Option<Collection<AccountId>>, DispatchError> {
-			Ok(<pallet_common::CollectionById<Runtime>>::get(collection))
-		}
-		fn collection_stats() -> Result<CollectionStats, DispatchError> {
-			Ok(<pallet_common::Pallet<Runtime>>::collection_stats())
-		}
-	}
-
-	impl sp_api::Core<Block> for Runtime {
-		fn version() -> RuntimeVersion {
-			VERSION
-		}
-
-		fn execute_block(block: Block) {
-			Executive::execute_block(block)
-		}
-
-		fn initialize_block(header: &<Block as BlockT>::Header) {
-			Executive::initialize_block(header)
-		}
-	}
-
-	impl sp_api::Metadata<Block> for Runtime {
-		fn metadata() -> OpaqueMetadata {
-			OpaqueMetadata::new(Runtime::metadata().into())
-		}
-	}
-
-	impl sp_block_builder::BlockBuilder<Block> for Runtime {
-		fn apply_extrinsic(extrinsic: <Block as BlockT>::Extrinsic) -> ApplyExtrinsicResult {
-			Executive::apply_extrinsic(extrinsic)
-		}
-
-		fn finalize_block() -> <Block as BlockT>::Header {
-			Executive::finalize_block()
-		}
-
-		fn inherent_extrinsics(data: sp_inherents::InherentData) -> Vec<<Block as BlockT>::Extrinsic> {
-			data.create_extrinsics()
-		}
-
-		fn check_inherents(
-			block: Block,
-			data: sp_inherents::InherentData,
-		) -> sp_inherents::CheckInherentsResult {
-			data.check_extrinsics(&block)
-		}
-
-		// fn random_seed() -> <Block as BlockT>::Hash {
-		//     RandomnessCollectiveFlip::random_seed().0
-		// }
-	}
-
-	impl sp_transaction_pool::runtime_api::TaggedTransactionQueue<Block> for Runtime {
-		fn validate_transaction(
-			source: TransactionSource,
-			tx: <Block as BlockT>::Extrinsic,
-			hash: <Block as BlockT>::Hash,
-		) -> TransactionValidity {
-			Executive::validate_transaction(source, tx, hash)
-		}
-	}
-
-	impl sp_offchain::OffchainWorkerApi<Block> for Runtime {
-		fn offchain_worker(header: &<Block as BlockT>::Header) {
-			Executive::offchain_worker(header)
-		}
-	}
-
-	impl fp_rpc::EthereumRuntimeRPCApi<Block> for Runtime {
-		fn chain_id() -> u64 {
-			<Runtime as pallet_evm::Config>::ChainId::get()
-		}
-
-		fn account_basic(address: H160) -> EVMAccount {
-			EVM::account_basic(&address)
-		}
-
-		fn gas_price() -> U256 {
-			<Runtime as pallet_evm::Config>::FeeCalculator::min_gas_price()
-		}
-
-		fn account_code_at(address: H160) -> Vec<u8> {
-			EVM::account_codes(address)
-		}
-
-		fn author() -> H160 {
-			<pallet_evm::Pallet<Runtime>>::find_author()
-		}
-
-		fn storage_at(address: H160, index: U256) -> H256 {
-			let mut tmp = [0u8; 32];
-			index.to_big_endian(&mut tmp);
-			EVM::account_storages(address, H256::from_slice(&tmp[..]))
-		}
-
-		#[allow(clippy::redundant_closure)]
-		fn call(
-			from: H160,
-			to: H160,
-			data: Vec<u8>,
-			value: U256,
-			gas_limit: U256,
-			max_fee_per_gas: Option<U256>,
-			max_priority_fee_per_gas: Option<U256>,
-			nonce: Option<U256>,
-			estimate: bool,
-			access_list: Option<Vec<(H160, Vec<H256>)>>,
-		) -> Result<pallet_evm::CallInfo, sp_runtime::DispatchError> {
-			let config = if estimate {
-				let mut config = <Runtime as pallet_evm::Config>::config().clone();
-				config.estimate = true;
-				Some(config)
-			} else {
-				None
-			};
-
-			<Runtime as pallet_evm::Config>::Runner::call(
-				from,
-				to,
-				data,
-				value,
-				gas_limit.low_u64(),
-				max_fee_per_gas,
-				max_priority_fee_per_gas,
-				nonce,
-				access_list.unwrap_or_default(),
-				config.as_ref().unwrap_or_else(|| <Runtime as pallet_evm::Config>::config()),
-			).map_err(|err| err.into())
-		}
-
-		#[allow(clippy::redundant_closure)]
-		fn create(
-			from: H160,
-			data: Vec<u8>,
-			value: U256,
-			gas_limit: U256,
-			max_fee_per_gas: Option<U256>,
-			max_priority_fee_per_gas: Option<U256>,
-			nonce: Option<U256>,
-			estimate: bool,
-			access_list: Option<Vec<(H160, Vec<H256>)>>,
-		) -> Result<pallet_evm::CreateInfo, sp_runtime::DispatchError> {
-			let config = if estimate {
-				let mut config = <Runtime as pallet_evm::Config>::config().clone();
-				config.estimate = true;
-				Some(config)
-			} else {
-				None
-			};
-
-			<Runtime as pallet_evm::Config>::Runner::create(
-				from,
-				data,
-				value,
-				gas_limit.low_u64(),
-				max_fee_per_gas,
-				max_priority_fee_per_gas,
-				nonce,
-				access_list.unwrap_or_default(),
-				config.as_ref().unwrap_or_else(|| <Runtime as pallet_evm::Config>::config()),
-			).map_err(|err| err.into())
-		}
-
-		fn current_transaction_statuses() -> Option<Vec<TransactionStatus>> {
-			Ethereum::current_transaction_statuses()
-		}
-
-		fn current_block() -> Option<pallet_ethereum::Block> {
-			Ethereum::current_block()
-		}
-
-		fn current_receipts() -> Option<Vec<pallet_ethereum::Receipt>> {
-			Ethereum::current_receipts()
-		}
-
-		fn current_all() -> (
-			Option<pallet_ethereum::Block>,
-			Option<Vec<pallet_ethereum::Receipt>>,
-			Option<Vec<TransactionStatus>>
-		) {
-			(
-				Ethereum::current_block(),
-				Ethereum::current_receipts(),
-				Ethereum::current_transaction_statuses()
-			)
-		}
-
-		fn extrinsic_filter(xts: Vec<<Block as sp_api::BlockT>::Extrinsic>) -> Vec<pallet_ethereum::Transaction> {
-			xts.into_iter().filter_map(|xt| match xt.0.function {
-				Call::Ethereum(pallet_ethereum::Call::transact { transaction }) => Some(transaction),
-				_ => None
-			}).collect()
-		}
-
-		fn elasticity() -> Option<Permill> {
-			None
-		}
-	}
-
-	impl sp_session::SessionKeys<Block> for Runtime {
-		fn decode_session_keys(
-			encoded: Vec<u8>,
-		) -> Option<Vec<(Vec<u8>, KeyTypeId)>> {
-			SessionKeys::decode_into_raw_public_keys(&encoded)
-		}
-
-		fn generate_session_keys(seed: Option<Vec<u8>>) -> Vec<u8> {
-			SessionKeys::generate(seed)
-		}
-	}
-
-	impl sp_consensus_aura::AuraApi<Block, AuraId> for Runtime {
-		fn slot_duration() -> sp_consensus_aura::SlotDuration {
-			sp_consensus_aura::SlotDuration::from_millis(Aura::slot_duration())
-		}
-
-		fn authorities() -> Vec<AuraId> {
-			Aura::authorities().to_vec()
-		}
-	}
-
-	impl cumulus_primitives_core::CollectCollationInfo<Block> for Runtime {
-		fn collect_collation_info(header: &<Block as BlockT>::Header) -> cumulus_primitives_core::CollationInfo {
-			ParachainSystem::collect_collation_info(header)
-		}
-	}
-
-	impl frame_system_rpc_runtime_api::AccountNonceApi<Block, AccountId, Index> for Runtime {
-		fn account_nonce(account: AccountId) -> Index {
-			System::account_nonce(account)
-		}
-	}
-
-	impl pallet_transaction_payment_rpc_runtime_api::TransactionPaymentApi<Block, Balance> for Runtime {
-		fn query_info(uxt: <Block as BlockT>::Extrinsic, len: u32) -> RuntimeDispatchInfo<Balance> {
-			TransactionPayment::query_info(uxt, len)
-		}
-		fn query_fee_details(uxt: <Block as BlockT>::Extrinsic, len: u32) -> FeeDetails<Balance> {
-			TransactionPayment::query_fee_details(uxt, len)
-		}
-	}
-
-	/*
-	impl pallet_contracts_rpc_runtime_api::ContractsApi<Block, AccountId, Balance, BlockNumber, Hash>
-		for Runtime
-	{
-		fn call(
-			origin: AccountId,
-			dest: AccountId,
-			value: Balance,
-			gas_limit: u64,
-			input_data: Vec<u8>,
-		) -> pallet_contracts_primitives::ContractExecResult {
-			Contracts::bare_call(origin, dest, value, gas_limit, input_data, false)
-		}
-
-		fn instantiate(
-			origin: AccountId,
-			endowment: Balance,
-			gas_limit: u64,
-			code: pallet_contracts_primitives::Code<Hash>,
-			data: Vec<u8>,
-			salt: Vec<u8>,
-		) -> pallet_contracts_primitives::ContractInstantiateResult<AccountId, BlockNumber>
-		{
-			Contracts::bare_instantiate(origin, endowment, gas_limit, code, data, salt, true, false)
-		}
-
-		fn get_storage(
-			address: AccountId,
-			key: [u8; 32],
-		) -> pallet_contracts_primitives::GetStorageResult {
-			Contracts::get_storage(address, key)
-		}
-
-		fn rent_projection(
-			address: AccountId,
-		) -> pallet_contracts_primitives::RentProjectionResult<BlockNumber> {
-			Contracts::rent_projection(address)
-		}
-	}
-	*/
-
-	#[cfg(feature = "runtime-benchmarks")]
-	impl frame_benchmarking::Benchmark<Block> for Runtime {
-		fn benchmark_metadata(extra: bool) -> (
-			Vec<frame_benchmarking::BenchmarkList>,
-			Vec<frame_support::traits::StorageInfo>,
-		) {
-			use frame_benchmarking::{list_benchmark, Benchmarking, BenchmarkList};
-			use frame_support::traits::StorageInfoTrait;
-
-			let mut list = Vec::<BenchmarkList>::new();
-
-			list_benchmark!(list, extra, pallet_evm_migration, EvmMigration);
-			list_benchmark!(list, extra, pallet_unique, Unique);
-			list_benchmark!(list, extra, pallet_inflation, Inflation);
-			list_benchmark!(list, extra, pallet_fungible, Fungible);
-			list_benchmark!(list, extra, pallet_refungible, Refungible);
-			list_benchmark!(list, extra, pallet_nonfungible, Nonfungible);
-			// list_benchmark!(list, extra, pallet_evm_coder_substrate, EvmCoderSubstrate);
-
-			let storage_info = AllPalletsReversedWithSystemFirst::storage_info();
-
-			return (list, storage_info)
-		}
-
-		fn dispatch_benchmark(
-			config: frame_benchmarking::BenchmarkConfig
-		) -> Result<Vec<frame_benchmarking::BenchmarkBatch>, sp_runtime::RuntimeString> {
-			use frame_benchmarking::{Benchmarking, BenchmarkBatch, add_benchmark, TrackedStorageKey};
-
-			let allowlist: Vec<TrackedStorageKey> = vec![
-				// Block Number
-				hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef702a5c1b19ab7a04f536c519aca4983ac").to_vec().into(),
-				// Total Issuance
-				hex_literal::hex!("c2261276cc9d1f8598ea4b6a74b15c2f57c875e4cff74148e4628f264b974c80").to_vec().into(),
-				// Execution Phase
-				hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef7ff553b5a9862a516939d82b3d3d8661a").to_vec().into(),
-				// Event Count
-				hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef70a98fdbe9ce6c55837576c60c7af3850").to_vec().into(),
-				// System Events
-				hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef780d41e5e16056765bc8461851072c9d7").to_vec().into(),
-			];
-
-			let mut batches = Vec::<BenchmarkBatch>::new();
-			let params = (&config, &allowlist);
-
-			add_benchmark!(params, batches, pallet_evm_migration, EvmMigration);
-			add_benchmark!(params, batches, pallet_unique, Unique);
-			add_benchmark!(params, batches, pallet_inflation, Inflation);
-			add_benchmark!(params, batches, pallet_fungible, Fungible);
-			add_benchmark!(params, batches, pallet_refungible, Refungible);
-			add_benchmark!(params, batches, pallet_nonfungible, Nonfungible);
-			// add_benchmark!(params, batches, pallet_evm_coder_substrate, EvmCoderSubstrate);
-
-			if batches.is_empty() { return Err("Benchmark not found for this pallet.".into()) }
-			Ok(batches)
-		}
-	}
-}
+impl_common_runtime_apis!();
 
 struct CheckInherents;