git.delta.rocks / unique-network / refs/commits / f4d3ad69d8ba

difftreelog

Field name changed

str-mv2020-07-03parent: #af2b662.patch.diff
in: master

4 files changed

modifiedCargo.lockdiffbeforeafterboth
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -2804,6 +2804,7 @@
  "pallet-grandpa",
  "pallet-nft",
  "pallet-randomness-collective-flip",
+ "pallet-staking",
  "pallet-sudo",
  "pallet-timestamp",
  "pallet-transaction-payment",
@@ -3005,6 +3006,21 @@
 ]
 
 [[package]]
+name = "pallet-authorship"
+version = "2.0.0-rc4"
+source = "git+https://github.com/paritytech/substrate.git?tag=v2.0.0-rc4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4"
+dependencies = [
+ "frame-support",
+ "frame-system",
+ "impl-trait-for-tuples",
+ "parity-scale-codec",
+ "sp-authorship",
+ "sp-inherents",
+ "sp-runtime",
+ "sp-std",
+]
+
+[[package]]
 name = "pallet-balances"
 version = "2.0.0-rc4"
 source = "git+https://github.com/paritytech/substrate.git?tag=v2.0.0-rc4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4"
@@ -3161,6 +3177,26 @@
 ]
 
 [[package]]
+name = "pallet-staking"
+version = "2.0.0-rc4"
+source = "git+https://github.com/paritytech/substrate.git?tag=v2.0.0-rc4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4"
+dependencies = [
+ "frame-support",
+ "frame-system",
+ "pallet-authorship",
+ "pallet-session",
+ "parity-scale-codec",
+ "serde",
+ "sp-application-crypto",
+ "sp-io",
+ "sp-npos-elections",
+ "sp-runtime",
+ "sp-staking",
+ "sp-std",
+ "static_assertions",
+]
+
+[[package]]
 name = "pallet-sudo"
 version = "2.0.0-rc4"
 source = "git+https://github.com/paritytech/substrate.git?tag=v2.0.0-rc4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4"
@@ -5360,6 +5396,17 @@
 ]
 
 [[package]]
+name = "sp-authorship"
+version = "2.0.0-rc4"
+source = "git+https://github.com/paritytech/substrate.git?tag=v2.0.0-rc4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4"
+dependencies = [
+ "parity-scale-codec",
+ "sp-inherents",
+ "sp-runtime",
+ "sp-std",
+]
+
+[[package]]
 name = "sp-block-builder"
 version = "2.0.0-rc4"
 source = "git+https://github.com/paritytech/substrate.git?tag=v2.0.0-rc4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4"
@@ -5577,6 +5624,29 @@
 ]
 
 [[package]]
+name = "sp-npos-elections"
+version = "2.0.0-rc4"
+source = "git+https://github.com/paritytech/substrate.git?tag=v2.0.0-rc4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4"
+dependencies = [
+ "parity-scale-codec",
+ "serde",
+ "sp-arithmetic",
+ "sp-npos-elections-compact",
+ "sp-std",
+]
+
+[[package]]
+name = "sp-npos-elections-compact"
+version = "2.0.0-rc4"
+source = "git+https://github.com/paritytech/substrate.git?tag=v2.0.0-rc4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4"
+dependencies = [
+ "proc-macro-crate",
+ "proc-macro2",
+ "quote 1.0.7",
+ "syn 1.0.31",
+]
+
+[[package]]
 name = "sp-offchain"
 version = "2.0.0-rc4"
 source = "git+https://github.com/paritytech/substrate.git?tag=v2.0.0-rc4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4"
modifiedpallets/nft/src/lib.rsdiffbeforeafterboth
--- a/pallets/nft/src/lib.rs
+++ b/pallets/nft/src/lib.rs
@@ -26,7 +26,7 @@
     pub next_item_id: u64,
     pub name: Vec<u16>, // 64 include null escape char
     pub description: Vec<u16>, // 256 include null escape char
-    pub token_trefix: Vec<u8>, // 16 include null escape char
+    pub token_prefix: Vec<u8>, // 16 include null escape char
     pub custom_data_size: u32,
 }
 
@@ -125,9 +125,9 @@
             description.push(0);
             ensure!(name.len() <= 256, "Collection description can not be longer than 255 char");
 
-            let mut token_trefix = token_prefix.to_vec();
-            token_trefix.push(0);
-            ensure!(token_trefix.len() <= 16, "Token prefix can not be longer than 15 char");
+            let mut prefix = token_prefix.to_vec();
+            prefix.push(0);
+            ensure!(prefix.len() <= 16, "Token prefix can not be longer than 15 char");
 
             // Generate next collection ID
             let next_id = NextCollectionID::get();
@@ -139,7 +139,7 @@
                 owner: who.clone(),
                 name: name,
                 description: description,
-                token_trefix: token_trefix,
+                token_prefix: prefix,
                 next_item_id: next_id,
                 custom_data_size: custom_data_sz,
             };
modifiedruntime/Cargo.tomldiffbeforeafterboth
--- a/runtime/Cargo.toml
+++ b/runtime/Cargo.toml
@@ -27,6 +27,7 @@
     'sudo/std',
     'system/std',
     'timestamp/std',
+    'staking/std',
     'transaction-payment/std',
     'nft/std',
 ]
@@ -201,6 +202,14 @@
 tag = 'v2.0.0-rc4'
 version = '2.0.0-rc4'
 
+
+[dependencies.staking]
+default-features = false
+git = 'https://github.com/paritytech/substrate.git'
+package = 'pallet-staking'
+tag = 'v2.0.0-rc4'
+version = '2.0.0-rc4'
+
 [dependencies.transaction-payment]
 default-features = false
 git = 'https://github.com/paritytech/substrate.git'
modifiedruntime/src/lib.rsdiffbeforeafterboth
before · runtime/src/lib.rs
1//! The Substrate Node Template runtime. This can be compiled with `#[no_std]`, ready for Wasm.23#![cfg_attr(not(feature = "std"), no_std)]4// `construct_runtime!` does a lot of recursion and requires us to increase the limit to 256.5#![recursion_limit="256"]67// Make the WASM binary available.8#[cfg(feature = "std")]9include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs"));1011use sp_std::prelude::*;12use sp_core::{crypto::KeyTypeId, OpaqueMetadata};13use sp_runtime::{14	ApplyExtrinsicResult, generic, create_runtime_str, impl_opaque_keys, MultiSignature,15	transaction_validity::{TransactionValidity, TransactionSource},16};17use sp_runtime::traits::{18	BlakeTwo256, Block as BlockT, IdentityLookup, Verify, IdentifyAccount, NumberFor, Saturating,19};20use sp_api::impl_runtime_apis;21use sp_consensus_aura::sr25519::AuthorityId as AuraId;22use grandpa::{AuthorityId as GrandpaId, AuthorityList as GrandpaAuthorityList};23use grandpa::fg_primitives;24use sp_version::RuntimeVersion;25#[cfg(feature = "std")]26use sp_version::NativeVersion;27use contracts_rpc_runtime_api::ContractExecResult;2829// A few exports that help ease life for downstream crates.30#[cfg(any(feature = "std", test))]31pub use sp_runtime::BuildStorage;32pub use timestamp::Call as TimestampCall;33pub use balances::Call as BalancesCall;34pub use sp_runtime::{Permill, Perbill};35pub use contracts::Schedule as ContractsSchedule;36pub use frame_support::{37	construct_runtime, parameter_types, StorageValue,38	traits::{KeyOwnerProofSystem, Randomness},39	weights::{40		Weight, IdentityFee,41		constants::{BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight, WEIGHT_PER_SECOND},42	},43};4445/// Importing a template pallet46pub use nft;4748/// An index to a block.49pub type BlockNumber = u32;5051/// Alias to 512-bit hash when used in the context of a transaction signature on the chain.52pub type Signature = MultiSignature;5354/// Some way of identifying an account on the chain. We intentionally make it equivalent55/// to the public key of our transaction signing scheme.56pub type AccountId = <<Signature as Verify>::Signer as IdentifyAccount>::AccountId;5758/// The type for looking up accounts. We don't expect more than 4 billion of them, but you59/// never know...60pub type AccountIndex = u32;6162/// Balance of an account.63pub type Balance = u128;6465/// Index of a transaction in the chain.66pub type Index = u32;6768/// A hash of some data used by the chain.69pub type Hash = sp_core::H256;7071/// Digest item type.72pub type DigestItem = generic::DigestItem<Hash>;7374pub const MILLICENTS: Balance = 1_000_000_000;75pub const CENTS: Balance = 1_000 * MILLICENTS;76pub const DOLLARS: Balance = 100 * CENTS;7778/// Opaque types. These are used by the CLI to instantiate machinery that don't need to know79/// the specifics of the runtime. They can then be made to be agnostic over specific formats80/// of data like extrinsics, allowing for them to continue syncing the network through upgrades81/// to even the core data structures.82pub mod opaque {83	use super::*;8485	pub use sp_runtime::OpaqueExtrinsic as UncheckedExtrinsic;8687	/// Opaque block header type.88	pub type Header = generic::Header<BlockNumber, BlakeTwo256>;89	/// Opaque block type.90	pub type Block = generic::Block<Header, UncheckedExtrinsic>;91	/// Opaque block identifier type.92	pub type BlockId = generic::BlockId<Block>;9394	impl_opaque_keys! {95		pub struct SessionKeys {96			pub aura: Aura,97			pub grandpa: Grandpa,98		}99	}100}101102/// This runtime version.103pub const VERSION: RuntimeVersion = RuntimeVersion {104    spec_name: create_runtime_str!("nft"),105    impl_name: create_runtime_str!("nft"),106	authoring_version: 1,107	spec_version: 1,108	impl_version: 1,109	apis: RUNTIME_API_VERSIONS,110	transaction_version: 1,111};112113pub const MILLISECS_PER_BLOCK: u64 = 6000;114115pub const SLOT_DURATION: u64 = MILLISECS_PER_BLOCK;116117// These time units are defined in number of blocks.118pub const MINUTES: BlockNumber = 60_000 / (MILLISECS_PER_BLOCK as BlockNumber);119pub const HOURS: BlockNumber = MINUTES * 60;120pub const DAYS: BlockNumber = HOURS * 24;121122/// The version information used to identify this runtime when compiled natively.123#[cfg(feature = "std")]124pub fn native_version() -> NativeVersion {125	NativeVersion {126		runtime_version: VERSION,127		can_author_with: Default::default(),128	}129}130131parameter_types! {132	pub const BlockHashCount: BlockNumber = 2400;133	/// We allow for 2 seconds of compute with a 6 second average block time.134	pub const MaximumBlockWeight: Weight = 2 * WEIGHT_PER_SECOND;135	pub const AvailableBlockRatio: Perbill = Perbill::from_percent(75);136	/// Assume 10% of weight for average on_initialize calls.137	pub MaximumExtrinsicWeight: Weight = AvailableBlockRatio::get()138		.saturating_sub(Perbill::from_percent(10)) * MaximumBlockWeight::get();139	pub const MaximumBlockLength: u32 = 5 * 1024 * 1024;140	pub const Version: RuntimeVersion = VERSION;141}142143impl system::Trait for Runtime {144	/// The basic call filter to use in dispatchable.145	type BaseCallFilter = ();146	/// The identifier used to distinguish between accounts.147	type AccountId = AccountId;148	/// The aggregated dispatch type that is available for extrinsics.149	type Call = Call;150	/// The lookup mechanism to get account ID from whatever is passed in dispatchers.151	type Lookup = IdentityLookup<AccountId>;152	/// The index type for storing how many extrinsics an account has signed.153	type Index = Index;154	/// The index type for blocks.155	type BlockNumber = BlockNumber;156	/// The type for hashing blocks and tries.157	type Hash = Hash;158	/// The hashing algorithm used.159	type Hashing = BlakeTwo256;160	/// The header type.161	type Header = generic::Header<BlockNumber, BlakeTwo256>;162	/// The ubiquitous event type.163	type Event = Event;164	/// The ubiquitous origin type.165	type Origin = Origin;166	/// Maximum number of block number to block hash mappings to keep (oldest pruned first).167	type BlockHashCount = BlockHashCount;168	/// Maximum weight of each block.169	type MaximumBlockWeight = MaximumBlockWeight;170	/// The weight of database operations that the runtime can invoke.171	type DbWeight = RocksDbWeight;172	/// The weight of the overhead invoked on the block import process, independent of the173	/// extrinsics included in that block.174	type BlockExecutionWeight = BlockExecutionWeight;175	/// The base weight of any extrinsic processed by the runtime, independent of the176	/// logic of that extrinsic. (Signature verification, nonce increment, fee, etc...)177	type ExtrinsicBaseWeight = ExtrinsicBaseWeight;178	/// The maximum weight that a single extrinsic of `Normal` dispatch class can have,179	/// idependent of the logic of that extrinsics. (Roughly max block weight - average on180	/// initialize cost).181	type MaximumExtrinsicWeight = MaximumExtrinsicWeight;182	/// Maximum size of all encoded transactions (in bytes) that are allowed in one block.183	type MaximumBlockLength = MaximumBlockLength;184	/// Portion of the block weight that is available to all normal transactions.185	type AvailableBlockRatio = AvailableBlockRatio;186	/// Version of the runtime.187	type Version = Version;188	/// Converts a module to the index of the module in `construct_runtime!`.189	///190	/// This type is being generated by `construct_runtime!`.191	type ModuleToIndex = ModuleToIndex;192	/// What to do if a new account is created.193	type OnNewAccount = ();194	/// What to do if an account is fully reaped from the system.195	type OnKilledAccount = ();196	/// The data to be stored in an account.197	type AccountData = balances::AccountData<Balance>;198}199200impl aura::Trait for Runtime {201	type AuthorityId = AuraId;202}203204impl grandpa::Trait for Runtime {205	type Event = Event;206	type Call = Call;207208	type KeyOwnerProofSystem = ();209210	type KeyOwnerProof =211		<Self::KeyOwnerProofSystem as KeyOwnerProofSystem<(KeyTypeId, GrandpaId)>>::Proof;212213	type KeyOwnerIdentification = <Self::KeyOwnerProofSystem as KeyOwnerProofSystem<(214		KeyTypeId,215		GrandpaId,216	)>>::IdentificationTuple;217218	type HandleEquivocation = ();219}220221parameter_types! {222	pub const MinimumPeriod: u64 = SLOT_DURATION / 2;223}224225impl timestamp::Trait for Runtime {226	/// A timestamp: milliseconds since the unix epoch.227	type Moment = u64;228	type OnTimestampSet = Aura;229	type MinimumPeriod = MinimumPeriod;230}231232parameter_types! {233	pub const ExistentialDeposit: u128 = 500;234}235236impl balances::Trait for Runtime {237	/// The type for recording an account's balance.238	type Balance = Balance;239	/// The ubiquitous event type.240	type Event = Event;241	type DustRemoval = ();242	type ExistentialDeposit = ExistentialDeposit;243	type AccountStore = System;244}245246parameter_types! {247	pub const TransactionByteFee: Balance = 1;248}249250impl transaction_payment::Trait for Runtime {251	type Currency = balances::Module<Runtime>;252	type OnTransactionPayment = ();253	type TransactionByteFee = TransactionByteFee;254	type WeightToFee = IdentityFee<Balance>;255	type FeeMultiplierUpdate = ();256}257258impl sudo::Trait for Runtime {259	type Event = Event;260	type Call = Call;261}262263parameter_types! {264    pub const TombstoneDeposit: Balance = 16 * MILLICENTS;265    pub const RentByteFee: Balance = 4 * MILLICENTS;266    pub const RentDepositOffset: Balance = 1000 * MILLICENTS;267    pub const SurchargeReward: Balance = 150 * MILLICENTS;268}269270impl contracts::Trait for Runtime {271    type Time = Timestamp;272    type Randomness = RandomnessCollectiveFlip;273    type Currency = Balances;274    type Event = Event;275    type DetermineContractAddress = contracts::SimpleAddressDeterminer<Runtime>;276    type TrieIdGenerator = contracts::TrieIdFromParentCounter<Runtime>;277    type RentPayment = ();278    type SignedClaimHandicap = contracts::DefaultSignedClaimHandicap;279    type TombstoneDeposit = TombstoneDeposit;280    type StorageSizeOffset = contracts::DefaultStorageSizeOffset;281    type RentByteFee = RentByteFee;282    type RentDepositOffset = RentDepositOffset;283    type SurchargeReward = SurchargeReward;284    type MaxDepth = contracts::DefaultMaxDepth;285    type MaxValueSize = contracts::DefaultMaxValueSize;286    type WeightPrice = transaction_payment::Module<Self>;287}288289/// Used for the module template in `./template.rs`290impl nft::Trait for Runtime {291    type Event = Event;292}293294construct_runtime!(295	pub enum Runtime where296		Block = Block,297		NodeBlock = opaque::Block,298		UncheckedExtrinsic = UncheckedExtrinsic299	{300		System: system::{Module, Call, Config, Storage, Event<T>},301		RandomnessCollectiveFlip: randomness_collective_flip::{Module, Call, Storage},302		Contracts: contracts::{Module, Call, Config, Storage, Event<T>},303		Timestamp: timestamp::{Module, Call, Storage, Inherent},304		Aura: aura::{Module, Config<T>, Inherent(Timestamp)},305		Grandpa: grandpa::{Module, Call, Storage, Config, Event},306		Balances: balances::{Module, Call, Storage, Config<T>, Event<T>},307		TransactionPayment: transaction_payment::{Module, Storage},308		Sudo: sudo::{Module, Call, Config<T>, Storage, Event<T>},309		// Used for the module template in `./template.rs`310        Nft: nft::{Module, Call, Storage, Event<T>},311	}312);313314/// The address format for describing accounts.315pub type Address = AccountId;316/// Block header type as expected by this runtime.317pub type Header = generic::Header<BlockNumber, BlakeTwo256>;318/// Block type as expected by this runtime.319pub type Block = generic::Block<Header, UncheckedExtrinsic>;320/// A Block signed with a Justification321pub type SignedBlock = generic::SignedBlock<Block>;322/// BlockId type as expected by this runtime.323pub type BlockId = generic::BlockId<Block>;324/// The SignedExtension to the basic transaction logic.325pub type SignedExtra = (326	system::CheckSpecVersion<Runtime>,327	system::CheckTxVersion<Runtime>,328	system::CheckGenesis<Runtime>,329	system::CheckEra<Runtime>,330	system::CheckNonce<Runtime>,331	system::CheckWeight<Runtime>,332	transaction_payment::ChargeTransactionPayment<Runtime>333);334/// Unchecked extrinsic type as expected by this runtime.335pub type UncheckedExtrinsic = generic::UncheckedExtrinsic<Address, Call, Signature, SignedExtra>;336/// Extrinsic type that has already been checked.337pub type CheckedExtrinsic = generic::CheckedExtrinsic<AccountId, Call, SignedExtra>;338/// Executive: handles dispatch to the various modules.339pub type Executive = frame_executive::Executive<Runtime, Block, system::ChainContext<Runtime>, Runtime, AllModules>;340341impl_runtime_apis! {342	impl sp_api::Core<Block> for Runtime {343		fn version() -> RuntimeVersion {344			VERSION345		}346347		fn execute_block(block: Block) {348			Executive::execute_block(block)349		}350351		fn initialize_block(header: &<Block as BlockT>::Header) {352			Executive::initialize_block(header)353		}354	}355356	impl sp_api::Metadata<Block> for Runtime {357		fn metadata() -> OpaqueMetadata {358			Runtime::metadata().into()359		}360	}361362	impl sp_block_builder::BlockBuilder<Block> for Runtime {363		fn apply_extrinsic(extrinsic: <Block as BlockT>::Extrinsic) -> ApplyExtrinsicResult {364			Executive::apply_extrinsic(extrinsic)365		}366367		fn finalize_block() -> <Block as BlockT>::Header {368			Executive::finalize_block()369		}370371		fn inherent_extrinsics(data: sp_inherents::InherentData) -> Vec<<Block as BlockT>::Extrinsic> {372			data.create_extrinsics()373		}374375		fn check_inherents(376			block: Block,377			data: sp_inherents::InherentData,378		) -> sp_inherents::CheckInherentsResult {379			data.check_extrinsics(&block)380		}381382		fn random_seed() -> <Block as BlockT>::Hash {383			RandomnessCollectiveFlip::random_seed()384		}385	}386387	impl sp_transaction_pool::runtime_api::TaggedTransactionQueue<Block> for Runtime {388		fn validate_transaction(389			source: TransactionSource,390			tx: <Block as BlockT>::Extrinsic,391		) -> TransactionValidity {392			Executive::validate_transaction(source, tx)393		}394	}395396	impl sp_offchain::OffchainWorkerApi<Block> for Runtime {397		fn offchain_worker(header: &<Block as BlockT>::Header) {398			Executive::offchain_worker(header)399		}400	}401402	impl sp_consensus_aura::AuraApi<Block, AuraId> for Runtime {403		fn slot_duration() -> u64 {404			Aura::slot_duration()405		}406407		fn authorities() -> Vec<AuraId> {408			Aura::authorities()409		}410	}411412	impl sp_session::SessionKeys<Block> for Runtime {413		fn generate_session_keys(seed: Option<Vec<u8>>) -> Vec<u8> {414			opaque::SessionKeys::generate(seed)415		}416417		fn decode_session_keys(418			encoded: Vec<u8>,419		) -> Option<Vec<(Vec<u8>, KeyTypeId)>> {420			opaque::SessionKeys::decode_into_raw_public_keys(&encoded)421		}422	}423424	impl fg_primitives::GrandpaApi<Block> for Runtime {425		fn grandpa_authorities() -> GrandpaAuthorityList {426			Grandpa::grandpa_authorities()427		}428429		fn submit_report_equivocation_extrinsic(430			_equivocation_proof: fg_primitives::EquivocationProof<431				<Block as BlockT>::Hash,432				NumberFor<Block>,433			>,434			_key_owner_proof: fg_primitives::OpaqueKeyOwnershipProof,435		) -> Option<()> {436			None437		}438439		fn generate_key_ownership_proof(440			_set_id: fg_primitives::SetId,441			_authority_id: GrandpaId,442		) -> Option<fg_primitives::OpaqueKeyOwnershipProof> {443			// NOTE: this is the only implementation possible since we've444			// defined our key owner proof type as a bottom type (i.e. a type445			// with no values).446			None447		}448	}449450	impl contracts_rpc_runtime_api::ContractsApi<Block, AccountId, Balance, BlockNumber>451	for Runtime452	{453		fn call(454			origin: AccountId,455			dest: AccountId,456			value: Balance,457			gas_limit: u64,458			input_data: Vec<u8>,459		) -> ContractExecResult {460			let exec_result =461				Contracts::bare_call(origin, dest.into(), value, gas_limit, input_data);462			match exec_result {463				Ok(v) => ContractExecResult::Success {464					status: v.status,465					data: v.data,466				},467				Err(_) => ContractExecResult::Error,468			}469		}470471		fn get_storage(472			address: AccountId,473			key: [u8; 32],474		) -> contracts_primitives::GetStorageResult {475			Contracts::get_storage(address, key)476		}477478		fn rent_projection(479			address: AccountId,480		) -> contracts_primitives::RentProjectionResult<BlockNumber> {481			Contracts::rent_projection(address)482		}483	}484485}
after · runtime/src/lib.rs
1//! The Substrate Node Template runtime. This can be compiled with `#[no_std]`, ready for Wasm.23#![cfg_attr(not(feature = "std"), no_std)]4// `construct_runtime!` does a lot of recursion and requires us to increase the limit to 256.5#![recursion_limit="256"]67// Make the WASM binary available.8#[cfg(feature = "std")]9include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs"));1011use sp_std::prelude::*;12use sp_core::{crypto::KeyTypeId, OpaqueMetadata};13use sp_runtime::{14	ApplyExtrinsicResult, generic, create_runtime_str, impl_opaque_keys, MultiSignature,15	transaction_validity::{TransactionValidity, TransactionSource},16};17use sp_runtime::traits::{18	BlakeTwo256, Block as BlockT, IdentityLookup, Verify, IdentifyAccount, NumberFor, Saturating,19};20use sp_api::impl_runtime_apis;21use sp_consensus_aura::sr25519::AuthorityId as AuraId;22use grandpa::{AuthorityId as GrandpaId, AuthorityList as GrandpaAuthorityList};23use grandpa::fg_primitives;24use sp_version::RuntimeVersion;25#[cfg(feature = "std")]26use sp_version::NativeVersion;27use contracts_rpc_runtime_api::ContractExecResult;2829// A few exports that help ease life for downstream crates.30#[cfg(any(feature = "std", test))]31pub use sp_runtime::BuildStorage;32pub use timestamp::Call as TimestampCall;33pub use staking::Call as StakingCall;34pub use balances::Call as BalancesCall;35pub use sp_runtime::{Permill, Perbill};36pub use contracts::Schedule as ContractsSchedule;37pub use frame_support::{38	construct_runtime, parameter_types, StorageValue,39	traits::{KeyOwnerProofSystem, Randomness},40	weights::{41		Weight, IdentityFee,42		constants::{BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight, WEIGHT_PER_SECOND},43	},44};4546/// Importing a template pallet47pub use nft;4849/// An index to a block.50pub type BlockNumber = u32;5152/// Alias to 512-bit hash when used in the context of a transaction signature on the chain.53pub type Signature = MultiSignature;5455/// Some way of identifying an account on the chain. We intentionally make it equivalent56/// to the public key of our transaction signing scheme.57pub type AccountId = <<Signature as Verify>::Signer as IdentifyAccount>::AccountId;5859/// The type for looking up accounts. We don't expect more than 4 billion of them, but you60/// never know...61pub type AccountIndex = u32;6263/// Balance of an account.64pub type Balance = u128;6566/// Index of a transaction in the chain.67pub type Index = u32;6869/// A hash of some data used by the chain.70pub type Hash = sp_core::H256;7172/// Digest item type.73pub type DigestItem = generic::DigestItem<Hash>;7475pub const MILLICENTS: Balance = 1_000_000_000;76pub const CENTS: Balance = 1_000 * MILLICENTS;77pub const DOLLARS: Balance = 100 * CENTS;7879/// Opaque types. These are used by the CLI to instantiate machinery that don't need to know80/// the specifics of the runtime. They can then be made to be agnostic over specific formats81/// of data like extrinsics, allowing for them to continue syncing the network through upgrades82/// to even the core data structures.83pub mod opaque {84	use super::*;8586	pub use sp_runtime::OpaqueExtrinsic as UncheckedExtrinsic;8788	/// Opaque block header type.89	pub type Header = generic::Header<BlockNumber, BlakeTwo256>;90	/// Opaque block type.91	pub type Block = generic::Block<Header, UncheckedExtrinsic>;92	/// Opaque block identifier type.93	pub type BlockId = generic::BlockId<Block>;9495	impl_opaque_keys! {96		pub struct SessionKeys {97			pub aura: Aura,98			pub grandpa: Grandpa,99		}100	}101}102103/// This runtime version.104pub const VERSION: RuntimeVersion = RuntimeVersion {105    spec_name: create_runtime_str!("nft"),106    impl_name: create_runtime_str!("nft"),107	authoring_version: 1,108	spec_version: 1,109	impl_version: 1,110	apis: RUNTIME_API_VERSIONS,111	transaction_version: 1,112};113114pub const MILLISECS_PER_BLOCK: u64 = 6000;115116pub const SLOT_DURATION: u64 = MILLISECS_PER_BLOCK;117118// These time units are defined in number of blocks.119pub const MINUTES: BlockNumber = 60_000 / (MILLISECS_PER_BLOCK as BlockNumber);120pub const HOURS: BlockNumber = MINUTES * 60;121pub const DAYS: BlockNumber = HOURS * 24;122123/// The version information used to identify this runtime when compiled natively.124#[cfg(feature = "std")]125pub fn native_version() -> NativeVersion {126	NativeVersion {127		runtime_version: VERSION,128		can_author_with: Default::default(),129	}130}131132parameter_types! {133	pub const BlockHashCount: BlockNumber = 2400;134	/// We allow for 2 seconds of compute with a 6 second average block time.135	pub const MaximumBlockWeight: Weight = 2 * WEIGHT_PER_SECOND;136	pub const AvailableBlockRatio: Perbill = Perbill::from_percent(75);137	/// Assume 10% of weight for average on_initialize calls.138	pub MaximumExtrinsicWeight: Weight = AvailableBlockRatio::get()139		.saturating_sub(Perbill::from_percent(10)) * MaximumBlockWeight::get();140	pub const MaximumBlockLength: u32 = 5 * 1024 * 1024;141	pub const Version: RuntimeVersion = VERSION;142}143144impl system::Trait for Runtime {145	/// The basic call filter to use in dispatchable.146	type BaseCallFilter = ();147	/// The identifier used to distinguish between accounts.148	type AccountId = AccountId;149	/// The aggregated dispatch type that is available for extrinsics.150	type Call = Call;151	/// The lookup mechanism to get account ID from whatever is passed in dispatchers.152	type Lookup = IdentityLookup<AccountId>;153	/// The index type for storing how many extrinsics an account has signed.154	type Index = Index;155	/// The index type for blocks.156	type BlockNumber = BlockNumber;157	/// The type for hashing blocks and tries.158	type Hash = Hash;159	/// The hashing algorithm used.160	type Hashing = BlakeTwo256;161	/// The header type.162	type Header = generic::Header<BlockNumber, BlakeTwo256>;163	/// The ubiquitous event type.164	type Event = Event;165	/// The ubiquitous origin type.166	type Origin = Origin;167	/// Maximum number of block number to block hash mappings to keep (oldest pruned first).168	type BlockHashCount = BlockHashCount;169	/// Maximum weight of each block.170	type MaximumBlockWeight = MaximumBlockWeight;171	/// The weight of database operations that the runtime can invoke.172	type DbWeight = RocksDbWeight;173	/// The weight of the overhead invoked on the block import process, independent of the174	/// extrinsics included in that block.175	type BlockExecutionWeight = BlockExecutionWeight;176	/// The base weight of any extrinsic processed by the runtime, independent of the177	/// logic of that extrinsic. (Signature verification, nonce increment, fee, etc...)178	type ExtrinsicBaseWeight = ExtrinsicBaseWeight;179	/// The maximum weight that a single extrinsic of `Normal` dispatch class can have,180	/// idependent of the logic of that extrinsics. (Roughly max block weight - average on181	/// initialize cost).182	type MaximumExtrinsicWeight = MaximumExtrinsicWeight;183	/// Maximum size of all encoded transactions (in bytes) that are allowed in one block.184	type MaximumBlockLength = MaximumBlockLength;185	/// Portion of the block weight that is available to all normal transactions.186	type AvailableBlockRatio = AvailableBlockRatio;187	/// Version of the runtime.188	type Version = Version;189	/// Converts a module to the index of the module in `construct_runtime!`.190	///191	/// This type is being generated by `construct_runtime!`.192	type ModuleToIndex = ModuleToIndex;193	/// What to do if a new account is created.194	type OnNewAccount = ();195	/// What to do if an account is fully reaped from the system.196	type OnKilledAccount = ();197	/// The data to be stored in an account.198	type AccountData = balances::AccountData<Balance>;199}200201impl aura::Trait for Runtime {202	type AuthorityId = AuraId;203}204205impl grandpa::Trait for Runtime {206	type Event = Event;207	type Call = Call;208209	type KeyOwnerProofSystem = ();210211	type KeyOwnerProof =212		<Self::KeyOwnerProofSystem as KeyOwnerProofSystem<(KeyTypeId, GrandpaId)>>::Proof;213214	type KeyOwnerIdentification = <Self::KeyOwnerProofSystem as KeyOwnerProofSystem<(215		KeyTypeId,216		GrandpaId,217	)>>::IdentificationTuple;218219	type HandleEquivocation = ();220}221222parameter_types! {223	pub const MinimumPeriod: u64 = SLOT_DURATION / 2;224}225226impl timestamp::Trait for Runtime {227	/// A timestamp: milliseconds since the unix epoch.228	type Moment = u64;229	type OnTimestampSet = Aura;230	type MinimumPeriod = MinimumPeriod;231}232233234parameter_types! {235    pub const TombstoneDeposit: Balance = 16 * MILLICENTS;236    pub const RentByteFee: Balance = 4 * MILLICENTS;237    pub const RentDepositOffset: Balance = 1000 * MILLICENTS;238    pub const SurchargeReward: Balance = 150 * MILLICENTS;239}240241impl contracts::Trait for Runtime {242    type Time = Timestamp;243    type Randomness = RandomnessCollectiveFlip;244    type Currency = Balances;245    type Event = Event;246    type DetermineContractAddress = contracts::SimpleAddressDeterminer<Runtime>;247    type TrieIdGenerator = contracts::TrieIdFromParentCounter<Runtime>;248    type RentPayment = ();249    type SignedClaimHandicap = contracts::DefaultSignedClaimHandicap;250    type TombstoneDeposit = TombstoneDeposit;251    type StorageSizeOffset = contracts::DefaultStorageSizeOffset;252    type RentByteFee = RentByteFee;253    type RentDepositOffset = RentDepositOffset;254    type SurchargeReward = SurchargeReward;255    type MaxDepth = contracts::DefaultMaxDepth;256    type MaxValueSize = contracts::DefaultMaxValueSize;257    type WeightPrice = transaction_payment::Module<Self>;258}259260parameter_types! {261	pub const ExistentialDeposit: u128 = 500;262}263264impl balances::Trait for Runtime {265	/// The type for recording an account's balance.266	type Balance = Balance;267	/// The ubiquitous event type.268	type Event = Event;269	type DustRemoval = ();270	type ExistentialDeposit = ExistentialDeposit;271	type AccountStore = System;272}273274parameter_types! {275	pub const TransactionByteFee: Balance = 1;276}277278impl transaction_payment::Trait for Runtime {279	type Currency = balances::Module<Runtime>;280	type OnTransactionPayment = ();281	type TransactionByteFee = TransactionByteFee;282	type WeightToFee = IdentityFee<Balance>;283	type FeeMultiplierUpdate = ();284}285286impl sudo::Trait for Runtime {287	type Event = Event;288	type Call = Call;289}290291/// Used for the module template in `./template.rs`292impl nft::Trait for Runtime {293    type Event = Event;294}295296construct_runtime!(297	pub enum Runtime where298		Block = Block,299		NodeBlock = opaque::Block,300		UncheckedExtrinsic = UncheckedExtrinsic301	{302		System: system::{Module, Call, Config, Storage, Event<T>},303		RandomnessCollectiveFlip: randomness_collective_flip::{Module, Call, Storage},304		Contracts: contracts::{Module, Call, Config, Storage, Event<T>},305		Timestamp: timestamp::{Module, Call, Storage, Inherent},306		Aura: aura::{Module, Config<T>, Inherent(Timestamp)},307		Grandpa: grandpa::{Module, Call, Storage, Config, Event},308		Balances: balances::{Module, Call, Storage, Config<T>, Event<T>},309		TransactionPayment: transaction_payment::{Module, Storage},310		Sudo: sudo::{Module, Call, Config<T>, Storage, Event<T>},311		// Staking: staking::{Module, Call, Config<T>, Storage, Event<T>},312		// Used for the module template in `./template.rs`313        Nft: nft::{Module, Call, Storage, Event<T>},314	}315);316317/// The address format for describing accounts.318pub type Address = AccountId;319/// Block header type as expected by this runtime.320pub type Header = generic::Header<BlockNumber, BlakeTwo256>;321/// Block type as expected by this runtime.322pub type Block = generic::Block<Header, UncheckedExtrinsic>;323/// A Block signed with a Justification324pub type SignedBlock = generic::SignedBlock<Block>;325/// BlockId type as expected by this runtime.326pub type BlockId = generic::BlockId<Block>;327/// The SignedExtension to the basic transaction logic.328pub type SignedExtra = (329	system::CheckSpecVersion<Runtime>,330	system::CheckTxVersion<Runtime>,331	system::CheckGenesis<Runtime>,332	system::CheckEra<Runtime>,333	system::CheckNonce<Runtime>,334	system::CheckWeight<Runtime>,335	transaction_payment::ChargeTransactionPayment<Runtime>336);337/// Unchecked extrinsic type as expected by this runtime.338pub type UncheckedExtrinsic = generic::UncheckedExtrinsic<Address, Call, Signature, SignedExtra>;339/// Extrinsic type that has already been checked.340pub type CheckedExtrinsic = generic::CheckedExtrinsic<AccountId, Call, SignedExtra>;341/// Executive: handles dispatch to the various modules.342pub type Executive = frame_executive::Executive<Runtime, Block, system::ChainContext<Runtime>, Runtime, AllModules>;343344impl_runtime_apis! {345	impl sp_api::Core<Block> for Runtime {346		fn version() -> RuntimeVersion {347			VERSION348		}349350		fn execute_block(block: Block) {351			Executive::execute_block(block)352		}353354		fn initialize_block(header: &<Block as BlockT>::Header) {355			Executive::initialize_block(header)356		}357	}358359	impl sp_api::Metadata<Block> for Runtime {360		fn metadata() -> OpaqueMetadata {361			Runtime::metadata().into()362		}363	}364365	impl sp_block_builder::BlockBuilder<Block> for Runtime {366		fn apply_extrinsic(extrinsic: <Block as BlockT>::Extrinsic) -> ApplyExtrinsicResult {367			Executive::apply_extrinsic(extrinsic)368		}369370		fn finalize_block() -> <Block as BlockT>::Header {371			Executive::finalize_block()372		}373374		fn inherent_extrinsics(data: sp_inherents::InherentData) -> Vec<<Block as BlockT>::Extrinsic> {375			data.create_extrinsics()376		}377378		fn check_inherents(379			block: Block,380			data: sp_inherents::InherentData,381		) -> sp_inherents::CheckInherentsResult {382			data.check_extrinsics(&block)383		}384385		fn random_seed() -> <Block as BlockT>::Hash {386			RandomnessCollectiveFlip::random_seed()387		}388	}389390	impl sp_transaction_pool::runtime_api::TaggedTransactionQueue<Block> for Runtime {391		fn validate_transaction(392			source: TransactionSource,393			tx: <Block as BlockT>::Extrinsic,394		) -> TransactionValidity {395			Executive::validate_transaction(source, tx)396		}397	}398399	impl sp_offchain::OffchainWorkerApi<Block> for Runtime {400		fn offchain_worker(header: &<Block as BlockT>::Header) {401			Executive::offchain_worker(header)402		}403	}404405	impl sp_consensus_aura::AuraApi<Block, AuraId> for Runtime {406		fn slot_duration() -> u64 {407			Aura::slot_duration()408		}409410		fn authorities() -> Vec<AuraId> {411			Aura::authorities()412		}413	}414415	impl sp_session::SessionKeys<Block> for Runtime {416		fn generate_session_keys(seed: Option<Vec<u8>>) -> Vec<u8> {417			opaque::SessionKeys::generate(seed)418		}419420		fn decode_session_keys(421			encoded: Vec<u8>,422		) -> Option<Vec<(Vec<u8>, KeyTypeId)>> {423			opaque::SessionKeys::decode_into_raw_public_keys(&encoded)424		}425	}426427	impl fg_primitives::GrandpaApi<Block> for Runtime {428		fn grandpa_authorities() -> GrandpaAuthorityList {429			Grandpa::grandpa_authorities()430		}431432		fn submit_report_equivocation_extrinsic(433			_equivocation_proof: fg_primitives::EquivocationProof<434				<Block as BlockT>::Hash,435				NumberFor<Block>,436			>,437			_key_owner_proof: fg_primitives::OpaqueKeyOwnershipProof,438		) -> Option<()> {439			None440		}441442		fn generate_key_ownership_proof(443			_set_id: fg_primitives::SetId,444			_authority_id: GrandpaId,445		) -> Option<fg_primitives::OpaqueKeyOwnershipProof> {446			// NOTE: this is the only implementation possible since we've447			// defined our key owner proof type as a bottom type (i.e. a type448			// with no values).449			None450		}451	}452453	impl contracts_rpc_runtime_api::ContractsApi<Block, AccountId, Balance, BlockNumber>454	for Runtime455	{456		fn call(457			origin: AccountId,458			dest: AccountId,459			value: Balance,460			gas_limit: u64,461			input_data: Vec<u8>,462		) -> ContractExecResult {463			let exec_result =464				Contracts::bare_call(origin, dest.into(), value, gas_limit, input_data);465			match exec_result {466				Ok(v) => ContractExecResult::Success {467					status: v.status,468					data: v.data,469				},470				Err(_) => ContractExecResult::Error,471			}472		}473474		fn get_storage(475			address: AccountId,476			key: [u8; 32],477		) -> contracts_primitives::GetStorageResult {478			Contracts::get_storage(address, key)479		}480481		fn rent_projection(482			address: AccountId,483		) -> contracts_primitives::RentProjectionResult<BlockNumber> {484			Contracts::rent_projection(address)485		}486	}487488}