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::*;899091pub type BlockNumber = u32;929394pub type Signature = MultiSignature;95969798pub type AccountId = <<Signature as Verify>::Signer as IdentifyAccount>::AccountId;99100101102pub type AccountIndex = u32;103104105pub type Balance = u128;106107108pub type Index = u32;109110111pub type Hash = sp_core::H256;112113114pub type DigestItem = generic::DigestItem<Hash>;115116mod nft_weights;117118119120121122pub mod opaque {123 use super::*;124125 pub use sp_runtime::OpaqueExtrinsic as UncheckedExtrinsic;126127 128 pub type Block = generic::Block<Header, UncheckedExtrinsic>;129130 pub type SessionHandlers = ();131132 impl_opaque_keys! {133 pub struct SessionKeys {}134 }135}136137138pub const VERSION: RuntimeVersion = RuntimeVersion {139 spec_name: create_runtime_str!("nft"),140 impl_name: create_runtime_str!("nft"),141 authoring_version: 1,142 spec_version: 3,143 impl_version: 1,144 apis: RUNTIME_API_VERSIONS,145 transaction_version: 1,146};147148pub const MILLISECS_PER_BLOCK: u64 = 12000;149150pub const SLOT_DURATION: u64 = MILLISECS_PER_BLOCK;151152153pub const MINUTES: BlockNumber = 60_000 / (MILLISECS_PER_BLOCK as BlockNumber);154pub const HOURS: BlockNumber = MINUTES * 60;155pub const DAYS: BlockNumber = HOURS * 24;156157#[derive(codec::Encode, codec::Decode)]158pub enum XCMPMessage<XAccountId, XBalance> {159 160 TransferToken(XAccountId, XBalance),161}162163164#[cfg(feature = "std")]165pub fn native_version() -> NativeVersion {166 NativeVersion {167 runtime_version: VERSION,168 can_author_with: Default::default(),169 }170}171172type NegativeImbalance = <Balances as Currency<AccountId>>::NegativeImbalance;173174pub struct DealWithFees;175impl OnUnbalanced<NegativeImbalance> for DealWithFees {176 fn on_unbalanceds<B>(mut fees_then_tips: impl Iterator<Item=NegativeImbalance>) {177 if let Some(fees) = fees_then_tips.next() {178 179 let mut split = fees.ration(100, 0);180 if let Some(tips) = fees_then_tips.next() {181 182 tips.ration_merge_into(100, 0, &mut split);183 }184 Treasury::on_unbalanced(split.0);185 186 }187 }188}189190191192193194195196197198199200201202203204205206207const AVERAGE_ON_INITIALIZE_RATIO: Perbill = Perbill::from_percent(10);208209210const NORMAL_DISPATCH_RATIO: Perbill = Perbill::from_percent(75);211212const MAXIMUM_BLOCK_WEIGHT: Weight = 2 * WEIGHT_PER_SECOND;213214parameter_types! {215 pub const BlockHashCount: BlockNumber = 2400;216 pub RuntimeBlockLength: BlockLength =217 BlockLength::max_with_normal_ratio(5 * 1024 * 1024, NORMAL_DISPATCH_RATIO);218 pub const AvailableBlockRatio: Perbill = Perbill::from_percent(75);219 pub const MaximumBlockLength: u32 = 5 * 1024 * 1024;220 pub RuntimeBlockWeights: BlockWeights = BlockWeights::builder()221 .base_block(BlockExecutionWeight::get())222 .for_class(DispatchClass::all(), |weights| {223 weights.base_extrinsic = ExtrinsicBaseWeight::get();224 })225 .for_class(DispatchClass::Normal, |weights| {226 weights.max_total = Some(NORMAL_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT);227 })228 .for_class(DispatchClass::Operational, |weights| {229 weights.max_total = Some(MAXIMUM_BLOCK_WEIGHT);230 231 232 weights.reserved = Some(233 MAXIMUM_BLOCK_WEIGHT - NORMAL_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT234 );235 })236 .avg_block_initialization(AVERAGE_ON_INITIALIZE_RATIO)237 .build_or_panic();238 pub const Version: RuntimeVersion = VERSION;239 pub const SS58Prefix: u8 = 42;240}241242impl system::Config for Runtime {243 244 type AccountData = pallet_balances::AccountData<Balance>;245 246 type AccountId = AccountId;247 248 type BaseCallFilter = ();249 250 type BlockHashCount = BlockHashCount;251 252 type BlockLength = RuntimeBlockLength;253 254 type BlockNumber = BlockNumber;255 256 type BlockWeights = RuntimeBlockWeights;257 258 type Call = Call;259 260 type DbWeight = RocksDbWeight;261 262 type Event = Event;263 264 type Hash = Hash;265 266 type Hashing = BlakeTwo256;267 268 type Header = generic::Header<BlockNumber, BlakeTwo256>;269 270 type Index = Index;271 272 type Lookup = AccountIdLookup<AccountId, ()>;273 274 type OnKilledAccount = ();275 276 type OnNewAccount = ();277 type OnSetCode = cumulus_pallet_parachain_system::ParachainSetCode<Self>;278 279 type Origin = Origin;280 281 type PalletInfo = PalletInfo;282 283 type SS58Prefix = SS58Prefix;284 285 type SystemWeightInfo = system::weights::SubstrateWeight<Runtime>;286 287 type Version = Version;288}289290parameter_types! {291 pub const MinimumPeriod: u64 = SLOT_DURATION / 2;292}293294impl pallet_timestamp::Config for Runtime {295 296 type Moment = u64;297 type OnTimestampSet = ();298 type MinimumPeriod = MinimumPeriod;299 type WeightInfo = ();300}301302parameter_types! {303 304 pub const ExistentialDeposit: u128 = 0;305 pub const MaxLocks: u32 = 50;306}307308impl pallet_balances::Config for Runtime {309 type MaxLocks = MaxLocks;310 311 type Balance = Balance;312 313 type Event = Event;314 type DustRemoval = Treasury;315 type ExistentialDeposit = ExistentialDeposit;316 type AccountStore = System;317 type WeightInfo = pallet_balances::weights::SubstrateWeight<Runtime>;318}319320pub const MICROUNIQUE: Balance = 1_000_000_000;321pub const MILLIUNIQUE: Balance = 1_000 * MICROUNIQUE;322pub const CENTIUNIQUE: Balance = 10 * MILLIUNIQUE;323pub const UNIQUE: Balance = 100 * CENTIUNIQUE;324325pub const fn deposit(items: u32, bytes: u32) -> Balance {326 items as Balance * 15 * CENTIUNIQUE + (bytes as Balance) * 6 * CENTIUNIQUE327}328329parameter_types! {330 pub TombstoneDeposit: Balance = deposit(331 1,332 sp_std::mem::size_of::<pallet_contracts::Pallet<Runtime>> as u32,333 );334 pub DepositPerContract: Balance = TombstoneDeposit::get();335 pub const DepositPerStorageByte: Balance = deposit(0, 1);336 pub const DepositPerStorageItem: Balance = deposit(1, 0);337 pub RentFraction: Perbill = Perbill::from_rational(1u32, 30 * DAYS);338 pub const SurchargeReward: Balance = 150 * MILLIUNIQUE;339 pub const SignedClaimHandicap: u32 = 2;340 pub const MaxDepth: u32 = 32;341 pub const MaxValueSize: u32 = 16 * 1024;342 pub const MaxCodeSize: u32 = 1024 * 1024 * 25; 343 344 pub DeletionWeightLimit: Weight = AVERAGE_ON_INITIALIZE_RATIO *345 RuntimeBlockWeights::get().max_block;346 347 348 pub DeletionQueueDepth: u32 = ((DeletionWeightLimit::get() / (349 <Runtime as pallet_contracts::Config>::WeightInfo::on_initialize_per_queue_item(1) -350 <Runtime as pallet_contracts::Config>::WeightInfo::on_initialize_per_queue_item(0)351 )) / 5) as u32;352 pub Schedule: pallet_contracts::Schedule<Runtime> = Default::default();353}354355impl pallet_contracts::Config for Runtime {356 type Time = Timestamp;357 type Randomness = RandomnessCollectiveFlip;358 type Currency = Balances;359 type Event = Event;360 type RentPayment = ();361 type SignedClaimHandicap = SignedClaimHandicap;362 type TombstoneDeposit = TombstoneDeposit;363 type DepositPerContract = DepositPerContract;364 type DepositPerStorageByte = DepositPerStorageByte;365 type DepositPerStorageItem = DepositPerStorageItem;366 type RentFraction = RentFraction;367 type SurchargeReward = SurchargeReward;368 369 370 type WeightPrice = pallet_transaction_payment::Module<Self>;371 type WeightInfo = pallet_contracts::weights::SubstrateWeight<Self>;372 type ChainExtension = NFTExtension;373 type DeletionQueueDepth = DeletionQueueDepth;374 type DeletionWeightLimit = DeletionWeightLimit;375 376 type Schedule = Schedule;377 type CallStack = [pallet_contracts::Frame<Self>; 31];378}379380parameter_types! {381 pub const TransactionByteFee: Balance = 501 * MICROUNIQUE; 382}383384385pub struct LinearFee<T>(sp_std::marker::PhantomData<T>);386387impl<T> WeightToFeePolynomial for LinearFee<T> where388 T: BaseArithmetic + From<u32> + Copy + Unsigned389{390 type Balance = T;391392 fn polynomial() -> WeightToFeeCoefficients<Self::Balance> {393 smallvec!(WeightToFeeCoefficient {394 coeff_integer: 146_700u32.into(), 395 coeff_frac: Perbill::zero(),396 negative: false,397 degree: 1,398 })399 }400}401402impl pallet_transaction_payment::Config for Runtime {403 type OnChargeTransaction = pallet_transaction_payment::CurrencyAdapter<Balances, ()>;404 type TransactionByteFee = TransactionByteFee;405 type WeightToFee = LinearFee<Balance>;406 type FeeMultiplierUpdate = ();407}408409parameter_types! {410 pub const ProposalBond: Permill = Permill::from_percent(5);411 pub const ProposalBondMinimum: Balance = 1 * UNIQUE;412 pub const SpendPeriod: BlockNumber = 5 * MINUTES;413 pub const Burn: Permill = Permill::from_percent(0);414 pub const TipCountdown: BlockNumber = 1 * DAYS;415 pub const TipFindersFee: Percent = Percent::from_percent(20);416 pub const TipReportDepositBase: Balance = 1 * UNIQUE;417 pub const DataDepositPerByte: Balance = 1 * CENTIUNIQUE;418 pub const BountyDepositBase: Balance = 1 * UNIQUE;419 pub const BountyDepositPayoutDelay: BlockNumber = 1 * DAYS;420 pub const TreasuryModuleId: PalletId = PalletId(*b"py/trsry");421 pub const BountyUpdatePeriod: BlockNumber = 14 * DAYS;422 pub const MaximumReasonLength: u32 = 16384;423 pub const BountyCuratorDeposit: Permill = Permill::from_percent(50);424 pub const BountyValueMinimum: Balance = 5 * UNIQUE;425 pub const MaxApprovals: u32 = 100;426}427428impl pallet_treasury::Config for Runtime {429 type PalletId = TreasuryModuleId;430 type Currency = Balances;431 type ApproveOrigin = EnsureRoot<AccountId>;432 type RejectOrigin = EnsureRoot<AccountId>;433 type Event = Event;434 type OnSlash = ();435 type ProposalBond = ProposalBond;436 type ProposalBondMinimum = ProposalBondMinimum;437 type SpendPeriod = SpendPeriod;438 type Burn = Burn;439 type BurnDestination = ();440 type SpendFunds = ();441 type WeightInfo = pallet_treasury::weights::SubstrateWeight<Runtime>;442 type MaxApprovals = MaxApprovals;443}444445impl pallet_sudo::Config for Runtime {446 type Event = Event;447 type Call = Call;448}449450parameter_types! {451 pub const MinVestedTransfer: Balance = 10 * UNIQUE;452}453454impl pallet_vesting::Config for Runtime {455 type Event = Event;456 type Currency = Balances;457 type BlockNumberToBalance = ConvertInto;458 type MinVestedTransfer = MinVestedTransfer;459 type WeightInfo = ();460}461462parameter_types! {463 pub const ReservedDmpWeight: Weight = MAXIMUM_BLOCK_WEIGHT / 4;464 pub const ReservedXcmpWeight: Weight = MAXIMUM_BLOCK_WEIGHT / 4;465}466467impl cumulus_pallet_parachain_system::Config for Runtime {468 type Event = Event;469 type OnValidationData = ();470 type SelfParaId = parachain_info::Pallet<Runtime>;471 472 473 474 475 476 type OutboundXcmpMessageSource = XcmpQueue;477 type DmpMessageHandler = DmpQueue;478 type ReservedDmpWeight = ReservedDmpWeight;479 type ReservedXcmpWeight = ReservedXcmpWeight;480 type XcmpMessageHandler = XcmpQueue;481}482483impl parachain_info::Config for Runtime {}484485impl cumulus_pallet_aura_ext::Config for Runtime {}486487parameter_types! {488 pub const RelayLocation: MultiLocation = X1(Parent);489 pub const RelayNetwork: NetworkId = NetworkId::Polkadot;490 pub RelayOrigin: Origin = cumulus_pallet_xcm::Origin::Relay.into();491 pub Ancestry: MultiLocation = X1(Parachain(ParachainInfo::parachain_id().into()));492}493494495496497pub type LocationToAccountId = (498 499 ParentIsDefault<AccountId>,500 501 SiblingParachainConvertsVia<Sibling, AccountId>,502 503 AccountId32Aliases<RelayNetwork, AccountId>,504);505506507pub type LocalAssetTransactor = CurrencyAdapter<508 509 Balances,510 511 IsConcrete<RelayLocation>,512 513 LocationToAccountId,514 515 AccountId,516 517 (),518>;519520521522523pub type XcmOriginToTransactDispatchOrigin = (524 525 526 527 SovereignSignedViaLocation<LocationToAccountId, Origin>,528 529 530 RelayChainAsNative<RelayOrigin, Origin>,531 532 533 SiblingParachainAsNative<cumulus_pallet_xcm::Origin, Origin>,534 535 536 ParentAsSuperuser<Origin>,537 538 539 SignedAccountId32AsNative<RelayNetwork, Origin>,540 541 XcmPassthrough<Origin>,542);543544parameter_types! {545 546 pub UnitWeightCost: Weight = 1_000_000;547 548 pub const WeightPrice: (MultiLocation, u128) = (X1(Parent), 1_200 * UNIQUE);549}550551match_type! {552 pub type ParentOrParentsUnitPlurality: impl Contains<MultiLocation> = {553 X1(Parent) | X2(Parent, Plurality { id: BodyId::Unit, .. })554 };555}556557pub type Barrier = (558 TakeWeightCredit,559 AllowTopLevelPaidExecutionFrom<All<MultiLocation>>,560 AllowUnpaidExecutionFrom<ParentOrParentsUnitPlurality>,561 562);563564pub struct XcmConfig;565impl Config for XcmConfig {566 type Call = Call;567 type XcmSender = XcmRouter;568 569 type AssetTransactor = LocalAssetTransactor;570 type OriginConverter = XcmOriginToTransactDispatchOrigin;571 type IsReserve = NativeAsset;572 type IsTeleporter = NativeAsset; 573 type LocationInverter = LocationInverter<Ancestry>;574 type Barrier = Barrier;575 type Weigher = FixedWeightBounds<UnitWeightCost, Call>;576 type Trader = UsingComponents<IdentityFee<Balance>, RelayLocation, AccountId, Balances, ()>;577 type ResponseHandler = (); 578}579580581582583584585pub type LocalOriginToLocation = (SignedToAccountId32<Origin, AccountId, RelayNetwork>,);586587588589pub type XcmRouter = (590 591 cumulus_primitives_utility::ParentAsUmp<ParachainSystem>,592 593 XcmpQueue,594);595596impl pallet_xcm::Config for Runtime {597 type Event = Event;598 type SendXcmOrigin = EnsureXcmOrigin<Origin, LocalOriginToLocation>;599 type XcmRouter = XcmRouter;600 type ExecuteXcmOrigin = EnsureXcmOrigin<Origin, LocalOriginToLocation>;601 type XcmExecuteFilter = All<(MultiLocation, Xcm<Call>)>;602 type XcmExecutor = XcmExecutor<XcmConfig>;603 type XcmTeleportFilter = All<(MultiLocation, Vec<MultiAsset>)>;604 type XcmReserveTransferFilter = ();605 type Weigher = FixedWeightBounds<UnitWeightCost, Call>;606}607608impl cumulus_pallet_xcm::Config for Runtime {609 type Event = Event;610 type XcmExecutor = XcmExecutor<XcmConfig>;611}612613impl cumulus_pallet_xcmp_queue::Config for Runtime {614 type Event = Event;615 type XcmExecutor = XcmExecutor<XcmConfig>;616 type ChannelInfo = ParachainSystem;617}618619impl cumulus_pallet_dmp_queue::Config for Runtime {620 type Event = Event;621 type XcmExecutor = XcmExecutor<XcmConfig>;622 type ExecuteOverweightOrigin = frame_system::EnsureRoot<AccountId>;623}624625impl pallet_aura::Config for Runtime {626 type AuthorityId = AuraId;627}628629parameter_types! {630 pub TreasuryAccountId: AccountId = TreasuryModuleId::get().into_account();631 pub const CollectionCreationPrice: Balance = 100 * UNIQUE;632}633634635impl pallet_nft::Config for Runtime {636 type Event = Event;637 type WeightInfo = nft_weights::WeightInfo;638 type Currency = Balances;639 type CollectionCreationPrice = CollectionCreationPrice;640 type TreasuryAccountId = TreasuryAccountId;641}642643644extern crate pallet_inflation;645pub use pallet_inflation::*;646647parameter_types! {648 pub const InflationBlockInterval: BlockNumber = 100; 649}650651652impl pallet_inflation::Config for Runtime {653 type Currency = Balances;654 type TreasuryAccountId = TreasuryAccountId;655 type InflationBlockInterval = InflationBlockInterval;656}657658construct_runtime!(659 pub enum Runtime where660 Block = Block,661 NodeBlock = opaque::Block,662 UncheckedExtrinsic = UncheckedExtrinsic663 {664 Balances: pallet_balances::{Pallet, Call, Storage, Config<T>, Event<T>} = 30,665 Contracts: pallet_contracts::{Pallet, Call, Storage, Event<T>},666 RandomnessCollectiveFlip: pallet_randomness_collective_flip::{Pallet, Call, Storage},667 Timestamp: pallet_timestamp::{Pallet, Call, Storage, Inherent},668 TransactionPayment: pallet_transaction_payment::{Pallet, Storage},669 Treasury: pallet_treasury::{Pallet, Call, Storage, Config, Event<T>},670 Sudo: pallet_sudo::{Pallet, Call, Storage, Config<T>, Event<T>},671 System: system::{Pallet, Call, Storage, Config, Event<T>},672 Vesting: pallet_vesting::{Pallet, Call, Config<T>, Storage, Event<T>},673674 ParachainSystem: cumulus_pallet_parachain_system::{Pallet, Call, Storage, Inherent, Event<T>, ValidateUnsigned} = 20,675 ParachainInfo: parachain_info::{Pallet, Storage, Config} = 21,676677 Aura: pallet_aura::{Pallet, Config<T>},678 AuraExt: cumulus_pallet_aura_ext::{Pallet, Config},679680 681 XcmpQueue: cumulus_pallet_xcmp_queue::{Pallet, Call, Storage, Event<T>} = 50,682 PolkadotXcm: pallet_xcm::{Pallet, Call, Event<T>, Origin} = 51,683 CumulusXcm: cumulus_pallet_xcm::{Pallet, Call, Event<T>, Origin} = 52,684 DmpQueue: cumulus_pallet_dmp_queue::{Pallet, Call, Storage, Event<T>} = 53,685686687 688 Inflation: pallet_inflation::{Pallet, Call, Storage},689 Nft: pallet_nft::{Pallet, Call, Config<T>, Storage, Event<T>},690 }691);692693694pub type Address = sp_runtime::MultiAddress<AccountId, ()>;695696pub type Header = generic::Header<BlockNumber, BlakeTwo256>;697698pub type Block = generic::Block<Header, UncheckedExtrinsic>;699700pub type SignedBlock = generic::SignedBlock<Block>;701702pub type BlockId = generic::BlockId<Block>;703704pub type SignedExtra = (705 system::CheckSpecVersion<Runtime>,706 707 system::CheckGenesis<Runtime>,708 system::CheckEra<Runtime>,709 system::CheckNonce<Runtime>,710 system::CheckWeight<Runtime>,711 pallet_nft::ChargeTransactionPayment<Runtime>,712);713714pub type UncheckedExtrinsic = generic::UncheckedExtrinsic<Address, Call, Signature, SignedExtra>;715716pub type CheckedExtrinsic = generic::CheckedExtrinsic<AccountId, Call, SignedExtra>;717718pub type Executive = frame_executive::Executive<719 Runtime,720 Block,721 frame_system::ChainContext<Runtime>,722 Runtime,723 AllPallets,724>;725726impl_opaque_keys! {727 pub struct SessionKeys {728 pub aura: Aura,729 }730}731732impl_runtime_apis! {733 impl sp_api::Core<Block> for Runtime {734 fn version() -> RuntimeVersion {735 VERSION736 }737738 fn execute_block(block: Block) {739 Executive::execute_block(block)740 }741742 fn initialize_block(header: &<Block as BlockT>::Header) {743 Executive::initialize_block(header)744 }745 }746747 impl sp_api::Metadata<Block> for Runtime {748 fn metadata() -> OpaqueMetadata {749 Runtime::metadata().into()750 }751 }752753 impl sp_block_builder::BlockBuilder<Block> for Runtime {754 fn apply_extrinsic(extrinsic: <Block as BlockT>::Extrinsic) -> ApplyExtrinsicResult {755 Executive::apply_extrinsic(extrinsic)756 }757758 fn finalize_block() -> <Block as BlockT>::Header {759 Executive::finalize_block()760 }761762 fn inherent_extrinsics(data: sp_inherents::InherentData) -> Vec<<Block as BlockT>::Extrinsic> {763 data.create_extrinsics()764 }765766 fn check_inherents(767 block: Block,768 data: sp_inherents::InherentData,769 ) -> sp_inherents::CheckInherentsResult {770 data.check_extrinsics(&block)771 }772773 774 775 776 }777778 impl sp_transaction_pool::runtime_api::TaggedTransactionQueue<Block> for Runtime {779 fn validate_transaction(780 source: TransactionSource,781 tx: <Block as BlockT>::Extrinsic,782 ) -> TransactionValidity {783 Executive::validate_transaction(source, tx)784 }785 }786787 impl sp_offchain::OffchainWorkerApi<Block> for Runtime {788 fn offchain_worker(header: &<Block as BlockT>::Header) {789 Executive::offchain_worker(header)790 }791 }792793 impl sp_session::SessionKeys<Block> for Runtime {794 fn decode_session_keys(795 encoded: Vec<u8>,796 ) -> Option<Vec<(Vec<u8>, KeyTypeId)>> {797 SessionKeys::decode_into_raw_public_keys(&encoded)798 }799800 fn generate_session_keys(seed: Option<Vec<u8>>) -> Vec<u8> {801 SessionKeys::generate(seed)802 }803 }804805 impl sp_consensus_aura::AuraApi<Block, AuraId> for Runtime {806 fn slot_duration() -> sp_consensus_aura::SlotDuration {807 sp_consensus_aura::SlotDuration::from_millis(Aura::slot_duration())808 }809810 fn authorities() -> Vec<AuraId> {811 Aura::authorities()812 }813 }814815 impl cumulus_primitives_core::CollectCollationInfo<Block> for Runtime {816 fn collect_collation_info() -> cumulus_primitives_core::CollationInfo {817 ParachainSystem::collect_collation_info()818 }819 }820821 impl frame_system_rpc_runtime_api::AccountNonceApi<Block, AccountId, Index> for Runtime {822 fn account_nonce(account: AccountId) -> Index {823 System::account_nonce(account)824 }825 }826827 impl pallet_transaction_payment_rpc_runtime_api::TransactionPaymentApi<Block, Balance> for Runtime {828 fn query_info(uxt: <Block as BlockT>::Extrinsic, len: u32) -> RuntimeDispatchInfo<Balance> {829 TransactionPayment::query_info(uxt, len)830 }831 fn query_fee_details(uxt: <Block as BlockT>::Extrinsic, len: u32) -> FeeDetails<Balance> {832 TransactionPayment::query_fee_details(uxt, len)833 }834 }835836 impl pallet_contracts_rpc_runtime_api::ContractsApi<Block, AccountId, Balance, BlockNumber, Hash>837 for Runtime838 {839 fn call(840 origin: AccountId,841 dest: AccountId,842 value: Balance,843 gas_limit: u64,844 input_data: Vec<u8>,845 ) -> pallet_contracts_primitives::ContractExecResult {846 Contracts::bare_call(origin, dest, value, gas_limit, input_data, false)847 }848849 fn instantiate(850 origin: AccountId,851 endowment: Balance,852 gas_limit: u64,853 code: pallet_contracts_primitives::Code<Hash>,854 data: Vec<u8>,855 salt: Vec<u8>,856 ) -> pallet_contracts_primitives::ContractInstantiateResult<AccountId, BlockNumber>857 {858 Contracts::bare_instantiate(origin, endowment, gas_limit, code, data, salt, true, false)859 }860861 fn get_storage(862 address: AccountId,863 key: [u8; 32],864 ) -> pallet_contracts_primitives::GetStorageResult {865 Contracts::get_storage(address, key)866 }867868 fn rent_projection(869 address: AccountId,870 ) -> pallet_contracts_primitives::RentProjectionResult<BlockNumber> {871 Contracts::rent_projection(address)872 }873 }874875 #[cfg(feature = "runtime-benchmarks")]876 impl frame_benchmarking::Benchmark<Block> for Runtime {877 fn dispatch_benchmark(878 config: frame_benchmarking::BenchmarkConfig879 ) -> Result<Vec<frame_benchmarking::BenchmarkBatch>, sp_runtime::RuntimeString> {880 use frame_benchmarking::{Benchmarking, BenchmarkBatch, add_benchmark, TrackedStorageKey};881882 let whitelist: Vec<TrackedStorageKey> = vec![883 884 hex_literal::hex!("d43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d").to_vec().into(),885 886 887 888 889 890 891 892 893 ];894895 let mut batches = Vec::<BenchmarkBatch>::new();896 let params = (&config, &whitelist);897898 add_benchmark!(params, batches, pallet_nft, Nft);899 add_benchmark!(params, batches, pallet_inflation, Inflation);900901 if batches.is_empty() { return Err("Benchmark not found for this pallet.".into()) }902 Ok(batches)903 }904 }905}