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 }3536 fn collection_properties(37 collection: CollectionId,38 keys: Option<Vec<Vec<u8>>>39 ) -> Result<Vec<Property>, DispatchError> {40 let keys = keys.map(41 |keys| pallet_common::Pallet::<Runtime>::bytes_keys_to_property_keys(keys)42 ).transpose()?;4344 pallet_common::Pallet::<Runtime>::filter_collection_properties(collection, keys)45 }4647 fn token_properties(48 collection: CollectionId,49 token_id: TokenId,50 keys: Option<Vec<Vec<u8>>>51 ) -> Result<Vec<Property>, DispatchError> {52 let keys = keys.map(53 |keys| pallet_common::Pallet::<Runtime>::bytes_keys_to_property_keys(keys)54 ).transpose()?;5556 dispatch_unique_runtime!(collection.token_properties(token_id, keys))57 }5859 fn property_permissions(60 collection: CollectionId,61 keys: Option<Vec<Vec<u8>>>62 ) -> Result<Vec<PropertyKeyPermission>, DispatchError> {63 let keys = keys.map(64 |keys| pallet_common::Pallet::<Runtime>::bytes_keys_to_property_keys(keys)65 ).transpose()?;6667 pallet_common::Pallet::<Runtime>::filter_property_permissions(collection, keys)68 }6970 fn token_data(71 collection: CollectionId,72 token_id: TokenId,73 keys: Option<Vec<Vec<u8>>>74 ) -> Result<TokenData<CrossAccountId>, DispatchError> {75 let token_data = TokenData {76 const_data: Self::const_metadata(collection, token_id)?,77 properties: Self::token_properties(collection, token_id, keys)?,78 owner: Self::token_owner(collection, token_id)?79 };8081 Ok(token_data)82 }8384 fn total_supply(collection: CollectionId) -> Result<u32, DispatchError> {85 dispatch_unique_runtime!(collection.total_supply())86 }87 fn account_balance(collection: CollectionId, account: CrossAccountId) -> Result<u32, DispatchError> {88 dispatch_unique_runtime!(collection.account_balance(account))89 }90 fn balance(collection: CollectionId, account: CrossAccountId, token: TokenId) -> Result<u128, DispatchError> {91 dispatch_unique_runtime!(collection.balance(account, token))92 }93 fn allowance(94 collection: CollectionId,95 sender: CrossAccountId,96 spender: CrossAccountId,97 token: TokenId,98 ) -> Result<u128, DispatchError> {99 dispatch_unique_runtime!(collection.allowance(sender, spender, token))100 }101102 fn adminlist(collection: CollectionId) -> Result<Vec<CrossAccountId>, DispatchError> {103 Ok(<pallet_common::Pallet<Runtime>>::adminlist(collection))104 }105 fn allowlist(collection: CollectionId) -> Result<Vec<CrossAccountId>, DispatchError> {106 Ok(<pallet_common::Pallet<Runtime>>::allowlist(collection))107 }108 fn allowed(collection: CollectionId, user: CrossAccountId) -> Result<bool, DispatchError> {109 Ok(<pallet_common::Pallet<Runtime>>::allowed(collection, user))110 }111 fn last_token_id(collection: CollectionId) -> Result<TokenId, DispatchError> {112 dispatch_unique_runtime!(collection.last_token_id())113 }114 fn collection_by_id(collection: CollectionId) -> Result<Option<RpcCollection<AccountId>>, DispatchError> {115 Ok(<pallet_common::Pallet<Runtime>>::rpc_collection(collection))116 }117 fn collection_stats() -> Result<CollectionStats, DispatchError> {118 Ok(<pallet_common::Pallet<Runtime>>::collection_stats())119 }120 fn next_sponsored(collection: CollectionId, account: CrossAccountId, token: TokenId) -> Result<Option<u64>, DispatchError> {121 Ok(<$crate::sponsoring::UniqueSponsorshipPredict<Runtime> as122 $crate::sponsoring::SponsorshipPredict<Runtime>>::predict(123 collection,124 account,125 token))126 }127128 fn effective_collection_limits(collection: CollectionId) -> Result<Option<CollectionLimits>, DispatchError> {129 Ok(<pallet_common::Pallet<Runtime>>::effective_collection_limits(collection))130 }131 }132133 impl rmrk_rpc::RmrkApi<134 Block,135 AccountId,136 RmrkCollectionInfo<AccountId>,137 RmrkInstanceInfo<AccountId>,138 RmrkResourceInfo,139 RmrkPropertyInfo,140 RmrkBaseInfo<AccountId>,141 RmrkPartType,142 RmrkTheme143 > for Runtime {144 fn last_collection_idx() -> Result<RmrkCollectionId, DispatchError> {145 Ok(<pallet_common::CreatedCollectionCount<Runtime>>::get().0)146 }147 fn collection_by_id(collection_id: RmrkCollectionId) -> Result<Option<RmrkCollectionInfo<AccountId>>, DispatchError> {148 149 use frame_support::BoundedVec;150151 let collection_id = CollectionId(collection_id);152 let collection = match <pallet_common::CollectionById<Runtime>>::get(collection_id) {153 Some(c) => c,154 None => return Ok(None)155 };156 let nfts_count: Result<u32, DispatchError> = dispatch_unique_runtime!(collection_id.total_supply());157 Ok(Some(RmrkCollectionInfo {158 issuer: collection.owner,159 metadata: BoundedVec::default(), 160 max: Some(collection.limits.token_limit()), 161 symbol: BoundedVec::try_from(collection.token_prefix.into_inner()).unwrap_or_default() 162163164,165 nfts_count: nfts_count? 166 }))167 }168 fn nft_by_id(collection_id: RmrkCollectionId, nft_by_id: RmrkNftId) -> Result<Option<RmrkInstanceInfo<AccountId>>, DispatchError> {169 use frame_support::BoundedVec;170 use up_data_structs::mapping::TokenAddressMapping;171172 let collection_id = CollectionId(collection_id);173 let nft_id = TokenId(nft_by_id);174175 let owner = match (dispatch_unique_runtime!(collection_id.token_owner(nft_id)) as Result<Option<CrossAccountId>, DispatchError>)? {176 Some(owner) => match <Runtime as pallet_common::Config>::CrossTokenAddressMapping::address_to_token(&owner) {177 Some((col, tok)) => RmrkAccountIdOrCollectionNftTuple::CollectionAndNftTuple(col.0, tok.0),178 None => RmrkAccountIdOrCollectionNftTuple::AccountId(owner.as_sub().clone())179 },180 None => return Ok(None)181 };182183 Ok(Some(RmrkInstanceInfo {184 owner: owner,185 186 royalty: None,187 metadata: BoundedVec::default(), 188 equipped: false, 189 pending: false, 190 }))191 }192 fn account_tokens(account_id: AccountId, collection_id: RmrkCollectionId) -> Result<Vec<RmrkNftId>, DispatchError> {193 let cross_account_id = CrossAccountId::from_sub(account_id);194 let collection_id = CollectionId(collection_id);195 Ok(196 (dispatch_unique_runtime!(collection_id.account_tokens(cross_account_id)) as Result<Vec<TokenId>, DispatchError>)?197 198 .into_iter()199 .map(|token| token.0)200 .collect::<Vec<_>>()201 )202 }203 fn nft_children(collection_id: RmrkCollectionId, nft_id: RmrkNftId) -> Result<Vec<RmrkNftChild>, DispatchError> {204 use up_data_structs::mapping::TokenAddressMapping;205206 let collection_id = CollectionId(collection_id);207 let nft_id = TokenId(nft_id);208 let cross_account_id = CrossAccountId::from_eth(209 EvmTokenAddressMapping::token_to_address(collection_id, nft_id)210 );211212 Ok(213 pallet_nonfungible::Owned::<Runtime>::iter_prefix((collection_id, cross_account_id))214 .map(|(child_id, _)| RmrkNftChild {215 collection_id: collection_id.0, 216 nft_id: child_id.0,217 })218 .collect()219 )220 }221 fn collection_properties(collection_id: RmrkCollectionId, filter_keys: Option<Vec<RmrkPropertyKey>>) -> Result<Vec<RmrkPropertyInfo>, DispatchError> {222 use frame_support::BoundedVec;223224 let collection_id = CollectionId(collection_id);225 let properties = pallet_common::Pallet::<Runtime>::collection_properties(collection_id);226227 return Ok(match filter_keys {228 Some(keys) => {229 let keys = pallet_common::Pallet::<Runtime>::bytes_keys_to_property_keys(keys)?;230 let properties = keys231 .into_iter()232 .filter_map(|key| {233 properties.get(&key).map(|value| RmrkPropertyInfo {234 key: BoundedVec::try_from(key.into_inner()).unwrap_or_default(),235 value: BoundedVec::try_from(value.clone().into_inner()).unwrap_or_default(),236 })237 })238 .collect();239240 properties241 }242 None => {243 properties244 .iter()245 .map(|(key, value)| RmrkPropertyInfo {246 key: BoundedVec::try_from(key.clone().into_inner()).unwrap_or_default(),247 value: BoundedVec::try_from(value.clone().into_inner()).unwrap_or_default(),248 })249 .collect()250 }251 });252 }253 fn nft_properties(collection_id: RmrkCollectionId, nft_id: RmrkNftId, filter_keys: Option<Vec<RmrkPropertyKey>>) -> Result<Vec<RmrkPropertyInfo>, DispatchError> {254 use frame_support::BoundedVec;255256 let collection_id = CollectionId(collection_id);257 let token_id = TokenId(nft_id);258259 let properties = pallet_nonfungible::Pallet::<Runtime>::token_properties((collection_id, token_id)); 260261 return Ok(match filter_keys {262 Some(keys) => {263 let keys = pallet_common::Pallet::<Runtime>::bytes_keys_to_property_keys(keys)?;264 let properties = keys265 .into_iter()266 .filter_map(|key| {267 properties.get(&key).map(|value| RmrkPropertyInfo {268 key: BoundedVec::try_from(key.into_inner()).unwrap_or_default(),269 value: BoundedVec::try_from(value.clone().into_inner()).unwrap_or_default(),270 })271 })272 .collect();273274 properties275 }276 None => {277 properties278 .iter()279 .map(|(key, value)| RmrkPropertyInfo {280 key: BoundedVec::try_from(key.clone().into_inner()).unwrap_or_default(),281 value: BoundedVec::try_from(value.clone().into_inner()).unwrap_or_default(),282 })283 .collect()284 }285 });286 }287 fn nft_resources(collection_id: RmrkCollectionId, nft_id: RmrkNftId) -> Result<Vec<RmrkResourceInfo>, DispatchError> {288 todo!()289 }290 fn nft_resource_priorities(collection_id: RmrkCollectionId, nft_id: RmrkNftId) -> Result<Vec<RmrkResourceId>, DispatchError> {291 todo!()292 }293 fn base(base_id: RmrkBaseId) -> Result<Option<RmrkBaseInfo<AccountId>>, DispatchError> {294 use frame_support::{BoundedVec, ensure};295 use scale_info::prelude::string::String;296297 let collection_id = CollectionId(base_id);298 let collection = match <pallet_common::CollectionById<Runtime>>::get(collection_id) {299 Some(c) => c,300 None => return Ok(None)301 };302303 304 let keys = pallet_common::Pallet::<Runtime>::bytes_keys_to_property_keys(305 Vec::from([String::from("rmrk:base-type").into_bytes()])306 )?;307 let properties = pallet_common::Pallet::<Runtime>::filter_collection_properties(collection_id, Some(keys))?;308 309310 Ok(Some( RmrkBaseInfo {311 issuer: collection.owner,312 base_type: BoundedVec::try_from(properties[0].value.clone().into_inner()).unwrap_or_default(), 313 symbol: BoundedVec::try_from(collection.token_prefix.into_inner()).unwrap_or_default(),314 }))315 }316 fn base_parts(base_id: RmrkBaseId) -> Result<Vec<RmrkPartType>, DispatchError> {317 todo!()318 }319 fn theme_names(base_id: RmrkBaseId) -> Result<Vec<RmrkThemeName>, DispatchError> {320 todo!()321 }322 fn theme(base_id: RmrkBaseId, theme_name: RmrkThemeName, filter_keys: Option<Vec<RmrkPropertyKey>>) -> Result<Option<RmrkTheme>, DispatchError> {323 todo!()324 }325 }326327 impl sp_api::Core<Block> for Runtime {328 fn version() -> RuntimeVersion {329 VERSION330 }331332 fn execute_block(block: Block) {333 Executive::execute_block(block)334 }335336 fn initialize_block(header: &<Block as BlockT>::Header) {337 Executive::initialize_block(header)338 }339 }340341 impl sp_api::Metadata<Block> for Runtime {342 fn metadata() -> OpaqueMetadata {343 OpaqueMetadata::new(Runtime::metadata().into())344 }345 }346347 impl sp_block_builder::BlockBuilder<Block> for Runtime {348 fn apply_extrinsic(extrinsic: <Block as BlockT>::Extrinsic) -> ApplyExtrinsicResult {349 Executive::apply_extrinsic(extrinsic)350 }351352 fn finalize_block() -> <Block as BlockT>::Header {353 Executive::finalize_block()354 }355356 fn inherent_extrinsics(data: sp_inherents::InherentData) -> Vec<<Block as BlockT>::Extrinsic> {357 data.create_extrinsics()358 }359360 fn check_inherents(361 block: Block,362 data: sp_inherents::InherentData,363 ) -> sp_inherents::CheckInherentsResult {364 data.check_extrinsics(&block)365 }366367 368 369 370 }371372 impl sp_transaction_pool::runtime_api::TaggedTransactionQueue<Block> for Runtime {373 fn validate_transaction(374 source: TransactionSource,375 tx: <Block as BlockT>::Extrinsic,376 hash: <Block as BlockT>::Hash,377 ) -> TransactionValidity {378 Executive::validate_transaction(source, tx, hash)379 }380 }381382 impl sp_offchain::OffchainWorkerApi<Block> for Runtime {383 fn offchain_worker(header: &<Block as BlockT>::Header) {384 Executive::offchain_worker(header)385 }386 }387388 impl fp_rpc::EthereumRuntimeRPCApi<Block> for Runtime {389 fn chain_id() -> u64 {390 <Runtime as pallet_evm::Config>::ChainId::get()391 }392393 fn account_basic(address: H160) -> EVMAccount {394 EVM::account_basic(&address)395 }396397 fn gas_price() -> U256 {398 <Runtime as pallet_evm::Config>::FeeCalculator::min_gas_price()399 }400401 fn account_code_at(address: H160) -> Vec<u8> {402 EVM::account_codes(address)403 }404405 fn author() -> H160 {406 <pallet_evm::Pallet<Runtime>>::find_author()407 }408409 fn storage_at(address: H160, index: U256) -> H256 {410 let mut tmp = [0u8; 32];411 index.to_big_endian(&mut tmp);412 EVM::account_storages(address, H256::from_slice(&tmp[..]))413 }414415 #[allow(clippy::redundant_closure)]416 fn call(417 from: H160,418 to: H160,419 data: Vec<u8>,420 value: U256,421 gas_limit: U256,422 max_fee_per_gas: Option<U256>,423 max_priority_fee_per_gas: Option<U256>,424 nonce: Option<U256>,425 estimate: bool,426 access_list: Option<Vec<(H160, Vec<H256>)>>,427 ) -> Result<pallet_evm::CallInfo, sp_runtime::DispatchError> {428 let config = if estimate {429 let mut config = <Runtime as pallet_evm::Config>::config().clone();430 config.estimate = true;431 Some(config)432 } else {433 None434 };435436 let is_transactional = false;437 <Runtime as pallet_evm::Config>::Runner::call(438 CrossAccountId::from_eth(from),439 to,440 data,441 value,442 gas_limit.low_u64(),443 max_fee_per_gas,444 max_priority_fee_per_gas,445 nonce,446 access_list.unwrap_or_default(),447 is_transactional,448 config.as_ref().unwrap_or_else(|| <Runtime as pallet_evm::Config>::config()),449 ).map_err(|err| err.into())450 }451452 #[allow(clippy::redundant_closure)]453 fn create(454 from: H160,455 data: Vec<u8>,456 value: U256,457 gas_limit: U256,458 max_fee_per_gas: Option<U256>,459 max_priority_fee_per_gas: Option<U256>,460 nonce: Option<U256>,461 estimate: bool,462 access_list: Option<Vec<(H160, Vec<H256>)>>,463 ) -> Result<pallet_evm::CreateInfo, sp_runtime::DispatchError> {464 let config = if estimate {465 let mut config = <Runtime as pallet_evm::Config>::config().clone();466 config.estimate = true;467 Some(config)468 } else {469 None470 };471472 let is_transactional = false;473 <Runtime as pallet_evm::Config>::Runner::create(474 CrossAccountId::from_eth(from),475 data,476 value,477 gas_limit.low_u64(),478 max_fee_per_gas,479 max_priority_fee_per_gas,480 nonce,481 access_list.unwrap_or_default(),482 is_transactional,483 config.as_ref().unwrap_or_else(|| <Runtime as pallet_evm::Config>::config()),484 ).map_err(|err| err.into())485 }486487 fn current_transaction_statuses() -> Option<Vec<TransactionStatus>> {488 Ethereum::current_transaction_statuses()489 }490491 fn current_block() -> Option<pallet_ethereum::Block> {492 Ethereum::current_block()493 }494495 fn current_receipts() -> Option<Vec<pallet_ethereum::Receipt>> {496 Ethereum::current_receipts()497 }498499 fn current_all() -> (500 Option<pallet_ethereum::Block>,501 Option<Vec<pallet_ethereum::Receipt>>,502 Option<Vec<TransactionStatus>>503 ) {504 (505 Ethereum::current_block(),506 Ethereum::current_receipts(),507 Ethereum::current_transaction_statuses()508 )509 }510511 fn extrinsic_filter(xts: Vec<<Block as sp_api::BlockT>::Extrinsic>) -> Vec<pallet_ethereum::Transaction> {512 xts.into_iter().filter_map(|xt| match xt.0.function {513 Call::Ethereum(pallet_ethereum::Call::transact { transaction }) => Some(transaction),514 _ => None515 }).collect()516 }517518 fn elasticity() -> Option<Permill> {519 None520 }521 }522523 impl fp_rpc::ConvertTransactionRuntimeApi<Block> for Runtime {524 fn convert_transaction(transaction: pallet_ethereum::Transaction) -> <Block as BlockT>::Extrinsic {525 UncheckedExtrinsic::new_unsigned(526 pallet_ethereum::Call::<Runtime>::transact { transaction }.into(),527 )528 }529 }530531 impl sp_session::SessionKeys<Block> for Runtime {532 fn decode_session_keys(533 encoded: Vec<u8>,534 ) -> Option<Vec<(Vec<u8>, KeyTypeId)>> {535 SessionKeys::decode_into_raw_public_keys(&encoded)536 }537538 fn generate_session_keys(seed: Option<Vec<u8>>) -> Vec<u8> {539 SessionKeys::generate(seed)540 }541 }542543 impl sp_consensus_aura::AuraApi<Block, AuraId> for Runtime {544 fn slot_duration() -> sp_consensus_aura::SlotDuration {545 sp_consensus_aura::SlotDuration::from_millis(Aura::slot_duration())546 }547548 fn authorities() -> Vec<AuraId> {549 Aura::authorities().to_vec()550 }551 }552553 impl cumulus_primitives_core::CollectCollationInfo<Block> for Runtime {554 fn collect_collation_info(header: &<Block as BlockT>::Header) -> cumulus_primitives_core::CollationInfo {555 ParachainSystem::collect_collation_info(header)556 }557 }558559 impl frame_system_rpc_runtime_api::AccountNonceApi<Block, AccountId, Index> for Runtime {560 fn account_nonce(account: AccountId) -> Index {561 System::account_nonce(account)562 }563 }564565 impl pallet_transaction_payment_rpc_runtime_api::TransactionPaymentApi<Block, Balance> for Runtime {566 fn query_info(uxt: <Block as BlockT>::Extrinsic, len: u32) -> RuntimeDispatchInfo<Balance> {567 TransactionPayment::query_info(uxt, len)568 }569 fn query_fee_details(uxt: <Block as BlockT>::Extrinsic, len: u32) -> FeeDetails<Balance> {570 TransactionPayment::query_fee_details(uxt, len)571 }572 }573574 575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615 #[cfg(feature = "runtime-benchmarks")]616 impl frame_benchmarking::Benchmark<Block> for Runtime {617 fn benchmark_metadata(extra: bool) -> (618 Vec<frame_benchmarking::BenchmarkList>,619 Vec<frame_support::traits::StorageInfo>,620 ) {621 use frame_benchmarking::{list_benchmark, Benchmarking, BenchmarkList};622 use frame_support::traits::StorageInfoTrait;623624 let mut list = Vec::<BenchmarkList>::new();625626 list_benchmark!(list, extra, pallet_evm_migration, EvmMigration);627 list_benchmark!(list, extra, pallet_unique, Unique);628 list_benchmark!(list, extra, pallet_structure, Structure);629 list_benchmark!(list, extra, pallet_inflation, Inflation);630 list_benchmark!(list, extra, pallet_fungible, Fungible);631 list_benchmark!(list, extra, pallet_refungible, Refungible);632 list_benchmark!(list, extra, pallet_nonfungible, Nonfungible);633 634635 let storage_info = AllPalletsReversedWithSystemFirst::storage_info();636637 return (list, storage_info)638 }639640 fn dispatch_benchmark(641 config: frame_benchmarking::BenchmarkConfig642 ) -> Result<Vec<frame_benchmarking::BenchmarkBatch>, sp_runtime::RuntimeString> {643 use frame_benchmarking::{Benchmarking, BenchmarkBatch, add_benchmark, TrackedStorageKey};644645 let allowlist: Vec<TrackedStorageKey> = vec![646 647 hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef702a5c1b19ab7a04f536c519aca4983ac").to_vec().into(),648 649 hex_literal::hex!("c2261276cc9d1f8598ea4b6a74b15c2f57c875e4cff74148e4628f264b974c80").to_vec().into(),650 651 hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef7ff553b5a9862a516939d82b3d3d8661a").to_vec().into(),652 653 hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef70a98fdbe9ce6c55837576c60c7af3850").to_vec().into(),654 655 hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef780d41e5e16056765bc8461851072c9d7").to_vec().into(),656657 658 hex_literal::hex!("3a7472616e73616374696f6e5f6c6576656c3a").to_vec().into(),659 ];660661 let mut batches = Vec::<BenchmarkBatch>::new();662 let params = (&config, &allowlist);663664 add_benchmark!(params, batches, pallet_evm_migration, EvmMigration);665 add_benchmark!(params, batches, pallet_unique, Unique);666 add_benchmark!(params, batches, pallet_structure, Structure);667 add_benchmark!(params, batches, pallet_inflation, Inflation);668 add_benchmark!(params, batches, pallet_fungible, Fungible);669 add_benchmark!(params, batches, pallet_refungible, Refungible);670 add_benchmark!(params, batches, pallet_nonfungible, Nonfungible);671 672673 if batches.is_empty() { return Err("Benchmark not found for this pallet.".into()) }674 Ok(batches)675 }676 }677678 #[cfg(feature = "try-runtime")]679 impl frame_try_runtime::TryRuntime<Block> for Runtime {680 fn on_runtime_upgrade() -> (Weight, Weight) {681 log::info!("try-runtime::on_runtime_upgrade unique-chain.");682 let weight = Executive::try_runtime_upgrade().unwrap();683 (weight, RuntimeBlockWeights::get().max_block)684 }685686 fn execute_block_no_check(block: Block) -> Weight {687 Executive::execute_block_no_check(block)688 }689 }690 }691 }692}