difftreelog
fix export RpcCollection to metadata
in: master
4 files changed
pallets/common/src/lib.rsdiffbeforeafterboth--- a/pallets/common/src/lib.rs
+++ b/pallets/common/src/lib.rs
@@ -33,7 +33,7 @@
COLLECTION_ADMINS_LIMIT, MetaUpdatePermission, TokenId, CollectionStats, MAX_TOKEN_OWNERSHIP,
CollectionMode, NFT_SPONSOR_TRANSFER_TIMEOUT, FUNGIBLE_SPONSOR_TRANSFER_TIMEOUT,
REFUNGIBLE_SPONSOR_TRANSFER_TIMEOUT, MAX_SPONSOR_TIMEOUT, CUSTOM_DATA_LIMIT, CollectionLimits,
- CustomDataLimit, CreateCollectionData, SponsorshipState, CreateItemExData, SponsoringRateLimit, budget::Budget, COLLECTION_FIELD_LIMIT, CollectionField,
+ CustomDataLimit, CreateCollectionData, SponsorshipState, CreateItemExData, SponsoringRateLimit, budget::Budget, COLLECTION_FIELD_LIMIT, CollectionField, PhantomType,
};
pub use pallet::*;
use sp_core::H160;
@@ -415,8 +415,8 @@
/// Not used by code, exists only to provide some types to metadata
#[pallet::storage]
- pub type DummyStorageValue<T> =
- StorageValue<Value = (CollectionStats, CollectionId, TokenId), QueryKind = OptionQuery>;
+ pub type DummyStorageValue<T: Config> =
+ StorageValue<Value = (CollectionStats, CollectionId, TokenId, PhantomType<RpcCollection<T::AccountId>>), QueryKind = OptionQuery>;
#[pallet::hooks]
impl<T: Config> Hooks<BlockNumberFor<T>> for Pallet<T> {
primitives/data-structs/src/lib.rsdiffbeforeafterboth--- a/primitives/data-structs/src/lib.rs
+++ b/primitives/data-structs/src/lib.rs
@@ -583,3 +583,24 @@
pub destroyed: u32,
pub alive: u32,
}
+
+#[derive(Encode, Decode, PartialEq, Clone, Debug)]
+pub struct PhantomType<T>(core::marker::PhantomData<T>);
+
+impl<T: TypeInfo + 'static> TypeInfo for PhantomType<T> {
+ type Identity = PhantomType<T>;
+
+ fn type_info() -> scale_info::Type {
+ use scale_info::{Type, Path, build::{FieldsBuilder, UnnamedFields}};
+ Type::builder()
+ .path(Path::new("up_data_structs", "PhantomType"))
+ .composite(<FieldsBuilder<UnnamedFields>>::default().field(|b|
+ b.ty::<[T ;0]>()
+ ))
+ }
+}
+impl<T> MaxEncodedLen for PhantomType<T> {
+ fn max_encoded_len() -> usize {
+ 0
+ }
+}
\ No newline at end of file
runtime/opal/src/lib.rsdiffbeforeafterboth1// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.2// This file is part of Unique Network.34// Unique Network is free software: you can redistribute it and/or modify5// it under the terms of the GNU General Public License as published by6// the Free Software Foundation, either version 3 of the License, or7// (at your option) any later version.89// Unique Network is distributed in the hope that it will be useful,10// but WITHOUT ANY WARRANTY; without even the implied warranty of11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the12// GNU General Public License for more details.1314// You should have received a copy of the GNU General Public License15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.1617//! The Substrate Node Template runtime. This can be compiled with `#[no_std]`, ready for Wasm.1819#![cfg_attr(not(feature = "std"), no_std)]20// `construct_runtime!` does a lot of recursion and requires us to increase the limit to 256.21#![recursion_limit = "1024"]22#![allow(clippy::from_over_into, clippy::identity_op)]23#![allow(clippy::fn_to_numeric_cast_with_truncation)]24// Make the WASM binary available.25#[cfg(feature = "std")]26include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs"));2728use sp_api::impl_runtime_apis;29use sp_core::{crypto::KeyTypeId, OpaqueMetadata, H256, U256, H160};30use sp_runtime::DispatchError;31// #[cfg(any(feature = "std", test))]32// pub use sp_runtime::BuildStorage;3334use sp_runtime::{35 Permill, Perbill, Percent, create_runtime_str, generic, impl_opaque_keys,36 traits::{AccountIdLookup, BlakeTwo256, Block as BlockT, AccountIdConversion, Zero},37 transaction_validity::{TransactionSource, TransactionValidity},38 ApplyExtrinsicResult, RuntimeAppPublic,39};4041use sp_std::prelude::*;4243#[cfg(feature = "std")]44use sp_version::NativeVersion;45use sp_version::RuntimeVersion;46pub use pallet_transaction_payment::{47 Multiplier, TargetedFeeAdjustment, FeeDetails, RuntimeDispatchInfo,48};49// A few exports that help ease life for downstream crates.50pub use pallet_balances::Call as BalancesCall;51pub use pallet_evm::{52 EnsureAddressTruncated, HashedAddressMapping, Runner, account::CrossAccountId as _,53};54pub use frame_support::{55 construct_runtime, match_types,56 dispatch::DispatchResult,57 PalletId, parameter_types, StorageValue, ConsensusEngineId,58 traits::{59 tokens::currency::Currency as CurrencyT, OnUnbalanced as OnUnbalancedT, Everything,60 Currency, ExistenceRequirement, Get, IsInVec, KeyOwnerProofSystem, LockIdentifier,61 OnUnbalanced, Randomness, FindAuthor, ConstU32, Imbalance,62 },63 weights::{64 constants::{BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight, WEIGHT_PER_SECOND},65 DispatchClass, DispatchInfo, GetDispatchInfo, IdentityFee, Pays, PostDispatchInfo, Weight,66 WeightToFeePolynomial, WeightToFeeCoefficient, WeightToFeeCoefficients, ConstantMultiplier,67 },68};69use up_data_structs::mapping::{EvmTokenAddressMapping, CrossTokenAddressMapping};70use up_data_structs::{CollectionId, TokenId, CollectionStats, Collection, RpcCollection};71// use pallet_contracts::weights::WeightInfo;72// #[cfg(any(feature = "std", test))]73use frame_system::{74 self as frame_system, EnsureRoot, EnsureSigned,75 limits::{BlockWeights, BlockLength},76};77use sp_arithmetic::{78 traits::{BaseArithmetic, Unsigned},79};80use smallvec::smallvec;81use codec::{Encode, Decode};82use pallet_evm::{Account as EVMAccount, FeeCalculator, GasWeightMapping};83use fp_rpc::TransactionStatus;84use sp_runtime::{85 traits::{BlockNumberProvider, Dispatchable, PostDispatchInfoOf, Saturating},86 transaction_validity::TransactionValidityError,87 SaturatedConversion,88};8990// pub use pallet_timestamp::Call as TimestampCall;91pub use sp_consensus_aura::sr25519::AuthorityId as AuraId;9293// Polkadot imports94use pallet_xcm::XcmPassthrough;95use polkadot_parachain::primitives::Sibling;96use xcm::v1::{BodyId, Junction::*, MultiLocation, NetworkId, Junctions::*};97use xcm_builder::{98 AccountId32Aliases, AllowTopLevelPaidExecutionFrom, AllowUnpaidExecutionFrom, CurrencyAdapter,99 EnsureXcmOrigin, FixedWeightBounds, LocationInverter, NativeAsset, ParentAsSuperuser,100 RelayChainAsNative, SiblingParachainAsNative, SiblingParachainConvertsVia,101 SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit,102 ParentIsPreset,103};104use xcm_executor::{Config, XcmExecutor, Assets};105use sp_std::{marker::PhantomData};106107use xcm::latest::{108 // Xcm,109 AssetId::{Concrete},110 Fungibility::Fungible as XcmFungible,111 MultiAsset,112 Error as XcmError,113};114use xcm_executor::traits::{MatchesFungible, WeightTrader};115//use xcm_executor::traits::MatchesFungible;116use sp_runtime::traits::CheckedConversion;117118use unique_runtime_common::{119 impl_common_runtime_apis,120 types::*,121 constants::*,122 dispatch::{CollectionDispatchT, CollectionDispatch},123};124125pub const RUNTIME_NAME: &str = "opal";126pub const TOKEN_SYMBOL: &str = "OPL";127128type CrossAccountId = pallet_evm::account::BasicCrossAccountId<Runtime>;129130impl RuntimeInstance for Runtime {131 type CrossAccountId = self::CrossAccountId;132 type TransactionConverter = self::TransactionConverter;133134 fn get_transaction_converter() -> TransactionConverter {135 TransactionConverter136 }137}138139/// The type for looking up accounts. We don't expect more than 4 billion of them, but you140/// never know...141pub type AccountIndex = u32;142143/// Balance of an account.144pub type Balance = u128;145146/// Index of a transaction in the chain.147pub type Index = u32;148149/// A hash of some data used by the chain.150pub type Hash = sp_core::H256;151152/// Digest item type.153pub type DigestItem = generic::DigestItem;154155/// Opaque types. These are used by the CLI to instantiate machinery that don't need to know156/// the specifics of the runtime. They can then be made to be agnostic over specific formats157/// of data like extrinsics, allowing for them to continue syncing the network through upgrades158/// to even the core data structures.159pub mod opaque {160 use sp_std::prelude::*;161 use sp_runtime::impl_opaque_keys;162 use super::Aura;163164 pub use unique_runtime_common::types::*;165166 impl_opaque_keys! {167 pub struct SessionKeys {168 pub aura: Aura,169 }170 }171}172173/// This runtime version.174pub const VERSION: RuntimeVersion = RuntimeVersion {175 spec_name: create_runtime_str!(RUNTIME_NAME),176 impl_name: create_runtime_str!(RUNTIME_NAME),177 authoring_version: 1,178 spec_version: 920000,179 impl_version: 0,180 apis: RUNTIME_API_VERSIONS,181 transaction_version: 1,182 state_version: 0,183};184185#[derive(codec::Encode, codec::Decode)]186pub enum XCMPMessage<XAccountId, XBalance> {187 /// Transfer tokens to the given account from the Parachain account.188 TransferToken(XAccountId, XBalance),189}190191/// The version information used to identify this runtime when compiled natively.192#[cfg(feature = "std")]193pub fn native_version() -> NativeVersion {194 NativeVersion {195 runtime_version: VERSION,196 can_author_with: Default::default(),197 }198}199200type NegativeImbalance = <Balances as Currency<AccountId>>::NegativeImbalance;201202pub struct DealWithFees;203impl OnUnbalanced<NegativeImbalance> for DealWithFees {204 fn on_unbalanceds<B>(mut fees_then_tips: impl Iterator<Item = NegativeImbalance>) {205 if let Some(fees) = fees_then_tips.next() {206 // for fees, 100% to treasury207 let mut split = fees.ration(100, 0);208 if let Some(tips) = fees_then_tips.next() {209 // for tips, if any, 100% to treasury210 tips.ration_merge_into(100, 0, &mut split);211 }212 Treasury::on_unbalanced(split.0);213 // Author::on_unbalanced(split.1);214 }215 }216}217218parameter_types! {219 pub const BlockHashCount: BlockNumber = 2400;220 pub RuntimeBlockLength: BlockLength =221 BlockLength::max_with_normal_ratio(5 * 1024 * 1024, NORMAL_DISPATCH_RATIO);222 pub const AvailableBlockRatio: Perbill = Perbill::from_percent(75);223 pub const MaximumBlockLength: u32 = 5 * 1024 * 1024;224 pub RuntimeBlockWeights: BlockWeights = BlockWeights::builder()225 .base_block(BlockExecutionWeight::get())226 .for_class(DispatchClass::all(), |weights| {227 weights.base_extrinsic = ExtrinsicBaseWeight::get();228 })229 .for_class(DispatchClass::Normal, |weights| {230 weights.max_total = Some(NORMAL_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT);231 })232 .for_class(DispatchClass::Operational, |weights| {233 weights.max_total = Some(MAXIMUM_BLOCK_WEIGHT);234 // Operational transactions have some extra reserved space, so that they235 // are included even if block reached `MAXIMUM_BLOCK_WEIGHT`.236 weights.reserved = Some(237 MAXIMUM_BLOCK_WEIGHT - NORMAL_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT238 );239 })240 .avg_block_initialization(AVERAGE_ON_INITIALIZE_RATIO)241 .build_or_panic();242 pub const Version: RuntimeVersion = VERSION;243 pub const SS58Prefix: u8 = 42;244}245246parameter_types! {247 pub const ChainId: u64 = 8882;248}249250pub struct FixedFee;251impl FeeCalculator for FixedFee {252 fn min_gas_price() -> U256 {253 MIN_GAS_PRICE.into()254 }255}256257// Assuming slowest ethereum opcode is SSTORE, with gas price of 20000 as our worst case258// (contract, which only writes a lot of data),259// approximating on top of our real store write weight260parameter_types! {261 pub const WritesPerSecond: u64 = WEIGHT_PER_SECOND / <Runtime as frame_system::Config>::DbWeight::get().write;262 pub const GasPerSecond: u64 = WritesPerSecond::get() * 20000;263 pub const WeightPerGas: u64 = WEIGHT_PER_SECOND / GasPerSecond::get();264}265266/// Limiting EVM execution to 50% of block for substrate users and management tasks267/// EVM transaction consumes more weight than substrate's, so we can't rely on them being268/// scheduled fairly269const EVM_DISPATCH_RATIO: Perbill = Perbill::from_percent(50);270parameter_types! {271 pub BlockGasLimit: U256 = U256::from(NORMAL_DISPATCH_RATIO * EVM_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT / WeightPerGas::get());272}273274pub enum FixedGasWeightMapping {}275impl GasWeightMapping for FixedGasWeightMapping {276 fn gas_to_weight(gas: u64) -> Weight {277 gas.saturating_mul(WeightPerGas::get())278 }279 fn weight_to_gas(weight: Weight) -> u64 {280 weight / WeightPerGas::get()281 }282}283284impl pallet_evm::account::Config for Runtime {285 type CrossAccountId = pallet_evm::account::BasicCrossAccountId<Self>;286 type EvmAddressMapping = pallet_evm::HashedAddressMapping<Self::Hashing>;287 type EvmBackwardsAddressMapping = fp_evm_mapping::MapBackwardsAddressTruncated;288}289290impl pallet_evm::Config for Runtime {291 type BlockGasLimit = BlockGasLimit;292 type FeeCalculator = FixedFee;293 type GasWeightMapping = FixedGasWeightMapping;294 type BlockHashMapping = pallet_ethereum::EthereumBlockHashMapping<Self>;295 type CallOrigin = EnsureAddressTruncated;296 type WithdrawOrigin = EnsureAddressTruncated;297 type AddressMapping = HashedAddressMapping<Self::Hashing>;298 type PrecompilesType = ();299 type PrecompilesValue = ();300 type Currency = Balances;301 type Event = Event;302 type OnMethodCall = (303 pallet_evm_migration::OnMethodCall<Self>,304 pallet_evm_contract_helpers::HelpersOnMethodCall<Self>,305 CollectionDispatchT<Self>,306 );307 type OnCreate = pallet_evm_contract_helpers::HelpersOnCreate<Self>;308 type ChainId = ChainId;309 type Runner = pallet_evm::runner::stack::Runner<Self>;310 type OnChargeTransaction = pallet_evm::EVMCurrencyAdapter<Balances, DealWithFees>;311 type TransactionValidityHack = pallet_evm_transaction_payment::TransactionValidityHack<Self>;312 type FindAuthor = EthereumFindAuthor<Aura>;313}314315impl pallet_evm_migration::Config for Runtime {316 type WeightInfo = pallet_evm_migration::weights::SubstrateWeight<Self>;317}318319pub struct EthereumFindAuthor<F>(core::marker::PhantomData<F>);320impl<F: FindAuthor<u32>> FindAuthor<H160> for EthereumFindAuthor<F> {321 fn find_author<'a, I>(digests: I) -> Option<H160>322 where323 I: 'a + IntoIterator<Item = (ConsensusEngineId, &'a [u8])>,324 {325 if let Some(author_index) = F::find_author(digests) {326 let authority_id = Aura::authorities()[author_index as usize].clone();327 return Some(H160::from_slice(&authority_id.to_raw_vec()[4..24]));328 }329 None330 }331}332333impl pallet_ethereum::Config for Runtime {334 type Event = Event;335 type StateRoot = pallet_ethereum::IntermediateStateRoot<Self>;336}337338impl pallet_randomness_collective_flip::Config for Runtime {}339340impl frame_system::Config for Runtime {341 /// The data to be stored in an account.342 type AccountData = pallet_balances::AccountData<Balance>;343 /// The identifier used to distinguish between accounts.344 type AccountId = AccountId;345 /// The basic call filter to use in dispatchable.346 type BaseCallFilter = Everything;347 /// Maximum number of block number to block hash mappings to keep (oldest pruned first).348 type BlockHashCount = BlockHashCount;349 /// The maximum length of a block (in bytes).350 type BlockLength = RuntimeBlockLength;351 /// The index type for blocks.352 type BlockNumber = BlockNumber;353 /// The weight of the overhead invoked on the block import process, independent of the extrinsics included in that block.354 type BlockWeights = RuntimeBlockWeights;355 /// The aggregated dispatch type that is available for extrinsics.356 type Call = Call;357 /// The weight of database operations that the runtime can invoke.358 type DbWeight = RocksDbWeight;359 /// The ubiquitous event type.360 type Event = Event;361 /// The type for hashing blocks and tries.362 type Hash = Hash;363 /// The hashing algorithm used.364 type Hashing = BlakeTwo256;365 /// The header type.366 type Header = generic::Header<BlockNumber, BlakeTwo256>;367 /// The index type for storing how many extrinsics an account has signed.368 type Index = Index;369 /// The lookup mechanism to get account ID from whatever is passed in dispatchers.370 type Lookup = AccountIdLookup<AccountId, ()>;371 /// What to do if an account is fully reaped from the system.372 type OnKilledAccount = ();373 /// What to do if a new account is created.374 type OnNewAccount = ();375 type OnSetCode = cumulus_pallet_parachain_system::ParachainSetCode<Self>;376 /// The ubiquitous origin type.377 type Origin = Origin;378 /// This type is being generated by `construct_runtime!`.379 type PalletInfo = PalletInfo;380 /// This is used as an identifier of the chain. 42 is the generic substrate prefix.381 type SS58Prefix = SS58Prefix;382 /// Weight information for the extrinsics of this pallet.383 type SystemWeightInfo = frame_system::weights::SubstrateWeight<Self>;384 /// Version of the runtime.385 type Version = Version;386 type MaxConsumers = ConstU32<16>;387}388389parameter_types! {390 pub const MinimumPeriod: u64 = SLOT_DURATION / 2;391}392393impl pallet_timestamp::Config for Runtime {394 /// A timestamp: milliseconds since the unix epoch.395 type Moment = u64;396 type OnTimestampSet = ();397 type MinimumPeriod = MinimumPeriod;398 type WeightInfo = ();399}400401parameter_types! {402 // pub const ExistentialDeposit: u128 = 500;403 pub const ExistentialDeposit: u128 = 0;404 pub const MaxLocks: u32 = 50;405}406407impl pallet_balances::Config for Runtime {408 type MaxLocks = MaxLocks;409 type MaxReserves = ();410 type ReserveIdentifier = [u8; 8];411 /// The type for recording an account's balance.412 type Balance = Balance;413 /// The ubiquitous event type.414 type Event = Event;415 type DustRemoval = Treasury;416 type ExistentialDeposit = ExistentialDeposit;417 type AccountStore = System;418 type WeightInfo = pallet_balances::weights::SubstrateWeight<Self>;419}420421pub const fn deposit(items: u32, bytes: u32) -> Balance {422 items as Balance * 15 * CENTIUNIQUE + (bytes as Balance) * 6 * CENTIUNIQUE423}424425/*426parameter_types! {427 pub TombstoneDeposit: Balance = deposit(428 1,429 sp_std::mem::size_of::<pallet_contracts::Pallet<Runtime>> as u32,430 );431 pub DepositPerContract: Balance = TombstoneDeposit::get();432 pub const DepositPerStorageByte: Balance = deposit(0, 1);433 pub const DepositPerStorageItem: Balance = deposit(1, 0);434 pub RentFraction: Perbill = Perbill::from_rational(1u32, 30 * DAYS);435 pub const SurchargeReward: Balance = 150 * MILLIUNIQUE;436 pub const SignedClaimHandicap: u32 = 2;437 pub const MaxDepth: u32 = 32;438 pub const MaxValueSize: u32 = 16 * 1024;439 pub const MaxCodeSize: u32 = 1024 * 1024 * 25; // 25 Mb440 // The lazy deletion runs inside on_initialize.441 pub DeletionWeightLimit: Weight = AVERAGE_ON_INITIALIZE_RATIO *442 RuntimeBlockWeights::get().max_block;443 // The weight needed for decoding the queue should be less or equal than a fifth444 // of the overall weight dedicated to the lazy deletion.445 pub DeletionQueueDepth: u32 = ((DeletionWeightLimit::get() / (446 <Runtime as pallet_contracts::Config>::WeightInfo::on_initialize_per_queue_item(1) -447 <Runtime as pallet_contracts::Config>::WeightInfo::on_initialize_per_queue_item(0)448 )) / 5) as u32;449 pub Schedule: pallet_contracts::Schedule<Runtime> = Default::default();450}451452impl pallet_contracts::Config for Runtime {453 type Time = Timestamp;454 type Randomness = RandomnessCollectiveFlip;455 type Currency = Balances;456 type Event = Event;457 type RentPayment = ();458 type SignedClaimHandicap = SignedClaimHandicap;459 type TombstoneDeposit = TombstoneDeposit;460 type DepositPerContract = DepositPerContract;461 type DepositPerStorageByte = DepositPerStorageByte;462 type DepositPerStorageItem = DepositPerStorageItem;463 type RentFraction = RentFraction;464 type SurchargeReward = SurchargeReward;465 type WeightPrice = pallet_transaction_payment::Pallet<Self>;466 type WeightInfo = pallet_contracts::weights::SubstrateWeight<Self>;467 type ChainExtension = NFTExtension;468 type DeletionQueueDepth = DeletionQueueDepth;469 type DeletionWeightLimit = DeletionWeightLimit;470 type Schedule = Schedule;471 type CallStack = [pallet_contracts::Frame<Self>; 31];472}473*/474475parameter_types! {476 /// This value increases the priority of `Operational` transactions by adding477 /// a "virtual tip" that's equal to the `OperationalFeeMultiplier * final_fee`.478 pub const OperationalFeeMultiplier: u8 = 5;479}480481/// Linear implementor of `WeightToFeePolynomial`482pub struct LinearFee<T>(sp_std::marker::PhantomData<T>);483484impl<T> WeightToFeePolynomial for LinearFee<T>485where486 T: BaseArithmetic + From<u32> + Copy + Unsigned,487{488 type Balance = T;489490 fn polynomial() -> WeightToFeeCoefficients<Self::Balance> {491 smallvec!(WeightToFeeCoefficient {492 // Targeting 0.1 Unique per NFT transfer493 coeff_integer: WEIGHT_TO_FEE_COEFF.into(),494 coeff_frac: Perbill::zero(),495 negative: false,496 degree: 1,497 })498 }499}500501impl pallet_transaction_payment::Config for Runtime {502 type OnChargeTransaction = pallet_transaction_payment::CurrencyAdapter<Balances, DealWithFees>;503 type LengthToFee = ConstantMultiplier<Balance, TransactionByteFee>;504 type OperationalFeeMultiplier = OperationalFeeMultiplier;505 type WeightToFee = LinearFee<Balance>;506 type FeeMultiplierUpdate = ();507}508509parameter_types! {510 pub const ProposalBond: Permill = Permill::from_percent(5);511 pub const ProposalBondMinimum: Balance = 1 * UNIQUE;512 pub const ProposalBondMaximum: Balance = 1000 * UNIQUE;513 pub const SpendPeriod: BlockNumber = 5 * MINUTES;514 pub const Burn: Permill = Permill::from_percent(0);515 pub const TipCountdown: BlockNumber = 1 * DAYS;516 pub const TipFindersFee: Percent = Percent::from_percent(20);517 pub const TipReportDepositBase: Balance = 1 * UNIQUE;518 pub const DataDepositPerByte: Balance = 1 * CENTIUNIQUE;519 pub const BountyDepositBase: Balance = 1 * UNIQUE;520 pub const BountyDepositPayoutDelay: BlockNumber = 1 * DAYS;521 pub const TreasuryModuleId: PalletId = PalletId(*b"py/trsry");522 pub const BountyUpdatePeriod: BlockNumber = 14 * DAYS;523 pub const MaximumReasonLength: u32 = 16384;524 pub const BountyCuratorDeposit: Permill = Permill::from_percent(50);525 pub const BountyValueMinimum: Balance = 5 * UNIQUE;526 pub const MaxApprovals: u32 = 100;527}528529impl pallet_treasury::Config for Runtime {530 type PalletId = TreasuryModuleId;531 type Currency = Balances;532 type ApproveOrigin = EnsureRoot<AccountId>;533 type RejectOrigin = EnsureRoot<AccountId>;534 type Event = Event;535 type OnSlash = ();536 type ProposalBond = ProposalBond;537 type ProposalBondMinimum = ProposalBondMinimum;538 type ProposalBondMaximum = ProposalBondMaximum;539 type SpendPeriod = SpendPeriod;540 type Burn = Burn;541 type BurnDestination = ();542 type SpendFunds = ();543 type WeightInfo = pallet_treasury::weights::SubstrateWeight<Self>;544 type MaxApprovals = MaxApprovals;545}546547impl pallet_sudo::Config for Runtime {548 type Event = Event;549 type Call = Call;550}551552pub struct RelayChainBlockNumberProvider<T>(sp_std::marker::PhantomData<T>);553554impl<T: cumulus_pallet_parachain_system::Config> BlockNumberProvider555 for RelayChainBlockNumberProvider<T>556{557 type BlockNumber = BlockNumber;558559 fn current_block_number() -> Self::BlockNumber {560 cumulus_pallet_parachain_system::Pallet::<T>::validation_data()561 .map(|d| d.relay_parent_number)562 .unwrap_or_default()563 }564}565566parameter_types! {567 pub const MinVestedTransfer: Balance = 10 * UNIQUE;568 pub const MaxVestingSchedules: u32 = 28;569}570571impl orml_vesting::Config for Runtime {572 type Event = Event;573 type Currency = pallet_balances::Pallet<Runtime>;574 type MinVestedTransfer = MinVestedTransfer;575 type VestedTransferOrigin = EnsureSigned<AccountId>;576 type WeightInfo = ();577 type MaxVestingSchedules = MaxVestingSchedules;578 type BlockNumberProvider = RelayChainBlockNumberProvider<Runtime>;579}580581parameter_types! {582 pub const ReservedDmpWeight: Weight = MAXIMUM_BLOCK_WEIGHT / 4;583 pub const ReservedXcmpWeight: Weight = MAXIMUM_BLOCK_WEIGHT / 4;584}585586impl cumulus_pallet_parachain_system::Config for Runtime {587 type Event = Event;588 type SelfParaId = parachain_info::Pallet<Self>;589 type OnSystemEvent = ();590 // type DownwardMessageHandlers = cumulus_primitives_utility::UnqueuedDmpAsParent<591 // MaxDownwardMessageWeight,592 // XcmExecutor<XcmConfig>,593 // Call,594 // >;595 type OutboundXcmpMessageSource = XcmpQueue;596 type DmpMessageHandler = DmpQueue;597 type ReservedDmpWeight = ReservedDmpWeight;598 type ReservedXcmpWeight = ReservedXcmpWeight;599 type XcmpMessageHandler = XcmpQueue;600}601602impl parachain_info::Config for Runtime {}603604impl cumulus_pallet_aura_ext::Config for Runtime {}605606parameter_types! {607 pub const RelayLocation: MultiLocation = MultiLocation::parent();608 pub const RelayNetwork: NetworkId = NetworkId::Polkadot;609 pub RelayOrigin: Origin = cumulus_pallet_xcm::Origin::Relay.into();610 pub Ancestry: MultiLocation = Parachain(ParachainInfo::parachain_id().into()).into();611}612613/// Type for specifying how a `MultiLocation` can be converted into an `AccountId`. This is used614/// when determining ownership of accounts for asset transacting and when attempting to use XCM615/// `Transact` in order to determine the dispatch Origin.616pub type LocationToAccountId = (617 // The parent (Relay-chain) origin converts to the default `AccountId`.618 ParentIsPreset<AccountId>,619 // Sibling parachain origins convert to AccountId via the `ParaId::into`.620 SiblingParachainConvertsVia<Sibling, AccountId>,621 // Straight up local `AccountId32` origins just alias directly to `AccountId`.622 AccountId32Aliases<RelayNetwork, AccountId>,623);624625pub struct OnlySelfCurrency;626impl<B: TryFrom<u128>> MatchesFungible<B> for OnlySelfCurrency {627 fn matches_fungible(a: &MultiAsset) -> Option<B> {628 match (&a.id, &a.fun) {629 (Concrete(_), XcmFungible(ref amount)) => CheckedConversion::checked_from(*amount),630 _ => None,631 }632 }633}634635/// Means for transacting assets on this chain.636pub type LocalAssetTransactor = CurrencyAdapter<637 // Use this currency:638 Balances,639 // Use this currency when it is a fungible asset matching the given location or name:640 OnlySelfCurrency,641 // Do a simple punn to convert an AccountId32 MultiLocation into a native chain account ID:642 LocationToAccountId,643 // Our chain's account ID type (we can't get away without mentioning it explicitly):644 AccountId,645 // We don't track any teleports.646 (),647>;648649/// This is the type we use to convert an (incoming) XCM origin into a local `Origin` instance,650/// ready for dispatching a transaction with Xcm's `Transact`. There is an `OriginKind` which can651/// biases the kind of local `Origin` it will become.652pub type XcmOriginToTransactDispatchOrigin = (653 // Sovereign account converter; this attempts to derive an `AccountId` from the origin location654 // using `LocationToAccountId` and then turn that into the usual `Signed` origin. Useful for655 // foreign chains who want to have a local sovereign account on this chain which they control.656 SovereignSignedViaLocation<LocationToAccountId, Origin>,657 // Native converter for Relay-chain (Parent) location; will converts to a `Relay` origin when658 // recognised.659 RelayChainAsNative<RelayOrigin, Origin>,660 // Native converter for sibling Parachains; will convert to a `SiblingPara` origin when661 // recognised.662 SiblingParachainAsNative<cumulus_pallet_xcm::Origin, Origin>,663 // Superuser converter for the Relay-chain (Parent) location. This will allow it to issue a664 // transaction from the Root origin.665 ParentAsSuperuser<Origin>,666 // Native signed account converter; this just converts an `AccountId32` origin into a normal667 // `Origin::Signed` origin of the same 32-byte value.668 SignedAccountId32AsNative<RelayNetwork, Origin>,669 // Xcm origins can be represented natively under the Xcm pallet's Xcm origin.670 XcmPassthrough<Origin>,671);672673parameter_types! {674 // One XCM operation is 1_000_000 weight - almost certainly a conservative estimate.675 pub UnitWeightCost: Weight = 1_000_000;676 // 1200 UNIQUEs buy 1 second of weight.677 pub const WeightPrice: (MultiLocation, u128) = (MultiLocation::parent(), 1_200 * UNIQUE);678 pub const MaxInstructions: u32 = 100;679 pub const MaxAuthorities: u32 = 100_000;680}681682match_types! {683 pub type ParentOrParentsUnitPlurality: impl Contains<MultiLocation> = {684 MultiLocation { parents: 1, interior: Here } |685 MultiLocation { parents: 1, interior: X1(Plurality { id: BodyId::Unit, .. }) }686 };687}688689pub type Barrier = (690 TakeWeightCredit,691 AllowTopLevelPaidExecutionFrom<Everything>,692 AllowUnpaidExecutionFrom<ParentOrParentsUnitPlurality>,693 // ^^^ Parent & its unit plurality gets free execution694);695696pub struct UsingOnlySelfCurrencyComponents<697 WeightToFee: WeightToFeePolynomial<Balance = Currency::Balance>,698 AssetId: Get<MultiLocation>,699 AccountId,700 Currency: CurrencyT<AccountId>,701 OnUnbalanced: OnUnbalancedT<Currency::NegativeImbalance>,702>(703 Weight,704 Currency::Balance,705 PhantomData<(WeightToFee, AssetId, AccountId, Currency, OnUnbalanced)>,706);707impl<708 WeightToFee: WeightToFeePolynomial<Balance = Currency::Balance>,709 AssetId: Get<MultiLocation>,710 AccountId,711 Currency: CurrencyT<AccountId>,712 OnUnbalanced: OnUnbalancedT<Currency::NegativeImbalance>,713 > WeightTrader714 for UsingOnlySelfCurrencyComponents<WeightToFee, AssetId, AccountId, Currency, OnUnbalanced>715{716 fn new() -> Self {717 Self(0, Zero::zero(), PhantomData)718 }719720 fn buy_weight(&mut self, weight: Weight, payment: Assets) -> Result<Assets, XcmError> {721 let amount = WeightToFee::calc(&weight);722 let u128_amount: u128 = amount.try_into().map_err(|_| XcmError::Overflow)?;723724 // location to this parachain through relay chain725 let option1: xcm::v1::AssetId = Concrete(MultiLocation {726 parents: 1,727 interior: X1(Parachain(ParachainInfo::parachain_id().into())),728 });729 // direct location730 let option2: xcm::v1::AssetId = Concrete(MultiLocation {731 parents: 0,732 interior: Here,733 });734735 let required = if payment.fungible.contains_key(&option1) {736 (option1, u128_amount).into()737 } else if payment.fungible.contains_key(&option2) {738 (option2, u128_amount).into()739 } else {740 (Concrete(MultiLocation::default()), u128_amount).into()741 };742743 let unused = payment744 .checked_sub(required)745 .map_err(|_| XcmError::TooExpensive)?;746 self.0 = self.0.saturating_add(weight);747 self.1 = self.1.saturating_add(amount);748 Ok(unused)749 }750751 fn refund_weight(&mut self, weight: Weight) -> Option<MultiAsset> {752 let weight = weight.min(self.0);753 let amount = WeightToFee::calc(&weight);754 self.0 -= weight;755 self.1 = self.1.saturating_sub(amount);756 let amount: u128 = amount.saturated_into();757 if amount > 0 {758 Some((AssetId::get(), amount).into())759 } else {760 None761 }762 }763}764impl<765 WeightToFee: WeightToFeePolynomial<Balance = Currency::Balance>,766 AssetId: Get<MultiLocation>,767 AccountId,768 Currency: CurrencyT<AccountId>,769 OnUnbalanced: OnUnbalancedT<Currency::NegativeImbalance>,770 > Drop771 for UsingOnlySelfCurrencyComponents<WeightToFee, AssetId, AccountId, Currency, OnUnbalanced>772{773 fn drop(&mut self) {774 OnUnbalanced::on_unbalanced(Currency::issue(self.1));775 }776}777778pub struct XcmConfig;779impl Config for XcmConfig {780 type Call = Call;781 type XcmSender = XcmRouter;782 // How to withdraw and deposit an asset.783 type AssetTransactor = LocalAssetTransactor;784 type OriginConverter = XcmOriginToTransactDispatchOrigin;785 type IsReserve = NativeAsset;786 type IsTeleporter = (); // Teleportation is disabled787 type LocationInverter = LocationInverter<Ancestry>;788 type Barrier = Barrier;789 type Weigher = FixedWeightBounds<UnitWeightCost, Call, MaxInstructions>;790 type Trader = UsingOnlySelfCurrencyComponents<791 IdentityFee<Balance>,792 RelayLocation,793 AccountId,794 Balances,795 (),796 >;797 type ResponseHandler = (); // Don't handle responses for now.798 type SubscriptionService = PolkadotXcm;799800 type AssetTrap = PolkadotXcm;801 type AssetClaims = PolkadotXcm;802}803804// parameter_types! {805// pub const MaxDownwardMessageWeight: Weight = MAXIMUM_BLOCK_WEIGHT / 10;806// }807808/// No local origins on this chain are allowed to dispatch XCM sends/executions.809pub type LocalOriginToLocation = (SignedToAccountId32<Origin, AccountId, RelayNetwork>,);810811/// The means for routing XCM messages which are not for local execution into the right message812/// queues.813pub type XcmRouter = (814 // Two routers - use UMP to communicate with the relay chain:815 cumulus_primitives_utility::ParentAsUmp<ParachainSystem, ()>,816 // ..and XCMP to communicate with the sibling chains.817 XcmpQueue,818);819820impl pallet_evm_coder_substrate::Config for Runtime {821 type EthereumTransactionSender = pallet_ethereum::Pallet<Self>;822 type GasWeightMapping = FixedGasWeightMapping;823}824825impl pallet_xcm::Config for Runtime {826 type Event = Event;827 type SendXcmOrigin = EnsureXcmOrigin<Origin, LocalOriginToLocation>;828 type XcmRouter = XcmRouter;829 type ExecuteXcmOrigin = EnsureXcmOrigin<Origin, LocalOriginToLocation>;830 type XcmExecuteFilter = Everything;831 type XcmExecutor = XcmExecutor<XcmConfig>;832 type XcmTeleportFilter = Everything;833 type XcmReserveTransferFilter = Everything;834 type Weigher = FixedWeightBounds<UnitWeightCost, Call, MaxInstructions>;835 type LocationInverter = LocationInverter<Ancestry>;836 type Origin = Origin;837 type Call = Call;838 const VERSION_DISCOVERY_QUEUE_SIZE: u32 = 100;839 type AdvertisedXcmVersion = pallet_xcm::CurrentXcmVersion;840}841842impl cumulus_pallet_xcm::Config for Runtime {843 type Event = Event;844 type XcmExecutor = XcmExecutor<XcmConfig>;845}846847impl cumulus_pallet_xcmp_queue::Config for Runtime {848 type WeightInfo = ();849 type Event = Event;850 type XcmExecutor = XcmExecutor<XcmConfig>;851 type ChannelInfo = ParachainSystem;852 type VersionWrapper = ();853 type ExecuteOverweightOrigin = frame_system::EnsureRoot<AccountId>;854 type ControllerOrigin = EnsureRoot<AccountId>;855 type ControllerOriginConverter = XcmOriginToTransactDispatchOrigin;856}857858impl cumulus_pallet_dmp_queue::Config for Runtime {859 type Event = Event;860 type XcmExecutor = XcmExecutor<XcmConfig>;861 type ExecuteOverweightOrigin = frame_system::EnsureRoot<AccountId>;862}863864impl pallet_aura::Config for Runtime {865 type AuthorityId = AuraId;866 type DisabledValidators = ();867 type MaxAuthorities = MaxAuthorities;868}869870parameter_types! {871 pub TreasuryAccountId: AccountId = TreasuryModuleId::get().into_account();872 pub const CollectionCreationPrice: Balance = 2 * UNIQUE;873}874875impl pallet_common::Config for Runtime {876 type Event = Event;877 type Currency = Balances;878 type CollectionCreationPrice = CollectionCreationPrice;879 type TreasuryAccountId = TreasuryAccountId;880 type CollectionDispatch = CollectionDispatchT<Self>;881882 type EvmTokenAddressMapping = EvmTokenAddressMapping;883 type CrossTokenAddressMapping = CrossTokenAddressMapping<Self::AccountId>;884}885886impl pallet_structure::Config for Runtime {887 type Event = Event;888 type Call = Call;889 type WeightInfo = pallet_structure::weights::SubstrateWeight<Self>;890}891892impl pallet_fungible::Config for Runtime {893 type WeightInfo = pallet_fungible::weights::SubstrateWeight<Self>;894}895impl pallet_refungible::Config for Runtime {896 type WeightInfo = pallet_refungible::weights::SubstrateWeight<Self>;897}898impl pallet_nonfungible::Config for Runtime {899 type WeightInfo = pallet_nonfungible::weights::SubstrateWeight<Self>;900}901902impl pallet_unique::Config for Runtime {903 type Event = Event;904 type WeightInfo = pallet_unique::weights::SubstrateWeight<Self>;905}906907parameter_types! {908 pub const InflationBlockInterval: BlockNumber = 100; // every time per how many blocks inflation is applied909}910911/// Used for the pallet inflation912impl pallet_inflation::Config for Runtime {913 type Currency = Balances;914 type TreasuryAccountId = TreasuryAccountId;915 type InflationBlockInterval = InflationBlockInterval;916 type BlockNumberProvider = RelayChainBlockNumberProvider<Runtime>;917}918919// parameter_types! {920// pub MaximumSchedulerWeight: Weight = Perbill::from_percent(50) *921// RuntimeBlockWeights::get().max_block;922// pub const MaxScheduledPerBlock: u32 = 50;923// }924925type EvmSponsorshipHandler = (926 pallet_unique::UniqueEthSponsorshipHandler<Runtime>,927 pallet_evm_contract_helpers::HelpersContractSponsoring<Runtime>,928);929type SponsorshipHandler = (930 pallet_unique::UniqueSponsorshipHandler<Runtime>,931 //pallet_contract_helpers::ContractSponsorshipHandler<Runtime>,932 pallet_evm_transaction_payment::BridgeSponsorshipHandler<Runtime>,933);934935// impl pallet_unq_scheduler::Config for Runtime {936// type Event = Event;937// type Origin = Origin;938// type PalletsOrigin = OriginCaller;939// type Call = Call;940// type MaximumWeight = MaximumSchedulerWeight;941// type ScheduleOrigin = EnsureSigned<AccountId>;942// type MaxScheduledPerBlock = MaxScheduledPerBlock;943// type SponsorshipHandler = SponsorshipHandler;944// type WeightInfo = ();945// }946947impl pallet_evm_transaction_payment::Config for Runtime {948 type EvmSponsorshipHandler = EvmSponsorshipHandler;949 type Currency = Balances;950}951952impl pallet_charge_transaction::Config for Runtime {953 type SponsorshipHandler = SponsorshipHandler;954}955956// impl pallet_contract_helpers::Config for Runtime {957// type DefaultSponsoringRateLimit = DefaultSponsoringRateLimit;958// }959960parameter_types! {961 // 0x842899ECF380553E8a4de75bF534cdf6fBF64049962 pub const HelpersContractAddress: H160 = H160([963 0x84, 0x28, 0x99, 0xec, 0xf3, 0x80, 0x55, 0x3e, 0x8a, 0x4d, 0xe7, 0x5b, 0xf5, 0x34, 0xcd, 0xf6, 0xfb, 0xf6, 0x40, 0x49,964 ]);965}966967impl pallet_evm_contract_helpers::Config for Runtime {968 type ContractAddress = HelpersContractAddress;969 type DefaultSponsoringRateLimit = DefaultSponsoringRateLimit;970}971972construct_runtime!(973 pub enum Runtime where974 Block = Block,975 NodeBlock = opaque::Block,976 UncheckedExtrinsic = UncheckedExtrinsic977 {978 ParachainSystem: cumulus_pallet_parachain_system::{Pallet, Call, Config, Storage, Inherent, Event<T>, ValidateUnsigned} = 20,979 ParachainInfo: parachain_info::{Pallet, Storage, Config} = 21,980981 Aura: pallet_aura::{Pallet, Config<T>} = 22,982 AuraExt: cumulus_pallet_aura_ext::{Pallet, Config} = 23,983984 Balances: pallet_balances::{Pallet, Call, Storage, Config<T>, Event<T>} = 30,985 RandomnessCollectiveFlip: pallet_randomness_collective_flip::{Pallet, Storage} = 31,986 Timestamp: pallet_timestamp::{Pallet, Call, Storage, Inherent} = 32,987 TransactionPayment: pallet_transaction_payment::{Pallet, Storage} = 33,988 Treasury: pallet_treasury::{Pallet, Call, Storage, Config, Event<T>} = 34,989 Sudo: pallet_sudo::{Pallet, Call, Storage, Config<T>, Event<T>} = 35,990 System: frame_system::{Pallet, Call, Storage, Config, Event<T>} = 36,991 Vesting: orml_vesting::{Pallet, Storage, Call, Event<T>, Config<T>} = 37,992 // Vesting: pallet_vesting::{Pallet, Call, Config<T>, Storage, Event<T>} = 37,993 // Contracts: pallet_contracts::{Pallet, Call, Storage, Event<T>} = 38,994995 // XCM helpers.996 XcmpQueue: cumulus_pallet_xcmp_queue::{Pallet, Call, Storage, Event<T>} = 50,997 PolkadotXcm: pallet_xcm::{Pallet, Call, Event<T>, Origin} = 51,998 CumulusXcm: cumulus_pallet_xcm::{Pallet, Call, Event<T>, Origin} = 52,999 DmpQueue: cumulus_pallet_dmp_queue::{Pallet, Call, Storage, Event<T>} = 53,10001001 // Unique Pallets1002 Inflation: pallet_inflation::{Pallet, Call, Storage} = 60,1003 Unique: pallet_unique::{Pallet, Call, Storage, Event<T>} = 61,1004 // Scheduler: pallet_unq_scheduler::{Pallet, Call, Storage, Event<T>} = 62,1005 // free = 631006 Charging: pallet_charge_transaction::{Pallet, Call, Storage } = 64,1007 // ContractHelpers: pallet_contract_helpers::{Pallet, Call, Storage} = 65,1008 Common: pallet_common::{Pallet, Storage, Event<T>} = 66,1009 Fungible: pallet_fungible::{Pallet, Storage} = 67,1010 Refungible: pallet_refungible::{Pallet, Storage} = 68,1011 Nonfungible: pallet_nonfungible::{Pallet, Storage} = 69,1012 Structure: pallet_structure::{Pallet, Call, Storage, Event<T>} = 70,10131014 // Frontier1015 EVM: pallet_evm::{Pallet, Config, Call, Storage, Event<T>} = 100,1016 Ethereum: pallet_ethereum::{Pallet, Config, Call, Storage, Event, Origin} = 101,10171018 EvmCoderSubstrate: pallet_evm_coder_substrate::{Pallet, Storage} = 150,1019 EvmContractHelpers: pallet_evm_contract_helpers::{Pallet, Storage} = 151,1020 EvmTransactionPayment: pallet_evm_transaction_payment::{Pallet} = 152,1021 EvmMigration: pallet_evm_migration::{Pallet, Call, Storage} = 153,1022 }1023);10241025pub struct TransactionConverter;10261027impl fp_rpc::ConvertTransaction<UncheckedExtrinsic> for TransactionConverter {1028 fn convert_transaction(&self, transaction: pallet_ethereum::Transaction) -> UncheckedExtrinsic {1029 UncheckedExtrinsic::new_unsigned(1030 pallet_ethereum::Call::<Runtime>::transact { transaction }.into(),1031 )1032 }1033}10341035impl fp_rpc::ConvertTransaction<opaque::UncheckedExtrinsic> for TransactionConverter {1036 fn convert_transaction(1037 &self,1038 transaction: pallet_ethereum::Transaction,1039 ) -> opaque::UncheckedExtrinsic {1040 let extrinsic = UncheckedExtrinsic::new_unsigned(1041 pallet_ethereum::Call::<Runtime>::transact { transaction }.into(),1042 );1043 let encoded = extrinsic.encode();1044 opaque::UncheckedExtrinsic::decode(&mut &encoded[..])1045 .expect("Encoded extrinsic is always valid")1046 }1047}10481049/// The address format for describing accounts.1050pub type Address = sp_runtime::MultiAddress<AccountId, ()>;1051/// Block header type as expected by this runtime.1052pub type Header = generic::Header<BlockNumber, BlakeTwo256>;1053/// Block type as expected by this runtime.1054pub type Block = generic::Block<Header, UncheckedExtrinsic>;1055/// A Block signed with a Justification1056pub type SignedBlock = generic::SignedBlock<Block>;1057/// BlockId type as expected by this runtime.1058pub type BlockId = generic::BlockId<Block>;1059/// The SignedExtension to the basic transaction logic.1060pub type SignedExtra = (1061 frame_system::CheckSpecVersion<Runtime>,1062 // system::CheckTxVersion<Runtime>,1063 frame_system::CheckGenesis<Runtime>,1064 frame_system::CheckEra<Runtime>,1065 frame_system::CheckNonce<Runtime>,1066 frame_system::CheckWeight<Runtime>,1067 pallet_charge_transaction::ChargeTransactionPayment<Runtime>,1068 //pallet_contract_helpers::ContractHelpersExtension<Runtime>,1069);1070/// Unchecked extrinsic type as expected by this runtime.1071pub type UncheckedExtrinsic =1072 fp_self_contained::UncheckedExtrinsic<Address, Call, Signature, SignedExtra>;1073/// Extrinsic type that has already been checked.1074pub type CheckedExtrinsic = fp_self_contained::CheckedExtrinsic<AccountId, Call, SignedExtra, H160>;1075/// Executive: handles dispatch to the various modules.1076pub type Executive = frame_executive::Executive<1077 Runtime,1078 Block,1079 frame_system::ChainContext<Runtime>,1080 Runtime,1081 AllPalletsReversedWithSystemFirst,1082>;10831084impl_opaque_keys! {1085 pub struct SessionKeys {1086 pub aura: Aura,1087 }1088}10891090impl fp_self_contained::SelfContainedCall for Call {1091 type SignedInfo = H160;10921093 fn is_self_contained(&self) -> bool {1094 match self {1095 Call::Ethereum(call) => call.is_self_contained(),1096 _ => false,1097 }1098 }10991100 fn check_self_contained(&self) -> Option<Result<Self::SignedInfo, TransactionValidityError>> {1101 match self {1102 Call::Ethereum(call) => call.check_self_contained(),1103 _ => None,1104 }1105 }11061107 fn validate_self_contained(&self, info: &Self::SignedInfo) -> Option<TransactionValidity> {1108 match self {1109 Call::Ethereum(call) => call.validate_self_contained(info),1110 _ => None,1111 }1112 }11131114 fn pre_dispatch_self_contained(1115 &self,1116 info: &Self::SignedInfo,1117 ) -> Option<Result<(), TransactionValidityError>> {1118 match self {1119 Call::Ethereum(call) => call.pre_dispatch_self_contained(info),1120 _ => None,1121 }1122 }11231124 fn apply_self_contained(1125 self,1126 info: Self::SignedInfo,1127 ) -> Option<sp_runtime::DispatchResultWithInfo<PostDispatchInfoOf<Self>>> {1128 match self {1129 call @ Call::Ethereum(pallet_ethereum::Call::transact { .. }) => Some(call.dispatch(1130 Origin::from(pallet_ethereum::RawOrigin::EthereumTransaction(info)),1131 )),1132 _ => None,1133 }1134 }1135}11361137macro_rules! dispatch_unique_runtime {1138 ($collection:ident.$method:ident($($name:ident),*)) => {{1139 let collection = <Runtime as pallet_common::Config>::CollectionDispatch::dispatch(<pallet_common::CollectionHandle<Runtime>>::try_get($collection)?);1140 let dispatch = collection.as_dyn();11411142 Ok(dispatch.$method($($name),*))1143 }};1144}11451146impl_common_runtime_apis!();11471148struct CheckInherents;11491150impl cumulus_pallet_parachain_system::CheckInherents<Block> for CheckInherents {1151 fn check_inherents(1152 block: &Block,1153 relay_state_proof: &cumulus_pallet_parachain_system::RelayChainStateProof,1154 ) -> sp_inherents::CheckInherentsResult {1155 let relay_chain_slot = relay_state_proof1156 .read_slot()1157 .expect("Could not read the relay chain slot from the proof");11581159 let inherent_data =1160 cumulus_primitives_timestamp::InherentDataProvider::from_relay_chain_slot_and_duration(1161 relay_chain_slot,1162 sp_std::time::Duration::from_secs(6),1163 )1164 .create_inherent_data()1165 .expect("Could not create the timestamp inherent data");11661167 inherent_data.check_extrinsics(block)1168 }1169}11701171cumulus_pallet_parachain_system::register_validate_block!(1172 Runtime = Runtime,1173 BlockExecutor = cumulus_pallet_aura_ext::BlockExecutor::<Runtime, Executive>,1174 CheckInherents = CheckInherents,1175);1// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.2// This file is part of Unique Network.34// Unique Network is free software: you can redistribute it and/or modify5// it under the terms of the GNU General Public License as published by6// the Free Software Foundation, either version 3 of the License, or7// (at your option) any later version.89// Unique Network is distributed in the hope that it will be useful,10// but WITHOUT ANY WARRANTY; without even the implied warranty of11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the12// GNU General Public License for more details.1314// You should have received a copy of the GNU General Public License15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.1617//! The Substrate Node Template runtime. This can be compiled with `#[no_std]`, ready for Wasm.1819#![cfg_attr(not(feature = "std"), no_std)]20// `construct_runtime!` does a lot of recursion and requires us to increase the limit to 256.21#![recursion_limit = "1024"]22#![allow(clippy::from_over_into, clippy::identity_op)]23#![allow(clippy::fn_to_numeric_cast_with_truncation)]24// Make the WASM binary available.25#[cfg(feature = "std")]26include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs"));2728use sp_api::impl_runtime_apis;29use sp_core::{crypto::KeyTypeId, OpaqueMetadata, H256, U256, H160};30use sp_runtime::DispatchError;31// #[cfg(any(feature = "std", test))]32// pub use sp_runtime::BuildStorage;3334use sp_runtime::{35 Permill, Perbill, Percent, create_runtime_str, generic, impl_opaque_keys,36 traits::{AccountIdLookup, BlakeTwo256, Block as BlockT, AccountIdConversion, Zero},37 transaction_validity::{TransactionSource, TransactionValidity},38 ApplyExtrinsicResult, RuntimeAppPublic,39};4041use sp_std::prelude::*;4243#[cfg(feature = "std")]44use sp_version::NativeVersion;45use sp_version::RuntimeVersion;46pub use pallet_transaction_payment::{47 Multiplier, TargetedFeeAdjustment, FeeDetails, RuntimeDispatchInfo,48};49// A few exports that help ease life for downstream crates.50pub use pallet_balances::Call as BalancesCall;51pub use pallet_evm::{52 EnsureAddressTruncated, HashedAddressMapping, Runner, account::CrossAccountId as _,53};54pub use frame_support::{55 construct_runtime, match_types,56 dispatch::DispatchResult,57 PalletId, parameter_types, StorageValue, ConsensusEngineId,58 traits::{59 tokens::currency::Currency as CurrencyT, OnUnbalanced as OnUnbalancedT, Everything,60 Currency, ExistenceRequirement, Get, IsInVec, KeyOwnerProofSystem, LockIdentifier,61 OnUnbalanced, Randomness, FindAuthor, ConstU32, Imbalance,62 },63 weights::{64 constants::{BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight, WEIGHT_PER_SECOND},65 DispatchClass, DispatchInfo, GetDispatchInfo, IdentityFee, Pays, PostDispatchInfo, Weight,66 WeightToFeePolynomial, WeightToFeeCoefficient, WeightToFeeCoefficients, ConstantMultiplier,67 },68};69use up_data_structs::mapping::{EvmTokenAddressMapping, CrossTokenAddressMapping};70use up_data_structs::{CollectionId, TokenId, CollectionStats, RpcCollection};71// use pallet_contracts::weights::WeightInfo;72// #[cfg(any(feature = "std", test))]73use frame_system::{74 self as frame_system, EnsureRoot, EnsureSigned,75 limits::{BlockWeights, BlockLength},76};77use sp_arithmetic::{78 traits::{BaseArithmetic, Unsigned},79};80use smallvec::smallvec;81use codec::{Encode, Decode};82use pallet_evm::{Account as EVMAccount, FeeCalculator, GasWeightMapping};83use fp_rpc::TransactionStatus;84use sp_runtime::{85 traits::{BlockNumberProvider, Dispatchable, PostDispatchInfoOf, Saturating},86 transaction_validity::TransactionValidityError,87 SaturatedConversion,88};8990// pub use pallet_timestamp::Call as TimestampCall;91pub use sp_consensus_aura::sr25519::AuthorityId as AuraId;9293// Polkadot imports94use pallet_xcm::XcmPassthrough;95use polkadot_parachain::primitives::Sibling;96use xcm::v1::{BodyId, Junction::*, MultiLocation, NetworkId, Junctions::*};97use xcm_builder::{98 AccountId32Aliases, AllowTopLevelPaidExecutionFrom, AllowUnpaidExecutionFrom, CurrencyAdapter,99 EnsureXcmOrigin, FixedWeightBounds, LocationInverter, NativeAsset, ParentAsSuperuser,100 RelayChainAsNative, SiblingParachainAsNative, SiblingParachainConvertsVia,101 SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit,102 ParentIsPreset,103};104use xcm_executor::{Config, XcmExecutor, Assets};105use sp_std::{marker::PhantomData};106107use xcm::latest::{108 // Xcm,109 AssetId::{Concrete},110 Fungibility::Fungible as XcmFungible,111 MultiAsset,112 Error as XcmError,113};114use xcm_executor::traits::{MatchesFungible, WeightTrader};115//use xcm_executor::traits::MatchesFungible;116use sp_runtime::traits::CheckedConversion;117118use unique_runtime_common::{119 impl_common_runtime_apis,120 types::*,121 constants::*,122 dispatch::{CollectionDispatchT, CollectionDispatch},123};124125pub const RUNTIME_NAME: &str = "opal";126pub const TOKEN_SYMBOL: &str = "OPL";127128type CrossAccountId = pallet_evm::account::BasicCrossAccountId<Runtime>;129130impl RuntimeInstance for Runtime {131 type CrossAccountId = self::CrossAccountId;132 type TransactionConverter = self::TransactionConverter;133134 fn get_transaction_converter() -> TransactionConverter {135 TransactionConverter136 }137}138139/// The type for looking up accounts. We don't expect more than 4 billion of them, but you140/// never know...141pub type AccountIndex = u32;142143/// Balance of an account.144pub type Balance = u128;145146/// Index of a transaction in the chain.147pub type Index = u32;148149/// A hash of some data used by the chain.150pub type Hash = sp_core::H256;151152/// Digest item type.153pub type DigestItem = generic::DigestItem;154155/// Opaque types. These are used by the CLI to instantiate machinery that don't need to know156/// the specifics of the runtime. They can then be made to be agnostic over specific formats157/// of data like extrinsics, allowing for them to continue syncing the network through upgrades158/// to even the core data structures.159pub mod opaque {160 use sp_std::prelude::*;161 use sp_runtime::impl_opaque_keys;162 use super::Aura;163164 pub use unique_runtime_common::types::*;165166 impl_opaque_keys! {167 pub struct SessionKeys {168 pub aura: Aura,169 }170 }171}172173/// This runtime version.174pub const VERSION: RuntimeVersion = RuntimeVersion {175 spec_name: create_runtime_str!(RUNTIME_NAME),176 impl_name: create_runtime_str!(RUNTIME_NAME),177 authoring_version: 1,178 spec_version: 920000,179 impl_version: 0,180 apis: RUNTIME_API_VERSIONS,181 transaction_version: 1,182 state_version: 0,183};184185#[derive(codec::Encode, codec::Decode)]186pub enum XCMPMessage<XAccountId, XBalance> {187 /// Transfer tokens to the given account from the Parachain account.188 TransferToken(XAccountId, XBalance),189}190191/// The version information used to identify this runtime when compiled natively.192#[cfg(feature = "std")]193pub fn native_version() -> NativeVersion {194 NativeVersion {195 runtime_version: VERSION,196 can_author_with: Default::default(),197 }198}199200type NegativeImbalance = <Balances as Currency<AccountId>>::NegativeImbalance;201202pub struct DealWithFees;203impl OnUnbalanced<NegativeImbalance> for DealWithFees {204 fn on_unbalanceds<B>(mut fees_then_tips: impl Iterator<Item = NegativeImbalance>) {205 if let Some(fees) = fees_then_tips.next() {206 // for fees, 100% to treasury207 let mut split = fees.ration(100, 0);208 if let Some(tips) = fees_then_tips.next() {209 // for tips, if any, 100% to treasury210 tips.ration_merge_into(100, 0, &mut split);211 }212 Treasury::on_unbalanced(split.0);213 // Author::on_unbalanced(split.1);214 }215 }216}217218parameter_types! {219 pub const BlockHashCount: BlockNumber = 2400;220 pub RuntimeBlockLength: BlockLength =221 BlockLength::max_with_normal_ratio(5 * 1024 * 1024, NORMAL_DISPATCH_RATIO);222 pub const AvailableBlockRatio: Perbill = Perbill::from_percent(75);223 pub const MaximumBlockLength: u32 = 5 * 1024 * 1024;224 pub RuntimeBlockWeights: BlockWeights = BlockWeights::builder()225 .base_block(BlockExecutionWeight::get())226 .for_class(DispatchClass::all(), |weights| {227 weights.base_extrinsic = ExtrinsicBaseWeight::get();228 })229 .for_class(DispatchClass::Normal, |weights| {230 weights.max_total = Some(NORMAL_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT);231 })232 .for_class(DispatchClass::Operational, |weights| {233 weights.max_total = Some(MAXIMUM_BLOCK_WEIGHT);234 // Operational transactions have some extra reserved space, so that they235 // are included even if block reached `MAXIMUM_BLOCK_WEIGHT`.236 weights.reserved = Some(237 MAXIMUM_BLOCK_WEIGHT - NORMAL_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT238 );239 })240 .avg_block_initialization(AVERAGE_ON_INITIALIZE_RATIO)241 .build_or_panic();242 pub const Version: RuntimeVersion = VERSION;243 pub const SS58Prefix: u8 = 42;244}245246parameter_types! {247 pub const ChainId: u64 = 8882;248}249250pub struct FixedFee;251impl FeeCalculator for FixedFee {252 fn min_gas_price() -> U256 {253 MIN_GAS_PRICE.into()254 }255}256257// Assuming slowest ethereum opcode is SSTORE, with gas price of 20000 as our worst case258// (contract, which only writes a lot of data),259// approximating on top of our real store write weight260parameter_types! {261 pub const WritesPerSecond: u64 = WEIGHT_PER_SECOND / <Runtime as frame_system::Config>::DbWeight::get().write;262 pub const GasPerSecond: u64 = WritesPerSecond::get() * 20000;263 pub const WeightPerGas: u64 = WEIGHT_PER_SECOND / GasPerSecond::get();264}265266/// Limiting EVM execution to 50% of block for substrate users and management tasks267/// EVM transaction consumes more weight than substrate's, so we can't rely on them being268/// scheduled fairly269const EVM_DISPATCH_RATIO: Perbill = Perbill::from_percent(50);270parameter_types! {271 pub BlockGasLimit: U256 = U256::from(NORMAL_DISPATCH_RATIO * EVM_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT / WeightPerGas::get());272}273274pub enum FixedGasWeightMapping {}275impl GasWeightMapping for FixedGasWeightMapping {276 fn gas_to_weight(gas: u64) -> Weight {277 gas.saturating_mul(WeightPerGas::get())278 }279 fn weight_to_gas(weight: Weight) -> u64 {280 weight / WeightPerGas::get()281 }282}283284impl pallet_evm::account::Config for Runtime {285 type CrossAccountId = pallet_evm::account::BasicCrossAccountId<Self>;286 type EvmAddressMapping = pallet_evm::HashedAddressMapping<Self::Hashing>;287 type EvmBackwardsAddressMapping = fp_evm_mapping::MapBackwardsAddressTruncated;288}289290impl pallet_evm::Config for Runtime {291 type BlockGasLimit = BlockGasLimit;292 type FeeCalculator = FixedFee;293 type GasWeightMapping = FixedGasWeightMapping;294 type BlockHashMapping = pallet_ethereum::EthereumBlockHashMapping<Self>;295 type CallOrigin = EnsureAddressTruncated;296 type WithdrawOrigin = EnsureAddressTruncated;297 type AddressMapping = HashedAddressMapping<Self::Hashing>;298 type PrecompilesType = ();299 type PrecompilesValue = ();300 type Currency = Balances;301 type Event = Event;302 type OnMethodCall = (303 pallet_evm_migration::OnMethodCall<Self>,304 pallet_evm_contract_helpers::HelpersOnMethodCall<Self>,305 CollectionDispatchT<Self>,306 );307 type OnCreate = pallet_evm_contract_helpers::HelpersOnCreate<Self>;308 type ChainId = ChainId;309 type Runner = pallet_evm::runner::stack::Runner<Self>;310 type OnChargeTransaction = pallet_evm::EVMCurrencyAdapter<Balances, DealWithFees>;311 type TransactionValidityHack = pallet_evm_transaction_payment::TransactionValidityHack<Self>;312 type FindAuthor = EthereumFindAuthor<Aura>;313}314315impl pallet_evm_migration::Config for Runtime {316 type WeightInfo = pallet_evm_migration::weights::SubstrateWeight<Self>;317}318319pub struct EthereumFindAuthor<F>(core::marker::PhantomData<F>);320impl<F: FindAuthor<u32>> FindAuthor<H160> for EthereumFindAuthor<F> {321 fn find_author<'a, I>(digests: I) -> Option<H160>322 where323 I: 'a + IntoIterator<Item = (ConsensusEngineId, &'a [u8])>,324 {325 if let Some(author_index) = F::find_author(digests) {326 let authority_id = Aura::authorities()[author_index as usize].clone();327 return Some(H160::from_slice(&authority_id.to_raw_vec()[4..24]));328 }329 None330 }331}332333impl pallet_ethereum::Config for Runtime {334 type Event = Event;335 type StateRoot = pallet_ethereum::IntermediateStateRoot<Self>;336}337338impl pallet_randomness_collective_flip::Config for Runtime {}339340impl frame_system::Config for Runtime {341 /// The data to be stored in an account.342 type AccountData = pallet_balances::AccountData<Balance>;343 /// The identifier used to distinguish between accounts.344 type AccountId = AccountId;345 /// The basic call filter to use in dispatchable.346 type BaseCallFilter = Everything;347 /// Maximum number of block number to block hash mappings to keep (oldest pruned first).348 type BlockHashCount = BlockHashCount;349 /// The maximum length of a block (in bytes).350 type BlockLength = RuntimeBlockLength;351 /// The index type for blocks.352 type BlockNumber = BlockNumber;353 /// The weight of the overhead invoked on the block import process, independent of the extrinsics included in that block.354 type BlockWeights = RuntimeBlockWeights;355 /// The aggregated dispatch type that is available for extrinsics.356 type Call = Call;357 /// The weight of database operations that the runtime can invoke.358 type DbWeight = RocksDbWeight;359 /// The ubiquitous event type.360 type Event = Event;361 /// The type for hashing blocks and tries.362 type Hash = Hash;363 /// The hashing algorithm used.364 type Hashing = BlakeTwo256;365 /// The header type.366 type Header = generic::Header<BlockNumber, BlakeTwo256>;367 /// The index type for storing how many extrinsics an account has signed.368 type Index = Index;369 /// The lookup mechanism to get account ID from whatever is passed in dispatchers.370 type Lookup = AccountIdLookup<AccountId, ()>;371 /// What to do if an account is fully reaped from the system.372 type OnKilledAccount = ();373 /// What to do if a new account is created.374 type OnNewAccount = ();375 type OnSetCode = cumulus_pallet_parachain_system::ParachainSetCode<Self>;376 /// The ubiquitous origin type.377 type Origin = Origin;378 /// This type is being generated by `construct_runtime!`.379 type PalletInfo = PalletInfo;380 /// This is used as an identifier of the chain. 42 is the generic substrate prefix.381 type SS58Prefix = SS58Prefix;382 /// Weight information for the extrinsics of this pallet.383 type SystemWeightInfo = frame_system::weights::SubstrateWeight<Self>;384 /// Version of the runtime.385 type Version = Version;386 type MaxConsumers = ConstU32<16>;387}388389parameter_types! {390 pub const MinimumPeriod: u64 = SLOT_DURATION / 2;391}392393impl pallet_timestamp::Config for Runtime {394 /// A timestamp: milliseconds since the unix epoch.395 type Moment = u64;396 type OnTimestampSet = ();397 type MinimumPeriod = MinimumPeriod;398 type WeightInfo = ();399}400401parameter_types! {402 // pub const ExistentialDeposit: u128 = 500;403 pub const ExistentialDeposit: u128 = 0;404 pub const MaxLocks: u32 = 50;405}406407impl pallet_balances::Config for Runtime {408 type MaxLocks = MaxLocks;409 type MaxReserves = ();410 type ReserveIdentifier = [u8; 8];411 /// The type for recording an account's balance.412 type Balance = Balance;413 /// The ubiquitous event type.414 type Event = Event;415 type DustRemoval = Treasury;416 type ExistentialDeposit = ExistentialDeposit;417 type AccountStore = System;418 type WeightInfo = pallet_balances::weights::SubstrateWeight<Self>;419}420421pub const fn deposit(items: u32, bytes: u32) -> Balance {422 items as Balance * 15 * CENTIUNIQUE + (bytes as Balance) * 6 * CENTIUNIQUE423}424425/*426parameter_types! {427 pub TombstoneDeposit: Balance = deposit(428 1,429 sp_std::mem::size_of::<pallet_contracts::Pallet<Runtime>> as u32,430 );431 pub DepositPerContract: Balance = TombstoneDeposit::get();432 pub const DepositPerStorageByte: Balance = deposit(0, 1);433 pub const DepositPerStorageItem: Balance = deposit(1, 0);434 pub RentFraction: Perbill = Perbill::from_rational(1u32, 30 * DAYS);435 pub const SurchargeReward: Balance = 150 * MILLIUNIQUE;436 pub const SignedClaimHandicap: u32 = 2;437 pub const MaxDepth: u32 = 32;438 pub const MaxValueSize: u32 = 16 * 1024;439 pub const MaxCodeSize: u32 = 1024 * 1024 * 25; // 25 Mb440 // The lazy deletion runs inside on_initialize.441 pub DeletionWeightLimit: Weight = AVERAGE_ON_INITIALIZE_RATIO *442 RuntimeBlockWeights::get().max_block;443 // The weight needed for decoding the queue should be less or equal than a fifth444 // of the overall weight dedicated to the lazy deletion.445 pub DeletionQueueDepth: u32 = ((DeletionWeightLimit::get() / (446 <Runtime as pallet_contracts::Config>::WeightInfo::on_initialize_per_queue_item(1) -447 <Runtime as pallet_contracts::Config>::WeightInfo::on_initialize_per_queue_item(0)448 )) / 5) as u32;449 pub Schedule: pallet_contracts::Schedule<Runtime> = Default::default();450}451452impl pallet_contracts::Config for Runtime {453 type Time = Timestamp;454 type Randomness = RandomnessCollectiveFlip;455 type Currency = Balances;456 type Event = Event;457 type RentPayment = ();458 type SignedClaimHandicap = SignedClaimHandicap;459 type TombstoneDeposit = TombstoneDeposit;460 type DepositPerContract = DepositPerContract;461 type DepositPerStorageByte = DepositPerStorageByte;462 type DepositPerStorageItem = DepositPerStorageItem;463 type RentFraction = RentFraction;464 type SurchargeReward = SurchargeReward;465 type WeightPrice = pallet_transaction_payment::Pallet<Self>;466 type WeightInfo = pallet_contracts::weights::SubstrateWeight<Self>;467 type ChainExtension = NFTExtension;468 type DeletionQueueDepth = DeletionQueueDepth;469 type DeletionWeightLimit = DeletionWeightLimit;470 type Schedule = Schedule;471 type CallStack = [pallet_contracts::Frame<Self>; 31];472}473*/474475parameter_types! {476 /// This value increases the priority of `Operational` transactions by adding477 /// a "virtual tip" that's equal to the `OperationalFeeMultiplier * final_fee`.478 pub const OperationalFeeMultiplier: u8 = 5;479}480481/// Linear implementor of `WeightToFeePolynomial`482pub struct LinearFee<T>(sp_std::marker::PhantomData<T>);483484impl<T> WeightToFeePolynomial for LinearFee<T>485where486 T: BaseArithmetic + From<u32> + Copy + Unsigned,487{488 type Balance = T;489490 fn polynomial() -> WeightToFeeCoefficients<Self::Balance> {491 smallvec!(WeightToFeeCoefficient {492 // Targeting 0.1 Unique per NFT transfer493 coeff_integer: WEIGHT_TO_FEE_COEFF.into(),494 coeff_frac: Perbill::zero(),495 negative: false,496 degree: 1,497 })498 }499}500501impl pallet_transaction_payment::Config for Runtime {502 type OnChargeTransaction = pallet_transaction_payment::CurrencyAdapter<Balances, DealWithFees>;503 type LengthToFee = ConstantMultiplier<Balance, TransactionByteFee>;504 type OperationalFeeMultiplier = OperationalFeeMultiplier;505 type WeightToFee = LinearFee<Balance>;506 type FeeMultiplierUpdate = ();507}508509parameter_types! {510 pub const ProposalBond: Permill = Permill::from_percent(5);511 pub const ProposalBondMinimum: Balance = 1 * UNIQUE;512 pub const ProposalBondMaximum: Balance = 1000 * UNIQUE;513 pub const SpendPeriod: BlockNumber = 5 * MINUTES;514 pub const Burn: Permill = Permill::from_percent(0);515 pub const TipCountdown: BlockNumber = 1 * DAYS;516 pub const TipFindersFee: Percent = Percent::from_percent(20);517 pub const TipReportDepositBase: Balance = 1 * UNIQUE;518 pub const DataDepositPerByte: Balance = 1 * CENTIUNIQUE;519 pub const BountyDepositBase: Balance = 1 * UNIQUE;520 pub const BountyDepositPayoutDelay: BlockNumber = 1 * DAYS;521 pub const TreasuryModuleId: PalletId = PalletId(*b"py/trsry");522 pub const BountyUpdatePeriod: BlockNumber = 14 * DAYS;523 pub const MaximumReasonLength: u32 = 16384;524 pub const BountyCuratorDeposit: Permill = Permill::from_percent(50);525 pub const BountyValueMinimum: Balance = 5 * UNIQUE;526 pub const MaxApprovals: u32 = 100;527}528529impl pallet_treasury::Config for Runtime {530 type PalletId = TreasuryModuleId;531 type Currency = Balances;532 type ApproveOrigin = EnsureRoot<AccountId>;533 type RejectOrigin = EnsureRoot<AccountId>;534 type Event = Event;535 type OnSlash = ();536 type ProposalBond = ProposalBond;537 type ProposalBondMinimum = ProposalBondMinimum;538 type ProposalBondMaximum = ProposalBondMaximum;539 type SpendPeriod = SpendPeriod;540 type Burn = Burn;541 type BurnDestination = ();542 type SpendFunds = ();543 type WeightInfo = pallet_treasury::weights::SubstrateWeight<Self>;544 type MaxApprovals = MaxApprovals;545}546547impl pallet_sudo::Config for Runtime {548 type Event = Event;549 type Call = Call;550}551552pub struct RelayChainBlockNumberProvider<T>(sp_std::marker::PhantomData<T>);553554impl<T: cumulus_pallet_parachain_system::Config> BlockNumberProvider555 for RelayChainBlockNumberProvider<T>556{557 type BlockNumber = BlockNumber;558559 fn current_block_number() -> Self::BlockNumber {560 cumulus_pallet_parachain_system::Pallet::<T>::validation_data()561 .map(|d| d.relay_parent_number)562 .unwrap_or_default()563 }564}565566parameter_types! {567 pub const MinVestedTransfer: Balance = 10 * UNIQUE;568 pub const MaxVestingSchedules: u32 = 28;569}570571impl orml_vesting::Config for Runtime {572 type Event = Event;573 type Currency = pallet_balances::Pallet<Runtime>;574 type MinVestedTransfer = MinVestedTransfer;575 type VestedTransferOrigin = EnsureSigned<AccountId>;576 type WeightInfo = ();577 type MaxVestingSchedules = MaxVestingSchedules;578 type BlockNumberProvider = RelayChainBlockNumberProvider<Runtime>;579}580581parameter_types! {582 pub const ReservedDmpWeight: Weight = MAXIMUM_BLOCK_WEIGHT / 4;583 pub const ReservedXcmpWeight: Weight = MAXIMUM_BLOCK_WEIGHT / 4;584}585586impl cumulus_pallet_parachain_system::Config for Runtime {587 type Event = Event;588 type SelfParaId = parachain_info::Pallet<Self>;589 type OnSystemEvent = ();590 // type DownwardMessageHandlers = cumulus_primitives_utility::UnqueuedDmpAsParent<591 // MaxDownwardMessageWeight,592 // XcmExecutor<XcmConfig>,593 // Call,594 // >;595 type OutboundXcmpMessageSource = XcmpQueue;596 type DmpMessageHandler = DmpQueue;597 type ReservedDmpWeight = ReservedDmpWeight;598 type ReservedXcmpWeight = ReservedXcmpWeight;599 type XcmpMessageHandler = XcmpQueue;600}601602impl parachain_info::Config for Runtime {}603604impl cumulus_pallet_aura_ext::Config for Runtime {}605606parameter_types! {607 pub const RelayLocation: MultiLocation = MultiLocation::parent();608 pub const RelayNetwork: NetworkId = NetworkId::Polkadot;609 pub RelayOrigin: Origin = cumulus_pallet_xcm::Origin::Relay.into();610 pub Ancestry: MultiLocation = Parachain(ParachainInfo::parachain_id().into()).into();611}612613/// Type for specifying how a `MultiLocation` can be converted into an `AccountId`. This is used614/// when determining ownership of accounts for asset transacting and when attempting to use XCM615/// `Transact` in order to determine the dispatch Origin.616pub type LocationToAccountId = (617 // The parent (Relay-chain) origin converts to the default `AccountId`.618 ParentIsPreset<AccountId>,619 // Sibling parachain origins convert to AccountId via the `ParaId::into`.620 SiblingParachainConvertsVia<Sibling, AccountId>,621 // Straight up local `AccountId32` origins just alias directly to `AccountId`.622 AccountId32Aliases<RelayNetwork, AccountId>,623);624625pub struct OnlySelfCurrency;626impl<B: TryFrom<u128>> MatchesFungible<B> for OnlySelfCurrency {627 fn matches_fungible(a: &MultiAsset) -> Option<B> {628 match (&a.id, &a.fun) {629 (Concrete(_), XcmFungible(ref amount)) => CheckedConversion::checked_from(*amount),630 _ => None,631 }632 }633}634635/// Means for transacting assets on this chain.636pub type LocalAssetTransactor = CurrencyAdapter<637 // Use this currency:638 Balances,639 // Use this currency when it is a fungible asset matching the given location or name:640 OnlySelfCurrency,641 // Do a simple punn to convert an AccountId32 MultiLocation into a native chain account ID:642 LocationToAccountId,643 // Our chain's account ID type (we can't get away without mentioning it explicitly):644 AccountId,645 // We don't track any teleports.646 (),647>;648649/// This is the type we use to convert an (incoming) XCM origin into a local `Origin` instance,650/// ready for dispatching a transaction with Xcm's `Transact`. There is an `OriginKind` which can651/// biases the kind of local `Origin` it will become.652pub type XcmOriginToTransactDispatchOrigin = (653 // Sovereign account converter; this attempts to derive an `AccountId` from the origin location654 // using `LocationToAccountId` and then turn that into the usual `Signed` origin. Useful for655 // foreign chains who want to have a local sovereign account on this chain which they control.656 SovereignSignedViaLocation<LocationToAccountId, Origin>,657 // Native converter for Relay-chain (Parent) location; will converts to a `Relay` origin when658 // recognised.659 RelayChainAsNative<RelayOrigin, Origin>,660 // Native converter for sibling Parachains; will convert to a `SiblingPara` origin when661 // recognised.662 SiblingParachainAsNative<cumulus_pallet_xcm::Origin, Origin>,663 // Superuser converter for the Relay-chain (Parent) location. This will allow it to issue a664 // transaction from the Root origin.665 ParentAsSuperuser<Origin>,666 // Native signed account converter; this just converts an `AccountId32` origin into a normal667 // `Origin::Signed` origin of the same 32-byte value.668 SignedAccountId32AsNative<RelayNetwork, Origin>,669 // Xcm origins can be represented natively under the Xcm pallet's Xcm origin.670 XcmPassthrough<Origin>,671);672673parameter_types! {674 // One XCM operation is 1_000_000 weight - almost certainly a conservative estimate.675 pub UnitWeightCost: Weight = 1_000_000;676 // 1200 UNIQUEs buy 1 second of weight.677 pub const WeightPrice: (MultiLocation, u128) = (MultiLocation::parent(), 1_200 * UNIQUE);678 pub const MaxInstructions: u32 = 100;679 pub const MaxAuthorities: u32 = 100_000;680}681682match_types! {683 pub type ParentOrParentsUnitPlurality: impl Contains<MultiLocation> = {684 MultiLocation { parents: 1, interior: Here } |685 MultiLocation { parents: 1, interior: X1(Plurality { id: BodyId::Unit, .. }) }686 };687}688689pub type Barrier = (690 TakeWeightCredit,691 AllowTopLevelPaidExecutionFrom<Everything>,692 AllowUnpaidExecutionFrom<ParentOrParentsUnitPlurality>,693 // ^^^ Parent & its unit plurality gets free execution694);695696pub struct UsingOnlySelfCurrencyComponents<697 WeightToFee: WeightToFeePolynomial<Balance = Currency::Balance>,698 AssetId: Get<MultiLocation>,699 AccountId,700 Currency: CurrencyT<AccountId>,701 OnUnbalanced: OnUnbalancedT<Currency::NegativeImbalance>,702>(703 Weight,704 Currency::Balance,705 PhantomData<(WeightToFee, AssetId, AccountId, Currency, OnUnbalanced)>,706);707impl<708 WeightToFee: WeightToFeePolynomial<Balance = Currency::Balance>,709 AssetId: Get<MultiLocation>,710 AccountId,711 Currency: CurrencyT<AccountId>,712 OnUnbalanced: OnUnbalancedT<Currency::NegativeImbalance>,713 > WeightTrader714 for UsingOnlySelfCurrencyComponents<WeightToFee, AssetId, AccountId, Currency, OnUnbalanced>715{716 fn new() -> Self {717 Self(0, Zero::zero(), PhantomData)718 }719720 fn buy_weight(&mut self, weight: Weight, payment: Assets) -> Result<Assets, XcmError> {721 let amount = WeightToFee::calc(&weight);722 let u128_amount: u128 = amount.try_into().map_err(|_| XcmError::Overflow)?;723724 // location to this parachain through relay chain725 let option1: xcm::v1::AssetId = Concrete(MultiLocation {726 parents: 1,727 interior: X1(Parachain(ParachainInfo::parachain_id().into())),728 });729 // direct location730 let option2: xcm::v1::AssetId = Concrete(MultiLocation {731 parents: 0,732 interior: Here,733 });734735 let required = if payment.fungible.contains_key(&option1) {736 (option1, u128_amount).into()737 } else if payment.fungible.contains_key(&option2) {738 (option2, u128_amount).into()739 } else {740 (Concrete(MultiLocation::default()), u128_amount).into()741 };742743 let unused = payment744 .checked_sub(required)745 .map_err(|_| XcmError::TooExpensive)?;746 self.0 = self.0.saturating_add(weight);747 self.1 = self.1.saturating_add(amount);748 Ok(unused)749 }750751 fn refund_weight(&mut self, weight: Weight) -> Option<MultiAsset> {752 let weight = weight.min(self.0);753 let amount = WeightToFee::calc(&weight);754 self.0 -= weight;755 self.1 = self.1.saturating_sub(amount);756 let amount: u128 = amount.saturated_into();757 if amount > 0 {758 Some((AssetId::get(), amount).into())759 } else {760 None761 }762 }763}764impl<765 WeightToFee: WeightToFeePolynomial<Balance = Currency::Balance>,766 AssetId: Get<MultiLocation>,767 AccountId,768 Currency: CurrencyT<AccountId>,769 OnUnbalanced: OnUnbalancedT<Currency::NegativeImbalance>,770 > Drop771 for UsingOnlySelfCurrencyComponents<WeightToFee, AssetId, AccountId, Currency, OnUnbalanced>772{773 fn drop(&mut self) {774 OnUnbalanced::on_unbalanced(Currency::issue(self.1));775 }776}777778pub struct XcmConfig;779impl Config for XcmConfig {780 type Call = Call;781 type XcmSender = XcmRouter;782 // How to withdraw and deposit an asset.783 type AssetTransactor = LocalAssetTransactor;784 type OriginConverter = XcmOriginToTransactDispatchOrigin;785 type IsReserve = NativeAsset;786 type IsTeleporter = (); // Teleportation is disabled787 type LocationInverter = LocationInverter<Ancestry>;788 type Barrier = Barrier;789 type Weigher = FixedWeightBounds<UnitWeightCost, Call, MaxInstructions>;790 type Trader = UsingOnlySelfCurrencyComponents<791 IdentityFee<Balance>,792 RelayLocation,793 AccountId,794 Balances,795 (),796 >;797 type ResponseHandler = (); // Don't handle responses for now.798 type SubscriptionService = PolkadotXcm;799800 type AssetTrap = PolkadotXcm;801 type AssetClaims = PolkadotXcm;802}803804// parameter_types! {805// pub const MaxDownwardMessageWeight: Weight = MAXIMUM_BLOCK_WEIGHT / 10;806// }807808/// No local origins on this chain are allowed to dispatch XCM sends/executions.809pub type LocalOriginToLocation = (SignedToAccountId32<Origin, AccountId, RelayNetwork>,);810811/// The means for routing XCM messages which are not for local execution into the right message812/// queues.813pub type XcmRouter = (814 // Two routers - use UMP to communicate with the relay chain:815 cumulus_primitives_utility::ParentAsUmp<ParachainSystem, ()>,816 // ..and XCMP to communicate with the sibling chains.817 XcmpQueue,818);819820impl pallet_evm_coder_substrate::Config for Runtime {821 type EthereumTransactionSender = pallet_ethereum::Pallet<Self>;822 type GasWeightMapping = FixedGasWeightMapping;823}824825impl pallet_xcm::Config for Runtime {826 type Event = Event;827 type SendXcmOrigin = EnsureXcmOrigin<Origin, LocalOriginToLocation>;828 type XcmRouter = XcmRouter;829 type ExecuteXcmOrigin = EnsureXcmOrigin<Origin, LocalOriginToLocation>;830 type XcmExecuteFilter = Everything;831 type XcmExecutor = XcmExecutor<XcmConfig>;832 type XcmTeleportFilter = Everything;833 type XcmReserveTransferFilter = Everything;834 type Weigher = FixedWeightBounds<UnitWeightCost, Call, MaxInstructions>;835 type LocationInverter = LocationInverter<Ancestry>;836 type Origin = Origin;837 type Call = Call;838 const VERSION_DISCOVERY_QUEUE_SIZE: u32 = 100;839 type AdvertisedXcmVersion = pallet_xcm::CurrentXcmVersion;840}841842impl cumulus_pallet_xcm::Config for Runtime {843 type Event = Event;844 type XcmExecutor = XcmExecutor<XcmConfig>;845}846847impl cumulus_pallet_xcmp_queue::Config for Runtime {848 type WeightInfo = ();849 type Event = Event;850 type XcmExecutor = XcmExecutor<XcmConfig>;851 type ChannelInfo = ParachainSystem;852 type VersionWrapper = ();853 type ExecuteOverweightOrigin = frame_system::EnsureRoot<AccountId>;854 type ControllerOrigin = EnsureRoot<AccountId>;855 type ControllerOriginConverter = XcmOriginToTransactDispatchOrigin;856}857858impl cumulus_pallet_dmp_queue::Config for Runtime {859 type Event = Event;860 type XcmExecutor = XcmExecutor<XcmConfig>;861 type ExecuteOverweightOrigin = frame_system::EnsureRoot<AccountId>;862}863864impl pallet_aura::Config for Runtime {865 type AuthorityId = AuraId;866 type DisabledValidators = ();867 type MaxAuthorities = MaxAuthorities;868}869870parameter_types! {871 pub TreasuryAccountId: AccountId = TreasuryModuleId::get().into_account();872 pub const CollectionCreationPrice: Balance = 2 * UNIQUE;873}874875impl pallet_common::Config for Runtime {876 type Event = Event;877 type Currency = Balances;878 type CollectionCreationPrice = CollectionCreationPrice;879 type TreasuryAccountId = TreasuryAccountId;880 type CollectionDispatch = CollectionDispatchT<Self>;881882 type EvmTokenAddressMapping = EvmTokenAddressMapping;883 type CrossTokenAddressMapping = CrossTokenAddressMapping<Self::AccountId>;884}885886impl pallet_structure::Config for Runtime {887 type Event = Event;888 type Call = Call;889 type WeightInfo = pallet_structure::weights::SubstrateWeight<Self>;890}891892impl pallet_fungible::Config for Runtime {893 type WeightInfo = pallet_fungible::weights::SubstrateWeight<Self>;894}895impl pallet_refungible::Config for Runtime {896 type WeightInfo = pallet_refungible::weights::SubstrateWeight<Self>;897}898impl pallet_nonfungible::Config for Runtime {899 type WeightInfo = pallet_nonfungible::weights::SubstrateWeight<Self>;900}901902impl pallet_unique::Config for Runtime {903 type Event = Event;904 type WeightInfo = pallet_unique::weights::SubstrateWeight<Self>;905}906907parameter_types! {908 pub const InflationBlockInterval: BlockNumber = 100; // every time per how many blocks inflation is applied909}910911/// Used for the pallet inflation912impl pallet_inflation::Config for Runtime {913 type Currency = Balances;914 type TreasuryAccountId = TreasuryAccountId;915 type InflationBlockInterval = InflationBlockInterval;916 type BlockNumberProvider = RelayChainBlockNumberProvider<Runtime>;917}918919// parameter_types! {920// pub MaximumSchedulerWeight: Weight = Perbill::from_percent(50) *921// RuntimeBlockWeights::get().max_block;922// pub const MaxScheduledPerBlock: u32 = 50;923// }924925type EvmSponsorshipHandler = (926 pallet_unique::UniqueEthSponsorshipHandler<Runtime>,927 pallet_evm_contract_helpers::HelpersContractSponsoring<Runtime>,928);929type SponsorshipHandler = (930 pallet_unique::UniqueSponsorshipHandler<Runtime>,931 //pallet_contract_helpers::ContractSponsorshipHandler<Runtime>,932 pallet_evm_transaction_payment::BridgeSponsorshipHandler<Runtime>,933);934935// impl pallet_unq_scheduler::Config for Runtime {936// type Event = Event;937// type Origin = Origin;938// type PalletsOrigin = OriginCaller;939// type Call = Call;940// type MaximumWeight = MaximumSchedulerWeight;941// type ScheduleOrigin = EnsureSigned<AccountId>;942// type MaxScheduledPerBlock = MaxScheduledPerBlock;943// type SponsorshipHandler = SponsorshipHandler;944// type WeightInfo = ();945// }946947impl pallet_evm_transaction_payment::Config for Runtime {948 type EvmSponsorshipHandler = EvmSponsorshipHandler;949 type Currency = Balances;950}951952impl pallet_charge_transaction::Config for Runtime {953 type SponsorshipHandler = SponsorshipHandler;954}955956// impl pallet_contract_helpers::Config for Runtime {957// type DefaultSponsoringRateLimit = DefaultSponsoringRateLimit;958// }959960parameter_types! {961 // 0x842899ECF380553E8a4de75bF534cdf6fBF64049962 pub const HelpersContractAddress: H160 = H160([963 0x84, 0x28, 0x99, 0xec, 0xf3, 0x80, 0x55, 0x3e, 0x8a, 0x4d, 0xe7, 0x5b, 0xf5, 0x34, 0xcd, 0xf6, 0xfb, 0xf6, 0x40, 0x49,964 ]);965}966967impl pallet_evm_contract_helpers::Config for Runtime {968 type ContractAddress = HelpersContractAddress;969 type DefaultSponsoringRateLimit = DefaultSponsoringRateLimit;970}971972construct_runtime!(973 pub enum Runtime where974 Block = Block,975 NodeBlock = opaque::Block,976 UncheckedExtrinsic = UncheckedExtrinsic977 {978 ParachainSystem: cumulus_pallet_parachain_system::{Pallet, Call, Config, Storage, Inherent, Event<T>, ValidateUnsigned} = 20,979 ParachainInfo: parachain_info::{Pallet, Storage, Config} = 21,980981 Aura: pallet_aura::{Pallet, Config<T>} = 22,982 AuraExt: cumulus_pallet_aura_ext::{Pallet, Config} = 23,983984 Balances: pallet_balances::{Pallet, Call, Storage, Config<T>, Event<T>} = 30,985 RandomnessCollectiveFlip: pallet_randomness_collective_flip::{Pallet, Storage} = 31,986 Timestamp: pallet_timestamp::{Pallet, Call, Storage, Inherent} = 32,987 TransactionPayment: pallet_transaction_payment::{Pallet, Storage} = 33,988 Treasury: pallet_treasury::{Pallet, Call, Storage, Config, Event<T>} = 34,989 Sudo: pallet_sudo::{Pallet, Call, Storage, Config<T>, Event<T>} = 35,990 System: frame_system::{Pallet, Call, Storage, Config, Event<T>} = 36,991 Vesting: orml_vesting::{Pallet, Storage, Call, Event<T>, Config<T>} = 37,992 // Vesting: pallet_vesting::{Pallet, Call, Config<T>, Storage, Event<T>} = 37,993 // Contracts: pallet_contracts::{Pallet, Call, Storage, Event<T>} = 38,994995 // XCM helpers.996 XcmpQueue: cumulus_pallet_xcmp_queue::{Pallet, Call, Storage, Event<T>} = 50,997 PolkadotXcm: pallet_xcm::{Pallet, Call, Event<T>, Origin} = 51,998 CumulusXcm: cumulus_pallet_xcm::{Pallet, Call, Event<T>, Origin} = 52,999 DmpQueue: cumulus_pallet_dmp_queue::{Pallet, Call, Storage, Event<T>} = 53,10001001 // Unique Pallets1002 Inflation: pallet_inflation::{Pallet, Call, Storage} = 60,1003 Unique: pallet_unique::{Pallet, Call, Storage, Event<T>} = 61,1004 // Scheduler: pallet_unq_scheduler::{Pallet, Call, Storage, Event<T>} = 62,1005 // free = 631006 Charging: pallet_charge_transaction::{Pallet, Call, Storage } = 64,1007 // ContractHelpers: pallet_contract_helpers::{Pallet, Call, Storage} = 65,1008 Common: pallet_common::{Pallet, Storage, Event<T>} = 66,1009 Fungible: pallet_fungible::{Pallet, Storage} = 67,1010 Refungible: pallet_refungible::{Pallet, Storage} = 68,1011 Nonfungible: pallet_nonfungible::{Pallet, Storage} = 69,1012 Structure: pallet_structure::{Pallet, Call, Storage, Event<T>} = 70,10131014 // Frontier1015 EVM: pallet_evm::{Pallet, Config, Call, Storage, Event<T>} = 100,1016 Ethereum: pallet_ethereum::{Pallet, Config, Call, Storage, Event, Origin} = 101,10171018 EvmCoderSubstrate: pallet_evm_coder_substrate::{Pallet, Storage} = 150,1019 EvmContractHelpers: pallet_evm_contract_helpers::{Pallet, Storage} = 151,1020 EvmTransactionPayment: pallet_evm_transaction_payment::{Pallet} = 152,1021 EvmMigration: pallet_evm_migration::{Pallet, Call, Storage} = 153,1022 }1023);10241025pub struct TransactionConverter;10261027impl fp_rpc::ConvertTransaction<UncheckedExtrinsic> for TransactionConverter {1028 fn convert_transaction(&self, transaction: pallet_ethereum::Transaction) -> UncheckedExtrinsic {1029 UncheckedExtrinsic::new_unsigned(1030 pallet_ethereum::Call::<Runtime>::transact { transaction }.into(),1031 )1032 }1033}10341035impl fp_rpc::ConvertTransaction<opaque::UncheckedExtrinsic> for TransactionConverter {1036 fn convert_transaction(1037 &self,1038 transaction: pallet_ethereum::Transaction,1039 ) -> opaque::UncheckedExtrinsic {1040 let extrinsic = UncheckedExtrinsic::new_unsigned(1041 pallet_ethereum::Call::<Runtime>::transact { transaction }.into(),1042 );1043 let encoded = extrinsic.encode();1044 opaque::UncheckedExtrinsic::decode(&mut &encoded[..])1045 .expect("Encoded extrinsic is always valid")1046 }1047}10481049/// The address format for describing accounts.1050pub type Address = sp_runtime::MultiAddress<AccountId, ()>;1051/// Block header type as expected by this runtime.1052pub type Header = generic::Header<BlockNumber, BlakeTwo256>;1053/// Block type as expected by this runtime.1054pub type Block = generic::Block<Header, UncheckedExtrinsic>;1055/// A Block signed with a Justification1056pub type SignedBlock = generic::SignedBlock<Block>;1057/// BlockId type as expected by this runtime.1058pub type BlockId = generic::BlockId<Block>;1059/// The SignedExtension to the basic transaction logic.1060pub type SignedExtra = (1061 frame_system::CheckSpecVersion<Runtime>,1062 // system::CheckTxVersion<Runtime>,1063 frame_system::CheckGenesis<Runtime>,1064 frame_system::CheckEra<Runtime>,1065 frame_system::CheckNonce<Runtime>,1066 frame_system::CheckWeight<Runtime>,1067 pallet_charge_transaction::ChargeTransactionPayment<Runtime>,1068 //pallet_contract_helpers::ContractHelpersExtension<Runtime>,1069);1070/// Unchecked extrinsic type as expected by this runtime.1071pub type UncheckedExtrinsic =1072 fp_self_contained::UncheckedExtrinsic<Address, Call, Signature, SignedExtra>;1073/// Extrinsic type that has already been checked.1074pub type CheckedExtrinsic = fp_self_contained::CheckedExtrinsic<AccountId, Call, SignedExtra, H160>;1075/// Executive: handles dispatch to the various modules.1076pub type Executive = frame_executive::Executive<1077 Runtime,1078 Block,1079 frame_system::ChainContext<Runtime>,1080 Runtime,1081 AllPalletsReversedWithSystemFirst,1082>;10831084impl_opaque_keys! {1085 pub struct SessionKeys {1086 pub aura: Aura,1087 }1088}10891090impl fp_self_contained::SelfContainedCall for Call {1091 type SignedInfo = H160;10921093 fn is_self_contained(&self) -> bool {1094 match self {1095 Call::Ethereum(call) => call.is_self_contained(),1096 _ => false,1097 }1098 }10991100 fn check_self_contained(&self) -> Option<Result<Self::SignedInfo, TransactionValidityError>> {1101 match self {1102 Call::Ethereum(call) => call.check_self_contained(),1103 _ => None,1104 }1105 }11061107 fn validate_self_contained(&self, info: &Self::SignedInfo) -> Option<TransactionValidity> {1108 match self {1109 Call::Ethereum(call) => call.validate_self_contained(info),1110 _ => None,1111 }1112 }11131114 fn pre_dispatch_self_contained(1115 &self,1116 info: &Self::SignedInfo,1117 ) -> Option<Result<(), TransactionValidityError>> {1118 match self {1119 Call::Ethereum(call) => call.pre_dispatch_self_contained(info),1120 _ => None,1121 }1122 }11231124 fn apply_self_contained(1125 self,1126 info: Self::SignedInfo,1127 ) -> Option<sp_runtime::DispatchResultWithInfo<PostDispatchInfoOf<Self>>> {1128 match self {1129 call @ Call::Ethereum(pallet_ethereum::Call::transact { .. }) => Some(call.dispatch(1130 Origin::from(pallet_ethereum::RawOrigin::EthereumTransaction(info)),1131 )),1132 _ => None,1133 }1134 }1135}11361137macro_rules! dispatch_unique_runtime {1138 ($collection:ident.$method:ident($($name:ident),*)) => {{1139 let collection = <Runtime as pallet_common::Config>::CollectionDispatch::dispatch(<pallet_common::CollectionHandle<Runtime>>::try_get($collection)?);1140 let dispatch = collection.as_dyn();11411142 Ok(dispatch.$method($($name),*))1143 }};1144}11451146impl_common_runtime_apis!();11471148struct CheckInherents;11491150impl cumulus_pallet_parachain_system::CheckInherents<Block> for CheckInherents {1151 fn check_inherents(1152 block: &Block,1153 relay_state_proof: &cumulus_pallet_parachain_system::RelayChainStateProof,1154 ) -> sp_inherents::CheckInherentsResult {1155 let relay_chain_slot = relay_state_proof1156 .read_slot()1157 .expect("Could not read the relay chain slot from the proof");11581159 let inherent_data =1160 cumulus_primitives_timestamp::InherentDataProvider::from_relay_chain_slot_and_duration(1161 relay_chain_slot,1162 sp_std::time::Duration::from_secs(6),1163 )1164 .create_inherent_data()1165 .expect("Could not create the timestamp inherent data");11661167 inherent_data.check_extrinsics(block)1168 }1169}11701171cumulus_pallet_parachain_system::register_validate_block!(1172 Runtime = Runtime,1173 BlockExecutor = cumulus_pallet_aura_ext::BlockExecutor::<Runtime, Executive>,1174 CheckInherents = CheckInherents,1175);tests/src/interfaces/unique/definitions.tsdiffbeforeafterboth--- a/tests/src/interfaces/unique/definitions.ts
+++ b/tests/src/interfaces/unique/definitions.ts
@@ -52,7 +52,7 @@
constMetadata: fun('Get token constant metadata', [collectionParam, tokenParam], 'Vec<u8>'),
variableMetadata: fun('Get token variable metadata', [collectionParam, tokenParam], 'Vec<u8>'),
tokenExists: fun('Check if token exists', [collectionParam, tokenParam], 'bool'),
- collectionById: fun('Get collection by specified id', [collectionParam], 'Option<UpDataStructsCollection>'),
+ collectionById: fun('Get collection by specified id', [collectionParam], 'Option<UpDataStructsRpcCollection>'),
collectionStats: fun('Get collection stats', [], 'UpDataStructsCollectionStats'),
allowed: fun('Check if user is allowed to use collection', [collectionParam, crossAccountParam()], 'bool'),
nextSponsored: fun('Get number of blocks when sponsored transaction is available', [collectionParam, crossAccountParam(), tokenParam], 'Option<u64>'),