difftreelog
Merge pull request #29 from usetech-llc/feature/nftpar-149
in: master
Feature/nftpar 149
4 files changed
node/src/chain_spec.rsdiffbeforeafterboth--- a/node/src/chain_spec.rs
+++ b/node/src/chain_spec.rs
@@ -147,23 +147,12 @@
pallet_aura: Some(AuraConfig {
authorities: initial_authorities.iter().map(|x| (x.0.clone())).collect(),
}),
- pallet_collective_Instance1: Some(CouncilConfig {
- members: vec![],
- phantom: Default::default(),
- }),
- pallet_collective_Instance2: Some(TechnicalCommitteeConfig {
- members: vec![],
- phantom: Default::default(),
- }),
- pallet_democracy: Some(DemocracyConfig::default()),
pallet_grandpa: Some(GrandpaConfig {
authorities: initial_authorities
.iter()
.map(|x| (x.1.clone(), 1))
.collect(),
}),
- pallet_elections_phragmen: Some(Default::default()),
- pallet_membership: Some(Default::default()),
pallet_treasury: Some(Default::default()),
pallet_sudo: Some(SudoConfig { key: root_key }),
pallet_nft: Some(NftConfig {
pallets/nft/src/lib.rsdiffbeforeafterboth--- a/pallets/nft/src/lib.rs
+++ b/pallets/nft/src/lib.rs
@@ -1328,7 +1328,12 @@
contract_address: T::AccountId,
enable: bool
) -> DispatchResult {
+
let sender = ensure_signed(origin)?;
+
+ #[cfg(feature = "runtime-benchmarks")]
+ <ContractOwner<T>>::insert(contract_address.clone(), sender.clone());
+
let mut is_owner = false;
if <ContractOwner<T>>::contains_key(contract_address.clone()) {
let owner = <ContractOwner<T>>::get(&contract_address);
@@ -1375,6 +1380,17 @@
Ok(())
}
+ // #[cfg(feature = "runtime-benchmarks")]
+ // #[weight = 0]
+ // pub fn add_contract_sponsoring_debug(
+ // origin,
+ // contract_address: T::AccountId,
+ // owner: T::AccountId) -> DispatchResult {
+ // let sender = ensure_signed(origin)?;
+ // <ContractOwner<T>>::insert(contract_address.clone(), owner);
+ // Ok(())
+ // }
+
}
}
runtime/Cargo.tomldiffbeforeafterboth--- a/runtime/Cargo.toml
+++ b/runtime/Cargo.toml
@@ -57,12 +57,7 @@
sp-transaction-pool = { default-features = false, version = '2.0.0' , git = 'https://github.com/usetech-llc/substrate.git', branch = 'v2.0.0_release' }
sp-version = { default-features = false, version = '2.0.0' , git = 'https://github.com/usetech-llc/substrate.git', branch = 'v2.0.0_release' }
-pallet-membership = { version = "2.0.0", default-features = false, git = 'https://github.com/usetech-llc/substrate.git', branch = 'v2.0.0_release' }
-pallet-collective = { default-features = false, version = '2.0.0' , git = 'https://github.com/usetech-llc/substrate.git', branch = 'v2.0.0_release' }
-pallet-democracy = { default-features = false, version = '2.0.0' , git = 'https://github.com/usetech-llc/substrate.git', branch = 'v2.0.0_release' }
-pallet-elections-phragmen = { version = "2.0.0", default-features = false, git = 'https://github.com/usetech-llc/substrate.git', branch = 'v2.0.0_release' }
pallet-treasury = { version = "2.0.0", default-features = false, git = 'https://github.com/usetech-llc/substrate.git', branch = 'v2.0.0_release' }
-pallet-scheduler = { version = "2.0.0", default-features = false, git = 'https://github.com/usetech-llc/substrate.git', branch = 'v2.0.0_release' }
[features]
default = ['std']
@@ -73,7 +68,6 @@
'frame-system-benchmarking',
'frame-system/runtime-benchmarks',
'pallet-balances/runtime-benchmarks',
- 'pallet-collective/runtime-benchmarks',
'pallet-timestamp/runtime-benchmarks',
'pallet-nft/runtime-benchmarks',
'sp-runtime/runtime-benchmarks',
@@ -109,10 +103,5 @@
'sp-transaction-pool/std',
'sp-version/std',
- 'pallet-collective/std',
- 'pallet-democracy/std',
- 'pallet-elections-phragmen/std',
- 'pallet-membership/std',
'pallet-treasury/std',
- 'pallet-scheduler/std',
]
runtime/src/lib.rsdiffbeforeafterboth1//! 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 pallet_contracts_rpc_runtime_api::ContractExecResult;12use pallet_grandpa::fg_primitives;13use pallet_grandpa::{AuthorityId as GrandpaId, AuthorityList as GrandpaAuthorityList};14use sp_api::impl_runtime_apis;15use sp_consensus_aura::sr25519::AuthorityId as AuraId;16use sp_core::{17 crypto::KeyTypeId, 18 OpaqueMetadata, 19 u32_trait::{_1, _2, _3, _4},20};21use sp_runtime::{22 create_runtime_str, generic, impl_opaque_keys,23 traits::{24 Convert, BlakeTwo256, Block as BlockT, IdentifyAccount, 25 IdentityLookup, NumberFor, Saturating, Verify,26 },27 transaction_validity::{TransactionSource, TransactionValidity},28 ApplyExtrinsicResult, MultiSignature,29};30use sp_std::prelude::*;31#[cfg(feature = "std")]32use sp_version::NativeVersion;33use sp_version::RuntimeVersion;3435// A few exports that help ease life for downstream crates.36pub use pallet_balances::Call as BalancesCall;37pub use pallet_contracts::Schedule as ContractsSchedule;38pub use frame_support::{39 construct_runtime,40 dispatch::DispatchResult,41 parameter_types,42 traits::{43 Currency, ExistenceRequirement, Get, KeyOwnerProofSystem, OnUnbalanced, Randomness,44 WithdrawReason, LockIdentifier,45 },46 weights::{47 constants::{BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight, WEIGHT_PER_SECOND},48 DispatchInfo, GetDispatchInfo, IdentityFee, Pays, PostDispatchInfo, Weight,49 WeightToFeePolynomial,50 },51 StorageValue,52};53#[cfg(any(feature = "std", test))]54pub use sp_runtime::BuildStorage;55use sp_runtime:: { Perbill, Permill, Percent, ModuleId };56use frame_system::{self as system, EnsureRoot, EnsureOneOf };5758pub use pallet_timestamp::Call as TimestampCall;5960/// Struct that handles the conversion of Balance -> `u64`. This is used for61/// staking's election calculation.62pub struct CurrencyToVoteHandler;6364impl CurrencyToVoteHandler {65 fn factor() -> Balance {66 (Balances::total_issuance() / u64::max_value() as Balance).max(1)67 }68}6970impl Convert<Balance, u64> for CurrencyToVoteHandler {71 fn convert(x: Balance) -> u64 {72 (x / Self::factor()) as u6473 }74}7576impl Convert<u128, Balance> for CurrencyToVoteHandler {77 fn convert(x: u128) -> Balance {78 x * Self::factor()79 }80}8182/// Re-export a nft pallet83/// TODO: Check this re-export. Is this safe and good style?84extern crate pallet_nft;85pub use pallet_nft::*;8687/// An index to a block.88pub type BlockNumber = u32;8990/// Alias to 512-bit hash when used in the context of a transaction signature on the chain.91pub type Signature = MultiSignature;9293/// Some way of identifying an account on the chain. We intentionally make it equivalent94/// to the public key of our transaction signing scheme.95pub type AccountId = <<Signature as Verify>::Signer as IdentifyAccount>::AccountId;9697/// The type for looking up accounts. We don't expect more than 4 billion of them, but you98/// never know...99pub type AccountIndex = u32;100101/// Balance of an account.102pub type Balance = u128;103104/// Index of a transaction in the chain.105pub type Index = u32;106107/// A hash of some data used by the chain.108pub type Hash = sp_core::H256;109110/// Digest item type.111pub type DigestItem = generic::DigestItem<Hash>;112113mod nft_weights;114115/// Opaque types. These are used by the CLI to instantiate machinery that don't need to know116/// the specifics of the runtime. They can then be made to be agnostic over specific formats117/// of data like extrinsics, allowing for them to continue syncing the network through upgrades118/// to even the core data structures.119pub mod opaque {120 use super::*;121122 pub use sp_runtime::OpaqueExtrinsic as UncheckedExtrinsic;123124 /// Opaque block header type.125 pub type Header = generic::Header<BlockNumber, BlakeTwo256>;126 /// Opaque block type.127 pub type Block = generic::Block<Header, UncheckedExtrinsic>;128 /// Opaque block identifier type.129 pub type BlockId = generic::BlockId<Block>;130131 impl_opaque_keys! {132 pub struct SessionKeys {133 pub aura: Aura,134 pub grandpa: Grandpa,135 }136 }137}138139/// This runtime version.140pub const VERSION: RuntimeVersion = RuntimeVersion {141 spec_name: create_runtime_str!("nft"),142 impl_name: create_runtime_str!("nft"),143 authoring_version: 1,144 spec_version: 2,145 impl_version: 1,146 apis: RUNTIME_API_VERSIONS,147 transaction_version: 1,148};149150pub const MILLISECS_PER_BLOCK: u64 = 6000;151152pub const SLOT_DURATION: u64 = MILLISECS_PER_BLOCK;153154// These time units are defined in number of blocks.155pub const MINUTES: BlockNumber = 60_000 / (MILLISECS_PER_BLOCK as BlockNumber);156pub const HOURS: BlockNumber = MINUTES * 60;157pub const DAYS: BlockNumber = HOURS * 24;158159/// The version information used to identify this runtime when compiled natively.160#[cfg(feature = "std")]161pub fn native_version() -> NativeVersion {162 NativeVersion {163 runtime_version: VERSION,164 can_author_with: Default::default(),165 }166}167168parameter_types! {169 pub const BlockHashCount: BlockNumber = 2400;170 /// We allow for 2 seconds of compute with a 6 second average block time.171 pub const MaximumBlockWeight: Weight = 2 * WEIGHT_PER_SECOND;172 pub const AvailableBlockRatio: Perbill = Perbill::from_percent(75);173 /// Assume 10% of weight for average on_initialize calls.174 pub MaximumExtrinsicWeight: Weight = AvailableBlockRatio::get()175 .saturating_sub(Perbill::from_percent(10)) * MaximumBlockWeight::get();176 pub const MaximumBlockLength: u32 = 5 * 1024 * 1024;177 pub const Version: RuntimeVersion = VERSION;178}179180impl system::Trait for Runtime {181 /// The basic call filter to use in dispatchable.182 type BaseCallFilter = ();183 /// The identifier used to distinguish between accounts.184 type AccountId = AccountId;185 /// The aggregated dispatch type that is available for extrinsics.186 type Call = Call;187 /// The lookup mechanism to get account ID from whatever is passed in dispatchers.188 type Lookup = IdentityLookup<AccountId>;189 /// The index type for storing how many extrinsics an account has signed.190 type Index = Index;191 /// The index type for blocks.192 type BlockNumber = BlockNumber;193 /// The type for hashing blocks and tries.194 type Hash = Hash;195 /// The hashing algorithm used.196 type Hashing = BlakeTwo256;197 /// The header type.198 type Header = generic::Header<BlockNumber, BlakeTwo256>;199 /// The ubiquitous event type.200 type Event = Event;201 /// The ubiquitous origin type.202 type Origin = Origin;203 /// Maximum number of block number to block hash mappings to keep (oldest pruned first).204 type BlockHashCount = BlockHashCount;205 /// Maximum weight of each block.206 type MaximumBlockWeight = MaximumBlockWeight;207 /// The weight of database operations that the runtime can invoke.208 type DbWeight = RocksDbWeight;209 /// The weight of the overhead invoked on the block import process, independent of the210 /// extrinsics included in that block.211 type BlockExecutionWeight = BlockExecutionWeight;212 /// The base weight of any extrinsic processed by the runtime, independent of the213 /// logic of that extrinsic. (Signature verification, nonce increment, fee, etc...)214 type ExtrinsicBaseWeight = ExtrinsicBaseWeight;215 /// The maximum weight that a single extrinsic of `Normal` dispatch class can have,216 /// idependent of the logic of that extrinsics. (Roughly max block weight - average on217 /// initialize cost).218 type MaximumExtrinsicWeight = MaximumExtrinsicWeight;219 /// Maximum size of all encoded transactions (in bytes) that are allowed in one block.220 type MaximumBlockLength = MaximumBlockLength;221 /// Portion of the block weight that is available to all normal transactions.222 type AvailableBlockRatio = AvailableBlockRatio;223 /// Version of the runtime.224 type Version = Version;225 /// This type is being generated by `construct_runtime!`.226 type PalletInfo = PalletInfo;227 /// What to do if a new account is created.228 type OnNewAccount = ();229 /// What to do if an account is fully reaped from the system.230 type OnKilledAccount = ();231 /// The data to be stored in an account.232 type AccountData = pallet_balances::AccountData<Balance>;233 /// Weight information for the extrinsics of this pallet.234 type SystemWeightInfo = ();235}236237impl pallet_aura::Trait for Runtime {238 type AuthorityId = AuraId;239}240241impl pallet_grandpa::Trait for Runtime {242 type Event = Event;243 type Call = Call;244245 type KeyOwnerProofSystem = ();246247 type KeyOwnerProof =248 <Self::KeyOwnerProofSystem as KeyOwnerProofSystem<(KeyTypeId, GrandpaId)>>::Proof;249250 type KeyOwnerIdentification = <Self::KeyOwnerProofSystem as KeyOwnerProofSystem<(251 KeyTypeId,252 GrandpaId,253 )>>::IdentificationTuple;254255 type HandleEquivocation = ();256257 type WeightInfo = ();258}259260parameter_types! {261 pub const MinimumPeriod: u64 = SLOT_DURATION / 2;262}263264impl pallet_timestamp::Trait for Runtime {265 /// A timestamp: milliseconds since the unix epoch.266 type Moment = u64;267 type OnTimestampSet = Aura;268 type MinimumPeriod = MinimumPeriod;269 type WeightInfo = ();270}271272parameter_types! {273 // pub const ExistentialDeposit: u128 = 500;274 pub const ExistentialDeposit: u128 = 0;275 pub const MaxLocks: u32 = 50;276}277278impl pallet_balances::Trait for Runtime {279 type MaxLocks = MaxLocks;280 /// The type for recording an account's balance.281 type Balance = Balance;282 /// The ubiquitous event type.283 type Event = Event;284 type DustRemoval = ();285 type ExistentialDeposit = ExistentialDeposit;286 type AccountStore = System;287 type WeightInfo = ();288}289290pub const MILLICENTS: Balance = 1_000_000_000;291pub const CENTS: Balance = 1_000 * MILLICENTS;292pub const DOLLARS: Balance = 100 * CENTS;293294parameter_types! {295 pub const TombstoneDeposit: Balance = 16 * MILLICENTS;296 pub const RentByteFee: Balance = 4 * MILLICENTS;297 pub const RentDepositOffset: Balance = 1000 * MILLICENTS;298 pub const SurchargeReward: Balance = 150 * MILLICENTS;299}300301impl pallet_contracts::Trait for Runtime {302 type Time = Timestamp;303 type Randomness = RandomnessCollectiveFlip;304 type Currency = Balances;305 type Event = Event;306 type DetermineContractAddress = pallet_contracts::SimpleAddressDeterminer<Runtime>;307 type TrieIdGenerator = pallet_contracts::TrieIdFromParentCounter<Runtime>;308 type RentPayment = ();309 type SignedClaimHandicap = pallet_contracts::DefaultSignedClaimHandicap;310 type TombstoneDeposit = TombstoneDeposit;311 type StorageSizeOffset = pallet_contracts::DefaultStorageSizeOffset;312 type RentByteFee = RentByteFee;313 type RentDepositOffset = RentDepositOffset;314 type SurchargeReward = SurchargeReward;315 type MaxDepth = pallet_contracts::DefaultMaxDepth;316 type MaxValueSize = pallet_contracts::DefaultMaxValueSize;317 type WeightPrice = pallet_transaction_payment::Module<Self>;318}319320parameter_types! {321 pub const TransactionByteFee: Balance = 10 * MILLICENTS;322}323324impl pallet_transaction_payment::Trait for Runtime {325 type Currency = pallet_balances::Module<Runtime>;326 type OnTransactionPayment = ();327 type TransactionByteFee = TransactionByteFee;328 type WeightToFee = IdentityFee<Balance>;329 type FeeMultiplierUpdate = ();330}331332parameter_types! {333 pub MaximumSchedulerWeight: Weight = Perbill::from_percent(80) * MaximumBlockWeight::get();334 pub const MaxScheduledPerBlock: u32 = 50;335}336337impl pallet_scheduler::Trait for Runtime {338 type Event = Event;339 type Origin = Origin;340 type PalletsOrigin = OriginCaller;341 type Call = Call;342 type MaximumWeight = MaximumSchedulerWeight;343 type ScheduleOrigin = EnsureRoot<AccountId>;344 type MaxScheduledPerBlock = MaxScheduledPerBlock;345 type WeightInfo = ();346}347348parameter_types! {349 pub const ProposalBond: Permill = Permill::from_percent(5);350 pub const ProposalBondMinimum: Balance = 1 * DOLLARS;351 pub const SpendPeriod: BlockNumber = 1 * DAYS;352 pub const Burn: Permill = Permill::from_percent(50);353 pub const TipCountdown: BlockNumber = 1 * DAYS;354 pub const TipFindersFee: Percent = Percent::from_percent(20);355 pub const TipReportDepositBase: Balance = 1 * DOLLARS;356 pub const DataDepositPerByte: Balance = 1 * CENTS;357 pub const BountyDepositBase: Balance = 1 * DOLLARS;358 pub const BountyDepositPayoutDelay: BlockNumber = 1 * DAYS;359 pub const TreasuryModuleId: ModuleId = ModuleId(*b"py/trsry");360 pub const BountyUpdatePeriod: BlockNumber = 14 * DAYS;361 pub const MaximumReasonLength: u32 = 16384;362 pub const BountyCuratorDeposit: Permill = Permill::from_percent(50);363 pub const BountyValueMinimum: Balance = 5 * DOLLARS;364}365366impl pallet_treasury::Trait for Runtime {367 type ModuleId = TreasuryModuleId;368 type Currency = Balances;369 type ApproveOrigin = 370 EnsureOneOf<371 AccountId,372 EnsureRoot<AccountId>,373 pallet_collective::EnsureMembers<_4, AccountId, CouncilCollective>374 >;375 type RejectOrigin = 376 EnsureOneOf<377 AccountId,378 EnsureRoot<AccountId>,379 pallet_collective::EnsureMembers<_2, AccountId, CouncilCollective>380 >;381 type Tippers = Elections;382 type TipCountdown = TipCountdown;383 type TipFindersFee = TipFindersFee;384 type TipReportDepositBase = TipReportDepositBase;385 type DataDepositPerByte = DataDepositPerByte;386 type Event = Event;387 type OnSlash = ();388 type ProposalBond = ProposalBond;389 type ProposalBondMinimum = ProposalBondMinimum;390 type SpendPeriod = SpendPeriod;391 type Burn = Burn;392 type BountyDepositBase = BountyDepositBase;393 type BountyDepositPayoutDelay = BountyDepositPayoutDelay;394 type BountyUpdatePeriod = BountyUpdatePeriod;395 type BountyCuratorDeposit = BountyCuratorDeposit;396 type BountyValueMinimum = BountyValueMinimum;397 type MaximumReasonLength = MaximumReasonLength;398 type BurnDestination = ();399 type WeightInfo = ();400}401402parameter_types! {403 pub const TechnicalMotionDuration: BlockNumber = 5 * DAYS;404 pub const TechnicalMaxProposals: u32 = 100;405 pub const TechnicalMaxMembers: u32 = 100;406}407408type TechnicalCollective = pallet_collective::Instance2;409impl pallet_collective::Trait<TechnicalCollective> for Runtime {410 type Origin = Origin;411 type Proposal = Call;412 type Event = Event;413 type MotionDuration = TechnicalMotionDuration;414 type MaxProposals = TechnicalMaxProposals;415 type MaxMembers = TechnicalMaxMembers;416 type DefaultVote = pallet_collective::PrimeDefaultVote;417 type WeightInfo = ();418}419420parameter_types! {421 pub const LaunchPeriod: BlockNumber = 28 * 24 * 60 * MINUTES;422 pub const VotingPeriod: BlockNumber = 28 * 24 * 60 * MINUTES;423 pub const FastTrackVotingPeriod: BlockNumber = 3 * 24 * 60 * MINUTES;424 pub const InstantAllowed: bool = true;425 pub const MinimumDeposit: Balance = 100 * DOLLARS;426 pub const EnactmentPeriod: BlockNumber = 30 * 24 * 60 * MINUTES;427 pub const CooloffPeriod: BlockNumber = 28 * 24 * 60 * MINUTES;428 // One cent: $10,000 / MB429 pub const PreimageByteDeposit: Balance = 1 * CENTS;430 pub const MaxVotes: u32 = 100;431}432433impl pallet_democracy::Trait for Runtime {434 type Proposal = Call;435 type Event = Event;436 type Currency = Balances;437 type EnactmentPeriod = EnactmentPeriod;438 type LaunchPeriod = LaunchPeriod;439 type VotingPeriod = VotingPeriod;440 type MinimumDeposit = MinimumDeposit;441 /// A straight majority of the council can decide what their next motion is.442 type ExternalOrigin = pallet_collective::EnsureProportionAtLeast<_1, _2, AccountId, CouncilCollective>;443 /// A super-majority can have the next scheduled referendum be a straight majority-carries vote.444 type ExternalMajorityOrigin = pallet_collective::EnsureProportionAtLeast<_3, _4, AccountId, CouncilCollective>;445 /// A unanimous council can have the next scheduled referendum be a straight default-carries446 /// (NTB) vote.447 type ExternalDefaultOrigin = pallet_collective::EnsureProportionAtLeast<_1, _1, AccountId, CouncilCollective>;448 /// Two thirds of the technical committee can have an ExternalMajority/ExternalDefault vote449 /// be tabled immediately and with a shorter voting/enactment period.450 type FastTrackOrigin = pallet_collective::EnsureProportionAtLeast<_2, _3, AccountId, TechnicalCollective>;451 type InstantOrigin = pallet_collective::EnsureProportionAtLeast<_1, _1, AccountId, TechnicalCollective>;452 type InstantAllowed = InstantAllowed;453 type FastTrackVotingPeriod = FastTrackVotingPeriod;454 // To cancel a proposal which has been passed, 2/3 of the council must agree to it.455 type CancellationOrigin = EnsureOneOf<456 AccountId,457 EnsureRoot<AccountId>,458 pallet_collective::EnsureProportionAtLeast<_2, _3, AccountId, CouncilCollective>,459 >;460 // Any single technical committee member may veto a coming council proposal, however they can461 // only do it once and it lasts only for the cooloff period.462 type VetoOrigin = pallet_collective::EnsureMember<AccountId, TechnicalCollective>;463 type CooloffPeriod = CooloffPeriod;464 type PreimageByteDeposit = PreimageByteDeposit;465 type OperationalPreimageOrigin = pallet_collective::EnsureMember<AccountId, CouncilCollective>;466 type Slash = Treasury;467 type Scheduler = Scheduler;468 type PalletsOrigin = OriginCaller;469 type MaxVotes = MaxVotes;470 type WeightInfo = (); //weights::pallet_democracy::WeightInfo;471}472473parameter_types! {474 pub const CouncilMotionDuration: BlockNumber = 5 * DAYS;475 pub const CouncilMaxProposals: u32 = 100;476 pub const CouncilMaxMembers: u32 = 100;477}478479type CouncilCollective = pallet_collective::Instance1;480impl pallet_collective::Trait<CouncilCollective> for Runtime {481 type Origin = Origin;482 type Proposal = Call;483 type Event = Event;484 type MotionDuration = CouncilMotionDuration;485 type MaxProposals = CouncilMaxProposals;486 type MaxMembers = CouncilMaxMembers;487 type DefaultVote = pallet_collective::PrimeDefaultVote;488 type WeightInfo = (); //weights::pallet_collective::WeightInfo;489}490491parameter_types! {492 pub const CandidacyBond: Balance = 10 * DOLLARS;493 pub const VotingBond: Balance = 1 * DOLLARS;494 pub const TermDuration: BlockNumber = 7 * DAYS;495 pub const DesiredMembers: u32 = 13;496 pub const DesiredRunnersUp: u32 = 7;497 pub const ElectionsPhragmenModuleId: LockIdentifier = *b"phrelect";498}499500// Make sure that there are no more than `MaxMembers` members elected via elections-phragmen.501// const_assert!(DesiredMembers::get() <= CouncilMaxMembers::get());502503impl pallet_elections_phragmen::Trait for Runtime {504 type Event = Event;505 type ModuleId = ElectionsPhragmenModuleId;506 type Currency = Balances;507 type ChangeMembers = Council;508 // NOTE: this implies that council's genesis members cannot be set directly and must come from509 // this module.510 type InitializeMembers = Council;511 type CurrencyToVote = CurrencyToVoteHandler;512 type CandidacyBond = CandidacyBond;513 type VotingBond = VotingBond;514 type LoserCandidate = ();515 type BadReport = ();516 type KickedMember = ();517 type DesiredMembers = DesiredMembers;518 type DesiredRunnersUp = DesiredRunnersUp;519 type TermDuration = TermDuration;520 type WeightInfo = (); //weights::pallet_elections_phragmen::WeightInfo;521}522523type EnsureRootOrHalfCouncil = EnsureOneOf<524 AccountId,525 EnsureRoot<AccountId>,526 pallet_collective::EnsureProportionMoreThan<_1, _2, AccountId, CouncilCollective>527>;528impl pallet_membership::Trait for Runtime {529 type Event = Event;530 type AddOrigin = EnsureRootOrHalfCouncil;531 type RemoveOrigin = EnsureRootOrHalfCouncil;532 type SwapOrigin = EnsureRootOrHalfCouncil;533 type ResetOrigin = EnsureRootOrHalfCouncil;534 type PrimeOrigin = EnsureRootOrHalfCouncil;535 type MembershipInitialized = TechnicalCommittee;536 type MembershipChanged = TechnicalCommittee;537}538539impl pallet_sudo::Trait for Runtime {540 type Event = Event;541 type Call = Call;542}543544/// Used for the module nft in `./nft.rs`545impl pallet_nft::Trait for Runtime {546 type Event = Event;547 type WeightInfo = nft_weights::WeightInfo;548}549550construct_runtime!(551 pub enum Runtime where552 Block = Block,553 NodeBlock = opaque::Block,554 UncheckedExtrinsic = UncheckedExtrinsic555 {556 System: system::{Module, Call, Config, Storage, Event<T>},557 RandomnessCollectiveFlip: pallet_randomness_collective_flip::{Module, Call, Storage},558 Contracts: pallet_contracts::{Module, Call, Config, Storage, Event<T>},559 Timestamp: pallet_timestamp::{Module, Call, Storage, Inherent},560 Aura: pallet_aura::{Module, Config<T>, Inherent},561 Grandpa: pallet_grandpa::{Module, Call, Storage, Config, Event},562 Balances: pallet_balances::{Module, Call, Storage, Config<T>, Event<T>},563 TransactionPayment: pallet_transaction_payment::{Module, Storage},564 Sudo: pallet_sudo::{Module, Call, Config<T>, Storage, Event<T>},565 Nft: pallet_nft::{Module, Call, Config<T>, Storage, Event<T>},566567 Democracy: pallet_democracy::{Module, Call, Storage, Config, Event<T>},568 Council: pallet_collective::<Instance1>::{Module, Call, Storage, Origin<T>, Event<T>, Config<T>},569 TechnicalCommittee: pallet_collective::<Instance2>::{Module, Call, Storage, Origin<T>, Event<T>, Config<T>},570 Elections: pallet_elections_phragmen::{Module, Call, Storage, Event<T>, Config<T>}, 571 TechnicalMembership: pallet_membership::{Module, Call, Storage, Event<T>, Config<T>},572 Treasury: pallet_treasury::{Module, Call, Storage, Config, Event<T>},573 Scheduler: pallet_scheduler::{Module, Call, Storage, Event<T>},574 }575);576577/// The address format for describing accounts.578pub type Address = AccountId;579/// Block header type as expected by this runtime.580pub type Header = generic::Header<BlockNumber, BlakeTwo256>;581/// Block type as expected by this runtime.582pub type Block = generic::Block<Header, UncheckedExtrinsic>;583/// A Block signed with a Justification584pub type SignedBlock = generic::SignedBlock<Block>;585/// BlockId type as expected by this runtime.586pub type BlockId = generic::BlockId<Block>;587/// The SignedExtension to the basic transaction logic.588pub type SignedExtra = (589 system::CheckSpecVersion<Runtime>,590 system::CheckTxVersion<Runtime>,591 system::CheckGenesis<Runtime>,592 system::CheckEra<Runtime>,593 system::CheckNonce<Runtime>,594 system::CheckWeight<Runtime>,595 pallet_nft::ChargeTransactionPayment<Runtime>,596);597/// Unchecked extrinsic type as expected by this runtime.598pub type UncheckedExtrinsic = generic::UncheckedExtrinsic<Address, Call, Signature, SignedExtra>;599/// Extrinsic type that has already been checked.600pub type CheckedExtrinsic = generic::CheckedExtrinsic<AccountId, Call, SignedExtra>;601/// Executive: handles dispatch to the various modules.602pub type Executive =603 frame_executive::Executive<Runtime, Block, system::ChainContext<Runtime>, Runtime, AllModules>;604605impl_runtime_apis! {606607 impl pallet_contracts_rpc_runtime_api::ContractsApi<Block, AccountId, Balance, BlockNumber>608 for Runtime609 {610 fn call(611 origin: AccountId,612 dest: AccountId,613 value: Balance,614 gas_limit: u64,615 input_data: Vec<u8>,616 ) -> ContractExecResult {617 let (exec_result, gas_consumed) =618 Contracts::bare_call(origin, dest.into(), value, gas_limit, input_data);619 match exec_result {620 Ok(v) => ContractExecResult::Success {621 flags: v.flags.bits(),622 data: v.data,623 gas_consumed: gas_consumed,624 },625 Err(_) => ContractExecResult::Error,626 }627 }628629 fn get_storage(630 address: AccountId,631 key: [u8; 32],632 ) -> pallet_contracts_primitives::GetStorageResult {633 Contracts::get_storage(address, key)634 }635636 fn rent_projection(637 address: AccountId,638 ) -> pallet_contracts_primitives::RentProjectionResult<BlockNumber> {639 Contracts::rent_projection(address)640 }641 }642643 impl sp_api::Core<Block> for Runtime {644 fn version() -> RuntimeVersion {645 VERSION646 }647648 fn execute_block(block: Block) {649 Executive::execute_block(block)650 }651652 fn initialize_block(header: &<Block as BlockT>::Header) {653 Executive::initialize_block(header)654 }655 }656657 impl sp_api::Metadata<Block> for Runtime {658 fn metadata() -> OpaqueMetadata {659 Runtime::metadata().into()660 }661 }662663 impl sp_block_builder::BlockBuilder<Block> for Runtime {664 fn apply_extrinsic(extrinsic: <Block as BlockT>::Extrinsic) -> ApplyExtrinsicResult {665 Executive::apply_extrinsic(extrinsic)666 }667668 fn finalize_block() -> <Block as BlockT>::Header {669 Executive::finalize_block()670 }671672 fn inherent_extrinsics(data: sp_inherents::InherentData) -> Vec<<Block as BlockT>::Extrinsic> {673 data.create_extrinsics()674 }675676 fn check_inherents(677 block: Block,678 data: sp_inherents::InherentData,679 ) -> sp_inherents::CheckInherentsResult {680 data.check_extrinsics(&block)681 }682683 fn random_seed() -> <Block as BlockT>::Hash {684 RandomnessCollectiveFlip::random_seed()685 }686 }687688 impl sp_transaction_pool::runtime_api::TaggedTransactionQueue<Block> for Runtime {689 fn validate_transaction(690 source: TransactionSource,691 tx: <Block as BlockT>::Extrinsic,692 ) -> TransactionValidity {693 Executive::validate_transaction(source, tx)694 }695 }696697 impl sp_offchain::OffchainWorkerApi<Block> for Runtime {698 fn offchain_worker(header: &<Block as BlockT>::Header) {699 Executive::offchain_worker(header)700 }701 }702703 impl sp_consensus_aura::AuraApi<Block, AuraId> for Runtime {704 fn slot_duration() -> u64 {705 Aura::slot_duration()706 }707708 fn authorities() -> Vec<AuraId> {709 Aura::authorities()710 }711 }712713 impl sp_session::SessionKeys<Block> for Runtime {714 fn generate_session_keys(seed: Option<Vec<u8>>) -> Vec<u8> {715 opaque::SessionKeys::generate(seed)716 }717718 fn decode_session_keys(719 encoded: Vec<u8>,720 ) -> Option<Vec<(Vec<u8>, KeyTypeId)>> {721 opaque::SessionKeys::decode_into_raw_public_keys(&encoded)722 }723 }724725 impl fg_primitives::GrandpaApi<Block> for Runtime {726 fn grandpa_authorities() -> GrandpaAuthorityList {727 Grandpa::grandpa_authorities()728 }729730 fn submit_report_equivocation_unsigned_extrinsic(731 _equivocation_proof: fg_primitives::EquivocationProof<732 <Block as BlockT>::Hash,733 NumberFor<Block>,734 >,735 _key_owner_proof: fg_primitives::OpaqueKeyOwnershipProof,736 ) -> Option<()> {737 None738 }739740 fn generate_key_ownership_proof(741 _set_id: fg_primitives::SetId,742 _authority_id: GrandpaId,743 ) -> Option<fg_primitives::OpaqueKeyOwnershipProof> {744 // NOTE: this is the only implementation possible since we've745 // defined our key owner proof type as a bottom type (i.e. a type746 // with no values).747 None748 }749 }750 751 impl frame_system_rpc_runtime_api::AccountNonceApi<Block, AccountId, Index> for Runtime {752 fn account_nonce(account: AccountId) -> Index {753 System::account_nonce(account)754 }755 }756757 impl pallet_transaction_payment_rpc_runtime_api::TransactionPaymentApi<Block, Balance> for Runtime {758 fn query_info(759 uxt: <Block as BlockT>::Extrinsic,760 len: u32,761 ) -> pallet_transaction_payment_rpc_runtime_api::RuntimeDispatchInfo<Balance> {762 TransactionPayment::query_info(uxt, len)763 }764 }765766 #[cfg(feature = "runtime-benchmarks")]767 impl frame_benchmarking::Benchmark<Block> for Runtime {768 fn dispatch_benchmark(769 config: frame_benchmarking::BenchmarkConfig770 ) -> Result<Vec<frame_benchmarking::BenchmarkBatch>, sp_runtime::RuntimeString> {771 use frame_benchmarking::{Benchmarking, BenchmarkBatch, add_benchmark, TrackedStorageKey};772773 let whitelist: Vec<TrackedStorageKey> = vec![774 // Alice account775 hex_literal::hex!("d43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d").to_vec().into(),776 // // Total Issuance777 // hex_literal::hex!("c2261276cc9d1f8598ea4b6a74b15c2f57c875e4cff74148e4628f264b974c80").to_vec().into(),778 // // Execution Phase779 // hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef7ff553b5a9862a516939d82b3d3d8661a").to_vec().into(),780 // // Event Count781 // hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef70a98fdbe9ce6c55837576c60c7af3850").to_vec().into(),782 // // System Events783 // hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef780d41e5e16056765bc8461851072c9d7").to_vec().into(),784 ];785786 let mut batches = Vec::<BenchmarkBatch>::new();787 let params = (&config, &whitelist);788789 add_benchmark!(params, batches, pallet_nft, Nft);790791 if batches.is_empty() { return Err("Benchmark not found for this pallet.".into()) }792 Ok(batches)793 }794 }795}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 pallet_contracts_rpc_runtime_api::ContractExecResult;12use pallet_grandpa::fg_primitives;13use pallet_grandpa::{AuthorityId as GrandpaId, AuthorityList as GrandpaAuthorityList};14use sp_api::impl_runtime_apis;15use sp_consensus_aura::sr25519::AuthorityId as AuraId;16use sp_core::{ crypto::KeyTypeId, crypto::Public, OpaqueMetadata };17use sp_runtime::{18 create_runtime_str, generic, impl_opaque_keys,19 traits::{20 Convert, BlakeTwo256, Block as BlockT, IdentifyAccount, 21 IdentityLookup, NumberFor, Saturating, Verify,22 },23 transaction_validity::{TransactionSource, TransactionValidity},24 ApplyExtrinsicResult, MultiSignature,25};26use sp_std::prelude::*;27#[cfg(feature = "std")]28use sp_version::NativeVersion;29use sp_version::RuntimeVersion;3031// A few exports that help ease life for downstream crates.32pub use pallet_balances::Call as BalancesCall;33pub use pallet_contracts::Schedule as ContractsSchedule;34pub use frame_support::{35 construct_runtime,36 dispatch::DispatchResult,37 parameter_types,38 traits::{39 Currency, ExistenceRequirement, Get, KeyOwnerProofSystem, OnUnbalanced, Randomness,40 WithdrawReason, LockIdentifier,41 },42 weights::{43 constants::{BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight, WEIGHT_PER_SECOND},44 DispatchInfo, GetDispatchInfo, IdentityFee, Pays, PostDispatchInfo, Weight,45 WeightToFeePolynomial,46 },47 StorageValue,48};49#[cfg(any(feature = "std", test))]50pub use sp_runtime::BuildStorage;51use sp_runtime:: { Perbill, Permill, Percent, ModuleId };52use frame_system::{self as system, EnsureRoot };53use sp_std::{marker::PhantomData};5455pub use pallet_timestamp::Call as TimestampCall;5657/// Struct that handles the conversion of Balance -> `u64`. This is used for58/// staking's election calculation.59pub struct CurrencyToVoteHandler;6061impl CurrencyToVoteHandler {62 fn factor() -> Balance {63 (Balances::total_issuance() / u64::max_value() as Balance).max(1)64 }65}6667impl Convert<Balance, u64> for CurrencyToVoteHandler {68 fn convert(x: Balance) -> u64 {69 (x / Self::factor()) as u6470 }71}7273impl Convert<u128, Balance> for CurrencyToVoteHandler {74 fn convert(x: u128) -> Balance {75 x * Self::factor()76 }77}7879/// Re-export a nft pallet80/// TODO: Check this re-export. Is this safe and good style?81extern crate pallet_nft;82pub use pallet_nft::*;8384/// An index to a block.85pub type BlockNumber = u32;8687/// Alias to 512-bit hash when used in the context of a transaction signature on the chain.88pub type Signature = MultiSignature;8990/// Some way of identifying an account on the chain. We intentionally make it equivalent91/// to the public key of our transaction signing scheme.92pub type AccountId = <<Signature as Verify>::Signer as IdentifyAccount>::AccountId;9394/// The type for looking up accounts. We don't expect more than 4 billion of them, but you95/// never know...96pub type AccountIndex = u32;9798/// Balance of an account.99pub type Balance = u128;100101/// Index of a transaction in the chain.102pub type Index = u32;103104/// A hash of some data used by the chain.105pub type Hash = sp_core::H256;106107/// Digest item type.108pub type DigestItem = generic::DigestItem<Hash>;109110mod nft_weights;111112/// Opaque types. These are used by the CLI to instantiate machinery that don't need to know113/// the specifics of the runtime. They can then be made to be agnostic over specific formats114/// of data like extrinsics, allowing for them to continue syncing the network through upgrades115/// to even the core data structures.116pub mod opaque {117 use super::*;118119 pub use sp_runtime::OpaqueExtrinsic as UncheckedExtrinsic;120121 /// Opaque block header type.122 pub type Header = generic::Header<BlockNumber, BlakeTwo256>;123 /// Opaque block type.124 pub type Block = generic::Block<Header, UncheckedExtrinsic>;125 /// Opaque block identifier type.126 pub type BlockId = generic::BlockId<Block>;127128 impl_opaque_keys! {129 pub struct SessionKeys {130 pub aura: Aura,131 pub grandpa: Grandpa,132 }133 }134}135136/// This runtime version.137pub const VERSION: RuntimeVersion = RuntimeVersion {138 spec_name: create_runtime_str!("nft"),139 impl_name: create_runtime_str!("nft"),140 authoring_version: 1,141 spec_version: 2,142 impl_version: 1,143 apis: RUNTIME_API_VERSIONS,144 transaction_version: 1,145};146147pub const MILLISECS_PER_BLOCK: u64 = 6000;148149pub const SLOT_DURATION: u64 = MILLISECS_PER_BLOCK;150151// These time units are defined in number of blocks.152pub const MINUTES: BlockNumber = 60_000 / (MILLISECS_PER_BLOCK as BlockNumber);153pub const HOURS: BlockNumber = MINUTES * 60;154pub const DAYS: BlockNumber = HOURS * 24;155156/// The version information used to identify this runtime when compiled natively.157#[cfg(feature = "std")]158pub fn native_version() -> NativeVersion {159 NativeVersion {160 runtime_version: VERSION,161 can_author_with: Default::default(),162 }163}164165/// Provides a membership set with only the configured aura users166pub struct ValiudatorsOnly<Runtime: pallet_aura::Trait>(PhantomData<Runtime>);167impl frame_support::traits::Contains<AccountId> for ValiudatorsOnly<Runtime> {168 fn contains(t: &AccountId) -> bool {169 let arr: [u8; 32] = *t.as_ref();170 let raw_key: Vec<u8> = Vec::from(arr);171172 match pallet_aura::Module::<Runtime>::authorities().iter().find(|auth| auth.to_raw_vec() == raw_key) {173 Some(_) => true,174 None => false,175 } 176 }177 fn sorted_members() -> Vec<AccountId> {178 let mut members: Vec<AccountId> = Vec::new();179 for auth in pallet_aura::Module::<Runtime>::authorities() {180 let mut arr: [u8; 32] = Default::default(); 181 let bor_arr = auth.clone().to_raw_vec();182 let slice = bor_arr.as_slice();183 arr.copy_from_slice(slice);184 members.push(AccountId::from(arr));185 }186 members 187 }188 fn count() -> usize {189 pallet_aura::Module::<Runtime>::authorities().len()190 }191}192193impl frame_support::traits::ContainsLengthBound for ValiudatorsOnly<Runtime> {194 fn min_len() -> usize {195 1196 }197 fn max_len() -> usize {198 100199 }200}201202parameter_types! {203 pub const BlockHashCount: BlockNumber = 2400;204 /// We allow for 2 seconds of compute with a 6 second average block time.205 pub const MaximumBlockWeight: Weight = 2 * WEIGHT_PER_SECOND;206 pub const AvailableBlockRatio: Perbill = Perbill::from_percent(75);207 /// Assume 10% of weight for average on_initialize calls.208 pub MaximumExtrinsicWeight: Weight = AvailableBlockRatio::get()209 .saturating_sub(Perbill::from_percent(10)) * MaximumBlockWeight::get();210 pub const MaximumBlockLength: u32 = 5 * 1024 * 1024;211 pub const Version: RuntimeVersion = VERSION;212}213214impl system::Trait for Runtime {215 /// The basic call filter to use in dispatchable.216 type BaseCallFilter = ();217 /// The identifier used to distinguish between accounts.218 type AccountId = AccountId;219 /// The aggregated dispatch type that is available for extrinsics.220 type Call = Call;221 /// The lookup mechanism to get account ID from whatever is passed in dispatchers.222 type Lookup = IdentityLookup<AccountId>;223 /// The index type for storing how many extrinsics an account has signed.224 type Index = Index;225 /// The index type for blocks.226 type BlockNumber = BlockNumber;227 /// The type for hashing blocks and tries.228 type Hash = Hash;229 /// The hashing algorithm used.230 type Hashing = BlakeTwo256;231 /// The header type.232 type Header = generic::Header<BlockNumber, BlakeTwo256>;233 /// The ubiquitous event type.234 type Event = Event;235 /// The ubiquitous origin type.236 type Origin = Origin;237 /// Maximum number of block number to block hash mappings to keep (oldest pruned first).238 type BlockHashCount = BlockHashCount;239 /// Maximum weight of each block.240 type MaximumBlockWeight = MaximumBlockWeight;241 /// The weight of database operations that the runtime can invoke.242 type DbWeight = RocksDbWeight;243 /// The weight of the overhead invoked on the block import process, independent of the244 /// extrinsics included in that block.245 type BlockExecutionWeight = BlockExecutionWeight;246 /// The base weight of any extrinsic processed by the runtime, independent of the247 /// logic of that extrinsic. (Signature verification, nonce increment, fee, etc...)248 type ExtrinsicBaseWeight = ExtrinsicBaseWeight;249 /// The maximum weight that a single extrinsic of `Normal` dispatch class can have,250 /// idependent of the logic of that extrinsics. (Roughly max block weight - average on251 /// initialize cost).252 type MaximumExtrinsicWeight = MaximumExtrinsicWeight;253 /// Maximum size of all encoded transactions (in bytes) that are allowed in one block.254 type MaximumBlockLength = MaximumBlockLength;255 /// Portion of the block weight that is available to all normal transactions.256 type AvailableBlockRatio = AvailableBlockRatio;257 /// Version of the runtime.258 type Version = Version;259 /// This type is being generated by `construct_runtime!`.260 type PalletInfo = PalletInfo;261 /// What to do if a new account is created.262 type OnNewAccount = ();263 /// What to do if an account is fully reaped from the system.264 type OnKilledAccount = ();265 /// The data to be stored in an account.266 type AccountData = pallet_balances::AccountData<Balance>;267 /// Weight information for the extrinsics of this pallet.268 type SystemWeightInfo = ();269}270271impl pallet_aura::Trait for Runtime {272 type AuthorityId = AuraId;273}274275impl pallet_grandpa::Trait for Runtime {276 type Event = Event;277 type Call = Call;278279 type KeyOwnerProofSystem = ();280281 type KeyOwnerProof =282 <Self::KeyOwnerProofSystem as KeyOwnerProofSystem<(KeyTypeId, GrandpaId)>>::Proof;283284 type KeyOwnerIdentification = <Self::KeyOwnerProofSystem as KeyOwnerProofSystem<(285 KeyTypeId,286 GrandpaId,287 )>>::IdentificationTuple;288289 type HandleEquivocation = ();290291 type WeightInfo = ();292}293294parameter_types! {295 pub const MinimumPeriod: u64 = SLOT_DURATION / 2;296}297298impl pallet_timestamp::Trait for Runtime {299 /// A timestamp: milliseconds since the unix epoch.300 type Moment = u64;301 type OnTimestampSet = Aura;302 type MinimumPeriod = MinimumPeriod;303 type WeightInfo = ();304}305306parameter_types! {307 // pub const ExistentialDeposit: u128 = 500;308 pub const ExistentialDeposit: u128 = 0;309 pub const MaxLocks: u32 = 50;310}311312impl pallet_balances::Trait for Runtime {313 type MaxLocks = MaxLocks;314 /// The type for recording an account's balance.315 type Balance = Balance;316 /// The ubiquitous event type.317 type Event = Event;318 type DustRemoval = ();319 type ExistentialDeposit = ExistentialDeposit;320 type AccountStore = System;321 type WeightInfo = ();322}323324pub const MILLICENTS: Balance = 1_000_000_000;325pub const CENTS: Balance = 1_000 * MILLICENTS;326pub const DOLLARS: Balance = 100 * CENTS;327328parameter_types! {329 pub const TombstoneDeposit: Balance = 16 * MILLICENTS;330 pub const RentByteFee: Balance = 4 * MILLICENTS;331 pub const RentDepositOffset: Balance = 1000 * MILLICENTS;332 pub const SurchargeReward: Balance = 150 * MILLICENTS;333}334335impl pallet_contracts::Trait for Runtime {336 type Time = Timestamp;337 type Randomness = RandomnessCollectiveFlip;338 type Currency = Balances;339 type Event = Event;340 type DetermineContractAddress = pallet_contracts::SimpleAddressDeterminer<Runtime>;341 type TrieIdGenerator = pallet_contracts::TrieIdFromParentCounter<Runtime>;342 type RentPayment = ();343 type SignedClaimHandicap = pallet_contracts::DefaultSignedClaimHandicap;344 type TombstoneDeposit = TombstoneDeposit;345 type StorageSizeOffset = pallet_contracts::DefaultStorageSizeOffset;346 type RentByteFee = RentByteFee;347 type RentDepositOffset = RentDepositOffset;348 type SurchargeReward = SurchargeReward;349 type MaxDepth = pallet_contracts::DefaultMaxDepth;350 type MaxValueSize = pallet_contracts::DefaultMaxValueSize;351 type WeightPrice = pallet_transaction_payment::Module<Self>;352}353354parameter_types! {355 pub const TransactionByteFee: Balance = 10 * MILLICENTS;356}357358impl pallet_transaction_payment::Trait for Runtime {359 type Currency = pallet_balances::Module<Runtime>;360 type OnTransactionPayment = ();361 type TransactionByteFee = TransactionByteFee;362 type WeightToFee = IdentityFee<Balance>;363 type FeeMultiplierUpdate = ();364}365366parameter_types! {367 pub const ProposalBond: Permill = Permill::from_percent(5);368 pub const ProposalBondMinimum: Balance = 1 * DOLLARS;369 pub const SpendPeriod: BlockNumber = 1 * DAYS;370 pub const Burn: Permill = Permill::from_percent(50);371 pub const TipCountdown: BlockNumber = 1 * DAYS;372 pub const TipFindersFee: Percent = Percent::from_percent(20);373 pub const TipReportDepositBase: Balance = 1 * DOLLARS;374 pub const DataDepositPerByte: Balance = 1 * CENTS;375 pub const BountyDepositBase: Balance = 1 * DOLLARS;376 pub const BountyDepositPayoutDelay: BlockNumber = 1 * DAYS;377 pub const TreasuryModuleId: ModuleId = ModuleId(*b"py/trsry");378 pub const BountyUpdatePeriod: BlockNumber = 14 * DAYS;379 pub const MaximumReasonLength: u32 = 16384;380 pub const BountyCuratorDeposit: Permill = Permill::from_percent(50);381 pub const BountyValueMinimum: Balance = 5 * DOLLARS;382}383384impl pallet_treasury::Trait for Runtime {385 type ModuleId = TreasuryModuleId;386 type Currency = Balances;387 type ApproveOrigin = EnsureRoot<AccountId>;388 type RejectOrigin = EnsureRoot<AccountId>;389 type Tippers = ValiudatorsOnly<Self>;390 type TipCountdown = TipCountdown;391 type TipFindersFee = TipFindersFee;392 type TipReportDepositBase = TipReportDepositBase;393 type DataDepositPerByte = DataDepositPerByte;394 type Event = Event;395 type OnSlash = ();396 type ProposalBond = ProposalBond;397 type ProposalBondMinimum = ProposalBondMinimum;398 type SpendPeriod = SpendPeriod;399 type Burn = Burn;400 type BountyDepositBase = BountyDepositBase;401 type BountyDepositPayoutDelay = BountyDepositPayoutDelay;402 type BountyUpdatePeriod = BountyUpdatePeriod;403 type BountyCuratorDeposit = BountyCuratorDeposit;404 type BountyValueMinimum = BountyValueMinimum;405 type MaximumReasonLength = MaximumReasonLength;406 type BurnDestination = ();407 type WeightInfo = ();408}409410impl pallet_sudo::Trait for Runtime {411 type Event = Event;412 type Call = Call;413}414415/// Used for the module nft in `./nft.rs`416impl pallet_nft::Trait for Runtime {417 type Event = Event;418 type WeightInfo = nft_weights::WeightInfo;419}420421construct_runtime!(422 pub enum Runtime where423 Block = Block,424 NodeBlock = opaque::Block,425 UncheckedExtrinsic = UncheckedExtrinsic426 {427 System: system::{Module, Call, Config, Storage, Event<T>},428 RandomnessCollectiveFlip: pallet_randomness_collective_flip::{Module, Call, Storage},429 Contracts: pallet_contracts::{Module, Call, Config, Storage, Event<T>},430 Timestamp: pallet_timestamp::{Module, Call, Storage, Inherent},431 Aura: pallet_aura::{Module, Config<T>, Inherent},432 Grandpa: pallet_grandpa::{Module, Call, Storage, Config, Event},433 Balances: pallet_balances::{Module, Call, Storage, Config<T>, Event<T>},434 TransactionPayment: pallet_transaction_payment::{Module, Storage},435 Sudo: pallet_sudo::{Module, Call, Config<T>, Storage, Event<T>},436 Nft: pallet_nft::{Module, Call, Config<T>, Storage, Event<T>},437 Treasury: pallet_treasury::{Module, Call, Storage, Config, Event<T>},438 }439);440441/// The address format for describing accounts.442pub type Address = AccountId;443/// Block header type as expected by this runtime.444pub type Header = generic::Header<BlockNumber, BlakeTwo256>;445/// Block type as expected by this runtime.446pub type Block = generic::Block<Header, UncheckedExtrinsic>;447/// A Block signed with a Justification448pub type SignedBlock = generic::SignedBlock<Block>;449/// BlockId type as expected by this runtime.450pub type BlockId = generic::BlockId<Block>;451/// The SignedExtension to the basic transaction logic.452pub type SignedExtra = (453 system::CheckSpecVersion<Runtime>,454 system::CheckTxVersion<Runtime>,455 system::CheckGenesis<Runtime>,456 system::CheckEra<Runtime>,457 system::CheckNonce<Runtime>,458 system::CheckWeight<Runtime>,459 pallet_nft::ChargeTransactionPayment<Runtime>,460);461/// Unchecked extrinsic type as expected by this runtime.462pub type UncheckedExtrinsic = generic::UncheckedExtrinsic<Address, Call, Signature, SignedExtra>;463/// Extrinsic type that has already been checked.464pub type CheckedExtrinsic = generic::CheckedExtrinsic<AccountId, Call, SignedExtra>;465/// Executive: handles dispatch to the various modules.466pub type Executive =467 frame_executive::Executive<Runtime, Block, system::ChainContext<Runtime>, Runtime, AllModules>;468469impl_runtime_apis! {470471 impl pallet_contracts_rpc_runtime_api::ContractsApi<Block, AccountId, Balance, BlockNumber>472 for Runtime473 {474 fn call(475 origin: AccountId,476 dest: AccountId,477 value: Balance,478 gas_limit: u64,479 input_data: Vec<u8>,480 ) -> ContractExecResult {481 let (exec_result, gas_consumed) =482 Contracts::bare_call(origin, dest.into(), value, gas_limit, input_data);483 match exec_result {484 Ok(v) => ContractExecResult::Success {485 flags: v.flags.bits(),486 data: v.data,487 gas_consumed: gas_consumed,488 },489 Err(_) => ContractExecResult::Error,490 }491 }492493 fn get_storage(494 address: AccountId,495 key: [u8; 32],496 ) -> pallet_contracts_primitives::GetStorageResult {497 Contracts::get_storage(address, key)498 }499500 fn rent_projection(501 address: AccountId,502 ) -> pallet_contracts_primitives::RentProjectionResult<BlockNumber> {503 Contracts::rent_projection(address)504 }505 }506507 impl sp_api::Core<Block> for Runtime {508 fn version() -> RuntimeVersion {509 VERSION510 }511512 fn execute_block(block: Block) {513 Executive::execute_block(block)514 }515516 fn initialize_block(header: &<Block as BlockT>::Header) {517 Executive::initialize_block(header)518 }519 }520521 impl sp_api::Metadata<Block> for Runtime {522 fn metadata() -> OpaqueMetadata {523 Runtime::metadata().into()524 }525 }526527 impl sp_block_builder::BlockBuilder<Block> for Runtime {528 fn apply_extrinsic(extrinsic: <Block as BlockT>::Extrinsic) -> ApplyExtrinsicResult {529 Executive::apply_extrinsic(extrinsic)530 }531532 fn finalize_block() -> <Block as BlockT>::Header {533 Executive::finalize_block()534 }535536 fn inherent_extrinsics(data: sp_inherents::InherentData) -> Vec<<Block as BlockT>::Extrinsic> {537 data.create_extrinsics()538 }539540 fn check_inherents(541 block: Block,542 data: sp_inherents::InherentData,543 ) -> sp_inherents::CheckInherentsResult {544 data.check_extrinsics(&block)545 }546547 fn random_seed() -> <Block as BlockT>::Hash {548 RandomnessCollectiveFlip::random_seed()549 }550 }551552 impl sp_transaction_pool::runtime_api::TaggedTransactionQueue<Block> for Runtime {553 fn validate_transaction(554 source: TransactionSource,555 tx: <Block as BlockT>::Extrinsic,556 ) -> TransactionValidity {557 Executive::validate_transaction(source, tx)558 }559 }560561 impl sp_offchain::OffchainWorkerApi<Block> for Runtime {562 fn offchain_worker(header: &<Block as BlockT>::Header) {563 Executive::offchain_worker(header)564 }565 }566567 impl sp_consensus_aura::AuraApi<Block, AuraId> for Runtime {568 fn slot_duration() -> u64 {569 Aura::slot_duration()570 }571572 fn authorities() -> Vec<AuraId> {573 Aura::authorities()574 }575 }576577 impl sp_session::SessionKeys<Block> for Runtime {578 fn generate_session_keys(seed: Option<Vec<u8>>) -> Vec<u8> {579 opaque::SessionKeys::generate(seed)580 }581582 fn decode_session_keys(583 encoded: Vec<u8>,584 ) -> Option<Vec<(Vec<u8>, KeyTypeId)>> {585 opaque::SessionKeys::decode_into_raw_public_keys(&encoded)586 }587 }588589 impl fg_primitives::GrandpaApi<Block> for Runtime {590 fn grandpa_authorities() -> GrandpaAuthorityList {591 Grandpa::grandpa_authorities()592 }593594 fn submit_report_equivocation_unsigned_extrinsic(595 _equivocation_proof: fg_primitives::EquivocationProof<596 <Block as BlockT>::Hash,597 NumberFor<Block>,598 >,599 _key_owner_proof: fg_primitives::OpaqueKeyOwnershipProof,600 ) -> Option<()> {601 None602 }603604 fn generate_key_ownership_proof(605 _set_id: fg_primitives::SetId,606 _authority_id: GrandpaId,607 ) -> Option<fg_primitives::OpaqueKeyOwnershipProof> {608 // NOTE: this is the only implementation possible since we've609 // defined our key owner proof type as a bottom type (i.e. a type610 // with no values).611 None612 }613 }614 615 impl frame_system_rpc_runtime_api::AccountNonceApi<Block, AccountId, Index> for Runtime {616 fn account_nonce(account: AccountId) -> Index {617 System::account_nonce(account)618 }619 }620621 impl pallet_transaction_payment_rpc_runtime_api::TransactionPaymentApi<Block, Balance> for Runtime {622 fn query_info(623 uxt: <Block as BlockT>::Extrinsic,624 len: u32,625 ) -> pallet_transaction_payment_rpc_runtime_api::RuntimeDispatchInfo<Balance> {626 TransactionPayment::query_info(uxt, len)627 }628 }629630 #[cfg(feature = "runtime-benchmarks")]631 impl frame_benchmarking::Benchmark<Block> for Runtime {632 fn dispatch_benchmark(633 config: frame_benchmarking::BenchmarkConfig634 ) -> Result<Vec<frame_benchmarking::BenchmarkBatch>, sp_runtime::RuntimeString> {635 use frame_benchmarking::{Benchmarking, BenchmarkBatch, add_benchmark, TrackedStorageKey};636637 let whitelist: Vec<TrackedStorageKey> = vec![638 // Alice account639 hex_literal::hex!("d43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d").to_vec().into(),640 // // Total Issuance641 // hex_literal::hex!("c2261276cc9d1f8598ea4b6a74b15c2f57c875e4cff74148e4628f264b974c80").to_vec().into(),642 // // Execution Phase643 // hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef7ff553b5a9862a516939d82b3d3d8661a").to_vec().into(),644 // // Event Count645 // hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef70a98fdbe9ce6c55837576c60c7af3850").to_vec().into(),646 // // System Events647 // hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef780d41e5e16056765bc8461851072c9d7").to_vec().into(),648 ];649650 let mut batches = Vec::<BenchmarkBatch>::new();651 let params = (&config, &whitelist);652653 add_benchmark!(params, batches, pallet_nft, Nft);654655 if batches.is_empty() { return Err("Benchmark not found for this pallet.".into()) }656 Ok(batches)657 }658 }659}