12345678#![cfg_attr(not(feature = "std"), no_std)]910#![recursion_limit = "1024"]111213#[cfg(feature = "std")]14include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs"));1516use sp_api::impl_runtime_apis;17use sp_core::{ crypto::KeyTypeId, OpaqueMetadata };18192021use sp_runtime::{22 Permill, Perbill, Percent,23 create_runtime_str, generic, impl_opaque_keys,24 traits::{25 AccountIdLookup, Convert, ConvertInto, BlakeTwo256, Block as BlockT, IdentifyAccount, 26 IdentityLookup, NumberFor, Verify, AccountIdConversion,27 },28 transaction_validity::{TransactionSource, TransactionValidity},29 ApplyExtrinsicResult, MultiSignature,30};3132use sp_std::prelude::*;3334#[cfg(feature = "std")]35use sp_version::NativeVersion;36use sp_version::RuntimeVersion;37pub use pallet_transaction_payment::{Multiplier, TargetedFeeAdjustment, FeeDetails, RuntimeDispatchInfo};3839pub use pallet_balances::Call as BalancesCall;40pub use frame_support::{41 construct_runtime,42 match_type,43 dispatch::DispatchResult,44 PalletId,45 parameter_types,46 StorageValue,47 traits::{48 All, Currency, ExistenceRequirement, Get, IsInVec, KeyOwnerProofSystem, LockIdentifier, OnUnbalanced, Randomness49 },50 weights::{51 constants::{BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight, WEIGHT_PER_SECOND},52 DispatchClass, DispatchInfo, GetDispatchInfo, IdentityFee, Pays, PostDispatchInfo, Weight,53 WeightToFeePolynomial, WeightToFeeCoefficient, WeightToFeeCoefficients54 },55};56use pallet_nft_transaction_payment::*;57use pallet_nft_charge_transaction::*;58use nft_data_structs::*;59use pallet_contracts::weights::WeightInfo;6061use frame_system::{62 self as system,63 EnsureRoot, EnsureSigned,64 limits::{BlockWeights, BlockLength},65};66use sp_arithmetic::{traits::{BaseArithmetic, Unsigned}};67use smallvec::smallvec;6869use sp_runtime::{70 traits::{ 71 Dispatchable,72 },73};74use pallet_contracts::chain_extension::UncheckedFrom;757677pub use pallet_timestamp::Call as TimestampCall;78pub use sp_consensus_aura::sr25519::AuthorityId as AuraId;798081use pallet_xcm::XcmPassthrough;82use polkadot_parachain::primitives::Sibling;83use xcm::v0::Xcm;84use xcm::v0::{BodyId, Junction::*, MultiAsset, MultiLocation, MultiLocation::*, NetworkId};85use xcm_builder::{86 AccountId32Aliases, AllowTopLevelPaidExecutionFrom, AllowUnpaidExecutionFrom, CurrencyAdapter,87 EnsureXcmOrigin, FixedWeightBounds, IsConcrete, LocationInverter, NativeAsset,88 ParentAsSuperuser, ParentIsDefault, RelayChainAsNative, SiblingParachainAsNative,89 SiblingParachainConvertsVia, SignedAccountId32AsNative, SignedToAccountId32,90 SovereignSignedViaLocation, TakeWeightCredit, UsingComponents,91};92use xcm_executor::{Config, XcmExecutor};939495mod chain_extension;96use crate::chain_extension::{ NFTExtension, Imbalance };979899100extern crate pallet_nft;101pub use pallet_nft::*;102103104extern crate pallet_inflation;105pub use pallet_inflation::*;106107108pub type BlockNumber = u32;109110111pub type Signature = MultiSignature;112113114115pub type AccountId = <<Signature as Verify>::Signer as IdentifyAccount>::AccountId;116117118119pub type AccountIndex = u32;120121122pub type Balance = u128;123124125pub type Index = u32;126127128pub type Hash = sp_core::H256;129130131pub type DigestItem = generic::DigestItem<Hash>;132133mod nft_weights;134135136137138139pub mod opaque {140 use super::*;141142 pub use sp_runtime::OpaqueExtrinsic as UncheckedExtrinsic;143144 145 pub type Block = generic::Block<Header, UncheckedExtrinsic>;146147 pub type SessionHandlers = ();148149 impl_opaque_keys! {150 pub struct SessionKeys {151 pub aura: Aura,152 }153 }154}155156157pub const VERSION: RuntimeVersion = RuntimeVersion {158 spec_name: create_runtime_str!("nft"),159 impl_name: create_runtime_str!("nft"),160 authoring_version: 1,161 spec_version: 3,162 impl_version: 1,163 apis: RUNTIME_API_VERSIONS,164 transaction_version: 1,165};166167pub const MILLISECS_PER_BLOCK: u64 = 12000;168169pub const SLOT_DURATION: u64 = MILLISECS_PER_BLOCK;170171172pub const MINUTES: BlockNumber = 60_000 / (MILLISECS_PER_BLOCK as BlockNumber);173pub const HOURS: BlockNumber = MINUTES * 60;174pub const DAYS: BlockNumber = HOURS * 24;175176#[derive(codec::Encode, codec::Decode)]177pub enum XCMPMessage<XAccountId, XBalance> {178 179 TransferToken(XAccountId, XBalance),180}181182183#[cfg(feature = "std")]184pub fn native_version() -> NativeVersion {185 NativeVersion {186 runtime_version: VERSION,187 can_author_with: Default::default(),188 }189}190191type NegativeImbalance = <Balances as Currency<AccountId>>::NegativeImbalance;192193pub struct DealWithFees;194impl OnUnbalanced<NegativeImbalance> for DealWithFees {195 fn on_unbalanceds<B>(mut fees_then_tips: impl Iterator<Item=NegativeImbalance>) {196 if let Some(fees) = fees_then_tips.next() {197 198 let mut split = fees.ration(100, 0);199 if let Some(tips) = fees_then_tips.next() {200 201 tips.ration_merge_into(100, 0, &mut split);202 }203 Treasury::on_unbalanced(split.0);204 205 }206 }207}208209210211const AVERAGE_ON_INITIALIZE_RATIO: Perbill = Perbill::from_percent(10);212213214const NORMAL_DISPATCH_RATIO: Perbill = Perbill::from_percent(75);215216const MAXIMUM_BLOCK_WEIGHT: Weight = 2 * WEIGHT_PER_SECOND;217218parameter_types! {219 pub const BlockHashCount: BlockNumber = 2400;220 pub RuntimeBlockLength: BlockLength =221 BlockLength::max_with_normal_ratio(5 * 1024 * 1024, NORMAL_DISPATCH_RATIO);222 pub const AvailableBlockRatio: Perbill = Perbill::from_percent(75);223 pub const MaximumBlockLength: u32 = 5 * 1024 * 1024;224 pub RuntimeBlockWeights: BlockWeights = BlockWeights::builder()225 .base_block(BlockExecutionWeight::get())226 .for_class(DispatchClass::all(), |weights| {227 weights.base_extrinsic = ExtrinsicBaseWeight::get();228 })229 .for_class(DispatchClass::Normal, |weights| {230 weights.max_total = Some(NORMAL_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT);231 })232 .for_class(DispatchClass::Operational, |weights| {233 weights.max_total = Some(MAXIMUM_BLOCK_WEIGHT);234 235 236 weights.reserved = Some(237 MAXIMUM_BLOCK_WEIGHT - NORMAL_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT238 );239 })240 .avg_block_initialization(AVERAGE_ON_INITIALIZE_RATIO)241 .build_or_panic();242 pub const Version: RuntimeVersion = VERSION;243 pub const SS58Prefix: u8 = 42;244}245246impl system::Config for Runtime {247 248 type AccountData = pallet_balances::AccountData<Balance>;249 250 type AccountId = AccountId;251 252 type BaseCallFilter = ();253 254 type BlockHashCount = BlockHashCount;255 256 type BlockLength = RuntimeBlockLength;257 258 type BlockNumber = BlockNumber;259 260 type BlockWeights = RuntimeBlockWeights;261 262 type Call = Call;263 264 type DbWeight = RocksDbWeight;265 266 type Event = Event;267 268 type Hash = Hash;269 270 type Hashing = BlakeTwo256;271 272 type Header = generic::Header<BlockNumber, BlakeTwo256>;273 274 type Index = Index;275 276 type Lookup = AccountIdLookup<AccountId, ()>;277 278 type OnKilledAccount = ();279 280 type OnNewAccount = ();281 type OnSetCode = cumulus_pallet_parachain_system::ParachainSetCode<Self>;282 283 type Origin = Origin;284 285 type PalletInfo = PalletInfo;286 287 type SS58Prefix = SS58Prefix;288 289 type SystemWeightInfo = system::weights::SubstrateWeight<Runtime>;290 291 type Version = Version;292}293294parameter_types! {295 pub const MinimumPeriod: u64 = SLOT_DURATION / 2;296}297298impl pallet_timestamp::Config for Runtime {299 300 type Moment = u64;301 type OnTimestampSet = ();302 type MinimumPeriod = MinimumPeriod;303 type WeightInfo = ();304}305306parameter_types! {307 308 pub const ExistentialDeposit: u128 = 0;309 pub const MaxLocks: u32 = 50;310}311312impl pallet_balances::Config for Runtime {313 type MaxLocks = MaxLocks;314 315 type Balance = Balance;316 317 type Event = Event;318 type DustRemoval = Treasury;319 type ExistentialDeposit = ExistentialDeposit;320 type AccountStore = System;321 type WeightInfo = pallet_balances::weights::SubstrateWeight<Runtime>;322}323324pub const MICROUNIQUE: Balance = 1_000_000_000;325pub const MILLIUNIQUE: Balance = 1_000 * MICROUNIQUE;326pub const CENTIUNIQUE: Balance = 10 * MILLIUNIQUE;327pub const UNIQUE: Balance = 100 * CENTIUNIQUE;328329pub const fn deposit(items: u32, bytes: u32) -> Balance {330 items as Balance * 15 * CENTIUNIQUE + (bytes as Balance) * 6 * CENTIUNIQUE331}332333parameter_types! {334 pub TombstoneDeposit: Balance = deposit(335 1,336 sp_std::mem::size_of::<pallet_contracts::Pallet<Runtime>> as u32,337 );338 pub DepositPerContract: Balance = TombstoneDeposit::get();339 pub const DepositPerStorageByte: Balance = deposit(0, 1);340 pub const DepositPerStorageItem: Balance = deposit(1, 0);341 pub RentFraction: Perbill = Perbill::from_rational(1u32, 30 * DAYS);342 pub const SurchargeReward: Balance = 150 * MILLIUNIQUE;343 pub const SignedClaimHandicap: u32 = 2;344 pub const MaxDepth: u32 = 32;345 pub const MaxValueSize: u32 = 16 * 1024;346 pub const MaxCodeSize: u32 = 1024 * 1024 * 25; 347 348 pub DeletionWeightLimit: Weight = AVERAGE_ON_INITIALIZE_RATIO *349 RuntimeBlockWeights::get().max_block;350 351 352 pub DeletionQueueDepth: u32 = ((DeletionWeightLimit::get() / (353 <Runtime as pallet_contracts::Config>::WeightInfo::on_initialize_per_queue_item(1) -354 <Runtime as pallet_contracts::Config>::WeightInfo::on_initialize_per_queue_item(0)355 )) / 5) as u32;356 pub Schedule: pallet_contracts::Schedule<Runtime> = Default::default();357}358359impl pallet_contracts::Config for Runtime {360 type Time = Timestamp;361 type Randomness = RandomnessCollectiveFlip;362 type Currency = Balances;363 type Event = Event;364 type RentPayment = ();365 type SignedClaimHandicap = SignedClaimHandicap;366 type TombstoneDeposit = TombstoneDeposit;367 type DepositPerContract = DepositPerContract;368 type DepositPerStorageByte = DepositPerStorageByte;369 type DepositPerStorageItem = DepositPerStorageItem;370 type RentFraction = RentFraction;371 type SurchargeReward = SurchargeReward;372 373 374 type WeightPrice = pallet_transaction_payment::Module<Self>;375 type WeightInfo = pallet_contracts::weights::SubstrateWeight<Self>;376 type ChainExtension = NFTExtension;377 type DeletionQueueDepth = DeletionQueueDepth;378 type DeletionWeightLimit = DeletionWeightLimit;379 380 type Schedule = Schedule;381 type CallStack = [pallet_contracts::Frame<Self>; 31];382}383384parameter_types! {385 pub const TransactionByteFee: Balance = 501 * MICROUNIQUE; 386}387388389pub struct LinearFee<T>(sp_std::marker::PhantomData<T>);390391impl<T> WeightToFeePolynomial for LinearFee<T> where392 T: BaseArithmetic + From<u32> + Copy + Unsigned393{394 type Balance = T;395396 fn polynomial() -> WeightToFeeCoefficients<Self::Balance> {397 smallvec!(WeightToFeeCoefficient {398 coeff_integer: 146_700u32.into(), 399 coeff_frac: Perbill::zero(),400 negative: false,401 degree: 1,402 })403 }404}405406impl pallet_transaction_payment::Config for Runtime {407 type OnChargeTransaction = pallet_transaction_payment::CurrencyAdapter<Balances, ()>;408 type TransactionByteFee = TransactionByteFee;409 type WeightToFee = LinearFee<Balance>;410 type FeeMultiplierUpdate = ();411}412413parameter_types! {414 pub const ProposalBond: Permill = Permill::from_percent(5);415 pub const ProposalBondMinimum: Balance = 1 * UNIQUE;416 pub const SpendPeriod: BlockNumber = 5 * MINUTES;417 pub const Burn: Permill = Permill::from_percent(0);418 pub const TipCountdown: BlockNumber = 1 * DAYS;419 pub const TipFindersFee: Percent = Percent::from_percent(20);420 pub const TipReportDepositBase: Balance = 1 * UNIQUE;421 pub const DataDepositPerByte: Balance = 1 * CENTIUNIQUE;422 pub const BountyDepositBase: Balance = 1 * UNIQUE;423 pub const BountyDepositPayoutDelay: BlockNumber = 1 * DAYS;424 pub const TreasuryModuleId: PalletId = PalletId(*b"py/trsry");425 pub const BountyUpdatePeriod: BlockNumber = 14 * DAYS;426 pub const MaximumReasonLength: u32 = 16384;427 pub const BountyCuratorDeposit: Permill = Permill::from_percent(50);428 pub const BountyValueMinimum: Balance = 5 * UNIQUE;429 pub const MaxApprovals: u32 = 100;430}431432impl pallet_treasury::Config for Runtime {433 type PalletId = TreasuryModuleId;434 type Currency = Balances;435 type ApproveOrigin = EnsureRoot<AccountId>;436 type RejectOrigin = EnsureRoot<AccountId>;437 type Event = Event;438 type OnSlash = ();439 type ProposalBond = ProposalBond;440 type ProposalBondMinimum = ProposalBondMinimum;441 type SpendPeriod = SpendPeriod;442 type Burn = Burn;443 type BurnDestination = ();444 type SpendFunds = ();445 type WeightInfo = pallet_treasury::weights::SubstrateWeight<Runtime>;446 type MaxApprovals = MaxApprovals;447}448449impl pallet_sudo::Config for Runtime {450 type Event = Event;451 type Call = Call;452}453454parameter_types! {455 pub const MinVestedTransfer: Balance = 10 * UNIQUE;456}457458impl pallet_vesting::Config for Runtime {459 type Event = Event;460 type Currency = Balances;461 type BlockNumberToBalance = ConvertInto;462 type MinVestedTransfer = MinVestedTransfer;463 type WeightInfo = ();464}465466parameter_types! {467 pub const ReservedDmpWeight: Weight = MAXIMUM_BLOCK_WEIGHT / 4;468 pub const ReservedXcmpWeight: Weight = MAXIMUM_BLOCK_WEIGHT / 4;469}470471impl cumulus_pallet_parachain_system::Config for Runtime {472 type Event = Event;473 type OnValidationData = ();474 type SelfParaId = parachain_info::Pallet<Runtime>;475 476 477 478 479 480 type OutboundXcmpMessageSource = XcmpQueue;481 type DmpMessageHandler = DmpQueue;482 type ReservedDmpWeight = ReservedDmpWeight;483 type ReservedXcmpWeight = ReservedXcmpWeight;484 type XcmpMessageHandler = XcmpQueue;485}486487impl parachain_info::Config for Runtime {}488489impl cumulus_pallet_aura_ext::Config for Runtime {}490491parameter_types! {492 pub const RelayLocation: MultiLocation = X1(Parent);493 pub const RelayNetwork: NetworkId = NetworkId::Polkadot;494 pub RelayOrigin: Origin = cumulus_pallet_xcm::Origin::Relay.into();495 pub Ancestry: MultiLocation = X1(Parachain(ParachainInfo::parachain_id().into()));496}497498499500501pub type LocationToAccountId = (502 503 ParentIsDefault<AccountId>,504 505 SiblingParachainConvertsVia<Sibling, AccountId>,506 507 AccountId32Aliases<RelayNetwork, AccountId>,508);509510511pub type LocalAssetTransactor = CurrencyAdapter<512 513 Balances,514 515 IsConcrete<RelayLocation>,516 517 LocationToAccountId,518 519 AccountId,520 521 (),522>;523524525526527pub type XcmOriginToTransactDispatchOrigin = (528 529 530 531 SovereignSignedViaLocation<LocationToAccountId, Origin>,532 533 534 RelayChainAsNative<RelayOrigin, Origin>,535 536 537 SiblingParachainAsNative<cumulus_pallet_xcm::Origin, Origin>,538 539 540 ParentAsSuperuser<Origin>,541 542 543 SignedAccountId32AsNative<RelayNetwork, Origin>,544 545 XcmPassthrough<Origin>,546);547548parameter_types! {549 550 pub UnitWeightCost: Weight = 1_000_000;551 552 pub const WeightPrice: (MultiLocation, u128) = (X1(Parent), 1_200 * UNIQUE);553}554555match_type! {556 pub type ParentOrParentsUnitPlurality: impl Contains<MultiLocation> = {557 X1(Parent) | X2(Parent, Plurality { id: BodyId::Unit, .. })558 };559}560561pub type Barrier = (562 TakeWeightCredit,563 AllowTopLevelPaidExecutionFrom<All<MultiLocation>>,564 AllowUnpaidExecutionFrom<ParentOrParentsUnitPlurality>,565 566);567568pub struct XcmConfig;569impl Config for XcmConfig {570 type Call = Call;571 type XcmSender = XcmRouter;572 573 type AssetTransactor = LocalAssetTransactor;574 type OriginConverter = XcmOriginToTransactDispatchOrigin;575 type IsReserve = NativeAsset;576 type IsTeleporter = NativeAsset; 577 type LocationInverter = LocationInverter<Ancestry>;578 type Barrier = Barrier;579 type Weigher = FixedWeightBounds<UnitWeightCost, Call>;580 type Trader = UsingComponents<IdentityFee<Balance>, RelayLocation, AccountId, Balances, ()>;581 type ResponseHandler = (); 582}583584585586587588589pub type LocalOriginToLocation = (SignedToAccountId32<Origin, AccountId, RelayNetwork>,);590591592593pub type XcmRouter = (594 595 cumulus_primitives_utility::ParentAsUmp<ParachainSystem>,596 597 XcmpQueue,598);599600impl pallet_xcm::Config for Runtime {601 type Event = Event;602 type SendXcmOrigin = EnsureXcmOrigin<Origin, LocalOriginToLocation>;603 type XcmRouter = XcmRouter;604 type ExecuteXcmOrigin = EnsureXcmOrigin<Origin, LocalOriginToLocation>;605 type XcmExecuteFilter = All<(MultiLocation, Xcm<Call>)>;606 type XcmExecutor = XcmExecutor<XcmConfig>;607 type XcmTeleportFilter = All<(MultiLocation, Vec<MultiAsset>)>;608 type XcmReserveTransferFilter = ();609 type Weigher = FixedWeightBounds<UnitWeightCost, Call>;610}611612impl cumulus_pallet_xcm::Config for Runtime {613 type Event = Event;614 type XcmExecutor = XcmExecutor<XcmConfig>;615}616617impl cumulus_pallet_xcmp_queue::Config for Runtime {618 type Event = Event;619 type XcmExecutor = XcmExecutor<XcmConfig>;620 type ChannelInfo = ParachainSystem;621}622623impl cumulus_pallet_dmp_queue::Config for Runtime {624 type Event = Event;625 type XcmExecutor = XcmExecutor<XcmConfig>;626 type ExecuteOverweightOrigin = frame_system::EnsureRoot<AccountId>;627}628629impl pallet_aura::Config for Runtime {630 type AuthorityId = AuraId;631}632633parameter_types! {634 pub TreasuryAccountId: AccountId = TreasuryModuleId::get().into_account();635 pub const CollectionCreationPrice: Balance = 100 * UNIQUE;636}637638639impl pallet_nft::Config for Runtime {640 type Event = Event;641 type WeightInfo = nft_weights::WeightInfo;642 type Currency = Balances;643 type CollectionCreationPrice = CollectionCreationPrice;644 type TreasuryAccountId = TreasuryAccountId;645}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}657658parameter_types! {659 pub MaximumSchedulerWeight: Weight = Perbill::from_percent(50) *660 RuntimeBlockWeights::get().max_block;661 pub const MaxScheduledPerBlock: u32 = 50;662}663664pub struct Sponsoring;665impl SponsoringResolve<AccountId, Call> for Sponsoring {666667 fn resolve(who: &AccountId, call: &Call) -> Option<AccountId> 668 where 669 Call: Dispatchable<Info=DispatchInfo>,670 Call: IsSubType<pallet_nft::Call<Runtime>>, 671 Call: IsSubType<pallet_contracts::Call<Runtime>>,672 AccountId: AsRef<[u8]>,673 AccountId: UncheckedFrom<Hash>674 {675 pallet_nft_transaction_payment::Module::<Runtime>::withdraw_type(who, call)676 }677}678679impl pallet_scheduler::Config for Runtime {680 type Event = Event;681 type Origin = Origin;682 type PalletsOrigin = OriginCaller;683 type Call = Call;684 type MaximumWeight = MaximumSchedulerWeight;685 type ScheduleOrigin = EnsureSigned<AccountId>;686 type MaxScheduledPerBlock = MaxScheduledPerBlock;687 type Sponsoring = Sponsoring;688 type WeightInfo = ();689}690691impl pallet_nft_transaction_payment::Config for Runtime {692}693694impl pallet_nft_charge_transaction::Config for Runtime {695}696697construct_runtime!(698 pub enum Runtime where699 Block = Block,700 NodeBlock = opaque::Block,701 UncheckedExtrinsic = UncheckedExtrinsic702 {703 Balances: pallet_balances::{Pallet, Call, Storage, Config<T>, Event<T>} = 30,704 Contracts: pallet_contracts::{Pallet, Call, Storage, Event<T>},705 RandomnessCollectiveFlip: pallet_randomness_collective_flip::{Pallet, Call, Storage},706 Timestamp: pallet_timestamp::{Pallet, Call, Storage, Inherent},707 TransactionPayment: pallet_transaction_payment::{Pallet, Storage},708 Treasury: pallet_treasury::{Pallet, Call, Storage, Config, Event<T>},709 Sudo: pallet_sudo::{Pallet, Call, Storage, Config<T>, Event<T>},710 System: system::{Pallet, Call, Storage, Config, Event<T>},711 Vesting: pallet_vesting::{Pallet, Call, Config<T>, Storage, Event<T>},712713 ParachainSystem: cumulus_pallet_parachain_system::{Pallet, Call, Storage, Inherent, Event<T>, ValidateUnsigned} = 20,714 ParachainInfo: parachain_info::{Pallet, Storage, Config} = 21,715716 Aura: pallet_aura::{Pallet, Config<T>},717 AuraExt: cumulus_pallet_aura_ext::{Pallet, Config},718719 720 XcmpQueue: cumulus_pallet_xcmp_queue::{Pallet, Call, Storage, Event<T>} = 50,721 PolkadotXcm: pallet_xcm::{Pallet, Call, Event<T>, Origin} = 51,722 CumulusXcm: cumulus_pallet_xcm::{Pallet, Call, Event<T>, Origin} = 52,723 DmpQueue: cumulus_pallet_dmp_queue::{Pallet, Call, Storage, Event<T>} = 53,724725726 727 Inflation: pallet_inflation::{Pallet, Call, Storage},728 Nft: pallet_nft::{Pallet, Call, Config<T>, Storage, Event<T>},729 Scheduler: pallet_scheduler::{Pallet, Call, Storage, Event<T>},730 NftPayment: pallet_nft_transaction_payment::{Pallet, Call, Storage},731 Charging: pallet_nft_charge_transaction::{Pallet, Call, Storage },732 }733);734735736pub type Address = sp_runtime::MultiAddress<AccountId, ()>;737738pub type Header = generic::Header<BlockNumber, BlakeTwo256>;739740pub type Block = generic::Block<Header, UncheckedExtrinsic>;741742pub type SignedBlock = generic::SignedBlock<Block>;743744pub type BlockId = generic::BlockId<Block>;745746pub type SignedExtra = (747 system::CheckSpecVersion<Runtime>,748 749 system::CheckGenesis<Runtime>,750 system::CheckEra<Runtime>,751 system::CheckNonce<Runtime>,752 system::CheckWeight<Runtime>,753 pallet_nft_charge_transaction::ChargeTransactionPayment<Runtime>,754);755756pub type UncheckedExtrinsic = generic::UncheckedExtrinsic<Address, Call, Signature, SignedExtra>;757758pub type CheckedExtrinsic = generic::CheckedExtrinsic<AccountId, Call, SignedExtra>;759760pub type Executive = frame_executive::Executive<761 Runtime,762 Block,763 frame_system::ChainContext<Runtime>,764 Runtime,765 AllPallets,766>;767768impl_opaque_keys! {769 pub struct SessionKeys {770 pub aura: Aura,771 }772}773774impl_runtime_apis! {775 impl sp_api::Core<Block> for Runtime {776 fn version() -> RuntimeVersion {777 VERSION778 }779780 fn execute_block(block: Block) {781 Executive::execute_block(block)782 }783784 fn initialize_block(header: &<Block as BlockT>::Header) {785 Executive::initialize_block(header)786 }787 }788789 impl sp_api::Metadata<Block> for Runtime {790 fn metadata() -> OpaqueMetadata {791 Runtime::metadata().into()792 }793 }794795 impl sp_block_builder::BlockBuilder<Block> for Runtime {796 fn apply_extrinsic(extrinsic: <Block as BlockT>::Extrinsic) -> ApplyExtrinsicResult {797 Executive::apply_extrinsic(extrinsic)798 }799800 fn finalize_block() -> <Block as BlockT>::Header {801 Executive::finalize_block()802 }803804 fn inherent_extrinsics(data: sp_inherents::InherentData) -> Vec<<Block as BlockT>::Extrinsic> {805 data.create_extrinsics()806 }807808 fn check_inherents(809 block: Block,810 data: sp_inherents::InherentData,811 ) -> sp_inherents::CheckInherentsResult {812 data.check_extrinsics(&block)813 }814815 816 817 818 }819820 impl sp_transaction_pool::runtime_api::TaggedTransactionQueue<Block> for Runtime {821 fn validate_transaction(822 source: TransactionSource,823 tx: <Block as BlockT>::Extrinsic,824 ) -> TransactionValidity {825 Executive::validate_transaction(source, tx)826 }827 }828829 impl sp_offchain::OffchainWorkerApi<Block> for Runtime {830 fn offchain_worker(header: &<Block as BlockT>::Header) {831 Executive::offchain_worker(header)832 }833 }834835 impl sp_session::SessionKeys<Block> for Runtime {836 fn decode_session_keys(837 encoded: Vec<u8>,838 ) -> Option<Vec<(Vec<u8>, KeyTypeId)>> {839 SessionKeys::decode_into_raw_public_keys(&encoded)840 }841842 fn generate_session_keys(seed: Option<Vec<u8>>) -> Vec<u8> {843 SessionKeys::generate(seed)844 }845 }846847 impl sp_consensus_aura::AuraApi<Block, AuraId> for Runtime {848 fn slot_duration() -> sp_consensus_aura::SlotDuration {849 sp_consensus_aura::SlotDuration::from_millis(Aura::slot_duration())850 }851852 fn authorities() -> Vec<AuraId> {853 Aura::authorities()854 }855 }856857 impl cumulus_primitives_core::CollectCollationInfo<Block> for Runtime {858 fn collect_collation_info() -> cumulus_primitives_core::CollationInfo {859 ParachainSystem::collect_collation_info()860 }861 }862863 impl frame_system_rpc_runtime_api::AccountNonceApi<Block, AccountId, Index> for Runtime {864 fn account_nonce(account: AccountId) -> Index {865 System::account_nonce(account)866 }867 }868869 impl pallet_transaction_payment_rpc_runtime_api::TransactionPaymentApi<Block, Balance> for Runtime {870 fn query_info(uxt: <Block as BlockT>::Extrinsic, len: u32) -> RuntimeDispatchInfo<Balance> {871 TransactionPayment::query_info(uxt, len)872 }873 fn query_fee_details(uxt: <Block as BlockT>::Extrinsic, len: u32) -> FeeDetails<Balance> {874 TransactionPayment::query_fee_details(uxt, len)875 }876 }877878 impl pallet_contracts_rpc_runtime_api::ContractsApi<Block, AccountId, Balance, BlockNumber, Hash>879 for Runtime880 {881 fn call(882 origin: AccountId,883 dest: AccountId,884 value: Balance,885 gas_limit: u64,886 input_data: Vec<u8>,887 ) -> pallet_contracts_primitives::ContractExecResult {888 Contracts::bare_call(origin, dest, value, gas_limit, input_data, false)889 }890891 fn instantiate(892 origin: AccountId,893 endowment: Balance,894 gas_limit: u64,895 code: pallet_contracts_primitives::Code<Hash>,896 data: Vec<u8>,897 salt: Vec<u8>,898 ) -> pallet_contracts_primitives::ContractInstantiateResult<AccountId, BlockNumber>899 {900 Contracts::bare_instantiate(origin, endowment, gas_limit, code, data, salt, true, false)901 }902903 fn get_storage(904 address: AccountId,905 key: [u8; 32],906 ) -> pallet_contracts_primitives::GetStorageResult {907 Contracts::get_storage(address, key)908 }909910 fn rent_projection(911 address: AccountId,912 ) -> pallet_contracts_primitives::RentProjectionResult<BlockNumber> {913 Contracts::rent_projection(address)914 }915 }916917 #[cfg(feature = "runtime-benchmarks")]918 impl frame_benchmarking::Benchmark<Block> for Runtime {919 fn dispatch_benchmark(920 config: frame_benchmarking::BenchmarkConfig921 ) -> Result<Vec<frame_benchmarking::BenchmarkBatch>, sp_runtime::RuntimeString> {922 use frame_benchmarking::{Benchmarking, BenchmarkBatch, add_benchmark, TrackedStorageKey};923924 let whitelist: Vec<TrackedStorageKey> = vec![925 926 hex_literal::hex!("d43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d").to_vec().into(),927 928 929 930 931 932 933 934 935 ];936937 let mut batches = Vec::<BenchmarkBatch>::new();938 let params = (&config, &whitelist);939940 add_benchmark!(params, batches, pallet_nft, Nft);941 add_benchmark!(params, batches, pallet_inflation, Inflation);942943 if batches.is_empty() { return Err("Benchmark not found for this pallet.".into()) }944 Ok(batches)945 }946 }947}948949cumulus_pallet_parachain_system::register_validate_block!(950 Runtime,951 cumulus_pallet_aura_ext::BlockExecutor::<Runtime, Executive>,952);