Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
82 commits
Select commit Hold shift + click to select a range
078c674
Move XCM query functionality to trait
franciscoaguirre Mar 16, 2023
2b32e5f
Fix tests
franciscoaguirre Mar 16, 2023
1981d4b
Merge remote-tracking branch 'origin/master' into cisco-xcm-query-han…
Mar 21, 2023
191c627
Add PayOverXcm implementation
franciscoaguirre Mar 21, 2023
34f61a2
fix the PayOverXcm trait to compile
tonyalaribe Mar 22, 2023
43699cf
moved doc comment out of trait implmeentation and to the trait
tonyalaribe Mar 22, 2023
a5d6004
PayOverXCM documentation
tonyalaribe Mar 22, 2023
32717a6
Change documentation a bit
franciscoaguirre Mar 22, 2023
192f9ef
Added empty benchmark methods implementation and changed docs
franciscoaguirre Mar 22, 2023
55451e6
update PayOverXCM to convert AccountIds to MultiLocations
tonyalaribe Mar 23, 2023
fb264f5
Implement benchmarking method
franciscoaguirre Mar 24, 2023
523ce24
Change v3 to latest
franciscoaguirre Mar 24, 2023
a364f1c
Descend origin to an asset sender (#6970)
muharem Mar 29, 2023
5a786d5
Add more variants to the QueryResponseStatus enum
franciscoaguirre Mar 30, 2023
5d045ac
Merge remote-tracking branch 'origin/master' into cisco-xcm-query-han…
Apr 4, 2023
ca7bc2a
Change Beneficiary to Into<[u8; 32]>
franciscoaguirre Apr 4, 2023
005c54b
Merge remote-tracking branch 'origin/master' into cisco-xcm-query-han…
Apr 12, 2023
fd00d14
update PayOverXcm to return concrete errors and use AccountId as sender
tonyalaribe Apr 20, 2023
f4c5bd7
companion for #13607
tonyalaribe Apr 11, 2023
59b7692
Merge remote-tracking branch 'origin/master' into cisco-xcm-query-han…
Apr 21, 2023
4a57b20
use polkadot-primitives for AccountId
tonyalaribe Apr 21, 2023
7505c4a
Merge remote-tracking branch 'origin/cisco-xcm-query-handler' into aa…
Apr 21, 2023
a7887a9
AccountId32Aliases should support accounts on the relay chain
tonyalaribe Apr 21, 2023
3794e53
cargo fmt
tonyalaribe Apr 21, 2023
3ca5292
Move XCM query functionality to trait
franciscoaguirre Mar 16, 2023
d136364
Fix tests
franciscoaguirre Mar 16, 2023
2529aff
Add PayOverXcm implementation
franciscoaguirre Mar 21, 2023
e6102f6
fix the PayOverXcm trait to compile
tonyalaribe Mar 22, 2023
20f9e1f
moved doc comment out of trait implmeentation and to the trait
tonyalaribe Mar 22, 2023
1a31c92
PayOverXCM documentation
tonyalaribe Mar 22, 2023
4030f14
Change documentation a bit
franciscoaguirre Mar 22, 2023
6d2a686
Added empty benchmark methods implementation and changed docs
franciscoaguirre Mar 22, 2023
1331aa5
update PayOverXCM to convert AccountIds to MultiLocations
tonyalaribe Mar 23, 2023
117c169
Implement benchmarking method
franciscoaguirre Mar 24, 2023
94a30c8
Change v3 to latest
franciscoaguirre Mar 24, 2023
6c0dece
Descend origin to an asset sender (#6970)
muharem Mar 29, 2023
ec24eba
Add more variants to the QueryResponseStatus enum
franciscoaguirre Mar 30, 2023
6aa7b20
Change Beneficiary to Into<[u8; 32]>
franciscoaguirre Apr 4, 2023
41fe1d8
update PayOverXcm to return concrete errors and use AccountId as sender
tonyalaribe Apr 20, 2023
13ceb40
use polkadot-primitives for AccountId
tonyalaribe Apr 21, 2023
9df80ea
fix dependency to use polkadot-core-primitives
tonyalaribe Apr 21, 2023
437f8ee
Merge branch 'cisco-xcm-query-handler' into aa/multi-asset-treasury-o…
tonyalaribe Apr 21, 2023
175330b
remove unneeded kusama imports
tonyalaribe Apr 21, 2023
615f0fd
cleanup Cargo.llock
tonyalaribe Apr 21, 2023
7102236
add benchmark helper to treasury impls and use PayFromAccount in trea…
tonyalaribe Apr 21, 2023
59b884c
force Unpaid instruction to the top of the instructions list
tonyalaribe Apr 25, 2023
3a8e9d8
Merge remote-tracking branch 'origin/cisco-xcm-query-handler' into aa…
Apr 25, 2023
093ae73
add benchmark helper to runtimes
tonyalaribe Apr 25, 2023
18febf9
explicit import for BenchmarkHelper
tonyalaribe Apr 25, 2023
49276c1
use multilocation for BenchmarkHelper
tonyalaribe Apr 25, 2023
31d3e1d
modify report_outcome to accept interior argument
tonyalaribe Apr 26, 2023
1de5716
Merge remote-tracking branch 'origin/cisco-xcm-query-handler' into aa…
Apr 26, 2023
918d62e
use new_query directly for building final xcm query, instead of repor…
tonyalaribe Apr 28, 2023
73db7b0
Merge remote-tracking branch 'origin/cisco-xcm-query-handler' into aa…
Apr 28, 2023
97d05d0
fix usage of new_query to use the XcmQueryHandler
tonyalaribe Apr 28, 2023
9cbda1d
Merge remote-tracking branch 'origin/cisco-xcm-query-handler' into aa…
Apr 28, 2023
2465cc4
fix usage of new_query to use the XcmQueryHandler
tonyalaribe Apr 28, 2023
411a8f2
Merge remote-tracking branch 'origin/cisco-xcm-query-handler' into aa…
Apr 28, 2023
a524d26
tiny method calling fix
tonyalaribe Apr 28, 2023
bd8ec85
Merge remote-tracking branch 'origin/cisco-xcm-query-handler' into aa…
Apr 28, 2023
feed38e
Merge branch 'master' into cisco-xcm-query-handler
tonyalaribe May 5, 2023
aebf573
Merge remote-tracking branch 'origin/cisco-xcm-query-handler' into aa…
May 5, 2023
f4c8222
full paths for imports in runtime-benchmarks
tonyalaribe May 5, 2023
8e86156
remove unneeded import
tonyalaribe May 5, 2023
d77abe4
fix a test using wrong BenchmarkHelper for runtime-benchmarks
tonyalaribe May 5, 2023
da915c2
reintroduce JunctionsBenchmarkHelper
tonyalaribe May 5, 2023
dd48670
add imports for XcmQueryHandler in pallet-xcm mock
tonyalaribe May 5, 2023
b8d01d6
direct XcmQueryHandler Import
tonyalaribe May 5, 2023
1554212
direct XcmQueryHandler Import
tonyalaribe May 5, 2023
ad737c1
remove commited debug logs
tonyalaribe May 5, 2023
70c7b2e
Update lib.rs
tonyalaribe May 5, 2023
8ae3a99
xcm query handler (#7198)
muharem May 10, 2023
3ee49cd
Update xcm/xcm-builder/src/pay.rs
tonyalaribe May 26, 2023
00cb2d2
Updates
gavofyork May 29, 2023
a309627
Merge remote-tracking branch 'origin/master' into cisco-xcm-query-han…
gavofyork May 29, 2023
a42c9e3
Docs
gavofyork May 29, 2023
3b38fa1
Fix benchmarking stuff
gavofyork May 29, 2023
3bedbab
Destination can be determined based on asset_kind
gavofyork May 30, 2023
9a28a2a
Tweaking API to minimise clones
gavofyork May 30, 2023
e4419d0
Merge branch 'cisco-xcm-query-handler' into aa/multi-asset-treasury-o…
tonyalaribe May 30, 2023
9b274c1
testing against runtimes
tonyalaribe May 30, 2023
45d92f3
useing new pay over xcm
tonyalaribe May 31, 2023
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
601 changes: 391 additions & 210 deletions Cargo.lock

Large diffs are not rendered by default.

260 changes: 260 additions & 0 deletions Cargo.toml

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion parachain/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ sp-core = { git = "https://github.com/paritytech/substrate", branch = "master",
frame-support = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
polkadot-core-primitives = { path = "../core-primitives", default-features = false }
derive_more = "0.99.11"
bounded-collections = { version = "0.1.5", default-features = false }
bounded-collections = { version = "0.1.7", default-features = false }

# all optional crates.
serde = { version = "1.0.137", default-features = false, features = [ "derive" ], optional = true }
Expand Down
21 changes: 19 additions & 2 deletions runtime/common/src/impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,17 @@ where
}
}

#[cfg(feature = "runtime-benchmarks")]
pub struct JunctionsBenchmarkHelper;
#[cfg(feature = "runtime-benchmarks")]
impl<AssetKind: From<xcm::latest::MultiLocation>> pallet_treasury::BenchmarkHelper<AssetKind>
for JunctionsBenchmarkHelper
{
fn create_asset_kind(_id: u32) -> AssetKind {
xcm::latest::Junctions::Here.into_location().into()
}
}

pub fn era_payout(
total_staked: Balance,
total_stakable: Balance,
Expand Down Expand Up @@ -104,7 +115,7 @@ mod tests {
use frame_support::{
dispatch::DispatchClass,
parameter_types,
traits::{ConstU32, FindAuthor},
traits::{tokens::PayFromAccount, ConstU32, FindAuthor},
weights::Weight,
PalletId,
};
Expand Down Expand Up @@ -195,9 +206,14 @@ mod tests {
parameter_types! {
pub const TreasuryPalletId: PalletId = PalletId(*b"py/trsry");
pub const MaxApprovals: u32 = 100;
pub TreasuryAccount: AccountId = Treasury::account_id();
}

impl pallet_treasury::Config for Test {
type PalletId = TreasuryPalletId;
type AssetKind = ();
type Paymaster = PayFromAccount<Balances, TreasuryAccount>;
type BalanceConverter = ();
type Currency = pallet_balances::Pallet<Test>;
type ApproveOrigin = frame_system::EnsureRoot<AccountId>;
type RejectOrigin = frame_system::EnsureRoot<AccountId>;
Expand All @@ -209,11 +225,12 @@ mod tests {
type SpendPeriod = ();
type Burn = ();
type BurnDestination = ();
type PalletId = TreasuryPalletId;
type SpendFunds = ();
type MaxApprovals = MaxApprovals;
type WeightInfo = ();
type SpendOrigin = frame_support::traits::NeverEnsureOrigin<u64>;
#[cfg(feature = "runtime-benchmarks")]
type BenchmarkHelper = pallet_treasury::NilBenchmarkHelper;
}

pub struct OneAuthor;
Expand Down
81 changes: 76 additions & 5 deletions runtime/kusama/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,10 @@ use frame_election_provider_support::{
generate_solution_type, onchain, NposSolution, SequentialPhragmen,
};
use frame_support::{
construct_runtime, parameter_types,
construct_runtime, ord_parameter_types, parameter_types,
traits::{
ConstU32, Contains, EitherOf, EitherOfDiverse, InstanceFilter, KeyOwnerProofSystem,
PrivilegeCmp, ProcessMessage, ProcessMessageError, StorageMapShim, WithdrawReasons,
tokens::ConversionFromAssetBalance, ConstU32, Contains, EitherOf, EitherOfDiverse,
InstanceFilter, KeyOwnerProofSystem, PrivilegeCmp,ProcessMessage, ProcessMessageError, StorageMapShim, WithdrawReasons,
},
weights::{ConstantMultiplier, WeightMeter},
PalletId, RuntimeDebug,
Expand All @@ -73,8 +73,8 @@ use sp_mmr_primitives as mmr;
use sp_runtime::{
create_runtime_str, generic, impl_opaque_keys,
traits::{
AccountIdLookup, BlakeTwo256, Block as BlockT, ConvertInto, Extrinsic as ExtrinsicT,
OpaqueKeys, SaturatedConversion, Verify,
AccountIdConversion, AccountIdLookup, BlakeTwo256, Block as BlockT, ConvertInto,
Extrinsic as ExtrinsicT, OpaqueKeys, SaturatedConversion, Verify,
},
transaction_validity::{TransactionPriority, TransactionSource, TransactionValidity},
ApplyExtrinsicResult, FixedU128, KeyTypeId, Perbill, Percent, Permill,
Expand All @@ -97,6 +97,7 @@ pub use sp_runtime::BuildStorage;

/// Constant values used within the runtime.
use kusama_runtime_constants::{currency::*, fee::*, time::*};
use xcm::v3::{AssetId, Fungibility};

// Weights used in the runtime.
mod weights;
Expand All @@ -109,10 +110,12 @@ pub mod xcm_config;

// Governance configurations.
pub mod governance;
use crate::xcm_config::Statemine;
use governance::{
pallet_custom_origins, AuctionAdmin, Fellows, GeneralAdmin, LeaseAdmin, StakingAdmin,
Treasurer, TreasurySpender,
};
use xcm_builder::{HasDestination, PayOverXcm};

#[cfg(test)]
mod tests;
Expand Down Expand Up @@ -619,10 +622,75 @@ parameter_types! {
pub const MaxKeys: u32 = 10_000;
pub const MaxPeerInHeartbeats: u32 = 10_000;
pub const MaxPeerDataEncodingSize: u32 = 1_000;
// PayOverXcmTimeout is set to 3 x the spend period to provide buffer before status messages
// are deleted from storage
pub const PayOverXcmTimeout: BlockNumber = 6 * 3 * DAYS;
}

ord_parameter_types! {
pub const TreasuryAccountId: AccountId = AccountIdConversion::<AccountId>::into_account_truncating(&TreasuryPalletId::get());
}

#[derive(Encode, Decode, Clone, Copy, PartialEq, Eq, MaxEncodedLen, RuntimeDebug, TypeInfo)]
pub struct AssetKind<AssetId> {
destination: xcm::latest::MultiLocation,
asset_id: AssetId,
amount: Fungibility,
}

impl From<AssetKind<AssetId>> for xcm::latest::AssetId {
fn from(item: AssetKind<AssetId>) -> Self {
item.asset_id
}
}

impl HasDestination for AssetKind<AssetId> {
fn destination(&self) -> xcm::latest::MultiLocation {
self.destination
}
}

impl pallet_treasury::Asset<AssetKind<xcm::v3::AssetId>, xcm::v3::Fungibility>
for AssetKind<AssetId>
{
fn asset_kind(&self) -> Self {
*self
}
fn amount(&self) -> xcm::v3::Fungibility {
self.amount
}
}

pub struct FungibleBalanceConverter;
impl<AssetId, OutBalance: core::convert::From<u128>>
ConversionFromAssetBalance<Fungibility, AssetId, OutBalance> for FungibleBalanceConverter
{
type Error = ();
fn from_asset_balance(
balance: Fungibility,
_asset_id: AssetId,
) -> Result<OutBalance, Self::Error> {
match balance {
Fungibility::Fungible(b) => Ok(b.into()),
Fungibility::NonFungible(_) => Ok(0.into()),
}
}
}

impl pallet_treasury::Config for Runtime {
type PalletId = TreasuryPalletId;
type AssetId = AssetKind<AssetId>;
type AssetKind = AssetKind<AssetId>;
// type AssetKind = MultiAsset;
type Paymaster = PayOverXcm<
TreasuryAccountId,
xcm_config::XcmRouter,
XcmPallet,
PayOverXcmTimeout,
Self::AccountId,
Self::AssetKind,
>;
type BalanceConverter = FungibleBalanceConverter;
type Currency = Balances;
type ApproveOrigin = EitherOfDiverse<EnsureRoot<AccountId>, Treasurer>;
type RejectOrigin = EitherOfDiverse<EnsureRoot<AccountId>, Treasurer>;
Expand All @@ -638,6 +706,9 @@ impl pallet_treasury::Config for Runtime {
type WeightInfo = weights::pallet_treasury::WeightInfo<Runtime>;
type SpendFunds = Bounties;
type SpendOrigin = TreasurySpender;
type MaxPaymentRetries = ConstU32<5>;
#[cfg(feature = "runtime-benchmarks")]
type BenchmarkHelper = runtime_common::impls::JunctionsBenchmarkHelper;
}

parameter_types! {
Expand Down
44 changes: 44 additions & 0 deletions runtime/kusama/src/weights/pallet_treasury.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,22 @@ impl<T: frame_system::Config> pallet_treasury::WeightInfo for WeightInfo<T> {
}
/// Storage: Treasury ProposalCount (r:1 w:1)
/// Proof: Treasury ProposalCount (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen)
/// Storage: Treasury Approvals (r:1 w:1)
/// Proof: Treasury Approvals (max_values: Some(1), max_size: Some(402), added: 897, mode: MaxEncodedLen)
/// Storage: Treasury Proposals (r:0 w:1)
/// Proof: Treasury Proposals (max_values: None, max_size: Some(108), added: 2583, mode: MaxEncodedLen)
fn spend_local() -> Weight {
// Proof Size summary in bytes:
// Measured: `6`
// Estimated: `3376`
// Minimum execution time: 14_516_000 picoseconds.
Weight::from_parts(14_898_000, 0)
.saturating_add(Weight::from_parts(0, 3376))
.saturating_add(T::DbWeight::get().reads(2))
.saturating_add(T::DbWeight::get().writes(3))
}
/// Storage: Treasury ProposalCount (r:1 w:1)
/// Proof: Treasury ProposalCount (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen)
/// Storage: Treasury Proposals (r:0 w:1)
/// Proof: Treasury Proposals (max_values: None, max_size: Some(108), added: 2583, mode: MaxEncodedLen)
fn propose_spend() -> Weight {
Expand Down Expand Up @@ -148,4 +164,32 @@ impl<T: frame_system::Config> pallet_treasury::WeightInfo for WeightInfo<T> {
.saturating_add(T::DbWeight::get().writes((3_u64).saturating_mul(p.into())))
.saturating_add(Weight::from_parts(0, 5206).saturating_mul(p.into()))
}
/// Storage: Treasury Deactivated (r:1 w:1)
/// Proof: Treasury Deactivated (max_values: Some(1), max_size: Some(16), added: 511, mode: MaxEncodedLen)
/// Storage: Balances InactiveIssuance (r:1 w:1)
/// Proof: Balances InactiveIssuance (max_values: Some(1), max_size: Some(16), added: 511, mode: MaxEncodedLen)
/// Storage: Treasury Approvals (r:1 w:1)
/// Proof: Treasury Approvals (max_values: Some(1), max_size: Some(402), added: 897, mode: MaxEncodedLen)
/// Storage: Treasury Proposals (r:100 w:100)
/// Proof: Treasury Proposals (max_values: None, max_size: Some(108), added: 2583, mode: MaxEncodedLen)
/// Storage: System Account (r:201 w:201)
/// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen)
/// Storage: Bounties BountyApprovals (r:1 w:1)
/// Proof: Bounties BountyApprovals (max_values: Some(1), max_size: Some(402), added: 897, mode: MaxEncodedLen)
/// The range of component `p` is `[0, 100]`.
fn on_initialize_pending_payments(p: u32, ) -> Weight {
// Proof Size summary in bytes:
// Measured: `297 + p * (251 ±0)`
// Estimated: `11359 + p * (7789 ±0)`
// Minimum execution time: 57_179_000 picoseconds.
Weight::from_parts(61_547_634, 0)
.saturating_add(Weight::from_parts(0, 11359))
// Standard Error: 30_382
.saturating_add(Weight::from_parts(32_012_031, 0).saturating_mul(p.into()))
.saturating_add(T::DbWeight::get().reads(5))
.saturating_add(T::DbWeight::get().reads((3_u64).saturating_mul(p.into())))
.saturating_add(T::DbWeight::get().writes(5))
.saturating_add(T::DbWeight::get().writes((3_u64).saturating_mul(p.into())))
.saturating_add(Weight::from_parts(0, 7789).saturating_mul(p.into()))
}
}
82 changes: 76 additions & 6 deletions runtime/polkadot/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,17 @@ use runtime_parachains::{
scheduler as parachains_scheduler, session_info as parachains_session_info,
shared as parachains_shared,
};
use scale_info::TypeInfo;

use crate::xcm_config::Statemint;
use authority_discovery_primitives::AuthorityId as AuthorityDiscoveryId;
use beefy_primitives::crypto::{AuthorityId as BeefyId, Signature as BeefySignature};
use frame_election_provider_support::{generate_solution_type, onchain, SequentialPhragmen};
use frame_support::{
construct_runtime, parameter_types,
construct_runtime, ord_parameter_types, parameter_types,
traits::{
ConstU32, EitherOf, EitherOfDiverse, InstanceFilter, KeyOwnerProofSystem, LockIdentifier,
PrivilegeCmp, ProcessMessage, ProcessMessageError, WithdrawReasons,
tokens::ConversionFromAssetBalance, ConstU32, EitherOf, EitherOfDiverse, InstanceFilter,
KeyOwnerProofSystem, LockIdentifier, PrivilegeCmp, ProcessMessage, ProcessMessageError, WithdrawReasons,
},
weights::{ConstantMultiplier, WeightMeter},
PalletId, RuntimeDebug,
Expand All @@ -70,8 +72,8 @@ use sp_runtime::{
curve::PiecewiseLinear,
generic, impl_opaque_keys,
traits::{
AccountIdLookup, BlakeTwo256, Block as BlockT, ConvertInto, Extrinsic as ExtrinsicT,
OpaqueKeys, SaturatedConversion, Verify,
AccountIdConversion, AccountIdLookup, BlakeTwo256, Block as BlockT, ConvertInto,
Extrinsic as ExtrinsicT, OpaqueKeys, SaturatedConversion, Verify,
},
transaction_validity::{TransactionPriority, TransactionSource, TransactionValidity},
ApplyExtrinsicResult, FixedU128, KeyTypeId, Perbill, Percent, Permill,
Expand All @@ -82,7 +84,7 @@ use sp_std::{cmp::Ordering, collections::btree_map::BTreeMap, prelude::*};
use sp_version::NativeVersion;
use sp_version::RuntimeVersion;
use static_assertions::const_assert;
use xcm::latest::Junction;
use xcm::{latest::{AssetId, Junction}, v3::Fungibility};

pub use frame_system::Call as SystemCall;
pub use pallet_balances::Call as BalancesCall;
Expand All @@ -109,6 +111,7 @@ use governance::{
old::CouncilCollective, pallet_custom_origins, AuctionAdmin, FellowshipAdmin, GeneralAdmin,
LeaseAdmin, StakingAdmin, Treasurer, TreasurySpender,
};
use xcm_builder::{HasDestination, PayOverXcm};

pub mod xcm_config;

Expand Down Expand Up @@ -657,10 +660,74 @@ parameter_types! {
pub const MaxPeerDataEncodingSize: u32 = 1_000;
pub const RootSpendOriginMaxAmount: Balance = Balance::MAX;
pub const CouncilSpendOriginMaxAmount: Balance = Balance::MAX;
// PayOverXcmTimeout is set to 3 x the spend period to provide buffer before status messages
// are deleted from storage
pub const PayOverXcmTimeout: BlockNumber = 6 * 3 * DAYS;
}

ord_parameter_types! {
pub const TreasuryAccountId: AccountId = AccountIdConversion::<AccountId>::into_account_truncating(&TreasuryPalletId::get());
}

#[derive(Encode, Decode, Clone, Copy, PartialEq, Eq, MaxEncodedLen, RuntimeDebug, TypeInfo)]
pub struct AssetKind<AssetId> {
destination: xcm::latest::MultiLocation,
asset_id: AssetId,
amount: Fungibility,
}

impl From<AssetKind<AssetId>> for xcm::latest::AssetId {
fn from(item: AssetKind<AssetId>) -> Self {
item.asset_id
}
}

impl HasDestination for AssetKind<AssetId> {
fn destination(&self) -> xcm::latest::MultiLocation {
self.destination
}
}

impl pallet_treasury::Asset<AssetKind<xcm::v3::AssetId>, xcm::v3::Fungibility>
for AssetKind<AssetId>
{
fn asset_kind(&self) -> Self {
*self
}
fn amount(&self) -> xcm::v3::Fungibility {
self.amount
}
}

pub struct FungibleBalanceConverter;
impl<AssetId, OutBalance: core::convert::From<u128>>
ConversionFromAssetBalance<Fungibility, AssetId, OutBalance> for FungibleBalanceConverter
{
type Error = ();
fn from_asset_balance(
balance: Fungibility,
_asset_id: AssetId,
) -> Result<OutBalance, Self::Error> {
match balance {
Fungibility::Fungible(b) => Ok(b.into()),
Fungibility::NonFungible(_) => Ok(0.into()),
}
}
}
impl pallet_treasury::Config for Runtime {
type PalletId = TreasuryPalletId;
type AssetId = AssetKind<AssetId>;
type AssetKind = AssetKind<AssetId>;
// type AssetKind = MultiAsset;
type Paymaster = PayOverXcm<
TreasuryAccountId,
xcm_config::XcmRouter,
XcmPallet,
PayOverXcmTimeout,
Self::AccountId,
Self::AssetKind,
>;
type BalanceConverter = FungibleBalanceConverter;
type Currency = Balances;
type ApproveOrigin = EitherOfDiverse<EnsureRoot<AccountId>, Treasurer>;
type RejectOrigin = EitherOfDiverse<EnsureRoot<AccountId>, Treasurer>;
Expand All @@ -676,6 +743,9 @@ impl pallet_treasury::Config for Runtime {
type MaxApprovals = MaxApprovals;
type WeightInfo = weights::pallet_treasury::WeightInfo<Runtime>;
type SpendOrigin = TreasurySpender;
type MaxPaymentRetries = ConstU32<5>;
#[cfg(feature = "runtime-benchmarks")]
type BenchmarkHelper = runtime_common::impls::JunctionsBenchmarkHelper;
}

parameter_types! {
Expand Down
Loading