Struct Pallet

Source
pub struct Pallet<T, I = ()>(PhantomData<(T, I)>);
Expand description

Primary Marker type for the Commitment pallet.

This pallet provides implementations for traits from commitment

Pallet implements the core commitment system traits:

Tuple Fields§

§0: PhantomData<(T, I)>

Implementations§

Source§

impl<T: Config<I>, I: 'static> Pallet<T, I>

Source

pub fn deposit_reserve( origin: OriginFor<T>, amount: AssetOf<T, I>, precision: PrecisionWrapper, ) -> DispatchResult

Deposits funds from free balance into reserve for future commitments.

Locks the specified amount under the HoldReason::PrepareForCommit hold reason.

These funds remain available for placing or raising commitments until explicitly withdrawn via Pallet::withdraw_reserve.

§Behavior
  • If precision is BestEffort, deposits the maximum available balance when insufficient
  • If precision is Exact, requires exact amount or fails with Error::InsufficientFunds
§Emits

Event::ReserveDeposited: Contains the amount deposited and the total balance on hold.

Source

pub fn withdraw_reserve( origin: OriginFor<T>, amount: Option<AssetOf<T, I>>, ) -> DispatchResult

Withdraws reserved funds back to the caller’s free balance.

Releases funds held under the HoldReason::PrepareForCommit reason and returns them to the caller’s free balance.

§Behavior
  • If amount is None, all reserved funds under the hold reason are released.
  • If amount is Some(value), only the specified amount is released, leaving any remaining reserved funds intact.

This call decreases the balance on hold with Precision::Exact and increases the caller’s free balance by the same amount.

Returns Error::InsufficientFunds if a specific amount is provided and the held balance is less than the requested amount.

§Emits

Event::ReserveWithdrawn: Contains the amount withdrawn and the amount balance on hold.

Source§

impl<T: Config<I>, I: 'static> Pallet<T, I>

Source

pub fn resolve_digest_model( digest: Digest<T>, reason: CommitReason<T, I>, ) -> Result<DigestVariant<T, I>, DispatchError>

Resolves the DigestVariant for a given digest and commit reason.

The returned variant defines how the digest is interpreted within the commitment system (Direct, Index or Pool).

Source

pub fn resolve_digest_model_for( caller: T::AccountId, reason: CommitReason<T, I>, ) -> Result<DigestVariant<T, I>, DispatchError>

Resolves the digest variant of caller’s active commitment under reason.

Retrieves the commitment digest currently associated with the caller for the specified reason, then determines its classification within the commitment system.

The returned DigestVariant indicates whether the commitment is a Direct, Index, or Pool type.

Source

pub fn query_commit_value( caller: T::AccountId, reason: CommitReason<T, I>, ) -> Result<AssetOf<T, I>, DispatchError>

Returns the total value committed by caller under a reason.

This represents the caller’s full active commitment for the specified reason.

Source

pub fn query_asset_to_issue() -> AssetOf<T, I>

Returns the total amount of assets currently recorded as pending issuance.

The returned value is an accounting value only. It does not guarantee that the underlying asset system has already minted the assets.

Source

pub fn query_asset_to_reap() -> AssetOf<T, I>

Returns the total amount of assets currently recorded as pending reaping.

The returned value is an accounting value only. It does not guarantee that the underlying asset system has already reaped, burned, or removed the assets.

Source

pub fn query_reason_value(reason: CommitReason<T, I>) -> AssetOf<T, I>

Returns the total committed asset value recorded for the given reason.

This value is read directly from ReasonValue and represents the aggregated committed value across all digests and variants associated with the specified reason.

Returns Zero if no committed value is currently stored for the reason.

Source

pub fn query_index_value( reason: CommitReason<T, I>, index: IndexDigest<T>, ) -> Result<AssetOf<T, I>, DispatchError>

Returns the total value committed to an index under a reason.

The returned value is the sum of all entry commitments from all accounts within the index.

Source

pub fn query_entries_value( reason: CommitReason<T, I>, index: IndexDigest<T>, ) -> Result<Vec<(Digest<T>, AssetOf<T, I>)>, DispatchError>

Returns the total committed value of every entry within an index under a reason.

Each tuple contains:

  • Entry digest
  • Aggregated value committed to that entry
Source

pub fn query_entry_value( reason: CommitReason<T, I>, index: IndexDigest<T>, entry: EntryDigest<T>, ) -> Result<AssetOf<T, I>, DispatchError>

Returns the total value committed to an entry digest within an index under a reason.

The returned value is aggregated across all accounts that have committed to the entry.

Source

pub fn query_index_value_for( caller: T::AccountId, reason: CommitReason<T, I>, index: IndexDigest<T>, ) -> Result<AssetOf<T, I>, DispatchError>

Returns the total value committed by caller to an index under a reason.

Source

pub fn query_entries_value_for( caller: T::AccountId, reason: CommitReason<T, I>, index: IndexDigest<T>, ) -> Result<Vec<(Digest<T>, AssetOf<T, I>)>, DispatchError>

Returns the caller’s committed value for each entry within an index under reason.

Each tuple contains:

  • Entry digest
  • Value committed by the caller to that entry
Source

pub fn query_entry_value_for( caller: T::AccountId, reason: CommitReason<T, I>, index: IndexDigest<T>, entry: EntryDigest<T>, ) -> Result<AssetOf<T, I>, DispatchError>

Returns the value committed by caller to an entry within an index under a reason.

Source

pub fn query_pool_value( reason: CommitReason<T, I>, pool: PoolDigest<T>, ) -> Result<AssetOf<T, I>, DispatchError>

Returns the total value committed to a pool under a reason.

The returned value is the sum of all slot commitments from all accounts within the pool.

Source

pub fn query_slots_value( reason: CommitReason<T, I>, pool: PoolDigest<T>, ) -> Result<Vec<(Digest<T>, AssetOf<T, I>)>, DispatchError>

Returns the total committed value of every slot within a pool under a reason.

Each tuple contains:

  • Slot digest
  • Aggregated value committed to that slot
Source

pub fn query_slot_value( reason: CommitReason<T, I>, pool: PoolDigest<T>, slot: SlotDigest<T>, ) -> Result<AssetOf<T, I>, DispatchError>

Returns the total value committed to a slot within a pool under a reason.

The returned value is aggregated across all accounts that have committed to the slot.

Source

pub fn query_pool_commission( reason: CommitReason<T, I>, pool: PoolDigest<T>, ) -> Result<T::Commission, DispatchError>

Returns the commission rate configured for a pool under a reason.

Source

pub fn query_pool_manager( reason: CommitReason<T, I>, pool: PoolDigest<T>, ) -> Result<T::AccountId, DispatchError>

Returns the current manager account for a pool under a reason.

The returned account is the authority responsible for managing the pool’s configuration and slot definitions.

Source

pub fn query_pool_value_for( caller: T::AccountId, reason: CommitReason<T, I>, pool: PoolDigest<T>, ) -> Result<AssetOf<T, I>, DispatchError>

Returns the total value committed by caller to a pool under a reason.

Source

pub fn query_slots_value_for( caller: T::AccountId, reason: CommitReason<T, I>, pool_of: PoolDigest<T>, ) -> Result<Vec<(Digest<T>, AssetOf<T, I>)>, DispatchError>

Returns the caller’s committed value for each slot within a pool under a reason.

Each tuple contains:

  • Slot digest
  • Value committed by the caller to that slot
Source

pub fn query_slot_value_for( caller: T::AccountId, reason: CommitReason<T, I>, pool: PoolDigest<T>, slot: SlotDigest<T>, ) -> Result<AssetOf<T, I>, DispatchError>

Returns the value committed by a caller to a slot within a pool under a reason.

Source§

impl<T: Config<I>, I: 'static> Pallet<T, I>

Source

pub(crate) fn deposit_event(event: Event<T, I>)

Trait Implementations§

Source§

impl<T: Config<I>, I: 'static> BeforeAllRuntimeMigrations for Pallet<T, I>

Source§

fn before_all_runtime_migrations() -> Weight

Something that should happen before runtime migrations are executed.
Source§

impl<T: Config<I>, I: 'static> Callable<T> for Pallet<T, I>

Source§

impl<T, I> Clone for Pallet<T, I>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<T: Config<I>, I: 'static> CommitBalance<<T as Config>::AccountId, Pallet<T, I>> for CommitHelpers<T, I>

Implements the CommitBalance trait for the pallet.

Provides low-level balance management.

Source§

type Imbalance = AssetDelta<T, I>

The structure representing a differential between deposited and withdrawn asset values - used to determine how the balance should be compensated.

Source§

fn resolve_imbalance( who: &Proprietor<T>, imbalance: Self::Imbalance, ) -> Result<<Pallet<T, I> as InspectAsset<Proprietor<T>>>::Asset, DispatchError>

Resolves an asset imbalance for a proprietor when a commitment is finalized (e.g. during withdrawal).

An imbalance may arise when a commitment’s effective value changes due to digest updates (for example via Commitment::set_digest_value). This function reconciles the difference between deposited and withdrawn amounts to preserve financial consistency.

The reconciliation is performed through the pallet’s Config::Asset fungible adapter by minting, burning, or reissuing assets as required.

This function finalizes the pallet’s internal accounting by settling AssetToIssue and AssetToReap with the underlying asset system.

Notably, this function does not rely on balanced fungible traits. Instead, the original deposit is returned to the proprietor, and any additional minting or burning is performed explicitly and independently via unbalanced low-level fungible traits.

This ensures balance adjustments occur in a controlled and safe manner without directly mutating the proprietor’s balance.

§Behavior
  • deposit < withdraw: The shortfall is minted as a reward (accounted via AssetToIssue).
  • deposit == withdraw: The values are balanced; no action is taken.
  • deposit > withdraw: The surplus is burned as a penalty (accounted via AssetToReap).
§Returns
  • Ok(Asset) containing the final asset value returned to the proprietor after resolving the imbalance.
  • Err(DispatchError) if minting or burning fails or capacity is insufficient.
Source§

fn deduct_balance( who: &Proprietor<T>, value: <Pallet<T, I> as InspectAsset<Proprietor<T>>>::Asset, qualifier: &DispatchPolicy, ) -> Result<<Pallet<T, I> as InspectAsset<Proprietor<T>>>::Asset, DispatchError>

Deducts a specified asset value from the proprietor’s balance.

Held funds (under HoldReason::PrepareForCommit) are applied first, followed by liquid funds if required. The deduction behavior is governed by the provided precision and fortitude parameters:

  • Precision: Determines whether an exact amount is required or a best-effort deduction is acceptable.
  • Fortitude: Determines whether deduction should be polite or forceful.

When Fortitude::Polite is used, only held (commit-reserved) funds are deducted. When Fortitude::Force is used, deduction first consumes any available held funds and then continues from the liquid balance if needed.

All balance operations are performed under a preservation context and therefore never risk account closure.

§Returns
  • Ok(Asset) containing the actual amount deducted.
  • Err(DispatchError) if funds are insufficient or the deduction fails.
Source§

fn deduct_from_imbalance( imbalance: &mut Self::Imbalance, value: <Pallet<T, I> as InspectAsset<Proprietor<T>>>::Asset, ) -> Result<Self::Imbalance, DispatchError>

Deducts a specified value from an existing imbalance, mutating it in-place.

This function extracts value from that differential while preserving correct economic accounting for rewards or penalties.

§Semantics
  • If withdraw > deposit (reward state): the deduction first consumes the reward portion. Any excess deduction converts into a penalty, increasing AssetToReap.
  • If withdraw == deposit (neutral state): the deduction is treated as a penalty and directly increases AssetToReap.
  • If withdraw < deposit (penalty state): the deduction deepens the penalty, further increasing AssetToReap.

In all cases, the imbalance holder remains the sole party whose economic position is adjusted, avoiding double mint/burn effects for both parties.

§Returns

Returns a neutral imbalance (deposit == withdraw == value). This allows the caller to credit the deducted value directly to the underlying fungible system without introducing additional reward or penalty logic.

  • DispatchError otherwise
Source§

impl<T: Config<I>, I: 'static> CommitDeposit<<T as Config>::AccountId, Pallet<T, I>> for CommitHelpers<T, I>

Implements the CommitDeposit trait for the pallet, providing low-level deposit functionality for digests, indexes, and pools within the commitment system.

Source§

type Receipt = ProductType<T, I, <<T as Config<I>>::BalanceContext as ModelContext>::Context, ReceiptAsset, ReceiptRational, ReceiptTime, ReceiptAddon>

Represents the “Receipt” of a digest at the time of a deposit.

Reference CommitInstance’s generic alias documentation, where it holds the deposit receipt from the digest’s lazy balance (LazyBalanceOf) when the deposit occurs.

It ensures that later commitment resolution can account for the digest’s state accurately, even if the underlying digest values changes over time.

Source§

fn deposit_to( who: &Proprietor<T>, reason: &<Pallet<T, I> as Commitment<Proprietor<T>>>::Reason, digest_model: &<Pallet<T, I> as DigestModel<Proprietor<T>>>::Model, value: <Pallet<T, I> as InspectAsset<Proprietor<T>>>::Asset, variant: &<Pallet<T, I> as CommitVariant<Proprietor<T>>>::Position, qualifier: &DispatchPolicy, ) -> Result<(Self::Receipt, <Pallet<T, I> as InspectAsset<Proprietor<T>>>::Asset), DispatchError>

Deposits a value for a given digest model and its specified variant.

This function centralizes the dispatch logic to the appropriate handler depending on the type of the digest model (Direct, Index, or Pool).

§Returns
  • Ok((DerivedBalance, Asset)) containing the deposit’s receipt and the actual depositted value.
  • Err(DispatchError) if the deposit fails
Source§

fn deposit_to_digest( _who: &Proprietor<T>, reason: &<Pallet<T, I> as Commitment<Proprietor<T>>>::Reason, digest: &<Pallet<T, I> as Commitment<Proprietor<T>>>::Digest, value: <Pallet<T, I> as InspectAsset<Proprietor<T>>>::Asset, variant: &<Pallet<T, I> as CommitVariant<Proprietor<T>>>::Position, qualifier: &DispatchPolicy, ) -> Result<(Self::Receipt, <Pallet<T, I> as InspectAsset<Proprietor<T>>>::Asset), DispatchError>

Deposits a given asset value into a specific direct-digest’s variant’s balance for a reason.

This is a low-level internal function - it:

  • Directly deposits value into the specified digest and its variant.
  • Does not inspect or deduct balance, as argument.

Digest variants represent different commitment positions (e.g., affirmative, contrary, etc). This function ensures deposits go to the correct variant’s balance via PositionIndex, as digest-balances will be stored as a vector of variant balances.

§Returns
  • Ok((DerivedBalance, Asset)) containing the deposit’s receipt and the actual depositted value.
  • Err(DispatchError) if the digest variant cannot be found or mutated
Source§

fn deposit_to_index( who: &Proprietor<T>, reason: &<Pallet<T, I> as Commitment<Proprietor<T>>>::Reason, index_of: &<Pallet<T, I> as Commitment<Proprietor<T>>>::Digest, value: <Pallet<T, I> as InspectAsset<Proprietor<T>>>::Asset, _variant: &<Pallet<T, I> as CommitVariant<Proprietor<T>>>::Position, qualifier: &DispatchPolicy, ) -> Result<(Self::Receipt, <Pallet<T, I> as InspectAsset<Proprietor<T>>>::Asset), DispatchError>

Deposits a given asset value into an index and distributes it across its entries’ digests.

This is a low-level internal function - it:

  • Splits the value proportionally across each entry based on its share/capital ratio.
  • Delegates deposits into each entry’s digest via Self::deposit_to_digest.
  • Updates the index’s own top-level balance.

Expected invariants:

  • Total capital must be non-zero (no stale or invalid indexes).
  • Total index capital must be at least the share value of each entry.
  • Entry shares must be non-zero (no stale or invalid entries).

The caller’s variant is ignored because each entry already defines its own variant.

If the index deposit has any remaining assets, they are refunded to the proprietor here. Other commitment types (such as direct digests or pools) do not require refunding, so the refund logic is handled exclusively at this level.

Since Index maintains entry-commit receipts in their own high-level structures the receipt returned is a placeholder receipt (default), although the depositted amount is valid.

§Returns
  • Ok((DerivedBalance, Asset)) containing a placeholder receipt and the actual depositted value.
  • Err(DispatchError) if the deposit cannot be conducted
Source§

fn deposit_to_pool( _who: &Proprietor<T>, reason: &<Pallet<T, I> as Commitment<Proprietor<T>>>::Reason, pool_of: &<Pallet<T, I> as Commitment<Proprietor<T>>>::Digest, value: <Pallet<T, I> as InspectAsset<Proprietor<T>>>::Asset, _variant: &<Pallet<T, I> as CommitVariant<Proprietor<T>>>::Position, qualifier: &DispatchPolicy, ) -> Result<(Self::Receipt, <Pallet<T, I> as InspectAsset<Proprietor<T>>>::Asset), DispatchError>

Deposits a given asset value into a pool for a reason.

This is a low-level internal function - it:

  • Directly deposits value into the specified pool.
  • Does not inspect or deduct balance, as argument _who is unused.

The caller’s variant is ignored because each pool’s slot already defines its own variant.

At this level the logic is straightforward: the pool itself acts as a proprietor. It receives funds and commits them to individual slot digests, while external proprietors hold shares of the pool.

As a result, every deposit into or withdrawal from the pool requires the pool to temporarily release and then re-acquire the corresponding funds. This mirrors how an index commitment is resolved and re-placed by a proprietor.

§Returns
  • Ok((DerivedBalance, Asset)) containing the pool’s deposit receipt and the actual depositted value of the proprietor.
  • Err(DispatchError) if the deposit cannot be conducted
Source§

impl<T: Config<I>, I: 'static> CommitErrorHandler for Pallet<T, I>

Source§

type Error = Error<T, I>

Concrete error type produced by the handler. Read more
Source§

fn from_commit_error(e: CommitError) -> Self::Error

Converts a generic CommitError into the handler’s concrete error type which implements Into<DispatchError>. Read more
Source§

impl<T: Config<I>, I: 'static> CommitIndex<<T as Config>::AccountId> for Pallet<T, I>

Implements CommitIndex for the pallet

Source§

type Index = IndexInfo<T, I>

Index struct representing an index’s internal structure.

This type holds all entries and their associated shares, used for commitment calculations and value aggregations within the index.

Source§

type Shares = <T as Config<I>>::Shares

Shares unit defining an entry’s proportional weight within the index.

Shares represent each entry’s relative contribution to the index capital, used for calculating value distributions and reward/penalty allocations.

Source§

fn index_exists( reason: &Self::Reason, index_of: &Self::Digest, ) -> DispatchResult

Checks whether a specific index exists for the given reason.

§Returns
  • Ok(()) if the index exists
  • Err(DispatchError) if the index does not exist
Source§

fn entry_exists( reason: &Self::Reason, index_of: &Self::Digest, entry_of: &Self::Digest, ) -> DispatchResult

Checks whether a specific entry exists within a given index.

§Returns
  • Ok(()) if the entry exists
  • Err(DispatchError) if the entry does not exist
Source§

fn has_index(reason: &Self::Reason) -> DispatchResult

Checks whether any index exists for the given reason.

§Returns
  • Ok(()) if at least one index exists
  • Err(DispatchError) if no indexes exist
Source§

fn get_index( reason: &Self::Reason, index_of: &Self::Digest, ) -> Result<Self::Index, DispatchError>

Retrieves the index information (meta-struct) for a given reason and index digest.

§Returns
  • Ok(Index) containing the index structure
  • Err(DispatchError)if the index does not exist
Source§

fn get_entries_shares( reason: &Self::Reason, index_of: &Self::Digest, ) -> Result<Vec<(Self::Digest, Self::Shares)>, DispatchError>

Retrieves all entry digests and their shares for a specific index.

§Returns
  • Ok(Vec<(Digest, Shares)>) containing each entry’s digest and shares
  • Err(DispatchError) if the index does not exist
Source§

fn get_entry_value( reason: &Self::Reason, index_of: &Self::Digest, entry_of: &Self::Digest, ) -> Result<Self::Asset, DispatchError>

Computes the aggregated real-time value of a specific entry across all proprietors.

Only includes commitments made via this index, not direct commitments to the entry digest.

§Returns
  • Ok(Asset) containing the total committed value for the entry
  • Err(DispatchError) if the entry does not exist
Source§

fn get_entry_value_for( who: &Proprietor<T>, reason: &Self::Reason, index_of: &Self::Digest, entry_of: &Self::Digest, ) -> Result<Self::Asset, DispatchError>

Retrieves the real-time committed value of a specific entry for a given proprietor via an index.

§Returns
  • Ok(Asset) containing the proprietor’s committed value for the entry
  • Err(DispatchError) if the entry does not exist
Source§

fn gen_index_digest( from: &Proprietor<T>, reason: &Self::Reason, index: &Self::Index, ) -> Result<Self::Digest, DispatchError>

Generates a unique digest for the given index using the proprietor and reason.

§Returns
  • Ok(Digest) with the newly generated digest.
  • Err(DispatchError) if digest generation fails
Source§

fn prepare_index( _who: &Proprietor<T>, _reason: &Self::Reason, entries: &[(Self::Digest, Self::Shares)], ) -> Result<Self::Index, DispatchError>

Prepares a new index instance from a list of entry digests and their corresponding shares.

This function does not associate the index with a specific reason or proprietor internally. The caller is responsible for ensuring the index is correctly attached to a reason and, optionally, the creator.

Entries with zero shares are silently ignored, as they carry no semantic contribution to the index.

Entry digests are not validated to be direct digests. If a commitment is placed on the index, each entry digest will be funded accordingly through the normal deposit routing.

Nested cases-such as index entries referencing other indexes or pools- are not supported and may be treated as new direct digests when routed through CommitDeposit::deposit_to_digest. Callers are responsible for validating such cases if required.

  • who: The proprietor creating the index.
  • reason: The reason under which the index is being prepared.
§Returns
  • Ok(Index) containing the prepared index
  • Err(DispatchError) if preparation fails
Source§

fn set_index( who: &Proprietor<T>, reason: &Self::Reason, index: &Self::Index, digest: &Self::Digest, ) -> DispatchResult

Sets a new index for the given digest at the given reason.

  • The caller must ensure that the provided digest is unique i.e., generated via CommitIndex::gen_index_digest and does not collide with existing indexes in the system.
  • This function is intended only for creating new indexes.
  • Mutations to existing indexes are not supported here.
  • For updating an index, a new index digest should be generated via CommitIndex::set_entry_shares
§Returns
  • Ok(()) if the index was successfully inserted
  • Err(DispatchError) with IndexDigestTaken if the digest already exists
Source§

fn set_entry_shares( who: &Proprietor<T>, reason: &Self::Reason, index_of: &Self::Digest, entry_of: &Self::Digest, shares: Self::Shares, ) -> Result<Self::Digest, DispatchError>

Updates or sets the shares for a specific entry of an index, producing a new index.

  • If the entry already exists in the index:
    • If shares is zero, the entry is removed.
    • Otherwise, the entry’s shares are updated while preserving its existing variant.
  • If the entry does not exist:
    • If shares is zero, the operation is a no-op and the original index is returned.
    • Otherwise, a new entry is added with the default Config::Position variant.

The newly added entry digest is not validated to be a direct digest and is accepted as provided through this function. If a commitment is placed on the index, it will be funded accordingly through normal deposit routing.

Nested cases-such as entries referencing other indexes or pools- are not supported and may be treated as new direct digests when routed through CommitDeposit::deposit_to_digest. Callers are responsible for validating such cases if required.

§Returns
  • Ok(Digest) containing the resulting index digest (may be unchanged if no-op)
  • Err(DispatchError) if the operation fails
Source§

fn reap_index(reason: &Self::Reason, index_of: &Self::Digest) -> DispatchResult

Removes an index if all entries have no committed funds.

§Returns
  • Ok(()) if the index was successfully removed
  • Err(DispatchError) with IndexHasFunds if any entry still has commitments
Source§

fn on_set_index( _who: &Proprietor<T>, index_of: &Self::Digest, reason: &Self::Reason, _index: &Self::Index, )

Emits an event when an index is created.

Source§

fn on_reap_index( index_of: &Self::Digest, reason: &Self::Reason, dust: Self::Asset, )

Emits an event when an index is successfully reaped.

Emits a Event::IndexReaped event if Config::EmitEvents is true.

Source§

fn get_index_value( reason: &Self::Reason, index_of: &Self::Digest, ) -> Result<Self::Asset, DispatchError>

Retrieves the real-time aggregated value of the specified index. Read more
Source§

fn get_entries_value( reason: &Self::Reason, index_of: &Self::Digest, ) -> Result<Vec<(Self::Digest, Self::Asset)>, DispatchError>

Retrieves the real-time values of all entries within the specified index. Read more
Source§

fn get_entries_value_for( who: &Proprietor, reason: &Self::Reason, index_of: &Self::Digest, ) -> Result<Vec<(Self::Digest, Self::Asset)>, DispatchError>

Retrieves the real-time values of a proprietor’s commitments to all entries within the specified index. Read more
Source§

fn get_index_value_for( who: &Proprietor, reason: &Self::Reason, index_of: &Self::Digest, ) -> Result<Self::Asset, DispatchError>

Retrieves the real-time total value of a proprietor’s commitment to an index. Read more
Source§

impl<T: Config<I>, I: 'static> CommitInspect<<T as Config>::AccountId, Pallet<T, I>> for CommitHelpers<T, I>

Implements the CommitInspect trait for the pallet, providing low-level inspection and querying capabilities for committed values across digests, indexes, and pools.

This implementation allows retrieving real-time committed values without altering state, supporting precise accounting and auditability. All functions are low-level and unchecked, meaning callers are responsible for ensuring correctness and invariants before invoking.

Source§

fn commit_value_of( who: &Proprietor<T>, reason: &<Pallet<T, I> as Commitment<Proprietor<T>>>::Reason, digest_model: &<Pallet<T, I> as DigestModel<Proprietor<T>>>::Model, ) -> Result<<Pallet<T, I> as InspectAsset<Proprietor<T>>>::Asset, DispatchError>

Retrieves the total committed value of a proprietor for a fully resolved digest model.

This function centralizes the dispatch logic to the appropriate handler depending on the type of the digest model.

Digest models represent different commitment structures:

  • Direct: a single digest commitment.
  • Index: a grouped commitment of multiple entry digests.
  • Pool: a shared resource i.e., a collective single commitment.
§Returns
  • Ok(Asset) containing the real-time committed value
  • Err(DispatchError) if the digest model is invalid or any underlying query fails
Source§

fn digest_commit_value( who: &Proprietor<T>, reason: &<Pallet<T, I> as Commitment<Proprietor<T>>>::Reason, digest: &<Pallet<T, I> as Commitment<Proprietor<T>>>::Digest, ) -> Result<<Pallet<T, I> as InspectAsset<Proprietor<T>>>::Asset, DispatchError>

Retrieves the proprietor’s committed value for a direct digest of a given reason.

§Returns
  • Ok(Asset) representing the real-time committed value for the digest
  • Err(DispatchError) otherwise
Source§

fn index_commit_value( who: &Proprietor<T>, reason: &<Pallet<T, I> as Commitment<Proprietor<T>>>::Reason, index_of: &<Pallet<T, I> as Commitment<Proprietor<T>>>::Digest, ) -> Result<<Pallet<T, I> as InspectAsset<Proprietor<T>>>::Asset, DispatchError>

Computes the total committed value of a proprietor for a given index digest.

§Returns
  • Ok(Asset) with the total committed value for the index
  • Err(DispatchError) otherwise
Source§

fn index_entry_commit_value( who: &Proprietor<T>, reason: &<Pallet<T, I> as Commitment<Proprietor<T>>>::Reason, index_of: &<Pallet<T, I> as Commitment<Proprietor<T>>>::Digest, entry_of: &<Pallet<T, I> as Commitment<Proprietor<T>>>::Digest, ) -> Result<<Pallet<T, I> as InspectAsset<Proprietor<T>>>::Asset, DispatchError>

Computes the total committed value of a proprietor for a specific entry within an index.

§Returns
  • Ok(Asset) containing the total committed value for the entry
  • Err(DispatchError) otherwise
Source§

fn pool_commit_value( who: &Proprietor<T>, reason: &<Pallet<T, I> as Commitment<Proprietor<T>>>::Reason, pool_of: &<Pallet<T, I> as Commitment<Proprietor<T>>>::Digest, ) -> Result<<Pallet<T, I> as InspectAsset<Proprietor<T>>>::Asset, DispatchError>

Computes the total committed value of a proprietor for a given pool.

§Returns
  • Ok(Asset) with the total effective committed value
  • Err(DispatchError) otherwise
Source§

fn pool_slot_commit_value( who: &Proprietor<T>, reason: &<Pallet<T, I> as Commitment<Proprietor<T>>>::Reason, pool_of: &<Pallet<T, I> as Commitment<Proprietor<T>>>::Digest, slot_of: &<Pallet<T, I> as Commitment<Proprietor<T>>>::Digest, ) -> Result<<Pallet<T, I> as InspectAsset<Proprietor<T>>>::Asset, DispatchError>

Computes the commit value of a specific slot for a given proprietor within a pool.

§Returns
  • Ok(Asset>) representing the slot’s effective value for the proprietor
  • Err(DispatchError) if calculation fails
Source§

fn value_of( digest_model: Option<&<Pallet<T, I> as DigestModel<Proprietor<T>>>::Model>, reason: &<Pallet<T, I> as Commitment<Proprietor<T>>>::Reason, ) -> Result<<Pallet<T, I> as InspectAsset<Proprietor<T>>>::Asset, DispatchError>

Retrieves the total value of a reason or a specific digest model.

For a specific digest model, computes the total of all dispositions (Affirmative, Contrary, Awaiting) for direct digests, or delegates to index/pool calculations as appropriate. If no model is provided, returns the stored top-level reason value.

§Returns
  • Ok(CommitmentAsset<T, I>) representing the total value
  • Err(DispatchError) if the reason is not found or digest value calculation fails
Source§

impl<T: Config<I>, I: 'static> CommitOps<<T as Config>::AccountId, Pallet<T, I>> for CommitHelpers<T, I>

Implements the CommitOps trait for the pallet

Provides low-level (not-lowest, but still unchecked) write functionalities for digests, indexes, and pools within the commitment system. This may utilize other commit-helper trait methods

Source§

fn place_commit_of( who: &Proprietor<T>, reason: &<Pallet<T, I> as Commitment<Proprietor<T>>>::Reason, digest_model: &<Pallet<T, I> as DigestModel<Proprietor<T>>>::Model, value: <Pallet<T, I> as InspectAsset<Proprietor<T>>>::Asset, variant: &<Pallet<T, I> as CommitVariant<Proprietor<T>>>::Position, qualifier: &DispatchPolicy, ) -> Result<<Pallet<T, I> as InspectAsset<Proprietor<T>>>::Asset, DispatchError>

Places (creates) a commitment for a given digest model with the specified variant.

This function centralizes the dispatches to the appropriate underlying handler depending on the type of the digest model (Direct, Index, or Pool).

Digest models represent different commitment structures:

  • Direct: a single digest commitment.
  • Index: a grouped commitment of multiple entry digests.
  • Pool: a shared resource i.e., a collective single commitment.
§Returns
  • Ok(Asset) containing the committed amount
  • Err(DispatchError) if placement fails
Source§

fn place_digest_commit( who: &Proprietor<T>, reason: &<Pallet<T, I> as Commitment<Proprietor<T>>>::Reason, digest: &<Pallet<T, I> as Commitment<Proprietor<T>>>::Digest, value: <Pallet<T, I> as InspectAsset<Proprietor<T>>>::Asset, variant: &<Pallet<T, I> as CommitVariant<Proprietor<T>>>::Position, qualifier: &DispatchPolicy, ) -> Result<<Pallet<T, I> as InspectAsset<Proprietor<T>>>::Asset, DispatchError>

Places (creates) a direct commitment for a specific digest of a given variant under a reason.

This function is the base implementation for placing commitments when the digest represents a single, direct item (not an index or pool).

Allows placing a commitment even if the digest does not already exist in the system.

§Returns
  • Ok(Asset) containing the actual committed amount
  • Err(DispatchError) if placement fails
Source§

fn place_index_commit( who: &Proprietor<T>, reason: &<Pallet<T, I> as Commitment<Proprietor<T>>>::Reason, index_of: &<Pallet<T, I> as Commitment<Proprietor<T>>>::Digest, value: <Pallet<T, I> as InspectAsset<Proprietor<T>>>::Asset, variant: &<Pallet<T, I> as CommitVariant<Proprietor<T>>>::Position, qualifier: &DispatchPolicy, ) -> Result<<Pallet<T, I> as InspectAsset<Proprietor<T>>>::Asset, DispatchError>

Places a commitment to an index digest under the specified reason.

Distributes the committed value proportionally across index entries based on their shares, creates entry-level commitment records, and updates the index balance.

§Returns
  • Ok(Asset) containing the actual committed amount
  • Err(DispatchError) if placement fails
Source§

fn place_pool_commit( who: &Proprietor<T>, reason: &<Pallet<T, I> as Commitment<Proprietor<T>>>::Reason, pool_of: &<Pallet<T, I> as Commitment<Proprietor<T>>>::Digest, value: <Pallet<T, I> as InspectAsset<Proprietor<T>>>::Asset, variant: &<Pallet<T, I> as CommitVariant<Proprietor<T>>>::Position, qualifier: &DispatchPolicy, ) -> Result<<Pallet<T, I> as InspectAsset<Proprietor<T>>>::Asset, DispatchError>

Places a commitment to a pool digest under the specified reason.

Deposits to the pool’s collective balance, updates slot digests proportionally, and maintains pool-level commitment records.

§Returns
  • Ok(Asset) containing the actual committed amount
  • Err(DispatchError) if placement fails
Source§

fn raise_commit_of( who: &Proprietor<T>, reason: &<Pallet<T, I> as Commitment<Proprietor<T>>>::Reason, digest_model: &<Pallet<T, I> as DigestModel<Proprietor<T>>>::Model, value: <Pallet<T, I> as InspectAsset<Proprietor<T>>>::Asset, qualifier: &DispatchPolicy, ) -> Result<<Pallet<T, I> as InspectAsset<Proprietor<T>>>::Asset, DispatchError>

Raises (increases) an existing commitment for a given digest model.

This function centralizes the dispatches to the appropriate underlying handler depending on the type of the digest model (Direct, Index, or Pool).

Digest models represent different commitment structures:

  • Direct: a single digest commitment.
  • Index: a grouped commitment of multiple entry digests.
  • Pool: a shared resource i.e., a collective single commitment.
§Returns
  • Ok(Asset) containing the raised amount
  • Err(DispatchError) if the raise operation fails
Source§

fn raise_digest_commit( who: &Proprietor<T>, reason: &<Pallet<T, I> as Commitment<Proprietor<T>>>::Reason, digest: &<Pallet<T, I> as Commitment<Proprietor<T>>>::Digest, value: <Pallet<T, I> as InspectAsset<Proprietor<T>>>::Asset, qualifier: &DispatchPolicy, ) -> Result<<Pallet<T, I> as InspectAsset<Proprietor<T>>>::Asset, DispatchError>

Raises (increases) a commitment for a direct digest under a given reason.

This function is the base implementation for raising commitments when the target is an direct digest rather than a index or pool.

Unlike Self::place_digest_commit this adds a additional commit instance to the list of commits to the same direct digest enforcing the One Reason One Digest Per Proprietor invariant.

§Returns
  • Ok(Asset) containing the raised amount
  • Err(DispatchError) if the raise operation fails
Source§

fn raise_index_commit( who: &Proprietor<T>, reason: &<Pallet<T, I> as Commitment<Proprietor<T>>>::Reason, index_of: &<Pallet<T, I> as Commitment<Proprietor<T>>>::Digest, value: <Pallet<T, I> as InspectAsset<Proprietor<T>>>::Asset, qualifier: &DispatchPolicy, ) -> Result<<Pallet<T, I> as InspectAsset<Proprietor<T>>>::Asset, DispatchError>

Raises (increases) an existing commitment for a specific index under a given reason.

This function is the base implementation for raising commitments when the target is an index rather than a digest or pool.

Unlike Self::place_index_commit this adds a additional commit instance to the list of commits to the same index digest enforcing the One Reason One Digest Per Proprietor invariant.

§Returns
  • Ok(Asset) containing the raised amount
  • Err(DispatchError) if the raise operation fails
Source§

fn raise_pool_commit( who: &Proprietor<T>, reason: &<Pallet<T, I> as Commitment<Proprietor<T>>>::Reason, pool_of: &<Pallet<T, I> as Commitment<Proprietor<T>>>::Digest, value: <Pallet<T, I> as InspectAsset<Proprietor<T>>>::Asset, qualifier: &DispatchPolicy, ) -> Result<<Pallet<T, I> as InspectAsset<Proprietor<T>>>::Asset, DispatchError>

Raises (increases) an existing commitment for a specific pool digest under a given reason.

This function is the base implementation for raising commitments when the target is an pool rather than a digest or index.

Unlike Self::place_pool_commit this adds a additional commit instance to the list of commits to the same pool digest enforcing the One Reason One Digest Per Proprietor invariant.

§Returns
  • Ok(Asset) containing the raised amount
  • Err(DispatchError) if the raise operation fails
Source§

fn resolve_commit_of( who: &Proprietor<T>, reason: &<Pallet<T, I> as Commitment<Proprietor<T>>>::Reason, digest_model: &<Pallet<T, I> as DigestModel<Proprietor<T>>>::Model, ) -> Result<<Pallet<T, I> as InspectAsset<Proprietor<T>>>::Asset, DispatchError>

Resolves (withdraws) and finalizes a commitment for a given digest model.

This function centralizes the dispatches to the appropriate underlying handler depending on the type of the digest model (Direct, Index, or Pool).

Digest models represent different commitment structures:

  • Direct: a single digest commitment.
  • Index: a grouped commitment of multiple entry digests.
  • Pool: a shared resource i.e., a collective single commitment.
§Returns
  • Ok(Asset) containing the resolved commitment value
  • Err(DispatchError) if resolution fails
Source§

fn resolve_digest_commit( who: &Proprietor<T>, reason: &<Pallet<T, I> as Commitment<Proprietor<T>>>::Reason, digest: &<Pallet<T, I> as Commitment<Proprietor<T>>>::Digest, ) -> Result<<Pallet<T, I> as InspectAsset<Proprietor<T>>>::Asset, DispatchError>

Resolves (withdraws) and finalizes a commitment for a direct digest under a given reason.

This function is the base implementation for resolving commitments when the target is an direct digest rather than a index or pool.

It resolves all commit instances tied to a direct digest of a reason.

§Returns
  • Ok(Asset) containing the resolved commitment value
  • Err(DispatchError) if resolution fails
Source§

fn resolve_index_commit( who: &Proprietor<T>, reason: &<Pallet<T, I> as Commitment<Proprietor<T>>>::Reason, index_of: &<Pallet<T, I> as Commitment<Proprietor<T>>>::Digest, ) -> Result<<Pallet<T, I> as InspectAsset<Proprietor<T>>>::Asset, DispatchError>

Resolves (withdraws) and finalizes a commitment for a index digest under a given reason.

This function is the base implementation for resolving commitments when the target is an index rather than a direct digest or pool.

It resolves all commit instances tied to a index digest of a reason.

§Returns
  • Ok(Asset) containing the resolved commitment value
  • Err(DispatchError) if resolution fails
Source§

fn resolve_pool_commit( who: &Proprietor<T>, reason: &<Pallet<T, I> as Commitment<Proprietor<T>>>::Reason, pool_of: &<Pallet<T, I> as Commitment<Proprietor<T>>>::Digest, ) -> Result<<Pallet<T, I> as InspectAsset<Proprietor<T>>>::Asset, DispatchError>

Resolves (withdraws) and finalizes a commitment for a pool digest under a given reason.

This function is the base implementation for resolving commitments when the target is an pool rather than a direct digest or index.

It resolves all commit instances tied to a pool digest of a reason.

§Returns
  • Ok(Asset) containing the resolved commitment value
  • Err(DispatchError) if resolution fails
Source§

fn set_total_value( reason: &<Pallet<T, I> as Commitment<Proprietor<T>>>::Reason, value: <Pallet<T, I> as InspectAsset<Proprietor<T>>>::Asset, )

Sets the total asset value for a given reason.

Use with caution! This is a low-level storage operation that directly updates the reason’s total value without validation.

For safe usage Self::add_to_total_value and Self::sub_from_total_value.

Used internally during deposit and withdrawal operations to maintain accurate aggregate tracking.

This value should not be treated like digest values, rewards/inflation, or penalties/deflation.

Source§

fn add_to_total_value( reason: &Pallet::Reason, value: <Pallet as InspectAsset<Proprietor>>::Asset, ) -> DispatchResult

Adds a given asset value to the total value for the specified reason. Read more
Source§

fn sub_from_total_value( reason: &Pallet::Reason, value: <Pallet as InspectAsset<Proprietor>>::Asset, ) -> DispatchResult

Subtracts a given asset value from the total value for the specified reason. Read more
Source§

impl<T: Config<I>, I: 'static> CommitPool<<T as Config>::AccountId> for Pallet<T, I>

Implements CommitPool for the pallet

Source§

type Pool = PoolInfo<T, I>

Pool struct representing a pool’s internal structure.

Contains the pool’s balance, capital, slots, commission rate, and other metadata required for pool operations and value calculations.

Source§

type Commission = <T as Config<I>>::Commission

Commission rate for the pool.

Represents the fraction of withdrawals collected by the pool manager as compensation for managing the pool.

Source§

fn pool_exists(reason: &Self::Reason, pool_of: &Self::Digest) -> DispatchResult

Checks whether a pool exists for the given reason and digest.

§Returns
  • Ok(()) if the pool exists
  • Err(DispatchError) if the pool does not exist
Source§

fn slot_exists( reason: &Self::Reason, pool_of: &Self::Digest, slot_of: &Self::Digest, ) -> DispatchResult

Checks whether a specific slot exists within a given pool.

§Returns
  • Ok(()) if the slot exists
  • Err(DispatchError) with SlotOfPoolNotFound if the slot does not exist
Source§

fn has_pool(reason: &Self::Reason) -> DispatchResult

Checks whether at least one pool exists for the given reason.

§Returns
  • Ok(()) if at least one pool exists
  • Err(DispatchError) with PoolNotFound if no pools exist
Source§

fn get_manager( reason: &Self::Reason, pool_of: &Self::Digest, ) -> Result<Proprietor<T>, DispatchError>

Retrieves the manager of a given pool.

Invariant enforced that every valid pool, must have a valid manager. For unmanaged distribution of commitments, CommitIndex exists.

§Returns
  • Ok(Proprietor) containing the pool manager’s account id
  • Err(DispatchError) with PoolManagerNotFound if no manager is set
Source§

fn get_commission( reason: &Self::Reason, pool_of: &Self::Digest, ) -> Result<Self::Commission, DispatchError>

Retrieves the commission rate of a given pool.

§Returns
  • Ok(Commission) containing the pool’s commission rate
  • Err(DispatchError) with PoolNotFound if the pool does not exist
Source§

fn get_pool( reason: &Self::Reason, pool_of: &Self::Digest, ) -> Result<Self::Pool, DispatchError>

Retrieves the pool information for a given reason and digest.

§Returns
  • Ok(Pool) containing the pool structure
  • Err(DispatchError) with PoolNotFound if the pool does not exist
Source§

fn get_slots_shares( reason: &Self::Reason, pool_of: &Self::Digest, ) -> Result<Vec<(Self::Digest, Self::Shares)>, DispatchError>

Retrieves all slot digests of a pool along with their respective shares.

§Returns
  • Ok(Vec<(Digest, Shares)>) containing each slot’s digest and shares
  • Err(DispatchError) if the pool does not exist
Source§

fn get_slot_value( reason: &Self::Reason, pool_of: &Self::Digest, slot_of: &Self::Digest, ) -> Result<Self::Asset, DispatchError>

Computes the real-time value of a specific slot digest in a pool across all proprietors.

§Returns
  • Ok(Asset)containing the aggregated slot value
  • Err(DispatchError) if the slot does not exist
Source§

fn get_slot_value_for( who: &Proprietor<T>, reason: &Self::Reason, pool_of: &Self::Digest, slot_of: &Self::Digest, ) -> Result<Self::Asset, DispatchError>

Computes the real-time value of a specific slot digest in a pool for a given proprietor.

§Returns
  • Ok(Asset) containing the proprietor’s slot value
  • Err(DispatchError) if the slot does not exist
Source§

fn get_pool_value_for( who: &Proprietor<T>, reason: &Self::Reason, pool_of: &Self::Digest, ) -> Result<Self::Asset, DispatchError>

Computes the real-time value of a pool-commit for a given proprietor.

§Returns
  • Ok(Asset) containing the proprietor’s pool value
  • Err(DispatchError) if the slot does not exist
Source§

fn gen_pool_digest( who: &Proprietor<T>, reason: &Self::Reason, index_of: &Self::Digest, commission: Self::Commission, ) -> Result<Self::Digest, DispatchError>

Generates a unique digest for a pool derived from a given index.

Pools are created from indexes, and each pool digest must be unique. This function deterministically derives a digest using:

  • The caller (who) as the target
  • The reason under which the pool is created
  • The pool’s internal entries and specified commission
  • The caller’s account nonce as a salt

This digest can then be used to create or reference the pool in the system.

§Returns
  • Ok(Digest) containing the unique pool digest
  • Err(DispatchError) if digest generation fails
Source§

fn set_pool( who: &Proprietor<T>, reason: &Self::Reason, pool_of: &Self::Digest, index_of: &Self::Digest, commission: Self::Commission, ) -> DispatchResult

Creates a new pool based on an existing index with a specified commission rate.

Pools are immutable with respect to their commission. Any changes to entries require modifying slots directly or creating a new pool.

  • Retrieves the index information to populate the pool slots.
  • Converts each index entry into a pool slot, preserving the shares.
  • Sets the caller as the manager of the new pool.
§Returns
  • Ok(()) if the pool was successfully created
  • Err(DispatchError) with PoolDigestTaken if a pool with this digest already exists
Source§

fn set_pool_manager( reason: &Self::Reason, pool_of: &Self::Digest, manager: &Proprietor<T>, ) -> DispatchResult

Sets or updates the manager for a specific pool.

The manager is responsible for handeling pool operations including risk management, applying strategies on behalf of pool participants, and earning commission based on the pool’s rules.

§Returns
  • Ok(()) if the manager was successfully set
  • Err(DispatchError) if the pool does not exist
Source§

fn set_slot_shares( who: &Proprietor<T>, reason: &Self::Reason, pool_of: &Self::Digest, slot_of: &Self::Digest, shares: Self::Shares, ) -> DispatchResult

Sets or updates the shares of a specific slot within a pool.

Unlike indexes, pools are mutable and managed internally, so modifying a slot does not produce a new digest. Each mutation releases and recovers the pool to maintain real-time balances.

If the slot already exists:

  • A zero share value removes the slot from the pool.
  • A non-zero share value updates the slot’s shares while keeping its variant.

Nested cases-such as pool slots referencing other pools or indexes are not supported and may be treated as new direct digests when routed through CommitDeposit::deposit_to_digest. Callers are responsible for validating such cases if required.

If the slot does not exist:

  • A zero share value returns early without any changes.
  • A non-zero share value creates a new slot with the default variant.

DispatchError if fails

Source§

fn reap_pool(reason: &Self::Reason, pool_of: &Self::Digest) -> DispatchResult

Removes a pool from the system if all deposits have been withdrawn.

Any residual funds (dust) remaining in the pool are automatically refunded to the pool manager.

This function doesn’t ensures the pool’s current manager as it should be validated elsewhere if required.

§Returns
  • Ok(()) if the pool was successfully removed
  • Err(DispatchError) otherwise
Source§

fn on_set_pool( _who: &Proprietor<T>, pool_of: &Self::Digest, reason: &Self::Reason, pool: &Self::Pool, )

Emits an event when a new pool is created or initialized.

Source§

fn on_set_manager( pool_of: &Self::Digest, reason: &Self::Reason, manager: &Proprietor<T>, )

Emits an event when the manager of a pool is set or updated.

Emits a Event::PoolManager event if Config::EmitEvents is true.

Source§

fn on_set_slot_shares( pool_of: &Self::Digest, reason: &Self::Reason, slot_of: &Self::Digest, shares: Self::Shares, )

Emits an event when the shares of a specific slot in a pool are updated.

This method delagates itself to PoolVariant::on_set_slot_of_variant with the default position variant.

Source§

fn on_reap_pool( pool_of: &Self::Digest, reason: &Self::Reason, dust: Self::Asset, )

Emits an event when a pool is reaped (removed).

Emits a Event::PoolReaped event if Config::EmitEvents is true.

Source§

fn get_pool_value( reason: &Self::Reason, pool_of: &Self::Digest, ) -> Result<Self::Asset, DispatchError>

Retrieves the real-time aggregated value of the specified pool. Read more
Source§

fn get_slots_value( reason: &Self::Reason, pool_of: &Self::Digest, ) -> Result<Vec<(Self::Digest, Self::Asset)>, DispatchError>

Retrieves the real-time values of all slots within the specified pool. Read more
Source§

fn get_slots_value_for( who: &Proprietor, reason: &Self::Reason, pool_of: &Self::Digest, ) -> Result<Vec<(Self::Digest, Self::Asset)>, DispatchError>

Retrieves the real-time values of a proprietor’s commitments to all slots within the specified pool. Read more
Source§

fn set_commission( who: &Proprietor, reason: &Self::Reason, index_of: &Self::Digest, commission: Self::Commission, ) -> Result<Self::Digest, DispatchError>

Creates a new pool digest from an index with a specified commission rate. Read more
Source§

impl<T: Config<I>, I: 'static> CommitVariant<<T as Config>::AccountId> for Pallet<T, I>

Implements CommitVariant for the pallet

Source§

type Position = <T as Config<I>>::Position

Defines the commitment position variant type for a proprietor.

Acts as the logical “stance” or directional disposition of a commitment.

Source§

fn can_set_digest_variant_value( reason: &Self::Reason, digest: &Self::Digest, value: Self::Asset, variant: &Self::Position, qualifier: &Self::Intent, ) -> DispatchResult

Validates whether a digest-variant value can be set.

Same as the default trait validation, but extended with additional checks against the underlying balance model to ensure minting or reaping can actually be applied.

In the lazy balance model, value updates are interpreted as:

  • Increase -> mint
  • Decrease -> reap

Missing digest or variant state is treated as a default (fresh) balance, but validation still depends on the underlying lazy balance model and may fail.

§Returns
  • Ok(()) if validation succeeds
  • Err(DispatchError) if any constraint is violated
Source§

fn can_place_commit_of_variant( who: &Proprietor<T>, reason: &Self::Reason, digest: &Self::Digest, variant: &Self::Position, value: Self::Asset, qualifier: &Self::Intent, ) -> DispatchResult

Validates whether a new commitment can be placed for a specific variant.

Same as the default trait validation, but extended with an additional check against the underlying balance model to ensure the deposit can actually be applied.

Missing digest or variant state is treated as a fresh balance; in such cases, a default balance is used to derive limits and validate the deposit.

§Returns
  • Ok(()) if validation succeeds
  • Err(DispatchError) if any constraint is violated
Source§

fn get_commit_variant( who: &Proprietor<T>, reason: &Self::Reason, ) -> Result<Self::Position, DispatchError>

Retrieves the current commitment variant for a proprietor and reason.

In-case of indexes and pools its always the default variant of Config::Position since its entries and slots carry the actual variants for which this commit is distributed.

§Returns
  • Ok(Position) containing the commitment’s variant
  • Err(DispatchError) with CommitNotFound if no commitment exists
Source§

fn get_digest_variant_value( reason: &Self::Reason, digest: &Self::Digest, variant: &Self::Position, ) -> Result<Self::Asset, DispatchError>

Retrieves the real-time effective value of a specific digest variant for a given reason.

§Returns
  • Ok(Asset) containing the variant’s effective value, or zero if the variant does not exist
  • Err(DispatchError) with DigestNotFound if the digest does not exist
Source§

fn digest_mint_limits_of_variant( digest: &Self::Digest, reason: &Self::Reason, variant: &Self::Position, qualifier: &Self::Intent, ) -> Result<Self::Limits, DispatchError>

Derives minting limits for a specific digest variant.

Fetches the current lazy balance of the given (reason, digest, variant) and computes the applicable minting limits using the underlying balance model.

If the digest not exists nor the variant has an initialized balance, the limits are derived using a default (empty) balance.

§Returns
  • Ok(Limits) containing the derived minting constraints
  • Err(DispatchError) if the limit derivation fails
Source§

fn digest_reap_limits_of_variant( digest: &Self::Digest, reason: &Self::Reason, variant: &Self::Position, qualifier: &Self::Intent, ) -> Result<Self::Limits, DispatchError>

Derives reaping limits for a specific digest variant.

Fetches the current lazy balance of the given (reason, digest, variant) and computes the applicable reaping limits using the underlying balance model.

If the digest does not exists nor the variant has a initialized balance, limits are derived using a default (empty) balance.

§Returns
  • Ok(Limits) containing the derived reaping constraints
  • Err(DispatchError) if the limit derivation fails
Source§

fn place_commit_limits_of_variant( _who: &Proprietor<T>, reason: &Self::Reason, digest: &Self::Digest, variant: &Self::Position, qualifier: &Self::Intent, ) -> Result<Self::Limits, DispatchError>

Derives the place commit limits for the given commitment-params.

Fetches the current lazy balance of the given (reason, digest, variant) and computes the applicable deposit limits using the underlying balance model.

  • For Direct digests, limits are derived based on existing digest balance.
  • For Index or Pool digests, no digest-level balance info exists, hence limits are treated as unbounded.

If the direct digest does not exist or the variant has no initialized balance, limits are derived using a default (empty) balance.

§Returns
  • Ok(Limits) containing the derived placement constraints
  • Err(DispatchError) if the limit derivation fails
Source§

fn set_digest_variant_value( reason: &Self::Reason, digest: &Self::Digest, value: Self::Asset, variant: &Self::Position, qualifier: &Self::Intent, ) -> Result<Self::Asset, DispatchError>

Sets the effective value of a specific digest variant for a given reason.

It is expected that the variant is initiated via a commitment before setting it.

Automatically handles minting (for increases) or reaping (for decreases) of assets, and updates the total reason value accordingly. This operation directly modifies the low-level digest variant balance without affecting other variants.

The qualifier influences how minting/reaping is applied and may affect the final value that is actually set.

§Returns
  • Ok(Asset) containing the resulting value of the digest-variant after update
  • Err(DispatchError) if the operation fails
Source§

fn place_commit_of_variant( who: &Proprietor<T>, reason: &Self::Reason, digest: &Self::Digest, value: Self::Asset, variant: &Self::Position, qualifier: &Self::Intent, ) -> Result<Self::Asset, DispatchError>

Places a commitment with a specific variant to a digest.

This function validates the commitment eligibility, determines the digest model (Direct, Index, or Pool), and registers the commitment with the specified variant and amount according to the provided precision and fortitude parameters.

Zero-value (marker) commitments are not allowed and will be rejected.

If the digest does not yet exist in the system, this function assumes it to be a direct digest (since indexes and pools require prior initialization) and initializes the commitment accordingly.

Callers must ensure that such digests are valid within their intended commitment context and agreement.

§Returns
  • Ok(Asset) containing the actual committed amount
  • Err(DispatchError) if placement fails
Source§

fn on_place_commit_on_variant( who: &Proprietor<T>, reason: &Self::Reason, digest: &Self::Digest, value: Self::Asset, variant: &Self::Position, )

Emits an event indicating that a commitment has been placed for a specific digest variant and proprietor.

The digest is verified and classified using DigestModel::determine_digest.

Emits Event::CommitPlaced event if Config::EmitEvents is true.

Source§

fn on_set_commit_variant( who: &Proprietor<T>, reason: &Self::Reason, digest: &Self::Digest, value: Self::Asset, variant: &Self::Position, )

Emits an event when a commit for a specific digest variant is updated.

This method delagates itself to CommitVariant::on_place_commit_on_variant with the default position variant.

Self::set_commit_variant is semantically similar to resolving and placing a new-commitment on a different variant internally.

Source§

fn on_set_digest_variant( digest: &Self::Digest, reason: &Self::Reason, value: Self::Asset, variant: &Self::Position, )

Emits an event when a digest variant’s effective value is updated.

This is typically triggered after a reward, penalty, or manual adjustment applied directly to a digest variant.

Emits Event::DigestInfo event if Config::EmitEvents is true.

Source§

fn set_commit_variant( who: &Proprietor, reason: &Self::Reason, variant: &Self::Position, qualifier: &Self::Intent, ) -> Result<(), DispatchError>

Changes the variant of an existing commitment. Read more
Source§

impl<T: Config<I>, I: 'static> CommitWithdraw<<T as Config>::AccountId, Pallet<T, I>> for CommitHelpers<T, I>

Implements the CommitWithdraw trait for the pallet

Provides low-level withdraw functionality for digests, indexes, and pools within the commitment system.

Source§

fn withdraw_for( who: &Proprietor<T>, reason: &<Pallet<T, I> as Commitment<Proprietor<T>>>::Reason, digest_model: &<Pallet<T, I> as DigestModel<Proprietor<T>>>::Model, variant: &<Pallet<T, I> as CommitVariant<Proprietor<T>>>::Position, ) -> Result<Self::Imbalance, DispatchError>

Withdraws the proprietor’s total committed value for a given digest model and reason.

This function centralizes the dispatches to the appropriate underlying handler depending on the type of the digest model (Direct, Index, or Pool).

Digest models represent different commitment structures:

  • Direct: a single digest commitment.
  • Index: a grouped commitment of multiple entry digests.
  • Pool: a shared resource i.e., a collective single commitment.
§Imbalance Semantics

The returned imbalance captures the difference between the original deposit made when the commitment was placed and the value withdrawn at resolution time. Since digests may accrue rewards or penalties over time, the withdrawn amount may differ from the original deposit; this difference is expected and is represented explicitly in the imbalance.

§Notes
  • Callers are expected to resolve this imbalance probably via CommitBalance::resolve_imbalance
  • The caller’s variant is ignored because each commit already defines its own variant during deposit operation.
§Returns
  • Ok(Imbalance) containing:
    • deposit: the original amount deposited when the commitment was placed.
    • withdraw: the amount withdrawn at resolution time.
  • Err(DispatchError) if any underlying withdrawal operation fails.
Source§

fn withdraw_from_digest( who: &Proprietor<T>, reason: &<Pallet<T, I> as Commitment<Proprietor<T>>>::Reason, digest: &<Pallet<T, I> as Commitment<Proprietor<T>>>::Digest, _variant: &<Pallet<T, I> as CommitVariant<Proprietor<T>>>::Position, ) -> Result<Self::Imbalance, DispatchError>

Withdraws the committed value for a single direct digest and variant.

This low-level function calculates the real-time effective value for all commit instances associated with this proprietor and digest, then updates the digest’s balance accordingly.

§Imbalance Semantics

The returned imbalance captures the difference between the original deposit made when the commitment was placed and the value withdrawn at resolution time. Since digests may accrue rewards or penalties over time, the withdrawn amount may differ from the original deposit; this difference is expected and is represented explicitly in the imbalance.

§Notes
  • Callers are expected to resolve this imbalance probably via CommitBalance::resolve_imbalance
  • The caller’s variant is ignored because each commit already defines its own variant during deposit operation.
§Returns
  • Ok(Imbalance) containing both the deposited and the withdrawn value
  • Err(DispatchError) if the digest or variant is not found
Source§

fn withdraw_from_index( who: &Proprietor<T>, reason: &<Pallet<T, I> as Commitment<Proprietor<T>>>::Reason, index_of: &<Pallet<T, I> as Commitment<Proprietor<T>>>::Digest, _variant: &<Pallet<T, I> as CommitVariant<Proprietor<T>>>::Position, ) -> Result<Self::Imbalance, DispatchError>

Withdraws the committed value for a given index digest.

Iterates over all entries in the index, calculates each entry’s effective withdrawal, and updates entry digest balances while removing commitment records from storage.

§Imbalance Semantics

The returned imbalance captures the difference between the original deposit made when the commitment was placed and the value withdrawn at resolution time. Since digests may accrue rewards or penalties over time, the withdrawn amount may differ from the original deposit; this difference is expected and is represented explicitly in the imbalance.

§Notes
  • Callers are expected to resolve this imbalance probably via CommitBalance::resolve_imbalance
  • The caller’s variant is ignored because each commit belongs to an entry already defines its own variant during deposit operation.
  • Since an index is an immutable structure-where entry updates result in a new index, no inconsistencies can arise.
§Returns
  • Ok(Imbalance) representing total withdrawn and deposited values across all entries
  • Err(DispatchError) if the index or any entry is not found
Source§

fn withdraw_from_pool( who: &Proprietor<T>, reason: &<Pallet<T, I> as Commitment<Proprietor<T>>>::Reason, pool_of: &<Pallet<T, I> as Commitment<Proprietor<T>>>::Digest, _variant: &<Pallet<T, I> as CommitVariant<Proprietor<T>>>::Position, ) -> Result<Self::Imbalance, DispatchError>

Withdraws the committed value for a pool digest.

The pool balance is released first, then each commitment within the pool is resolved. Withdrawn values are accumulated, pool state is recovered, and commissions are handled (provided to manager internally itself) according to the pool’s configuration.

This low-level operation ensures the proprietor receives their imbalance while also minting, burning, or reallocating tokens due to commission configuration for the manager only.

§Returns
  • Ok(Imbalance) containing total deposited and withdrawn amounts after commissions
  • Err(DispatchError) if the pool is not found or withdrawal fails
Source§

impl<T: Config<I>, I: 'static> Commitment<<T as Config>::AccountId> for Pallet<T, I>

Implements the base Commitment trait for the pallet.

Source§

type DigestSource = <T as Config>::AccountId

The source of a digest, used to determine the concrete digest.

In this implementation, the digest source is the the calling source i.e., [frame_system::Config::AccountId]. Must be using its account nonce for deterministic-randomness.

This means all digests - whether direct, index, or pool - have a deterministic account ID generated by Commitment::gen_digest and similar methods.

Internally, the methods enforces generating the Commitment::Digest same as the source type.

Source§

type Digest = <T as Config>::AccountId

The digest type used in this pallet, based on account ID type (from [frame_system::Config::AccountId]).

This ensures all digests are tied to a consistent, predictable identity, same as every accounts. Much alike contract addresses.

Source§

type Reason = <<T as Config<I>>::Asset as Inspect<<T as Config>::AccountId>>::Id

The reason associated with a commitment.

This type is linked to the Id type of the InspectFreeze fungible trait, typically a composite enum constructed at runtime from all pallets that use fungible properties.

Declaring Reason as the top-level key:

  • Encourages compile-time reasons for commitments.
  • Prevents creating new reasons at runtime without explicit intent.
  • Ensures other pallets adopt this commitment structure for consistent behavior.
Source§

type Intent = DispatchPolicy

Commitment operation top level configuration.

Enforces exactness and forcefullness towards a commit operation.

Source§

type Limits = LimitsProduct<T, I>

Type representing the derived limits used for commitment validations.

Encapsulates bounds (e.g. minimum, maximum, optimal) computed by the underlying balance model for deposit, mint, and reap operations.

Source§

fn commit_exists(who: &Proprietor<T>, reason: &Self::Reason) -> DispatchResult

Checks whether a commitment exists for the given proprietor and reason.

§Returns
  • Ok(()) if a commitment exists
  • Err(DispatchError) if no commitment exists
Source§

fn digest_exists(reason: &Self::Reason, digest: &Self::Digest) -> DispatchResult

Checks whether a direct-digest exists for the given reason.

This doesn’t ensures existence for index or pool digests, as callers should use CommitIndex::index_exists or CommitPool::pool_exists

§Returns
  • Ok(()) if the digest exists
  • Err(DispatchError) if the digest does not exist
Source§

fn can_place_commit( who: &Proprietor<T>, reason: &Self::Reason, digest: &Self::Digest, value: Self::Asset, qualifier: &Self::Intent, ) -> DispatchResult

Validates whether a new commitment can be placed with the variant’s Config::Position default.

This is a thin wrapper over Self::can_place_commit_of_variant, using the default Config::Position for non-variant commitments.

§Returns
  • Ok(()) if validation succeeds
  • Err(DispatchError) if validation fails
Source§

fn can_raise_commit( who: &Proprietor<T>, reason: &Self::Reason, value: Self::Asset, qualifier: &Self::Intent, ) -> DispatchResult

Validates whether an existing commitment can be increased (raised).

Same as the default trait validation, but extended with an additional check against the underlying balance model to ensure the deposit can actually be applied.

In the lazy balance model, raising is equivalent to performing an additional deposit and the underlying system does not distinguish between placing and raising.

§Returns
  • Ok(()) if validation succeeds
  • Err(DispatchError) if any constraint is violated
Source§

fn can_resolve_commit( who: &Proprietor<T>, reason: &Self::Reason, ) -> DispatchResult

Validates whether a commitment can be resolved.

Extends the default trait behavior by additionally validating that all underlying balances can support the required withdrawals.

Since each digest model maintains balances differently:

  • Direct / Index: withdrawals are validated directly against their balances
  • Pool: validation is performed against the pool’s current (unadjusted) aggregate balance, without applying intermediate slot updates

This is a lightweight validation step; full consistency (including pool rebalancing) is enforced during the actual resolution operation.

§Returns
  • Ok(()) if all withdrawals are valid
  • Err(DispatchError) if any withdrawal is invalid
Source§

fn can_set_digest_value( reason: &Self::Reason, digest: &Self::Digest, value: Self::Asset, qualifier: &Self::Intent, ) -> DispatchResult

Validates whether a digest’s value can be set using the default variant.

This is a thin wrapper over Self::can_set_digest_variant_value, using the default Config::Position for single non-variant commitments.

§Returns
  • Ok(()) if validation succeeds
  • Err(DispatchError) if validation fails
Source§

fn get_commit_digest( who: &Proprietor<T>, reason: &Self::Reason, ) -> Result<Self::Digest, DispatchError>

Retrieves the digest associated with a proprietor’s commitment.

Since Commitment::Digest is opaque to identify as direct or index or pool. This function can return any digest model which later can be determined using DigestModel::determine_digest.

Since each reason can only have one active digest per proprietor, this directly returns the commitment’s digest.

§Returns
  • Ok(Digest) containing the commitment’s digest
  • Err(DispatchError) if no commitment exists
Source§

fn get_total_value(reason: &Self::Reason) -> Self::Asset

Retrieves the total committed value across all proprietors for a reason.

§Returns
  • Asset containing the total committed value, or zero if unavailable
Source§

fn get_commit_value( who: &Proprietor<T>, reason: &Self::Reason, ) -> Result<Self::Asset, DispatchError>

Retrieves the real-time committed value for a specific proprietor and reason.

This value reflects the current state including any applied rewards or penalties. Since each proprietor can only have one active digest per reason, this returns the aggregate value across all commitment instances for that digest.

Internally, raising commits doesn’t mutate an existing commitment-balance but instead accmulate new immutable balances as commit-instances which will be aggregated.

§Returns
  • Ok(Asset) containing the proprietor’s current committed value
  • Err(DispatchError) if no commitment exists
Source§

fn get_digest_value( reason: &Self::Reason, digest: &Self::Digest, ) -> Result<Self::Asset, DispatchError>

Retrieves the real-time total value of a specific direct-digest’s default variant of Config::Position for a given reason.

This doesn’t provides value for index or pool digests, as callers should use CommitIndex::get_index_value or CommitPool::get_pool_value

Aggregates all commitments across all proprietors who committed funds to this digest’s default variant.

This method delagates itself to CommitVariant::get_digest_variant_value with the default position variant.

§Returns
  • Ok(Asset) containing the digest’s total value
  • Err(DispatchError) if the digest does not exist
Source§

fn place_commit_limits( who: &Proprietor<T>, reason: &Self::Reason, digest: &Self::Digest, qualifier: &Self::Intent, ) -> Result<Self::Limits, DispatchError>

Derives place commit limits for the given params of the default commit-variant.

This is a convenience wrapper over Self::place_commit_limits_of_variant, using the default Config::Position for non-variant commitments.

§Returns
  • Ok(Limits) containing the derived constraints
  • Err(DispatchError) if the derivation fails
Source§

fn raise_commit_limits( who: &Proprietor<T>, reason: &Self::Reason, qualifier: &Self::Intent, ) -> Result<Self::Limits, DispatchError>

Derives limits for increasing (raising) an existing commitment under the default commit-variant.

Resolves the commit’s associated digest and variant for the given proprietor and reason, then delegates to Self::place_commit_limits_of_variant.

In the lazy balance model, raising is equivalent to performing an additional deposit on an existing commitment, so the same limit derivation logic applies.

The qualifier influences how limits are derived.

§Returns
  • Ok(Limits) containing the derived constraints
  • Err(DispatchError) if the commitment does not exist or derivation fails
Source§

fn digest_mint_limits( digest: &Self::Digest, reason: &Self::Reason, qualifier: &Self::Intent, ) -> Result<Self::Limits, DispatchError>

Derives minting limits for a digest using the default variant.

This is a convenience wrapper over Self::digest_mint_limits_of_variant, using the default Config::Position for single non-variant digests.

The qualifier influences how limits are derived (e.g. strict vs relaxed).

§Returns
  • Ok(Limits) containing the derived minting constraints
  • Err(DispatchError) if the derivation fails
Source§

fn digest_reap_limits( digest: &Self::Digest, reason: &Self::Reason, qualifier: &Self::Intent, ) -> Result<Self::Limits, DispatchError>

Derives reaping limits for a digest using the default variant.

This is a convenience wrapper over Self::digest_reap_limits_of_variant, using the default Config::Position for single non-variant digests.

The qualifier influences how limits are derived (e.g. strict vs relaxed).

§Returns
  • Ok(Limits) containing the derived reaping constraints
  • Err(DispatchError) if the derivation fails
Source§

fn gen_digest(source: &DigestSource<T>) -> Result<Self::Digest, DispatchError>

Generates a unique digest identifier from the given source.

Uses the account nonce as a salt to ensure uniqueness across multiple digest generations for the same source.

Utilizes KeyGenFor trait implementation via KeySeedFor

§Returns
  • Ok(Digest) containing the generated digest
  • Err(DispatchError) if digest generation fails
Source§

fn place_commit( who: &Proprietor<T>, reason: &Self::Reason, digest: &Self::Digest, value: Self::Asset, qualifier: &Self::Intent, ) -> Result<Self::Asset, DispatchError>

Places a commitment with the variant’s Config::Position default.

This method delagates itself to CommitVariant::place_commit_of_variant with the default position variant.

For detailed information on how placing a commitment works, refer to the called implemented method CommitVariant::place_commit_of_variant.

§Returns
  • Ok(Asset) containing the actual committed amount
  • Err(DispatchError) if placement fails
Source§

fn resolve_commit( who: &Proprietor<T>, reason: &Self::Reason, ) -> Result<Self::Asset, DispatchError>

Resolves and withdraws a commitment for the given proprietor and reason.

Calculates the final value including any rewards or penalties, unfreezes the committed assets, and returns them to the owner (authorized-caller).

The commitment record is removed upon successful resolution.

§Returns
  • Ok(Asset) containing the resolved amount returned to the proprietor
  • Err(DispatchError) if no commitment exists or resolution fails
Source§

fn raise_commit( who: &Proprietor<T>, reason: &Self::Reason, value: Self::Asset, qualifier: &Self::Intent, ) -> Result<Self::Asset, DispatchError>

Raises a commitment for the given proprietor and reason.

Enforces that the proprietor must already have an active commitment for the given reason.

Does not allow zero-value marker commitments.

§Returns
  • Ok(Asset) containing the raised amount
  • Err(DispatchError) if no existing commitment is found or funds are insufficient
Source§

fn set_digest_value( reason: &Self::Reason, digest: &Self::Digest, value: Self::Asset, qualifier: &Self::Intent, ) -> Result<Self::Asset, DispatchError>

Sets a direct value on a digest, typically for applying rewards/inflation or penalties/deflation.

Note: This function operates at the low-level commitment for a direct-digest. It cannot be used to directly apply rewards or penalties to indexes or pools, because those maintain their balances at a higher level through their entries and slots digests.

Any value adjustment for indexes or pools should propagate via their underlying sub-systems if applicable.

Internally calls CommitVariant::set_digest_variant_value with the default variant of Config::Position.

The qualifier influences how the adjustment (via the given direction which could be increase or decrease from current digest value) is applied and may affect the final value that is actually set.

§Returns
  • Ok(Asset) containing the resulting value of the digest after update
  • Err(DispatchError) if the operation fails
Source§

fn reap_digest(digest: &Self::Digest, reason: &Self::Reason) -> DispatchResult

Removes a digest from storage after ensuring it contains no active deposits.

This operation is only allowed when the digest’s balance has no remaining deposits (i.e., no claimable commitments exist).

Note: This function operates for direct digests only. It cannot be used to reap indexes or pools.

Any residual value (“dust”) left after all deposits are withdrawn is treated as unclaimable and reaped-accounted in AssetToReap, deducted from total committed value crate::ReasonValue, and considered effectively dead.

The digest itself can be recreated later if a new deposit is made via CommitDeposit::deposit_to_digest.

§Returns
  • Ok(()) if the digest is successfully removed
  • Err(DispatchError) with DigestHasFunds if active deposits still exist
Source§

fn on_commit_place( who: &Proprietor<T>, reason: &Self::Reason, digest: &Self::Digest, value: Self::Asset, )

Hook called when a commitment is placed.

Delagates itself to CommitVariant::on_place_commit_on_variant with the default position variant.

Source§

fn on_commit_raise( who: &Proprietor<T>, reason: &Self::Reason, digest: &Self::Digest, value: Self::Asset, )

Hook called when a commitment is raised.

The digest is verified and classified using DigestModel::determine_digest.

Emits Event::CommitRaised event if Config::EmitEvents is true.

Source§

fn on_commit_resolve( who: &Proprietor<T>, reason: &Self::Reason, digest: &Self::Digest, value: Self::Asset, )

Hook called when a commitment is resolved.

The digest is verified and classified using DigestModel::determine_digest.

Emits Event::CommitResolved event if Config::EmitEvents is true.

Source§

fn on_digest_update( digest: &Self::Digest, reason: &Self::Reason, value: Self::Asset, )

Hook called when a digest value is updated.

This method delagates itself to CommitVariant::on_set_digest_variant with the default position variant.

Source§

fn on_reap_digest( digest: &Self::Digest, reason: &Self::Reason, dust: Self::Asset, )

Hook called when a digest is successfully reaped.

Emits Event::DigestReaped event if Config::EmitEvents is true.

Source§

impl<T, I> Debug for Pallet<T, I>

Source§

fn fmt(&self, fmt: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T: Config<I>, I: 'static> DigestModel<<T as Config>::AccountId> for Pallet<T, I>

Implements DigestModel for the pallet, allowing the system to determine the specific model variant of a given digest.

Since all digests share the same base type, we need a wrapper i.e., DigestVariant to distinguish between models such as Direct, Index, and Pool.

Source§

type Model = DigestVariant<T, I>

The digest model type, wrapping the digest with its variant classification.

This type distinguishes between three commitment models:

  • Direct: A standalone commitment to a specific digest
  • Index: A commitment distributed across multiple entries with weighted shares
  • Pool: A managed commitment structure with dynamic slot allocation and commission
Source§

fn determine_digest( digest: &Self::Digest, reason: &Self::Reason, ) -> Result<Self::Model, DispatchError>

Determines which digest model a given digest belongs to.

This method checks if the digest exists in each model variant in order:

  1. Direct
  2. Index
  3. Pool

If a matching model is found, it returns the wrapped variant. Otherwise, a DispatchError.

Note: This method is not suitable for creating new digests (not registered in the system).

New digests should be manually wrapped to avoid incorrect determination.

Source§

impl<T: Config<I>, I: 'static> DispatchViewFunction for Pallet<T, I>

Source§

fn dispatch_view_function<O: Output>( id: &ViewFunctionId, input: &mut &[u8], output: &mut O, ) -> Result<(), ViewFunctionDispatchError>

Source§

impl<T: Config<I>, I: 'static> GetStorageVersion for Pallet<T, I>

Source§

type InCodeStorageVersion = NoStorageVersionSet

This type is generated by the pallet macro. Read more
Source§

fn in_code_storage_version() -> Self::InCodeStorageVersion

Returns the in-code storage version as specified in the storage_version attribute, or [NoStorageVersionSet] if the attribute is missing.
Source§

fn on_chain_storage_version() -> StorageVersion

Returns the storage version of the pallet as last set in the actual on-chain storage.
§

fn current_storage_version() -> Self::InCodeStorageVersion

👎Deprecated: This method has been renamed to in_code_storage_version and will be removed after March 2024.
DEPRECATED: Use [Self::current_storage_version] instead. Read more
Source§

impl<T: Config<I>, I: 'static> Hooks<<<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number> for Pallet<T, I>

§

fn on_initialize(_n: BlockNumber) -> Weight

Block initialization hook. This is called at the very beginning of block execution. Read more
§

fn on_finalize(_n: BlockNumber)

Block finalization hook. This is called at the very end of block execution. Read more
§

fn on_idle(_n: BlockNumber, _remaining_weight: Weight) -> Weight

Hook to consume a block’s idle time. This will run when the block is being finalized (before [Hooks::on_finalize]). Read more
§

fn on_poll(_n: BlockNumber, _weight: &mut WeightMeter)

A hook to run logic after inherent application. Read more
§

fn on_runtime_upgrade() -> Weight

Hook executed when a code change (aka. a “runtime upgrade”) is detected by the FRAME Executive pallet. Read more
§

fn offchain_worker(_n: BlockNumber)

Implementing this function on a pallet allows you to perform long-running tasks that are dispatched as separate threads, and entirely independent of the main blockchain execution. Read more
§

fn integrity_test()

Check the integrity of this pallet’s configuration. Read more
Source§

impl<T: Config<I>, I: 'static> IndexOps<<T as Config>::AccountId, Pallet<T, I>> for CommitHelpers<T, I>

Implementation of IndexOps for the pallet, defining how index entries are queried, inserted, updated, or removed within a given index digest.

Each function operates on the index-entry composition layer - maintaining relationships between an index digest and its subordinate entry digests.

Source§

fn remove_index_entry( who: &Proprietor<T>, reason: &<Pallet<T, I> as Commitment<Proprietor<T>>>::Reason, index_of: &<Pallet<T, I> as Commitment<Proprietor<T>>>::Digest, entry_of: &<Pallet<T, I> as Commitment<Proprietor<T>>>::Digest, ) -> Result<<Pallet<T, I> as Commitment<Proprietor<T>>>::Digest, DispatchError>

Removes a specific entry from an existing index.

The function retrieves the target index, searches for the specified entry, and removes it if found. The index digest is then re-generated and updated to reflect the new structure as indexes are immutable, changes may create new index digest.

§Returns
  • Ok(IndexDigest) containing the new index digest after entry removal
  • Err(DispatchError) if the operation fails
Source§

fn set_index_entry( who: &Proprietor<T>, reason: &<Pallet<T, I> as Commitment<Proprietor<T>>>::Reason, index_of: &<Pallet<T, I> as Commitment<Proprietor<T>>>::Digest, entry_of: &<Pallet<T, I> as Commitment<Proprietor<T>>>::Digest, shares: <Pallet<T, I> as CommitIndex<Proprietor<T>>>::Shares, variant: &<Pallet<T, I> as CommitVariant<Proprietor<T>>>::Position, ) -> Result<<Pallet<T, I> as Commitment<Proprietor<T>>>::Digest, DispatchError>

Inserts or updates an entry within a given index. For removing use Self::remove_index_entry instead.

Since indexes are immutable, this operation creates a new index with the modified entry configuration and generates a new digest.

If the entry exists, its shares and variant are updated; otherwise, a new entry is appended.

§Returns
  • Ok(IndexDigest) containing the new index digest after entry modification
  • Err(DispatchError) if the operation fails
Source§

impl<T: Config<I>, I: 'static> IndexVariant<<T as Config>::AccountId> for Pallet<T, I>

Implements IndexVariant for the pallet

Source§

fn prepare_index_of_variants( _who: &Proprietor<T>, _reason: &Self::Reason, entries: Vec<(Self::Digest, Self::Shares, Self::Position)>, ) -> Result<Self::Index, DispatchError>

Prepares a new index object from a list of entry digests, their shares, and variants.

This function does not associate the index with a specific reason or proprietor internally. The caller is responsible for ensuring the index is correctly attached to a reason via CommitIndex::set_index and, optionally, the creator (for reap reasons since index should not have a manager).

Entries with zero shares are silently ignored, as they carry no semantic contribution to the index.

  • who: The proprietor creating the index.
  • reason: The reason under which the index is being prepared (not used internally).
  • entries: A vector of tuples containing:
    • Digest: The entry digest
    • Shares: The number of shares assigned to the entry
    • Position: The variant/disposition of the entry
§Returns
  • Ok(Index) containing the prepared index
  • Err(DispatchError) if preparation fails
Source§

fn get_entry_variant( reason: &Self::Reason, index_of: &Self::Digest, entry_of: &Self::Digest, ) -> Result<Self::Position, DispatchError>

Retrieves the variant associated with a specific entry in an index.

§Returns
  • Ok(Position) containing the entry’s variant
  • Err(DispatchError) otherwise
Source§

fn set_entry_of_variant( who: &Proprietor<T>, reason: &Self::Reason, index_of: &Self::Digest, entry_of: &Self::Digest, variant: Self::Position, shares: Option<Self::Shares>, ) -> Result<Self::Digest, DispatchError>

Sets or updates the variant (position/disposition) of a specific entry of an index, producing a new index.

This function handles both existing and new entries:

  • If the entry exists:
    • If shares is Some(zero), the entry is removed.
    • If shares is Some, both shares and variant are updated.
    • If shares is None, only the variant is updated while retaining existing shares.
  • If the entry does not exist:
    • If shares is Some(zero) or None, the operation is a no-op and the original index is returned.
    • Otherwise, a new entry is added with the provided variant and shares.

The entry digest is not validated to be a direct digest and is accepted as provided. If a commitment is placed on the index, the entry will be funded through normal deposit routing.

§Returns
  • Ok(Digest) containing the resulting index digest (may be unchanged if no-op)
  • Err(DispatchError) if the operation fails
Source§

impl<T: Config<I>, I: 'static> InspectAsset<<T as Config>::AccountId> for Pallet<T, I>

Implements InspectAsset for the pallet, allowing the commitment pallet to inspect a user’s available funds for commitment.

Source§

type Asset = <<T as Config<I>>::Asset as Inspect<<T as Config>::AccountId>>::Balance

The asset type used in commitments, taken from the fungible Inspect trait.

This allows any fungible implementation to be used as the commitment asset, providing flexibility in the type of value being committed while ensuring compatibility with the broader Substrate fungible ecosystem.

Source§

fn available_funds(who: &Proprietor<T>) -> Self::Asset

Retrieves the total available funds for commitment for a given proprietor.

Aggregates two balance sources:

  • Funds held under HoldReason::PrepareForCommit reason
  • Liquid balance reducible under [Preservation::Preserve] and [Fortitude::Polite] rules

This aggregated view is used by commitment validation logic to determine whether a proprietor has sufficient funds to place, raise, or modify commitments.

§Returns

Asset containing the total available balance

Source§

impl<T: Config<I>, I: 'static> IntegrityTest for Pallet<T, I>

Source§

fn integrity_test()

See [Hooks::integrity_test].
Source§

impl<T, I> LazyBalance for Pallet<T, I>
where T: Config<I>, I: 'static,

Source§

type Asset = <<T as Config<I>>::Asset as Inspect<<T as Config>::AccountId>>::Balance

The underlying unit of value tracked by the system. Read more
Source§

type Rational = <T as Config<I>>::Bias

The numeric representation used for value calculations. Read more
Source§

type Time = <T as Config<I>>::Time

The temporal index of the system. Read more
Source§

type Balance = ProductType<T, I, <<T as Config<I>>::BalanceContext as ModelContext>::Context, BalanceAsset, BalanceRational, BalanceTime, BalanceAddon>

Primary mutable balance state. Read more
Source§

type Variant = <T as Config<I>>::Position

Logical partition of a balance. Read more
Source§

type Id = <T as Config>::AccountId

Identifier of a balance owner or entity. Read more
Source§

type Limits = LimitsProduct<T, I>

Abstract representation of operation limits. Read more
Source§

type Subject = DispatchPolicy

Represents the directive / intent of an operation. Read more
Source§

type SnapShot = ProductType<T, I, <<T as Config<I>>::BalanceContext as ModelContext>::Context, SnapShotAsset, SnapShotRational, SnapShotTime, SnapShotAddon>

Time-indexed projection of balance state. Read more
Source§

type Receipt = ProductType<T, I, <<T as Config<I>>::BalanceContext as ModelContext>::Context, ReceiptAsset, ReceiptRational, ReceiptTime, ReceiptAddon>

Claim over deposited value. Read more
Source§

type Input<'a> = LazyInput<'a, T, I>

Input carrier for all operations. Read more
Source§

type Output<'a> = LazyOutput<'a, T, I>

Output carrier for all operations. Read more
Source§

type BalanceFamily<'a> = <T as Config<I>>::BalanceFamily<'a>

Plugin Family implementing all LazyBalance operations. Read more
Source§

type BalanceContext = <T as Config<I>>::BalanceContext

Context provider for all LazyBalance operations via Self::BalanceFamily. Read more
Source§

fn can_deposit<'a>(input: Self::Input<'a>) -> Self::Output<'a>

Plugin invocation pure-function for the child - CanDeposit of the plugin family - LazyBalanceRoot Returns whether a deposit is permitted.
Source§

fn can_withdraw<'a>(input: Self::Input<'a>) -> Self::Output<'a>

Plugin invocation pure-function for the child - CanWithdraw of the plugin family - LazyBalanceRoot Returns whether a withdrawal is permitted.
Source§

fn can_mint<'a>(input: Self::Input<'a>) -> Self::Output<'a>

Plugin invocation pure-function for the child - CanMint of the plugin family - LazyBalanceRoot Returns whether minting is permitted.
Source§

fn can_reap<'a>(input: Self::Input<'a>) -> Self::Output<'a>

Plugin invocation pure-function for the child - CanReap of the plugin family - LazyBalanceRoot Returns whether reaping is permitted.
Source§

fn deposit<'a>(input: Self::Input<'a>) -> Self::Output<'a>

Plugin invocation pure-function for the child - Deposit of the plugin family - LazyBalanceRoot Deposits value into the balance and issues a receipt along with depositted amount.
Source§

fn withdraw<'a>(input: Self::Input<'a>) -> Self::Output<'a>

Plugin invocation pure-function for the child - Withdraw of the plugin family - LazyBalanceRoot Withdraws value by consuming a receipt, returning withdrawed amount.
Source§

fn mint<'a>(input: Self::Input<'a>) -> Self::Output<'a>

Plugin invocation pure-function for the child - Mint of the plugin family - LazyBalanceRoot Introduces new value into the balance, returning minted amount.
Source§

fn reap<'a>(input: Self::Input<'a>) -> Self::Output<'a>

Plugin invocation pure-function for the child - Reap of the plugin family - LazyBalanceRoot Removes or adjusts value from the balance, returning reaped amount.
Source§

fn drain<'a>(input: Self::Input<'a>) -> Self::Output<'a>

Plugin invocation pure-function for the child - Drain of the plugin family - LazyBalanceRoot Clears the balance state, returning drained amount.
Source§

fn total_value<'a>(input: Self::Input<'a>) -> Self::Output<'a>

Plugin invocation pure-function for the child - TotalValue of the plugin family - LazyBalanceRoot Returns the total value of the balance.
Source§

fn receipt_active_value<'a>(input: Self::Input<'a>) -> Self::Output<'a>

Plugin invocation pure-function for the child - ReceiptActiveValue of the plugin family - LazyBalanceRoot Returns the current redeemable value of a receipt.
Source§

fn has_deposits<'a>(input: Self::Input<'a>) -> Self::Output<'a>

Plugin invocation pure-function for the child - HasDeposits of the plugin family - LazyBalanceRoot Returns whether the balance has any deposits.
Source§

fn receipt_deposit_value<'a>(input: Self::Input<'a>) -> Self::Output<'a>

Plugin invocation pure-function for the child - ReceiptDepositValue of the plugin family - LazyBalanceRoot Returns the original deposited value represented by a receipt.
Source§

fn deposit_limits<'a>(input: Self::Input<'a>) -> Self::Output<'a>

Plugin invocation pure-function for the child - DepositLimits of the plugin family - LazyBalanceRoot Returns limits for deposit operations if any, else permissive.
Source§

fn mint_limits<'a>(input: Self::Input<'a>) -> Self::Output<'a>

Plugin invocation pure-function for the child - MintLimits of the plugin family - LazyBalanceRoot Returns limits for mint operations if any, else permissive.
Source§

fn reap_limits<'a>(input: Self::Input<'a>) -> Self::Output<'a>

Plugin invocation pure-function for the child - ReapLimits of the plugin family - LazyBalanceRoot Returns limits for reap operations if any, else permissive.
Source§

impl<T: Config<I>, I: 'static> OffchainWorker<<<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number> for Pallet<T, I>

Source§

fn offchain_worker(n: BlockNumberFor<T>)

This function is being called after every block import (when fully synced). Read more
Source§

impl<T: Config<I>, I: 'static> OnFinalize<<<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number> for Pallet<T, I>

Source§

fn on_finalize(n: BlockNumberFor<T>)

See [Hooks::on_finalize].
Source§

impl<T: Config<I>, I: 'static> OnGenesis for Pallet<T, I>

Source§

fn on_genesis()

Something that should happen at genesis.
Source§

impl<T: Config<I>, I: 'static> OnIdle<<<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number> for Pallet<T, I>

Source§

fn on_idle(n: BlockNumberFor<T>, remaining_weight: Weight) -> Weight

See [Hooks::on_idle].
Source§

impl<T: Config<I>, I: 'static> OnInitialize<<<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number> for Pallet<T, I>

Source§

fn on_initialize(n: BlockNumberFor<T>) -> Weight

See [Hooks::on_initialize].
Source§

impl<T: Config<I>, I: 'static> OnPoll<<<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number> for Pallet<T, I>

Source§

fn on_poll(n: BlockNumberFor<T>, weight: &mut WeightMeter)

Code to execute every now and then at the beginning of the block after inherent application. Read more
Source§

impl<T: Config<I>, I: 'static> OnRuntimeUpgrade for Pallet<T, I>

Source§

fn on_runtime_upgrade() -> Weight

See [Hooks::on_runtime_upgrade].
Source§

impl<T: Config<I>, I: 'static> PalletInfoAccess for Pallet<T, I>

Source§

fn index() -> usize

Index of the pallet as configured in the runtime.
Source§

fn name() -> &'static str

Name of the pallet as configured in the runtime.
Source§

fn name_hash() -> [u8; 16]

Two128 hash of name.
Source§

fn module_name() -> &'static str

Name of the Rust module containing the pallet.
Source§

fn crate_version() -> CrateVersion

Version of the crate containing the pallet.
Source§

impl<T: Config<I>, I: 'static> PalletsInfoAccess for Pallet<T, I>

Source§

fn count() -> usize

The number of pallets’ information that this type represents. Read more
Source§

fn infos() -> Vec<PalletInfoData>

All of the pallets’ information that this type represents.
Source§

impl<T, I> PartialEq for Pallet<T, I>

Source§

fn eq(&self, other: &Self) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<T: Config<I>, I: 'static> PoolOps<<T as Config>::AccountId, Pallet<T, I>> for CommitHelpers<T, I>

Implementation of PoolOps for the pallet, defining how pools slots are queried, inserted, updated, or removed within a given index digest.

Each function operates on the pool-slot composition layer - maintaining relationships between an pool digest and its subordinate slot digests.

Source§

type PoolBalance = ProductType<T, I, <<T as Config<I>>::BalanceContext as ModelContext>::Context, BalanceAsset, BalanceRational, BalanceTime, BalanceAddon>

Uses LazyBalanceOf to track both the real-time effective balance and the total principal deposits contributed by all proprietors of the pool.

Each proprietor’s deposit (commit) into the pool is recorded as a CommitInstance inside its storage.

Source§

fn release_pool( reason: &<Pallet<T, I> as Commitment<Proprietor<T>>>::Reason, pool_of: &<Pallet<T, I> as Commitment<Proprietor<T>>>::Digest, ) -> Result<Self::PoolBalance, DispatchError>

Releases a pool’s balance into a detached representation.

Resolves all active slot digests belonging to the pool, withdraws their values proportionally, and resets the pool’s stored balance to default. The released balance can then be modified before being recovered.

§Returns
  • Ok(Balance) containing the released pool balance
  • Err(DispatchError) if the pool is not found or release fails
Source§

fn recover_pool( reason: &<Pallet<T, I> as Commitment<Proprietor<T>>>::Reason, pool_of: &<Pallet<T, I> as Commitment<Proprietor<T>>>::Digest, balance: &Self::PoolBalance, ) -> DispatchResult

Restores a pool’s state after a prior release.

Redistributes the recovered balance among slots proportionally based on their shares, and reconciles any dust with the pool manager. This function should only be called after release_pool.

§Returns
  • Ok(()) if the pool state was successfully recovered
  • Err(DispatchError) with ReleasePoolToRecover if pool is not in released state, or recovery fails
Source§

fn remove_pool_slot( _who: &Proprietor<T>, reason: &<Pallet<T, I> as Commitment<Proprietor<T>>>::Reason, pool_of: &<Pallet<T, I> as Commitment<Proprietor<T>>>::Digest, slot_of: &<Pallet<T, I> as Commitment<Proprietor<T>>>::Digest, ) -> DispatchResult

Removes a specific slot from a given pool.

The function first releases the pool to safely mutate it, ensuring no lazy balance state remains. Once verified, it searches for the specified slot and removes it. The pool’s capital is then adjusted to account for the removed slot’s shares. Finally, the pool state is recovered.

§Returns
  • Ok(()) if the slot is successfully removed or not found
  • Err(DispatchError) if pool or slot state is invalid
Source§

fn set_pool_slot( _who: &Proprietor<T>, reason: &<Pallet<T, I> as Commitment<Proprietor<T>>>::Reason, pool_of: &<Pallet<T, I> as Commitment<Proprietor<T>>>::Digest, slot_of: &<Pallet<T, I> as Commitment<Proprietor<T>>>::Digest, shares: <Pallet<T, I> as CommitIndex<Proprietor<T>>>::Shares, variant: &<Pallet<T, I> as CommitVariant<Proprietor<T>>>::Position, ) -> DispatchResult

Inserts or updates a slot within an existing pool. For removing use Self::remove_pool_slot instead.

The pool is first released for safe modification.
If the slot already exists, it is removed and replaced with the updated one. Capital adjustments are performed based on the delta between old and new share allocations. The pool is then recovered post-mutation.

§Returns
  • Ok(()) if the slot is successfully set
  • Err(DispatchError) if pool is not in released state, if slot capacity exceeded, or operation fails
Source§

impl<T: Config<I>, I: 'static> PoolVariant<<T as Config>::AccountId> for Pallet<T, I>

Implements PoolVariant for the pallet

Source§

fn get_slot_variant( reason: &Self::Reason, pool_of: &Self::Digest, slot_of: &Self::Digest, ) -> Result<Self::Position, DispatchError>

Retrieves the variant associated with a specific slot in a pool.

§Returns
  • Ok(Position) containing the slot’s variant
  • Err(DispatchError)if the slot does not exist
Source§

fn set_slot_of_variant( who: &Proprietor<T>, reason: &Self::Reason, pool_of: &Self::Digest, slot_of: &Self::Digest, variant: Self::Position, shares: Option<Self::Shares>, ) -> DispatchResult

Sets or updates the variant of a specific slot within a pool.

Unlike indexes, pools are mutable, so this operation modifies the pool in place without creating a new pool digest. The pool is released and recovered to maintain real-time balances after the mutation.

This function handles both existing and new slots:

  • If the slot exists:
    • Updates its variant.
    • Updates shares if provided.
    • Removes the slot if provided shares are zero.
    • Retains existing shares if shares is None.
  • If the slot does not exist:
    • Creates a new slot if non-zero shares is provided.
    • Does nothing if shares is zero.
    • Returns an error if shares is None (no slot to update and no data to create).
§Returns
  • Ok(()) if the operation completes successfully
  • Err(DispatchError) if the slot is not found and cannot be created, or if the operation fails
Source§

fn on_set_slot_of_variant( pool_of: &Self::Digest, reason: &Self::Reason, slot_of: &Self::Digest, shares: Option<Self::Shares>, variant: &Self::Position, )

Emits an event when a slot’s variant or shares within a pool is updated.

Records the pool digest, reason, slot digest, new variant, and shares (either provided or retrieved from current state).

If the slot cannot be found, the function silently returns.

Emits:

Events are emitted only if Config::EmitEvents is true.

Source§

impl<T: Config<I>, I: 'static> StorageInfoTrait for Pallet<T, I>

Source§

fn storage_info() -> Vec<StorageInfo>

Source§

impl<T: Config<I>, I: 'static> ViewFunctionIdPrefix for Pallet<T, I>

Source§

fn prefix() -> [u8; 16]

Source§

impl<T, I> VirtualNMap<ProductType<T, I, <<T as Config<I>>::BalanceContext as ModelContext>::Context, BalanceAsset, BalanceRational, BalanceTime, BalanceAddon>, SnapShotStorage> for Pallet<T, I>
where T: Config<I>, I: 'static,

VirtualNMap implementation for snapshot storage of VirtualBalance.

Implemented for Pallet since it satisfies the super-bounds of LazyBalance and provides the concrete virtual storage backend.

Maps (digest, variant, time) -> VirtualSnapShot, enabling time-indexed balance projections via BalanceSnapShots.

Source§

type Key = (<T as Config>::AccountId, <T as Config<I>>::Position, <T as Config<I>>::Time)

Key used to address entries in the map. Read more
Source§

type Value = ProductType<T, I, <<T as Config<I>>::BalanceContext as ModelContext>::Context, SnapShotAsset, SnapShotRational, SnapShotTime, SnapShotAddon>

Value stored in the map. Read more
Source§

type KeyGen = (Key<Blake2_128Concat, <T as Config>::AccountId>, Key<Blake2_128Concat, <T as Config<I>>::Position>, Key<Blake2_128Concat, <T as Config<I>>::Time>)

Defines how Key is transformed into storage keys. Read more
Source§

type Map = StorageNMap<_GeneratedPrefixForStorageBalanceSnapShots<T, I>, (Key<Blake2_128Concat, <T as Config>::AccountId>, Key<Blake2_128Concat, <T as Config<I>>::Position>, Key<Blake2_128Concat, <T as Config<I>>::Time>), ProductType<T, I, <<T as Config<I>>::BalanceContext as ModelContext>::Context, SnapShotAsset, SnapShotRational, SnapShotTime, SnapShotAddon>>

Underlying storage map backing this abstraction. Read more
Source§

type Query = Option<ProductType<T, I, <<T as Config<I>>::BalanceContext as ModelContext>::Context, SnapShotAsset, SnapShotRational, SnapShotTime, SnapShotAddon>>

Return type for read operations. Read more
Source§

fn get(key: Self::Key) -> Self::Query

Fetch value associated with key.
Source§

fn insert(key: Self::Key, value: Self::Value)

Insert or overwrite value at key.
Source§

fn remove(key: Self::Key)

Remove value at key.
Source§

fn take(key: Self::Key) -> Self::Query

Remove and return value at key.
Source§

fn contains_key(key: Self::Key) -> bool

Check if key exists.
Source§

fn mutate<R>(key: Self::Key, f: impl FnOnce(&mut Option<Self::Value>) -> R) -> R

Mutate value at key in-place. Read more
Source§

fn iter() -> impl Iterator<Item = (<Self::KeyGen as KeyGenerator>::Key, Self::Value)>

Iterate over all (full_key, value) pairs.
Source§

fn iter_keys() -> impl Iterator<Item = <Self::KeyGen as KeyGenerator>::Key>

Iterate over all full keys.
Source§

fn iter_values() -> impl Iterator<Item = Self::Value>

Iterate over all values.
Source§

fn drain() -> impl Iterator<Item = (<Self::KeyGen as KeyGenerator>::Key, Self::Value)>

Drain entire map, yielding all (key, value) pairs.
Source§

fn count() -> usize

Count total number of entries.
Source§

fn iter_prefix_values<P>(prefix: P) -> impl Iterator<Item = Self::Value>
where Self::KeyGen: HasKeyPrefix<P>,

Iterate over values matching a prefix. Read more
Source§

fn iter_prefix<P>( prefix: P, ) -> impl Iterator<Item = (<Self::KeyGen as HasKeyPrefix<P>>::Suffix, Self::Value)>
where Self::KeyGen: HasReversibleKeyPrefix<P>,

Iterate over (suffix, value) under a prefix. Read more
Source§

fn iter_key_prefix<P>( prefix: P, ) -> impl Iterator<Item = <Self::KeyGen as HasKeyPrefix<P>>::Suffix>
where Self::KeyGen: HasReversibleKeyPrefix<P>,

Iterate over suffix keys under a prefix.
Source§

fn drain_prefix<P>( prefix: P, ) -> impl Iterator<Item = (<Self::KeyGen as HasKeyPrefix<P>>::Suffix, Self::Value)>
where Self::KeyGen: HasReversibleKeyPrefix<P>,

Drain entries under a prefix, yielding (suffix, value).
Source§

impl<T: Config<I>, I: 'static> WhitelistedStorageKeys for Pallet<T, I>

Source§

fn whitelisted_storage_keys() -> Vec<TrackedStorageKey>

Returns a 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.
Source§

impl<T, I> Eq for Pallet<T, I>

Auto Trait Implementations§

§

impl<T, I> Freeze for Pallet<T, I>

§

impl<T, I> RefUnwindSafe for Pallet<T, I>

§

impl<T, I> Send for Pallet<T, I>
where T: Send, I: Send,

§

impl<T, I> Sync for Pallet<T, I>
where T: Sync, I: Sync,

§

impl<T, I> Unpin for Pallet<T, I>
where T: Unpin, I: Unpin,

§

impl<T, I> UnwindSafe for Pallet<T, I>
where T: UnwindSafe, I: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> CheckedConversion for T

§

fn checked_from<T>(t: T) -> Option<Self>
where Self: TryFrom<T>,

Convert from a value of T into an equivalent instance of Option<Self>. Read more
§

fn checked_into<T>(self) -> Option<T>
where Self: TryInto<T>,

Consume self to return Some equivalent value of Option<T>. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DynClone for T
where T: Clone,

§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
§

impl<T, U> IntoKey<U> for T
where U: FromKey<T>,

§

fn into_key(self) -> U

Source§

impl<T, U, Tag> IntoTag<U, Tag> for T
where U: FromTag<T, Tag>, Tag: DiscriminantTag,

Source§

fn into_tag(self) -> U

§

impl<Src, Dest> IntoTuple<Dest> for Src
where Dest: FromTuple<Src>,

§

fn into_tuple(self) -> Dest

§

impl<T> IsType<T> for T

§

fn from_ref(t: &T) -> &T

Cast reference.
§

fn into_ref(&self) -> &T

Cast reference.
§

fn from_mut(t: &mut T) -> &mut T

Cast mutable reference.
§

fn into_mut(&mut self) -> &mut T

Cast mutable reference.
§

impl<T, Outer> IsWrappedBy<Outer> for T
where Outer: AsRef<T> + AsMut<T> + From<T>, T: From<Outer>,

§

fn from_ref(outer: &Outer) -> &T

Get a reference to the inner from the outer.

§

fn from_mut(outer: &mut Outer) -> &mut T

Get a mutable reference to the inner from the outer.

Source§

impl<T, Time> Logging<Time> for T
where Time: Time,

Source§

const FALLBACK_TARGET: &'static str = "routine"

Default logging target if none is provided.

Most routines, especially offchain workers or background tasks, use this target for simplicity.

It allows a consistent place to look for routine logs without requiring every call to specify a target.

Note: This target is only a conveninence and may be somewhat vague. To ensure errors can still be traced accurately, the logged messages should include additional metadata (e.g., module name, error index, or contextual info) so that the source of the error can be identified even if the target is generic.

Source§

type Logger = DispatchError

The type taken and returned for logging.

We simply return the same [DispatchError] that was logged, so logging does not change control flow or error propagation.

DispatchError is used because in Substrate it encompasses all runtime errors - including module errors, token errors, arithmetic issues, and transactional boundaries - making it the universal substrate-side error representation.

Source§

type Level = LogLevel

The log level type.

We use the LogLevel enum to standardize severity levels (Info, Warn, Error, Debug) across all routine logs.

Source§

fn log( level: <T as Logging<Time>>::Level, err: &<T as Logging<Time>>::Logger, timestamp: Time, target: Option<&str>, fmt: Option<fn(Time, &<T as Logging<Time>>::Level, &str, &str) -> String>, ) -> <T as Logging<Time>>::Logger

Core logging function that all helpers delegate to. Read more
Source§

fn info( err: &Self::Logger, timestamp: Timestamp, target: Option<&str>, fmt: Option<fn(Timestamp, &Self::Level, &str, &str) -> String>, ) -> Self::Logger
where Self: Sized,

Logs an info-level message. Read more
Source§

fn warn( err: &Self::Logger, timestamp: Timestamp, target: Option<&str>, fmt: Option<fn(Timestamp, &Self::Level, &str, &str) -> String>, ) -> Self::Logger
where Self: Sized,

Logs a warning-level message. Read more
Source§

fn error( err: &Self::Logger, timestamp: Timestamp, target: Option<&str>, fmt: Option<fn(Timestamp, &Self::Level, &str, &str) -> String>, ) -> Self::Logger
where Self: Sized,

Logs an error-level message. Read more
Source§

fn debug( err: &Self::Logger, timestamp: Timestamp, target: Option<&str>, fmt: Option<fn(Timestamp, &Self::Level, &str, &str) -> String>, ) -> Self::Logger
where Self: Sized,

Logs a debug-level message. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
§

impl<T> SaturatedConversion for T

§

fn saturated_from<T>(t: T) -> Self
where Self: UniqueSaturatedFrom<T>,

Convert from a value of T into an equivalent instance of Self. Read more
§

fn saturated_into<T>(self) -> T
where Self: UniqueSaturatedInto<T>,

Consume self to return an equivalent value of T. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T, U> TryIntoKey<U> for T
where U: TryFromKey<T>,

§

type Error = <U as TryFromKey<T>>::Error

§

fn try_into_key(self) -> Result<U, <U as TryFromKey<T>>::Error>

§

impl<S, T> UncheckedInto<T> for S
where T: UncheckedFrom<S>,

§

fn unchecked_into(self) -> T

The counterpart to unchecked_from.
§

impl<T, S> UniqueSaturatedInto<T> for S
where T: Bounded, S: TryInto<T>,

§

fn unique_saturated_into(self) -> T

Consume self to return an equivalent value of T.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
Source§

impl<Provider, Discriminant, T> DelegateVirtualDynBound<Provider, Discriminant> for T
where Provider: VirtualDynBound<Discriminant>, Discriminant: DiscriminantTag,

Source§

impl<Provider, Discriminant, T> DelegateVirtualStaticBound<Provider, Discriminant> for T
where Provider: VirtualStaticBound<Discriminant>, Discriminant: DiscriminantTag,

§

impl<T> JsonSchemaMaybe for T

Source§

impl<T> LazyBalanceMarker for T
where T: LazyBalance + Clone + Debug,

§

impl<T> MaybeDebug for T
where T: Debug,

§

impl<T> MaybeRefUnwindSafe for T
where T: RefUnwindSafe,

§

impl<T> Member for T
where T: Send + Sync + Debug + Eq + PartialEq + Clone + 'static,