From 1d190e525f2f1a2c843c5e592e7dbd35b613c0d7 Mon Sep 17 00:00:00 2001 From: giuseppere Date: Thu, 7 Nov 2024 16:25:17 +0100 Subject: [PATCH 1/3] Add pool accounts `view_function` --- substrate/frame/nomination-pools/src/lib.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/substrate/frame/nomination-pools/src/lib.rs b/substrate/frame/nomination-pools/src/lib.rs index 177c5da74d4f..231d00e62d8e 100644 --- a/substrate/frame/nomination-pools/src/lib.rs +++ b/substrate/frame/nomination-pools/src/lib.rs @@ -4072,3 +4072,13 @@ impl sp_staking::OnStakingUpdate> for Pall } } } + +#[pallet::view_functions] +impl Pallet { + /// Query value no args. + pub fn pool_accounts(pool_id: PoolId) -> (T::AccountId, T::AccountId) { + let bonded_account = Self::generate_bonded_account(pool_id); + let reward_account = Self::generate_reward_account(pool_id); + (bonded_account, reward_account) + } +} From b4f288849090070a920e40a38ff3a9b4e32a1bda Mon Sep 17 00:00:00 2001 From: giuseppere Date: Thu, 7 Nov 2024 16:29:44 +0100 Subject: [PATCH 2/3] fix docs --- substrate/frame/nomination-pools/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/substrate/frame/nomination-pools/src/lib.rs b/substrate/frame/nomination-pools/src/lib.rs index 231d00e62d8e..39dc12b21e07 100644 --- a/substrate/frame/nomination-pools/src/lib.rs +++ b/substrate/frame/nomination-pools/src/lib.rs @@ -4075,7 +4075,7 @@ impl sp_staking::OnStakingUpdate> for Pall #[pallet::view_functions] impl Pallet { - /// Query value no args. + /// Provide bonded account and reward account for nomination pool. pub fn pool_accounts(pool_id: PoolId) -> (T::AccountId, T::AccountId) { let bonded_account = Self::generate_bonded_account(pool_id); let reward_account = Self::generate_reward_account(pool_id); From a3abe0c1ae01c7b8dc6e8d5eab9521738baf9374 Mon Sep 17 00:00:00 2001 From: giuseppere Date: Fri, 20 Dec 2024 17:44:04 +0100 Subject: [PATCH 3/3] put view function inside pallet --- substrate/frame/nomination-pools/src/lib.rs | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/substrate/frame/nomination-pools/src/lib.rs b/substrate/frame/nomination-pools/src/lib.rs index 39dc12b21e07..732282ea95a0 100644 --- a/substrate/frame/nomination-pools/src/lib.rs +++ b/substrate/frame/nomination-pools/src/lib.rs @@ -1740,6 +1740,16 @@ pub mod pallet { pub type ClaimPermissions = StorageMap<_, Twox64Concat, T::AccountId, ClaimPermission, ValueQuery>; + #[pallet::view_functions] + impl Pallet { + /// Provide bonded account and reward account for nomination pool. + pub fn pool_accountss(pool_id: PoolId) -> (T::AccountId, T::AccountId) { + let bonded_account = Self::generate_bonded_account(pool_id); + let reward_account = Self::generate_reward_account(pool_id); + (bonded_account, reward_account) + } + } + #[pallet::genesis_config] pub struct GenesisConfig { pub min_join_bond: BalanceOf, @@ -4072,13 +4082,3 @@ impl sp_staking::OnStakingUpdate> for Pall } } } - -#[pallet::view_functions] -impl Pallet { - /// Provide bonded account and reward account for nomination pool. - pub fn pool_accounts(pool_id: PoolId) -> (T::AccountId, T::AccountId) { - let bonded_account = Self::generate_bonded_account(pool_id); - let reward_account = Self::generate_reward_account(pool_id); - (bonded_account, reward_account) - } -}