git.delta.rocks / unique-network / refs/commits / 157619d37683

difftreelog

wip parachains

Greg Zaitsev2021-06-03parent: #c803bd5.patch.diff
in: master

2 files changed

modifiedruntime/Cargo.tomldiffbeforeafterboth
1################################################################################
2# Package
3
1[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'
914
10[package.metadata.docs.rs]15[package.metadata.docs.rs]
11targets = ['x86_64-unknown-linux-gnu']16targets = ['x86_64-unknown-linux-gnu']
1217
13[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',
69
70 'pallet-inflation/std',
71 'pallet-nft/std',
72]
73
74################################################################################
75# Substrate Dependencies
76
17[dependencies.codec]77[dependencies.codec]
18default-features = false78default-features = false
19features = ['derive']79features = ['derive']
20package = 'parity-scale-codec'80package = 'parity-scale-codec'
21version = '2.0.0'81version = '2.0.0'
2282
23[dependencies]83[dependencies.frame-benchmarking]
24hex-literal = { optional = true, version = '0.3.1' }84default-features = false
85git = 'https://github.com/paritytech/substrate.git'
86optional = true
87branch = 'rococo-v1'
88version = '3.0.0'
89
90[dependencies.frame-executive]
25serde = { features = ['derive'], optional = true, version = '1.0.119' }91default-features = false
2692git = 'https://github.com/paritytech/substrate.git'
27# local dependencies93branch = 'rococo-v1'
94version = '3.0.0'
95
96[dependencies.frame-support]
28pallet-nft = { path = '../pallets/nft', default-features = false, version = '3.0.0' }97default-features = false
98git = 'https://github.com/paritytech/substrate.git'
99branch = 'rococo-v1'
100version = '3.0.0'
101
102[dependencies.frame-system]
29pallet-inflation = { path = '../pallets/inflation', default-features = false, version = '3.0.0' }103default-features = false
30104git = 'https://github.com/paritytech/substrate.git'
31# Substrate dependencies105branch = 'rococo-v1'
106version = '3.0.0'
107
108[dependencies.frame-system-benchmarking]
32frame-benchmarking = { default-features = false, optional = true, version = '3.0.0' }109default-features = false
110git = 'https://github.com/paritytech/substrate.git'
111optional = true
112branch = 'rococo-v1'
113version = '3.0.0'
114
115[dependencies.frame-system-rpc-runtime-api]
33frame-executive = { default-features = false, version = '3.0.0' }116default-features = false
117git = 'https://github.com/paritytech/substrate.git'
118branch = 'rococo-v1'
119version = '3.0.0'
120
121[dependencies.hex-literal]
122optional = true
123version = '0.3.1'
124
125[dependencies.serde]
126features = ['derive']
34frame-support = { default-features = false, version = '3.0.0' }127optional = true
128version = '1.0.119'
129
130[dependencies.pallet-balances]
131default-features = false
132git = 'https://github.com/paritytech/substrate.git'
133branch = 'rococo-v1'
134version = '3.0.0'
135
136# Contracts specific packages
137[dependencies.pallet-contracts]
35frame-system = { default-features = false, version = '3.0.0' }138git = 'https://github.com/paritytech/substrate.git'
139default-features = false
140branch = 'rococo-v1'
141version = '3.0.0'
142
143[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 = false
146branch = 'rococo-v1'
147version = '3.0.0'
148
149[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 = false
152branch = 'rococo-v1'
153version = '3.0.0'
154
155[dependencies.pallet-randomness-collective-flip]
38pallet-aura = { default-features = false, version = '3.0.0' }156default-features = false
157git = 'https://github.com/paritytech/substrate.git'
158branch = 'rococo-v1'
159version = '3.0.0'
160
161[dependencies.pallet-sudo]
39pallet-balances = { default-features = false, version = '3.0.0' }162default-features = false
163git = 'https://github.com/paritytech/substrate.git'
164branch = 'rococo-v1'
165version = '3.0.0'
166
167[dependencies.pallet-timestamp]
40pallet-contracts = { default-features = false, version = '3.0.0' }168default-features = false
169git = 'https://github.com/paritytech/substrate.git'
170branch = 'rococo-v1'
171version = '3.0.0'
172
173[dependencies.pallet-transaction-payment]
41pallet-contracts-primitives = { default-features = false, version = '3.0.0' }174default-features = false
175git = 'https://github.com/paritytech/substrate.git'
176branch = 'rococo-v1'
177version = '3.0.0'
178
179[dependencies.pallet-transaction-payment-rpc-runtime-api]
42pallet-contracts-rpc-runtime-api = { default-features = false, version = '3.0.0' }180default-features = false
181git = 'https://github.com/paritytech/substrate.git'
182branch = 'rococo-v1'
183version = '3.0.0'
184
185[dependencies.pallet-treasury]
43pallet-grandpa = { default-features = false, version = '3.0.0' }186default-features = false
187git = 'https://github.com/paritytech/substrate.git'
188branch = 'rococo-v1'
189version = '3.0.0'
190
191[dependencies.pallet-vesting]
44pallet-randomness-collective-flip = { default-features = false, version = '3.0.0' }192default-features = false
193git = 'https://github.com/paritytech/substrate.git'
194branch = 'rococo-v1'
195version = '3.0.0'
196
197[dependencies.sp-arithmetic]
45pallet-sudo = { default-features = false, version = '3.0.0' }198default-features = false
199git = 'https://github.com/paritytech/substrate.git'
200branch = 'rococo-v1'
201version = '3.0.0'
202
203[dependencies.sp-api]
46pallet-timestamp = { default-features = false, version = '3.0.0' }204default-features = false
205git = 'https://github.com/paritytech/substrate.git'
206branch = 'rococo-v1'
207version = '3.0.0'
208
209[dependencies.sp-block-builder]
47pallet-transaction-payment = { default-features = false, version = '3.0.0' }210default-features = false
211git = 'https://github.com/paritytech/substrate.git'
212branch = 'rococo-v1'
213version = '3.0.0'
214
215[dependencies.sp-core]
48pallet-transaction-payment-rpc-runtime-api = { default-features = false, version = '3.0.0' }216default-features = false
217git = 'https://github.com/paritytech/substrate.git'
218branch = 'rococo-v1'
219version = '3.0.0'
220
221[dependencies.sp-inherents]
49pallet-treasury = { default-features = false, version = "3.0.0" }222default-features = false
223git = 'https://github.com/paritytech/substrate.git'
224branch = 'rococo-v1'
225version = '3.0.0'
226
227[dependencies.sp-io]
50pallet-vesting = { default-features = false, version = "3.0.0" }228default-features = false
229git = 'https://github.com/paritytech/substrate.git'
230branch = 'rococo-v1'
231version = '3.0.0'
232
233[dependencies.sp-offchain]
51sp-arithmetic = { default-features = false, version = '3.0.0' }234default-features = false
235git = 'https://github.com/paritytech/substrate.git'
236branch = 'rococo-v1'
237version = '3.0.0'
238
239[dependencies.sp-runtime]
52sp-api = { default-features = false, version = '3.0.0' }240default-features = false
241git = 'https://github.com/paritytech/substrate.git'
242branch = 'rococo-v1'
243version = '3.0.0'
244
245[dependencies.sp-session]
53sp-block-builder = { default-features = false, version = '3.0.0' }246default-features = false
247git = 'https://github.com/paritytech/substrate.git'
248branch = 'rococo-v1'
249version = '3.0.0'
250
251[dependencies.sp-std]
54sp-consensus-aura = { default-features = false, version = '0.9.0' }252default-features = false
253git = 'https://github.com/paritytech/substrate.git'
254branch = 'rococo-v1'
255version = '3.0.0'
256
257[dependencies.sp-transaction-pool]
55sp-core = { default-features = false, version = '3.0.0' }258default-features = false
259git = 'https://github.com/paritytech/substrate.git'
260branch = 'rococo-v1'
261version = '3.0.0'
262
263[dependencies.sp-version]
56sp-inherents = { default-features = false, version = '3.0.0' }264default-features = false
265git = 'https://github.com/paritytech/substrate.git'
266branch = 'rococo-v1'
267version = '3.0.0'
268
269[dependencies.smallvec]
57sp-offchain = { default-features = false, version = '3.0.0' }270version = '1.4.1'
271
272################################################################################
273# Cumulus dependencies
274
275[dependencies.parachain-info]
276default-features = false
277git = 'https://github.com/paritytech/cumulus.git'
278branch = 'rococo-v1'
279version = '0.1.0'
280
281[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 = false
285
286[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 = false
290
291[dependencies.cumulus-pallet-xcm]
292git = 'https://github.com/paritytech/cumulus.git'
293branch = 'rococo-v1'
294default-features = false
295
296[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 = false
300
301[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 = false
305
306################################################################################
307# Polkadot dependencies
308
309[dependencies.polkadot-parachain]
310git = 'https://github.com/paritytech/polkadot'
311branch = 'rococo-v1'
312default-features = false
313
314[dependencies.xcm]
315git = 'https://github.com/paritytech/polkadot'
316branch = 'rococo-v1'
62sp-version = { default-features = false, version = '3.0.0' }317default-features = false
318
319[dependencies.xcm-builder]
320git = 'https://github.com/paritytech/polkadot'
321branch = 'rococo-v1'
322default-features = false
323
324[dependencies.xcm-executor]
325git = 'https://github.com/paritytech/polkadot'
326branch = 'rococo-v1'
327default-features = false
328
329[dependencies.pallet-xcm]
330git = 'https://github.com/paritytech/polkadot'
63smallvec = "1.4.1"331branch = 'rococo-v1'
332default-features = false
333
334
335################################################################################
336# Build Dependencies
64337
65[features]338[build-dependencies]
66default = ['std']339substrate-wasm-builder = '4.0.0'
340
341
342################################################################################
343# local dependencies
344
67runtime-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',
99
100 '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',
113
114]
115347
348
modifiedruntime/src/lib.rsdiffbeforeafterboth
13#[cfg(feature = "std")]13#[cfg(feature = "std")]
14include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs"));14include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs"));
1515
16use pallet_grandpa::fg_primitives;
17use pallet_grandpa::{AuthorityId as GrandpaId, AuthorityList as GrandpaAuthorityList};
18use sp_api::impl_runtime_apis;16use sp_api::impl_runtime_apis;
19use sp_consensus_aura::sr25519::AuthorityId as AuraId;
20use sp_core::{ crypto::KeyTypeId, crypto::Public, OpaqueMetadata };17use sp_core::{ crypto::KeyTypeId, crypto::Public, OpaqueMetadata };
21use sp_runtime::{18use sp_runtime::{
19 BuildStorage,
22 Permill, Perbill, Percent,20 Permill, Perbill, Percent,
23 ModuleId,21 ModuleId,
24 create_runtime_str, generic, impl_opaque_keys,22 create_runtime_str, generic, impl_opaque_keys,
25 traits::{23 traits::{
26 Convert, ConvertInto, BlakeTwo256, Block as BlockT, IdentifyAccount, 24 AccountIdLookup, BlakeTwo256, Block as BlockT, Convert, ConvertInto, IdentifyAccount,
27 IdentityLookup, NumberFor, Verify, AccountIdConversion,25 IdentityLookup, NumberFor, Verify, AccountIdConversion,
28 },26 },
29 transaction_validity::{TransactionSource, TransactionValidity},27 transaction_validity::{TransactionSource, TransactionValidity},
30 ApplyExtrinsicResult, MultiSignature,28 ApplyExtrinsicResult, MultiSignature,
31};29};
30
31use sp_std::prelude::*;
32
32#[cfg(feature = "std")]33#[cfg(feature = "std")]
33use sp_version::NativeVersion;34use sp_version::NativeVersion;
42 parameter_types,43 parameter_types,
43 StorageValue,44 StorageValue,
44 traits::{45 traits::{
45 Currency, ExistenceRequirement, Get, KeyOwnerProofSystem, OnUnbalanced, Randomness,46 All, Currency, ExistenceRequirement, Get, IsInVec, KeyOwnerProofSystem, LockIdentifier, OnUnbalanced, Randomness
46 LockIdentifier,
47 },47 },
48 weights::{48 weights::{
49 constants::{BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight, WEIGHT_PER_SECOND},49 constants::{BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight, WEIGHT_PER_SECOND},
50 DispatchClass, DispatchInfo, GetDispatchInfo, Pays, PostDispatchInfo, Weight,50 DispatchClass, DispatchInfo, GetDispatchInfo, IdentityFee, Pays, PostDispatchInfo, Weight,
51 WeightToFeePolynomial, WeightToFeeCoefficient, WeightToFeeCoefficients51 WeightToFeePolynomial, WeightToFeeCoefficient, WeightToFeeCoefficients
52 },52 },
53};53};
6464
65pub use pallet_timestamp::Call as TimestampCall;65pub use pallet_timestamp::Call as TimestampCall;
66
67// Polkadot imports
68use polkadot_parachain::primitives::Sibling;
69use xcm::v0::{Junction, MultiLocation, NetworkId};
70use xcm_builder::{
71 AccountId32Aliases, CurrencyAdapter, LocationInverter, ParentIsDefault, RelayChainAsNative,
72 SiblingParachainAsNative, SiblingParachainConvertsVia, SignedAccountId32AsNative,
73 SovereignSignedViaLocation, FixedRateOfConcreteFungible, EnsureXcmOrigin,
74 AllowTopLevelPaidExecutionFrom, TakeWeightCredit, FixedWeightBounds, IsConcrete, NativeAsset,
75 AllowUnpaidExecutionFrom, ParentAsSuperuser,
76};
77use xcm_executor::{Config, XcmExecutor};
78
6679
67mod chain_extension;80mod chain_extension;
140153
141 impl_opaque_keys! {154 impl_opaque_keys! {
142 pub struct SessionKeys {155 pub struct SessionKeys {}
143 pub aura: Aura,
144 pub grandpa: Grandpa,
145 }
146 }156 }
147}157}
166pub const HOURS: BlockNumber = MINUTES * 60;176pub const HOURS: BlockNumber = MINUTES * 60;
167pub const DAYS: BlockNumber = HOURS * 24;177pub const DAYS: BlockNumber = HOURS * 24;
178
179#[derive(codec::Encode, codec::Decode)]
180pub enum XCMPMessage<XAccountId, XBalance> {
181 /// Transfer tokens to the given account from the Parachain account.
182 TransferToken(XAccountId, XBalance),
183}
168184
169/// The version information used to identify this runtime when compiled natively.185/// The version information used to identify this runtime when compiled natively.
170#[cfg(feature = "std")]186#[cfg(feature = "std")]
175 }191 }
176}192}
177
178/// Provides a membership set with only the configured aura users
179pub struct ValiudatorsOnly<Runtime: pallet_aura::Config>(PhantomData<Runtime>);
180impl frame_support::traits::Contains<AccountId> for ValiudatorsOnly<Runtime> {
181 fn contains(t: &AccountId) -> bool {
182 let arr: [u8; 32] = *t.as_ref();
183 let raw_key: Vec<u8> = Vec::from(arr);
184
185 match pallet_aura::Module::<Runtime>::authorities().iter().find(|auth| auth.to_raw_vec() == raw_key) {
186 Some(_) => true,
187 None => false,
188 }
189 }
190 fn sorted_members() -> Vec<AccountId> {
191 let mut members: Vec<AccountId> = Vec::new();
192 for auth in pallet_aura::Module::<Runtime>::authorities() {
193 let mut arr: [u8; 32] = Default::default();
194 let bor_arr = auth.clone().to_raw_vec();
195 let slice = bor_arr.as_slice();
196 arr.copy_from_slice(slice);
197 members.push(AccountId::from(arr));
198 }
199 members
200 }
201 fn count() -> usize {
202 pallet_aura::Module::<Runtime>::authorities().len()
203 }
204}
205
206impl frame_support::traits::ContainsLengthBound for ValiudatorsOnly<Runtime> {
207 fn min_len() -> usize {
208 1
209 }
210 fn max_len() -> usize {
211 100
212 }
213}
214193
215type NegativeImbalance = <Balances as Currency<AccountId>>::NegativeImbalance;194type NegativeImbalance = <Balances as Currency<AccountId>>::NegativeImbalance;
216195
283}262}
284263
285impl system::Config for Runtime {264impl system::Config for Runtime {
286 /// The basic call filter to use in dispatchable.265 /// The data to be stored in an account.
287 type BaseCallFilter = ();266 type AccountData = pallet_balances::AccountData<Balance>;
288 /// The identifier used to distinguish between accounts.267 /// The identifier used to distinguish between accounts.
289 type AccountId = AccountId;268 type AccountId = AccountId;
290 /// The aggregated dispatch type that is available for extrinsics.269 /// The basic call filter to use in dispatchable.
291 type Call = Call;270 type BaseCallFilter = ();
292 /// The lookup mechanism to get account ID from whatever is passed in dispatchers.271 /// Maximum number of block number to block hash mappings to keep (oldest pruned first).
293 type Lookup = IdentityLookup<AccountId>;272 type BlockHashCount = BlockHashCount;
294 /// The index type for storing how many extrinsics an account has signed.273 /// The maximum length of a block (in bytes).
295 type Index = Index;274 type BlockLength = RuntimeBlockLength;
296 /// The index type for blocks.275 /// The index type for blocks.
297 type BlockNumber = BlockNumber;276 type BlockNumber = BlockNumber;
277 /// The weight of the overhead invoked on the block import process, independent of the
278 /// extrinsics included in that block.
279 type BlockWeights = RuntimeBlockWeights;
280 /// The aggregated dispatch type that is available for extrinsics.
281 type Call = Call;
282 /// The weight of database operations that the runtime can invoke.
283 type DbWeight = RocksDbWeight;
284 /// The ubiquitous event type.
285 type Event = Event;
298 /// The type for hashing blocks and tries.286 /// The type for hashing blocks and tries.
299 type Hash = Hash;287 type Hash = Hash;
300 /// The hashing algorithm used.288 /// The hashing algorithm used.
301 type Hashing = BlakeTwo256;289 type Hashing = BlakeTwo256;
302 /// The header type.290 /// The header type.
303 type Header = generic::Header<BlockNumber, BlakeTwo256>;291 type Header = generic::Header<BlockNumber, BlakeTwo256>;
304 /// The ubiquitous event type.292 /// The index type for storing how many extrinsics an account has signed.
305 type Event = Event;293 type Index = Index;
306 /// The ubiquitous origin type.294 /// The lookup mechanism to get account ID from whatever is passed in dispatchers.
307 type Origin = Origin;295 type Lookup = IdentityLookup<AccountId>;
308 /// Maximum number of block number to block hash mappings to keep (oldest pruned first).296 /// What to do if an account is fully reaped from the system.
309 type BlockHashCount = BlockHashCount;297 type OnKilledAccount = ();
310 /// The weight of database operations that the runtime can invoke.298 /// What to do if a new account is created.
311 type DbWeight = RocksDbWeight;299 type OnNewAccount = ();
312 /// The weight of the overhead invoked on the block import process, independent of the
313 /// extrinsics included in that block.
314 type BlockWeights = RuntimeBlockWeights;300 type OnSetCode = cumulus_pallet_parachain_system::ParachainSetCode<Self>;
315 /// Version of the runtime.301 /// The ubiquitous origin type.
316 type Version = Version;302 type Origin = Origin;
317 /// This type is being generated by `construct_runtime!`.303 /// This type is being generated by `construct_runtime!`.
318 type PalletInfo = PalletInfo;304 type PalletInfo = PalletInfo;
319 /// What to do if a new account is created.305 /// This is used as an identifier of the chain. 42 is the generic substrate prefix.
320 type OnNewAccount = ();
321 /// What to do if an account is fully reaped from the system.
322 type OnKilledAccount = ();306 type SS58Prefix = SS58Prefix;
323 /// The data to be stored in an account.
324 type AccountData = pallet_balances::AccountData<Balance>;
325 /// Weight information for the extrinsics of this pallet.307 /// Weight information for the extrinsics of this pallet.
326 type SystemWeightInfo = system::weights::SubstrateWeight<Runtime>;308 type SystemWeightInfo = system::weights::SubstrateWeight<Runtime>;
327 309 /// Version of the runtime.
328 type BlockLength = RuntimeBlockLength;310 type Version = Version;
329 type SS58Prefix = SS58Prefix;
330}311}
331
332impl pallet_aura::Config for Runtime {
333 type AuthorityId = AuraId;
334}
335
336impl pallet_grandpa::Config for Runtime {
337 type Event = Event;
338 type Call = Call;
339
340 type KeyOwnerProofSystem = ();
341
342 type KeyOwnerProof =
343 <Self::KeyOwnerProofSystem as KeyOwnerProofSystem<(KeyTypeId, GrandpaId)>>::Proof;
344
345 type KeyOwnerIdentification = <Self::KeyOwnerProofSystem as KeyOwnerProofSystem<(
346 KeyTypeId,
347 GrandpaId,
348 )>>::IdentificationTuple;
349
350 type HandleEquivocation = ();
351
352 type WeightInfo = ();
353}
354312
355parameter_types! {313parameter_types! {
356 pub const MinimumPeriod: u64 = SLOT_DURATION / 2;314 pub const MinimumPeriod: u64 = SLOT_DURATION / 2;
379 type DustRemoval = Treasury;337 type DustRemoval = Treasury;
380 type ExistentialDeposit = ExistentialDeposit;338 type ExistentialDeposit = ExistentialDeposit;
381 type AccountStore = System;339 type AccountStore = System;
382 type WeightInfo = ();340 type WeightInfo = pallet_balances::weights::SubstrateWeight<Runtime>;
383}341}
384342
385pub const MICROUNIQUE: Balance = 1_000_000_000;343pub const MICROUNIQUE: Balance = 1_000_000_000;
440 type MaxCodeSize = MaxCodeSize;398 type MaxCodeSize = MaxCodeSize;
441}399}
442400
443parameter_types! {401parame ter_types! {
444 pub const TransactionByteFee: Balance = 501 * MICROUNIQUE; // Targeting 0.1 Unique per NFT transfer 402 pub const TransactionByteFee: Balance = 501 * MICROUNIQUE; // Targeting 0.1 Unique per NFT transfer
445}403}
446404
520 type WeightInfo = ();478 type WeightInfo = ();
521}479}
480
481parameter_types! {
482 pub const ReservedXcmpWeight: Weight = MAXIMUM_BLOCK_WEIGHT / 4;
483}
484
485impl cumulus_pallet_parachain_system::Config for Runtime {
486 type Event = Event;
487 type OnValidationData = ();
488 type SelfParaId = parachain_info::Module<Runtime>;
489 type DownwardMessageHandlers = cumulus_primitives_utility::UnqueuedDmpAsParent<
490 MaxDownwardMessageWeight,
491 XcmExecutor<XcmConfig>,
492 Call,
493 >;
494 type OutboundXcmpMessageSource = XcmpQueue;
495 type XcmpMessageHandler = XcmpQueue;
496 type ReservedXcmpWeight = ReservedXcmpWeight;
497}
498
499impl parachain_info::Config for Runtime {}
500
501parameter_types! {
502 pub const RococoLocation: MultiLocation = MultiLocation::X1(Junction::Parent);
503 pub const RococoNetwork: NetworkId = NetworkId::Polkadot;
504 pub RelayChainOrigin: Origin = cumulus_pallet_xcm::Origin::Relay.into();
505 pub Ancestry: MultiLocation = Junction::Parachain {
506 id: ParachainInfo::parachain_id().into()
507 }.into();
508}
509
510/// Type for specifying how a `MultiLocation` can be converted into an `AccountId`. This is used
511/// when determining ownership of accounts for asset transacting and when attempting to use XCM
512/// `Transact` in order to determine the dispatch Origin.
513pub type LocationToAccountId = (
514 // The parent (Relay-chain) origin converts to the default `AccountId`.
515 ParentIsDefault<AccountId>,
516 // Sibling parachain origins convert to AccountId via the `ParaId::into`.
517 SiblingParachainConvertsVia<Sibling, AccountId>,
518 // Straight up local `AccountId32` origins just alias directly to `AccountId`.
519 AccountId32Aliases<RococoNetwork, AccountId>,
520);
521
522/// Means for transacting assets on this chain.
523pub type LocalAssetTransactor = CurrencyAdapter<
524 // Use this currency:
525 Balances,
526 // Use this currency when it is a fungible asset matching the given location or name:
527 IsConcrete<RococoLocation>,
528 // Do a simple punn to convert an AccountId32 MultiLocation into a native chain account ID:
529 LocationToAccountId,
530 // Our chain's account ID type (we can't get away without mentioning it explicitly):
531 AccountId,
532>;
533
534/// This is the type we use to convert an (incoming) XCM origin into a local `Origin` instance,
535/// ready for dispatching a transaction with Xcm's `Transact`. There is an `OriginKind` which can
536/// biases the kind of local `Origin` it will become.
537pub type XcmOriginToTransactDispatchOrigin = (
538 // Sovereign account converter; this attempts to derive an `AccountId` from the origin location
539 // using `LocationToAccountId` and then turn that into the usual `Signed` origin. Useful for
540 // foreign chains who want to have a local sovereign account on this chain which they control.
541 SovereignSignedViaLocation<LocationToAccountId, Origin>,
542 // Native converter for Relay-chain (Parent) location; will converts to a `Relay` origin when
543 // recognised.
544 RelayChainAsNative<RelayChainOrigin, Origin>,
545 // Native converter for sibling Parachains; will convert to a `SiblingPara` origin when
546 // recognised.
547 SiblingParachainAsNative<cumulus_pallet_xcm::Origin, Origin>,
548 // Superuser converter for the Relay-chain (Parent) location. This will allow it to issue a
549 // transaction from the Root origin.
550 ParentAsSuperuser<Origin>,
551 // Native signed account converter; this just converts an `AccountId32` origin into a normal
552 // `Origin::Signed` origin of the same 32-byte value.
553 SignedAccountId32AsNative<RococoNetwork, Origin>,
554);
555
556parameter_types! {
557 pub UnitWeightCost: Weight = 1_000;
558}
559
560parameter_types! {
561 // 1_000_000_000_000 => 1 unit of asset for 1 unit of Weight.
562 // TODO: Should take the actual weight price. This is just 1_000 ROC per second of weight.
563 pub const WeightPrice: (MultiLocation, u128) = (MultiLocation::X1(Junction::Parent), 1_000);
564 pub AllowUnpaidFrom: Vec<MultiLocation> = vec![ MultiLocation::X1(Junction::Parent) ];
565}
566
567pub type Barrier = (
568 TakeWeightCredit,
569 AllowTopLevelPaidExecutionFrom<All<MultiLocation>>,
570 AllowUnpaidExecutionFrom<IsInVec<AllowUnpaidFrom>>, // <- Parent gets free execution
571);
572
573
574pub struct XcmConfig;
575impl Config for XcmConfig {
576 type Call = Call;
577 type XcmSender = XcmRouter;
578 // How to withdraw and deposit an asset.
579 type AssetTransactor = LocalAssetTransactor;
580 type OriginConverter = XcmOriginToTransactDispatchOrigin;
581 type IsReserve = NativeAsset;
582 type IsTeleporter = NativeAsset; // <- should be enough to allow teleportation of ROC
583 type LocationInverter = LocationInverter<Ancestry>;
584 type Barrier = Barrier;
585 type Weigher = FixedWeightBounds<UnitWeightCost, Call>;
586 type Trader = FixedRateOfConcreteFungible<WeightPrice>;
587 type ResponseHandler = (); // Don't handle responses for now.
588}
589
590parameter_types! {
591 pub const MaxDownwardMessageWeight: Weight = MAXIMUM_BLOCK_WEIGHT / 10;
592}
593
594/// No local origins on this chain are allowed to dispatch XCM sends/executions.
595pub type LocalOriginToLocation = ();
596
597/// The means for routing XCM messages which are not for local execution into the right message
598/// queues.
599pub type XcmRouter = (
600 // Two routers - use UMP to communicate with the relay chain:
601 cumulus_primitives_utility::ParentAsUmp<ParachainSystem>,
602 // ..and XCMP to communicate with the sibling chains.
603 XcmpQueue,
604);
605
606impl pallet_xcm::Config for Runtime {
607 type Event = Event;
608 type SendXcmOrigin = EnsureXcmOrigin<Origin, LocalOriginToLocation>;
609 type XcmRouter = XcmRouter;
610 type ExecuteXcmOrigin = EnsureXcmOrigin<Origin, LocalOriginToLocation>;
611 type XcmExecutor = XcmExecutor<XcmConfig>;
612}
613
614impl cumulus_pallet_xcm::Config for Runtime {}
615
616impl cumulus_pallet_xcmp_queue::Config for Runtime {
617 type Event = Event;
618 type XcmExecutor = XcmExecutor<XcmConfig>;
619 type ChannelInfo = ParachainSystem;
620}
522621
523parameter_types! {622parameter_types! {
524 pub TreasuryAccountId: AccountId = TreasuryModuleId::get().into_account();623 pub TreasuryAccountId: AccountId = TreasuryModuleId::get().into_account();
555 NodeBlock = opaque::Block,654 NodeBlock = opaque::Block,
556 UncheckedExtrinsic = UncheckedExtrinsic655 UncheckedExtrinsic = UncheckedExtrinsic
557 {656 {
558 System: system::{Module, Call, Config, Storage, Event<T>},657 Balances: pallet_balances::{Module, Call, Storage, Config<T>, Event<T>},
559 RandomnessCollectiveFlip: pallet_randomness_collective_flip::{Module, Call, Storage},
560 Contracts: pallet_contracts::{Module, Call, Config<T>, Storage, Event<T>},658 Contracts: pallet_contracts::{Module, Call, Config<T>, Storage, Event<T>},
561 Timestamp: pallet_timestamp::{Module, Call, Storage, Inherent},659 CumulusXcm: cumulus_pallet_xcm::{Pallet, Origin},
562 Aura: pallet_aura::{Module, Config<T> },660 ParachainInfo: parachain_info::{Pallet, Storage, Config},
563 Grandpa: pallet_grandpa::{Module, Call, Storage, Config, Event},661 ParachainSystem: cumulus_pallet_parachain_system::{Pallet, Call, Storage, Inherent, Event<T>},
564 Balances: pallet_balances::{Module, Call, Storage, Config<T>, Event<T>},662 PolkadotXcm: pallet_xcm::{Pallet, Call, Event<T>, Origin},
565 TransactionPayment: pallet_transaction_payment::{Module, Storage},663 RandomnessCollectiveFlip: pallet_randomness_collective_flip::{Module, Call, Storage},
566 Sudo: pallet_sudo::{Module, Call, Config<T>, Storage, Event<T>},664 Sudo: pallet_sudo::{Module, Call, Config<T>, Storage, Event<T>},
567 Inflation: pallet_inflation::{Module, Call, Storage},665 System: system::{Module, Call, Config, Storage, Event<T>},
568 Nft: pallet_nft::{Module, Call, Config<T>, Storage, Event<T>},666 Timestamp: pallet_timestamp::{Module, Call, Storage, Inherent},
667 TransactionPayment: pallet_transaction_payment::{Module, Storage},
668 Treasury: pallet_treasury::{Module, Call, Storage, Config, Event<T>},
669 Vesting: pallet_vesting::{Module, Call, Config<T>, Storage, Event<T>},
569 Treasury: pallet_treasury::{Module, Call, Storage, Config, Event<T>},670 XcmpQueue: cumulus_pallet_xcmp_queue::{Pallet, Call, Storage, Event<T>},
671
570 Vesting: pallet_vesting::{Module, Call, Config<T>, Storage, Event<T>},672 Inflation: pallet_inflation::{Module, Call, Storage},
673 Nft: pallet_nft::{Module, Call, Config<T>, Storage, Event<T>},
571 }674 }
572);675);
573676
601704
602impl_runtime_apis! {705impl_runtime_apis! {
603
604 impl pallet_contracts_rpc_runtime_api::ContractsApi<Block, AccountId, Balance, BlockNumber>
605 for Runtime
606 {
607 fn call(
608 origin: AccountId,
609 dest: AccountId,
610 value: Balance,
611 gas_limit: u64,
612 input_data: Vec<u8>,
613 ) -> pallet_contracts_primitives::ContractExecResult {
614 Contracts::bare_call(origin, dest, value, gas_limit, input_data)
615 }
616
617 fn get_storage(
618 address: AccountId,
619 key: [u8; 32],
620 ) -> pallet_contracts_primitives::GetStorageResult {
621 Contracts::get_storage(address, key)
622 }
623
624 fn rent_projection(
625 address: AccountId,
626 ) -> pallet_contracts_primitives::RentProjectionResult<BlockNumber> {
627 Contracts::rent_projection(address)
628 }
629 }
630
631 impl sp_api::Core<Block> for Runtime {706 impl sp_api::Core<Block> for Runtime {
632 fn version() -> RuntimeVersion {707 fn version() -> RuntimeVersion {
688 }763 }
689 }764 }
690
691 impl sp_consensus_aura::AuraApi<Block, AuraId> for Runtime {
692 fn slot_duration() -> u64 {
693 Aura::slot_duration()
694 }
695
696 fn authorities() -> Vec<AuraId> {
697 Aura::authorities()
698 }
699 }
700765
701 impl sp_session::SessionKeys<Block> for Runtime {766 impl sp_session::SessionKeys<Block> for Runtime {
702 fn generate_session_keys(seed: Option<Vec<u8>>) -> Vec<u8> {767 fn generate_session_keys(seed: Option<Vec<u8>>) -> Vec<u8> {
710 }775 }
711 }776 }
712777
713 impl fg_primitives::GrandpaApi<Block> for Runtime {
714 fn grandpa_authorities() -> GrandpaAuthorityList {
715 Grandpa::grandpa_authorities()
716 }
717
718 fn submit_report_equivocation_unsigned_extrinsic(
719 _equivocation_proof: fg_primitives::EquivocationProof<
720 <Block as BlockT>::Hash,
721 NumberFor<Block>,
722 >,
723 _key_owner_proof: fg_primitives::OpaqueKeyOwnershipProof,
724 ) -> Option<()> {
725 None
726 }
727
728 fn generate_key_ownership_proof(
729 _set_id: fg_primitives::SetId,
730 _authority_id: GrandpaId,
731 ) -> Option<fg_primitives::OpaqueKeyOwnershipProof> {
732 // NOTE: this is the only implementation possible since we've
733 // defined our key owner proof type as a bottom type (i.e. a type
734 // with no values).
735 None
736 }
737 }
738
739 impl frame_system_rpc_runtime_api::AccountNonceApi<Block, AccountId, Index> for Runtime {778 impl frame_system_rpc_runtime_api::AccountNonceApi<Block, AccountId, Index> for Runtime {
740 fn account_nonce(account: AccountId) -> Index {779 fn account_nonce(account: AccountId) -> Index {
751 }790 }
752 }791 }
792
793 impl pallet_contracts_rpc_runtime_api::ContractsApi<Block, AccountId, Balance, BlockNumber>
794 for Runtime
795 {
796 fn call(
797 origin: AccountId,
798 dest: AccountId,
799 value: Balance,
800 gas_limit: u64,
801 input_data: Vec<u8>,
802 ) -> pallet_contracts_primitives::ContractExecResult {
803 Contracts::bare_call(origin, dest, value, gas_limit, input_data)
804 }
805
806 fn get_storage(
807 address: AccountId,
808 key: [u8; 32],
809 ) -> pallet_contracts_primitives::GetStorageResult {
810 Contracts::get_storage(address, key)
811 }
812
813 fn rent_projection(
814 address: AccountId,
815 ) -> pallet_contracts_primitives::RentProjectionResult<BlockNumber> {
816 Contracts::rent_projection(address)
817 }
818 }
753819
754 #[cfg(feature = "runtime-benchmarks")]820 #[cfg(feature = "runtime-benchmarks")]
755 impl frame_benchmarking::Benchmark<Block> for Runtime {821 impl frame_benchmarking::Benchmark<Block> for Runtime {