12345678#![cfg_attr(not(feature = "std"), no_std)]910#![recursion_limit = "256"]111213#[cfg(feature = "std")]14include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs"));1516use sp_api::impl_runtime_apis;17use sp_core::{ crypto::KeyTypeId, OpaqueMetadata };181920use sp_runtime::traits::{21 AccountIdLookup, AccountIdConversion, BlakeTwo256, Block as BlockT, ConvertInto, IdentifyAccount, Verify,22};23use sp_runtime::{24 Permill, Perbill, Percent,25 create_runtime_str, generic, impl_opaque_keys,26 transaction_validity::{TransactionSource, TransactionValidity},27 ApplyExtrinsicResult, MultiSignature,28};2930use sp_std::prelude::*;3132#[cfg(feature = "std")]33use sp_version::NativeVersion;34use sp_version::RuntimeVersion;35pub use pallet_transaction_payment::{Multiplier, TargetedFeeAdjustment, FeeDetails, RuntimeDispatchInfo};3637pub use pallet_balances::Call as BalancesCall;38pub use frame_support::{39 construct_runtime,40 match_type,41 dispatch::DispatchResult,42 PalletId,43 parameter_types,44 StorageValue,45 traits::{46 All, Currency, ExistenceRequirement, Get, IsInVec, KeyOwnerProofSystem, LockIdentifier, OnUnbalanced, Randomness47 },48 weights::{49 constants::{BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight, WEIGHT_PER_SECOND},50 DispatchClass, DispatchInfo, GetDispatchInfo, IdentityFee, Pays, PostDispatchInfo, Weight,51 WeightToFeePolynomial, WeightToFeeCoefficient, WeightToFeeCoefficients52 },53};54use pallet_contracts::weights::WeightInfo;5556use frame_system::{57 self as system,58 EnsureRoot, 59 limits::{BlockWeights, BlockLength},60};61use sp_arithmetic::{traits::{BaseArithmetic, Unsigned}};62use smallvec::smallvec;6364pub use pallet_timestamp::Call as TimestampCall;65pub use sp_consensus_aura::sr25519::AuthorityId as AuraId;666768use pallet_xcm::XcmPassthrough;69use polkadot_parachain::primitives::Sibling;70use xcm::v0::Xcm;71use xcm::v0::{BodyId, Junction::*, MultiAsset, MultiLocation, MultiLocation::*, NetworkId};72use xcm_builder::{73 AccountId32Aliases, AllowTopLevelPaidExecutionFrom, AllowUnpaidExecutionFrom, CurrencyAdapter,74 EnsureXcmOrigin, FixedWeightBounds, IsConcrete, LocationInverter, NativeAsset,75 ParentAsSuperuser, ParentIsDefault, RelayChainAsNative, SiblingParachainAsNative,76 SiblingParachainConvertsVia, SignedAccountId32AsNative, SignedToAccountId32,77 SovereignSignedViaLocation, TakeWeightCredit, UsingComponents,78};79use xcm_executor::{Config, XcmExecutor};808182mod chain_extension;83use crate::chain_extension::{ NFTExtension, Imbalance };84858687extern crate pallet_nft;88pub use pallet_nft::*;899091extern crate pallet_inflation;92pub use pallet_inflation::*;939495pub type BlockNumber = u32;969798pub type Signature = MultiSignature;99100101102pub type AccountId = <<Signature as Verify>::Signer as IdentifyAccount>::AccountId;103104105106pub type AccountIndex = u32;107108109pub type Balance = u128;110111112pub type Index = u32;113114115pub type Hash = sp_core::H256;116117118pub type DigestItem = generic::DigestItem<Hash>;119120mod nft_weights;121122123124125126pub mod opaque {127 use super::*;128129 pub use sp_runtime::OpaqueExtrinsic as UncheckedExtrinsic;130131 132 pub type Block = generic::Block<Header, UncheckedExtrinsic>;133134 pub type SessionHandlers = ();135136 impl_opaque_keys! {137 pub struct SessionKeys {138 pub aura: Aura,139 }140 }141}142143144pub const VERSION: RuntimeVersion = RuntimeVersion {145 spec_name: create_runtime_str!("nft"),146 impl_name: create_runtime_str!("nft"),147 authoring_version: 1,148 spec_version: 3,149 impl_version: 1,150 apis: RUNTIME_API_VERSIONS,151 transaction_version: 1,152};153154pub const MILLISECS_PER_BLOCK: u64 = 12000;155156pub const SLOT_DURATION: u64 = MILLISECS_PER_BLOCK;157158159pub const MINUTES: BlockNumber = 60_000 / (MILLISECS_PER_BLOCK as BlockNumber);160pub const HOURS: BlockNumber = MINUTES * 60;161pub const DAYS: BlockNumber = HOURS * 24;162163#[derive(codec::Encode, codec::Decode)]164pub enum XCMPMessage<XAccountId, XBalance> {165 166 TransferToken(XAccountId, XBalance),167}168169170#[cfg(feature = "std")]171pub fn native_version() -> NativeVersion {172 NativeVersion {173 runtime_version: VERSION,174 can_author_with: Default::default(),175 }176}177178type NegativeImbalance = <Balances as Currency<AccountId>>::NegativeImbalance;179180pub struct DealWithFees;181impl OnUnbalanced<NegativeImbalance> for DealWithFees {182 fn on_unbalanceds<B>(mut fees_then_tips: impl Iterator<Item=NegativeImbalance>) {183 if let Some(fees) = fees_then_tips.next() {184 185 let mut split = fees.ration(100, 0);186 if let Some(tips) = fees_then_tips.next() {187 188 tips.ration_merge_into(100, 0, &mut split);189 }190 Treasury::on_unbalanced(split.0);191 192 }193 }194}195196197198199200201202203204205206207208209210211212213const AVERAGE_ON_INITIALIZE_RATIO: Perbill = Perbill::from_percent(10);214215216const NORMAL_DISPATCH_RATIO: Perbill = Perbill::from_percent(75);217218const MAXIMUM_BLOCK_WEIGHT: Weight = 2 * WEIGHT_PER_SECOND;219220parameter_types! {221 pub const BlockHashCount: BlockNumber = 2400;222 pub RuntimeBlockLength: BlockLength =223 BlockLength::max_with_normal_ratio(5 * 1024 * 1024, NORMAL_DISPATCH_RATIO);224 pub const AvailableBlockRatio: Perbill = Perbill::from_percent(75);225 pub const MaximumBlockLength: u32 = 5 * 1024 * 1024;226 pub RuntimeBlockWeights: BlockWeights = BlockWeights::builder()227 .base_block(BlockExecutionWeight::get())228 .for_class(DispatchClass::all(), |weights| {229 weights.base_extrinsic = ExtrinsicBaseWeight::get();230 })231 .for_class(DispatchClass::Normal, |weights| {232 weights.max_total = Some(NORMAL_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT);233 })234 .for_class(DispatchClass::Operational, |weights| {235 weights.max_total = Some(MAXIMUM_BLOCK_WEIGHT);236 237 238 weights.reserved = Some(239 MAXIMUM_BLOCK_WEIGHT - NORMAL_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT240 );241 })242 .avg_block_initialization(AVERAGE_ON_INITIALIZE_RATIO)243 .build_or_panic();244 pub const Version: RuntimeVersion = VERSION;245 pub const SS58Prefix: u8 = 42;246}247248impl system::Config for Runtime {249 250 type AccountData = pallet_balances::AccountData<Balance>;251 252 type AccountId = AccountId;253 254 type BaseCallFilter = ();255 256 type BlockHashCount = BlockHashCount;257 258 type BlockLength = RuntimeBlockLength;259 260 type BlockNumber = BlockNumber;261 262 type BlockWeights = RuntimeBlockWeights;263 264 type Call = Call;265 266 type DbWeight = RocksDbWeight;267 268 type Event = Event;269 270 type Hash = Hash;271 272 type Hashing = BlakeTwo256;273 274 type Header = generic::Header<BlockNumber, BlakeTwo256>;275 276 type Index = Index;277 278 type Lookup = AccountIdLookup<AccountId, ()>;279 280 type OnKilledAccount = ();281 282 type OnNewAccount = ();283 type OnSetCode = cumulus_pallet_parachain_system::ParachainSetCode<Self>;284 285 type Origin = Origin;286 287 type PalletInfo = PalletInfo;288 289 type SS58Prefix = SS58Prefix;290 291 type SystemWeightInfo = system::weights::SubstrateWeight<Runtime>;292 293 type Version = Version;294}295296parameter_types! {297 pub const MinimumPeriod: u64 = SLOT_DURATION / 2;298}299300impl pallet_timestamp::Config for Runtime {301 302 type Moment = u64;303 type OnTimestampSet = ();304 type MinimumPeriod = MinimumPeriod;305 type WeightInfo = ();306}307308parameter_types! {309 310 pub const ExistentialDeposit: u128 = 0;311 pub const MaxLocks: u32 = 50;312}313314impl pallet_balances::Config for Runtime {315 type MaxLocks = MaxLocks;316 317 type Balance = Balance;318 319 type Event = Event;320 type DustRemoval = Treasury;321 type ExistentialDeposit = ExistentialDeposit;322 type AccountStore = System;323 type WeightInfo = pallet_balances::weights::SubstrateWeight<Runtime>;324}325326pub const MICROUNIQUE: Balance = 1_000_000_000;327pub const MILLIUNIQUE: Balance = 1_000 * MICROUNIQUE;328pub const CENTIUNIQUE: Balance = 10 * MILLIUNIQUE;329pub const UNIQUE: Balance = 100 * CENTIUNIQUE;330331pub const fn deposit(items: u32, bytes: u32) -> Balance {332 items as Balance * 15 * CENTIUNIQUE + (bytes as Balance) * 6 * CENTIUNIQUE333}334335parameter_types! {336 pub TombstoneDeposit: Balance = deposit(337 1,338 sp_std::mem::size_of::<pallet_contracts::Pallet<Runtime>> as u32,339 );340 pub DepositPerContract: Balance = TombstoneDeposit::get();341 pub const DepositPerStorageByte: Balance = deposit(0, 1);342 pub const DepositPerStorageItem: Balance = deposit(1, 0);343 pub RentFraction: Perbill = Perbill::from_rational(1u32, 30 * DAYS);344 pub const SurchargeReward: Balance = 150 * MILLIUNIQUE;345 pub const SignedClaimHandicap: u32 = 2;346 pub const MaxDepth: u32 = 32;347 pub const MaxValueSize: u32 = 16 * 1024;348 pub const MaxCodeSize: u32 = 1024 * 1024 * 25; 349 350 pub DeletionWeightLimit: Weight = AVERAGE_ON_INITIALIZE_RATIO *351 RuntimeBlockWeights::get().max_block;352 353 354 pub DeletionQueueDepth: u32 = ((DeletionWeightLimit::get() / (355 <Runtime as pallet_contracts::Config>::WeightInfo::on_initialize_per_queue_item(1) -356 <Runtime as pallet_contracts::Config>::WeightInfo::on_initialize_per_queue_item(0)357 )) / 5) as u32;358 pub Schedule: pallet_contracts::Schedule<Runtime> = Default::default();359}360361impl pallet_contracts::Config for Runtime {362 type Time = Timestamp;363 type Randomness = RandomnessCollectiveFlip;364 type Currency = Balances;365 type Event = Event;366 type RentPayment = ();367 type SignedClaimHandicap = SignedClaimHandicap;368 type TombstoneDeposit = TombstoneDeposit;369 type DepositPerContract = DepositPerContract;370 type DepositPerStorageByte = DepositPerStorageByte;371 type DepositPerStorageItem = DepositPerStorageItem;372 type RentFraction = RentFraction;373 type SurchargeReward = SurchargeReward;374 375 376 type WeightPrice = pallet_transaction_payment::Module<Self>;377 type WeightInfo = pallet_contracts::weights::SubstrateWeight<Self>;378 type ChainExtension = NFTExtension;379 type DeletionQueueDepth = DeletionQueueDepth;380 type DeletionWeightLimit = DeletionWeightLimit;381 382 type Schedule = Schedule;383 type CallStack = [pallet_contracts::Frame<Self>; 31];384}385386parameter_types! {387 pub const TransactionByteFee: Balance = 501 * MICROUNIQUE; 388}389390391pub struct LinearFee<T>(sp_std::marker::PhantomData<T>);392393impl<T> WeightToFeePolynomial for LinearFee<T> where394 T: BaseArithmetic + From<u32> + Copy + Unsigned395{396 type Balance = T;397398 fn polynomial() -> WeightToFeeCoefficients<Self::Balance> {399 smallvec!(WeightToFeeCoefficient {400 coeff_integer: 146_700u32.into(), 401 coeff_frac: Perbill::zero(),402 negative: false,403 degree: 1,404 })405 }406}407408impl pallet_transaction_payment::Config for Runtime {409 type OnChargeTransaction = pallet_transaction_payment::CurrencyAdapter<Balances, ()>;410 type TransactionByteFee = TransactionByteFee;411 type WeightToFee = LinearFee<Balance>;412 type FeeMultiplierUpdate = ();413}414415parameter_types! {416 pub const ProposalBond: Permill = Permill::from_percent(5);417 pub const ProposalBondMinimum: Balance = 1 * UNIQUE;418 pub const SpendPeriod: BlockNumber = 5 * MINUTES;419 pub const Burn: Permill = Permill::from_percent(0);420 pub const TipCountdown: BlockNumber = 1 * DAYS;421 pub const TipFindersFee: Percent = Percent::from_percent(20);422 pub const TipReportDepositBase: Balance = 1 * UNIQUE;423 pub const DataDepositPerByte: Balance = 1 * CENTIUNIQUE;424 pub const BountyDepositBase: Balance = 1 * UNIQUE;425 pub const BountyDepositPayoutDelay: BlockNumber = 1 * DAYS;426 pub const TreasuryModuleId: PalletId = PalletId(*b"py/trsry");427 pub const BountyUpdatePeriod: BlockNumber = 14 * DAYS;428 pub const MaximumReasonLength: u32 = 16384;429 pub const BountyCuratorDeposit: Permill = Permill::from_percent(50);430 pub const BountyValueMinimum: Balance = 5 * UNIQUE;431 pub const MaxApprovals: u32 = 100;432}433434impl pallet_treasury::Config for Runtime {435 type PalletId = TreasuryModuleId;436 type Currency = Balances;437 type ApproveOrigin = EnsureRoot<AccountId>;438 type RejectOrigin = EnsureRoot<AccountId>;439 type Event = Event;440 type OnSlash = ();441 type ProposalBond = ProposalBond;442 type ProposalBondMinimum = ProposalBondMinimum;443 type SpendPeriod = SpendPeriod;444 type Burn = Burn;445 type BurnDestination = ();446 type SpendFunds = ();447 type WeightInfo = pallet_treasury::weights::SubstrateWeight<Runtime>;448 type MaxApprovals = MaxApprovals;449}450451impl pallet_sudo::Config for Runtime {452 type Event = Event;453 type Call = Call;454}455456parameter_types! {457 pub const MinVestedTransfer: Balance = 10 * UNIQUE;458}459460impl pallet_vesting::Config for Runtime {461 type Event = Event;462 type Currency = Balances;463 type BlockNumberToBalance = ConvertInto;464 type MinVestedTransfer = MinVestedTransfer;465 type WeightInfo = ();466}467468parameter_types! {469 pub const ReservedDmpWeight: Weight = MAXIMUM_BLOCK_WEIGHT / 4;470 pub const ReservedXcmpWeight: Weight = MAXIMUM_BLOCK_WEIGHT / 4;471}472473impl cumulus_pallet_parachain_system::Config for Runtime {474 type Event = Event;475 type OnValidationData = ();476 type SelfParaId = parachain_info::Pallet<Runtime>;477 478 479 480 481 482 type OutboundXcmpMessageSource = XcmpQueue;483 type DmpMessageHandler = DmpQueue;484 type ReservedDmpWeight = ReservedDmpWeight;485 type ReservedXcmpWeight = ReservedXcmpWeight;486 type XcmpMessageHandler = XcmpQueue;487}488489impl parachain_info::Config for Runtime {}490491impl cumulus_pallet_aura_ext::Config for Runtime {}492493parameter_types! {494 pub const RelayLocation: MultiLocation = X1(Parent);495 pub const RelayNetwork: NetworkId = NetworkId::Polkadot;496 pub RelayOrigin: Origin = cumulus_pallet_xcm::Origin::Relay.into();497 pub Ancestry: MultiLocation = X1(Parachain(ParachainInfo::parachain_id().into()));498}499500501502503pub type LocationToAccountId = (504 505 ParentIsDefault<AccountId>,506 507 SiblingParachainConvertsVia<Sibling, AccountId>,508 509 AccountId32Aliases<RelayNetwork, AccountId>,510);511512513pub type LocalAssetTransactor = CurrencyAdapter<514 515 Balances,516 517 IsConcrete<RelayLocation>,518 519 LocationToAccountId,520 521 AccountId,522 523 (),524>;525526527528529pub type XcmOriginToTransactDispatchOrigin = (530 531 532 533 SovereignSignedViaLocation<LocationToAccountId, Origin>,534 535 536 RelayChainAsNative<RelayOrigin, Origin>,537 538 539 SiblingParachainAsNative<cumulus_pallet_xcm::Origin, Origin>,540 541 542 ParentAsSuperuser<Origin>,543 544 545 SignedAccountId32AsNative<RelayNetwork, Origin>,546 547 XcmPassthrough<Origin>,548);549550parameter_types! {551 552 pub UnitWeightCost: Weight = 1_000_000;553 554 pub const WeightPrice: (MultiLocation, u128) = (X1(Parent), 1_200 * UNIQUE);555}556557match_type! {558 pub type ParentOrParentsUnitPlurality: impl Contains<MultiLocation> = {559 X1(Parent) | X2(Parent, Plurality { id: BodyId::Unit, .. })560 };561}562563pub type Barrier = (564 TakeWeightCredit,565 AllowTopLevelPaidExecutionFrom<All<MultiLocation>>,566 AllowUnpaidExecutionFrom<ParentOrParentsUnitPlurality>,567 568);569570pub struct XcmConfig;571impl Config for XcmConfig {572 type Call = Call;573 type XcmSender = XcmRouter;574 575 type AssetTransactor = LocalAssetTransactor;576 type OriginConverter = XcmOriginToTransactDispatchOrigin;577 type IsReserve = NativeAsset;578 type IsTeleporter = NativeAsset; 579 type LocationInverter = LocationInverter<Ancestry>;580 type Barrier = Barrier;581 type Weigher = FixedWeightBounds<UnitWeightCost, Call>;582 type Trader = UsingComponents<IdentityFee<Balance>, RelayLocation, AccountId, Balances, ()>;583 type ResponseHandler = (); 584}585586587588589590591pub type LocalOriginToLocation = (SignedToAccountId32<Origin, AccountId, RelayNetwork>,);592593594595pub type XcmRouter = (596 597 cumulus_primitives_utility::ParentAsUmp<ParachainSystem>,598 599 XcmpQueue,600);601602impl pallet_xcm::Config for Runtime {603 type Event = Event;604 type SendXcmOrigin = EnsureXcmOrigin<Origin, LocalOriginToLocation>;605 type XcmRouter = XcmRouter;606 type ExecuteXcmOrigin = EnsureXcmOrigin<Origin, LocalOriginToLocation>;607 type XcmExecuteFilter = All<(MultiLocation, Xcm<Call>)>;608 type XcmExecutor = XcmExecutor<XcmConfig>;609 type XcmTeleportFilter = All<(MultiLocation, Vec<MultiAsset>)>;610 type XcmReserveTransferFilter = ();611 type Weigher = FixedWeightBounds<UnitWeightCost, Call>;612}613614impl cumulus_pallet_xcm::Config for Runtime {615 type Event = Event;616 type XcmExecutor = XcmExecutor<XcmConfig>;617}618619impl cumulus_pallet_xcmp_queue::Config for Runtime {620 type Event = Event;621 type XcmExecutor = XcmExecutor<XcmConfig>;622 type ChannelInfo = ParachainSystem;623}624625impl cumulus_pallet_dmp_queue::Config for Runtime {626 type Event = Event;627 type XcmExecutor = XcmExecutor<XcmConfig>;628 type ExecuteOverweightOrigin = frame_system::EnsureRoot<AccountId>;629}630631impl pallet_aura::Config for Runtime {632 type AuthorityId = AuraId;633}634635parameter_types! {636 pub TreasuryAccountId: AccountId = TreasuryModuleId::get().into_account();637 pub const CollectionCreationPrice: Balance = 100 * UNIQUE;638}639640641impl pallet_nft::Config for Runtime {642 type Event = Event;643 type WeightInfo = nft_weights::WeightInfo;644 type Currency = Balances;645 type CollectionCreationPrice = CollectionCreationPrice;646 type TreasuryAccountId = TreasuryAccountId;647}648649parameter_types! {650 pub const InflationBlockInterval: BlockNumber = 100; 651}652653654impl pallet_inflation::Config for Runtime {655 type Currency = Balances;656 type TreasuryAccountId = TreasuryAccountId;657 type InflationBlockInterval = InflationBlockInterval;658}659660construct_runtime!(661 pub enum Runtime where662 Block = Block,663 NodeBlock = opaque::Block,664 UncheckedExtrinsic = UncheckedExtrinsic665 {666 Balances: pallet_balances::{Pallet, Call, Storage, Config<T>, Event<T>} = 30,667 Contracts: pallet_contracts::{Pallet, Call, Storage, Event<T>},668 RandomnessCollectiveFlip: pallet_randomness_collective_flip::{Pallet, Call, Storage},669 Timestamp: pallet_timestamp::{Pallet, Call, Storage, Inherent},670 TransactionPayment: pallet_transaction_payment::{Pallet, Storage},671 Treasury: pallet_treasury::{Pallet, Call, Storage, Config, Event<T>},672 Sudo: pallet_sudo::{Pallet, Call, Storage, Config<T>, Event<T>},673 System: system::{Pallet, Call, Storage, Config, Event<T>},674 Vesting: pallet_vesting::{Pallet, Call, Config<T>, Storage, Event<T>},675676 ParachainSystem: cumulus_pallet_parachain_system::{Pallet, Call, Storage, Inherent, Event<T>, ValidateUnsigned} = 20,677 ParachainInfo: parachain_info::{Pallet, Storage, Config} = 21,678679 Aura: pallet_aura::{Pallet, Config<T>},680 AuraExt: cumulus_pallet_aura_ext::{Pallet, Config},681682 683 XcmpQueue: cumulus_pallet_xcmp_queue::{Pallet, Call, Storage, Event<T>} = 50,684 PolkadotXcm: pallet_xcm::{Pallet, Call, Event<T>, Origin} = 51,685 CumulusXcm: cumulus_pallet_xcm::{Pallet, Call, Event<T>, Origin} = 52,686 DmpQueue: cumulus_pallet_dmp_queue::{Pallet, Call, Storage, Event<T>} = 53,687688689 690 Inflation: pallet_inflation::{Pallet, Call, Storage},691 Nft: pallet_nft::{Pallet, Call, Config<T>, Storage, Event<T>},692 }693);694695696pub type Address = sp_runtime::MultiAddress<AccountId, ()>;697698pub type Header = generic::Header<BlockNumber, BlakeTwo256>;699700pub type Block = generic::Block<Header, UncheckedExtrinsic>;701702pub type SignedBlock = generic::SignedBlock<Block>;703704pub type BlockId = generic::BlockId<Block>;705706pub type SignedExtra = (707 system::CheckSpecVersion<Runtime>,708 709 system::CheckGenesis<Runtime>,710 system::CheckEra<Runtime>,711 system::CheckNonce<Runtime>,712 system::CheckWeight<Runtime>,713 pallet_nft::ChargeTransactionPayment<Runtime>,714);715716pub type UncheckedExtrinsic = generic::UncheckedExtrinsic<Address, Call, Signature, SignedExtra>;717718pub type CheckedExtrinsic = generic::CheckedExtrinsic<AccountId, Call, SignedExtra>;719720pub type Executive = frame_executive::Executive<721 Runtime,722 Block,723 frame_system::ChainContext<Runtime>,724 Runtime,725 AllPallets,726>;727728impl_opaque_keys! {729 pub struct SessionKeys {730 pub aura: Aura,731 }732}733734impl_runtime_apis! {735 impl sp_api::Core<Block> for Runtime {736 fn version() -> RuntimeVersion {737 VERSION738 }739740 fn execute_block(block: Block) {741 Executive::execute_block(block)742 }743744 fn initialize_block(header: &<Block as BlockT>::Header) {745 Executive::initialize_block(header)746 }747 }748749 impl sp_api::Metadata<Block> for Runtime {750 fn metadata() -> OpaqueMetadata {751 Runtime::metadata().into()752 }753 }754755 impl sp_block_builder::BlockBuilder<Block> for Runtime {756 fn apply_extrinsic(extrinsic: <Block as BlockT>::Extrinsic) -> ApplyExtrinsicResult {757 Executive::apply_extrinsic(extrinsic)758 }759760 fn finalize_block() -> <Block as BlockT>::Header {761 Executive::finalize_block()762 }763764 fn inherent_extrinsics(data: sp_inherents::InherentData) -> Vec<<Block as BlockT>::Extrinsic> {765 data.create_extrinsics()766 }767768 fn check_inherents(769 block: Block,770 data: sp_inherents::InherentData,771 ) -> sp_inherents::CheckInherentsResult {772 data.check_extrinsics(&block)773 }774775 776 777 778 }779780 impl sp_transaction_pool::runtime_api::TaggedTransactionQueue<Block> for Runtime {781 fn validate_transaction(782 source: TransactionSource,783 tx: <Block as BlockT>::Extrinsic,784 ) -> TransactionValidity {785 Executive::validate_transaction(source, tx)786 }787 }788789 impl sp_offchain::OffchainWorkerApi<Block> for Runtime {790 fn offchain_worker(header: &<Block as BlockT>::Header) {791 Executive::offchain_worker(header)792 }793 }794795 impl sp_session::SessionKeys<Block> for Runtime {796 fn decode_session_keys(797 encoded: Vec<u8>,798 ) -> Option<Vec<(Vec<u8>, KeyTypeId)>> {799 SessionKeys::decode_into_raw_public_keys(&encoded)800 }801802 fn generate_session_keys(seed: Option<Vec<u8>>) -> Vec<u8> {803 SessionKeys::generate(seed)804 }805 }806807 impl sp_consensus_aura::AuraApi<Block, AuraId> for Runtime {808 fn slot_duration() -> sp_consensus_aura::SlotDuration {809 sp_consensus_aura::SlotDuration::from_millis(Aura::slot_duration())810 }811812 fn authorities() -> Vec<AuraId> {813 Aura::authorities()814 }815 }816817 impl cumulus_primitives_core::CollectCollationInfo<Block> for Runtime {818 fn collect_collation_info() -> cumulus_primitives_core::CollationInfo {819 ParachainSystem::collect_collation_info()820 }821 }822823 impl frame_system_rpc_runtime_api::AccountNonceApi<Block, AccountId, Index> for Runtime {824 fn account_nonce(account: AccountId) -> Index {825 System::account_nonce(account)826 }827 }828829 impl pallet_transaction_payment_rpc_runtime_api::TransactionPaymentApi<Block, Balance> for Runtime {830 fn query_info(uxt: <Block as BlockT>::Extrinsic, len: u32) -> RuntimeDispatchInfo<Balance> {831 TransactionPayment::query_info(uxt, len)832 }833 fn query_fee_details(uxt: <Block as BlockT>::Extrinsic, len: u32) -> FeeDetails<Balance> {834 TransactionPayment::query_fee_details(uxt, len)835 }836 }837838 impl pallet_contracts_rpc_runtime_api::ContractsApi<Block, AccountId, Balance, BlockNumber, Hash>839 for Runtime840 {841 fn call(842 origin: AccountId,843 dest: AccountId,844 value: Balance,845 gas_limit: u64,846 input_data: Vec<u8>,847 ) -> pallet_contracts_primitives::ContractExecResult {848 Contracts::bare_call(origin, dest, value, gas_limit, input_data, false)849 }850851 fn instantiate(852 origin: AccountId,853 endowment: Balance,854 gas_limit: u64,855 code: pallet_contracts_primitives::Code<Hash>,856 data: Vec<u8>,857 salt: Vec<u8>,858 ) -> pallet_contracts_primitives::ContractInstantiateResult<AccountId, BlockNumber>859 {860 Contracts::bare_instantiate(origin, endowment, gas_limit, code, data, salt, true, false)861 }862863 fn get_storage(864 address: AccountId,865 key: [u8; 32],866 ) -> pallet_contracts_primitives::GetStorageResult {867 Contracts::get_storage(address, key)868 }869870 fn rent_projection(871 address: AccountId,872 ) -> pallet_contracts_primitives::RentProjectionResult<BlockNumber> {873 Contracts::rent_projection(address)874 }875 }876877 #[cfg(feature = "runtime-benchmarks")]878 impl frame_benchmarking::Benchmark<Block> for Runtime {879 fn dispatch_benchmark(880 config: frame_benchmarking::BenchmarkConfig881 ) -> Result<Vec<frame_benchmarking::BenchmarkBatch>, sp_runtime::RuntimeString> {882 use frame_benchmarking::{Benchmarking, BenchmarkBatch, add_benchmark, TrackedStorageKey};883884 let whitelist: Vec<TrackedStorageKey> = vec![885 886 hex_literal::hex!("d43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d").to_vec().into(),887 888 889 890 891 892 893 894 895 ];896897 let mut batches = Vec::<BenchmarkBatch>::new();898 let params = (&config, &whitelist);899900 add_benchmark!(params, batches, pallet_nft, Nft);901 add_benchmark!(params, batches, pallet_inflation, Inflation);902903 if batches.is_empty() { return Err("Benchmark not found for this pallet.".into()) }904 Ok(batches)905 }906 }907}908909cumulus_pallet_parachain_system::register_validate_block!(910 Runtime,911 cumulus_pallet_aura_ext::BlockExecutor::<Runtime, Executive>,912);