12345678#![cfg_attr(not(feature = "std"), no_std)]910#![recursion_limit = "1024"]11#![allow(clippy::from_over_into, clippy::identity_op)]12#![allow(clippy::fn_to_numeric_cast_with_truncation)]1314#[cfg(feature = "std")]15include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs"));1617use sp_api::impl_runtime_apis;18use sp_core::{crypto::KeyTypeId, OpaqueMetadata, H256, U256, H160};19202122use sp_runtime::{23 Permill, Perbill, Percent, create_runtime_str, generic, impl_opaque_keys,24 traits::{25 AccountIdLookup, ConvertInto, BlakeTwo256, Block as BlockT, IdentifyAccount, Verify,26 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::{38 Multiplier, TargetedFeeAdjustment, FeeDetails, RuntimeDispatchInfo,39};4041pub use pallet_balances::Call as BalancesCall;42pub use pallet_evm::{EnsureAddressTruncated, HashedAddressMapping, Runner};43pub use frame_support::{44 construct_runtime, match_type,45 dispatch::DispatchResult,46 PalletId, parameter_types, StorageValue, ConsensusEngineId,47 traits::{48 Everything, Currency, ExistenceRequirement, Get, IsInVec, KeyOwnerProofSystem,49 LockIdentifier, OnUnbalanced, Randomness, FindAuthor,50 },51 weights::{52 constants::{BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight, WEIGHT_PER_SECOND},53 DispatchClass, DispatchInfo, GetDispatchInfo, IdentityFee, Pays, PostDispatchInfo, Weight,54 WeightToFeePolynomial, WeightToFeeCoefficient, WeightToFeeCoefficients,55 },56};57use nft_data_structs::*;585960use frame_system::{61 self as system, EnsureRoot, EnsureSigned,62 limits::{BlockWeights, BlockLength},63};64use sp_arithmetic::{65 traits::{BaseArithmetic, Unsigned},66};67use smallvec::smallvec;68use codec::{Encode, Decode};69use pallet_evm::{Account as EVMAccount, FeeCalculator, OnMethodCall};70use fp_rpc::TransactionStatus;71use sp_core::crypto::Public;72use sp_runtime::{73 traits::{Dispatchable},74};757677pub use sp_consensus_aura::sr25519::AuthorityId as AuraId;787980use pallet_xcm::XcmPassthrough;81use polkadot_parachain::primitives::Sibling;82use xcm::v0::{BodyId, Junction::*, MultiLocation, MultiLocation::*, NetworkId};83use xcm_builder::{84 AccountId32Aliases, AllowTopLevelPaidExecutionFrom, AllowUnpaidExecutionFrom, CurrencyAdapter,85 EnsureXcmOrigin, FixedWeightBounds, IsConcrete, LocationInverter, NativeAsset,86 ParentAsSuperuser, ParentIsDefault, RelayChainAsNative, SiblingParachainAsNative,87 SiblingParachainConvertsVia, SignedAccountId32AsNative, SignedToAccountId32,88 SovereignSignedViaLocation, TakeWeightCredit, UsingComponents,89};90use xcm_executor::{Config, XcmExecutor};919293949596pub type BlockNumber = u32;979899pub type Signature = MultiSignature;100101102103pub type AccountId = <<Signature as Verify>::Signer as IdentifyAccount>::AccountId;104105106107pub type AccountIndex = u32;108109110pub type Balance = u128;111112113pub type Index = u32;114115116pub type Hash = sp_core::H256;117118119pub type DigestItem = generic::DigestItem<Hash>;120121122123124125pub mod opaque {126 use super::*;127128 pub use sp_runtime::OpaqueExtrinsic as UncheckedExtrinsic;129130 131 pub type Block = generic::Block<Header, UncheckedExtrinsic>;132133 pub type SessionHandlers = ();134135 impl_opaque_keys! {136 pub struct SessionKeys {137 pub aura: Aura,138 }139 }140}141142143pub const VERSION: RuntimeVersion = RuntimeVersion {144 spec_name: create_runtime_str!("nft"),145 impl_name: create_runtime_str!("nft"),146 authoring_version: 1,147 spec_version: 3,148 impl_version: 1,149 apis: RUNTIME_API_VERSIONS,150 transaction_version: 1,151};152153pub const MILLISECS_PER_BLOCK: u64 = 12000;154155pub const SLOT_DURATION: u64 = MILLISECS_PER_BLOCK;156157158pub const MINUTES: BlockNumber = 60_000 / (MILLISECS_PER_BLOCK as BlockNumber);159pub const HOURS: BlockNumber = MINUTES * 60;160pub const DAYS: BlockNumber = HOURS * 24;161162parameter_types! {163 pub const DefaultSponsoringRateLimit: BlockNumber = 1 * DAYS;164}165166#[derive(codec::Encode, codec::Decode)]167pub enum XCMPMessage<XAccountId, XBalance> {168 169 TransferToken(XAccountId, XBalance),170}171172173#[cfg(feature = "std")]174pub fn native_version() -> NativeVersion {175 NativeVersion {176 runtime_version: VERSION,177 can_author_with: Default::default(),178 }179}180181type NegativeImbalance = <Balances as Currency<AccountId>>::NegativeImbalance;182183pub struct DealWithFees;184impl OnUnbalanced<NegativeImbalance> for DealWithFees {185 fn on_unbalanceds<B>(mut fees_then_tips: impl Iterator<Item = NegativeImbalance>) {186 if let Some(fees) = fees_then_tips.next() {187 188 let mut split = fees.ration(100, 0);189 if let Some(tips) = fees_then_tips.next() {190 191 tips.ration_merge_into(100, 0, &mut split);192 }193 Treasury::on_unbalanced(split.0);194 195 }196 }197}198199200201const AVERAGE_ON_INITIALIZE_RATIO: Perbill = Perbill::from_percent(10);202203204const NORMAL_DISPATCH_RATIO: Perbill = Perbill::from_percent(75);205206const MAXIMUM_BLOCK_WEIGHT: Weight = WEIGHT_PER_SECOND / 2;207208parameter_types! {209 pub const BlockHashCount: BlockNumber = 2400;210 pub RuntimeBlockLength: BlockLength =211 BlockLength::max_with_normal_ratio(5 * 1024 * 1024, NORMAL_DISPATCH_RATIO);212 pub const AvailableBlockRatio: Perbill = Perbill::from_percent(75);213 pub const MaximumBlockLength: u32 = 5 * 1024 * 1024;214 pub RuntimeBlockWeights: BlockWeights = BlockWeights::builder()215 .base_block(BlockExecutionWeight::get())216 .for_class(DispatchClass::all(), |weights| {217 weights.base_extrinsic = ExtrinsicBaseWeight::get();218 })219 .for_class(DispatchClass::Normal, |weights| {220 weights.max_total = Some(NORMAL_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT);221 })222 .for_class(DispatchClass::Operational, |weights| {223 weights.max_total = Some(MAXIMUM_BLOCK_WEIGHT);224 225 226 weights.reserved = Some(227 MAXIMUM_BLOCK_WEIGHT - NORMAL_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT228 );229 })230 .avg_block_initialization(AVERAGE_ON_INITIALIZE_RATIO)231 .build_or_panic();232 pub const Version: RuntimeVersion = VERSION;233 pub const SS58Prefix: u8 = 42;234}235236parameter_types! {237 pub const ChainId: u64 = 8888;238}239240impl pallet_evm::Config for Runtime {241 type BlockGasLimit = BlockGasLimit;242 type FeeCalculator = ();243 type GasWeightMapping = ();244 type BlockHashMapping = pallet_ethereum::EthereumBlockHashMapping<Self>;245 type CallOrigin = EnsureAddressTruncated;246 type WithdrawOrigin = EnsureAddressTruncated;247 type AddressMapping = HashedAddressMapping<Self::Hashing>;248 type Precompiles = ();249 type Currency = Balances;250 type Event = Event;251 type OnMethodCall = (252 pallet_evm_migration::OnMethodCall<Self>,253 pallet_nft::NftErcSupport<Self>,254 pallet_evm_contract_helpers::HelpersOnMethodCall<Self>,255 );256 type OnCreate = pallet_evm_contract_helpers::HelpersOnCreate<Self>;257 type ChainId = ChainId;258 type Runner = pallet_evm::runner::stack::Runner<Self>;259 type OnChargeTransaction = pallet_evm_transaction_payment::OnChargeTransaction<Self>;260 type TransactionValidityHack = pallet_evm_transaction_payment::TransactionValidityHack<Self>;261 type FindAuthor = EthereumFindAuthor<Aura>;262}263264impl pallet_evm_migration::Config for Runtime {265 type WeightInfo = pallet_evm_migration::weights::SubstrateWeight<Self>;266}267268pub struct EthereumFindAuthor<F>(core::marker::PhantomData<F>);269impl<F: FindAuthor<u32>> FindAuthor<H160> for EthereumFindAuthor<F> {270 fn find_author<'a, I>(digests: I) -> Option<H160>271 where272 I: 'a + IntoIterator<Item = (ConsensusEngineId, &'a [u8])>,273 {274 if let Some(author_index) = F::find_author(digests) {275 let authority_id = Aura::authorities()[author_index as usize].clone();276 return Some(H160::from_slice(&authority_id.to_raw_vec()[4..24]));277 }278 None279 }280}281282parameter_types! {283 pub BlockGasLimit: U256 = U256::from(u32::max_value());284}285286impl pallet_ethereum::Config for Runtime {287 type Event = Event;288 type StateRoot = pallet_ethereum::IntermediateStateRoot;289 type EvmSubmitLog = pallet_evm::Pallet<Self>;290}291292impl pallet_randomness_collective_flip::Config for Runtime {}293294impl system::Config for Runtime {295 296 type AccountData = pallet_balances::AccountData<Balance>;297 298 type AccountId = AccountId;299 300 type BaseCallFilter = Everything;301 302 type BlockHashCount = BlockHashCount;303 304 type BlockLength = RuntimeBlockLength;305 306 type BlockNumber = BlockNumber;307 308 type BlockWeights = RuntimeBlockWeights;309 310 type Call = Call;311 312 type DbWeight = RocksDbWeight;313 314 type Event = Event;315 316 type Hash = Hash;317 318 type Hashing = BlakeTwo256;319 320 type Header = generic::Header<BlockNumber, BlakeTwo256>;321 322 type Index = Index;323 324 type Lookup = AccountIdLookup<AccountId, ()>;325 326 type OnKilledAccount = ();327 328 type OnNewAccount = ();329 type OnSetCode = cumulus_pallet_parachain_system::ParachainSetCode<Self>;330 331 type Origin = Origin;332 333 type PalletInfo = PalletInfo;334 335 type SS58Prefix = SS58Prefix;336 337 type SystemWeightInfo = system::weights::SubstrateWeight<Self>;338 339 type Version = Version;340}341342parameter_types! {343 pub const MinimumPeriod: u64 = SLOT_DURATION / 2;344}345346impl pallet_timestamp::Config for Runtime {347 348 type Moment = u64;349 type OnTimestampSet = ();350 type MinimumPeriod = MinimumPeriod;351 type WeightInfo = ();352}353354parameter_types! {355 356 pub const ExistentialDeposit: u128 = 0;357 pub const MaxLocks: u32 = 50;358}359360impl pallet_balances::Config for Runtime {361 type MaxLocks = MaxLocks;362 type MaxReserves = ();363 type ReserveIdentifier = [u8; 8];364 365 type Balance = Balance;366 367 type Event = Event;368 type DustRemoval = Treasury;369 type ExistentialDeposit = ExistentialDeposit;370 type AccountStore = System;371 type WeightInfo = pallet_balances::weights::SubstrateWeight<Self>;372}373374pub const MICROUNIQUE: Balance = 1_000_000_000;375pub const MILLIUNIQUE: Balance = 1_000 * MICROUNIQUE;376pub const CENTIUNIQUE: Balance = 10 * MILLIUNIQUE;377pub const UNIQUE: Balance = 100 * CENTIUNIQUE;378379pub const fn deposit(items: u32, bytes: u32) -> Balance {380 items as Balance * 15 * CENTIUNIQUE + (bytes as Balance) * 6 * CENTIUNIQUE381}382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433parameter_types! {434 pub const TransactionByteFee: Balance = 501 * MICROUNIQUE; 435}436437438pub struct LinearFee<T>(sp_std::marker::PhantomData<T>);439440impl<T> WeightToFeePolynomial for LinearFee<T>441where442 T: BaseArithmetic + From<u32> + Copy + Unsigned,443{444 type Balance = T;445446 fn polynomial() -> WeightToFeeCoefficients<Self::Balance> {447 smallvec!(WeightToFeeCoefficient {448 coeff_integer: 146_700u32.into(), 449 coeff_frac: Perbill::zero(),450 negative: false,451 degree: 1,452 })453 }454}455456impl pallet_transaction_payment::Config for Runtime {457 type OnChargeTransaction = pallet_transaction_payment::CurrencyAdapter<Balances, DealWithFees>;458 type TransactionByteFee = TransactionByteFee;459 type WeightToFee = LinearFee<Balance>;460 type FeeMultiplierUpdate = ();461}462463parameter_types! {464 pub const ProposalBond: Permill = Permill::from_percent(5);465 pub const ProposalBondMinimum: Balance = 1 * UNIQUE;466 pub const SpendPeriod: BlockNumber = 5 * MINUTES;467 pub const Burn: Permill = Permill::from_percent(0);468 pub const TipCountdown: BlockNumber = 1 * DAYS;469 pub const TipFindersFee: Percent = Percent::from_percent(20);470 pub const TipReportDepositBase: Balance = 1 * UNIQUE;471 pub const DataDepositPerByte: Balance = 1 * CENTIUNIQUE;472 pub const BountyDepositBase: Balance = 1 * UNIQUE;473 pub const BountyDepositPayoutDelay: BlockNumber = 1 * DAYS;474 pub const TreasuryModuleId: PalletId = PalletId(*b"py/trsry");475 pub const BountyUpdatePeriod: BlockNumber = 14 * DAYS;476 pub const MaximumReasonLength: u32 = 16384;477 pub const BountyCuratorDeposit: Permill = Permill::from_percent(50);478 pub const BountyValueMinimum: Balance = 5 * UNIQUE;479 pub const MaxApprovals: u32 = 100;480}481482impl pallet_treasury::Config for Runtime {483 type PalletId = TreasuryModuleId;484 type Currency = Balances;485 type ApproveOrigin = EnsureRoot<AccountId>;486 type RejectOrigin = EnsureRoot<AccountId>;487 type Event = Event;488 type OnSlash = ();489 type ProposalBond = ProposalBond;490 type ProposalBondMinimum = ProposalBondMinimum;491 type SpendPeriod = SpendPeriod;492 type Burn = Burn;493 type BurnDestination = ();494 type SpendFunds = ();495 type WeightInfo = pallet_treasury::weights::SubstrateWeight<Self>;496 type MaxApprovals = MaxApprovals;497}498499impl pallet_sudo::Config for Runtime {500 type Event = Event;501 type Call = Call;502}503504parameter_types! {505 pub const MinVestedTransfer: Balance = 10 * UNIQUE;506}507508impl pallet_vesting::Config for Runtime {509 type Event = Event;510 type Currency = Balances;511 type BlockNumberToBalance = ConvertInto;512 type MinVestedTransfer = MinVestedTransfer;513 type WeightInfo = ();514}515516parameter_types! {517 pub const ReservedDmpWeight: Weight = MAXIMUM_BLOCK_WEIGHT / 4;518 pub const ReservedXcmpWeight: Weight = MAXIMUM_BLOCK_WEIGHT / 4;519}520521impl cumulus_pallet_parachain_system::Config for Runtime {522 type Event = Event;523 type OnValidationData = ();524 type SelfParaId = parachain_info::Pallet<Self>;525 526 527 528 529 530 type OutboundXcmpMessageSource = XcmpQueue;531 type DmpMessageHandler = DmpQueue;532 type ReservedDmpWeight = ReservedDmpWeight;533 type ReservedXcmpWeight = ReservedXcmpWeight;534 type XcmpMessageHandler = XcmpQueue;535}536537impl parachain_info::Config for Runtime {}538539impl cumulus_pallet_aura_ext::Config for Runtime {}540541parameter_types! {542 pub const RelayLocation: MultiLocation = X1(Parent);543 pub const RelayNetwork: NetworkId = NetworkId::Polkadot;544 pub RelayOrigin: Origin = cumulus_pallet_xcm::Origin::Relay.into();545 pub Ancestry: MultiLocation = X1(Parachain(ParachainInfo::parachain_id().into()));546}547548549550551pub type LocationToAccountId = (552 553 ParentIsDefault<AccountId>,554 555 SiblingParachainConvertsVia<Sibling, AccountId>,556 557 AccountId32Aliases<RelayNetwork, AccountId>,558);559560561pub type LocalAssetTransactor = CurrencyAdapter<562 563 Balances,564 565 IsConcrete<RelayLocation>,566 567 LocationToAccountId,568 569 AccountId,570 571 (),572>;573574575576577pub type XcmOriginToTransactDispatchOrigin = (578 579 580 581 SovereignSignedViaLocation<LocationToAccountId, Origin>,582 583 584 RelayChainAsNative<RelayOrigin, Origin>,585 586 587 SiblingParachainAsNative<cumulus_pallet_xcm::Origin, Origin>,588 589 590 ParentAsSuperuser<Origin>,591 592 593 SignedAccountId32AsNative<RelayNetwork, Origin>,594 595 XcmPassthrough<Origin>,596);597598parameter_types! {599 600 pub UnitWeightCost: Weight = 1_000_000;601 602 pub const WeightPrice: (MultiLocation, u128) = (X1(Parent), 1_200 * UNIQUE);603}604605match_type! {606 pub type ParentOrParentsUnitPlurality: impl Contains<MultiLocation> = {607 X1(Parent) | X2(Parent, Plurality { id: BodyId::Unit, .. })608 };609}610611pub type Barrier = (612 TakeWeightCredit,613 AllowTopLevelPaidExecutionFrom<Everything>,614 AllowUnpaidExecutionFrom<ParentOrParentsUnitPlurality>,615 616);617618pub struct XcmConfig;619impl Config for XcmConfig {620 type Call = Call;621 type XcmSender = XcmRouter;622 623 type AssetTransactor = LocalAssetTransactor;624 type OriginConverter = XcmOriginToTransactDispatchOrigin;625 type IsReserve = NativeAsset;626 type IsTeleporter = (); 627 type LocationInverter = LocationInverter<Ancestry>;628 type Barrier = Barrier;629 type Weigher = FixedWeightBounds<UnitWeightCost, Call>;630 type Trader = UsingComponents<IdentityFee<Balance>, RelayLocation, AccountId, Balances, ()>;631 type ResponseHandler = (); 632}633634635636637638639pub type LocalOriginToLocation = (SignedToAccountId32<Origin, AccountId, RelayNetwork>,);640641642643pub type XcmRouter = (644 645 cumulus_primitives_utility::ParentAsUmp<ParachainSystem>,646 647 XcmpQueue,648);649650impl pallet_evm_coder_substrate::Config for Runtime {651 type EthereumTransactionSender = pallet_ethereum::Pallet<Self>;652}653654impl pallet_xcm::Config for Runtime {655 type Event = Event;656 type SendXcmOrigin = EnsureXcmOrigin<Origin, LocalOriginToLocation>;657 type XcmRouter = XcmRouter;658 type ExecuteXcmOrigin = EnsureXcmOrigin<Origin, LocalOriginToLocation>;659 type XcmExecuteFilter = Everything;660 type XcmExecutor = XcmExecutor<XcmConfig>;661 type XcmTeleportFilter = Everything;662 type XcmReserveTransferFilter = ();663 type Weigher = FixedWeightBounds<UnitWeightCost, Call>;664 type LocationInverter = LocationInverter<Ancestry>;665}666667impl cumulus_pallet_xcm::Config for Runtime {668 type Event = Event;669 type XcmExecutor = XcmExecutor<XcmConfig>;670}671672impl cumulus_pallet_xcmp_queue::Config for Runtime {673 type Event = Event;674 type XcmExecutor = XcmExecutor<XcmConfig>;675 type ChannelInfo = ParachainSystem;676}677678impl cumulus_pallet_dmp_queue::Config for Runtime {679 type Event = Event;680 type XcmExecutor = XcmExecutor<XcmConfig>;681 type ExecuteOverweightOrigin = frame_system::EnsureRoot<AccountId>;682}683684impl pallet_aura::Config for Runtime {685 type AuthorityId = AuraId;686 type DisabledValidators = ();687}688689parameter_types! {690 pub TreasuryAccountId: AccountId = TreasuryModuleId::get().into_account();691 pub const CollectionCreationPrice: Balance = 100 * UNIQUE;692}693694695impl pallet_nft::Config for Runtime {696 type Event = Event;697 type WeightInfo = pallet_nft::weights::SubstrateWeight<Self>;698699 type EvmBackwardsAddressMapping = pallet_nft::MapBackwardsAddressTruncated;700 type EvmAddressMapping = HashedAddressMapping<Self::Hashing>;701 type CrossAccountId = pallet_nft::BasicCrossAccountId<Self>;702703 type Currency = Balances;704 type CollectionCreationPrice = CollectionCreationPrice;705 type TreasuryAccountId = TreasuryAccountId;706}707708parameter_types! {709 pub const InflationBlockInterval: BlockNumber = 100; 710}711712713impl pallet_inflation::Config for Runtime {714 type Currency = Balances;715 type TreasuryAccountId = TreasuryAccountId;716 type InflationBlockInterval = InflationBlockInterval;717}718719parameter_types! {720 pub MaximumSchedulerWeight: Weight = Perbill::from_percent(50) *721 RuntimeBlockWeights::get().max_block;722 pub const MaxScheduledPerBlock: u32 = 50;723}724725pub struct Sponsoring;726impl SponsoringResolve<AccountId, Call> for Sponsoring {727 fn resolve(who: &AccountId, call: &Call) -> Option<AccountId>728 where729 Call: Dispatchable<Info = DispatchInfo>,730 AccountId: AsRef<[u8]>,731 {732 pallet_nft_transaction_payment::Module::<Runtime>::withdraw_type(who, call)733 }734}735736type SponsorshipHandler = (737 pallet_nft::NftSponsorshipHandler<Runtime>,738 739);740741impl pallet_scheduler::Config for Runtime {742 type Event = Event;743 type Origin = Origin;744 type PalletsOrigin = OriginCaller;745 type Call = Call;746 type MaximumWeight = MaximumSchedulerWeight;747 type ScheduleOrigin = EnsureSigned<AccountId>;748 type MaxScheduledPerBlock = MaxScheduledPerBlock;749 type SponsorshipHandler = SponsorshipHandler;750 type WeightInfo = ();751}752753impl pallet_nft_transaction_payment::Config for Runtime {754 type SponsorshipHandler = SponsorshipHandler;755}756757impl pallet_evm_transaction_payment::Config for Runtime {758 type SponsorshipHandler = (759 pallet_nft::NftEthSponsorshipHandler<Self>,760 pallet_evm_contract_helpers::HelpersContractSponsoring<Self>,761 );762 type Currency = Balances;763}764765impl pallet_nft_charge_transaction::Config for Runtime {}766767768769770771parameter_types! {772 773 pub const HelpersContractAddress: H160 = H160([774 0x84, 0x28, 0x99, 0xec, 0xf3, 0x80, 0x55, 0x3e, 0x8a, 0x4d, 0xe7, 0x5b, 0xf5, 0x34, 0xcd, 0xf6, 0xfb, 0xf6, 0x40, 0x49,775 ]);776}777778impl pallet_evm_contract_helpers::Config for Runtime {779 type ContractAddress = HelpersContractAddress;780 type DefaultSponsoringRateLimit = DefaultSponsoringRateLimit;781}782783construct_runtime!(784 pub enum Runtime where785 Block = Block,786 NodeBlock = opaque::Block,787 UncheckedExtrinsic = UncheckedExtrinsic788 {789 ParachainSystem: cumulus_pallet_parachain_system::{Pallet, Call, Storage, Inherent, Event<T>, ValidateUnsigned} = 20,790 ParachainInfo: parachain_info::{Pallet, Storage, Config} = 21,791792 Aura: pallet_aura::{Pallet, Config<T>} = 22,793 AuraExt: cumulus_pallet_aura_ext::{Pallet, Config} = 23,794795 Balances: pallet_balances::{Pallet, Call, Storage, Config<T>, Event<T>} = 30,796 RandomnessCollectiveFlip: pallet_randomness_collective_flip::{Pallet, Storage} = 31,797 Timestamp: pallet_timestamp::{Pallet, Call, Storage, Inherent} = 32,798 TransactionPayment: pallet_transaction_payment::{Pallet, Storage} = 33,799 Treasury: pallet_treasury::{Pallet, Call, Storage, Config, Event<T>} = 34,800 Sudo: pallet_sudo::{Pallet, Call, Storage, Config<T>, Event<T>} = 35,801 System: system::{Pallet, Call, Storage, Config, Event<T>} = 36,802 Vesting: pallet_vesting::{Pallet, Call, Config<T>, Storage, Event<T>} = 37,803 804805 806 XcmpQueue: cumulus_pallet_xcmp_queue::{Pallet, Call, Storage, Event<T>} = 50,807 PolkadotXcm: pallet_xcm::{Pallet, Call, Event<T>, Origin} = 51,808 CumulusXcm: cumulus_pallet_xcm::{Pallet, Call, Event<T>, Origin} = 52,809 DmpQueue: cumulus_pallet_dmp_queue::{Pallet, Call, Storage, Event<T>} = 53,810811 812 Inflation: pallet_inflation::{Pallet, Call, Storage} = 60,813 Nft: pallet_nft::{Pallet, Call, Config<T>, Storage, Event<T>} = 61,814 Scheduler: pallet_scheduler::{Pallet, Call, Storage, Event<T>} = 62,815 NftPayment: pallet_nft_transaction_payment::{Pallet, Call, Storage} = 63,816 Charging: pallet_nft_charge_transaction::{Pallet, Call, Storage } = 64,817 818819 820 EVM: pallet_evm::{Pallet, Config, Call, Storage, Event<T>} = 100,821 Ethereum: pallet_ethereum::{Pallet, Config, Call, Storage, Event, ValidateUnsigned} = 101,822823 EvmCoderSubstrate: pallet_evm_coder_substrate::{Pallet, Storage} = 150,824 EvmContractHelpers: pallet_evm_contract_helpers::{Pallet, Storage} = 151,825 EvmTransactionPayment: pallet_evm_transaction_payment::{Pallet} = 152,826 EvmMigration: pallet_evm_migration::{Pallet, Call, Storage} = 153,827 }828);829830pub struct TransactionConverter;831832impl fp_rpc::ConvertTransaction<UncheckedExtrinsic> for TransactionConverter {833 fn convert_transaction(&self, transaction: pallet_ethereum::Transaction) -> UncheckedExtrinsic {834 UncheckedExtrinsic::new_unsigned(835 pallet_ethereum::Call::<Runtime>::transact(transaction).into(),836 )837 }838}839840impl fp_rpc::ConvertTransaction<opaque::UncheckedExtrinsic> for TransactionConverter {841 fn convert_transaction(842 &self,843 transaction: pallet_ethereum::Transaction,844 ) -> opaque::UncheckedExtrinsic {845 let extrinsic = UncheckedExtrinsic::new_unsigned(846 pallet_ethereum::Call::<Runtime>::transact(transaction).into(),847 );848 let encoded = extrinsic.encode();849 opaque::UncheckedExtrinsic::decode(&mut &encoded[..])850 .expect("Encoded extrinsic is always valid")851 }852}853854855pub type Address = sp_runtime::MultiAddress<AccountId, ()>;856857pub type Header = generic::Header<BlockNumber, BlakeTwo256>;858859pub type Block = generic::Block<Header, UncheckedExtrinsic>;860861pub type SignedBlock = generic::SignedBlock<Block>;862863pub type BlockId = generic::BlockId<Block>;864865pub type SignedExtra = (866 system::CheckSpecVersion<Runtime>,867 868 system::CheckGenesis<Runtime>,869 system::CheckEra<Runtime>,870 system::CheckNonce<Runtime>,871 system::CheckWeight<Runtime>,872 pallet_nft_charge_transaction::ChargeTransactionPayment<Runtime>,873 874);875876pub type UncheckedExtrinsic = generic::UncheckedExtrinsic<Address, Call, Signature, SignedExtra>;877878pub type CheckedExtrinsic = generic::CheckedExtrinsic<AccountId, Call, SignedExtra>;879880pub type Executive = frame_executive::Executive<881 Runtime,882 Block,883 frame_system::ChainContext<Runtime>,884 Runtime,885 AllPallets,886>;887888impl_opaque_keys! {889 pub struct SessionKeys {890 pub aura: Aura,891 }892}893894impl_runtime_apis! {895 impl pallet_nft::NftApi<Block>896 for Runtime897 {898 fn eth_contract_code(account: H160) -> Option<Vec<u8>> {899 <pallet_nft::NftErcSupport<Runtime>>::get_code(&account)900 }901 }902903 impl sp_api::Core<Block> for Runtime {904 fn version() -> RuntimeVersion {905 VERSION906 }907908 fn execute_block(block: Block) {909 Executive::execute_block(block)910 }911912 fn initialize_block(header: &<Block as BlockT>::Header) {913 Executive::initialize_block(header)914 }915 }916917 impl sp_api::Metadata<Block> for Runtime {918 fn metadata() -> OpaqueMetadata {919 Runtime::metadata().into()920 }921 }922923 impl sp_block_builder::BlockBuilder<Block> for Runtime {924 fn apply_extrinsic(extrinsic: <Block as BlockT>::Extrinsic) -> ApplyExtrinsicResult {925 Executive::apply_extrinsic(extrinsic)926 }927928 fn finalize_block() -> <Block as BlockT>::Header {929 Executive::finalize_block()930 }931932 fn inherent_extrinsics(data: sp_inherents::InherentData) -> Vec<<Block as BlockT>::Extrinsic> {933 data.create_extrinsics()934 }935936 fn check_inherents(937 block: Block,938 data: sp_inherents::InherentData,939 ) -> sp_inherents::CheckInherentsResult {940 data.check_extrinsics(&block)941 }942943 944 945 946 }947948 impl sp_transaction_pool::runtime_api::TaggedTransactionQueue<Block> for Runtime {949 fn validate_transaction(950 source: TransactionSource,951 tx: <Block as BlockT>::Extrinsic,952 hash: <Block as BlockT>::Hash,953 ) -> TransactionValidity {954 Executive::validate_transaction(source, tx, hash)955 }956 }957958 impl sp_offchain::OffchainWorkerApi<Block> for Runtime {959 fn offchain_worker(header: &<Block as BlockT>::Header) {960 Executive::offchain_worker(header)961 }962 }963964 impl fp_rpc::EthereumRuntimeRPCApi<Block> for Runtime {965 fn chain_id() -> u64 {966 <Runtime as pallet_evm::Config>::ChainId::get()967 }968969 fn account_basic(address: H160) -> EVMAccount {970 EVM::account_basic(&address)971 }972973 fn gas_price() -> U256 {974 <Runtime as pallet_evm::Config>::FeeCalculator::min_gas_price()975 }976977 fn account_code_at(address: H160) -> Vec<u8> {978 EVM::account_codes(address)979 }980981 fn author() -> H160 {982 <pallet_evm::Pallet<Runtime>>::find_author()983 }984985 fn storage_at(address: H160, index: U256) -> H256 {986 let mut tmp = [0u8; 32];987 index.to_big_endian(&mut tmp);988 EVM::account_storages(address, H256::from_slice(&tmp[..]))989 }990991 fn call(992 from: H160,993 to: H160,994 data: Vec<u8>,995 value: U256,996 gas_limit: U256,997 gas_price: Option<U256>,998 nonce: Option<U256>,999 estimate: bool,1000 ) -> Result<pallet_evm::CallInfo, sp_runtime::DispatchError> {1001 let config = if estimate {1002 let mut config = <Runtime as pallet_evm::Config>::config().clone();1003 config.estimate = true;1004 Some(config)1005 } else {1006 None1007 };10081009 <Runtime as pallet_evm::Config>::Runner::call(1010 from,1011 to,1012 data,1013 value,1014 gas_limit.low_u64(),1015 gas_price,1016 nonce,1017 config.as_ref().unwrap_or_else(|| <Runtime as pallet_evm::Config>::config()),1018 ).map_err(|err| err.into())1019 }10201021 fn create(1022 from: H160,1023 data: Vec<u8>,1024 value: U256,1025 gas_limit: U256,1026 gas_price: Option<U256>,1027 nonce: Option<U256>,1028 estimate: bool,1029 ) -> Result<pallet_evm::CreateInfo, sp_runtime::DispatchError> {1030 let config = if estimate {1031 let mut config = <Runtime as pallet_evm::Config>::config().clone();1032 config.estimate = true;1033 Some(config)1034 } else {1035 None1036 };10371038 <Runtime as pallet_evm::Config>::Runner::create(1039 from,1040 data,1041 value,1042 gas_limit.low_u64(),1043 gas_price,1044 nonce,1045 config.as_ref().unwrap_or_else(|| <Runtime as pallet_evm::Config>::config()),1046 ).map_err(|err| err.into())1047 }10481049 fn current_transaction_statuses() -> Option<Vec<TransactionStatus>> {1050 Ethereum::current_transaction_statuses()1051 }10521053 fn current_block() -> Option<pallet_ethereum::Block> {1054 Ethereum::current_block()1055 }10561057 fn current_receipts() -> Option<Vec<pallet_ethereum::Receipt>> {1058 Ethereum::current_receipts()1059 }10601061 fn current_all() -> (1062 Option<pallet_ethereum::Block>,1063 Option<Vec<pallet_ethereum::Receipt>>,1064 Option<Vec<TransactionStatus>>1065 ) {1066 (1067 Ethereum::current_block(),1068 Ethereum::current_receipts(),1069 Ethereum::current_transaction_statuses()1070 )1071 }10721073 fn extrinsic_filter(xts: Vec<<Block as sp_api::BlockT>::Extrinsic>) -> Vec<pallet_ethereum::Transaction> {1074 xts.into_iter().filter_map(|xt| match xt.function {1075 Call::Ethereum(pallet_ethereum::Call::transact(t)) => Some(t),1076 _ => None1077 }).collect()1078 }1079 }10801081 impl sp_session::SessionKeys<Block> for Runtime {1082 fn decode_session_keys(1083 encoded: Vec<u8>,1084 ) -> Option<Vec<(Vec<u8>, KeyTypeId)>> {1085 SessionKeys::decode_into_raw_public_keys(&encoded)1086 }10871088 fn generate_session_keys(seed: Option<Vec<u8>>) -> Vec<u8> {1089 SessionKeys::generate(seed)1090 }1091 }10921093 impl sp_consensus_aura::AuraApi<Block, AuraId> for Runtime {1094 fn slot_duration() -> sp_consensus_aura::SlotDuration {1095 sp_consensus_aura::SlotDuration::from_millis(Aura::slot_duration())1096 }10971098 fn authorities() -> Vec<AuraId> {1099 Aura::authorities()1100 }1101 }11021103 impl cumulus_primitives_core::CollectCollationInfo<Block> for Runtime {1104 fn collect_collation_info() -> cumulus_primitives_core::CollationInfo {1105 ParachainSystem::collect_collation_info()1106 }1107 }11081109 impl frame_system_rpc_runtime_api::AccountNonceApi<Block, AccountId, Index> for Runtime {1110 fn account_nonce(account: AccountId) -> Index {1111 System::account_nonce(account)1112 }1113 }11141115 impl pallet_transaction_payment_rpc_runtime_api::TransactionPaymentApi<Block, Balance> for Runtime {1116 fn query_info(uxt: <Block as BlockT>::Extrinsic, len: u32) -> RuntimeDispatchInfo<Balance> {1117 TransactionPayment::query_info(uxt, len)1118 }1119 fn query_fee_details(uxt: <Block as BlockT>::Extrinsic, len: u32) -> FeeDetails<Balance> {1120 TransactionPayment::query_fee_details(uxt, len)1121 }1122 }11231124 11251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165 #[cfg(feature = "runtime-benchmarks")]1166 impl frame_benchmarking::Benchmark<Block> for Runtime {1167 fn dispatch_benchmark(1168 config: frame_benchmarking::BenchmarkConfig1169 ) -> Result<Vec<frame_benchmarking::BenchmarkBatch>, sp_runtime::RuntimeString> {1170 use frame_benchmarking::{Benchmarking, BenchmarkBatch, add_benchmark, TrackedStorageKey};11711172 let whitelist: Vec<TrackedStorageKey> = vec![1173 1174 hex_literal::hex!("d43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d").to_vec().into(),1175 1176 1177 1178 1179 1180 1181 1182 1183 ];11841185 let mut batches = Vec::<BenchmarkBatch>::new();1186 let params = (&config, &whitelist);11871188 add_benchmark!(params, batches, pallet_evm_migration, EvmMigration);1189 add_benchmark!(params, batches, pallet_nft, Nft);1190 add_benchmark!(params, batches, pallet_inflation, Inflation);11911192 if batches.is_empty() { return Err("Benchmark not found for this pallet.".into()) }1193 Ok(batches)1194 }1195 }1196}11971198struct CheckInherents;11991200impl cumulus_pallet_parachain_system::CheckInherents<Block> for CheckInherents {1201 fn check_inherents(1202 block: &Block,1203 relay_state_proof: &cumulus_pallet_parachain_system::RelayChainStateProof,1204 ) -> sp_inherents::CheckInherentsResult {1205 let relay_chain_slot = relay_state_proof1206 .read_slot()1207 .expect("Could not read the relay chain slot from the proof");12081209 let inherent_data =1210 cumulus_primitives_timestamp::InherentDataProvider::from_relay_chain_slot_and_duration(1211 relay_chain_slot,1212 sp_std::time::Duration::from_secs(6),1213 )1214 .create_inherent_data()1215 .expect("Could not create the timestamp inherent data");12161217 inherent_data.check_extrinsics(block)1218 }1219}12201221cumulus_pallet_parachain_system::register_validate_block!(1222 Runtime = Runtime,1223 BlockExecutor = cumulus_pallet_aura_ext::BlockExecutor::<Runtime, Executive>,1224 CheckInherents = CheckInherents,1225);