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::v1::{BodyId, Junction::*, MultiLocation, NetworkId, Junctions::*};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!("opal"),145 impl_name: create_runtime_str!("opal"),146 authoring_version: 1,147 spec_version: 910000,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}239240pub struct FixedFee;241impl FeeCalculator for FixedFee {242 fn min_gas_price() -> U256 {243 1.into()244 }245}246247impl pallet_evm::Config for Runtime {248 type BlockGasLimit = BlockGasLimit;249 type FeeCalculator = FixedFee;250 type GasWeightMapping = ();251 type BlockHashMapping = pallet_ethereum::EthereumBlockHashMapping<Self>;252 type CallOrigin = EnsureAddressTruncated;253 type WithdrawOrigin = EnsureAddressTruncated;254 type AddressMapping = HashedAddressMapping<Self::Hashing>;255 type Precompiles = ();256 type Currency = Balances;257 type Event = Event;258 type OnMethodCall = (259 pallet_evm_migration::OnMethodCall<Self>,260 pallet_nft::NftErcSupport<Self>,261 pallet_evm_contract_helpers::HelpersOnMethodCall<Self>,262 );263 type OnCreate = pallet_evm_contract_helpers::HelpersOnCreate<Self>;264 type ChainId = ChainId;265 type Runner = pallet_evm::runner::stack::Runner<Self>;266 type OnChargeTransaction = pallet_evm_transaction_payment::OnChargeTransaction<Self>;267 type TransactionValidityHack = pallet_evm_transaction_payment::TransactionValidityHack<Self>;268 type FindAuthor = EthereumFindAuthor<Aura>;269}270271impl pallet_evm_migration::Config for Runtime {272 type WeightInfo = pallet_evm_migration::weights::SubstrateWeight<Self>;273}274275pub struct EthereumFindAuthor<F>(core::marker::PhantomData<F>);276impl<F: FindAuthor<u32>> FindAuthor<H160> for EthereumFindAuthor<F> {277 fn find_author<'a, I>(digests: I) -> Option<H160>278 where279 I: 'a + IntoIterator<Item = (ConsensusEngineId, &'a [u8])>,280 {281 if let Some(author_index) = F::find_author(digests) {282 let authority_id = Aura::authorities()[author_index as usize].clone();283 return Some(H160::from_slice(&authority_id.to_raw_vec()[4..24]));284 }285 None286 }287}288289parameter_types! {290 pub BlockGasLimit: U256 = U256::from(u32::max_value());291}292293impl pallet_ethereum::Config for Runtime {294 type Event = Event;295 type StateRoot = pallet_ethereum::IntermediateStateRoot;296 type EvmSubmitLog = pallet_evm::Pallet<Self>;297}298299impl pallet_randomness_collective_flip::Config for Runtime {}300301impl system::Config for Runtime {302 303 type AccountData = pallet_balances::AccountData<Balance>;304 305 type AccountId = AccountId;306 307 type BaseCallFilter = Everything;308 309 type BlockHashCount = BlockHashCount;310 311 type BlockLength = RuntimeBlockLength;312 313 type BlockNumber = BlockNumber;314 315 type BlockWeights = RuntimeBlockWeights;316 317 type Call = Call;318 319 type DbWeight = RocksDbWeight;320 321 type Event = Event;322 323 type Hash = Hash;324 325 type Hashing = BlakeTwo256;326 327 type Header = generic::Header<BlockNumber, BlakeTwo256>;328 329 type Index = Index;330 331 type Lookup = AccountIdLookup<AccountId, ()>;332 333 type OnKilledAccount = ();334 335 type OnNewAccount = ();336 type OnSetCode = cumulus_pallet_parachain_system::ParachainSetCode<Self>;337 338 type Origin = Origin;339 340 type PalletInfo = PalletInfo;341 342 type SS58Prefix = SS58Prefix;343 344 type SystemWeightInfo = system::weights::SubstrateWeight<Self>;345 346 type Version = Version;347}348349parameter_types! {350 pub const MinimumPeriod: u64 = SLOT_DURATION / 2;351}352353impl pallet_timestamp::Config for Runtime {354 355 type Moment = u64;356 type OnTimestampSet = ();357 type MinimumPeriod = MinimumPeriod;358 type WeightInfo = ();359}360361parameter_types! {362 363 pub const ExistentialDeposit: u128 = 0;364 pub const MaxLocks: u32 = 50;365}366367impl pallet_balances::Config for Runtime {368 type MaxLocks = MaxLocks;369 type MaxReserves = ();370 type ReserveIdentifier = [u8; 8];371 372 type Balance = Balance;373 374 type Event = Event;375 type DustRemoval = Treasury;376 type ExistentialDeposit = ExistentialDeposit;377 type AccountStore = System;378 type WeightInfo = pallet_balances::weights::SubstrateWeight<Self>;379}380381pub const MICROUNIQUE: Balance = 1_000_000_000;382pub const MILLIUNIQUE: Balance = 1_000 * MICROUNIQUE;383pub const CENTIUNIQUE: Balance = 10 * MILLIUNIQUE;384pub const UNIQUE: Balance = 100 * CENTIUNIQUE;385386pub const fn deposit(items: u32, bytes: u32) -> Balance {387 items as Balance * 15 * CENTIUNIQUE + (bytes as Balance) * 6 * CENTIUNIQUE388}389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440parameter_types! {441 pub const TransactionByteFee: Balance = 501 * MICROUNIQUE; 442}443444445pub struct LinearFee<T>(sp_std::marker::PhantomData<T>);446447impl<T> WeightToFeePolynomial for LinearFee<T>448where449 T: BaseArithmetic + From<u32> + Copy + Unsigned,450{451 type Balance = T;452453 fn polynomial() -> WeightToFeeCoefficients<Self::Balance> {454 smallvec!(WeightToFeeCoefficient {455 coeff_integer: 146_700u32.into(), 456 coeff_frac: Perbill::zero(),457 negative: false,458 degree: 1,459 })460 }461}462463impl pallet_transaction_payment::Config for Runtime {464 type OnChargeTransaction = pallet_transaction_payment::CurrencyAdapter<Balances, DealWithFees>;465 type TransactionByteFee = TransactionByteFee;466 type WeightToFee = LinearFee<Balance>;467 type FeeMultiplierUpdate = ();468}469470parameter_types! {471 pub const ProposalBond: Permill = Permill::from_percent(5);472 pub const ProposalBondMinimum: Balance = 1 * UNIQUE;473 pub const SpendPeriod: BlockNumber = 5 * MINUTES;474 pub const Burn: Permill = Permill::from_percent(0);475 pub const TipCountdown: BlockNumber = 1 * DAYS;476 pub const TipFindersFee: Percent = Percent::from_percent(20);477 pub const TipReportDepositBase: Balance = 1 * UNIQUE;478 pub const DataDepositPerByte: Balance = 1 * CENTIUNIQUE;479 pub const BountyDepositBase: Balance = 1 * UNIQUE;480 pub const BountyDepositPayoutDelay: BlockNumber = 1 * DAYS;481 pub const TreasuryModuleId: PalletId = PalletId(*b"py/trsry");482 pub const BountyUpdatePeriod: BlockNumber = 14 * DAYS;483 pub const MaximumReasonLength: u32 = 16384;484 pub const BountyCuratorDeposit: Permill = Permill::from_percent(50);485 pub const BountyValueMinimum: Balance = 5 * UNIQUE;486 pub const MaxApprovals: u32 = 100;487}488489impl pallet_treasury::Config for Runtime {490 type PalletId = TreasuryModuleId;491 type Currency = Balances;492 type ApproveOrigin = EnsureRoot<AccountId>;493 type RejectOrigin = EnsureRoot<AccountId>;494 type Event = Event;495 type OnSlash = ();496 type ProposalBond = ProposalBond;497 type ProposalBondMinimum = ProposalBondMinimum;498 type SpendPeriod = SpendPeriod;499 type Burn = Burn;500 type BurnDestination = ();501 type SpendFunds = ();502 type WeightInfo = pallet_treasury::weights::SubstrateWeight<Self>;503 type MaxApprovals = MaxApprovals;504}505506impl pallet_sudo::Config for Runtime {507 type Event = Event;508 type Call = Call;509}510511parameter_types! {512 pub const MinVestedTransfer: Balance = 10 * UNIQUE;513}514515impl pallet_vesting::Config for Runtime {516 type Event = Event;517 type Currency = Balances;518 type BlockNumberToBalance = ConvertInto;519 type MinVestedTransfer = MinVestedTransfer;520 type WeightInfo = ();521}522523parameter_types! {524 pub const ReservedDmpWeight: Weight = MAXIMUM_BLOCK_WEIGHT / 4;525 pub const ReservedXcmpWeight: Weight = MAXIMUM_BLOCK_WEIGHT / 4;526}527528impl cumulus_pallet_parachain_system::Config for Runtime {529 type Event = Event;530 type OnValidationData = ();531 type SelfParaId = parachain_info::Pallet<Self>;532 533 534 535 536 537 type OutboundXcmpMessageSource = XcmpQueue;538 type DmpMessageHandler = DmpQueue;539 type ReservedDmpWeight = ReservedDmpWeight;540 type ReservedXcmpWeight = ReservedXcmpWeight;541 type XcmpMessageHandler = XcmpQueue;542}543544impl parachain_info::Config for Runtime {}545546impl cumulus_pallet_aura_ext::Config for Runtime {}547548parameter_types! {549 pub const RelayLocation: MultiLocation = MultiLocation::parent();550 pub const RelayNetwork: NetworkId = NetworkId::Polkadot;551 pub RelayOrigin: Origin = cumulus_pallet_xcm::Origin::Relay.into();552 pub Ancestry: MultiLocation = Parachain(ParachainInfo::parachain_id().into()).into();553}554555556557558pub type LocationToAccountId = (559 560 ParentIsDefault<AccountId>,561 562 SiblingParachainConvertsVia<Sibling, AccountId>,563 564 AccountId32Aliases<RelayNetwork, AccountId>,565);566567568pub type LocalAssetTransactor = CurrencyAdapter<569 570 Balances,571 572 IsConcrete<RelayLocation>,573 574 LocationToAccountId,575 576 AccountId,577 578 (),579>;580581582583584pub type XcmOriginToTransactDispatchOrigin = (585 586 587 588 SovereignSignedViaLocation<LocationToAccountId, Origin>,589 590 591 RelayChainAsNative<RelayOrigin, Origin>,592 593 594 SiblingParachainAsNative<cumulus_pallet_xcm::Origin, Origin>,595 596 597 ParentAsSuperuser<Origin>,598 599 600 SignedAccountId32AsNative<RelayNetwork, Origin>,601 602 XcmPassthrough<Origin>,603);604605parameter_types! {606 607 pub UnitWeightCost: Weight = 1_000_000;608 609 pub const WeightPrice: (MultiLocation, u128) = (MultiLocation::parent(), 1_200 * UNIQUE);610}611612match_type! {613 pub type ParentOrParentsUnitPlurality: impl Contains<MultiLocation> = {614 MultiLocation { parents: 1, interior: Here } |615 MultiLocation { parents: 1, interior: X1(Plurality { id: BodyId::Unit, .. }) }616 };617}618619pub type Barrier = (620 TakeWeightCredit,621 AllowTopLevelPaidExecutionFrom<Everything>,622 AllowUnpaidExecutionFrom<ParentOrParentsUnitPlurality>,623 624);625626pub struct XcmConfig;627impl Config for XcmConfig {628 type Call = Call;629 type XcmSender = XcmRouter;630 631 type AssetTransactor = LocalAssetTransactor;632 type OriginConverter = XcmOriginToTransactDispatchOrigin;633 type IsReserve = NativeAsset;634 type IsTeleporter = (); 635 type LocationInverter = LocationInverter<Ancestry>;636 type Barrier = Barrier;637 type Weigher = FixedWeightBounds<UnitWeightCost, Call>;638 type Trader = UsingComponents<IdentityFee<Balance>, RelayLocation, AccountId, Balances, ()>;639 type ResponseHandler = (); 640 type SubscriptionService = PolkadotXcm;641}642643644645646647648pub type LocalOriginToLocation = (SignedToAccountId32<Origin, AccountId, RelayNetwork>,);649650651652pub type XcmRouter = (653 654 cumulus_primitives_utility::ParentAsUmp<ParachainSystem, ()>,655 656 XcmpQueue,657);658659impl pallet_evm_coder_substrate::Config for Runtime {660 type EthereumTransactionSender = pallet_ethereum::Pallet<Self>;661}662663impl pallet_xcm::Config for Runtime {664 type Event = Event;665 type SendXcmOrigin = EnsureXcmOrigin<Origin, LocalOriginToLocation>;666 type XcmRouter = XcmRouter;667 type ExecuteXcmOrigin = EnsureXcmOrigin<Origin, LocalOriginToLocation>;668 type XcmExecuteFilter = Everything;669 type XcmExecutor = XcmExecutor<XcmConfig>;670 type XcmTeleportFilter = Everything;671 type XcmReserveTransferFilter = ();672 type Weigher = FixedWeightBounds<UnitWeightCost, Call>;673 type LocationInverter = LocationInverter<Ancestry>;674}675676impl cumulus_pallet_xcm::Config for Runtime {677 type Event = Event;678 type XcmExecutor = XcmExecutor<XcmConfig>;679}680681impl cumulus_pallet_xcmp_queue::Config for Runtime {682 type Event = Event;683 type XcmExecutor = XcmExecutor<XcmConfig>;684 type ChannelInfo = ParachainSystem;685 type VersionWrapper = ();686}687688impl cumulus_pallet_dmp_queue::Config for Runtime {689 type Event = Event;690 type XcmExecutor = XcmExecutor<XcmConfig>;691 type ExecuteOverweightOrigin = frame_system::EnsureRoot<AccountId>;692}693694impl pallet_aura::Config for Runtime {695 type AuthorityId = AuraId;696 type DisabledValidators = ();697}698699parameter_types! {700 pub TreasuryAccountId: AccountId = TreasuryModuleId::get().into_account();701 pub const CollectionCreationPrice: Balance = 100 * UNIQUE;702}703704705impl pallet_nft::Config for Runtime {706 type Event = Event;707 type WeightInfo = pallet_nft::weights::SubstrateWeight<Self>;708709 type EvmBackwardsAddressMapping = pallet_nft::MapBackwardsAddressTruncated;710 type EvmAddressMapping = HashedAddressMapping<Self::Hashing>;711 type CrossAccountId = pallet_nft::BasicCrossAccountId<Self>;712713 type Currency = Balances;714 type CollectionCreationPrice = CollectionCreationPrice;715 type TreasuryAccountId = TreasuryAccountId;716}717718parameter_types! {719 pub const InflationBlockInterval: BlockNumber = 100; 720}721722723impl pallet_inflation::Config for Runtime {724 type Currency = Balances;725 type TreasuryAccountId = TreasuryAccountId;726 type InflationBlockInterval = InflationBlockInterval;727}728729parameter_types! {730 pub MaximumSchedulerWeight: Weight = Perbill::from_percent(50) *731 RuntimeBlockWeights::get().max_block;732 pub const MaxScheduledPerBlock: u32 = 50;733}734735pub struct Sponsoring;736impl SponsoringResolve<AccountId, Call> for Sponsoring {737 fn resolve(who: &AccountId, call: &Call) -> Option<AccountId>738 where739 Call: Dispatchable<Info = DispatchInfo>,740 AccountId: AsRef<[u8]>,741 {742 pallet_nft_transaction_payment::Module::<Runtime>::withdraw_type(who, call)743 }744}745746type SponsorshipHandler = (747 pallet_nft::NftSponsorshipHandler<Runtime>,748 749);750751impl pallet_unq_scheduler::Config for Runtime {752 type Event = Event;753 type Origin = Origin;754 type PalletsOrigin = OriginCaller;755 type Call = Call;756 type MaximumWeight = MaximumSchedulerWeight;757 type ScheduleOrigin = EnsureSigned<AccountId>;758 type MaxScheduledPerBlock = MaxScheduledPerBlock;759 type SponsorshipHandler = SponsorshipHandler;760 type WeightInfo = ();761}762763impl pallet_nft_transaction_payment::Config for Runtime {764 type SponsorshipHandler = SponsorshipHandler;765}766767impl pallet_evm_transaction_payment::Config for Runtime {768 type SponsorshipHandler = (769 pallet_nft::NftEthSponsorshipHandler<Self>,770 pallet_evm_contract_helpers::HelpersContractSponsoring<Self>,771 );772 type Currency = Balances;773}774775impl pallet_nft_charge_transaction::Config for Runtime {}776777778779780781parameter_types! {782 783 pub const HelpersContractAddress: H160 = H160([784 0x84, 0x28, 0x99, 0xec, 0xf3, 0x80, 0x55, 0x3e, 0x8a, 0x4d, 0xe7, 0x5b, 0xf5, 0x34, 0xcd, 0xf6, 0xfb, 0xf6, 0x40, 0x49,785 ]);786}787788impl pallet_evm_contract_helpers::Config for Runtime {789 type ContractAddress = HelpersContractAddress;790 type DefaultSponsoringRateLimit = DefaultSponsoringRateLimit;791}792793construct_runtime!(794 pub enum Runtime where795 Block = Block,796 NodeBlock = opaque::Block,797 UncheckedExtrinsic = UncheckedExtrinsic798 {799 ParachainSystem: cumulus_pallet_parachain_system::{Pallet, Call, Storage, Inherent, Event<T>, ValidateUnsigned} = 20,800 ParachainInfo: parachain_info::{Pallet, Storage, Config} = 21,801802 Aura: pallet_aura::{Pallet, Config<T>} = 22,803 AuraExt: cumulus_pallet_aura_ext::{Pallet, Config} = 23,804805 Balances: pallet_balances::{Pallet, Call, Storage, Config<T>, Event<T>} = 30,806 RandomnessCollectiveFlip: pallet_randomness_collective_flip::{Pallet, Storage} = 31,807 Timestamp: pallet_timestamp::{Pallet, Call, Storage, Inherent} = 32,808 TransactionPayment: pallet_transaction_payment::{Pallet, Storage} = 33,809 Treasury: pallet_treasury::{Pallet, Call, Storage, Config, Event<T>} = 34,810 Sudo: pallet_sudo::{Pallet, Call, Storage, Config<T>, Event<T>} = 35,811 System: system::{Pallet, Call, Storage, Config, Event<T>} = 36,812 Vesting: pallet_vesting::{Pallet, Call, Config<T>, Storage, Event<T>} = 37,813 814815 816 XcmpQueue: cumulus_pallet_xcmp_queue::{Pallet, Call, Storage, Event<T>} = 50,817 PolkadotXcm: pallet_xcm::{Pallet, Call, Event<T>, Origin} = 51,818 CumulusXcm: cumulus_pallet_xcm::{Pallet, Call, Event<T>, Origin} = 52,819 DmpQueue: cumulus_pallet_dmp_queue::{Pallet, Call, Storage, Event<T>} = 53,820821 822 Inflation: pallet_inflation::{Pallet, Call, Storage} = 60,823 Nft: pallet_nft::{Pallet, Call, Config<T>, Storage, Event<T>} = 61,824 Scheduler: pallet_unq_scheduler::{Pallet, Call, Storage, Event<T>} = 62,825 NftPayment: pallet_nft_transaction_payment::{Pallet, Call, Storage} = 63,826 Charging: pallet_nft_charge_transaction::{Pallet, Call, Storage } = 64,827 828829 830 EVM: pallet_evm::{Pallet, Config, Call, Storage, Event<T>} = 100,831 Ethereum: pallet_ethereum::{Pallet, Config, Call, Storage, Event, ValidateUnsigned} = 101,832833 EvmCoderSubstrate: pallet_evm_coder_substrate::{Pallet, Storage} = 150,834 EvmContractHelpers: pallet_evm_contract_helpers::{Pallet, Storage} = 151,835 EvmTransactionPayment: pallet_evm_transaction_payment::{Pallet} = 152,836 EvmMigration: pallet_evm_migration::{Pallet, Call, Storage} = 153,837 }838);839840pub struct TransactionConverter;841842impl fp_rpc::ConvertTransaction<UncheckedExtrinsic> for TransactionConverter {843 fn convert_transaction(&self, transaction: pallet_ethereum::Transaction) -> UncheckedExtrinsic {844 UncheckedExtrinsic::new_unsigned(845 pallet_ethereum::Call::<Runtime>::transact(transaction).into(),846 )847 }848}849850impl fp_rpc::ConvertTransaction<opaque::UncheckedExtrinsic> for TransactionConverter {851 fn convert_transaction(852 &self,853 transaction: pallet_ethereum::Transaction,854 ) -> opaque::UncheckedExtrinsic {855 let extrinsic = UncheckedExtrinsic::new_unsigned(856 pallet_ethereum::Call::<Runtime>::transact(transaction).into(),857 );858 let encoded = extrinsic.encode();859 opaque::UncheckedExtrinsic::decode(&mut &encoded[..])860 .expect("Encoded extrinsic is always valid")861 }862}863864865pub type Address = sp_runtime::MultiAddress<AccountId, ()>;866867pub type Header = generic::Header<BlockNumber, BlakeTwo256>;868869pub type Block = generic::Block<Header, UncheckedExtrinsic>;870871pub type SignedBlock = generic::SignedBlock<Block>;872873pub type BlockId = generic::BlockId<Block>;874875pub type SignedExtra = (876 system::CheckSpecVersion<Runtime>,877 878 system::CheckGenesis<Runtime>,879 system::CheckEra<Runtime>,880 system::CheckNonce<Runtime>,881 system::CheckWeight<Runtime>,882 pallet_nft_charge_transaction::ChargeTransactionPayment<Runtime>,883 884);885886pub type UncheckedExtrinsic = generic::UncheckedExtrinsic<Address, Call, Signature, SignedExtra>;887888pub type CheckedExtrinsic = generic::CheckedExtrinsic<AccountId, Call, SignedExtra>;889890pub type Executive = frame_executive::Executive<891 Runtime,892 Block,893 frame_system::ChainContext<Runtime>,894 Runtime,895 AllPallets,896>;897898impl_opaque_keys! {899 pub struct SessionKeys {900 pub aura: Aura,901 }902}903904impl_runtime_apis! {905 impl pallet_nft::NftApi<Block>906 for Runtime907 {908 fn eth_contract_code(account: H160) -> Option<Vec<u8>> {909 <pallet_nft::NftErcSupport<Runtime>>::get_code(&account)910 }911 }912913 impl sp_api::Core<Block> for Runtime {914 fn version() -> RuntimeVersion {915 VERSION916 }917918 fn execute_block(block: Block) {919 Executive::execute_block(block)920 }921922 fn initialize_block(header: &<Block as BlockT>::Header) {923 Executive::initialize_block(header)924 }925 }926927 impl sp_api::Metadata<Block> for Runtime {928 fn metadata() -> OpaqueMetadata {929 Runtime::metadata().into()930 }931 }932933 impl sp_block_builder::BlockBuilder<Block> for Runtime {934 fn apply_extrinsic(extrinsic: <Block as BlockT>::Extrinsic) -> ApplyExtrinsicResult {935 Executive::apply_extrinsic(extrinsic)936 }937938 fn finalize_block() -> <Block as BlockT>::Header {939 Executive::finalize_block()940 }941942 fn inherent_extrinsics(data: sp_inherents::InherentData) -> Vec<<Block as BlockT>::Extrinsic> {943 data.create_extrinsics()944 }945946 fn check_inherents(947 block: Block,948 data: sp_inherents::InherentData,949 ) -> sp_inherents::CheckInherentsResult {950 data.check_extrinsics(&block)951 }952953 954 955 956 }957958 impl sp_transaction_pool::runtime_api::TaggedTransactionQueue<Block> for Runtime {959 fn validate_transaction(960 source: TransactionSource,961 tx: <Block as BlockT>::Extrinsic,962 hash: <Block as BlockT>::Hash,963 ) -> TransactionValidity {964 Executive::validate_transaction(source, tx, hash)965 }966 }967968 impl sp_offchain::OffchainWorkerApi<Block> for Runtime {969 fn offchain_worker(header: &<Block as BlockT>::Header) {970 Executive::offchain_worker(header)971 }972 }973974 impl fp_rpc::EthereumRuntimeRPCApi<Block> for Runtime {975 fn chain_id() -> u64 {976 <Runtime as pallet_evm::Config>::ChainId::get()977 }978979 fn account_basic(address: H160) -> EVMAccount {980 EVM::account_basic(&address)981 }982983 fn gas_price() -> U256 {984 <Runtime as pallet_evm::Config>::FeeCalculator::min_gas_price()985 }986987 fn account_code_at(address: H160) -> Vec<u8> {988 EVM::account_codes(address)989 }990991 fn author() -> H160 {992 <pallet_evm::Pallet<Runtime>>::find_author()993 }994995 fn storage_at(address: H160, index: U256) -> H256 {996 let mut tmp = [0u8; 32];997 index.to_big_endian(&mut tmp);998 EVM::account_storages(address, H256::from_slice(&tmp[..]))999 }10001001 fn call(1002 from: H160,1003 to: H160,1004 data: Vec<u8>,1005 value: U256,1006 gas_limit: U256,1007 gas_price: Option<U256>,1008 nonce: Option<U256>,1009 estimate: bool,1010 ) -> Result<pallet_evm::CallInfo, sp_runtime::DispatchError> {1011 let config = if estimate {1012 let mut config = <Runtime as pallet_evm::Config>::config().clone();1013 config.estimate = true;1014 Some(config)1015 } else {1016 None1017 };10181019 <Runtime as pallet_evm::Config>::Runner::call(1020 from,1021 to,1022 data,1023 value,1024 gas_limit.low_u64(),1025 gas_price,1026 nonce,1027 config.as_ref().unwrap_or_else(|| <Runtime as pallet_evm::Config>::config()),1028 ).map_err(|err| err.into())1029 }10301031 fn create(1032 from: H160,1033 data: Vec<u8>,1034 value: U256,1035 gas_limit: U256,1036 gas_price: Option<U256>,1037 nonce: Option<U256>,1038 estimate: bool,1039 ) -> Result<pallet_evm::CreateInfo, sp_runtime::DispatchError> {1040 let config = if estimate {1041 let mut config = <Runtime as pallet_evm::Config>::config().clone();1042 config.estimate = true;1043 Some(config)1044 } else {1045 None1046 };10471048 <Runtime as pallet_evm::Config>::Runner::create(1049 from,1050 data,1051 value,1052 gas_limit.low_u64(),1053 gas_price,1054 nonce,1055 config.as_ref().unwrap_or_else(|| <Runtime as pallet_evm::Config>::config()),1056 ).map_err(|err| err.into())1057 }10581059 fn current_transaction_statuses() -> Option<Vec<TransactionStatus>> {1060 Ethereum::current_transaction_statuses()1061 }10621063 fn current_block() -> Option<pallet_ethereum::Block> {1064 Ethereum::current_block()1065 }10661067 fn current_receipts() -> Option<Vec<pallet_ethereum::Receipt>> {1068 Ethereum::current_receipts()1069 }10701071 fn current_all() -> (1072 Option<pallet_ethereum::Block>,1073 Option<Vec<pallet_ethereum::Receipt>>,1074 Option<Vec<TransactionStatus>>1075 ) {1076 (1077 Ethereum::current_block(),1078 Ethereum::current_receipts(),1079 Ethereum::current_transaction_statuses()1080 )1081 }10821083 fn extrinsic_filter(xts: Vec<<Block as sp_api::BlockT>::Extrinsic>) -> Vec<pallet_ethereum::Transaction> {1084 xts.into_iter().filter_map(|xt| match xt.function {1085 Call::Ethereum(pallet_ethereum::Call::transact(t)) => Some(t),1086 _ => None1087 }).collect()1088 }1089 }10901091 impl sp_session::SessionKeys<Block> for Runtime {1092 fn decode_session_keys(1093 encoded: Vec<u8>,1094 ) -> Option<Vec<(Vec<u8>, KeyTypeId)>> {1095 SessionKeys::decode_into_raw_public_keys(&encoded)1096 }10971098 fn generate_session_keys(seed: Option<Vec<u8>>) -> Vec<u8> {1099 SessionKeys::generate(seed)1100 }1101 }11021103 impl sp_consensus_aura::AuraApi<Block, AuraId> for Runtime {1104 fn slot_duration() -> sp_consensus_aura::SlotDuration {1105 sp_consensus_aura::SlotDuration::from_millis(Aura::slot_duration())1106 }11071108 fn authorities() -> Vec<AuraId> {1109 Aura::authorities()1110 }1111 }11121113 impl cumulus_primitives_core::CollectCollationInfo<Block> for Runtime {1114 fn collect_collation_info() -> cumulus_primitives_core::CollationInfo {1115 ParachainSystem::collect_collation_info()1116 }1117 }11181119 impl frame_system_rpc_runtime_api::AccountNonceApi<Block, AccountId, Index> for Runtime {1120 fn account_nonce(account: AccountId) -> Index {1121 System::account_nonce(account)1122 }1123 }11241125 impl pallet_transaction_payment_rpc_runtime_api::TransactionPaymentApi<Block, Balance> for Runtime {1126 fn query_info(uxt: <Block as BlockT>::Extrinsic, len: u32) -> RuntimeDispatchInfo<Balance> {1127 TransactionPayment::query_info(uxt, len)1128 }1129 fn query_fee_details(uxt: <Block as BlockT>::Extrinsic, len: u32) -> FeeDetails<Balance> {1130 TransactionPayment::query_fee_details(uxt, len)1131 }1132 }11331134 11351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175 #[cfg(feature = "runtime-benchmarks")]1176 impl frame_benchmarking::Benchmark<Block> for Runtime {1177 fn dispatch_benchmark(1178 config: frame_benchmarking::BenchmarkConfig1179 ) -> Result<Vec<frame_benchmarking::BenchmarkBatch>, sp_runtime::RuntimeString> {1180 use frame_benchmarking::{Benchmarking, BenchmarkBatch, add_benchmark, TrackedStorageKey};11811182 let whitelist: Vec<TrackedStorageKey> = vec![1183 1184 hex_literal::hex!("d43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d").to_vec().into(),1185 1186 1187 1188 1189 1190 1191 1192 1193 ];11941195 let mut batches = Vec::<BenchmarkBatch>::new();1196 let params = (&config, &whitelist);11971198 add_benchmark!(params, batches, pallet_evm_migration, EvmMigration);1199 add_benchmark!(params, batches, pallet_nft, Nft);1200 add_benchmark!(params, batches, pallet_inflation, Inflation);12011202 if batches.is_empty() { return Err("Benchmark not found for this pallet.".into()) }1203 Ok(batches)1204 }1205 }1206}12071208struct CheckInherents;12091210impl cumulus_pallet_parachain_system::CheckInherents<Block> for CheckInherents {1211 fn check_inherents(1212 block: &Block,1213 relay_state_proof: &cumulus_pallet_parachain_system::RelayChainStateProof,1214 ) -> sp_inherents::CheckInherentsResult {1215 let relay_chain_slot = relay_state_proof1216 .read_slot()1217 .expect("Could not read the relay chain slot from the proof");12181219 let inherent_data =1220 cumulus_primitives_timestamp::InherentDataProvider::from_relay_chain_slot_and_duration(1221 relay_chain_slot,1222 sp_std::time::Duration::from_secs(6),1223 )1224 .create_inherent_data()1225 .expect("Could not create the timestamp inherent data");12261227 inherent_data.check_extrinsics(block)1228 }1229}12301231cumulus_pallet_parachain_system::register_validate_block!(1232 Runtime = Runtime,1233 BlockExecutor = cumulus_pallet_aura_ext::BlockExecutor::<Runtime, Executive>,1234 CheckInherents = CheckInherents,1235);