-
Notifications
You must be signed in to change notification settings - Fork 147
Fellowship Treasury #109
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fellowship Treasury #109
Changes from 7 commits
8f2ed70
f822d73
467b9da
c5aee46
cddf65f
59fb73a
8b847fc
c205369
90f334b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -19,26 +19,33 @@ | |
| mod origins; | ||
| mod tracks; | ||
| use crate::{ | ||
| impls::ToParentTreasury, weights, AccountId, Balance, Balances, FellowshipReferenda, | ||
| GovernanceLocation, PolkadotTreasuryAccount, Preimage, Runtime, RuntimeCall, RuntimeEvent, | ||
| RuntimeOrigin, Scheduler, DAYS, | ||
| impls::ToParentTreasury, weights, xcm_config::TreasurerBodyId, AccountId, AssetRate, Balance, | ||
| Balances, FellowshipReferenda, GovernanceLocation, PolkadotTreasuryAccount, Preimage, Runtime, | ||
| RuntimeCall, RuntimeEvent, RuntimeOrigin, Scheduler, DAYS, | ||
| }; | ||
| use cumulus_primitives_core::Junction::GeneralIndex; | ||
| use frame_support::{ | ||
| parameter_types, | ||
| traits::{EitherOf, EitherOfDiverse, MapSuccess, OriginTrait, TryWithMorphedArg}, | ||
| PalletId, | ||
| }; | ||
| use frame_system::EnsureRootWithSuccess; | ||
| use frame_system::{EnsureRoot, EnsureRootWithSuccess}; | ||
| pub use origins::{ | ||
| pallet_origins as pallet_fellowship_origins, Architects, EnsureCanPromoteTo, EnsureCanRetainAt, | ||
| EnsureFellowship, Fellows, Masters, Members, ToVoice, | ||
| }; | ||
| use pallet_ranked_collective::EnsureOfRank; | ||
| use pallet_xcm::{EnsureXcm, IsVoiceOfBody}; | ||
| use parachains_common::polkadot::account; | ||
| use polkadot_runtime_constants::{time::HOURS, xcm::body::FELLOWSHIP_ADMIN_INDEX}; | ||
| use polkadot_runtime_common::impls::{ | ||
| LocatableAssetConverter, VersionedLocatableAsset, VersionedMultiLocationConverter, | ||
| }; | ||
| use polkadot_runtime_constants::{currency::GRAND, time::HOURS, xcm::body::FELLOWSHIP_ADMIN_INDEX}; | ||
| use sp_arithmetic::Permill; | ||
| use sp_core::{ConstU128, ConstU32}; | ||
| use sp_runtime::traits::{AccountIdConversion, ConstU16, ConvertToValue, Replace, TakeFirst}; | ||
| use sp_runtime::traits::{ | ||
| AccountIdConversion, ConstU16, ConvertToValue, IdentityLookup, Replace, TakeFirst, | ||
| }; | ||
| use xcm::latest::BodyId; | ||
| use xcm_builder::{AliasesIntoAccountId32, LocatableAssetId, PayOverXcm}; | ||
|
|
||
|
|
@@ -244,3 +251,123 @@ impl pallet_salary::Config<FellowshipSalaryInstance> for Runtime { | |
| // Total monthly salary budget. | ||
| type Budget = ConstU128<{ 100_000 * USDT_UNITS }>; | ||
| } | ||
|
|
||
| parameter_types! { | ||
| // TODO: reference the constant value from common crate when polkadot-sdk 1.5 is released. | ||
| // https://github.com/polkadot-fellows/runtimes/issues/113 | ||
| pub const FellowshipTreasuryPalletId: PalletId = PalletId(*b"py/feltr"); | ||
xlc marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| pub const HundredPercent: Permill = Permill::from_percent(100); | ||
bkchr marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| pub const Burn: Permill = Permill::from_percent(0); | ||
| pub const MaxBalance: Balance = Balance::max_value(); | ||
| // The asset's interior location for the paying account. This is the Fellowship Treasury | ||
| // pallet instance (which sits at index 65). | ||
| pub FellowshipTreasuryInteriorLocation: InteriorMultiLocation = PalletInstance(65).into(); | ||
|
||
| } | ||
|
|
||
| /// [`PayOverXcm`] setup to pay the Fellowship Treasury. | ||
| pub type FellowshipTreasuryPaymaster = PayOverXcm< | ||
| FellowshipTreasuryInteriorLocation, | ||
| crate::xcm_config::XcmRouter, | ||
| crate::PolkadotXcm, | ||
| ConstU32<{ 6 * HOURS }>, | ||
| VersionedMultiLocation, | ||
| VersionedLocatableAsset, | ||
| LocatableAssetConverter, | ||
| VersionedMultiLocationConverter, | ||
| >; | ||
|
|
||
| pub type FellowshipTreasuryInstance = pallet_treasury::Instance1; | ||
|
|
||
| impl pallet_treasury::Config<FellowshipTreasuryInstance> for Runtime { | ||
| // The creation of proposals via the treasury pallet is deprecated and should not be utilized. | ||
| // Instead, public or fellowship referenda should be used to propose and command the treasury | ||
| // spend or spend_local dispatchables. The parameters below have been configured accordingly to | ||
| // discourage its use. | ||
| // TODO: replace with `NeverEnsure` once polkadot-sdk 1.5 is released. | ||
xlc marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| // https://github.com/polkadot-fellows/runtimes/issues/113 | ||
| type ApproveOrigin = EnsureRoot<AccountId>; | ||
| type OnSlash = (); | ||
| type ProposalBond = HundredPercent; | ||
bkchr marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| type ProposalBondMinimum = MaxBalance; | ||
| type ProposalBondMaximum = MaxBalance; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. again, out of scope of this PR, but this means the treasury pallet needs some serious refactoring
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. related calls were deprecated half year ago, with a note that they will be removed in Feb |
||
| // end. | ||
|
|
||
| type WeightInfo = weights::pallet_treasury::WeightInfo<Runtime>; | ||
| type RuntimeEvent = RuntimeEvent; | ||
| type PalletId = FellowshipTreasuryPalletId; | ||
| type Currency = Balances; | ||
| type RejectOrigin = EitherOfDiverse< | ||
| EnsureRoot<AccountId>, | ||
| EitherOfDiverse<EnsureXcm<IsVoiceOfBody<GovernanceLocation, TreasurerBodyId>>, Fellows>, | ||
| >; | ||
| type SpendPeriod = ConstU32<{ 7 * DAYS }>; | ||
| type Burn = Burn; | ||
| type BurnDestination = (); | ||
| type SpendFunds = (); | ||
| type MaxApprovals = ConstU32<100>; | ||
| type SpendOrigin = EitherOf< | ||
xlc marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| EitherOf< | ||
| EnsureRootWithSuccess<AccountId, MaxBalance>, | ||
| MapSuccess< | ||
| EnsureXcm<IsVoiceOfBody<GovernanceLocation, TreasurerBodyId>>, | ||
| Replace<ConstU128<{ 10_000 * GRAND }>>, | ||
| >, | ||
| >, | ||
| EitherOf< | ||
| MapSuccess<Architects, Replace<ConstU128<{ 10_000 * GRAND }>>>, | ||
| MapSuccess<Fellows, Replace<ConstU128<{ 10 * GRAND }>>>, | ||
| >, | ||
| >; | ||
| type AssetKind = VersionedLocatableAsset; | ||
| type Beneficiary = VersionedMultiLocation; | ||
| type BeneficiaryLookup = IdentityLookup<Self::Beneficiary>; | ||
| #[cfg(not(feature = "runtime-benchmarks"))] | ||
| type Paymaster = FellowshipTreasuryPaymaster; | ||
| #[cfg(feature = "runtime-benchmarks")] | ||
| type Paymaster = PayWithEnsure<FellowshipTreasuryPaymaster, OpenHrmpChannel<ConstU32<1000>>>; | ||
| type BalanceConverter = AssetRate; | ||
| type PayoutPeriod = ConstU32<{ 30 * DAYS }>; | ||
| #[cfg(feature = "runtime-benchmarks")] | ||
| type BenchmarkHelper = benchmarks::TreasuryArguments<sp_core::ConstU8<1>, ConstU32<1000>>; | ||
| } | ||
|
|
||
| // TODO: replace by [`polkadot_runtime_common::impls::benchmarks::TreasuryArguments`] when | ||
| // polkadot-sdk 1.5 is released. | ||
| // https://github.com/polkadot-fellows/runtimes/issues/113 | ||
| #[cfg(feature = "runtime-benchmarks")] | ||
| mod benchmarks { | ||
| use super::VersionedLocatableAsset; | ||
| use core::marker::PhantomData; | ||
| use frame_support::traits::Get; | ||
| use pallet_treasury::ArgumentsFactory as TreasuryArgumentsFactory; | ||
| use sp_core::{ConstU32, ConstU8}; | ||
| use xcm::prelude::*; | ||
|
|
||
| /// Provide factory methods for the [`VersionedLocatableAsset`] and the `Beneficiary` of the | ||
| /// [`VersionedMultiLocation`]. The location of the asset is determined as a Parachain with an | ||
| /// ID equal to the passed seed. | ||
| pub struct TreasuryArguments<Parents = ConstU8<0>, ParaId = ConstU32<0>>( | ||
| PhantomData<(Parents, ParaId)>, | ||
| ); | ||
| impl<Parents: Get<u8>, ParaId: Get<u32>> | ||
| TreasuryArgumentsFactory<VersionedLocatableAsset, VersionedMultiLocation> | ||
| for TreasuryArguments<Parents, ParaId> | ||
| { | ||
| fn create_asset_kind(seed: u32) -> VersionedLocatableAsset { | ||
| VersionedLocatableAsset::V3 { | ||
| location: xcm::v3::MultiLocation::new(Parents::get(), X1(Parachain(ParaId::get()))), | ||
| asset_id: xcm::v3::MultiLocation::new( | ||
| 0, | ||
| X2(PalletInstance(seed.try_into().unwrap()), GeneralIndex(seed.into())), | ||
| ) | ||
| .into(), | ||
| } | ||
| } | ||
| fn create_beneficiary(seed: [u8; 32]) -> VersionedMultiLocation { | ||
| VersionedMultiLocation::V3(xcm::v3::MultiLocation::new( | ||
| 0, | ||
| X1(AccountId32 { network: None, id: seed }), | ||
| )) | ||
| } | ||
| } | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.