Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Cargo.lock

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
Expand Up @@ -29,8 +29,10 @@ use polkadot_runtime_common::{
impls::{ContainsParts, VersionedLocatableAsset},
prod_or_fast,
};
use alloc::{vec, vec::Vec};
use sp_runtime::{traits::IdentityLookup, Percent};
use xcm::latest::BodyId;
use pallet_assets::AssetCategoryManager;

mod origins;
pub use origins::{
Expand Down Expand Up @@ -124,6 +126,22 @@ parameter_types! {

pub type TreasurySpender = EitherOf<EnsureRootWithSuccess<AccountId, MaxBalance>, Spender>;

pub struct AHWAssetCategories;

impl AssetCategoryManager<AccountId> for AHWAssetCategories {
type AssetKind = VersionedLocatableAsset;
type Balance = Balance;

fn assets_in_category(_category: &[u8]) -> Vec<Self::AssetKind> {
vec![]
}

fn available_balance(_asset: Self::AssetKind, _owner: AccountId) -> Option<Self::Balance> {
None
}
}


impl pallet_treasury::Config for Runtime {
type PalletId = TreasuryPalletId;
type Currency = Balances;
Expand All @@ -150,6 +168,7 @@ impl pallet_treasury::Config for Runtime {
AssetRate,
>;
type PayoutPeriod = PayoutSpendPeriod;
type AssetCategories = AHWAssetCategories;
type BlockNumberProvider = RelaychainDataProvider<Runtime>;
#[cfg(feature = "runtime-benchmarks")]
type BenchmarkHelper = parachains_common::pay::benchmarks::LocalPayArguments<
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ frame-system = { workspace = true }
frame-system-benchmarking = { optional = true, workspace = true }
frame-system-rpc-runtime-api = { workspace = true }
frame-try-runtime = { optional = true, workspace = true }
pallet-assets = { workspace = true }
pallet-alliance = { workspace = true }
pallet-asset-rate = { workspace = true }
pallet-aura = { workspace = true }
Expand Down Expand Up @@ -114,6 +115,7 @@ runtime-benchmarks = [
"frame-system-benchmarking/runtime-benchmarks",
"frame-system/runtime-benchmarks",
"pallet-alliance/runtime-benchmarks",
"pallet-assets/runtime-benchmarks",
"pallet-asset-rate/runtime-benchmarks",
"pallet-balances/runtime-benchmarks",
"pallet-collator-selection/runtime-benchmarks",
Expand Down Expand Up @@ -157,6 +159,7 @@ try-runtime = [
"frame-system/try-runtime",
"frame-try-runtime/try-runtime",
"pallet-alliance/try-runtime",
"pallet-assets/try-runtime",
"pallet-asset-rate/try-runtime",
"pallet-aura/try-runtime",
"pallet-authorship/try-runtime",
Expand Down Expand Up @@ -205,6 +208,7 @@ std = [
"frame-system/std",
"frame-try-runtime?/std",
"pallet-alliance/std",
"pallet-assets/std",
"pallet-asset-rate/std",
"pallet-aura/std",
"pallet-authorship/std",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ use frame_support::{
},
PalletId,
};
use alloc::{vec, vec::Vec};
use pallet_assets::AssetCategoryManager;
use frame_system::{EnsureRoot, EnsureRootWithSuccess};
pub use origins::{
pallet_origins as pallet_fellowship_origins, Architects, EnsureCanPromoteTo, EnsureCanRetainAt,
Expand Down Expand Up @@ -285,6 +287,21 @@ pub type FellowshipTreasuryPaymaster = PayOverXcm<

pub type FellowshipTreasuryInstance = pallet_treasury::Instance1;

pub struct CWAssetCategories;

impl AssetCategoryManager<AccountId> for CWAssetCategories {
type AssetKind = VersionedLocatableAsset;
type Balance = Balance;

fn assets_in_category(_category: &[u8]) -> Vec<Self::AssetKind> {
vec![]
}

fn available_balance(_asset: Self::AssetKind, _owner: AccountId) -> Option<Self::Balance> {
None
}
}

impl pallet_treasury::Config<FellowshipTreasuryInstance> for Runtime {
type WeightInfo = weights::pallet_treasury::WeightInfo<Runtime>;
type PalletId = FellowshipTreasuryPalletId;
Expand Down Expand Up @@ -329,6 +346,7 @@ impl pallet_treasury::Config<FellowshipTreasuryInstance> for Runtime {
AssetRate,
>;
type PayoutPeriod = ConstU32<{ 30 * DAYS }>;
type AssetCategories = CWAssetCategories;
#[cfg(feature = "runtime-benchmarks")]
type BenchmarkHelper = polkadot_runtime_common::impls::benchmarks::TreasuryArguments<
sp_core::ConstU8<1>,
Expand Down
4 changes: 4 additions & 0 deletions polkadot/runtime/rococo/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ frame-executive = { workspace = true }
frame-support = { features = ["tuples-96"], workspace = true }
frame-system = { workspace = true }
frame-system-rpc-runtime-api = { workspace = true }
pallet-assets = { workspace = true }
pallet-asset-rate = { workspace = true }
pallet-authority-discovery = { workspace = true }
pallet-authorship = { workspace = true }
Expand Down Expand Up @@ -135,6 +136,7 @@ std = [
"frame-system/std",
"frame-try-runtime/std",
"log/std",
"pallet-assets/std",
"pallet-asset-rate/std",
"pallet-authority-discovery/std",
"pallet-authorship/std",
Expand Down Expand Up @@ -219,6 +221,7 @@ runtime-benchmarks = [
"frame-support/runtime-benchmarks",
"frame-system-benchmarking/runtime-benchmarks",
"frame-system/runtime-benchmarks",
"pallet-assets/runtime-benchmarks",
"pallet-asset-rate/runtime-benchmarks",
"pallet-babe/runtime-benchmarks",
"pallet-balances/runtime-benchmarks",
Expand Down Expand Up @@ -275,6 +278,7 @@ try-runtime = [
"frame-system/try-runtime",
"frame-try-runtime",
"frame-try-runtime/try-runtime",
"pallet-assets/try-runtime",
"pallet-asset-rate/try-runtime",
"pallet-authority-discovery/try-runtime",
"pallet-authorship/try-runtime",
Expand Down
17 changes: 17 additions & 0 deletions polkadot/runtime/rococo/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ use alloc::{
vec,
vec::Vec,
};
use pallet_assets::AssetCategoryManager;
use codec::{Decode, DecodeWithMemTracking, Encode, MaxEncodedLen};
use core::cmp::Ordering;
use frame_support::{
Expand Down Expand Up @@ -330,6 +331,21 @@ impl EnsureOriginWithArg<RuntimeOrigin, RuntimeParametersKey> for DynamicParamet
}
}

pub struct RococoAssetCategories;

impl AssetCategoryManager<AccountId> for RococoAssetCategories {
type AssetKind = VersionedLocatableAsset;
type Balance = Balance;

fn assets_in_category(_category: &[u8]) -> Vec<Self::AssetKind> {
vec![]
}

fn available_balance(_asset: Self::AssetKind, _owner: AccountId) -> Option<Self::Balance> {
None
}
}

impl pallet_scheduler::Config for Runtime {
type RuntimeOrigin = RuntimeOrigin;
type RuntimeEvent = RuntimeEvent;
Expand Down Expand Up @@ -561,6 +577,7 @@ impl pallet_treasury::Config for Runtime {
>;
type PayoutPeriod = PayoutSpendPeriod;
type BlockNumberProvider = System;
type AssetCategories = RococoAssetCategories;
#[cfg(feature = "runtime-benchmarks")]
type BenchmarkHelper = polkadot_runtime_common::impls::benchmarks::TreasuryArguments;
}
Expand Down
4 changes: 4 additions & 0 deletions polkadot/runtime/westend/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ frame-metadata-hash-extension = { workspace = true }
frame-support = { features = ["experimental", "tuples-96"], workspace = true }
frame-system = { workspace = true }
frame-system-rpc-runtime-api = { workspace = true }
pallet-assets = { workspace = true }
pallet-asset-rate = { workspace = true }
pallet-authority-discovery = { workspace = true }
pallet-authorship = { workspace = true }
Expand Down Expand Up @@ -147,6 +148,7 @@ std = [
"frame-system/std",
"frame-try-runtime/std",
"log/std",
"pallet-assets/std",
"pallet-asset-rate/std",
"pallet-authority-discovery/std",
"pallet-authorship/std",
Expand Down Expand Up @@ -240,6 +242,7 @@ runtime-benchmarks = [
"frame-support/runtime-benchmarks",
"frame-system-benchmarking/runtime-benchmarks",
"frame-system/runtime-benchmarks",
"pallet-assets/runtime-benchmarks",
"pallet-asset-rate/runtime-benchmarks",
"pallet-babe/runtime-benchmarks",
"pallet-bags-list/runtime-benchmarks",
Expand Down Expand Up @@ -303,6 +306,7 @@ try-runtime = [
"frame-system/try-runtime",
"frame-try-runtime",
"frame-try-runtime/try-runtime",
"pallet-assets/try-runtime",
"pallet-asset-rate/try-runtime",
"pallet-authority-discovery/try-runtime",
"pallet-authorship/try-runtime",
Expand Down
17 changes: 17 additions & 0 deletions polkadot/runtime/westend/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ use frame_support::{
weights::{ConstantMultiplier, WeightMeter},
PalletId,
};
use pallet_assets::AssetCategoryManager;
use frame_system::{EnsureRoot, EnsureSigned};
use pallet_grandpa::{fg_primitives, AuthorityId as GrandpaId};
use pallet_identity::legacy::IdentityInfo;
Expand Down Expand Up @@ -894,6 +895,21 @@ impl ah_client::SendToAssetHub for StakingXcmToAssetHub {
}
}

pub struct WestendAssetCategories;

impl AssetCategoryManager<AccountId> for WestendAssetCategories {
type AssetKind = VersionedLocatableAsset;
type Balance = Balance;

fn assets_in_category(_category: &[u8]) -> Vec<Self::AssetKind> {
vec![]
}

fn available_balance(_asset: Self::AssetKind, _owner: AccountId) -> Option<Self::Balance> {
None
}
}

impl ah_client::Config for Runtime {
type CurrencyBalance = Balance;
type AssetHubOrigin =
Expand Down Expand Up @@ -977,6 +993,7 @@ impl pallet_treasury::Config for Runtime {
>;
type PayoutPeriod = PayoutSpendPeriod;
type BlockNumberProvider = System;
type AssetCategories = WestendAssetCategories;
#[cfg(feature = "runtime-benchmarks")]
type BenchmarkHelper = polkadot_runtime_common::impls::benchmarks::TreasuryArguments;
}
Expand Down
28 changes: 27 additions & 1 deletion substrate/bin/node/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ use pallet_multi_asset_bounties::ArgumentsFactory as PalletMultiAssetBountiesArg
use pallet_treasury::ArgumentsFactory as PalletTreasuryArgumentsFactory;
#[cfg(feature = "runtime-benchmarks")]
use polkadot_sdk::sp_core::crypto::FromEntropy;

use crate::pallet_assets::AssetCategoryManager;
use polkadot_sdk::*;

use alloc::{vec, vec::Vec};
Expand Down Expand Up @@ -262,6 +262,31 @@ impl Contains<RuntimeCallNameOf<Runtime>> for TxPauseWhitelistedCalls {
}
}

pub struct CombinedAssetManager;

impl AssetCategoryManager<AccountId> for CombinedAssetManager {
type AssetKind = NativeOrWithId<u32>;
type Balance = Balance;

fn assets_in_category(category: &[u8]) -> Vec<Self::AssetKind> {
Assets::assets_in_category(category)
.into_iter()
.map(|asset_id| NativeOrWithId::WithId(asset_id))
.collect()
}

fn available_balance(asset: Self::AssetKind, owner: AccountId) -> Option<Self::Balance> {
match asset {
NativeOrWithId::Native => {
Some(Balances::free_balance(&owner))
}
NativeOrWithId::WithId(asset_id) => {
Assets::available_balance(asset_id, owner)
}
}
}
}

#[cfg(feature = "runtime-benchmarks")]
pub struct AssetRateArguments;
#[cfg(feature = "runtime-benchmarks")]
Expand Down Expand Up @@ -1328,6 +1353,7 @@ impl pallet_treasury::Config for Runtime {
type BalanceConverter = AssetRate;
type PayoutPeriod = SpendPayoutPeriod;
type BlockNumberProvider = System;
type AssetCategories = CombinedAssetManager;
#[cfg(feature = "runtime-benchmarks")]
type BenchmarkHelper = PalletTreasuryArguments;
}
Expand Down
Loading
Loading