difftreelog
Warnings fixed
in: master
5 files changed
pallets/nft-charge-transaction/src/lib.rsdiffbeforeafterboth--- a/pallets/nft-charge-transaction/src/lib.rs
+++ b/pallets/nft-charge-transaction/src/lib.rs
@@ -135,10 +135,10 @@
}
// check errors
- let error = <pallet_nft_transaction_payment::Module<T>>::check_error(who, call);
- match error {
- Err(error) => return Err(error),
- Ok(error) => {}
+ let _error = <pallet_nft_transaction_payment::Module<T>>::check_error(who, call);
+ match _error {
+ Err(_error) => return Err(_error),
+ Ok(_error) => {}
};
// Determine who is paying transaction fee based on ecnomic model
pallets/nft-transaction-payment/src/lib.rsdiffbeforeafterboth--- a/pallets/nft-transaction-payment/src/lib.rs
+++ b/pallets/nft-transaction-payment/src/lib.rs
@@ -140,7 +140,7 @@
},
Some(pallet_nft::Call::set_variable_meta_data(collection_id, item_id, data)) => {
- Self::withdraw_set_variable_meta_data(who, collection_id, item_id, &data)
+ Self::withdraw_set_variable_meta_data(collection_id, item_id, &data)
},
_ => None,
};
@@ -175,7 +175,7 @@
let collection = pallet_nft::CollectionById::<T>::get(collection_id)?;
// sponsor timeout
- let block_number = <frame_system::Module<T>>::block_number() as T::BlockNumber;
+ let block_number = <frame_system::Pallet<T>>::block_number() as T::BlockNumber;
let limit = collection.limits.sponsor_transfer_timeout;
if pallet_nft::CreateItemBasket::<T>::contains_key((collection_id, &who)) {
@@ -212,7 +212,7 @@
let collection_mode = collection.mode.clone();
// sponsor timeout
- let block_number = <frame_system::Module<T>>::block_number() as T::BlockNumber;
+ let block_number = <frame_system::Pallet<T>>::block_number() as T::BlockNumber;
sponsor_transfer = match collection_mode {
CollectionMode::NFT => {
@@ -246,7 +246,7 @@
limits.fungible_sponsor_transfer_timeout
};
- let block_number = <frame_system::Module<T>>::block_number() as T::BlockNumber;
+ let block_number = <frame_system::Pallet<T>>::block_number() as T::BlockNumber;
let mut sponsored = true;
if pallet_nft::FungibleTransferBasket::<T>::contains_key(collection_id, who) {
let last_tx_block = pallet_nft::FungibleTransferBasket::<T>::get(collection_id, who);
@@ -299,7 +299,6 @@
}
pub fn withdraw_set_variable_meta_data(
- who: &T::AccountId,
collection_id: &CollectionId,
item_id: &TokenId,
data: &Vec<u8>,
@@ -317,7 +316,7 @@
data.len() <= collection.limits.sponsored_data_size as usize
{
if let Some(rate_limit) = collection.limits.sponsored_data_rate_limit {
- let block_number = <frame_system::Module<T>>::block_number() as T::BlockNumber;
+ let block_number = <frame_system::Pallet<T>>::block_number() as T::BlockNumber;
if pallet_nft::VariableMetaDataBasket::<T>::get(collection_id, item_id)
.map(|last_block| block_number - last_block > rate_limit)
@@ -358,7 +357,7 @@
let mut sponsor_transfer = false;
if pallet_nft::ContractSponsoringRateLimit::<T>::contains_key(called_contract.clone()) {
let last_tx_block = pallet_nft::ContractSponsorBasket::<T>::get((&called_contract, &who));
- let block_number = <frame_system::Module<T>>::block_number() as T::BlockNumber;
+ let block_number = <frame_system::Pallet<T>>::block_number() as T::BlockNumber;
let rate_limit = pallet_nft::ContractSponsoringRateLimit::<T>::get(&called_contract);
let limit_time = last_tx_block + rate_limit;
@@ -390,7 +389,7 @@
T::AccountId: UncheckedFrom<T::Hash>
{
- let new_contract_address = <pallet_contracts::Module<T>>::contract_address(
+ let new_contract_address = <pallet_contracts::Pallet<T>>::contract_address(
&who,
code_hash,
salt,
pallets/nft/src/lib.rsdiffbeforeafterboth--- a/pallets/nft/src/lib.rs
+++ b/pallets/nft/src/lib.rs
@@ -13,7 +13,6 @@
#[cfg(feature = "std")]
pub use serde::*;
-use codec::{Decode, Encode};
pub use frame_support::{
construct_runtime, decl_event, decl_module, decl_storage, decl_error,
dispatch::DispatchResult,
runtime/src/chain_extension.rsdiffbeforeafterboth--- a/runtime/src/chain_extension.rs
+++ b/runtime/src/chain_extension.rs
@@ -18,10 +18,6 @@
extern crate pallet_nft;
pub use pallet_nft::*;
use nft_data_structs::*;
-// use crate::Runtime;
-
-use sp_runtime::AccountId32;
-use crate::Vec;
/// Create item parameters
#[derive(Debug, PartialEq, Encode, Decode)]
runtime/src/lib.rsdiffbeforeafterboth1//2// This file is subject to the terms and conditions defined in3// file 'LICENSE', which is part of this source code package.4//56//! The Substrate Node Template runtime. This can be compiled with `#[no_std]`, ready for Wasm.78#![cfg_attr(not(feature = "std"), no_std)]9// `construct_runtime!` does a lot of recursion and requires us to increase the limit to 256.10#![recursion_limit = "1024"]1112// Make the WASM binary available.13#[cfg(feature = "std")]14include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs"));1516use sp_api::impl_runtime_apis;17use sp_core::{ crypto::KeyTypeId, OpaqueMetadata };18// #[cfg(any(feature = "std", test))]19// pub use sp_runtime::BuildStorage;2021use sp_runtime::{22 Permill, Perbill, Percent,23 create_runtime_str, generic, impl_opaque_keys,24 traits::{25 AccountIdLookup, Convert, ConvertInto, BlakeTwo256, Block as BlockT, IdentifyAccount, 26 IdentityLookup, NumberFor, Verify, AccountIdConversion,27 },28 transaction_validity::{TransactionSource, TransactionValidity},29 ApplyExtrinsicResult, MultiSignature,30};3132use sp_std::prelude::*;3334#[cfg(feature = "std")]35use sp_version::NativeVersion;36use sp_version::RuntimeVersion;37pub use pallet_transaction_payment::{Multiplier, TargetedFeeAdjustment, FeeDetails, RuntimeDispatchInfo};38// A few exports that help ease life for downstream crates.39pub use pallet_balances::Call as BalancesCall;40pub use frame_support::{41 construct_runtime,42 match_type,43 dispatch::DispatchResult,44 PalletId,45 parameter_types,46 StorageValue,47 traits::{48 All, Currency, ExistenceRequirement, Get, IsInVec, KeyOwnerProofSystem, LockIdentifier, OnUnbalanced, Randomness49 },50 weights::{51 constants::{BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight, WEIGHT_PER_SECOND},52 DispatchClass, DispatchInfo, GetDispatchInfo, IdentityFee, Pays, PostDispatchInfo, Weight,53 WeightToFeePolynomial, WeightToFeeCoefficient, WeightToFeeCoefficients54 },55};56use pallet_nft_transaction_payment::*;57use pallet_nft_charge_transaction::*;58use nft_data_structs::*;59use pallet_contracts::weights::WeightInfo;60// #[cfg(any(feature = "std", test))]61use frame_system::{62 self as system,63 EnsureRoot, EnsureSigned,64 limits::{BlockWeights, BlockLength},65};66use sp_arithmetic::{traits::{BaseArithmetic, Unsigned}};67use smallvec::smallvec;6869use sp_runtime::{70 traits::{ 71 Dispatchable,72 },73};74use pallet_contracts::chain_extension::UncheckedFrom;757677pub use pallet_timestamp::Call as TimestampCall;78pub use sp_consensus_aura::sr25519::AuthorityId as AuraId;7980// Polkadot imports81use pallet_xcm::XcmPassthrough;82use polkadot_parachain::primitives::Sibling;83use xcm::v0::Xcm;84use xcm::v0::{BodyId, Junction::*, MultiAsset, MultiLocation, MultiLocation::*, NetworkId};85use xcm_builder::{86 AccountId32Aliases, AllowTopLevelPaidExecutionFrom, AllowUnpaidExecutionFrom, CurrencyAdapter,87 EnsureXcmOrigin, FixedWeightBounds, IsConcrete, LocationInverter, NativeAsset,88 ParentAsSuperuser, ParentIsDefault, RelayChainAsNative, SiblingParachainAsNative,89 SiblingParachainConvertsVia, SignedAccountId32AsNative, SignedToAccountId32,90 SovereignSignedViaLocation, TakeWeightCredit, UsingComponents,91};92use xcm_executor::{Config, XcmExecutor};939495mod chain_extension;96use crate::chain_extension::{ NFTExtension, Imbalance };9798/// Re-export a nft pallet99/// TODO: Check this re-export. Is this safe and good style?100extern crate pallet_nft;101pub use pallet_nft::*;102103/// Reimport pallet inflation104extern crate pallet_inflation;105pub use pallet_inflation::*;106107/// An index to a block.108pub type BlockNumber = u32;109110/// Alias to 512-bit hash when used in the context of a transaction signature on the chain.111pub type Signature = MultiSignature;112113/// Some way of identifying an account on the chain. We intentionally make it equivalent114/// to the public key of our transaction signing scheme.115pub type AccountId = <<Signature as Verify>::Signer as IdentifyAccount>::AccountId;116117/// The type for looking up accounts. We don't expect more than 4 billion of them, but you118/// never know...119pub type AccountIndex = u32;120121/// Balance of an account.122pub type Balance = u128;123124/// Index of a transaction in the chain.125pub type Index = u32;126127/// A hash of some data used by the chain.128pub type Hash = sp_core::H256;129130/// Digest item type.131pub type DigestItem = generic::DigestItem<Hash>;132133mod nft_weights;134135/// Opaque types. These are used by the CLI to instantiate machinery that don't need to know136/// the specifics of the runtime. They can then be made to be agnostic over specific formats137/// of data like extrinsics, allowing for them to continue syncing the network through upgrades138/// to even the core data structures.139pub mod opaque {140 use super::*;141142 pub use sp_runtime::OpaqueExtrinsic as UncheckedExtrinsic;143144 /// Opaque block type.145 pub type Block = generic::Block<Header, UncheckedExtrinsic>;146147 pub type SessionHandlers = ();148149 impl_opaque_keys! {150 pub struct SessionKeys {151 pub aura: Aura,152 }153 }154}155156/// This runtime version.157pub const VERSION: RuntimeVersion = RuntimeVersion {158 spec_name: create_runtime_str!("nft"),159 impl_name: create_runtime_str!("nft"),160 authoring_version: 1,161 spec_version: 3,162 impl_version: 1,163 apis: RUNTIME_API_VERSIONS,164 transaction_version: 1,165};166167pub const MILLISECS_PER_BLOCK: u64 = 12000;168169pub const SLOT_DURATION: u64 = MILLISECS_PER_BLOCK;170171// These time units are defined in number of blocks.172pub const MINUTES: BlockNumber = 60_000 / (MILLISECS_PER_BLOCK as BlockNumber);173pub const HOURS: BlockNumber = MINUTES * 60;174pub const DAYS: BlockNumber = HOURS * 24;175176#[derive(codec::Encode, codec::Decode)]177pub enum XCMPMessage<XAccountId, XBalance> {178 /// Transfer tokens to the given account from the Parachain account.179 TransferToken(XAccountId, XBalance),180}181182/// The version information used to identify this runtime when compiled natively.183#[cfg(feature = "std")]184pub fn native_version() -> NativeVersion {185 NativeVersion {186 runtime_version: VERSION,187 can_author_with: Default::default(),188 }189}190191type NegativeImbalance = <Balances as Currency<AccountId>>::NegativeImbalance;192193pub struct DealWithFees;194impl OnUnbalanced<NegativeImbalance> for DealWithFees {195 fn on_unbalanceds<B>(mut fees_then_tips: impl Iterator<Item=NegativeImbalance>) {196 if let Some(fees) = fees_then_tips.next() {197 // for fees, 100% to treasury198 let mut split = fees.ration(100, 0);199 if let Some(tips) = fees_then_tips.next() {200 // for tips, if any, 100% to treasury201 tips.ration_merge_into(100, 0, &mut split);202 }203 Treasury::on_unbalanced(split.0);204 // Author::on_unbalanced(split.1);205 }206 }207}208209/// We assume that ~10% of the block weight is consumed by `on_initalize` handlers.210/// This is used to limit the maximal weight of a single extrinsic.211const AVERAGE_ON_INITIALIZE_RATIO: Perbill = Perbill::from_percent(10);212/// We allow `Normal` extrinsics to fill up the block up to 75%, the rest can be used213/// by Operational extrinsics.214const NORMAL_DISPATCH_RATIO: Perbill = Perbill::from_percent(75);215/// We allow for 2 seconds of compute with a 6 second average block time.216const MAXIMUM_BLOCK_WEIGHT: Weight = 2 * WEIGHT_PER_SECOND;217218parameter_types! {219 pub const BlockHashCount: BlockNumber = 2400;220 pub RuntimeBlockLength: BlockLength =221 BlockLength::max_with_normal_ratio(5 * 1024 * 1024, NORMAL_DISPATCH_RATIO);222 pub const AvailableBlockRatio: Perbill = Perbill::from_percent(75);223 pub const MaximumBlockLength: u32 = 5 * 1024 * 1024;224 pub RuntimeBlockWeights: BlockWeights = BlockWeights::builder()225 .base_block(BlockExecutionWeight::get())226 .for_class(DispatchClass::all(), |weights| {227 weights.base_extrinsic = ExtrinsicBaseWeight::get();228 })229 .for_class(DispatchClass::Normal, |weights| {230 weights.max_total = Some(NORMAL_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT);231 })232 .for_class(DispatchClass::Operational, |weights| {233 weights.max_total = Some(MAXIMUM_BLOCK_WEIGHT);234 // 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}245246impl system::Config for Runtime {247 /// The data to be stored in an account.248 type AccountData = pallet_balances::AccountData<Balance>;249 /// The identifier used to distinguish between accounts.250 type AccountId = AccountId;251 /// The basic call filter to use in dispatchable.252 type BaseCallFilter = ();253 /// Maximum number of block number to block hash mappings to keep (oldest pruned first).254 type BlockHashCount = BlockHashCount;255 /// The maximum length of a block (in bytes).256 type BlockLength = RuntimeBlockLength;257 /// The index type for blocks.258 type BlockNumber = BlockNumber;259 /// The weight of the overhead invoked on the block import process, independent of the extrinsics included in that block.260 type BlockWeights = RuntimeBlockWeights;261 /// The aggregated dispatch type that is available for extrinsics.262 type Call = Call;263 /// The weight of database operations that the runtime can invoke.264 type DbWeight = RocksDbWeight;265 /// The ubiquitous event type.266 type Event = Event;267 /// The type for hashing blocks and tries.268 type Hash = Hash;269 /// The hashing algorithm used.270 type Hashing = BlakeTwo256;271 /// The header type.272 type Header = generic::Header<BlockNumber, BlakeTwo256>;273 /// The index type for storing how many extrinsics an account has signed.274 type Index = Index;275 /// The lookup mechanism to get account ID from whatever is passed in dispatchers.276 type Lookup = AccountIdLookup<AccountId, ()>;277 /// What to do if an account is fully reaped from the system.278 type OnKilledAccount = ();279 /// What to do if a new account is created.280 type OnNewAccount = ();281 type OnSetCode = cumulus_pallet_parachain_system::ParachainSetCode<Self>;282 /// The ubiquitous origin type.283 type Origin = Origin;284 /// This type is being generated by `construct_runtime!`.285 type PalletInfo = PalletInfo;286 /// This is used as an identifier of the chain. 42 is the generic substrate prefix.287 type SS58Prefix = SS58Prefix;288 /// Weight information for the extrinsics of this pallet.289 type SystemWeightInfo = system::weights::SubstrateWeight<Runtime>;290 /// Version of the runtime.291 type Version = Version;292}293294parameter_types! {295 pub const MinimumPeriod: u64 = SLOT_DURATION / 2;296}297298impl pallet_timestamp::Config for Runtime {299 /// A timestamp: milliseconds since the unix epoch.300 type Moment = u64;301 type OnTimestampSet = ();302 type MinimumPeriod = MinimumPeriod;303 type WeightInfo = ();304}305306parameter_types! {307 // pub const ExistentialDeposit: u128 = 500;308 pub const ExistentialDeposit: u128 = 0;309 pub const MaxLocks: u32 = 50;310}311312impl pallet_balances::Config for Runtime {313 type MaxLocks = MaxLocks;314 /// The type for recording an account's balance.315 type Balance = Balance;316 /// The ubiquitous event type.317 type Event = Event;318 type DustRemoval = Treasury;319 type ExistentialDeposit = ExistentialDeposit;320 type AccountStore = System;321 type WeightInfo = pallet_balances::weights::SubstrateWeight<Runtime>;322}323324pub const MICROUNIQUE: Balance = 1_000_000_000;325pub const MILLIUNIQUE: Balance = 1_000 * MICROUNIQUE;326pub const CENTIUNIQUE: Balance = 10 * MILLIUNIQUE;327pub const UNIQUE: Balance = 100 * CENTIUNIQUE;328329pub const fn deposit(items: u32, bytes: u32) -> Balance {330 items as Balance * 15 * CENTIUNIQUE + (bytes as Balance) * 6 * CENTIUNIQUE331}332333parameter_types! {334 pub TombstoneDeposit: Balance = deposit(335 1,336 sp_std::mem::size_of::<pallet_contracts::Pallet<Runtime>> as u32,337 );338 pub DepositPerContract: Balance = TombstoneDeposit::get();339 pub const DepositPerStorageByte: Balance = deposit(0, 1);340 pub const DepositPerStorageItem: Balance = deposit(1, 0);341 pub RentFraction: Perbill = Perbill::from_rational(1u32, 30 * DAYS);342 pub const SurchargeReward: Balance = 150 * MILLIUNIQUE;343 pub const SignedClaimHandicap: u32 = 2;344 pub const MaxDepth: u32 = 32;345 pub const MaxValueSize: u32 = 16 * 1024;346 pub const MaxCodeSize: u32 = 1024 * 1024 * 25; // 25 Mb 347 // The lazy deletion runs inside on_initialize.348 pub DeletionWeightLimit: Weight = AVERAGE_ON_INITIALIZE_RATIO *349 RuntimeBlockWeights::get().max_block;350 // The weight needed for decoding the queue should be less or equal than a fifth351 // of the overall weight dedicated to the lazy deletion.352 pub DeletionQueueDepth: u32 = ((DeletionWeightLimit::get() / (353 <Runtime as pallet_contracts::Config>::WeightInfo::on_initialize_per_queue_item(1) -354 <Runtime as pallet_contracts::Config>::WeightInfo::on_initialize_per_queue_item(0)355 )) / 5) as u32;356 pub Schedule: pallet_contracts::Schedule<Runtime> = Default::default();357}358359impl pallet_contracts::Config for Runtime {360 type Time = Timestamp;361 type Randomness = RandomnessCollectiveFlip;362 type Currency = Balances;363 type Event = Event;364 type RentPayment = ();365 type SignedClaimHandicap = SignedClaimHandicap;366 type TombstoneDeposit = TombstoneDeposit;367 type DepositPerContract = DepositPerContract;368 type DepositPerStorageByte = DepositPerStorageByte;369 type DepositPerStorageItem = DepositPerStorageItem;370 type RentFraction = RentFraction;371 type SurchargeReward = SurchargeReward;372 // type MaxDepth = MaxDepth;373 // type MaxValueSize = MaxValueSize;374 type WeightPrice = pallet_transaction_payment::Module<Self>;375 type WeightInfo = pallet_contracts::weights::SubstrateWeight<Self>;376 type ChainExtension = NFTExtension;377 type DeletionQueueDepth = DeletionQueueDepth;378 type DeletionWeightLimit = DeletionWeightLimit;379 // type MaxCodeSize = MaxCodeSize;380 type Schedule = Schedule;381 type CallStack = [pallet_contracts::Frame<Self>; 31];382}383384parameter_types! {385 pub const TransactionByteFee: Balance = 501 * MICROUNIQUE; // Targeting 0.1 Unique per NFT transfer 386}387388/// Linear implementor of `WeightToFeePolynomial` 389pub struct LinearFee<T>(sp_std::marker::PhantomData<T>);390391impl<T> WeightToFeePolynomial for LinearFee<T> where392 T: BaseArithmetic + From<u32> + Copy + Unsigned393{394 type Balance = T;395396 fn polynomial() -> WeightToFeeCoefficients<Self::Balance> {397 smallvec!(WeightToFeeCoefficient {398 coeff_integer: 146_700u32.into(), // Targeting 0.1 Unique per NFT transfer399 coeff_frac: Perbill::zero(),400 negative: false,401 degree: 1,402 })403 }404}405406impl pallet_transaction_payment::Config for Runtime {407 type OnChargeTransaction = pallet_transaction_payment::CurrencyAdapter<Balances, ()>;408 type TransactionByteFee = TransactionByteFee;409 type WeightToFee = LinearFee<Balance>;410 type FeeMultiplierUpdate = ();411}412413parameter_types! {414 pub const ProposalBond: Permill = Permill::from_percent(5);415 pub const ProposalBondMinimum: Balance = 1 * UNIQUE;416 pub const SpendPeriod: BlockNumber = 5 * MINUTES;417 pub const Burn: Permill = Permill::from_percent(0);418 pub const TipCountdown: BlockNumber = 1 * DAYS;419 pub const TipFindersFee: Percent = Percent::from_percent(20);420 pub const TipReportDepositBase: Balance = 1 * UNIQUE;421 pub const DataDepositPerByte: Balance = 1 * CENTIUNIQUE;422 pub const BountyDepositBase: Balance = 1 * UNIQUE;423 pub const BountyDepositPayoutDelay: BlockNumber = 1 * DAYS;424 pub const TreasuryModuleId: PalletId = PalletId(*b"py/trsry");425 pub const BountyUpdatePeriod: BlockNumber = 14 * DAYS;426 pub const MaximumReasonLength: u32 = 16384;427 pub const BountyCuratorDeposit: Permill = Permill::from_percent(50);428 pub const BountyValueMinimum: Balance = 5 * UNIQUE;429 pub const MaxApprovals: u32 = 100;430}431432impl pallet_treasury::Config for Runtime {433 type PalletId = TreasuryModuleId;434 type Currency = Balances;435 type ApproveOrigin = EnsureRoot<AccountId>;436 type RejectOrigin = EnsureRoot<AccountId>;437 type Event = Event;438 type OnSlash = ();439 type ProposalBond = ProposalBond;440 type ProposalBondMinimum = ProposalBondMinimum;441 type SpendPeriod = SpendPeriod;442 type Burn = Burn;443 type BurnDestination = ();444 type SpendFunds = ();445 type WeightInfo = pallet_treasury::weights::SubstrateWeight<Runtime>;446 type MaxApprovals = MaxApprovals;447}448449impl pallet_sudo::Config for Runtime {450 type Event = Event;451 type Call = Call;452}453454parameter_types! {455 pub const MinVestedTransfer: Balance = 10 * UNIQUE;456}457458impl pallet_vesting::Config for Runtime {459 type Event = Event;460 type Currency = Balances;461 type BlockNumberToBalance = ConvertInto;462 type MinVestedTransfer = MinVestedTransfer;463 type WeightInfo = ();464}465466parameter_types! {467 pub const ReservedDmpWeight: Weight = MAXIMUM_BLOCK_WEIGHT / 4;468 pub const ReservedXcmpWeight: Weight = MAXIMUM_BLOCK_WEIGHT / 4;469}470471impl cumulus_pallet_parachain_system::Config for Runtime {472 type Event = Event;473 type OnValidationData = ();474 type SelfParaId = parachain_info::Pallet<Runtime>;475 // type DownwardMessageHandlers = cumulus_primitives_utility::UnqueuedDmpAsParent<476 // MaxDownwardMessageWeight,477 // XcmExecutor<XcmConfig>,478 // Call,479 // >;480 type OutboundXcmpMessageSource = XcmpQueue;481 type DmpMessageHandler = DmpQueue;482 type ReservedDmpWeight = ReservedDmpWeight;483 type ReservedXcmpWeight = ReservedXcmpWeight;484 type XcmpMessageHandler = XcmpQueue;485}486487impl parachain_info::Config for Runtime {}488489impl cumulus_pallet_aura_ext::Config for Runtime {}490491parameter_types! {492 pub const RelayLocation: MultiLocation = X1(Parent);493 pub const RelayNetwork: NetworkId = NetworkId::Polkadot;494 pub RelayOrigin: Origin = cumulus_pallet_xcm::Origin::Relay.into();495 pub Ancestry: MultiLocation = X1(Parachain(ParachainInfo::parachain_id().into()));496}497498/// Type for specifying how a `MultiLocation` can be converted into an `AccountId`. This is used499/// when determining ownership of accounts for asset transacting and when attempting to use XCM500/// `Transact` in order to determine the dispatch Origin.501pub type LocationToAccountId = (502 // The parent (Relay-chain) origin converts to the default `AccountId`.503 ParentIsDefault<AccountId>,504 // Sibling parachain origins convert to AccountId via the `ParaId::into`.505 SiblingParachainConvertsVia<Sibling, AccountId>,506 // Straight up local `AccountId32` origins just alias directly to `AccountId`.507 AccountId32Aliases<RelayNetwork, AccountId>,508);509510/// Means for transacting assets on this chain.511pub type LocalAssetTransactor = CurrencyAdapter<512 // Use this currency:513 Balances,514 // Use this currency when it is a fungible asset matching the given location or name:515 IsConcrete<RelayLocation>,516 // Do a simple punn to convert an AccountId32 MultiLocation into a native chain account ID:517 LocationToAccountId,518 // Our chain's account ID type (we can't get away without mentioning it explicitly):519 AccountId,520 // We don't track any teleports.521 (),522>;523524/// This is the type we use to convert an (incoming) XCM origin into a local `Origin` instance,525/// ready for dispatching a transaction with Xcm's `Transact`. There is an `OriginKind` which can526/// biases the kind of local `Origin` it will become.527pub type XcmOriginToTransactDispatchOrigin = (528 // Sovereign account converter; this attempts to derive an `AccountId` from the origin location529 // using `LocationToAccountId` and then turn that into the usual `Signed` origin. Useful for530 // foreign chains who want to have a local sovereign account on this chain which they control.531 SovereignSignedViaLocation<LocationToAccountId, Origin>,532 // Native converter for Relay-chain (Parent) location; will converts to a `Relay` origin when533 // recognised.534 RelayChainAsNative<RelayOrigin, Origin>,535 // Native converter for sibling Parachains; will convert to a `SiblingPara` origin when536 // recognised.537 SiblingParachainAsNative<cumulus_pallet_xcm::Origin, Origin>,538 // Superuser converter for the Relay-chain (Parent) location. This will allow it to issue a539 // transaction from the Root origin.540 ParentAsSuperuser<Origin>,541 // Native signed account converter; this just converts an `AccountId32` origin into a normal542 // `Origin::Signed` origin of the same 32-byte value.543 SignedAccountId32AsNative<RelayNetwork, Origin>,544 // Xcm origins can be represented natively under the Xcm pallet's Xcm origin.545 XcmPassthrough<Origin>,546);547548parameter_types! {549 // One XCM operation is 1_000_000 weight - almost certainly a conservative estimate.550 pub UnitWeightCost: Weight = 1_000_000;551 // 1200 UNIQUEs buy 1 second of weight.552 pub const WeightPrice: (MultiLocation, u128) = (X1(Parent), 1_200 * UNIQUE);553}554555match_type! {556 pub type ParentOrParentsUnitPlurality: impl Contains<MultiLocation> = {557 X1(Parent) | X2(Parent, Plurality { id: BodyId::Unit, .. })558 };559}560561pub type Barrier = (562 TakeWeightCredit,563 AllowTopLevelPaidExecutionFrom<All<MultiLocation>>,564 AllowUnpaidExecutionFrom<ParentOrParentsUnitPlurality>,565 // ^^^ Parent & its unit plurality gets free execution566);567568pub struct XcmConfig;569impl Config for XcmConfig {570 type Call = Call;571 type XcmSender = XcmRouter;572 // How to withdraw and deposit an asset.573 type AssetTransactor = LocalAssetTransactor;574 type OriginConverter = XcmOriginToTransactDispatchOrigin;575 type IsReserve = NativeAsset;576 type IsTeleporter = NativeAsset; // <- should be enough to allow teleportation of ROC577 type LocationInverter = LocationInverter<Ancestry>;578 type Barrier = Barrier;579 type Weigher = FixedWeightBounds<UnitWeightCost, Call>;580 type Trader = UsingComponents<IdentityFee<Balance>, RelayLocation, AccountId, Balances, ()>;581 type ResponseHandler = (); // Don't handle responses for now.582}583584// parameter_types! {585// pub const MaxDownwardMessageWeight: Weight = MAXIMUM_BLOCK_WEIGHT / 10;586// }587588/// No local origins on this chain are allowed to dispatch XCM sends/executions.589pub type LocalOriginToLocation = (SignedToAccountId32<Origin, AccountId, RelayNetwork>,);590591/// The means for routing XCM messages which are not for local execution into the right message592/// queues.593pub type XcmRouter = (594 // Two routers - use UMP to communicate with the relay chain:595 cumulus_primitives_utility::ParentAsUmp<ParachainSystem>,596 // ..and XCMP to communicate with the sibling chains.597 XcmpQueue,598);599600impl pallet_xcm::Config for Runtime {601 type Event = Event;602 type SendXcmOrigin = EnsureXcmOrigin<Origin, LocalOriginToLocation>;603 type XcmRouter = XcmRouter;604 type ExecuteXcmOrigin = EnsureXcmOrigin<Origin, LocalOriginToLocation>;605 type XcmExecuteFilter = All<(MultiLocation, Xcm<Call>)>;606 type XcmExecutor = XcmExecutor<XcmConfig>;607 type XcmTeleportFilter = All<(MultiLocation, Vec<MultiAsset>)>;608 type XcmReserveTransferFilter = ();609 type Weigher = FixedWeightBounds<UnitWeightCost, Call>;610}611612impl cumulus_pallet_xcm::Config for Runtime {613 type Event = Event;614 type XcmExecutor = XcmExecutor<XcmConfig>;615}616617impl cumulus_pallet_xcmp_queue::Config for Runtime {618 type Event = Event;619 type XcmExecutor = XcmExecutor<XcmConfig>;620 type ChannelInfo = ParachainSystem;621}622623impl cumulus_pallet_dmp_queue::Config for Runtime {624 type Event = Event;625 type XcmExecutor = XcmExecutor<XcmConfig>;626 type ExecuteOverweightOrigin = frame_system::EnsureRoot<AccountId>;627}628629impl pallet_aura::Config for Runtime {630 type AuthorityId = AuraId;631}632633parameter_types! {634 pub TreasuryAccountId: AccountId = TreasuryModuleId::get().into_account();635 pub const CollectionCreationPrice: Balance = 100 * UNIQUE;636}637638/// Used for the pallet nft in `./nft.rs`639impl pallet_nft::Config for Runtime {640 type Event = Event;641 type WeightInfo = nft_weights::WeightInfo;642 type Currency = Balances;643 type CollectionCreationPrice = CollectionCreationPrice;644 type TreasuryAccountId = TreasuryAccountId;645}646647parameter_types! {648 pub const InflationBlockInterval: BlockNumber = 100; // every time per how many blocks inflation is applied649}650651/// Used for the pallet inflation652impl pallet_inflation::Config for Runtime {653 type Currency = Balances;654 type TreasuryAccountId = TreasuryAccountId;655 type InflationBlockInterval = InflationBlockInterval;656}657658parameter_types! {659 pub MaximumSchedulerWeight: Weight = Perbill::from_percent(50) *660 RuntimeBlockWeights::get().max_block;661 pub const MaxScheduledPerBlock: u32 = 50;662}663664pub struct Sponsoring;665impl SponsoringResolve<AccountId, Call> for Sponsoring {666667 fn resolve(who: &AccountId, call: &Call) -> Option<AccountId> 668 where 669 Call: Dispatchable<Info=DispatchInfo>,670 Call: IsSubType<pallet_nft::Call<Runtime>>, 671 Call: IsSubType<pallet_contracts::Call<Runtime>>,672 AccountId: AsRef<[u8]>,673 AccountId: UncheckedFrom<Hash>674 {675 pallet_nft_transaction_payment::Module::<Runtime>::withdraw_type(who, call)676 }677}678679impl pallet_scheduler::Config for Runtime {680 type Event = Event;681 type Origin = Origin;682 type PalletsOrigin = OriginCaller;683 type Call = Call;684 type MaximumWeight = MaximumSchedulerWeight;685 type ScheduleOrigin = EnsureSigned<AccountId>;686 type MaxScheduledPerBlock = MaxScheduledPerBlock;687 type Sponsoring = Sponsoring;688 type WeightInfo = ();689}690691impl pallet_nft_transaction_payment::Config for Runtime {692}693694impl pallet_nft_charge_transaction::Config for Runtime {695}696697construct_runtime!(698 pub enum Runtime where699 Block = Block,700 NodeBlock = opaque::Block,701 UncheckedExtrinsic = UncheckedExtrinsic702 {703 Balances: pallet_balances::{Pallet, Call, Storage, Config<T>, Event<T>} = 30,704 Contracts: pallet_contracts::{Pallet, Call, Storage, Event<T>},705 RandomnessCollectiveFlip: pallet_randomness_collective_flip::{Pallet, Call, Storage},706 Timestamp: pallet_timestamp::{Pallet, Call, Storage, Inherent},707 TransactionPayment: pallet_transaction_payment::{Pallet, Storage},708 Treasury: pallet_treasury::{Pallet, Call, Storage, Config, Event<T>},709 Sudo: pallet_sudo::{Pallet, Call, Storage, Config<T>, Event<T>},710 System: system::{Pallet, Call, Storage, Config, Event<T>},711 Vesting: pallet_vesting::{Pallet, Call, Config<T>, Storage, Event<T>},712713 ParachainSystem: cumulus_pallet_parachain_system::{Pallet, Call, Storage, Inherent, Event<T>, ValidateUnsigned} = 20,714 ParachainInfo: parachain_info::{Pallet, Storage, Config} = 21,715716 Aura: pallet_aura::{Pallet, Config<T>},717 AuraExt: cumulus_pallet_aura_ext::{Pallet, Config},718719 // XCM helpers.720 XcmpQueue: cumulus_pallet_xcmp_queue::{Pallet, Call, Storage, Event<T>} = 50,721 PolkadotXcm: pallet_xcm::{Pallet, Call, Event<T>, Origin} = 51,722 CumulusXcm: cumulus_pallet_xcm::{Pallet, Call, Event<T>, Origin} = 52,723 DmpQueue: cumulus_pallet_dmp_queue::{Pallet, Call, Storage, Event<T>} = 53,724725726 // Unique Pallets727 Inflation: pallet_inflation::{Pallet, Call, Storage},728 Nft: pallet_nft::{Pallet, Call, Config<T>, Storage, Event<T>},729 Scheduler: pallet_scheduler::{Pallet, Call, Storage, Event<T>},730 NftPayment: pallet_nft_transaction_payment::{Pallet, Call, Storage},731 Charging: pallet_nft_charge_transaction::{Pallet, Call, Storage },732 }733);734735/// The address format for describing accounts.736pub type Address = sp_runtime::MultiAddress<AccountId, ()>;737/// Block header type as expected by this runtime.738pub type Header = generic::Header<BlockNumber, BlakeTwo256>;739/// Block type as expected by this runtime.740pub type Block = generic::Block<Header, UncheckedExtrinsic>;741/// A Block signed with a Justification742pub type SignedBlock = generic::SignedBlock<Block>;743/// BlockId type as expected by this runtime.744pub type BlockId = generic::BlockId<Block>;745/// The SignedExtension to the basic transaction logic.746pub type SignedExtra = (747 system::CheckSpecVersion<Runtime>,748 // system::CheckTxVersion<Runtime>,749 system::CheckGenesis<Runtime>,750 system::CheckEra<Runtime>,751 system::CheckNonce<Runtime>,752 system::CheckWeight<Runtime>,753 pallet_nft_charge_transaction::ChargeTransactionPayment<Runtime>,754);755/// Unchecked extrinsic type as expected by this runtime.756pub type UncheckedExtrinsic = generic::UncheckedExtrinsic<Address, Call, Signature, SignedExtra>;757/// Extrinsic type that has already been checked.758pub type CheckedExtrinsic = generic::CheckedExtrinsic<AccountId, Call, SignedExtra>;759/// Executive: handles dispatch to the various modules.760pub type Executive = frame_executive::Executive<761 Runtime,762 Block,763 frame_system::ChainContext<Runtime>,764 Runtime,765 AllPallets,766>;767768impl_opaque_keys! {769 pub struct SessionKeys {770 pub aura: Aura,771 }772}773774impl_runtime_apis! {775 impl sp_api::Core<Block> for Runtime {776 fn version() -> RuntimeVersion {777 VERSION778 }779780 fn execute_block(block: Block) {781 Executive::execute_block(block)782 }783784 fn initialize_block(header: &<Block as BlockT>::Header) {785 Executive::initialize_block(header)786 }787 }788789 impl sp_api::Metadata<Block> for Runtime {790 fn metadata() -> OpaqueMetadata {791 Runtime::metadata().into()792 }793 }794795 impl sp_block_builder::BlockBuilder<Block> for Runtime {796 fn apply_extrinsic(extrinsic: <Block as BlockT>::Extrinsic) -> ApplyExtrinsicResult {797 Executive::apply_extrinsic(extrinsic)798 }799800 fn finalize_block() -> <Block as BlockT>::Header {801 Executive::finalize_block()802 }803804 fn inherent_extrinsics(data: sp_inherents::InherentData) -> Vec<<Block as BlockT>::Extrinsic> {805 data.create_extrinsics()806 }807808 fn check_inherents(809 block: Block,810 data: sp_inherents::InherentData,811 ) -> sp_inherents::CheckInherentsResult {812 data.check_extrinsics(&block)813 }814815 // fn random_seed() -> <Block as BlockT>::Hash {816 // RandomnessCollectiveFlip::random_seed().0817 // }818 }819820 impl sp_transaction_pool::runtime_api::TaggedTransactionQueue<Block> for Runtime {821 fn validate_transaction(822 source: TransactionSource,823 tx: <Block as BlockT>::Extrinsic,824 ) -> TransactionValidity {825 Executive::validate_transaction(source, tx)826 }827 }828829 impl sp_offchain::OffchainWorkerApi<Block> for Runtime {830 fn offchain_worker(header: &<Block as BlockT>::Header) {831 Executive::offchain_worker(header)832 }833 }834835 impl sp_session::SessionKeys<Block> for Runtime {836 fn decode_session_keys(837 encoded: Vec<u8>,838 ) -> Option<Vec<(Vec<u8>, KeyTypeId)>> {839 SessionKeys::decode_into_raw_public_keys(&encoded)840 }841842 fn generate_session_keys(seed: Option<Vec<u8>>) -> Vec<u8> {843 SessionKeys::generate(seed)844 }845 }846847 impl sp_consensus_aura::AuraApi<Block, AuraId> for Runtime {848 fn slot_duration() -> sp_consensus_aura::SlotDuration {849 sp_consensus_aura::SlotDuration::from_millis(Aura::slot_duration())850 }851852 fn authorities() -> Vec<AuraId> {853 Aura::authorities()854 }855 }856857 impl cumulus_primitives_core::CollectCollationInfo<Block> for Runtime {858 fn collect_collation_info() -> cumulus_primitives_core::CollationInfo {859 ParachainSystem::collect_collation_info()860 }861 }862863 impl frame_system_rpc_runtime_api::AccountNonceApi<Block, AccountId, Index> for Runtime {864 fn account_nonce(account: AccountId) -> Index {865 System::account_nonce(account)866 }867 }868869 impl pallet_transaction_payment_rpc_runtime_api::TransactionPaymentApi<Block, Balance> for Runtime {870 fn query_info(uxt: <Block as BlockT>::Extrinsic, len: u32) -> RuntimeDispatchInfo<Balance> {871 TransactionPayment::query_info(uxt, len)872 }873 fn query_fee_details(uxt: <Block as BlockT>::Extrinsic, len: u32) -> FeeDetails<Balance> {874 TransactionPayment::query_fee_details(uxt, len)875 }876 }877878 impl pallet_contracts_rpc_runtime_api::ContractsApi<Block, AccountId, Balance, BlockNumber, Hash>879 for Runtime880 {881 fn call(882 origin: AccountId,883 dest: AccountId,884 value: Balance,885 gas_limit: u64,886 input_data: Vec<u8>,887 ) -> pallet_contracts_primitives::ContractExecResult {888 Contracts::bare_call(origin, dest, value, gas_limit, input_data, false)889 }890891 fn instantiate(892 origin: AccountId,893 endowment: Balance,894 gas_limit: u64,895 code: pallet_contracts_primitives::Code<Hash>,896 data: Vec<u8>,897 salt: Vec<u8>,898 ) -> pallet_contracts_primitives::ContractInstantiateResult<AccountId, BlockNumber>899 {900 Contracts::bare_instantiate(origin, endowment, gas_limit, code, data, salt, true, false)901 }902903 fn get_storage(904 address: AccountId,905 key: [u8; 32],906 ) -> pallet_contracts_primitives::GetStorageResult {907 Contracts::get_storage(address, key)908 }909910 fn rent_projection(911 address: AccountId,912 ) -> pallet_contracts_primitives::RentProjectionResult<BlockNumber> {913 Contracts::rent_projection(address)914 }915 }916917 #[cfg(feature = "runtime-benchmarks")]918 impl frame_benchmarking::Benchmark<Block> for Runtime {919 fn dispatch_benchmark(920 config: frame_benchmarking::BenchmarkConfig921 ) -> Result<Vec<frame_benchmarking::BenchmarkBatch>, sp_runtime::RuntimeString> {922 use frame_benchmarking::{Benchmarking, BenchmarkBatch, add_benchmark, TrackedStorageKey};923924 let whitelist: Vec<TrackedStorageKey> = vec![925 // Alice account926 hex_literal::hex!("d43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d").to_vec().into(),927 // // Total Issuance928 // hex_literal::hex!("c2261276cc9d1f8598ea4b6a74b15c2f57c875e4cff74148e4628f264b974c80").to_vec().into(),929 // // Execution Phase930 // hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef7ff553b5a9862a516939d82b3d3d8661a").to_vec().into(),931 // // Event Count932 // hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef70a98fdbe9ce6c55837576c60c7af3850").to_vec().into(),933 // // System Events934 // hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef780d41e5e16056765bc8461851072c9d7").to_vec().into(),935 ];936937 let mut batches = Vec::<BenchmarkBatch>::new();938 let params = (&config, &whitelist);939940 add_benchmark!(params, batches, pallet_nft, Nft);941 add_benchmark!(params, batches, pallet_inflation, Inflation);942943 if batches.is_empty() { return Err("Benchmark not found for this pallet.".into()) }944 Ok(batches)945 }946 }947}948949cumulus_pallet_parachain_system::register_validate_block!(950 Runtime,951 cumulus_pallet_aura_ext::BlockExecutor::<Runtime, Executive>,952);