difftreelog
Merge pull request #29 from usetech-llc/feature/nftpar-149
in: master
Feature/nftpar 149
4 files changed
node/src/chain_spec.rsdiffbeforeafterboth147 pallet_aura: Some(AuraConfig {147 pallet_aura: Some(AuraConfig {148 authorities: initial_authorities.iter().map(|x| (x.0.clone())).collect(),148 authorities: initial_authorities.iter().map(|x| (x.0.clone())).collect(),149 }),149 }),150 pallet_collective_Instance1: Some(CouncilConfig {151 members: vec![],152 phantom: Default::default(),153 }),154 pallet_collective_Instance2: Some(TechnicalCommitteeConfig {155 members: vec![],156 phantom: Default::default(),157 }),158 pallet_democracy: Some(DemocracyConfig::default()),159 pallet_grandpa: Some(GrandpaConfig {150 pallet_grandpa: Some(GrandpaConfig {160 authorities: initial_authorities151 authorities: initial_authorities161 .iter()152 .iter()162 .map(|x| (x.1.clone(), 1))153 .map(|x| (x.1.clone(), 1))163 .collect(),154 .collect(),164 }),155 }),165 pallet_elections_phragmen: Some(Default::default()),166 pallet_membership: Some(Default::default()),167 pallet_treasury: Some(Default::default()),156 pallet_treasury: Some(Default::default()),168 pallet_sudo: Some(SudoConfig { key: root_key }),157 pallet_sudo: Some(SudoConfig { key: root_key }),169 pallet_nft: Some(NftConfig {158 pallet_nft: Some(NftConfig {pallets/nft/src/lib.rsdiffbeforeafterboth13311331 let sender = ensure_signed(origin)?;1332 let sender = ensure_signed(origin)?;13331334 #[cfg(feature = "runtime-benchmarks")]1335 <ContractOwner<T>>::insert(contract_address.clone(), sender.clone());13361332 let mut is_owner = false;1337 let mut is_owner = false;1333 if <ContractOwner<T>>::contains_key(contract_address.clone()) {1338 if <ContractOwner<T>>::contains_key(contract_address.clone()) {1375 Ok(())1380 Ok(())1376 }1381 }137713821383 // #[cfg(feature = "runtime-benchmarks")]1384 // #[weight = 0]1385 // pub fn add_contract_sponsoring_debug(1386 // origin,1387 // contract_address: T::AccountId, 1388 // owner: T::AccountId) -> DispatchResult {1389 // let sender = ensure_signed(origin)?;1390 // <ContractOwner<T>>::insert(contract_address.clone(), owner);1391 // Ok(())1392 // }1393 1378 }1394 }1379}1395}runtime/Cargo.tomldiffbeforeafterboth57sp-transaction-pool = { default-features = false, version = '2.0.0' , git = 'https://github.com/usetech-llc/substrate.git', branch = 'v2.0.0_release' }57sp-transaction-pool = { default-features = false, version = '2.0.0' , git = 'https://github.com/usetech-llc/substrate.git', branch = 'v2.0.0_release' }58sp-version = { default-features = false, version = '2.0.0' , git = 'https://github.com/usetech-llc/substrate.git', branch = 'v2.0.0_release' }58sp-version = { default-features = false, version = '2.0.0' , git = 'https://github.com/usetech-llc/substrate.git', branch = 'v2.0.0_release' }595960pallet-membership = { version = "2.0.0", default-features = false, git = 'https://github.com/usetech-llc/substrate.git', branch = 'v2.0.0_release' }61pallet-collective = { default-features = false, version = '2.0.0' , git = 'https://github.com/usetech-llc/substrate.git', branch = 'v2.0.0_release' }62pallet-democracy = { default-features = false, version = '2.0.0' , git = 'https://github.com/usetech-llc/substrate.git', branch = 'v2.0.0_release' }63pallet-elections-phragmen = { version = "2.0.0", default-features = false, git = 'https://github.com/usetech-llc/substrate.git', branch = 'v2.0.0_release' }64pallet-treasury = { version = "2.0.0", default-features = false, git = 'https://github.com/usetech-llc/substrate.git', branch = 'v2.0.0_release' }60pallet-treasury = { version = "2.0.0", default-features = false, git = 'https://github.com/usetech-llc/substrate.git', branch = 'v2.0.0_release' }65pallet-scheduler = { version = "2.0.0", default-features = false, git = 'https://github.com/usetech-llc/substrate.git', branch = 'v2.0.0_release' }666167[features]62[features]68default = ['std']63default = ['std']73 'frame-system-benchmarking',68 'frame-system-benchmarking',74 'frame-system/runtime-benchmarks',69 'frame-system/runtime-benchmarks',75 'pallet-balances/runtime-benchmarks',70 'pallet-balances/runtime-benchmarks',76 'pallet-collective/runtime-benchmarks',77 'pallet-timestamp/runtime-benchmarks',71 'pallet-timestamp/runtime-benchmarks',78 'pallet-nft/runtime-benchmarks',72 'pallet-nft/runtime-benchmarks',79 'sp-runtime/runtime-benchmarks',73 'sp-runtime/runtime-benchmarks',109 'sp-transaction-pool/std',103 'sp-transaction-pool/std',110 'sp-version/std',104 'sp-version/std',111105112 'pallet-collective/std',113 'pallet-democracy/std',114 'pallet-elections-phragmen/std', 115 'pallet-membership/std',116 'pallet-treasury/std',106 'pallet-treasury/std',117 'pallet-scheduler/std',118]107]119108runtime/src/lib.rsdiffbeforeafterboth13use pallet_grandpa::{AuthorityId as GrandpaId, AuthorityList as GrandpaAuthorityList};13use pallet_grandpa::{AuthorityId as GrandpaId, AuthorityList as GrandpaAuthorityList};14use sp_api::impl_runtime_apis;14use sp_api::impl_runtime_apis;15use sp_consensus_aura::sr25519::AuthorityId as AuraId;15use sp_consensus_aura::sr25519::AuthorityId as AuraId;16use sp_core::{16use sp_core::{ crypto::KeyTypeId, crypto::Public, OpaqueMetadata };17 crypto::KeyTypeId, 18 OpaqueMetadata, 19 u32_trait::{_1, _2, _3, _4},20};21use sp_runtime::{17use sp_runtime::{22 create_runtime_str, generic, impl_opaque_keys,18 create_runtime_str, generic, impl_opaque_keys,53#[cfg(any(feature = "std", test))]49#[cfg(any(feature = "std", test))]54pub use sp_runtime::BuildStorage;50pub use sp_runtime::BuildStorage;55use sp_runtime:: { Perbill, Permill, Percent, ModuleId };51use sp_runtime:: { Perbill, Permill, Percent, ModuleId };56use frame_system::{self as system, EnsureRoot, EnsureOneOf };52use frame_system::{self as system, EnsureRoot };53use sp_std::{marker::PhantomData};575458pub use pallet_timestamp::Call as TimestampCall;55pub use pallet_timestamp::Call as TimestampCall;5956165 }162 }166}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}167201168parameter_types! {202parameter_types! {169 pub const BlockHashCount: BlockNumber = 2400;203 pub const BlockHashCount: BlockNumber = 2400;329 type FeeMultiplierUpdate = ();363 type FeeMultiplierUpdate = ();330}364}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}347365348parameter_types! {366parameter_types! {349 pub const ProposalBond: Permill = Permill::from_percent(5);367 pub const ProposalBond: Permill = Permill::from_percent(5);367 type ModuleId = TreasuryModuleId;385 type ModuleId = TreasuryModuleId;368 type Currency = Balances;386 type Currency = Balances;369 type ApproveOrigin = 387 type ApproveOrigin = EnsureRoot<AccountId>;370 EnsureOneOf<371 AccountId,372 EnsureRoot<AccountId>,373 pallet_collective::EnsureMembers<_4, AccountId, CouncilCollective>374 >;375 type RejectOrigin = 388 type RejectOrigin = EnsureRoot<AccountId>;376 EnsureOneOf<377 AccountId,378 EnsureRoot<AccountId>,379 pallet_collective::EnsureMembers<_2, AccountId, CouncilCollective>380 >;381 type Tippers = Elections;389 type Tippers = ValiudatorsOnly<Self>;382 type TipCountdown = TipCountdown;390 type TipCountdown = TipCountdown;383 type TipFindersFee = TipFindersFee;391 type TipFindersFee = TipFindersFee;384 type TipReportDepositBase = TipReportDepositBase;392 type TipReportDepositBase = TipReportDepositBase;399 type WeightInfo = ();407 type WeightInfo = ();400}408}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}538409539impl pallet_sudo::Trait for Runtime {410impl pallet_sudo::Trait for Runtime {540 type Event = Event;411 type Event = Event;564 Sudo: pallet_sudo::{Module, Call, Config<T>, Storage, Event<T>},435 Sudo: pallet_sudo::{Module, Call, Config<T>, Storage, Event<T>},565 Nft: pallet_nft::{Module, Call, Config<T>, Storage, Event<T>},436 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>},437 Treasury: pallet_treasury::{Module, Call, Storage, Config, Event<T>},573 Scheduler: pallet_scheduler::{Module, Call, Storage, Event<T>},574 }438 }575);439);576440