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}