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;104105pub type CrossAccountId = pallet_common::account::BasicCrossAccountId<Runtime>;106107108109pub type AccountIndex = u32;110111112pub type Balance = u128;113114115pub type Index = u32;116117118pub type Hash = sp_core::H256;119120121pub type DigestItem = generic::DigestItem<Hash>;122123124125126127pub mod opaque {128 use super::*;129130 pub use sp_runtime::OpaqueExtrinsic as UncheckedExtrinsic;131132 133 pub type Block = generic::Block<Header, UncheckedExtrinsic>;134135 pub type SessionHandlers = ();136137 impl_opaque_keys! {138 pub struct SessionKeys {139 pub aura: Aura,140 }141 }142}143144145pub const VERSION: RuntimeVersion = RuntimeVersion {146 spec_name: create_runtime_str!("opal"),147 impl_name: create_runtime_str!("opal"),148 authoring_version: 1,149 spec_version: 910000,150 impl_version: 1,151 apis: RUNTIME_API_VERSIONS,152 transaction_version: 1,153};154155pub const MILLISECS_PER_BLOCK: u64 = 12000;156157pub const SLOT_DURATION: u64 = MILLISECS_PER_BLOCK;158159160pub const MINUTES: BlockNumber = 60_000 / (MILLISECS_PER_BLOCK as BlockNumber);161pub const HOURS: BlockNumber = MINUTES * 60;162pub const DAYS: BlockNumber = HOURS * 24;163164parameter_types! {165 pub const DefaultSponsoringRateLimit: BlockNumber = 1 * DAYS;166}167168#[derive(codec::Encode, codec::Decode)]169pub enum XCMPMessage<XAccountId, XBalance> {170 171 TransferToken(XAccountId, XBalance),172}173174175#[cfg(feature = "std")]176pub fn native_version() -> NativeVersion {177 NativeVersion {178 runtime_version: VERSION,179 can_author_with: Default::default(),180 }181}182183type NegativeImbalance = <Balances as Currency<AccountId>>::NegativeImbalance;184185pub struct DealWithFees;186impl OnUnbalanced<NegativeImbalance> for DealWithFees {187 fn on_unbalanceds<B>(mut fees_then_tips: impl Iterator<Item = NegativeImbalance>) {188 if let Some(fees) = fees_then_tips.next() {189 190 let mut split = fees.ration(100, 0);191 if let Some(tips) = fees_then_tips.next() {192 193 tips.ration_merge_into(100, 0, &mut split);194 }195 Treasury::on_unbalanced(split.0);196 197 }198 }199}200201202203const AVERAGE_ON_INITIALIZE_RATIO: Perbill = Perbill::from_percent(10);204205206const NORMAL_DISPATCH_RATIO: Perbill = Perbill::from_percent(75);207208const MAXIMUM_BLOCK_WEIGHT: Weight = WEIGHT_PER_SECOND / 2;209210parameter_types! {211 pub const BlockHashCount: BlockNumber = 2400;212 pub RuntimeBlockLength: BlockLength =213 BlockLength::max_with_normal_ratio(5 * 1024 * 1024, NORMAL_DISPATCH_RATIO);214 pub const AvailableBlockRatio: Perbill = Perbill::from_percent(75);215 pub const MaximumBlockLength: u32 = 5 * 1024 * 1024;216 pub RuntimeBlockWeights: BlockWeights = BlockWeights::builder()217 .base_block(BlockExecutionWeight::get())218 .for_class(DispatchClass::all(), |weights| {219 weights.base_extrinsic = ExtrinsicBaseWeight::get();220 })221 .for_class(DispatchClass::Normal, |weights| {222 weights.max_total = Some(NORMAL_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT);223 })224 .for_class(DispatchClass::Operational, |weights| {225 weights.max_total = Some(MAXIMUM_BLOCK_WEIGHT);226 227 228 weights.reserved = Some(229 MAXIMUM_BLOCK_WEIGHT - NORMAL_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT230 );231 })232 .avg_block_initialization(AVERAGE_ON_INITIALIZE_RATIO)233 .build_or_panic();234 pub const Version: RuntimeVersion = VERSION;235 pub const SS58Prefix: u8 = 42;236}237238parameter_types! {239 pub const ChainId: u64 = 8888;240}241242pub struct FixedFee;243impl FeeCalculator for FixedFee {244 fn min_gas_price() -> U256 {245 1.into()246 }247}248249impl pallet_evm::Config for Runtime {250 type BlockGasLimit = BlockGasLimit;251 type FeeCalculator = FixedFee;252 type GasWeightMapping = ();253 type BlockHashMapping = pallet_ethereum::EthereumBlockHashMapping<Self>;254 type CallOrigin = EnsureAddressTruncated;255 type WithdrawOrigin = EnsureAddressTruncated;256 type AddressMapping = HashedAddressMapping<Self::Hashing>;257 type Precompiles = ();258 type Currency = Balances;259 type Event = Event;260 type OnMethodCall = (261 pallet_evm_migration::OnMethodCall<Self>,262 pallet_nft::NftErcSupport<Self>,263 pallet_evm_contract_helpers::HelpersOnMethodCall<Self>,264 );265 type OnCreate = pallet_evm_contract_helpers::HelpersOnCreate<Self>;266 type ChainId = ChainId;267 type Runner = pallet_evm::runner::stack::Runner<Self>;268 type OnChargeTransaction = pallet_evm_transaction_payment::OnChargeTransaction<Self>;269 type TransactionValidityHack = pallet_evm_transaction_payment::TransactionValidityHack<Self>;270 type FindAuthor = EthereumFindAuthor<Aura>;271}272273impl pallet_evm_migration::Config for Runtime {274 type WeightInfo = pallet_evm_migration::weights::SubstrateWeight<Self>;275}276277pub struct EthereumFindAuthor<F>(core::marker::PhantomData<F>);278impl<F: FindAuthor<u32>> FindAuthor<H160> for EthereumFindAuthor<F> {279 fn find_author<'a, I>(digests: I) -> Option<H160>280 where281 I: 'a + IntoIterator<Item = (ConsensusEngineId, &'a [u8])>,282 {283 if let Some(author_index) = F::find_author(digests) {284 let authority_id = Aura::authorities()[author_index as usize].clone();285 return Some(H160::from_slice(&authority_id.to_raw_vec()[4..24]));286 }287 None288 }289}290291parameter_types! {292 pub BlockGasLimit: U256 = U256::from(u32::max_value());293}294295impl pallet_ethereum::Config for Runtime {296 type Event = Event;297 type StateRoot = pallet_ethereum::IntermediateStateRoot;298 type EvmSubmitLog = pallet_evm::Pallet<Self>;299}300301impl pallet_randomness_collective_flip::Config for Runtime {}302303impl system::Config for Runtime {304 305 type AccountData = pallet_balances::AccountData<Balance>;306 307 type AccountId = AccountId;308 309 type BaseCallFilter = Everything;310 311 type BlockHashCount = BlockHashCount;312 313 type BlockLength = RuntimeBlockLength;314 315 type BlockNumber = BlockNumber;316 317 type BlockWeights = RuntimeBlockWeights;318 319 type Call = Call;320 321 type DbWeight = RocksDbWeight;322 323 type Event = Event;324 325 type Hash = Hash;326 327 type Hashing = BlakeTwo256;328 329 type Header = generic::Header<BlockNumber, BlakeTwo256>;330 331 type Index = Index;332 333 type Lookup = AccountIdLookup<AccountId, ()>;334 335 type OnKilledAccount = ();336 337 type OnNewAccount = ();338 type OnSetCode = cumulus_pallet_parachain_system::ParachainSetCode<Self>;339 340 type Origin = Origin;341 342 type PalletInfo = PalletInfo;343 344 type SS58Prefix = SS58Prefix;345 346 type SystemWeightInfo = system::weights::SubstrateWeight<Self>;347 348 type Version = Version;349}350351parameter_types! {352 pub const MinimumPeriod: u64 = SLOT_DURATION / 2;353}354355impl pallet_timestamp::Config for Runtime {356 357 type Moment = u64;358 type OnTimestampSet = ();359 type MinimumPeriod = MinimumPeriod;360 type WeightInfo = ();361}362363parameter_types! {364 365 pub const ExistentialDeposit: u128 = 0;366 pub const MaxLocks: u32 = 50;367}368369impl pallet_balances::Config for Runtime {370 type MaxLocks = MaxLocks;371 type MaxReserves = ();372 type ReserveIdentifier = [u8; 8];373 374 type Balance = Balance;375 376 type Event = Event;377 type DustRemoval = Treasury;378 type ExistentialDeposit = ExistentialDeposit;379 type AccountStore = System;380 type WeightInfo = pallet_balances::weights::SubstrateWeight<Self>;381}382383pub const MICROUNIQUE: Balance = 1_000_000_000;384pub const MILLIUNIQUE: Balance = 1_000 * MICROUNIQUE;385pub const CENTIUNIQUE: Balance = 10 * MILLIUNIQUE;386pub const UNIQUE: Balance = 100 * CENTIUNIQUE;387388pub const fn deposit(items: u32, bytes: u32) -> Balance {389 items as Balance * 15 * CENTIUNIQUE + (bytes as Balance) * 6 * CENTIUNIQUE390}391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442parameter_types! {443 pub const TransactionByteFee: Balance = 501 * MICROUNIQUE; 444}445446447pub struct LinearFee<T>(sp_std::marker::PhantomData<T>);448449impl<T> WeightToFeePolynomial for LinearFee<T>450where451 T: BaseArithmetic + From<u32> + Copy + Unsigned,452{453 type Balance = T;454455 fn polynomial() -> WeightToFeeCoefficients<Self::Balance> {456 smallvec!(WeightToFeeCoefficient {457 coeff_integer: 146_700u32.into(), 458 coeff_frac: Perbill::zero(),459 negative: false,460 degree: 1,461 })462 }463}464465impl pallet_transaction_payment::Config for Runtime {466 type OnChargeTransaction = pallet_transaction_payment::CurrencyAdapter<Balances, DealWithFees>;467 type TransactionByteFee = TransactionByteFee;468 type WeightToFee = LinearFee<Balance>;469 type FeeMultiplierUpdate = ();470}471472parameter_types! {473 pub const ProposalBond: Permill = Permill::from_percent(5);474 pub const ProposalBondMinimum: Balance = 1 * UNIQUE;475 pub const SpendPeriod: BlockNumber = 5 * MINUTES;476 pub const Burn: Permill = Permill::from_percent(0);477 pub const TipCountdown: BlockNumber = 1 * DAYS;478 pub const TipFindersFee: Percent = Percent::from_percent(20);479 pub const TipReportDepositBase: Balance = 1 * UNIQUE;480 pub const DataDepositPerByte: Balance = 1 * CENTIUNIQUE;481 pub const BountyDepositBase: Balance = 1 * UNIQUE;482 pub const BountyDepositPayoutDelay: BlockNumber = 1 * DAYS;483 pub const TreasuryModuleId: PalletId = PalletId(*b"py/trsry");484 pub const BountyUpdatePeriod: BlockNumber = 14 * DAYS;485 pub const MaximumReasonLength: u32 = 16384;486 pub const BountyCuratorDeposit: Permill = Permill::from_percent(50);487 pub const BountyValueMinimum: Balance = 5 * UNIQUE;488 pub const MaxApprovals: u32 = 100;489}490491impl pallet_treasury::Config for Runtime {492 type PalletId = TreasuryModuleId;493 type Currency = Balances;494 type ApproveOrigin = EnsureRoot<AccountId>;495 type RejectOrigin = EnsureRoot<AccountId>;496 type Event = Event;497 type OnSlash = ();498 type ProposalBond = ProposalBond;499 type ProposalBondMinimum = ProposalBondMinimum;500 type SpendPeriod = SpendPeriod;501 type Burn = Burn;502 type BurnDestination = ();503 type SpendFunds = ();504 type WeightInfo = pallet_treasury::weights::SubstrateWeight<Self>;505 type MaxApprovals = MaxApprovals;506}507508impl pallet_sudo::Config for Runtime {509 type Event = Event;510 type Call = Call;511}512513parameter_types! {514 pub const MinVestedTransfer: Balance = 10 * UNIQUE;515}516517impl pallet_vesting::Config for Runtime {518 type Event = Event;519 type Currency = Balances;520 type BlockNumberToBalance = ConvertInto;521 type MinVestedTransfer = MinVestedTransfer;522 type WeightInfo = ();523}524525parameter_types! {526 pub const ReservedDmpWeight: Weight = MAXIMUM_BLOCK_WEIGHT / 4;527 pub const ReservedXcmpWeight: Weight = MAXIMUM_BLOCK_WEIGHT / 4;528}529530impl cumulus_pallet_parachain_system::Config for Runtime {531 type Event = Event;532 type OnValidationData = ();533 type SelfParaId = parachain_info::Pallet<Self>;534 535 536 537 538 539 type OutboundXcmpMessageSource = XcmpQueue;540 type DmpMessageHandler = DmpQueue;541 type ReservedDmpWeight = ReservedDmpWeight;542 type ReservedXcmpWeight = ReservedXcmpWeight;543 type XcmpMessageHandler = XcmpQueue;544}545546impl parachain_info::Config for Runtime {}547548impl cumulus_pallet_aura_ext::Config for Runtime {}549550parameter_types! {551 pub const RelayLocation: MultiLocation = MultiLocation::parent();552 pub const RelayNetwork: NetworkId = NetworkId::Polkadot;553 pub RelayOrigin: Origin = cumulus_pallet_xcm::Origin::Relay.into();554 pub Ancestry: MultiLocation = Parachain(ParachainInfo::parachain_id().into()).into();555}556557558559560pub type LocationToAccountId = (561 562 ParentIsDefault<AccountId>,563 564 SiblingParachainConvertsVia<Sibling, AccountId>,565 566 AccountId32Aliases<RelayNetwork, AccountId>,567);568569570pub type LocalAssetTransactor = CurrencyAdapter<571 572 Balances,573 574 IsConcrete<RelayLocation>,575 576 LocationToAccountId,577 578 AccountId,579 580 (),581>;582583584585586pub type XcmOriginToTransactDispatchOrigin = (587 588 589 590 SovereignSignedViaLocation<LocationToAccountId, Origin>,591 592 593 RelayChainAsNative<RelayOrigin, Origin>,594 595 596 SiblingParachainAsNative<cumulus_pallet_xcm::Origin, Origin>,597 598 599 ParentAsSuperuser<Origin>,600 601 602 SignedAccountId32AsNative<RelayNetwork, Origin>,603 604 XcmPassthrough<Origin>,605);606607parameter_types! {608 609 pub UnitWeightCost: Weight = 1_000_000;610 611 pub const WeightPrice: (MultiLocation, u128) = (MultiLocation::parent(), 1_200 * UNIQUE);612}613614match_type! {615 pub type ParentOrParentsUnitPlurality: impl Contains<MultiLocation> = {616 MultiLocation { parents: 1, interior: Here } |617 MultiLocation { parents: 1, interior: X1(Plurality { id: BodyId::Unit, .. }) }618 };619}620621pub type Barrier = (622 TakeWeightCredit,623 AllowTopLevelPaidExecutionFrom<Everything>,624 AllowUnpaidExecutionFrom<ParentOrParentsUnitPlurality>,625 626);627628pub struct XcmConfig;629impl Config for XcmConfig {630 type Call = Call;631 type XcmSender = XcmRouter;632 633 type AssetTransactor = LocalAssetTransactor;634 type OriginConverter = XcmOriginToTransactDispatchOrigin;635 type IsReserve = NativeAsset;636 type IsTeleporter = (); 637 type LocationInverter = LocationInverter<Ancestry>;638 type Barrier = Barrier;639 type Weigher = FixedWeightBounds<UnitWeightCost, Call>;640 type Trader = UsingComponents<IdentityFee<Balance>, RelayLocation, AccountId, Balances, ()>;641 type ResponseHandler = (); 642 type SubscriptionService = PolkadotXcm;643}644645646647648649650pub type LocalOriginToLocation = (SignedToAccountId32<Origin, AccountId, RelayNetwork>,);651652653654pub type XcmRouter = (655 656 cumulus_primitives_utility::ParentAsUmp<ParachainSystem, ()>,657 658 XcmpQueue,659);660661impl pallet_evm_coder_substrate::Config for Runtime {662 type EthereumTransactionSender = pallet_ethereum::Pallet<Self>;663}664665impl pallet_xcm::Config for Runtime {666 type Event = Event;667 type SendXcmOrigin = EnsureXcmOrigin<Origin, LocalOriginToLocation>;668 type XcmRouter = XcmRouter;669 type ExecuteXcmOrigin = EnsureXcmOrigin<Origin, LocalOriginToLocation>;670 type XcmExecuteFilter = Everything;671 type XcmExecutor = XcmExecutor<XcmConfig>;672 type XcmTeleportFilter = Everything;673 type XcmReserveTransferFilter = ();674 type Weigher = FixedWeightBounds<UnitWeightCost, Call>;675 type LocationInverter = LocationInverter<Ancestry>;676}677678impl cumulus_pallet_xcm::Config for Runtime {679 type Event = Event;680 type XcmExecutor = XcmExecutor<XcmConfig>;681}682683impl cumulus_pallet_xcmp_queue::Config for Runtime {684 type Event = Event;685 type XcmExecutor = XcmExecutor<XcmConfig>;686 type ChannelInfo = ParachainSystem;687 type VersionWrapper = ();688}689690impl cumulus_pallet_dmp_queue::Config for Runtime {691 type Event = Event;692 type XcmExecutor = XcmExecutor<XcmConfig>;693 type ExecuteOverweightOrigin = frame_system::EnsureRoot<AccountId>;694}695696impl pallet_aura::Config for Runtime {697 type AuthorityId = AuraId;698 type DisabledValidators = ();699}700701parameter_types! {702 pub TreasuryAccountId: AccountId = TreasuryModuleId::get().into_account();703 pub const CollectionCreationPrice: Balance = 100 * UNIQUE;704}705706impl pallet_common::Config for Runtime {707 type Event = Event;708 type EvmBackwardsAddressMapping = pallet_common::account::MapBackwardsAddressTruncated;709 type EvmAddressMapping = HashedAddressMapping<Self::Hashing>;710 type CrossAccountId = pallet_common::account::BasicCrossAccountId<Self>;711712 type Currency = Balances;713 type CollectionCreationPrice = CollectionCreationPrice;714 type TreasuryAccountId = TreasuryAccountId;715}716717impl pallet_fungible::Config for Runtime {718 type WeightInfo = pallet_fungible::weights::SubstrateWeight<Self>;719}720impl pallet_refungible::Config for Runtime {721 type WeightInfo = pallet_refungible::weights::SubstrateWeight<Self>;722}723impl pallet_nonfungible::Config for Runtime {724 type WeightInfo = pallet_nonfungible::weights::SubstrateWeight<Self>;725}726727728impl pallet_nft::Config for Runtime {729 type WeightInfo = pallet_nft::weights::SubstrateWeight<Self>;730}731732parameter_types! {733 pub const InflationBlockInterval: BlockNumber = 100; 734}735736737impl pallet_inflation::Config for Runtime {738 type Currency = Balances;739 type TreasuryAccountId = TreasuryAccountId;740 type InflationBlockInterval = InflationBlockInterval;741}742743parameter_types! {744 pub MaximumSchedulerWeight: Weight = Perbill::from_percent(50) *745 RuntimeBlockWeights::get().max_block;746 pub const MaxScheduledPerBlock: u32 = 50;747}748749pub struct Sponsoring;750impl SponsoringResolve<AccountId, Call> for Sponsoring {751 fn resolve(who: &AccountId, call: &Call) -> Option<AccountId>752 where753 Call: Dispatchable<Info = DispatchInfo>,754 AccountId: AsRef<[u8]>,755 {756 pallet_nft_transaction_payment::Module::<Runtime>::withdraw_type(who, call)757 }758}759760type SponsorshipHandler = (761 pallet_nft::NftSponsorshipHandler<Runtime>,762 763);764765impl pallet_scheduler::Config for Runtime {766 type Event = Event;767 type Origin = Origin;768 type PalletsOrigin = OriginCaller;769 type Call = Call;770 type MaximumWeight = MaximumSchedulerWeight;771 type ScheduleOrigin = EnsureSigned<AccountId>;772 type MaxScheduledPerBlock = MaxScheduledPerBlock;773 type SponsorshipHandler = SponsorshipHandler;774 type WeightInfo = ();775}776777impl pallet_nft_transaction_payment::Config for Runtime {778 type SponsorshipHandler = SponsorshipHandler;779}780781impl pallet_evm_transaction_payment::Config for Runtime {782 type SponsorshipHandler = (783 pallet_nft::NftEthSponsorshipHandler<Self>,784 pallet_evm_contract_helpers::HelpersContractSponsoring<Self>,785 );786 type Currency = Balances;787}788789impl pallet_nft_charge_transaction::Config for Runtime {}790791792793794795parameter_types! {796 797 pub const HelpersContractAddress: H160 = H160([798 0x84, 0x28, 0x99, 0xec, 0xf3, 0x80, 0x55, 0x3e, 0x8a, 0x4d, 0xe7, 0x5b, 0xf5, 0x34, 0xcd, 0xf6, 0xfb, 0xf6, 0x40, 0x49,799 ]);800}801802impl pallet_evm_contract_helpers::Config for Runtime {803 type ContractAddress = HelpersContractAddress;804 type DefaultSponsoringRateLimit = DefaultSponsoringRateLimit;805}806807construct_runtime!(808 pub enum Runtime where809 Block = Block,810 NodeBlock = opaque::Block,811 UncheckedExtrinsic = UncheckedExtrinsic812 {813 ParachainSystem: cumulus_pallet_parachain_system::{Pallet, Call, Storage, Inherent, Event<T>, ValidateUnsigned} = 20,814 ParachainInfo: parachain_info::{Pallet, Storage, Config} = 21,815816 Aura: pallet_aura::{Pallet, Config<T>} = 22,817 AuraExt: cumulus_pallet_aura_ext::{Pallet, Config} = 23,818819 Balances: pallet_balances::{Pallet, Call, Storage, Config<T>, Event<T>} = 30,820 RandomnessCollectiveFlip: pallet_randomness_collective_flip::{Pallet, Storage} = 31,821 Timestamp: pallet_timestamp::{Pallet, Call, Storage, Inherent} = 32,822 TransactionPayment: pallet_transaction_payment::{Pallet, Storage} = 33,823 Treasury: pallet_treasury::{Pallet, Call, Storage, Config, Event<T>} = 34,824 Sudo: pallet_sudo::{Pallet, Call, Storage, Config<T>, Event<T>} = 35,825 System: system::{Pallet, Call, Storage, Config, Event<T>} = 36,826 Vesting: pallet_vesting::{Pallet, Call, Config<T>, Storage, Event<T>} = 37,827 828829 830 XcmpQueue: cumulus_pallet_xcmp_queue::{Pallet, Call, Storage, Event<T>} = 50,831 PolkadotXcm: pallet_xcm::{Pallet, Call, Event<T>, Origin} = 51,832 CumulusXcm: cumulus_pallet_xcm::{Pallet, Call, Event<T>, Origin} = 52,833 DmpQueue: cumulus_pallet_dmp_queue::{Pallet, Call, Storage, Event<T>} = 53,834835 836 Inflation: pallet_inflation::{Pallet, Call, Storage} = 60,837 Nft: pallet_nft::{Pallet, Call, Storage} = 61,838 Scheduler: pallet_scheduler::{Pallet, Call, Storage, Event<T>} = 62,839 NftPayment: pallet_nft_transaction_payment::{Pallet, Call, Storage} = 63,840 Charging: pallet_nft_charge_transaction::{Pallet, Call, Storage } = 64,841 842 Common: pallet_common::{Pallet, Storage, Event<T>} = 66,843 Fungible: pallet_fungible::{Pallet, Storage} = 67,844 Refungible: pallet_refungible::{Pallet, Storage} = 68,845 Nonfungible: pallet_nonfungible::{Pallet, Storage} = 69,846847 848 EVM: pallet_evm::{Pallet, Config, Call, Storage, Event<T>} = 100,849 Ethereum: pallet_ethereum::{Pallet, Config, Call, Storage, Event, ValidateUnsigned} = 101,850851 EvmCoderSubstrate: pallet_evm_coder_substrate::{Pallet, Storage} = 150,852 EvmContractHelpers: pallet_evm_contract_helpers::{Pallet, Storage} = 151,853 EvmTransactionPayment: pallet_evm_transaction_payment::{Pallet} = 152,854 EvmMigration: pallet_evm_migration::{Pallet, Call, Storage} = 153,855 }856);857858pub struct TransactionConverter;859860impl fp_rpc::ConvertTransaction<UncheckedExtrinsic> for TransactionConverter {861 fn convert_transaction(&self, transaction: pallet_ethereum::Transaction) -> UncheckedExtrinsic {862 UncheckedExtrinsic::new_unsigned(863 pallet_ethereum::Call::<Runtime>::transact(transaction).into(),864 )865 }866}867868impl fp_rpc::ConvertTransaction<opaque::UncheckedExtrinsic> for TransactionConverter {869 fn convert_transaction(870 &self,871 transaction: pallet_ethereum::Transaction,872 ) -> opaque::UncheckedExtrinsic {873 let extrinsic = UncheckedExtrinsic::new_unsigned(874 pallet_ethereum::Call::<Runtime>::transact(transaction).into(),875 );876 let encoded = extrinsic.encode();877 opaque::UncheckedExtrinsic::decode(&mut &encoded[..])878 .expect("Encoded extrinsic is always valid")879 }880}881882883pub type Address = sp_runtime::MultiAddress<AccountId, ()>;884885pub type Header = generic::Header<BlockNumber, BlakeTwo256>;886887pub type Block = generic::Block<Header, UncheckedExtrinsic>;888889pub type SignedBlock = generic::SignedBlock<Block>;890891pub type BlockId = generic::BlockId<Block>;892893pub type SignedExtra = (894 system::CheckSpecVersion<Runtime>,895 896 system::CheckGenesis<Runtime>,897 system::CheckEra<Runtime>,898 system::CheckNonce<Runtime>,899 system::CheckWeight<Runtime>,900 pallet_nft_charge_transaction::ChargeTransactionPayment<Runtime>,901 902);903904pub type UncheckedExtrinsic = generic::UncheckedExtrinsic<Address, Call, Signature, SignedExtra>;905906pub type CheckedExtrinsic = generic::CheckedExtrinsic<AccountId, Call, SignedExtra>;907908pub type Executive = frame_executive::Executive<909 Runtime,910 Block,911 frame_system::ChainContext<Runtime>,912 Runtime,913 AllPallets,914>;915916impl_opaque_keys! {917 pub struct SessionKeys {918 pub aura: Aura,919 }920}921922macro_rules! dispatch_nft_runtime {923 ($collection:ident.$method:ident($($name:ident),*)) => {{924 use pallet_nft::dispatch::Dispatched;925926 let collection = Dispatched::dispatch(<pallet_common::CollectionHandle<Runtime>>::new($collection).unwrap());927 let dispatch = collection.as_dyn();928929 dispatch.$method($($name),*)930 }};931}932933impl_runtime_apis! {934 impl up_rpc::NftApi<Block, CrossAccountId, AccountId>935 for Runtime936 {937 fn account_tokens(collection: CollectionId, account: CrossAccountId) -> Vec<TokenId> {938 dispatch_nft_runtime!(collection.account_tokens(account))939 }940 fn token_exists(collection: CollectionId, token: TokenId) -> bool {941 dispatch_nft_runtime!(collection.token_exists(token))942 }943944 fn token_owner(collection: CollectionId, token: TokenId) -> CrossAccountId {945 dispatch_nft_runtime!(collection.token_owner(token))946 }947 fn const_metadata(collection: CollectionId, token: TokenId) -> Vec<u8> {948 dispatch_nft_runtime!(collection.const_metadata(token))949 }950 fn variable_metadata(collection: CollectionId, token: TokenId) -> Vec<u8> {951 dispatch_nft_runtime!(collection.variable_metadata(token))952 }953954 fn collection_tokens(collection: CollectionId) -> u32 {955 dispatch_nft_runtime!(collection.collection_tokens())956 }957 fn account_balance(collection: CollectionId, account: CrossAccountId) -> u32 {958 dispatch_nft_runtime!(collection.account_balance(account))959 }960 fn balance(collection: CollectionId, account: CrossAccountId, token: TokenId) -> u128 {961 dispatch_nft_runtime!(collection.balance(account, token))962 }963 fn allowance(964 collection: CollectionId,965 sender: CrossAccountId,966 spender: CrossAccountId,967 token: TokenId,968 ) -> u128 {969 dispatch_nft_runtime!(collection.allowance(sender, spender, token))970 }971972 fn eth_contract_code(account: H160) -> Option<Vec<u8>> {973 <pallet_nft::NftErcSupport<Runtime>>::get_code(&account)974 }975 fn adminlist(collection: CollectionId) -> Vec<AccountId> {976 <pallet_nft::Pallet<Runtime>>::adminlist(collection)977 }978 fn allowlist(collection: CollectionId) -> Vec<AccountId> {979 <pallet_nft::Pallet<Runtime>>::allowlist(collection)980 }981 fn last_token_id(collection: CollectionId) -> TokenId {982 dispatch_nft_runtime!(collection.last_token_id())983 }984 }985986 impl sp_api::Core<Block> for Runtime {987 fn version() -> RuntimeVersion {988 VERSION989 }990991 fn execute_block(block: Block) {992 Executive::execute_block(block)993 }994995 fn initialize_block(header: &<Block as BlockT>::Header) {996 Executive::initialize_block(header)997 }998 }9991000 impl sp_api::Metadata<Block> for Runtime {1001 fn metadata() -> OpaqueMetadata {1002 Runtime::metadata().into()1003 }1004 }10051006 impl sp_block_builder::BlockBuilder<Block> for Runtime {1007 fn apply_extrinsic(extrinsic: <Block as BlockT>::Extrinsic) -> ApplyExtrinsicResult {1008 Executive::apply_extrinsic(extrinsic)1009 }10101011 fn finalize_block() -> <Block as BlockT>::Header {1012 Executive::finalize_block()1013 }10141015 fn inherent_extrinsics(data: sp_inherents::InherentData) -> Vec<<Block as BlockT>::Extrinsic> {1016 data.create_extrinsics()1017 }10181019 fn check_inherents(1020 block: Block,1021 data: sp_inherents::InherentData,1022 ) -> sp_inherents::CheckInherentsResult {1023 data.check_extrinsics(&block)1024 }10251026 1027 1028 1029 }10301031 impl sp_transaction_pool::runtime_api::TaggedTransactionQueue<Block> for Runtime {1032 fn validate_transaction(1033 source: TransactionSource,1034 tx: <Block as BlockT>::Extrinsic,1035 hash: <Block as BlockT>::Hash,1036 ) -> TransactionValidity {1037 Executive::validate_transaction(source, tx, hash)1038 }1039 }10401041 impl sp_offchain::OffchainWorkerApi<Block> for Runtime {1042 fn offchain_worker(header: &<Block as BlockT>::Header) {1043 Executive::offchain_worker(header)1044 }1045 }10461047 impl fp_rpc::EthereumRuntimeRPCApi<Block> for Runtime {1048 fn chain_id() -> u64 {1049 <Runtime as pallet_evm::Config>::ChainId::get()1050 }10511052 fn account_basic(address: H160) -> EVMAccount {1053 EVM::account_basic(&address)1054 }10551056 fn gas_price() -> U256 {1057 <Runtime as pallet_evm::Config>::FeeCalculator::min_gas_price()1058 }10591060 fn account_code_at(address: H160) -> Vec<u8> {1061 EVM::account_codes(address)1062 }10631064 fn author() -> H160 {1065 <pallet_evm::Pallet<Runtime>>::find_author()1066 }10671068 fn storage_at(address: H160, index: U256) -> H256 {1069 let mut tmp = [0u8; 32];1070 index.to_big_endian(&mut tmp);1071 EVM::account_storages(address, H256::from_slice(&tmp[..]))1072 }10731074 fn call(1075 from: H160,1076 to: H160,1077 data: Vec<u8>,1078 value: U256,1079 gas_limit: U256,1080 gas_price: Option<U256>,1081 nonce: Option<U256>,1082 estimate: bool,1083 ) -> Result<pallet_evm::CallInfo, sp_runtime::DispatchError> {1084 let config = if estimate {1085 let mut config = <Runtime as pallet_evm::Config>::config().clone();1086 config.estimate = true;1087 Some(config)1088 } else {1089 None1090 };10911092 <Runtime as pallet_evm::Config>::Runner::call(1093 from,1094 to,1095 data,1096 value,1097 gas_limit.low_u64(),1098 gas_price,1099 nonce,1100 config.as_ref().unwrap_or_else(|| <Runtime as pallet_evm::Config>::config()),1101 ).map_err(|err| err.into())1102 }11031104 fn create(1105 from: H160,1106 data: Vec<u8>,1107 value: U256,1108 gas_limit: U256,1109 gas_price: Option<U256>,1110 nonce: Option<U256>,1111 estimate: bool,1112 ) -> Result<pallet_evm::CreateInfo, sp_runtime::DispatchError> {1113 let config = if estimate {1114 let mut config = <Runtime as pallet_evm::Config>::config().clone();1115 config.estimate = true;1116 Some(config)1117 } else {1118 None1119 };11201121 <Runtime as pallet_evm::Config>::Runner::create(1122 from,1123 data,1124 value,1125 gas_limit.low_u64(),1126 gas_price,1127 nonce,1128 config.as_ref().unwrap_or_else(|| <Runtime as pallet_evm::Config>::config()),1129 ).map_err(|err| err.into())1130 }11311132 fn current_transaction_statuses() -> Option<Vec<TransactionStatus>> {1133 Ethereum::current_transaction_statuses()1134 }11351136 fn current_block() -> Option<pallet_ethereum::Block> {1137 Ethereum::current_block()1138 }11391140 fn current_receipts() -> Option<Vec<pallet_ethereum::Receipt>> {1141 Ethereum::current_receipts()1142 }11431144 fn current_all() -> (1145 Option<pallet_ethereum::Block>,1146 Option<Vec<pallet_ethereum::Receipt>>,1147 Option<Vec<TransactionStatus>>1148 ) {1149 (1150 Ethereum::current_block(),1151 Ethereum::current_receipts(),1152 Ethereum::current_transaction_statuses()1153 )1154 }11551156 fn extrinsic_filter(xts: Vec<<Block as sp_api::BlockT>::Extrinsic>) -> Vec<pallet_ethereum::Transaction> {1157 xts.into_iter().filter_map(|xt| match xt.function {1158 Call::Ethereum(pallet_ethereum::Call::transact(t)) => Some(t),1159 _ => None1160 }).collect()1161 }1162 }11631164 impl sp_session::SessionKeys<Block> for Runtime {1165 fn decode_session_keys(1166 encoded: Vec<u8>,1167 ) -> Option<Vec<(Vec<u8>, KeyTypeId)>> {1168 SessionKeys::decode_into_raw_public_keys(&encoded)1169 }11701171 fn generate_session_keys(seed: Option<Vec<u8>>) -> Vec<u8> {1172 SessionKeys::generate(seed)1173 }1174 }11751176 impl sp_consensus_aura::AuraApi<Block, AuraId> for Runtime {1177 fn slot_duration() -> sp_consensus_aura::SlotDuration {1178 sp_consensus_aura::SlotDuration::from_millis(Aura::slot_duration())1179 }11801181 fn authorities() -> Vec<AuraId> {1182 Aura::authorities()1183 }1184 }11851186 impl cumulus_primitives_core::CollectCollationInfo<Block> for Runtime {1187 fn collect_collation_info() -> cumulus_primitives_core::CollationInfo {1188 ParachainSystem::collect_collation_info()1189 }1190 }11911192 impl frame_system_rpc_runtime_api::AccountNonceApi<Block, AccountId, Index> for Runtime {1193 fn account_nonce(account: AccountId) -> Index {1194 System::account_nonce(account)1195 }1196 }11971198 impl pallet_transaction_payment_rpc_runtime_api::TransactionPaymentApi<Block, Balance> for Runtime {1199 fn query_info(uxt: <Block as BlockT>::Extrinsic, len: u32) -> RuntimeDispatchInfo<Balance> {1200 TransactionPayment::query_info(uxt, len)1201 }1202 fn query_fee_details(uxt: <Block as BlockT>::Extrinsic, len: u32) -> FeeDetails<Balance> {1203 TransactionPayment::query_fee_details(uxt, len)1204 }1205 }12061207 12081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248 #[cfg(feature = "runtime-benchmarks")]1249 impl frame_benchmarking::Benchmark<Block> for Runtime {1250 fn dispatch_benchmark(1251 config: frame_benchmarking::BenchmarkConfig1252 ) -> Result<Vec<frame_benchmarking::BenchmarkBatch>, sp_runtime::RuntimeString> {1253 use frame_benchmarking::{Benchmarking, BenchmarkBatch, add_benchmark, TrackedStorageKey};12541255 let whitelist: Vec<TrackedStorageKey> = vec![1256 1257 hex_literal::hex!("d43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d").to_vec().into(),1258 1259 1260 1261 1262 1263 1264 1265 1266 ];12671268 let mut batches = Vec::<BenchmarkBatch>::new();1269 let params = (&config, &whitelist);12701271 add_benchmark!(params, batches, pallet_evm_migration, EvmMigration);1272 add_benchmark!(params, batches, pallet_nft, Nft);1273 add_benchmark!(params, batches, pallet_inflation, Inflation);12741275 if batches.is_empty() { return Err("Benchmark not found for this pallet.".into()) }1276 Ok(batches)1277 }1278 }1279}12801281struct CheckInherents;12821283impl cumulus_pallet_parachain_system::CheckInherents<Block> for CheckInherents {1284 fn check_inherents(1285 block: &Block,1286 relay_state_proof: &cumulus_pallet_parachain_system::RelayChainStateProof,1287 ) -> sp_inherents::CheckInherentsResult {1288 let relay_chain_slot = relay_state_proof1289 .read_slot()1290 .expect("Could not read the relay chain slot from the proof");12911292 let inherent_data =1293 cumulus_primitives_timestamp::InherentDataProvider::from_relay_chain_slot_and_duration(1294 relay_chain_slot,1295 sp_std::time::Duration::from_secs(6),1296 )1297 .create_inherent_data()1298 .expect("Could not create the timestamp inherent data");12991300 inherent_data.check_extrinsics(block)1301 }1302}13031304cumulus_pallet_parachain_system::register_validate_block!(1305 Runtime = Runtime,1306 BlockExecutor = cumulus_pallet_aura_ext::BlockExecutor::<Runtime, Executive>,1307 CheckInherents = CheckInherents,1308);