From 38d2fa859861005157ccb249dca1378f015e0b06 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Molina=20Colmenero?= <jose@blockdeep.io> Date: Mon, 17 Mar 2025 03:30:50 +0100 Subject: [PATCH] Add an extra_constant to pallet-treasury (#7918) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Aligned with #7206, this PR exposes `pallet-treasury`'s pot account as an extra constant. Users can this way for instance donate to the chain's treasury account, or founders can easily spot it in case they require to fund it. In any case this greatly reduces errors and headaches trying to figure out what's the pot's address. --------- Co-authored-by: Bastian Köcher <git@kchr.de> Co-authored-by: Guillaume Thiolliere <gui.thiolliere@gmail.com> --- prdoc/pr_7918.prdoc | 13 +++++++++++++ substrate/frame/treasury/src/lib.rs | 8 ++++++++ 2 files changed, 21 insertions(+) create mode 100644 prdoc/pr_7918.prdoc diff --git a/prdoc/pr_7918.prdoc b/prdoc/pr_7918.prdoc new file mode 100644 index 00000000000..d770865c2eb --- /dev/null +++ b/prdoc/pr_7918.prdoc @@ -0,0 +1,13 @@ +# Schema: Polkadot SDK PRDoc Schema (prdoc) v1.0.0 +# See doc at https://raw.githubusercontent.com/paritytech/polkadot-sdk/master/prdoc/schema_user.json + +title: "Add an extra_constant to pallet-treasury" + +doc: + - audience: Runtime Dev + description: | + - Allows to query pallet-treasury's pot account via extra constant. + +crates: + - name: pallet-treasury + bump: minor diff --git a/substrate/frame/treasury/src/lib.rs b/substrate/frame/treasury/src/lib.rs index 0f1897872cc..2a4f49fd5b3 100644 --- a/substrate/frame/treasury/src/lib.rs +++ b/substrate/frame/treasury/src/lib.rs @@ -289,6 +289,14 @@ pub mod pallet { type BlockNumberProvider: BlockNumberProvider; } + #[pallet::extra_constants] + impl<T: Config<I>, I: 'static> Pallet<T, I> { + /// Gets this pallet's derived pot account. + fn pot_account() -> T::AccountId { + Self::account_id() + } + } + /// DEPRECATED: associated with `spend_local` call and will be removed in May 2025. /// Refer to <https://github.com/paritytech/polkadot-sdk/pull/5961> for migration to `spend`. /// -- GitLab