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
1#![cfg_attr(not(feature = "std"), no_std)]1#![cfg_attr(not(feature = "std"), no_std)]
22
3pub mod runtime_apis;
3pub mod constants;4pub mod constants;
4pub mod types;5pub mod types;
56
addedruntime/common/src/runtime_apis.rsdiffbeforeafterboth

no changes

modifiedruntime/opal/src/lib.rsdiffbeforeafterboth
112//use xcm_executor::traits::MatchesFungible;112//use xcm_executor::traits::MatchesFungible;
113use sp_runtime::traits::CheckedConversion;113use sp_runtime::traits::CheckedConversion;
114114
115use unique_runtime_common::{types::*, constants::*};115use unique_runtime_common::{impl_common_runtime_apis, types::*, constants::*};
116116
117pub const RUNTIME_NAME: &str = "Opal";117pub const RUNTIME_NAME: &str = "Opal";
118118
1112 }};1112 }};
1113}1113}
1114
1114impl_runtime_apis! {1115impl_common_runtime_apis!();
1115 impl up_rpc::UniqueApi<Block, CrossAccountId, AccountId>
1116 for Runtime
1117 {
1118 fn account_tokens(collection: CollectionId, account: CrossAccountId) -> Result<Vec<TokenId>, DispatchError> {
1119 dispatch_unique_runtime!(collection.account_tokens(account))
1120 }
1121 fn token_exists(collection: CollectionId, token: TokenId) -> Result<bool, DispatchError> {
1122 dispatch_unique_runtime!(collection.token_exists(token))
1123 }
1124
1125 fn token_owner(collection: CollectionId, token: TokenId) -> Result<Option<CrossAccountId>, DispatchError> {
1126 dispatch_unique_runtime!(collection.token_owner(token))
1127 }
1128 fn const_metadata(collection: CollectionId, token: TokenId) -> Result<Vec<u8>, DispatchError> {
1129 dispatch_unique_runtime!(collection.const_metadata(token))
1130 }
1131 fn variable_metadata(collection: CollectionId, token: TokenId) -> Result<Vec<u8>, DispatchError> {
1132 dispatch_unique_runtime!(collection.variable_metadata(token))
1133 }
1134
1135 fn collection_tokens(collection: CollectionId) -> Result<u32, DispatchError> {
1136 dispatch_unique_runtime!(collection.collection_tokens())
1137 }
1138 fn account_balance(collection: CollectionId, account: CrossAccountId) -> Result<u32, DispatchError> {
1139 dispatch_unique_runtime!(collection.account_balance(account))
1140 }
1141 fn balance(collection: CollectionId, account: CrossAccountId, token: TokenId) -> Result<u128, DispatchError> {
1142 dispatch_unique_runtime!(collection.balance(account, token))
1143 }
1144 fn allowance(
1145 collection: CollectionId,
1146 sender: CrossAccountId,
1147 spender: CrossAccountId,
1148 token: TokenId,
1149 ) -> Result<u128, DispatchError> {
1150 dispatch_unique_runtime!(collection.allowance(sender, spender, token))
1151 }
1152
1153 fn eth_contract_code(account: H160) -> Option<Vec<u8>> {
1154 <pallet_unique::UniqueErcSupport<Runtime>>::get_code(&account)
1155 .or_else(|| <pallet_evm_migration::OnMethodCall<Runtime>>::get_code(&account))
1156 .or_else(|| <pallet_evm_contract_helpers::HelpersOnMethodCall<Self>>::get_code(&account))
1157 }
1158 fn adminlist(collection: CollectionId) -> Result<Vec<CrossAccountId>, DispatchError> {
1159 Ok(<pallet_common::Pallet<Runtime>>::adminlist(collection))
1160 }
1161 fn allowlist(collection: CollectionId) -> Result<Vec<CrossAccountId>, DispatchError> {
1162 Ok(<pallet_common::Pallet<Runtime>>::allowlist(collection))
1163 }
1164 fn allowed(collection: CollectionId, user: CrossAccountId) -> Result<bool, DispatchError> {
1165 Ok(<pallet_common::Pallet<Runtime>>::allowed(collection, user))
1166 }
1167 fn last_token_id(collection: CollectionId) -> Result<TokenId, DispatchError> {
1168 dispatch_unique_runtime!(collection.last_token_id())
1169 }
1170 fn collection_by_id(collection: CollectionId) -> Result<Option<Collection<AccountId>>, DispatchError> {
1171 Ok(<pallet_common::CollectionById<Runtime>>::get(collection))
1172 }
1173 fn collection_stats() -> Result<CollectionStats, DispatchError> {
1174 Ok(<pallet_common::Pallet<Runtime>>::collection_stats())
1175 }
1176 }
1177
1178 impl sp_api::Core<Block> for Runtime {
1179 fn version() -> RuntimeVersion {
1180 VERSION
1181 }
1182
1183 fn execute_block(block: Block) {
1184 Executive::execute_block(block)
1185 }
1186
1187 fn initialize_block(header: &<Block as BlockT>::Header) {
1188 Executive::initialize_block(header)
1189 }
1190 }
1191
1192 impl sp_api::Metadata<Block> for Runtime {
1193 fn metadata() -> OpaqueMetadata {
1194 OpaqueMetadata::new(Runtime::metadata().into())
1195 }
1196 }
1197
1198 impl sp_block_builder::BlockBuilder<Block> for Runtime {
1199 fn apply_extrinsic(extrinsic: <Block as BlockT>::Extrinsic) -> ApplyExtrinsicResult {
1200 Executive::apply_extrinsic(extrinsic)
1201 }
1202
1203 fn finalize_block() -> <Block as BlockT>::Header {
1204 Executive::finalize_block()
1205 }
1206
1207 fn inherent_extrinsics(data: sp_inherents::InherentData) -> Vec<<Block as BlockT>::Extrinsic> {
1208 data.create_extrinsics()
1209 }
1210
1211 fn check_inherents(
1212 block: Block,
1213 data: sp_inherents::InherentData,
1214 ) -> sp_inherents::CheckInherentsResult {
1215 data.check_extrinsics(&block)
1216 }
1217
1218 // fn random_seed() -> <Block as BlockT>::Hash {
1219 // RandomnessCollectiveFlip::random_seed().0
1220 // }
1221 }
1222
1223 impl sp_transaction_pool::runtime_api::TaggedTransactionQueue<Block> for Runtime {
1224 fn validate_transaction(
1225 source: TransactionSource,
1226 tx: <Block as BlockT>::Extrinsic,
1227 hash: <Block as BlockT>::Hash,
1228 ) -> TransactionValidity {
1229 Executive::validate_transaction(source, tx, hash)
1230 }
1231 }
1232
1233 impl sp_offchain::OffchainWorkerApi<Block> for Runtime {
1234 fn offchain_worker(header: &<Block as BlockT>::Header) {
1235 Executive::offchain_worker(header)
1236 }
1237 }
1238
1239 impl fp_rpc::EthereumRuntimeRPCApi<Block> for Runtime {
1240 fn chain_id() -> u64 {
1241 <Runtime as pallet_evm::Config>::ChainId::get()
1242 }
1243
1244 fn account_basic(address: H160) -> EVMAccount {
1245 EVM::account_basic(&address)
1246 }
1247
1248 fn gas_price() -> U256 {
1249 <Runtime as pallet_evm::Config>::FeeCalculator::min_gas_price()
1250 }
1251
1252 fn account_code_at(address: H160) -> Vec<u8> {
1253 EVM::account_codes(address)
1254 }
1255
1256 fn author() -> H160 {
1257 <pallet_evm::Pallet<Runtime>>::find_author()
1258 }
1259
1260 fn storage_at(address: H160, index: U256) -> H256 {
1261 let mut tmp = [0u8; 32];
1262 index.to_big_endian(&mut tmp);
1263 EVM::account_storages(address, H256::from_slice(&tmp[..]))
1264 }
1265
1266 #[allow(clippy::redundant_closure)]
1267 fn call(
1268 from: H160,
1269 to: H160,
1270 data: Vec<u8>,
1271 value: U256,
1272 gas_limit: U256,
1273 max_fee_per_gas: Option<U256>,
1274 max_priority_fee_per_gas: Option<U256>,
1275 nonce: Option<U256>,
1276 estimate: bool,
1277 access_list: Option<Vec<(H160, Vec<H256>)>>,
1278 ) -> Result<pallet_evm::CallInfo, sp_runtime::DispatchError> {
1279 let config = if estimate {
1280 let mut config = <Runtime as pallet_evm::Config>::config().clone();
1281 config.estimate = true;
1282 Some(config)
1283 } else {
1284 None
1285 };
1286
1287 <Runtime as pallet_evm::Config>::Runner::call(
1288 from,
1289 to,
1290 data,
1291 value,
1292 gas_limit.low_u64(),
1293 max_fee_per_gas,
1294 max_priority_fee_per_gas,
1295 nonce,
1296 access_list.unwrap_or_default(),
1297 config.as_ref().unwrap_or_else(|| <Runtime as pallet_evm::Config>::config()),
1298 ).map_err(|err| err.into())
1299 }
1300
1301 #[allow(clippy::redundant_closure)]
1302 fn create(
1303 from: H160,
1304 data: Vec<u8>,
1305 value: U256,
1306 gas_limit: U256,
1307 max_fee_per_gas: Option<U256>,
1308 max_priority_fee_per_gas: Option<U256>,
1309 nonce: Option<U256>,
1310 estimate: bool,
1311 access_list: Option<Vec<(H160, Vec<H256>)>>,
1312 ) -> Result<pallet_evm::CreateInfo, sp_runtime::DispatchError> {
1313 let config = if estimate {
1314 let mut config = <Runtime as pallet_evm::Config>::config().clone();
1315 config.estimate = true;
1316 Some(config)
1317 } else {
1318 None
1319 };
1320
1321 <Runtime as pallet_evm::Config>::Runner::create(
1322 from,
1323 data,
1324 value,
1325 gas_limit.low_u64(),
1326 max_fee_per_gas,
1327 max_priority_fee_per_gas,
1328 nonce,
1329 access_list.unwrap_or_default(),
1330 config.as_ref().unwrap_or_else(|| <Runtime as pallet_evm::Config>::config()),
1331 ).map_err(|err| err.into())
1332 }
1333
1334 fn current_transaction_statuses() -> Option<Vec<TransactionStatus>> {
1335 Ethereum::current_transaction_statuses()
1336 }
1337
1338 fn current_block() -> Option<pallet_ethereum::Block> {
1339 Ethereum::current_block()
1340 }
1341
1342 fn current_receipts() -> Option<Vec<pallet_ethereum::Receipt>> {
1343 Ethereum::current_receipts()
1344 }
1345
1346 fn current_all() -> (
1347 Option<pallet_ethereum::Block>,
1348 Option<Vec<pallet_ethereum::Receipt>>,
1349 Option<Vec<TransactionStatus>>
1350 ) {
1351 (
1352 Ethereum::current_block(),
1353 Ethereum::current_receipts(),
1354 Ethereum::current_transaction_statuses()
1355 )
1356 }
1357
1358 fn extrinsic_filter(xts: Vec<<Block as sp_api::BlockT>::Extrinsic>) -> Vec<pallet_ethereum::Transaction> {
1359 xts.into_iter().filter_map(|xt| match xt.0.function {
1360 Call::Ethereum(pallet_ethereum::Call::transact { transaction }) => Some(transaction),
1361 _ => None
1362 }).collect()
1363 }
1364
1365 fn elasticity() -> Option<Permill> {
1366 None
1367 }
1368 }
1369
1370 impl sp_session::SessionKeys<Block> for Runtime {
1371 fn decode_session_keys(
1372 encoded: Vec<u8>,
1373 ) -> Option<Vec<(Vec<u8>, KeyTypeId)>> {
1374 SessionKeys::decode_into_raw_public_keys(&encoded)
1375 }
1376
1377 fn generate_session_keys(seed: Option<Vec<u8>>) -> Vec<u8> {
1378 SessionKeys::generate(seed)
1379 }
1380 }
1381
1382 impl sp_consensus_aura::AuraApi<Block, AuraId> for Runtime {
1383 fn slot_duration() -> sp_consensus_aura::SlotDuration {
1384 sp_consensus_aura::SlotDuration::from_millis(Aura::slot_duration())
1385 }
1386
1387 fn authorities() -> Vec<AuraId> {
1388 Aura::authorities().to_vec()
1389 }
1390 }
1391
1392 impl cumulus_primitives_core::CollectCollationInfo<Block> for Runtime {
1393 fn collect_collation_info(header: &<Block as BlockT>::Header) -> cumulus_primitives_core::CollationInfo {
1394 ParachainSystem::collect_collation_info(header)
1395 }
1396 }
1397
1398 impl frame_system_rpc_runtime_api::AccountNonceApi<Block, AccountId, Index> for Runtime {
1399 fn account_nonce(account: AccountId) -> Index {
1400 System::account_nonce(account)
1401 }
1402 }
1403
1404 impl pallet_transaction_payment_rpc_runtime_api::TransactionPaymentApi<Block, Balance> for Runtime {
1405 fn query_info(uxt: <Block as BlockT>::Extrinsic, len: u32) -> RuntimeDispatchInfo<Balance> {
1406 TransactionPayment::query_info(uxt, len)
1407 }
1408 fn query_fee_details(uxt: <Block as BlockT>::Extrinsic, len: u32) -> FeeDetails<Balance> {
1409 TransactionPayment::query_fee_details(uxt, len)
1410 }
1411 }
1412
1413 /*
1414 impl pallet_contracts_rpc_runtime_api::ContractsApi<Block, AccountId, Balance, BlockNumber, Hash>
1415 for Runtime
1416 {
1417 fn call(
1418 origin: AccountId,
1419 dest: AccountId,
1420 value: Balance,
1421 gas_limit: u64,
1422 input_data: Vec<u8>,
1423 ) -> pallet_contracts_primitives::ContractExecResult {
1424 Contracts::bare_call(origin, dest, value, gas_limit, input_data, false)
1425 }
1426
1427 fn instantiate(
1428 origin: AccountId,
1429 endowment: Balance,
1430 gas_limit: u64,
1431 code: pallet_contracts_primitives::Code<Hash>,
1432 data: Vec<u8>,
1433 salt: Vec<u8>,
1434 ) -> pallet_contracts_primitives::ContractInstantiateResult<AccountId, BlockNumber>
1435 {
1436 Contracts::bare_instantiate(origin, endowment, gas_limit, code, data, salt, true, false)
1437 }
1438
1439 fn get_storage(
1440 address: AccountId,
1441 key: [u8; 32],
1442 ) -> pallet_contracts_primitives::GetStorageResult {
1443 Contracts::get_storage(address, key)
1444 }
1445
1446 fn rent_projection(
1447 address: AccountId,
1448 ) -> pallet_contracts_primitives::RentProjectionResult<BlockNumber> {
1449 Contracts::rent_projection(address)
1450 }
1451 }
1452 */
1453
1454 #[cfg(feature = "runtime-benchmarks")]
1455 impl frame_benchmarking::Benchmark<Block> for Runtime {
1456 fn benchmark_metadata(extra: bool) -> (
1457 Vec<frame_benchmarking::BenchmarkList>,
1458 Vec<frame_support::traits::StorageInfo>,
1459 ) {
1460 use frame_benchmarking::{list_benchmark, Benchmarking, BenchmarkList};
1461 use frame_support::traits::StorageInfoTrait;
1462
1463 let mut list = Vec::<BenchmarkList>::new();
1464
1465 list_benchmark!(list, extra, pallet_evm_migration, EvmMigration);
1466 list_benchmark!(list, extra, pallet_unique, Unique);
1467 list_benchmark!(list, extra, pallet_inflation, Inflation);
1468 list_benchmark!(list, extra, pallet_fungible, Fungible);
1469 list_benchmark!(list, extra, pallet_refungible, Refungible);
1470 list_benchmark!(list, extra, pallet_nonfungible, Nonfungible);
1471 // list_benchmark!(list, extra, pallet_evm_coder_substrate, EvmCoderSubstrate);
1472
1473 let storage_info = AllPalletsReversedWithSystemFirst::storage_info();
1474
1475 return (list, storage_info)
1476 }
1477
1478 fn dispatch_benchmark(
1479 config: frame_benchmarking::BenchmarkConfig
1480 ) -> Result<Vec<frame_benchmarking::BenchmarkBatch>, sp_runtime::RuntimeString> {
1481 use frame_benchmarking::{Benchmarking, BenchmarkBatch, add_benchmark, TrackedStorageKey};
1482
1483 let allowlist: Vec<TrackedStorageKey> = vec![
1484 // Block Number
1485 hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef702a5c1b19ab7a04f536c519aca4983ac").to_vec().into(),
1486 // Total Issuance
1487 hex_literal::hex!("c2261276cc9d1f8598ea4b6a74b15c2f57c875e4cff74148e4628f264b974c80").to_vec().into(),
1488 // Execution Phase
1489 hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef7ff553b5a9862a516939d82b3d3d8661a").to_vec().into(),
1490 // Event Count
1491 hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef70a98fdbe9ce6c55837576c60c7af3850").to_vec().into(),
1492 // System Events
1493 hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef780d41e5e16056765bc8461851072c9d7").to_vec().into(),
1494 ];
1495
1496 let mut batches = Vec::<BenchmarkBatch>::new();
1497 let params = (&config, &allowlist);
1498
1499 add_benchmark!(params, batches, pallet_evm_migration, EvmMigration);
1500 add_benchmark!(params, batches, pallet_unique, Unique);
1501 add_benchmark!(params, batches, pallet_inflation, Inflation);
1502 add_benchmark!(params, batches, pallet_fungible, Fungible);
1503 add_benchmark!(params, batches, pallet_refungible, Refungible);
1504 add_benchmark!(params, batches, pallet_nonfungible, Nonfungible);
1505 // add_benchmark!(params, batches, pallet_evm_coder_substrate, EvmCoderSubstrate);
1506
1507 if batches.is_empty() { return Err("Benchmark not found for this pallet.".into()) }
1508 Ok(batches)
1509 }
1510 }
1511}
15121116
1513struct CheckInherents;1117struct CheckInherents;
15141118
modifiedruntime/quartz/src/lib.rsdiffbeforeafterboth
112//use xcm_executor::traits::MatchesFungible;112//use xcm_executor::traits::MatchesFungible;
113use sp_runtime::traits::CheckedConversion;113use sp_runtime::traits::CheckedConversion;
114114
115use unique_runtime_common::{types::*, constants::*};115use unique_runtime_common::{impl_common_runtime_apis, types::*, constants::*};
116116
117pub const RUNTIME_NAME: &str = "Quartz";117pub const RUNTIME_NAME: &str = "Quartz";
118118
1116 }};1116 }};
1117}1117}
1118
1118impl_runtime_apis! {1119impl_common_runtime_apis!();
1119 impl up_rpc::UniqueApi<Block, CrossAccountId, AccountId>
1120 for Runtime
1121 {
1122 fn account_tokens(collection: CollectionId, account: CrossAccountId) -> Result<Vec<TokenId>, DispatchError> {
1123 dispatch_unique_runtime!(collection.account_tokens(account))
1124 }
1125 fn token_exists(collection: CollectionId, token: TokenId) -> Result<bool, DispatchError> {
1126 dispatch_unique_runtime!(collection.token_exists(token))
1127 }
1128
1129 fn token_owner(collection: CollectionId, token: TokenId) -> Result<Option<CrossAccountId>, DispatchError> {
1130 dispatch_unique_runtime!(collection.token_owner(token))
1131 }
1132 fn const_metadata(collection: CollectionId, token: TokenId) -> Result<Vec<u8>, DispatchError> {
1133 dispatch_unique_runtime!(collection.const_metadata(token))
1134 }
1135 fn variable_metadata(collection: CollectionId, token: TokenId) -> Result<Vec<u8>, DispatchError> {
1136 dispatch_unique_runtime!(collection.variable_metadata(token))
1137 }
1138
1139 fn collection_tokens(collection: CollectionId) -> Result<u32, DispatchError> {
1140 dispatch_unique_runtime!(collection.collection_tokens())
1141 }
1142 fn account_balance(collection: CollectionId, account: CrossAccountId) -> Result<u32, DispatchError> {
1143 dispatch_unique_runtime!(collection.account_balance(account))
1144 }
1145 fn balance(collection: CollectionId, account: CrossAccountId, token: TokenId) -> Result<u128, DispatchError> {
1146 dispatch_unique_runtime!(collection.balance(account, token))
1147 }
1148 fn allowance(
1149 collection: CollectionId,
1150 sender: CrossAccountId,
1151 spender: CrossAccountId,
1152 token: TokenId,
1153 ) -> Result<u128, DispatchError> {
1154 dispatch_unique_runtime!(collection.allowance(sender, spender, token))
1155 }
1156
1157 fn eth_contract_code(account: H160) -> Option<Vec<u8>> {
1158 <pallet_unique::UniqueErcSupport<Runtime>>::get_code(&account)
1159 .or_else(|| <pallet_evm_migration::OnMethodCall<Runtime>>::get_code(&account))
1160 .or_else(|| <pallet_evm_contract_helpers::HelpersOnMethodCall<Self>>::get_code(&account))
1161 }
1162 fn adminlist(collection: CollectionId) -> Result<Vec<CrossAccountId>, DispatchError> {
1163 Ok(<pallet_common::Pallet<Runtime>>::adminlist(collection))
1164 }
1165 fn allowlist(collection: CollectionId) -> Result<Vec<CrossAccountId>, DispatchError> {
1166 Ok(<pallet_common::Pallet<Runtime>>::allowlist(collection))
1167 }
1168 fn allowed(collection: CollectionId, user: CrossAccountId) -> Result<bool, DispatchError> {
1169 Ok(<pallet_common::Pallet<Runtime>>::allowed(collection, user))
1170 }
1171 fn last_token_id(collection: CollectionId) -> Result<TokenId, DispatchError> {
1172 dispatch_unique_runtime!(collection.last_token_id())
1173 }
1174 fn collection_by_id(collection: CollectionId) -> Result<Option<Collection<AccountId>>, DispatchError> {
1175 Ok(<pallet_common::CollectionById<Runtime>>::get(collection))
1176 }
1177 fn collection_stats() -> Result<CollectionStats, DispatchError> {
1178 Ok(<pallet_common::Pallet<Runtime>>::collection_stats())
1179 }
1180 }
1181
1182 impl sp_api::Core<Block> for Runtime {
1183 fn version() -> RuntimeVersion {
1184 VERSION
1185 }
1186
1187 fn execute_block(block: Block) {
1188 Executive::execute_block(block)
1189 }
1190
1191 fn initialize_block(header: &<Block as BlockT>::Header) {
1192 Executive::initialize_block(header)
1193 }
1194 }
1195
1196 impl sp_api::Metadata<Block> for Runtime {
1197 fn metadata() -> OpaqueMetadata {
1198 OpaqueMetadata::new(Runtime::metadata().into())
1199 }
1200 }
1201
1202 impl sp_block_builder::BlockBuilder<Block> for Runtime {
1203 fn apply_extrinsic(extrinsic: <Block as BlockT>::Extrinsic) -> ApplyExtrinsicResult {
1204 Executive::apply_extrinsic(extrinsic)
1205 }
1206
1207 fn finalize_block() -> <Block as BlockT>::Header {
1208 Executive::finalize_block()
1209 }
1210
1211 fn inherent_extrinsics(data: sp_inherents::InherentData) -> Vec<<Block as BlockT>::Extrinsic> {
1212 data.create_extrinsics()
1213 }
1214
1215 fn check_inherents(
1216 block: Block,
1217 data: sp_inherents::InherentData,
1218 ) -> sp_inherents::CheckInherentsResult {
1219 data.check_extrinsics(&block)
1220 }
1221
1222 // fn random_seed() -> <Block as BlockT>::Hash {
1223 // RandomnessCollectiveFlip::random_seed().0
1224 // }
1225 }
1226
1227 impl sp_transaction_pool::runtime_api::TaggedTransactionQueue<Block> for Runtime {
1228 fn validate_transaction(
1229 source: TransactionSource,
1230 tx: <Block as BlockT>::Extrinsic,
1231 hash: <Block as BlockT>::Hash,
1232 ) -> TransactionValidity {
1233 Executive::validate_transaction(source, tx, hash)
1234 }
1235 }
1236
1237 impl sp_offchain::OffchainWorkerApi<Block> for Runtime {
1238 fn offchain_worker(header: &<Block as BlockT>::Header) {
1239 Executive::offchain_worker(header)
1240 }
1241 }
1242
1243 impl fp_rpc::EthereumRuntimeRPCApi<Block> for Runtime {
1244 fn chain_id() -> u64 {
1245 <Runtime as pallet_evm::Config>::ChainId::get()
1246 }
1247
1248 fn account_basic(address: H160) -> EVMAccount {
1249 EVM::account_basic(&address)
1250 }
1251
1252 fn gas_price() -> U256 {
1253 <Runtime as pallet_evm::Config>::FeeCalculator::min_gas_price()
1254 }
1255
1256 fn account_code_at(address: H160) -> Vec<u8> {
1257 EVM::account_codes(address)
1258 }
1259
1260 fn author() -> H160 {
1261 <pallet_evm::Pallet<Runtime>>::find_author()
1262 }
1263
1264 fn storage_at(address: H160, index: U256) -> H256 {
1265 let mut tmp = [0u8; 32];
1266 index.to_big_endian(&mut tmp);
1267 EVM::account_storages(address, H256::from_slice(&tmp[..]))
1268 }
1269
1270 #[allow(clippy::redundant_closure)]
1271 fn call(
1272 from: H160,
1273 to: H160,
1274 data: Vec<u8>,
1275 value: U256,
1276 gas_limit: U256,
1277 max_fee_per_gas: Option<U256>,
1278 max_priority_fee_per_gas: Option<U256>,
1279 nonce: Option<U256>,
1280 estimate: bool,
1281 access_list: Option<Vec<(H160, Vec<H256>)>>,
1282 ) -> Result<pallet_evm::CallInfo, sp_runtime::DispatchError> {
1283 let config = if estimate {
1284 let mut config = <Runtime as pallet_evm::Config>::config().clone();
1285 config.estimate = true;
1286 Some(config)
1287 } else {
1288 None
1289 };
1290
1291 <Runtime as pallet_evm::Config>::Runner::call(
1292 from,
1293 to,
1294 data,
1295 value,
1296 gas_limit.low_u64(),
1297 max_fee_per_gas,
1298 max_priority_fee_per_gas,
1299 nonce,
1300 access_list.unwrap_or_default(),
1301 config.as_ref().unwrap_or_else(|| <Runtime as pallet_evm::Config>::config()),
1302 ).map_err(|err| err.into())
1303 }
1304
1305 #[allow(clippy::redundant_closure)]
1306 fn create(
1307 from: H160,
1308 data: Vec<u8>,
1309 value: U256,
1310 gas_limit: U256,
1311 max_fee_per_gas: Option<U256>,
1312 max_priority_fee_per_gas: Option<U256>,
1313 nonce: Option<U256>,
1314 estimate: bool,
1315 access_list: Option<Vec<(H160, Vec<H256>)>>,
1316 ) -> Result<pallet_evm::CreateInfo, sp_runtime::DispatchError> {
1317 let config = if estimate {
1318 let mut config = <Runtime as pallet_evm::Config>::config().clone();
1319 config.estimate = true;
1320 Some(config)
1321 } else {
1322 None
1323 };
1324
1325 <Runtime as pallet_evm::Config>::Runner::create(
1326 from,
1327 data,
1328 value,
1329 gas_limit.low_u64(),
1330 max_fee_per_gas,
1331 max_priority_fee_per_gas,
1332 nonce,
1333 access_list.unwrap_or_default(),
1334 config.as_ref().unwrap_or_else(|| <Runtime as pallet_evm::Config>::config()),
1335 ).map_err(|err| err.into())
1336 }
1337
1338 fn current_transaction_statuses() -> Option<Vec<TransactionStatus>> {
1339 Ethereum::current_transaction_statuses()
1340 }
1341
1342 fn current_block() -> Option<pallet_ethereum::Block> {
1343 Ethereum::current_block()
1344 }
1345
1346 fn current_receipts() -> Option<Vec<pallet_ethereum::Receipt>> {
1347 Ethereum::current_receipts()
1348 }
1349
1350 fn current_all() -> (
1351 Option<pallet_ethereum::Block>,
1352 Option<Vec<pallet_ethereum::Receipt>>,
1353 Option<Vec<TransactionStatus>>
1354 ) {
1355 (
1356 Ethereum::current_block(),
1357 Ethereum::current_receipts(),
1358 Ethereum::current_transaction_statuses()
1359 )
1360 }
1361
1362 fn extrinsic_filter(xts: Vec<<Block as sp_api::BlockT>::Extrinsic>) -> Vec<pallet_ethereum::Transaction> {
1363 xts.into_iter().filter_map(|xt| match xt.0.function {
1364 Call::Ethereum(pallet_ethereum::Call::transact { transaction }) => Some(transaction),
1365 _ => None
1366 }).collect()
1367 }
1368
1369 fn elasticity() -> Option<Permill> {
1370 None
1371 }
1372 }
1373
1374 impl sp_session::SessionKeys<Block> for Runtime {
1375 fn decode_session_keys(
1376 encoded: Vec<u8>,
1377 ) -> Option<Vec<(Vec<u8>, KeyTypeId)>> {
1378 SessionKeys::decode_into_raw_public_keys(&encoded)
1379 }
1380
1381 fn generate_session_keys(seed: Option<Vec<u8>>) -> Vec<u8> {
1382 SessionKeys::generate(seed)
1383 }
1384 }
1385
1386 impl sp_consensus_aura::AuraApi<Block, AuraId> for Runtime {
1387 fn slot_duration() -> sp_consensus_aura::SlotDuration {
1388 sp_consensus_aura::SlotDuration::from_millis(Aura::slot_duration())
1389 }
1390
1391 fn authorities() -> Vec<AuraId> {
1392 Aura::authorities().to_vec()
1393 }
1394 }
1395
1396 impl cumulus_primitives_core::CollectCollationInfo<Block> for Runtime {
1397 fn collect_collation_info(header: &<Block as BlockT>::Header) -> cumulus_primitives_core::CollationInfo {
1398 ParachainSystem::collect_collation_info(header)
1399 }
1400 }
1401
1402 impl frame_system_rpc_runtime_api::AccountNonceApi<Block, AccountId, Index> for Runtime {
1403 fn account_nonce(account: AccountId) -> Index {
1404 System::account_nonce(account)
1405 }
1406 }
1407
1408 impl pallet_transaction_payment_rpc_runtime_api::TransactionPaymentApi<Block, Balance> for Runtime {
1409 fn query_info(uxt: <Block as BlockT>::Extrinsic, len: u32) -> RuntimeDispatchInfo<Balance> {
1410 TransactionPayment::query_info(uxt, len)
1411 }
1412 fn query_fee_details(uxt: <Block as BlockT>::Extrinsic, len: u32) -> FeeDetails<Balance> {
1413 TransactionPayment::query_fee_details(uxt, len)
1414 }
1415 }
1416
1417 /*
1418 impl pallet_contracts_rpc_runtime_api::ContractsApi<Block, AccountId, Balance, BlockNumber, Hash>
1419 for Runtime
1420 {
1421 fn call(
1422 origin: AccountId,
1423 dest: AccountId,
1424 value: Balance,
1425 gas_limit: u64,
1426 input_data: Vec<u8>,
1427 ) -> pallet_contracts_primitives::ContractExecResult {
1428 Contracts::bare_call(origin, dest, value, gas_limit, input_data, false)
1429 }
1430
1431 fn instantiate(
1432 origin: AccountId,
1433 endowment: Balance,
1434 gas_limit: u64,
1435 code: pallet_contracts_primitives::Code<Hash>,
1436 data: Vec<u8>,
1437 salt: Vec<u8>,
1438 ) -> pallet_contracts_primitives::ContractInstantiateResult<AccountId, BlockNumber>
1439 {
1440 Contracts::bare_instantiate(origin, endowment, gas_limit, code, data, salt, true, false)
1441 }
1442
1443 fn get_storage(
1444 address: AccountId,
1445 key: [u8; 32],
1446 ) -> pallet_contracts_primitives::GetStorageResult {
1447 Contracts::get_storage(address, key)
1448 }
1449
1450 fn rent_projection(
1451 address: AccountId,
1452 ) -> pallet_contracts_primitives::RentProjectionResult<BlockNumber> {
1453 Contracts::rent_projection(address)
1454 }
1455 }
1456 */
1457
1458 #[cfg(feature = "runtime-benchmarks")]
1459 impl frame_benchmarking::Benchmark<Block> for Runtime {
1460 fn benchmark_metadata(extra: bool) -> (
1461 Vec<frame_benchmarking::BenchmarkList>,
1462 Vec<frame_support::traits::StorageInfo>,
1463 ) {
1464 use frame_benchmarking::{list_benchmark, Benchmarking, BenchmarkList};
1465 use frame_support::traits::StorageInfoTrait;
1466
1467 let mut list = Vec::<BenchmarkList>::new();
1468
1469 list_benchmark!(list, extra, pallet_evm_migration, EvmMigration);
1470 list_benchmark!(list, extra, pallet_unique, Unique);
1471 list_benchmark!(list, extra, pallet_inflation, Inflation);
1472 list_benchmark!(list, extra, pallet_fungible, Fungible);
1473 list_benchmark!(list, extra, pallet_refungible, Refungible);
1474 list_benchmark!(list, extra, pallet_nonfungible, Nonfungible);
1475 // list_benchmark!(list, extra, pallet_evm_coder_substrate, EvmCoderSubstrate);
1476
1477 let storage_info = AllPalletsReversedWithSystemFirst::storage_info();
1478
1479 return (list, storage_info)
1480 }
1481
1482 fn dispatch_benchmark(
1483 config: frame_benchmarking::BenchmarkConfig
1484 ) -> Result<Vec<frame_benchmarking::BenchmarkBatch>, sp_runtime::RuntimeString> {
1485 use frame_benchmarking::{Benchmarking, BenchmarkBatch, add_benchmark, TrackedStorageKey};
1486
1487 let allowlist: Vec<TrackedStorageKey> = vec![
1488 // Block Number
1489 hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef702a5c1b19ab7a04f536c519aca4983ac").to_vec().into(),
1490 // Total Issuance
1491 hex_literal::hex!("c2261276cc9d1f8598ea4b6a74b15c2f57c875e4cff74148e4628f264b974c80").to_vec().into(),
1492 // Execution Phase
1493 hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef7ff553b5a9862a516939d82b3d3d8661a").to_vec().into(),
1494 // Event Count
1495 hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef70a98fdbe9ce6c55837576c60c7af3850").to_vec().into(),
1496 // System Events
1497 hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef780d41e5e16056765bc8461851072c9d7").to_vec().into(),
1498 ];
1499
1500 let mut batches = Vec::<BenchmarkBatch>::new();
1501 let params = (&config, &allowlist);
1502
1503 add_benchmark!(params, batches, pallet_evm_migration, EvmMigration);
1504 add_benchmark!(params, batches, pallet_unique, Unique);
1505 add_benchmark!(params, batches, pallet_inflation, Inflation);
1506 add_benchmark!(params, batches, pallet_fungible, Fungible);
1507 add_benchmark!(params, batches, pallet_refungible, Refungible);
1508 add_benchmark!(params, batches, pallet_nonfungible, Nonfungible);
1509 // add_benchmark!(params, batches, pallet_evm_coder_substrate, EvmCoderSubstrate);
1510
1511 if batches.is_empty() { return Err("Benchmark not found for this pallet.".into()) }
1512 Ok(batches)
1513 }
1514 }
1515}
15161120
1517struct CheckInherents;1121struct CheckInherents;
15181122
modifiedruntime/unique/src/lib.rsdiffbeforeafterboth
112//use xcm_executor::traits::MatchesFungible;112//use xcm_executor::traits::MatchesFungible;
113use sp_runtime::traits::CheckedConversion;113use sp_runtime::traits::CheckedConversion;
114114
115use unique_runtime_common::{types::*, constants::*};115use unique_runtime_common::{impl_common_runtime_apis, types::*, constants::*};
116116
117pub const RUNTIME_NAME: &str = "Unique";117pub const RUNTIME_NAME: &str = "Unique";
118118
1117 }};1117 }};
1118}1118}
1119
1119impl_runtime_apis! {1120impl_common_runtime_apis!();
1120 impl up_rpc::UniqueApi<Block, CrossAccountId, AccountId>
1121 for Runtime
1122 {
1123 fn account_tokens(collection: CollectionId, account: CrossAccountId) -> Result<Vec<TokenId>, DispatchError> {
1124 dispatch_unique_runtime!(collection.account_tokens(account))
1125 }
1126 fn token_exists(collection: CollectionId, token: TokenId) -> Result<bool, DispatchError> {
1127 dispatch_unique_runtime!(collection.token_exists(token))
1128 }
1129
1130 fn token_owner(collection: CollectionId, token: TokenId) -> Result<Option<CrossAccountId>, DispatchError> {
1131 dispatch_unique_runtime!(collection.token_owner(token))
1132 }
1133 fn const_metadata(collection: CollectionId, token: TokenId) -> Result<Vec<u8>, DispatchError> {
1134 dispatch_unique_runtime!(collection.const_metadata(token))
1135 }
1136 fn variable_metadata(collection: CollectionId, token: TokenId) -> Result<Vec<u8>, DispatchError> {
1137 dispatch_unique_runtime!(collection.variable_metadata(token))
1138 }
1139
1140 fn collection_tokens(collection: CollectionId) -> Result<u32, DispatchError> {
1141 dispatch_unique_runtime!(collection.collection_tokens())
1142 }
1143 fn account_balance(collection: CollectionId, account: CrossAccountId) -> Result<u32, DispatchError> {
1144 dispatch_unique_runtime!(collection.account_balance(account))
1145 }
1146 fn balance(collection: CollectionId, account: CrossAccountId, token: TokenId) -> Result<u128, DispatchError> {
1147 dispatch_unique_runtime!(collection.balance(account, token))
1148 }
1149 fn allowance(
1150 collection: CollectionId,
1151 sender: CrossAccountId,
1152 spender: CrossAccountId,
1153 token: TokenId,
1154 ) -> Result<u128, DispatchError> {
1155 dispatch_unique_runtime!(collection.allowance(sender, spender, token))
1156 }
1157
1158 fn eth_contract_code(account: H160) -> Option<Vec<u8>> {
1159 <pallet_unique::UniqueErcSupport<Runtime>>::get_code(&account)
1160 .or_else(|| <pallet_evm_migration::OnMethodCall<Runtime>>::get_code(&account))
1161 .or_else(|| <pallet_evm_contract_helpers::HelpersOnMethodCall<Self>>::get_code(&account))
1162 }
1163 fn adminlist(collection: CollectionId) -> Result<Vec<CrossAccountId>, DispatchError> {
1164 Ok(<pallet_common::Pallet<Runtime>>::adminlist(collection))
1165 }
1166 fn allowlist(collection: CollectionId) -> Result<Vec<CrossAccountId>, DispatchError> {
1167 Ok(<pallet_common::Pallet<Runtime>>::allowlist(collection))
1168 }
1169 fn allowed(collection: CollectionId, user: CrossAccountId) -> Result<bool, DispatchError> {
1170 Ok(<pallet_common::Pallet<Runtime>>::allowed(collection, user))
1171 }
1172 fn last_token_id(collection: CollectionId) -> Result<TokenId, DispatchError> {
1173 dispatch_unique_runtime!(collection.last_token_id())
1174 }
1175 fn collection_by_id(collection: CollectionId) -> Result<Option<Collection<AccountId>>, DispatchError> {
1176 Ok(<pallet_common::CollectionById<Runtime>>::get(collection))
1177 }
1178 fn collection_stats() -> Result<CollectionStats, DispatchError> {
1179 Ok(<pallet_common::Pallet<Runtime>>::collection_stats())
1180 }
1181 }
1182
1183 impl sp_api::Core<Block> for Runtime {
1184 fn version() -> RuntimeVersion {
1185 VERSION
1186 }
1187
1188 fn execute_block(block: Block) {
1189 Executive::execute_block(block)
1190 }
1191
1192 fn initialize_block(header: &<Block as BlockT>::Header) {
1193 Executive::initialize_block(header)
1194 }
1195 }
1196
1197 impl sp_api::Metadata<Block> for Runtime {
1198 fn metadata() -> OpaqueMetadata {
1199 OpaqueMetadata::new(Runtime::metadata().into())
1200 }
1201 }
1202
1203 impl sp_block_builder::BlockBuilder<Block> for Runtime {
1204 fn apply_extrinsic(extrinsic: <Block as BlockT>::Extrinsic) -> ApplyExtrinsicResult {
1205 Executive::apply_extrinsic(extrinsic)
1206 }
1207
1208 fn finalize_block() -> <Block as BlockT>::Header {
1209 Executive::finalize_block()
1210 }
1211
1212 fn inherent_extrinsics(data: sp_inherents::InherentData) -> Vec<<Block as BlockT>::Extrinsic> {
1213 data.create_extrinsics()
1214 }
1215
1216 fn check_inherents(
1217 block: Block,
1218 data: sp_inherents::InherentData,
1219 ) -> sp_inherents::CheckInherentsResult {
1220 data.check_extrinsics(&block)
1221 }
1222
1223 // fn random_seed() -> <Block as BlockT>::Hash {
1224 // RandomnessCollectiveFlip::random_seed().0
1225 // }
1226 }
1227
1228 impl sp_transaction_pool::runtime_api::TaggedTransactionQueue<Block> for Runtime {
1229 fn validate_transaction(
1230 source: TransactionSource,
1231 tx: <Block as BlockT>::Extrinsic,
1232 hash: <Block as BlockT>::Hash,
1233 ) -> TransactionValidity {
1234 Executive::validate_transaction(source, tx, hash)
1235 }
1236 }
1237
1238 impl sp_offchain::OffchainWorkerApi<Block> for Runtime {
1239 fn offchain_worker(header: &<Block as BlockT>::Header) {
1240 Executive::offchain_worker(header)
1241 }
1242 }
1243
1244 impl fp_rpc::EthereumRuntimeRPCApi<Block> for Runtime {
1245 fn chain_id() -> u64 {
1246 <Runtime as pallet_evm::Config>::ChainId::get()
1247 }
1248
1249 fn account_basic(address: H160) -> EVMAccount {
1250 EVM::account_basic(&address)
1251 }
1252
1253 fn gas_price() -> U256 {
1254 <Runtime as pallet_evm::Config>::FeeCalculator::min_gas_price()
1255 }
1256
1257 fn account_code_at(address: H160) -> Vec<u8> {
1258 EVM::account_codes(address)
1259 }
1260
1261 fn author() -> H160 {
1262 <pallet_evm::Pallet<Runtime>>::find_author()
1263 }
1264
1265 fn storage_at(address: H160, index: U256) -> H256 {
1266 let mut tmp = [0u8; 32];
1267 index.to_big_endian(&mut tmp);
1268 EVM::account_storages(address, H256::from_slice(&tmp[..]))
1269 }
1270
1271 #[allow(clippy::redundant_closure)]
1272 fn call(
1273 from: H160,
1274 to: H160,
1275 data: Vec<u8>,
1276 value: U256,
1277 gas_limit: U256,
1278 max_fee_per_gas: Option<U256>,
1279 max_priority_fee_per_gas: Option<U256>,
1280 nonce: Option<U256>,
1281 estimate: bool,
1282 access_list: Option<Vec<(H160, Vec<H256>)>>,
1283 ) -> Result<pallet_evm::CallInfo, sp_runtime::DispatchError> {
1284 let config = if estimate {
1285 let mut config = <Runtime as pallet_evm::Config>::config().clone();
1286 config.estimate = true;
1287 Some(config)
1288 } else {
1289 None
1290 };
1291
1292 <Runtime as pallet_evm::Config>::Runner::call(
1293 from,
1294 to,
1295 data,
1296 value,
1297 gas_limit.low_u64(),
1298 max_fee_per_gas,
1299 max_priority_fee_per_gas,
1300 nonce,
1301 access_list.unwrap_or_default(),
1302 config.as_ref().unwrap_or_else(|| <Runtime as pallet_evm::Config>::config()),
1303 ).map_err(|err| err.into())
1304 }
1305
1306 #[allow(clippy::redundant_closure)]
1307 fn create(
1308 from: H160,
1309 data: Vec<u8>,
1310 value: U256,
1311 gas_limit: U256,
1312 max_fee_per_gas: Option<U256>,
1313 max_priority_fee_per_gas: Option<U256>,
1314 nonce: Option<U256>,
1315 estimate: bool,
1316 access_list: Option<Vec<(H160, Vec<H256>)>>,
1317 ) -> Result<pallet_evm::CreateInfo, sp_runtime::DispatchError> {
1318 let config = if estimate {
1319 let mut config = <Runtime as pallet_evm::Config>::config().clone();
1320 config.estimate = true;
1321 Some(config)
1322 } else {
1323 None
1324 };
1325
1326 <Runtime as pallet_evm::Config>::Runner::create(
1327 from,
1328 data,
1329 value,
1330 gas_limit.low_u64(),
1331 max_fee_per_gas,
1332 max_priority_fee_per_gas,
1333 nonce,
1334 access_list.unwrap_or_default(),
1335 config.as_ref().unwrap_or_else(|| <Runtime as pallet_evm::Config>::config()),
1336 ).map_err(|err| err.into())
1337 }
1338
1339 fn current_transaction_statuses() -> Option<Vec<TransactionStatus>> {
1340 Ethereum::current_transaction_statuses()
1341 }
1342
1343 fn current_block() -> Option<pallet_ethereum::Block> {
1344 Ethereum::current_block()
1345 }
1346
1347 fn current_receipts() -> Option<Vec<pallet_ethereum::Receipt>> {
1348 Ethereum::current_receipts()
1349 }
1350
1351 fn current_all() -> (
1352 Option<pallet_ethereum::Block>,
1353 Option<Vec<pallet_ethereum::Receipt>>,
1354 Option<Vec<TransactionStatus>>
1355 ) {
1356 (
1357 Ethereum::current_block(),
1358 Ethereum::current_receipts(),
1359 Ethereum::current_transaction_statuses()
1360 )
1361 }
1362
1363 fn extrinsic_filter(xts: Vec<<Block as sp_api::BlockT>::Extrinsic>) -> Vec<pallet_ethereum::Transaction> {
1364 xts.into_iter().filter_map(|xt| match xt.0.function {
1365 Call::Ethereum(pallet_ethereum::Call::transact { transaction }) => Some(transaction),
1366 _ => None
1367 }).collect()
1368 }
1369
1370 fn elasticity() -> Option<Permill> {
1371 None
1372 }
1373 }
1374
1375 impl sp_session::SessionKeys<Block> for Runtime {
1376 fn decode_session_keys(
1377 encoded: Vec<u8>,
1378 ) -> Option<Vec<(Vec<u8>, KeyTypeId)>> {
1379 SessionKeys::decode_into_raw_public_keys(&encoded)
1380 }
1381
1382 fn generate_session_keys(seed: Option<Vec<u8>>) -> Vec<u8> {
1383 SessionKeys::generate(seed)
1384 }
1385 }
1386
1387 impl sp_consensus_aura::AuraApi<Block, AuraId> for Runtime {
1388 fn slot_duration() -> sp_consensus_aura::SlotDuration {
1389 sp_consensus_aura::SlotDuration::from_millis(Aura::slot_duration())
1390 }
1391
1392 fn authorities() -> Vec<AuraId> {
1393 Aura::authorities().to_vec()
1394 }
1395 }
1396
1397 impl cumulus_primitives_core::CollectCollationInfo<Block> for Runtime {
1398 fn collect_collation_info(header: &<Block as BlockT>::Header) -> cumulus_primitives_core::CollationInfo {
1399 ParachainSystem::collect_collation_info(header)
1400 }
1401 }
1402
1403 impl frame_system_rpc_runtime_api::AccountNonceApi<Block, AccountId, Index> for Runtime {
1404 fn account_nonce(account: AccountId) -> Index {
1405 System::account_nonce(account)
1406 }
1407 }
1408
1409 impl pallet_transaction_payment_rpc_runtime_api::TransactionPaymentApi<Block, Balance> for Runtime {
1410 fn query_info(uxt: <Block as BlockT>::Extrinsic, len: u32) -> RuntimeDispatchInfo<Balance> {
1411 TransactionPayment::query_info(uxt, len)
1412 }
1413 fn query_fee_details(uxt: <Block as BlockT>::Extrinsic, len: u32) -> FeeDetails<Balance> {
1414 TransactionPayment::query_fee_details(uxt, len)
1415 }
1416 }
1417
1418 /*
1419 impl pallet_contracts_rpc_runtime_api::ContractsApi<Block, AccountId, Balance, BlockNumber, Hash>
1420 for Runtime
1421 {
1422 fn call(
1423 origin: AccountId,
1424 dest: AccountId,
1425 value: Balance,
1426 gas_limit: u64,
1427 input_data: Vec<u8>,
1428 ) -> pallet_contracts_primitives::ContractExecResult {
1429 Contracts::bare_call(origin, dest, value, gas_limit, input_data, false)
1430 }
1431
1432 fn instantiate(
1433 origin: AccountId,
1434 endowment: Balance,
1435 gas_limit: u64,
1436 code: pallet_contracts_primitives::Code<Hash>,
1437 data: Vec<u8>,
1438 salt: Vec<u8>,
1439 ) -> pallet_contracts_primitives::ContractInstantiateResult<AccountId, BlockNumber>
1440 {
1441 Contracts::bare_instantiate(origin, endowment, gas_limit, code, data, salt, true, false)
1442 }
1443
1444 fn get_storage(
1445 address: AccountId,
1446 key: [u8; 32],
1447 ) -> pallet_contracts_primitives::GetStorageResult {
1448 Contracts::get_storage(address, key)
1449 }
1450
1451 fn rent_projection(
1452 address: AccountId,
1453 ) -> pallet_contracts_primitives::RentProjectionResult<BlockNumber> {
1454 Contracts::rent_projection(address)
1455 }
1456 }
1457 */
1458
1459 #[cfg(feature = "runtime-benchmarks")]
1460 impl frame_benchmarking::Benchmark<Block> for Runtime {
1461 fn benchmark_metadata(extra: bool) -> (
1462 Vec<frame_benchmarking::BenchmarkList>,
1463 Vec<frame_support::traits::StorageInfo>,
1464 ) {
1465 use frame_benchmarking::{list_benchmark, Benchmarking, BenchmarkList};
1466 use frame_support::traits::StorageInfoTrait;
1467
1468 let mut list = Vec::<BenchmarkList>::new();
1469
1470 list_benchmark!(list, extra, pallet_evm_migration, EvmMigration);
1471 list_benchmark!(list, extra, pallet_unique, Unique);
1472 list_benchmark!(list, extra, pallet_inflation, Inflation);
1473 list_benchmark!(list, extra, pallet_fungible, Fungible);
1474 list_benchmark!(list, extra, pallet_refungible, Refungible);
1475 list_benchmark!(list, extra, pallet_nonfungible, Nonfungible);
1476 // list_benchmark!(list, extra, pallet_evm_coder_substrate, EvmCoderSubstrate);
1477
1478 let storage_info = AllPalletsReversedWithSystemFirst::storage_info();
1479
1480 return (list, storage_info)
1481 }
1482
1483 fn dispatch_benchmark(
1484 config: frame_benchmarking::BenchmarkConfig
1485 ) -> Result<Vec<frame_benchmarking::BenchmarkBatch>, sp_runtime::RuntimeString> {
1486 use frame_benchmarking::{Benchmarking, BenchmarkBatch, add_benchmark, TrackedStorageKey};
1487
1488 let allowlist: Vec<TrackedStorageKey> = vec![
1489 // Block Number
1490 hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef702a5c1b19ab7a04f536c519aca4983ac").to_vec().into(),
1491 // Total Issuance
1492 hex_literal::hex!("c2261276cc9d1f8598ea4b6a74b15c2f57c875e4cff74148e4628f264b974c80").to_vec().into(),
1493 // Execution Phase
1494 hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef7ff553b5a9862a516939d82b3d3d8661a").to_vec().into(),
1495 // Event Count
1496 hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef70a98fdbe9ce6c55837576c60c7af3850").to_vec().into(),
1497 // System Events
1498 hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef780d41e5e16056765bc8461851072c9d7").to_vec().into(),
1499 ];
1500
1501 let mut batches = Vec::<BenchmarkBatch>::new();
1502 let params = (&config, &allowlist);
1503
1504 add_benchmark!(params, batches, pallet_evm_migration, EvmMigration);
1505 add_benchmark!(params, batches, pallet_unique, Unique);
1506 add_benchmark!(params, batches, pallet_inflation, Inflation);
1507 add_benchmark!(params, batches, pallet_fungible, Fungible);
1508 add_benchmark!(params, batches, pallet_refungible, Refungible);
1509 add_benchmark!(params, batches, pallet_nonfungible, Nonfungible);
1510 // add_benchmark!(params, batches, pallet_evm_coder_substrate, EvmCoderSubstrate);
1511
1512 if batches.is_empty() { return Err("Benchmark not found for this pallet.".into()) }
1513 Ok(batches)
1514 }
1515 }
1516}
15171121
1518struct CheckInherents;1122struct CheckInherents;
15191123