difftreelog
wip parachains
in: master
2 files changed
runtime/Cargo.tomldiffbeforeafterboth1################################################################################2# Package 31[package]4[package]2authors = ['UseTech Professional <https://usetech.com/blockchain>']5authors = ['Unique Network <support@uniquenetwork.io>']6build = 'build.rs'7description = 'Substrate node nft'3edition = '2018'8edition = '2018'4homepage = 'https://substrate.io'9homepage = 'https://unique.network'5license = 'All Rights Reserved'10license = 'All Rights Reserved'6name = 'nft-runtime'11name = 'nft-runtime'7repository = 'https://github.com/usetech-llc/nft_parachain/'12repository = 'https://github.com/usetech-llc/nft_private/'8version = '3.0.0'13version = '3.0.0'91410[package.metadata.docs.rs]15[package.metadata.docs.rs]11targets = ['x86_64-unknown-linux-gnu']16targets = ['x86_64-unknown-linux-gnu']121713[build-dependencies]18[features]14substrate-wasm-builder = '4.0.0'19default = ['std']1520runtime-benchmarks = [16# alias "parity-scale-code" to "codec"21 'hex-literal',22 'frame-benchmarking',23 'frame-support/runtime-benchmarks',24 'frame-system-benchmarking',25 'frame-system/runtime-benchmarks',26 'pallet-balances/runtime-benchmarks',27 'pallet-timestamp/runtime-benchmarks',28 'pallet-nft/runtime-benchmarks',29 'pallet-inflation/runtime-benchmarks',30 'sp-runtime/runtime-benchmarks',31]32std = [33 'codec/std',34 'cumulus-pallet-parachain-system/std',35 'cumulus-pallet-xcm/std',36 'cumulus-pallet-xcmp-queue/std',37 'cumulus-primitives-core/std',38 'cumulus-primitives-utility/std',39 'frame-executive/std',40 'frame-support/std',41 'frame-system/std',42 'frame-system-rpc-runtime-api/std',43 'pallet-balances/std',44 'pallet-contracts/std',45 'pallet-contracts-primitives/std',46 'pallet-contracts-rpc-runtime-api/std',47 'pallet-randomness-collective-flip/std',48 'pallet-sudo/std',49 'pallet-timestamp/std',50 'pallet-transaction-payment/std',51 'pallet-transaction-payment-rpc-runtime-api/std',52 'pallet-treasury/std',53 'pallet-vesting/std',54 'serde',55 'sp-api/std',56 'sp-block-builder/std',57 'sp-core/std',58 'sp-inherents/std',59 'sp-io/std',60 'sp-offchain/std',61 'sp-runtime/std',62 'sp-session/std',63 'sp-std/std',64 'sp-transaction-pool/std',65 'sp-version/std',66 'xcm/std',67 'xcm-builder/std',68 'xcm-executor/std',6970 'pallet-inflation/std',71 'pallet-nft/std',72]7374################################################################################75# Substrate Dependencies7617[dependencies.codec]77[dependencies.codec]18default-features = false78default-features = false19features = ['derive']79features = ['derive']20package = 'parity-scale-codec'80package = 'parity-scale-codec'21version = '2.0.0'81version = '2.0.0'228223[dependencies]83[dependencies.frame-benchmarking]24hex-literal = { optional = true, version = '0.3.1' }84default-features = false85git = 'https://github.com/paritytech/substrate.git'86optional = true87branch = 'rococo-v1'88version = '3.0.0'8990[dependencies.frame-executive]25serde = { features = ['derive'], optional = true, version = '1.0.119' }91default-features = false2692git = 'https://github.com/paritytech/substrate.git'27# local dependencies93branch = 'rococo-v1'94version = '3.0.0'9596[dependencies.frame-support]28pallet-nft = { path = '../pallets/nft', default-features = false, version = '3.0.0' }97default-features = false98git = 'https://github.com/paritytech/substrate.git'99branch = 'rococo-v1'100version = '3.0.0'101102[dependencies.frame-system]29pallet-inflation = { path = '../pallets/inflation', default-features = false, version = '3.0.0' }103default-features = false30104git = 'https://github.com/paritytech/substrate.git'31# Substrate dependencies105branch = 'rococo-v1'106version = '3.0.0'107108[dependencies.frame-system-benchmarking]32frame-benchmarking = { default-features = false, optional = true, version = '3.0.0' }109default-features = false110git = 'https://github.com/paritytech/substrate.git'111optional = true112branch = 'rococo-v1'113version = '3.0.0'114115[dependencies.frame-system-rpc-runtime-api]33frame-executive = { default-features = false, version = '3.0.0' }116default-features = false117git = 'https://github.com/paritytech/substrate.git'118branch = 'rococo-v1'119version = '3.0.0'120121[dependencies.hex-literal]122optional = true123version = '0.3.1'124125[dependencies.serde]126features = ['derive']34frame-support = { default-features = false, version = '3.0.0' }127optional = true128version = '1.0.119'129130[dependencies.pallet-balances]131default-features = false132git = 'https://github.com/paritytech/substrate.git'133branch = 'rococo-v1'134version = '3.0.0'135136# Contracts specific packages137[dependencies.pallet-contracts]35frame-system = { default-features = false, version = '3.0.0' }138git = 'https://github.com/paritytech/substrate.git'139default-features = false140branch = 'rococo-v1'141version = '3.0.0'142143[dependencies.pallet-contracts-primitives]36frame-system-benchmarking = { default-features = false, optional = true, version = '3.0.0' }144git = 'https://github.com/paritytech/substrate.git'145default-features = false146branch = 'rococo-v1'147version = '3.0.0'148149[dependencies.pallet-contracts-rpc-runtime-api]37frame-system-rpc-runtime-api = { default-features = false, version = '3.0.0' }150git = 'https://github.com/paritytech/substrate.git'151default-features = false152branch = 'rococo-v1'153version = '3.0.0'154155[dependencies.pallet-randomness-collective-flip]38pallet-aura = { default-features = false, version = '3.0.0' }156default-features = false157git = 'https://github.com/paritytech/substrate.git'158branch = 'rococo-v1'159version = '3.0.0'160161[dependencies.pallet-sudo]39pallet-balances = { default-features = false, version = '3.0.0' }162default-features = false163git = 'https://github.com/paritytech/substrate.git'164branch = 'rococo-v1'165version = '3.0.0'166167[dependencies.pallet-timestamp]40pallet-contracts = { default-features = false, version = '3.0.0' }168default-features = false169git = 'https://github.com/paritytech/substrate.git'170branch = 'rococo-v1'171version = '3.0.0'172173[dependencies.pallet-transaction-payment]41pallet-contracts-primitives = { default-features = false, version = '3.0.0' }174default-features = false175git = 'https://github.com/paritytech/substrate.git'176branch = 'rococo-v1'177version = '3.0.0'178179[dependencies.pallet-transaction-payment-rpc-runtime-api]42pallet-contracts-rpc-runtime-api = { default-features = false, version = '3.0.0' }180default-features = false181git = 'https://github.com/paritytech/substrate.git'182branch = 'rococo-v1'183version = '3.0.0'184185[dependencies.pallet-treasury]43pallet-grandpa = { default-features = false, version = '3.0.0' }186default-features = false187git = 'https://github.com/paritytech/substrate.git'188branch = 'rococo-v1'189version = '3.0.0'190191[dependencies.pallet-vesting]44pallet-randomness-collective-flip = { default-features = false, version = '3.0.0' }192default-features = false193git = 'https://github.com/paritytech/substrate.git'194branch = 'rococo-v1'195version = '3.0.0'196197[dependencies.sp-arithmetic]45pallet-sudo = { default-features = false, version = '3.0.0' }198default-features = false199git = 'https://github.com/paritytech/substrate.git'200branch = 'rococo-v1'201version = '3.0.0'202203[dependencies.sp-api]46pallet-timestamp = { default-features = false, version = '3.0.0' }204default-features = false205git = 'https://github.com/paritytech/substrate.git'206branch = 'rococo-v1'207version = '3.0.0'208209[dependencies.sp-block-builder]47pallet-transaction-payment = { default-features = false, version = '3.0.0' }210default-features = false211git = 'https://github.com/paritytech/substrate.git'212branch = 'rococo-v1'213version = '3.0.0'214215[dependencies.sp-core]48pallet-transaction-payment-rpc-runtime-api = { default-features = false, version = '3.0.0' }216default-features = false217git = 'https://github.com/paritytech/substrate.git'218branch = 'rococo-v1'219version = '3.0.0'220221[dependencies.sp-inherents]49pallet-treasury = { default-features = false, version = "3.0.0" }222default-features = false223git = 'https://github.com/paritytech/substrate.git'224branch = 'rococo-v1'225version = '3.0.0'226227[dependencies.sp-io]50pallet-vesting = { default-features = false, version = "3.0.0" }228default-features = false229git = 'https://github.com/paritytech/substrate.git'230branch = 'rococo-v1'231version = '3.0.0'232233[dependencies.sp-offchain]51sp-arithmetic = { default-features = false, version = '3.0.0' }234default-features = false235git = 'https://github.com/paritytech/substrate.git'236branch = 'rococo-v1'237version = '3.0.0'238239[dependencies.sp-runtime]52sp-api = { default-features = false, version = '3.0.0' }240default-features = false241git = 'https://github.com/paritytech/substrate.git'242branch = 'rococo-v1'243version = '3.0.0'244245[dependencies.sp-session]53sp-block-builder = { default-features = false, version = '3.0.0' }246default-features = false247git = 'https://github.com/paritytech/substrate.git'248branch = 'rococo-v1'249version = '3.0.0'250251[dependencies.sp-std]54sp-consensus-aura = { default-features = false, version = '0.9.0' }252default-features = false253git = 'https://github.com/paritytech/substrate.git'254branch = 'rococo-v1'255version = '3.0.0'256257[dependencies.sp-transaction-pool]55sp-core = { default-features = false, version = '3.0.0' }258default-features = false259git = 'https://github.com/paritytech/substrate.git'260branch = 'rococo-v1'261version = '3.0.0'262263[dependencies.sp-version]56sp-inherents = { default-features = false, version = '3.0.0' }264default-features = false265git = 'https://github.com/paritytech/substrate.git'266branch = 'rococo-v1'267version = '3.0.0'268269[dependencies.smallvec]57sp-offchain = { default-features = false, version = '3.0.0' }270version = '1.4.1'271272################################################################################273# Cumulus dependencies274275[dependencies.parachain-info]276default-features = false277git = 'https://github.com/paritytech/cumulus.git'278branch = 'rococo-v1'279version = '0.1.0'280281[dependencies.cumulus-pallet-parachain-system]58sp-runtime = { default-features = false, version = '3.0.0' }282git = 'https://github.com/paritytech/cumulus.git'283branch = 'rococo-v1'284default-features = false285286[dependencies.cumulus-primitives-core]287git = 'https://github.com/paritytech/cumulus.git'59sp-session = { default-features = false, version = '3.0.0' }288branch = 'rococo-v1'289default-features = false290291[dependencies.cumulus-pallet-xcm]292git = 'https://github.com/paritytech/cumulus.git'293branch = 'rococo-v1'294default-features = false295296[dependencies.cumulus-pallet-xcmp-queue]297git = 'https://github.com/paritytech/cumulus.git'60sp-std = { default-features = false, version = '3.0.0' }298branch = 'rococo-v1'299default-features = false300301[dependencies.cumulus-primitives-utility]302git = 'https://github.com/paritytech/cumulus.git'303branch = 'rococo-v1'61sp-transaction-pool = { default-features = false, version = '3.0.0' }304default-features = false305306################################################################################307# Polkadot dependencies308309[dependencies.polkadot-parachain]310git = 'https://github.com/paritytech/polkadot'311branch = 'rococo-v1'312default-features = false313314[dependencies.xcm]315git = 'https://github.com/paritytech/polkadot'316branch = 'rococo-v1'62sp-version = { default-features = false, version = '3.0.0' }317default-features = false318319[dependencies.xcm-builder]320git = 'https://github.com/paritytech/polkadot'321branch = 'rococo-v1'322default-features = false323324[dependencies.xcm-executor]325git = 'https://github.com/paritytech/polkadot'326branch = 'rococo-v1'327default-features = false328329[dependencies.pallet-xcm]330git = 'https://github.com/paritytech/polkadot'63smallvec = "1.4.1"331branch = 'rococo-v1'332default-features = false333334335################################################################################336# Build Dependencies6433765[features]338[build-dependencies]66default = ['std']339substrate-wasm-builder = '4.0.0'340341342################################################################################343# local dependencies34467runtime-benchmarks = [345pallet-nft = { path = '../pallets/nft', default-features = false, version = '3.0.0' }68 'hex-literal',69 'frame-benchmarking',70 'frame-support/runtime-benchmarks',71 'frame-system-benchmarking',72 'frame-system/runtime-benchmarks',73 'pallet-balances/runtime-benchmarks',74 'pallet-timestamp/runtime-benchmarks',75 'pallet-nft/runtime-benchmarks',76 'pallet-inflation/runtime-benchmarks',77 'sp-runtime/runtime-benchmarks',78]79std = [346pallet-inflation = { path = '../pallets/inflation', default-features = false, version = '3.0.0' }80 'codec/std',81 'serde',82 'frame-executive/std',83 'frame-support/std',84 'frame-system/std',85 'frame-system-rpc-runtime-api/std',86 'pallet-aura/std',87 'pallet-balances/std',88 'pallet-contracts/std',89 'pallet-contracts-primitives/std',90 'pallet-contracts-rpc-runtime-api/std',91 'pallet-grandpa/std',92 'pallet-randomness-collective-flip/std',93 'pallet-sudo/std',94 'pallet-timestamp/std',95 'pallet-transaction-payment/std',96 'pallet-transaction-payment-rpc-runtime-api/std',97 'pallet-treasury/std',98 'pallet-vesting/std',99100 'pallet-inflation/std',101 'pallet-nft/std',102 'sp-api/std',103 'sp-block-builder/std',104 'sp-consensus-aura/std',105 'sp-core/std',106 'sp-inherents/std',107 'sp-offchain/std',108 'sp-runtime/std',109 'sp-session/std',110 'sp-std/std',111 'sp-transaction-pool/std',112 'sp-version/std',113114]115347348runtime/src/lib.rsdiffbeforeafterboth--- a/runtime/src/lib.rs
+++ b/runtime/src/lib.rs
@@ -13,22 +13,23 @@
#[cfg(feature = "std")]
include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs"));
-use pallet_grandpa::fg_primitives;
-use pallet_grandpa::{AuthorityId as GrandpaId, AuthorityList as GrandpaAuthorityList};
use sp_api::impl_runtime_apis;
-use sp_consensus_aura::sr25519::AuthorityId as AuraId;
use sp_core::{ crypto::KeyTypeId, crypto::Public, OpaqueMetadata };
use sp_runtime::{
+ BuildStorage,
Permill, Perbill, Percent,
ModuleId,
create_runtime_str, generic, impl_opaque_keys,
traits::{
- Convert, ConvertInto, BlakeTwo256, Block as BlockT, IdentifyAccount,
+ AccountIdLookup, BlakeTwo256, Block as BlockT, Convert, ConvertInto, IdentifyAccount,
IdentityLookup, NumberFor, Verify, AccountIdConversion,
},
transaction_validity::{TransactionSource, TransactionValidity},
ApplyExtrinsicResult, MultiSignature,
};
+
+use sp_std::prelude::*;
+
#[cfg(feature = "std")]
use sp_version::NativeVersion;
use sp_version::RuntimeVersion;
@@ -42,12 +43,11 @@
parameter_types,
StorageValue,
traits::{
- Currency, ExistenceRequirement, Get, KeyOwnerProofSystem, OnUnbalanced, Randomness,
- LockIdentifier,
+ All, Currency, ExistenceRequirement, Get, IsInVec, KeyOwnerProofSystem, LockIdentifier, OnUnbalanced, Randomness
},
weights::{
constants::{BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight, WEIGHT_PER_SECOND},
- DispatchClass, DispatchInfo, GetDispatchInfo, Pays, PostDispatchInfo, Weight,
+ DispatchClass, DispatchInfo, GetDispatchInfo, IdentityFee, Pays, PostDispatchInfo, Weight,
WeightToFeePolynomial, WeightToFeeCoefficient, WeightToFeeCoefficients
},
};
@@ -64,6 +64,19 @@
pub use pallet_timestamp::Call as TimestampCall;
+// Polkadot imports
+use polkadot_parachain::primitives::Sibling;
+use xcm::v0::{Junction, MultiLocation, NetworkId};
+use xcm_builder::{
+ AccountId32Aliases, CurrencyAdapter, LocationInverter, ParentIsDefault, RelayChainAsNative,
+ SiblingParachainAsNative, SiblingParachainConvertsVia, SignedAccountId32AsNative,
+ SovereignSignedViaLocation, FixedRateOfConcreteFungible, EnsureXcmOrigin,
+ AllowTopLevelPaidExecutionFrom, TakeWeightCredit, FixedWeightBounds, IsConcrete, NativeAsset,
+ AllowUnpaidExecutionFrom, ParentAsSuperuser,
+};
+use xcm_executor::{Config, XcmExecutor};
+
+
mod chain_extension;
use crate::chain_extension::{ NFTExtension, Imbalance };
@@ -139,10 +152,7 @@
pub type BlockId = generic::BlockId<Block>;
impl_opaque_keys! {
- pub struct SessionKeys {
- pub aura: Aura,
- pub grandpa: Grandpa,
- }
+ pub struct SessionKeys {}
}
}
@@ -166,6 +176,12 @@
pub const HOURS: BlockNumber = MINUTES * 60;
pub const DAYS: BlockNumber = HOURS * 24;
+#[derive(codec::Encode, codec::Decode)]
+pub enum XCMPMessage<XAccountId, XBalance> {
+ /// Transfer tokens to the given account from the Parachain account.
+ TransferToken(XAccountId, XBalance),
+}
+
/// The version information used to identify this runtime when compiled natively.
#[cfg(feature = "std")]
pub fn native_version() -> NativeVersion {
@@ -173,45 +189,8 @@
runtime_version: VERSION,
can_author_with: Default::default(),
}
-}
-
-/// Provides a membership set with only the configured aura users
-pub struct ValiudatorsOnly<Runtime: pallet_aura::Config>(PhantomData<Runtime>);
-impl frame_support::traits::Contains<AccountId> for ValiudatorsOnly<Runtime> {
- fn contains(t: &AccountId) -> bool {
- let arr: [u8; 32] = *t.as_ref();
- let raw_key: Vec<u8> = Vec::from(arr);
-
- match pallet_aura::Module::<Runtime>::authorities().iter().find(|auth| auth.to_raw_vec() == raw_key) {
- Some(_) => true,
- None => false,
- }
- }
- fn sorted_members() -> Vec<AccountId> {
- let mut members: Vec<AccountId> = Vec::new();
- for auth in pallet_aura::Module::<Runtime>::authorities() {
- let mut arr: [u8; 32] = Default::default();
- let bor_arr = auth.clone().to_raw_vec();
- let slice = bor_arr.as_slice();
- arr.copy_from_slice(slice);
- members.push(AccountId::from(arr));
- }
- members
- }
- fn count() -> usize {
- pallet_aura::Module::<Runtime>::authorities().len()
- }
}
-impl frame_support::traits::ContainsLengthBound for ValiudatorsOnly<Runtime> {
- fn min_len() -> usize {
- 1
- }
- fn max_len() -> usize {
- 100
- }
-}
-
type NegativeImbalance = <Balances as Currency<AccountId>>::NegativeImbalance;
pub struct DealWithFees;
@@ -283,73 +262,52 @@
}
impl system::Config for Runtime {
+ /// The data to be stored in an account.
+ type AccountData = pallet_balances::AccountData<Balance>;
+ /// The identifier used to distinguish between accounts.
+ type AccountId = AccountId;
/// The basic call filter to use in dispatchable.
type BaseCallFilter = ();
- /// The identifier used to distinguish between accounts.
- type AccountId = AccountId;
+ /// Maximum number of block number to block hash mappings to keep (oldest pruned first).
+ type BlockHashCount = BlockHashCount;
+ /// The maximum length of a block (in bytes).
+ type BlockLength = RuntimeBlockLength;
+ /// The index type for blocks.
+ type BlockNumber = BlockNumber;
+ /// The weight of the overhead invoked on the block import process, independent of the
+ /// extrinsics included in that block.
+ type BlockWeights = RuntimeBlockWeights;
/// The aggregated dispatch type that is available for extrinsics.
type Call = Call;
- /// The lookup mechanism to get account ID from whatever is passed in dispatchers.
- type Lookup = IdentityLookup<AccountId>;
- /// The index type for storing how many extrinsics an account has signed.
- type Index = Index;
- /// The index type for blocks.
- type BlockNumber = BlockNumber;
+ /// The weight of database operations that the runtime can invoke.
+ type DbWeight = RocksDbWeight;
+ /// The ubiquitous event type.
+ type Event = Event;
/// The type for hashing blocks and tries.
type Hash = Hash;
- /// The hashing algorithm used.
+ /// The hashing algorithm used.
type Hashing = BlakeTwo256;
/// The header type.
type Header = generic::Header<BlockNumber, BlakeTwo256>;
- /// The ubiquitous event type.
- type Event = Event;
+ /// The index type for storing how many extrinsics an account has signed.
+ type Index = Index;
+ /// The lookup mechanism to get account ID from whatever is passed in dispatchers.
+ type Lookup = IdentityLookup<AccountId>;
+ /// What to do if an account is fully reaped from the system.
+ type OnKilledAccount = ();
+ /// What to do if a new account is created.
+ type OnNewAccount = ();
+ type OnSetCode = cumulus_pallet_parachain_system::ParachainSetCode<Self>;
/// The ubiquitous origin type.
type Origin = Origin;
- /// Maximum number of block number to block hash mappings to keep (oldest pruned first).
- type BlockHashCount = BlockHashCount;
- /// The weight of database operations that the runtime can invoke.
- type DbWeight = RocksDbWeight;
- /// The weight of the overhead invoked on the block import process, independent of the
- /// extrinsics included in that block.
- type BlockWeights = RuntimeBlockWeights;
- /// Version of the runtime.
- type Version = Version;
/// This type is being generated by `construct_runtime!`.
type PalletInfo = PalletInfo;
- /// What to do if a new account is created.
- type OnNewAccount = ();
- /// What to do if an account is fully reaped from the system.
- type OnKilledAccount = ();
- /// The data to be stored in an account.
- type AccountData = pallet_balances::AccountData<Balance>;
+ /// This is used as an identifier of the chain. 42 is the generic substrate prefix.
+ type SS58Prefix = SS58Prefix;
/// Weight information for the extrinsics of this pallet.
type SystemWeightInfo = system::weights::SubstrateWeight<Runtime>;
-
- type BlockLength = RuntimeBlockLength;
- type SS58Prefix = SS58Prefix;
-}
-
-impl pallet_aura::Config for Runtime {
- type AuthorityId = AuraId;
-}
-
-impl pallet_grandpa::Config for Runtime {
- type Event = Event;
- type Call = Call;
-
- type KeyOwnerProofSystem = ();
-
- type KeyOwnerProof =
- <Self::KeyOwnerProofSystem as KeyOwnerProofSystem<(KeyTypeId, GrandpaId)>>::Proof;
-
- type KeyOwnerIdentification = <Self::KeyOwnerProofSystem as KeyOwnerProofSystem<(
- KeyTypeId,
- GrandpaId,
- )>>::IdentificationTuple;
-
- type HandleEquivocation = ();
-
- type WeightInfo = ();
+ /// Version of the runtime.
+ type Version = Version;
}
parameter_types! {
@@ -379,7 +337,7 @@
type DustRemoval = Treasury;
type ExistentialDeposit = ExistentialDeposit;
type AccountStore = System;
- type WeightInfo = ();
+ type WeightInfo = pallet_balances::weights::SubstrateWeight<Runtime>;
}
pub const MICROUNIQUE: Balance = 1_000_000_000;
@@ -440,7 +398,7 @@
type MaxCodeSize = MaxCodeSize;
}
-parameter_types! {
+parame ter_types! {
pub const TransactionByteFee: Balance = 501 * MICROUNIQUE; // Targeting 0.1 Unique per NFT transfer
}
@@ -521,6 +479,147 @@
}
parameter_types! {
+ pub const ReservedXcmpWeight: Weight = MAXIMUM_BLOCK_WEIGHT / 4;
+}
+
+impl cumulus_pallet_parachain_system::Config for Runtime {
+ type Event = Event;
+ type OnValidationData = ();
+ type SelfParaId = parachain_info::Module<Runtime>;
+ type DownwardMessageHandlers = cumulus_primitives_utility::UnqueuedDmpAsParent<
+ MaxDownwardMessageWeight,
+ XcmExecutor<XcmConfig>,
+ Call,
+ >;
+ type OutboundXcmpMessageSource = XcmpQueue;
+ type XcmpMessageHandler = XcmpQueue;
+ type ReservedXcmpWeight = ReservedXcmpWeight;
+}
+
+impl parachain_info::Config for Runtime {}
+
+parameter_types! {
+ pub const RococoLocation: MultiLocation = MultiLocation::X1(Junction::Parent);
+ pub const RococoNetwork: NetworkId = NetworkId::Polkadot;
+ pub RelayChainOrigin: Origin = cumulus_pallet_xcm::Origin::Relay.into();
+ pub Ancestry: MultiLocation = Junction::Parachain {
+ id: ParachainInfo::parachain_id().into()
+ }.into();
+}
+
+/// Type for specifying how a `MultiLocation` can be converted into an `AccountId`. This is used
+/// when determining ownership of accounts for asset transacting and when attempting to use XCM
+/// `Transact` in order to determine the dispatch Origin.
+pub type LocationToAccountId = (
+ // The parent (Relay-chain) origin converts to the default `AccountId`.
+ ParentIsDefault<AccountId>,
+ // Sibling parachain origins convert to AccountId via the `ParaId::into`.
+ SiblingParachainConvertsVia<Sibling, AccountId>,
+ // Straight up local `AccountId32` origins just alias directly to `AccountId`.
+ AccountId32Aliases<RococoNetwork, AccountId>,
+);
+
+/// Means for transacting assets on this chain.
+pub type LocalAssetTransactor = CurrencyAdapter<
+ // Use this currency:
+ Balances,
+ // Use this currency when it is a fungible asset matching the given location or name:
+ IsConcrete<RococoLocation>,
+ // Do a simple punn to convert an AccountId32 MultiLocation into a native chain account ID:
+ LocationToAccountId,
+ // Our chain's account ID type (we can't get away without mentioning it explicitly):
+ AccountId,
+>;
+
+/// This is the type we use to convert an (incoming) XCM origin into a local `Origin` instance,
+/// ready for dispatching a transaction with Xcm's `Transact`. There is an `OriginKind` which can
+/// biases the kind of local `Origin` it will become.
+pub type XcmOriginToTransactDispatchOrigin = (
+ // Sovereign account converter; this attempts to derive an `AccountId` from the origin location
+ // using `LocationToAccountId` and then turn that into the usual `Signed` origin. Useful for
+ // foreign chains who want to have a local sovereign account on this chain which they control.
+ SovereignSignedViaLocation<LocationToAccountId, Origin>,
+ // Native converter for Relay-chain (Parent) location; will converts to a `Relay` origin when
+ // recognised.
+ RelayChainAsNative<RelayChainOrigin, Origin>,
+ // Native converter for sibling Parachains; will convert to a `SiblingPara` origin when
+ // recognised.
+ SiblingParachainAsNative<cumulus_pallet_xcm::Origin, Origin>,
+ // Superuser converter for the Relay-chain (Parent) location. This will allow it to issue a
+ // transaction from the Root origin.
+ ParentAsSuperuser<Origin>,
+ // Native signed account converter; this just converts an `AccountId32` origin into a normal
+ // `Origin::Signed` origin of the same 32-byte value.
+ SignedAccountId32AsNative<RococoNetwork, Origin>,
+);
+
+parameter_types! {
+ pub UnitWeightCost: Weight = 1_000;
+}
+
+parameter_types! {
+ // 1_000_000_000_000 => 1 unit of asset for 1 unit of Weight.
+ // TODO: Should take the actual weight price. This is just 1_000 ROC per second of weight.
+ pub const WeightPrice: (MultiLocation, u128) = (MultiLocation::X1(Junction::Parent), 1_000);
+ pub AllowUnpaidFrom: Vec<MultiLocation> = vec![ MultiLocation::X1(Junction::Parent) ];
+}
+
+pub type Barrier = (
+ TakeWeightCredit,
+ AllowTopLevelPaidExecutionFrom<All<MultiLocation>>,
+ AllowUnpaidExecutionFrom<IsInVec<AllowUnpaidFrom>>, // <- Parent gets free execution
+);
+
+
+pub struct XcmConfig;
+impl Config for XcmConfig {
+ type Call = Call;
+ type XcmSender = XcmRouter;
+ // How to withdraw and deposit an asset.
+ type AssetTransactor = LocalAssetTransactor;
+ type OriginConverter = XcmOriginToTransactDispatchOrigin;
+ type IsReserve = NativeAsset;
+ type IsTeleporter = NativeAsset; // <- should be enough to allow teleportation of ROC
+ type LocationInverter = LocationInverter<Ancestry>;
+ type Barrier = Barrier;
+ type Weigher = FixedWeightBounds<UnitWeightCost, Call>;
+ type Trader = FixedRateOfConcreteFungible<WeightPrice>;
+ type ResponseHandler = (); // Don't handle responses for now.
+}
+
+parameter_types! {
+ pub const MaxDownwardMessageWeight: Weight = MAXIMUM_BLOCK_WEIGHT / 10;
+}
+
+/// No local origins on this chain are allowed to dispatch XCM sends/executions.
+pub type LocalOriginToLocation = ();
+
+/// The means for routing XCM messages which are not for local execution into the right message
+/// queues.
+pub type XcmRouter = (
+ // Two routers - use UMP to communicate with the relay chain:
+ cumulus_primitives_utility::ParentAsUmp<ParachainSystem>,
+ // ..and XCMP to communicate with the sibling chains.
+ XcmpQueue,
+);
+
+impl pallet_xcm::Config for Runtime {
+ type Event = Event;
+ type SendXcmOrigin = EnsureXcmOrigin<Origin, LocalOriginToLocation>;
+ type XcmRouter = XcmRouter;
+ type ExecuteXcmOrigin = EnsureXcmOrigin<Origin, LocalOriginToLocation>;
+ type XcmExecutor = XcmExecutor<XcmConfig>;
+}
+
+impl cumulus_pallet_xcm::Config for Runtime {}
+
+impl cumulus_pallet_xcmp_queue::Config for Runtime {
+ type Event = Event;
+ type XcmExecutor = XcmExecutor<XcmConfig>;
+ type ChannelInfo = ParachainSystem;
+}
+
+parameter_types! {
pub TreasuryAccountId: AccountId = TreasuryModuleId::get().into_account();
pub const CollectionCreationPrice: Balance = 100 * UNIQUE;
}
@@ -555,19 +654,23 @@
NodeBlock = opaque::Block,
UncheckedExtrinsic = UncheckedExtrinsic
{
- System: system::{Module, Call, Config, Storage, Event<T>},
- RandomnessCollectiveFlip: pallet_randomness_collective_flip::{Module, Call, Storage},
+ Balances: pallet_balances::{Module, Call, Storage, Config<T>, Event<T>},
Contracts: pallet_contracts::{Module, Call, Config<T>, Storage, Event<T>},
+ CumulusXcm: cumulus_pallet_xcm::{Pallet, Origin},
+ ParachainInfo: parachain_info::{Pallet, Storage, Config},
+ ParachainSystem: cumulus_pallet_parachain_system::{Pallet, Call, Storage, Inherent, Event<T>},
+ PolkadotXcm: pallet_xcm::{Pallet, Call, Event<T>, Origin},
+ RandomnessCollectiveFlip: pallet_randomness_collective_flip::{Module, Call, Storage},
+ Sudo: pallet_sudo::{Module, Call, Config<T>, Storage, Event<T>},
+ System: system::{Module, Call, Config, Storage, Event<T>},
Timestamp: pallet_timestamp::{Module, Call, Storage, Inherent},
- Aura: pallet_aura::{Module, Config<T> },
- Grandpa: pallet_grandpa::{Module, Call, Storage, Config, Event},
- Balances: pallet_balances::{Module, Call, Storage, Config<T>, Event<T>},
TransactionPayment: pallet_transaction_payment::{Module, Storage},
- Sudo: pallet_sudo::{Module, Call, Config<T>, Storage, Event<T>},
- Inflation: pallet_inflation::{Module, Call, Storage},
- Nft: pallet_nft::{Module, Call, Config<T>, Storage, Event<T>},
Treasury: pallet_treasury::{Module, Call, Storage, Config, Event<T>},
Vesting: pallet_vesting::{Module, Call, Config<T>, Storage, Event<T>},
+ XcmpQueue: cumulus_pallet_xcmp_queue::{Pallet, Call, Storage, Event<T>},
+
+ Inflation: pallet_inflation::{Module, Call, Storage},
+ Nft: pallet_nft::{Module, Call, Config<T>, Storage, Event<T>},
}
);
@@ -600,34 +703,6 @@
frame_executive::Executive<Runtime, Block, system::ChainContext<Runtime>, Runtime, AllModules>;
impl_runtime_apis! {
-
- impl pallet_contracts_rpc_runtime_api::ContractsApi<Block, AccountId, Balance, BlockNumber>
- for Runtime
- {
- fn call(
- origin: AccountId,
- dest: AccountId,
- value: Balance,
- gas_limit: u64,
- input_data: Vec<u8>,
- ) -> pallet_contracts_primitives::ContractExecResult {
- Contracts::bare_call(origin, dest, value, gas_limit, input_data)
- }
-
- fn get_storage(
- address: AccountId,
- key: [u8; 32],
- ) -> pallet_contracts_primitives::GetStorageResult {
- Contracts::get_storage(address, key)
- }
-
- fn rent_projection(
- address: AccountId,
- ) -> pallet_contracts_primitives::RentProjectionResult<BlockNumber> {
- Contracts::rent_projection(address)
- }
- }
-
impl sp_api::Core<Block> for Runtime {
fn version() -> RuntimeVersion {
VERSION
@@ -688,16 +763,6 @@
}
}
- impl sp_consensus_aura::AuraApi<Block, AuraId> for Runtime {
- fn slot_duration() -> u64 {
- Aura::slot_duration()
- }
-
- fn authorities() -> Vec<AuraId> {
- Aura::authorities()
- }
- }
-
impl sp_session::SessionKeys<Block> for Runtime {
fn generate_session_keys(seed: Option<Vec<u8>>) -> Vec<u8> {
opaque::SessionKeys::generate(seed)
@@ -710,32 +775,6 @@
}
}
- impl fg_primitives::GrandpaApi<Block> for Runtime {
- fn grandpa_authorities() -> GrandpaAuthorityList {
- Grandpa::grandpa_authorities()
- }
-
- fn submit_report_equivocation_unsigned_extrinsic(
- _equivocation_proof: fg_primitives::EquivocationProof<
- <Block as BlockT>::Hash,
- NumberFor<Block>,
- >,
- _key_owner_proof: fg_primitives::OpaqueKeyOwnershipProof,
- ) -> Option<()> {
- None
- }
-
- fn generate_key_ownership_proof(
- _set_id: fg_primitives::SetId,
- _authority_id: GrandpaId,
- ) -> Option<fg_primitives::OpaqueKeyOwnershipProof> {
- // NOTE: this is the only implementation possible since we've
- // defined our key owner proof type as a bottom type (i.e. a type
- // with no values).
- None
- }
- }
-
impl frame_system_rpc_runtime_api::AccountNonceApi<Block, AccountId, Index> for Runtime {
fn account_nonce(account: AccountId) -> Index {
System::account_nonce(account)
@@ -751,6 +790,33 @@
}
}
+ impl pallet_contracts_rpc_runtime_api::ContractsApi<Block, AccountId, Balance, BlockNumber>
+ for Runtime
+ {
+ fn call(
+ origin: AccountId,
+ dest: AccountId,
+ value: Balance,
+ gas_limit: u64,
+ input_data: Vec<u8>,
+ ) -> pallet_contracts_primitives::ContractExecResult {
+ Contracts::bare_call(origin, dest, value, gas_limit, input_data)
+ }
+
+ fn get_storage(
+ address: AccountId,
+ key: [u8; 32],
+ ) -> pallet_contracts_primitives::GetStorageResult {
+ Contracts::get_storage(address, key)
+ }
+
+ fn rent_projection(
+ address: AccountId,
+ ) -> pallet_contracts_primitives::RentProjectionResult<BlockNumber> {
+ Contracts::rent_projection(address)
+ }
+ }
+
#[cfg(feature = "runtime-benchmarks")]
impl frame_benchmarking::Benchmark<Block> for Runtime {
fn dispatch_benchmark(