Skip to content

Commit

Permalink
Fix compilation issue
Browse files Browse the repository at this point in the history
  • Loading branch information
valentinfernandez1 committed Dec 19, 2024
1 parent 357a777 commit 226beaa
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 25 deletions.
25 changes: 2 additions & 23 deletions runtime/common/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
#![cfg_attr(not(feature = "std"), no_std)]
use core::marker::PhantomData;
use frame_support::{
traits::fungible::{Inspect, Mutate},
weights::{constants::WEIGHT_REF_TIME_PER_SECOND, Weight},
};
use frame_support::weights::{constants::WEIGHT_REF_TIME_PER_SECOND, Weight};
use parity_scale_codec::{Decode, Encode, MaxEncodedLen};
use scale_info::TypeInfo;
use sp_core::{crypto::FromEntropy, U256};
use sp_core::U256;

use sp_runtime::{
traits::{IdentifyAccount, Verify},
Expand Down Expand Up @@ -82,20 +78,3 @@ impl From<u16> for IncrementableU256 {
IncrementableU256(U256::from(value))
}
}

pub struct TreasuryBenchmarkHelper<T>(PhantomData<T>);

#[cfg(feature = "runtime-benchmarks")]
impl<T> pallet_treasury::ArgumentsFactory<(), AccountId> for TreasuryBenchmarkHelper<T>
where
T: Mutate<AccountId> + Inspect<AccountId>,
{
fn create_asset_kind(_seed: u32) -> () {
()
}
fn create_beneficiary(seed: [u8; 32]) -> AccountId {
let account = AccountId::from_entropy(&mut seed.as_slice()).unwrap();
<T as Mutate<_>>::mint_into(&account, <T as Inspect<_>>::minimum_balance()).unwrap();
account
}
}
31 changes: 30 additions & 1 deletion runtime/mainnet/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,17 @@ use frame_support::traits::fungible::Balanced;
use frame_support::traits::{
fungible, AsEnsureOriginWithArg, InstanceFilter, OnUnbalanced, WithdrawReasons,
};

#[cfg(feature = "runtime-benchmarks")]
use pallet_treasury::ArgumentsFactory;
#[cfg(feature = "runtime-benchmarks")]
use sp_core::crypto::FromEntropy;

use parity_scale_codec::{Decode, Encode, MaxEncodedLen};
use runtime_common::TreasuryBenchmarkHelper;

use sp_api::impl_runtime_apis;
use sp_core::{crypto::KeyTypeId, ConstBool, OpaqueMetadata, H160};

use sp_runtime::{
create_runtime_str, generic, impl_opaque_keys,
traits::{BlakeTwo256, Block as BlockT, ConvertInto, IdentityLookup, Verify},
Expand Down Expand Up @@ -988,6 +995,28 @@ parameter_types! {
pub const SpendPayoutPeriod: BlockNumber = 30 * DAYS;
}

pub struct TreasuryBenchmarkHelper<T>(PhantomData<T>);

#[cfg(feature = "runtime-benchmarks")]

impl<T> ArgumentsFactory<(), AccountId> for TreasuryBenchmarkHelper<T>
where
T: fungible::Mutate<AccountId> + fungible::Inspect<AccountId>,
{
fn create_asset_kind(_seed: u32) -> () {
()
}
fn create_beneficiary(seed: [u8; 32]) -> AccountId {
let account = AccountId::from_entropy(&mut seed.as_slice()).unwrap();
<T as fungible::Mutate<_>>::mint_into(
&account,
<T as fungible::Inspect<_>>::minimum_balance(),
)
.unwrap();
account
}
}

impl pallet_treasury::Config for Runtime {
type Currency = Balances;
type RejectOrigin = EitherOfDiverse<
Expand Down
30 changes: 29 additions & 1 deletion runtime/testnet/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@ pub use fee::WeightToFee;

use cumulus_pallet_parachain_system::RelayNumberMonotonicallyIncreases;
use cumulus_primitives_core::{AggregateMessageOrigin, AssetId, ParaId};

#[cfg(feature = "runtime-benchmarks")]
use pallet_treasury::ArgumentsFactory;
#[cfg(feature = "runtime-benchmarks")]
use sp_core::crypto::FromEntropy;

use sp_api::impl_runtime_apis;
use sp_core::{crypto::KeyTypeId, ConstBool, OpaqueMetadata, H160};
use sp_runtime::{
Expand Down Expand Up @@ -74,7 +80,7 @@ use weights::{BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight};

// XCM Imports
use crate::xcm_config::SelfReserve;
use runtime_common::{AccountIdOf, TreasuryBenchmarkHelper};
use runtime_common::AccountIdOf;

/// The address format for describing accounts.
pub type Address = AccountId;
Expand Down Expand Up @@ -1005,6 +1011,28 @@ parameter_types! {
pub const SpendPayoutPeriod: BlockNumber = 7 * DAYS;
}

pub struct TreasuryBenchmarkHelper<T>(PhantomData<T>);

#[cfg(feature = "runtime-benchmarks")]

impl<T> ArgumentsFactory<(), AccountId> for TreasuryBenchmarkHelper<T>
where
T: fungible::Mutate<AccountId> + fungible::Inspect<AccountId>,
{
fn create_asset_kind(_seed: u32) -> () {
()
}
fn create_beneficiary(seed: [u8; 32]) -> AccountId {
let account = AccountId::from_entropy(&mut seed.as_slice()).unwrap();
<T as fungible::Mutate<_>>::mint_into(
&account,
<T as fungible::Inspect<_>>::minimum_balance(),
)
.unwrap();
account
}
}

impl pallet_treasury::Config for Runtime {
type Currency = Balances;
type RejectOrigin = EitherOfDiverse<
Expand Down

0 comments on commit 226beaa

Please sign in to comment.