Skip to content

Commit

Permalink
fix up merge
Browse files Browse the repository at this point in the history
  • Loading branch information
pgherveou committed Jan 16, 2025
1 parent 3fbcaed commit ce2ff1e
Showing 1 changed file with 72 additions and 5 deletions.
77 changes: 72 additions & 5 deletions substrate/bin/node/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,10 @@ use frame_support::{
imbalance::ResolveAssetTo, nonfungibles_v2::Inspect, pay::PayAssetFromAccount,
GetSalary, PayFromAccount,
},
AsEnsureOriginWithArg, ConstBool, ConstU128, ConstU16, ConstU32, ConstU64, Contains,
Currency, EitherOfDiverse, EnsureOriginWithArg, EqualPrivilegeOnly, Imbalance, InsideBoth,
InstanceFilter, KeyOwnerProofSystem, LinearStoragePrice, LockIdentifier, Nothing,
OnUnbalanced, VariantCountOf, WithdrawReasons,
AsEnsureOriginWithArg, ConstBool, ConstU128, ConstU16, ConstU32, ConstU64,
ConstantStoragePrice, Contains, Currency, EitherOfDiverse, EnsureOriginWithArg,
EqualPrivilegeOnly, Imbalance, InsideBoth, InstanceFilter, KeyOwnerProofSystem,
LinearStoragePrice, LockIdentifier, Nothing, OnUnbalanced, VariantCountOf, WithdrawReasons,
},
weights::{
constants::{
Expand Down Expand Up @@ -511,7 +511,8 @@ impl pallet_glutton::Config for Runtime {
}

parameter_types! {
pub const PreimageHoldReason: RuntimeHoldReason = RuntimeHoldReason::Preimage(pallet_preimage::HoldReason::Preimage);
pub const PreimageHoldReason: RuntimeHoldReason =
RuntimeHoldReason::Preimage(pallet_preimage::HoldReason::Preimage);
}

impl pallet_preimage::Config for Runtime {
Expand Down Expand Up @@ -618,6 +619,12 @@ impl pallet_transaction_payment::Config for Runtime {
type WeightInfo = pallet_transaction_payment::weights::SubstrateWeight<Runtime>;
}

pub type AssetsFreezerInstance = pallet_assets_freezer::Instance1;
impl pallet_assets_freezer::Config<AssetsFreezerInstance> for Runtime {
type RuntimeFreezeReason = RuntimeFreezeReason;
type RuntimeEvent = RuntimeEvent;
}

impl pallet_asset_conversion_tx_payment::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
type AssetId = NativeOrWithId<u32>;
Expand Down Expand Up @@ -1858,6 +1865,53 @@ impl pallet_asset_conversion::Config for Runtime {
type BenchmarkHelper = ();
}

pub type NativeAndAssetsFreezer =
UnionOf<Balances, AssetsFreezer, NativeFromLeft, NativeOrWithId<u32>, AccountId>;

/// Benchmark Helper
#[cfg(feature = "runtime-benchmarks")]
pub struct AssetRewardsBenchmarkHelper;

#[cfg(feature = "runtime-benchmarks")]
impl pallet_asset_rewards::benchmarking::BenchmarkHelper<NativeOrWithId<u32>>
for AssetRewardsBenchmarkHelper
{
fn staked_asset() -> NativeOrWithId<u32> {
NativeOrWithId::<u32>::WithId(100)
}
fn reward_asset() -> NativeOrWithId<u32> {
NativeOrWithId::<u32>::WithId(101)
}
}

parameter_types! {
pub const StakingRewardsPalletId: PalletId = PalletId(*b"py/stkrd");
pub const CreationHoldReason: RuntimeHoldReason =
RuntimeHoldReason::AssetRewards(pallet_asset_rewards::HoldReason::PoolCreation);
// 1 item, 135 bytes into the storage on pool creation.
pub const StakePoolCreationDeposit: Balance = deposit(1, 135);
}

impl pallet_asset_rewards::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
type RuntimeFreezeReason = RuntimeFreezeReason;
type AssetId = NativeOrWithId<u32>;
type Balance = Balance;
type Assets = NativeAndAssets;
type PalletId = StakingRewardsPalletId;
type CreatePoolOrigin = EnsureSigned<AccountId>;
type WeightInfo = ();
type AssetsFreezer = NativeAndAssetsFreezer;
type Consideration = HoldConsideration<
AccountId,
Balances,
CreationHoldReason,
ConstantStoragePrice<StakePoolCreationDeposit, Balance>,
>;
#[cfg(feature = "runtime-benchmarks")]
type BenchmarkHelper = AssetRewardsBenchmarkHelper;
}

impl pallet_asset_conversion_ops::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
type PriorAccountIdConverter = pallet_asset_conversion::AccountIdConverterNoSeed<(
Expand Down Expand Up @@ -2636,6 +2690,12 @@ mod runtime {

#[runtime::pallet_index(81)]
pub type VerifySignature = pallet_verify_signature::Pallet<Runtime>;

#[runtime::pallet_index(83)]
pub type AssetRewards = pallet_asset_rewards::Pallet<Runtime>;

#[runtime::pallet_index(84)]
pub type AssetsFreezer = pallet_assets_freezer::Pallet<Runtime, Instance1>;
}

impl TryFrom<RuntimeCall> for pallet_revive::Call<Runtime> {
Expand Down Expand Up @@ -2846,6 +2906,7 @@ mod benches {
[pallet_example_tasks, TasksExample]
[pallet_democracy, Democracy]
[pallet_asset_conversion, AssetConversion]
[pallet_asset_rewards, AssetRewards]
[pallet_asset_conversion_tx_payment, AssetConversionTxPayment]
[pallet_transaction_payment, TransactionPayment]
[pallet_election_provider_multi_phase, ElectionProviderMultiPhase]
Expand Down Expand Up @@ -3601,6 +3662,12 @@ impl_runtime_apis! {
}
}

impl pallet_asset_rewards::AssetRewards<Block, Balance> for Runtime {
fn pool_creation_cost() -> Balance {
StakePoolCreationDeposit::get()
}
}

#[cfg(feature = "try-runtime")]
impl frame_try_runtime::TryRuntime<Block> for Runtime {
fn on_runtime_upgrade(checks: frame_try_runtime::UpgradeCheckSelect) -> (Weight, Weight) {
Expand Down

0 comments on commit ce2ff1e

Please sign in to comment.