pub type Treasury = Pallet<Runtime>;
Aliased Type§
struct Treasury(/* private fields */);
Implementations
Source§impl<T, I> Pallet<T, I>where
T: Config<I>,
I: 'static,
impl<T, I> Pallet<T, I>where
T: Config<I>,
I: 'static,
Sourcepub fn spend_local(
origin: <T as Config>::RuntimeOrigin,
amount: <<T as Config<I>>::Currency as Currency<<T as Config>::AccountId>>::Balance,
beneficiary: <<T as Config>::Lookup as StaticLookup>::Source,
) -> Result<(), DispatchError>
👎Deprecated: The spend_local
call will be removed by May 2025. Migrate to the new flow and use the spend
call.
pub fn spend_local( origin: <T as Config>::RuntimeOrigin, amount: <<T as Config<I>>::Currency as Currency<<T as Config>::AccountId>>::Balance, beneficiary: <<T as Config>::Lookup as StaticLookup>::Source, ) -> Result<(), DispatchError>
spend_local
call will be removed by May 2025. Migrate to the new flow and use the spend
call.Propose and approve a spend of treasury funds.
§Dispatch Origin
Must be Config::SpendOrigin
with the Success
value being at least amount
.
§Details
NOTE: For record-keeping purposes, the proposer is deemed to be equivalent to the beneficiary.
§Parameters
amount
: The amount to be transferred from the treasury to thebeneficiary
.beneficiary
: The destination account for the transfer.
§Events
Emits Event::SpendApproved
if successful.
Sourcepub fn remove_approval(
origin: <T as Config>::RuntimeOrigin,
proposal_id: u32,
) -> Result<(), DispatchError>
👎Deprecated: The remove_approval
call will be removed by May 2025. It associated with the deprecated spend_local
call.
pub fn remove_approval( origin: <T as Config>::RuntimeOrigin, proposal_id: u32, ) -> Result<(), DispatchError>
remove_approval
call will be removed by May 2025. It associated with the deprecated spend_local
call.Force a previously approved proposal to be removed from the approval queue.
§Dispatch Origin
Must be Config::RejectOrigin
.
§Details
The original deposit will no longer be returned.
§Parameters
proposal_id
: The index of a proposal
§Complexity
- O(A) where
A
is the number of approvals
§Errors
Error::ProposalNotApproved
: Theproposal_id
supplied was not found in the approval queue, i.e., the proposal has not been approved. This could also mean the proposal does not exist altogether, thus there is no way it would have been approved in the first place.
Sourcepub fn spend(
origin: <T as Config>::RuntimeOrigin,
asset_kind: Box<<T as Config<I>>::AssetKind>,
amount: <<T as Config<I>>::Paymaster as Pay>::Balance,
beneficiary: Box<<<T as Config<I>>::BeneficiaryLookup as StaticLookup>::Source>,
valid_from: Option<<<T as Config<I>>::BlockNumberProvider as BlockNumberProvider>::BlockNumber>,
) -> Result<(), DispatchError>
pub fn spend( origin: <T as Config>::RuntimeOrigin, asset_kind: Box<<T as Config<I>>::AssetKind>, amount: <<T as Config<I>>::Paymaster as Pay>::Balance, beneficiary: Box<<<T as Config<I>>::BeneficiaryLookup as StaticLookup>::Source>, valid_from: Option<<<T as Config<I>>::BlockNumberProvider as BlockNumberProvider>::BlockNumber>, ) -> Result<(), DispatchError>
Propose and approve a spend of treasury funds.
§Dispatch Origin
Must be Config::SpendOrigin
with the Success
value being at least
amount
of asset_kind
in the native asset. The amount of asset_kind
is converted
for assertion using the Config::BalanceConverter
.
§Details
Create an approved spend for transferring a specific amount
of asset_kind
to a
designated beneficiary. The spend must be claimed using the payout
dispatchable within
the Config::PayoutPeriod
.
§Parameters
asset_kind
: An indicator of the specific asset class to be spent.amount
: The amount to be transferred from the treasury to thebeneficiary
.beneficiary
: The beneficiary of the spend.valid_from
: The block number from which the spend can be claimed. It can refer to the past if the resulting spend has not yet expired according to theConfig::PayoutPeriod
. IfNone
, the spend can be claimed immediately after approval.
§Events
Emits Event::AssetSpendApproved
if successful.
Sourcepub fn payout(
origin: <T as Config>::RuntimeOrigin,
index: u32,
) -> Result<(), DispatchError>
pub fn payout( origin: <T as Config>::RuntimeOrigin, index: u32, ) -> Result<(), DispatchError>
Claim a spend.
§Dispatch Origin
Must be signed
§Details
Spends must be claimed within some temporal bounds. A spend may be claimed within one
Config::PayoutPeriod
from the valid_from
block.
In case of a payout failure, the spend status must be updated with the check_status
dispatchable before retrying with the current function.
§Parameters
index
: The spend index.
§Events
Emits Event::Paid
if successful.
Sourcepub fn check_status(
origin: <T as Config>::RuntimeOrigin,
index: u32,
) -> Result<PostDispatchInfo, DispatchErrorWithPostInfo<PostDispatchInfo>>
pub fn check_status( origin: <T as Config>::RuntimeOrigin, index: u32, ) -> Result<PostDispatchInfo, DispatchErrorWithPostInfo<PostDispatchInfo>>
Check the status of the spend and remove it from the storage if processed.
§Dispatch Origin
Must be signed.
§Details
The status check is a prerequisite for retrying a failed payout. If a spend has either succeeded or expired, it is removed from the storage by this function. In such instances, transaction fees are refunded.
§Parameters
index
: The spend index.
§Events
Emits Event::PaymentFailed
if the spend payout has failed.
Emits Event::SpendProcessed
if the spend payout has succeed.
Sourcepub fn void_spend(
origin: <T as Config>::RuntimeOrigin,
index: u32,
) -> Result<(), DispatchError>
pub fn void_spend( origin: <T as Config>::RuntimeOrigin, index: u32, ) -> Result<(), DispatchError>
Void previously approved spend.
§Dispatch Origin
Must be Config::RejectOrigin
.
§Details
A spend void is only possible if the payout has not been attempted yet.
§Parameters
index
: The spend index.
§Events
Emits Event::AssetSpendVoided
if successful.
Source§impl<T, I> Pallet<T, I>where
T: Config<I>,
I: 'static,
impl<T, I> Pallet<T, I>where
T: Config<I>,
I: 'static,
Sourcepub fn account_id() -> <T as Config>::AccountId
pub fn account_id() -> <T as Config>::AccountId
The account ID of the treasury pot.
This actually does computation. If you need to keep using it, then make sure you cache the value and only call this once.
Sourcepub fn proposal_count() -> u32
👎Deprecated: This function will be removed by May 2025. Configure pallet to use PayFromAccount for Paymaster type instead
pub fn proposal_count() -> u32
Public function to proposal_count storage.
Sourcepub fn proposals(
index: u32,
) -> Option<Proposal<<T as Config>::AccountId, <<T as Config<I>>::Currency as Currency<<T as Config>::AccountId>>::Balance>>
👎Deprecated: This function will be removed by May 2025. Configure pallet to use PayFromAccount for Paymaster type instead
pub fn proposals( index: u32, ) -> Option<Proposal<<T as Config>::AccountId, <<T as Config<I>>::Currency as Currency<<T as Config>::AccountId>>::Balance>>
Public function to proposals storage.
Sourcepub fn approvals() -> BoundedVec<u32, <T as Config<I>>::MaxApprovals>
👎Deprecated: This function will be removed by May 2025. Configure pallet to use PayFromAccount for Paymaster type instead
pub fn approvals() -> BoundedVec<u32, <T as Config<I>>::MaxApprovals>
Public function to approvals storage.
Sourcepub fn spend_funds(
spend_periods_passed: <<T as Config<I>>::BlockNumberProvider as BlockNumberProvider>::BlockNumber,
new_last_spend_period: <<T as Config<I>>::BlockNumberProvider as BlockNumberProvider>::BlockNumber,
) -> Weight
pub fn spend_funds( spend_periods_passed: <<T as Config<I>>::BlockNumberProvider as BlockNumberProvider>::BlockNumber, new_last_spend_period: <<T as Config<I>>::BlockNumberProvider as BlockNumberProvider>::BlockNumber, ) -> Weight
Spend some money! returns number of approvals before spend.
Trait Implementations
Source§impl<T, I> BeforeAllRuntimeMigrations for Pallet<T, I>where
T: Config<I>,
I: 'static,
impl<T, I> BeforeAllRuntimeMigrations for Pallet<T, I>where
T: Config<I>,
I: 'static,
Source§fn before_all_runtime_migrations() -> Weight
fn before_all_runtime_migrations() -> Weight
Source§impl<T, I> Benchmarking for Pallet<T, I>
impl<T, I> Benchmarking for Pallet<T, I>
Source§fn benchmarks(extra: bool) -> Vec<BenchmarkMetadata>
fn benchmarks(extra: bool) -> Vec<BenchmarkMetadata>
Source§fn run_benchmark(
extrinsic: &[u8],
c: &[(BenchmarkParameter, u32)],
whitelist: &[TrackedStorageKey],
verify: bool,
internal_repeats: u32,
) -> Result<Vec<BenchmarkResult>, BenchmarkError>
fn run_benchmark( extrinsic: &[u8], c: &[(BenchmarkParameter, u32)], whitelist: &[TrackedStorageKey], verify: bool, internal_repeats: u32, ) -> Result<Vec<BenchmarkResult>, BenchmarkError>
Source§impl<T, I> Callable<T> for Pallet<T, I>where
T: Config<I>,
I: 'static,
impl<T, I> Callable<T> for Pallet<T, I>where
T: Config<I>,
I: 'static,
type RuntimeCall = Call<T, I>
Source§impl<T, I> DispatchViewFunction for Pallet<T, I>where
T: Config<I>,
I: 'static,
impl<T, I> DispatchViewFunction for Pallet<T, I>where
T: Config<I>,
I: 'static,
fn dispatch_view_function<O>(
id: &ViewFunctionId,
input: &mut &[u8],
output: &mut O,
) -> Result<(), ViewFunctionDispatchError>where
O: Output,
Source§impl<T, I> GetStorageVersion for Pallet<T, I>where
T: Config<I>,
I: 'static,
impl<T, I> GetStorageVersion for Pallet<T, I>where
T: Config<I>,
I: 'static,
Source§fn in_code_storage_version() -> <Pallet<T, I> as GetStorageVersion>::InCodeStorageVersion
fn in_code_storage_version() -> <Pallet<T, I> as GetStorageVersion>::InCodeStorageVersion
storage_version
attribute, or
NoStorageVersionSet
if the attribute is missing.Source§fn on_chain_storage_version() -> StorageVersion
fn on_chain_storage_version() -> StorageVersion
Source§fn current_storage_version() -> Self::InCodeStorageVersion
fn current_storage_version() -> Self::InCodeStorageVersion
in_code_storage_version
and will be removed after March 2024.Self::current_storage_version
instead. Read moreSource§impl<T, I> Hooks<<<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number> for Pallet<T, I>where
T: Config<I>,
I: 'static,
impl<T, I> Hooks<<<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number> for Pallet<T, I>where
T: Config<I>,
I: 'static,
Source§fn on_initialize(
_do_not_use_local_block_number: <<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number,
) -> Weight
fn on_initialize( _do_not_use_local_block_number: <<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number, ) -> Weight
§Complexity
O(A)
whereA
is the number of approvals
Source§fn try_state(
_: <<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number,
) -> Result<(), DispatchError>
fn try_state( _: <<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number, ) -> Result<(), DispatchError>
Source§fn on_finalize(_n: BlockNumber)
fn on_finalize(_n: BlockNumber)
Source§fn on_idle(_n: BlockNumber, _remaining_weight: Weight) -> Weight
fn on_idle(_n: BlockNumber, _remaining_weight: Weight) -> Weight
Hooks::on_finalize
). Read moreSource§fn on_poll(_n: BlockNumber, _weight: &mut WeightMeter)
fn on_poll(_n: BlockNumber, _weight: &mut WeightMeter)
Source§fn on_runtime_upgrade() -> Weight
fn on_runtime_upgrade() -> Weight
Executive
pallet. Read moreSource§fn pre_upgrade() -> Result<Vec<u8>, DispatchError>
fn pre_upgrade() -> Result<Vec<u8>, DispatchError>
Source§fn post_upgrade(_state: Vec<u8>) -> Result<(), DispatchError>
fn post_upgrade(_state: Vec<u8>) -> Result<(), DispatchError>
Source§fn offchain_worker(_n: BlockNumber)
fn offchain_worker(_n: BlockNumber)
Source§fn integrity_test()
fn integrity_test()
Source§impl<T, I> IntegrityTest for Pallet<T, I>where
T: Config<I>,
I: 'static,
impl<T, I> IntegrityTest for Pallet<T, I>where
T: Config<I>,
I: 'static,
Source§impl<T, I> OffchainWorker<<<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number> for Pallet<T, I>where
T: Config<I>,
I: 'static,
impl<T, I> OffchainWorker<<<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number> for Pallet<T, I>where
T: Config<I>,
I: 'static,
Source§impl<T, I> OnFinalize<<<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number> for Pallet<T, I>where
T: Config<I>,
I: 'static,
impl<T, I> OnFinalize<<<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number> for Pallet<T, I>where
T: Config<I>,
I: 'static,
Source§fn on_finalize(
n: <<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number,
)
fn on_finalize( n: <<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number, )
Hooks::on_finalize
.Source§impl<T, I> OnGenesis for Pallet<T, I>where
T: Config<I>,
I: 'static,
impl<T, I> OnGenesis for Pallet<T, I>where
T: Config<I>,
I: 'static,
Source§fn on_genesis()
fn on_genesis()
Source§impl<T, I> OnIdle<<<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number> for Pallet<T, I>where
T: Config<I>,
I: 'static,
impl<T, I> OnIdle<<<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number> for Pallet<T, I>where
T: Config<I>,
I: 'static,
Source§impl<T, I> OnInitialize<<<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number> for Pallet<T, I>where
T: Config<I>,
I: 'static,
impl<T, I> OnInitialize<<<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number> for Pallet<T, I>where
T: Config<I>,
I: 'static,
Source§fn on_initialize(
n: <<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number,
) -> Weight
fn on_initialize( n: <<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number, ) -> Weight
Hooks::on_initialize
.Source§impl<T, I> OnPoll<<<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number> for Pallet<T, I>where
T: Config<I>,
I: 'static,
impl<T, I> OnPoll<<<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number> for Pallet<T, I>where
T: Config<I>,
I: 'static,
Source§impl<T, I> OnRuntimeUpgrade for Pallet<T, I>where
T: Config<I>,
I: 'static,
impl<T, I> OnRuntimeUpgrade for Pallet<T, I>where
T: Config<I>,
I: 'static,
Source§fn on_runtime_upgrade() -> Weight
fn on_runtime_upgrade() -> Weight
Source§fn pre_upgrade() -> Result<Vec<u8>, DispatchError>
fn pre_upgrade() -> Result<Vec<u8>, DispatchError>
Hooks::pre_upgrade
.Source§fn post_upgrade(state: Vec<u8>) -> Result<(), DispatchError>
fn post_upgrade(state: Vec<u8>) -> Result<(), DispatchError>
Hooks::post_upgrade
.Source§fn try_on_runtime_upgrade(checks: bool) -> Result<Weight, DispatchError>
fn try_on_runtime_upgrade(checks: bool) -> Result<Weight, DispatchError>
pre_upgrade
->
on_runtime_upgrade
-> post_upgrade
hooks for a migration. Read moreSource§impl<T, I> OnUnbalanced<<<T as Config<I>>::Currency as Currency<<T as Config>::AccountId>>::NegativeImbalance> for Pallet<T, I>where
T: Config<I>,
I: 'static,
impl<T, I> OnUnbalanced<<<T as Config<I>>::Currency as Currency<<T as Config>::AccountId>>::NegativeImbalance> for Pallet<T, I>where
T: Config<I>,
I: 'static,
Source§fn on_nonzero_unbalanced(
amount: <<T as Config<I>>::Currency as Currency<<T as Config>::AccountId>>::NegativeImbalance,
)
fn on_nonzero_unbalanced( amount: <<T as Config<I>>::Currency as Currency<<T as Config>::AccountId>>::NegativeImbalance, )
on_unbalanced
.Source§fn on_unbalanceds(amounts: impl Iterator<Item = Imbalance>)where
Imbalance: TryMerge,
fn on_unbalanceds(amounts: impl Iterator<Item = Imbalance>)where
Imbalance: TryMerge,
Source§fn on_unbalanced(amount: Imbalance)
fn on_unbalanced(amount: Imbalance)
Source§impl<T, I> PalletInfoAccess for Pallet<T, I>where
T: Config<I>,
I: 'static,
impl<T, I> PalletInfoAccess for Pallet<T, I>where
T: Config<I>,
I: 'static,
Source§fn module_name() -> &'static str
fn module_name() -> &'static str
Source§fn crate_version() -> CrateVersion
fn crate_version() -> CrateVersion
Source§impl<T, I> PalletsInfoAccess for Pallet<T, I>where
T: Config<I>,
I: 'static,
impl<T, I> PalletsInfoAccess for Pallet<T, I>where
T: Config<I>,
I: 'static,
Source§impl<T, I> StorageInfoTrait for Pallet<T, I>where
T: Config<I>,
I: 'static,
impl<T, I> StorageInfoTrait for Pallet<T, I>where
T: Config<I>,
I: 'static,
fn storage_info() -> Vec<StorageInfo>
Source§impl<T, I> TryDecodeEntireStorage for Pallet<T, I>where
T: Config<I>,
I: 'static,
impl<T, I> TryDecodeEntireStorage for Pallet<T, I>where
T: Config<I>,
I: 'static,
Source§fn try_decode_entire_state() -> Result<usize, Vec<TryDecodeEntireStorageError>>
fn try_decode_entire_state() -> Result<usize, Vec<TryDecodeEntireStorageError>>
Ok(bytes_decoded)
if success.Source§impl<T, I> TryState<<<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number> for Pallet<T, I>where
T: Config<I>,
I: 'static,
impl<T, I> TryState<<<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number> for Pallet<T, I>where
T: Config<I>,
I: 'static,
Source§impl<T, I> ViewFunctionIdPrefix for Pallet<T, I>where
T: Config<I>,
I: 'static,
impl<T, I> ViewFunctionIdPrefix for Pallet<T, I>where
T: Config<I>,
I: 'static,
Source§impl<T, I> WhitelistedStorageKeys for Pallet<T, I>where
T: Config<I>,
I: 'static,
impl<T, I> WhitelistedStorageKeys for Pallet<T, I>where
T: Config<I>,
I: 'static,
Source§fn whitelisted_storage_keys() -> Vec<TrackedStorageKey>
fn whitelisted_storage_keys() -> Vec<TrackedStorageKey>
Vec<TrackedStorageKey>
indicating the storage keys that
should be whitelisted during benchmarking. This means that those keys
will be excluded from the benchmarking performance calculation.