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>
impl<T: Config<I>, I: 'static> Pallet<T, I>
Sourcepub fn deposit_reserve(
origin: OriginFor<T>,
amount: AssetOf<T, I>,
precision: PrecisionWrapper,
) -> DispatchResult
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
precisionisBestEffort, deposits the maximum available balance when insufficient - If
precisionisExact, requires exact amount or fails withError::InsufficientFunds
§Emits
Event::ReserveDeposited: Contains the amount deposited and the total balance on hold.
Sourcepub fn withdraw_reserve(
origin: OriginFor<T>,
amount: Option<AssetOf<T, I>>,
) -> DispatchResult
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
amountisNone, all reserved funds under the hold reason are released. - If
amountisSome(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>
impl<T: Config<I>, I: 'static> Pallet<T, I>
Sourcepub fn resolve_digest_model(
digest: Digest<T>,
reason: CommitReason<T, I>,
) -> Result<DigestVariant<T, I>, DispatchError>
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).
Sourcepub fn resolve_digest_model_for(
caller: T::AccountId,
reason: CommitReason<T, I>,
) -> Result<DigestVariant<T, I>, DispatchError>
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.
Sourcepub fn query_commit_value(
caller: T::AccountId,
reason: CommitReason<T, I>,
) -> Result<AssetOf<T, I>, DispatchError>
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.
Sourcepub fn query_asset_to_issue() -> AssetOf<T, I>
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.
Sourcepub fn query_asset_to_reap() -> AssetOf<T, I>
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.
Sourcepub fn query_reason_value(reason: CommitReason<T, I>) -> AssetOf<T, I>
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.
Sourcepub fn query_index_value(
reason: CommitReason<T, I>,
index: IndexDigest<T>,
) -> Result<AssetOf<T, I>, DispatchError>
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.
Sourcepub fn query_entries_value(
reason: CommitReason<T, I>,
index: IndexDigest<T>,
) -> Result<Vec<(Digest<T>, AssetOf<T, I>)>, DispatchError>
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
Sourcepub fn query_entry_value(
reason: CommitReason<T, I>,
index: IndexDigest<T>,
entry: EntryDigest<T>,
) -> Result<AssetOf<T, I>, DispatchError>
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.
Sourcepub fn query_index_value_for(
caller: T::AccountId,
reason: CommitReason<T, I>,
index: IndexDigest<T>,
) -> Result<AssetOf<T, I>, DispatchError>
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.
Sourcepub fn query_entries_value_for(
caller: T::AccountId,
reason: CommitReason<T, I>,
index: IndexDigest<T>,
) -> Result<Vec<(Digest<T>, AssetOf<T, I>)>, DispatchError>
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
Sourcepub fn query_entry_value_for(
caller: T::AccountId,
reason: CommitReason<T, I>,
index: IndexDigest<T>,
entry: EntryDigest<T>,
) -> Result<AssetOf<T, I>, DispatchError>
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.
Sourcepub fn query_pool_value(
reason: CommitReason<T, I>,
pool: PoolDigest<T>,
) -> Result<AssetOf<T, I>, DispatchError>
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.
Sourcepub fn query_slots_value(
reason: CommitReason<T, I>,
pool: PoolDigest<T>,
) -> Result<Vec<(Digest<T>, AssetOf<T, I>)>, DispatchError>
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
Sourcepub fn query_slot_value(
reason: CommitReason<T, I>,
pool: PoolDigest<T>,
slot: SlotDigest<T>,
) -> Result<AssetOf<T, I>, DispatchError>
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.
Sourcepub fn query_pool_commission(
reason: CommitReason<T, I>,
pool: PoolDigest<T>,
) -> Result<T::Commission, DispatchError>
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.
Sourcepub fn query_pool_manager(
reason: CommitReason<T, I>,
pool: PoolDigest<T>,
) -> Result<T::AccountId, DispatchError>
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.
Sourcepub fn query_pool_value_for(
caller: T::AccountId,
reason: CommitReason<T, I>,
pool: PoolDigest<T>,
) -> Result<AssetOf<T, I>, DispatchError>
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.
Sourcepub fn query_slots_value_for(
caller: T::AccountId,
reason: CommitReason<T, I>,
pool_of: PoolDigest<T>,
) -> Result<Vec<(Digest<T>, AssetOf<T, I>)>, DispatchError>
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
Sourcepub fn query_slot_value_for(
caller: T::AccountId,
reason: CommitReason<T, I>,
pool: PoolDigest<T>,
slot: SlotDigest<T>,
) -> Result<AssetOf<T, I>, DispatchError>
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.
Trait Implementations§
Source§impl<T: Config<I>, I: 'static> BeforeAllRuntimeMigrations for Pallet<T, I>
impl<T: Config<I>, I: 'static> BeforeAllRuntimeMigrations for Pallet<T, I>
Source§fn before_all_runtime_migrations() -> Weight
fn before_all_runtime_migrations() -> Weight
Source§impl<T: Config<I>, I: 'static> Callable<T> for Pallet<T, I>
impl<T: Config<I>, I: 'static> Callable<T> for Pallet<T, I>
type RuntimeCall = Call<T, I>
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.
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>
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>
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 viaAssetToIssue).deposit == withdraw: The values are balanced; no action is taken.deposit > withdraw: The surplus is burned as a penalty (accounted viaAssetToReap).
§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>
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>
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, increasingAssetToReap. - If
withdraw == deposit(neutral state): the deduction is treated as a penalty and directly increasesAssetToReap. - If
withdraw < deposit(penalty state): the deduction deepens the penalty, further increasingAssetToReap.
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.
DispatchErrorotherwise
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.
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>
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>
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>
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>
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>
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
_whois 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>
impl<T: Config<I>, I: 'static> CommitErrorHandler for Pallet<T, I>
Source§fn from_commit_error(e: CommitError) -> Self::Error
fn from_commit_error(e: CommitError) -> Self::Error
CommitError into the handler’s
concrete error type which implements Into<DispatchError>. Read moreSource§impl<T: Config<I>, I: 'static> CommitIndex<<T as Config>::AccountId> for Pallet<T, I>
Implements CommitIndex for the pallet
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>
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.
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
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 existsErr(DispatchError)if the index does not exist
Source§fn entry_exists(
reason: &Self::Reason,
index_of: &Self::Digest,
entry_of: &Self::Digest,
) -> DispatchResult
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 existsErr(DispatchError)if the entry does not exist
Source§fn has_index(reason: &Self::Reason) -> DispatchResult
fn has_index(reason: &Self::Reason) -> DispatchResult
Checks whether any index exists for the given reason.
§Returns
Ok(())if at least one index existsErr(DispatchError)if no indexes exist
Source§fn get_index(
reason: &Self::Reason,
index_of: &Self::Digest,
) -> Result<Self::Index, DispatchError>
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 structureErr(DispatchError)if the index does not exist
Retrieves all entry digests and their shares for a specific index.
§Returns
Ok(Vec<(Digest, Shares)>)containing each entry’s digest and sharesErr(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>
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 entryErr(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>
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 entryErr(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>
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>
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 indexErr(DispatchError)if preparation fails
Source§fn set_index(
who: &Proprietor<T>,
reason: &Self::Reason,
index: &Self::Index,
digest: &Self::Digest,
) -> DispatchResult
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_digestand 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 insertedErr(DispatchError)withIndexDigestTakenif the digest already exists
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
sharesis zero, the entry is removed. - Otherwise, the entry’s shares are updated while preserving its existing variant.
- If
- If the entry does not exist:
- If
sharesis zero, the operation is a no-op and the original index is returned. - Otherwise, a new entry is added with the default
Config::Positionvariant.
- If
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
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 removedErr(DispatchError)withIndexHasFundsif any entry still has commitments
Source§fn on_set_index(
_who: &Proprietor<T>,
index_of: &Self::Digest,
reason: &Self::Reason,
_index: &Self::Index,
)
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.
- Records the index digest, reason, and entry-share mappings.
- Emits
Event::IndexInitializedorEvent::IndexInitializeddepending on whether multiple variants are supported byConfig::Position - Emits these events only if
Config::EmitEventsistrue.
Source§fn on_reap_index(
index_of: &Self::Digest,
reason: &Self::Reason,
dust: Self::Asset,
)
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>
fn get_index_value( reason: &Self::Reason, index_of: &Self::Digest, ) -> Result<Self::Asset, DispatchError>
Source§fn get_entries_value(
reason: &Self::Reason,
index_of: &Self::Digest,
) -> Result<Vec<(Self::Digest, Self::Asset)>, DispatchError>
fn get_entries_value( reason: &Self::Reason, index_of: &Self::Digest, ) -> Result<Vec<(Self::Digest, Self::Asset)>, DispatchError>
Source§fn get_entries_value_for(
who: &Proprietor,
reason: &Self::Reason,
index_of: &Self::Digest,
) -> Result<Vec<(Self::Digest, Self::Asset)>, DispatchError>
fn get_entries_value_for( who: &Proprietor, reason: &Self::Reason, index_of: &Self::Digest, ) -> Result<Vec<(Self::Digest, Self::Asset)>, DispatchError>
Source§fn get_index_value_for(
who: &Proprietor,
reason: &Self::Reason,
index_of: &Self::Digest,
) -> Result<Self::Asset, DispatchError>
fn get_index_value_for( who: &Proprietor, reason: &Self::Reason, index_of: &Self::Digest, ) -> Result<Self::Asset, DispatchError>
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.
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>
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 valueErr(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>
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 digestErr(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>
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 indexErr(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>
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 entryErr(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>
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 valueErr(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>
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 proprietorErr(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>
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 valueErr(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
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>
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 amountErr(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>
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 amountErr(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>
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 amountErr(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>
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 amountErr(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>
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 amountErr(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>
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 amountErr(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>
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 amountErr(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>
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 amountErr(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>
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 valueErr(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>
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 valueErr(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>
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 valueErr(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>
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 valueErr(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,
)
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
fn add_to_total_value( reason: &Pallet::Reason, value: <Pallet as InspectAsset<Proprietor>>::Asset, ) -> DispatchResult
Source§fn sub_from_total_value(
reason: &Pallet::Reason,
value: <Pallet as InspectAsset<Proprietor>>::Asset,
) -> DispatchResult
fn sub_from_total_value( reason: &Pallet::Reason, value: <Pallet as InspectAsset<Proprietor>>::Asset, ) -> DispatchResult
Source§impl<T: Config<I>, I: 'static> CommitPool<<T as Config>::AccountId> for Pallet<T, I>
Implements CommitPool for the pallet
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>
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
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
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 existsErr(DispatchError)if the pool does not exist
Source§fn slot_exists(
reason: &Self::Reason,
pool_of: &Self::Digest,
slot_of: &Self::Digest,
) -> DispatchResult
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 existsErr(DispatchError)withSlotOfPoolNotFoundif the slot does not exist
Source§fn has_pool(reason: &Self::Reason) -> DispatchResult
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 existsErr(DispatchError)withPoolNotFoundif no pools exist
Source§fn get_manager(
reason: &Self::Reason,
pool_of: &Self::Digest,
) -> Result<Proprietor<T>, DispatchError>
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 idErr(DispatchError)withPoolManagerNotFoundif no manager is set
Source§fn get_commission(
reason: &Self::Reason,
pool_of: &Self::Digest,
) -> Result<Self::Commission, DispatchError>
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 rateErr(DispatchError)withPoolNotFoundif the pool does not exist
Source§fn get_pool(
reason: &Self::Reason,
pool_of: &Self::Digest,
) -> Result<Self::Pool, DispatchError>
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 structureErr(DispatchError)withPoolNotFoundif the pool does not exist
Retrieves all slot digests of a pool along with their respective shares.
§Returns
Ok(Vec<(Digest, Shares)>)containing each slot’s digest and sharesErr(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>
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 valueErr(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>
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 valueErr(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>
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 valueErr(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>
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
reasonunder 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 digestErr(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
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 createdErr(DispatchError)withPoolDigestTakenif a pool with this digest already exists
Source§fn set_pool_manager(
reason: &Self::Reason,
pool_of: &Self::Digest,
manager: &Proprietor<T>,
) -> DispatchResult
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 setErr(DispatchError)if the pool does not exist
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
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 removedErr(DispatchError)otherwise
Source§fn on_set_pool(
_who: &Proprietor<T>,
pool_of: &Self::Digest,
reason: &Self::Reason,
pool: &Self::Pool,
)
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.
-
Includes all underlying slots and the commission set for the pool manager.
-
Emits
Event::PoolInitializedorEvent::PoolInitializeddepending on whether multiple variants are supported byConfig::Position. -
Emits these events only if
Config::EmitEventsistrue.
Source§fn on_set_manager(
pool_of: &Self::Digest,
reason: &Self::Reason,
manager: &Proprietor<T>,
)
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.
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,
)
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>
fn get_pool_value( reason: &Self::Reason, pool_of: &Self::Digest, ) -> Result<Self::Asset, DispatchError>
Source§fn get_slots_value(
reason: &Self::Reason,
pool_of: &Self::Digest,
) -> Result<Vec<(Self::Digest, Self::Asset)>, DispatchError>
fn get_slots_value( reason: &Self::Reason, pool_of: &Self::Digest, ) -> Result<Vec<(Self::Digest, Self::Asset)>, DispatchError>
Source§fn get_slots_value_for(
who: &Proprietor,
reason: &Self::Reason,
pool_of: &Self::Digest,
) -> Result<Vec<(Self::Digest, Self::Asset)>, DispatchError>
fn get_slots_value_for( who: &Proprietor, reason: &Self::Reason, pool_of: &Self::Digest, ) -> Result<Vec<(Self::Digest, Self::Asset)>, DispatchError>
Source§fn set_commission(
who: &Proprietor,
reason: &Self::Reason,
index_of: &Self::Digest,
commission: Self::Commission,
) -> Result<Self::Digest, DispatchError>
fn set_commission( who: &Proprietor, reason: &Self::Reason, index_of: &Self::Digest, commission: Self::Commission, ) -> Result<Self::Digest, DispatchError>
Source§impl<T: Config<I>, I: 'static> CommitVariant<<T as Config>::AccountId> for Pallet<T, I>
Implements CommitVariant for the pallet
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
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
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 succeedsErr(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
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 succeedsErr(DispatchError)if any constraint is violated
Source§fn get_commit_variant(
who: &Proprietor<T>,
reason: &Self::Reason,
) -> Result<Self::Position, DispatchError>
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 variantErr(DispatchError)withCommitNotFoundif no commitment exists
Source§fn get_digest_variant_value(
reason: &Self::Reason,
digest: &Self::Digest,
variant: &Self::Position,
) -> Result<Self::Asset, DispatchError>
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 existErr(DispatchError)withDigestNotFoundif 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>
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 constraintsErr(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>
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 constraintsErr(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>
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 constraintsErr(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>
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 updateErr(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>
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 amountErr(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,
)
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,
)
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,
)
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>
fn set_commit_variant( who: &Proprietor, reason: &Self::Reason, variant: &Self::Position, qualifier: &Self::Intent, ) -> Result<(), DispatchError>
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
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>
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
variantis 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>
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
variantis ignored because each commit already defines its own variant during deposit operation.
§Returns
Ok(Imbalance)containing both the deposited and the withdrawn valueErr(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>
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
variantis 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 entriesErr(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>
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 commissionsErr(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.
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
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
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
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
type Intent = DispatchPolicy
Commitment operation top level configuration.
Enforces exactness and forcefullness towards a commit operation.
Source§type Limits = LimitsProduct<T, I>
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
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 existsErr(DispatchError)if no commitment exists
Source§fn digest_exists(reason: &Self::Reason, digest: &Self::Digest) -> DispatchResult
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 existsErr(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
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 succeedsErr(DispatchError)if validation fails
Source§fn can_raise_commit(
who: &Proprietor<T>,
reason: &Self::Reason,
value: Self::Asset,
qualifier: &Self::Intent,
) -> DispatchResult
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 succeedsErr(DispatchError)if any constraint is violated
Source§fn can_resolve_commit(
who: &Proprietor<T>,
reason: &Self::Reason,
) -> DispatchResult
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 validErr(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
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 succeedsErr(DispatchError)if validation fails
Source§fn get_commit_digest(
who: &Proprietor<T>,
reason: &Self::Reason,
) -> Result<Self::Digest, DispatchError>
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 digestErr(DispatchError)if no commitment exists
Source§fn get_total_value(reason: &Self::Reason) -> Self::Asset
fn get_total_value(reason: &Self::Reason) -> Self::Asset
Retrieves the total committed value across all proprietors for a reason.
§Returns
Assetcontaining the total committed value, or zero if unavailable
Source§fn get_commit_value(
who: &Proprietor<T>,
reason: &Self::Reason,
) -> Result<Self::Asset, DispatchError>
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 valueErr(DispatchError)if no commitment exists
Source§fn get_digest_value(
reason: &Self::Reason,
digest: &Self::Digest,
) -> Result<Self::Asset, DispatchError>
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 valueErr(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>
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 constraintsErr(DispatchError)if the derivation fails
Source§fn raise_commit_limits(
who: &Proprietor<T>,
reason: &Self::Reason,
qualifier: &Self::Intent,
) -> Result<Self::Limits, DispatchError>
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 constraintsErr(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>
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 constraintsErr(DispatchError)if the derivation fails
Source§fn digest_reap_limits(
digest: &Self::Digest,
reason: &Self::Reason,
qualifier: &Self::Intent,
) -> Result<Self::Limits, DispatchError>
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 constraintsErr(DispatchError)if the derivation fails
Source§fn gen_digest(source: &DigestSource<T>) -> Result<Self::Digest, DispatchError>
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 digestErr(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>
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 amountErr(DispatchError)if placement fails
Source§fn resolve_commit(
who: &Proprietor<T>,
reason: &Self::Reason,
) -> Result<Self::Asset, DispatchError>
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 proprietorErr(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>
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 amountErr(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>
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 updateErr(DispatchError)if the operation fails
Source§fn reap_digest(digest: &Self::Digest, reason: &Self::Reason) -> DispatchResult
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 removedErr(DispatchError)withDigestHasFundsif active deposits still exist
Source§fn on_commit_place(
who: &Proprietor<T>,
reason: &Self::Reason,
digest: &Self::Digest,
value: Self::Asset,
)
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,
)
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,
)
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,
)
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,
)
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: 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.
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>
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>
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:
- Direct
- Index
- 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> GetStorageVersion for Pallet<T, I>
impl<T: Config<I>, I: 'static> GetStorageVersion for Pallet<T, I>
Source§type InCodeStorageVersion = NoStorageVersionSet
type InCodeStorageVersion = NoStorageVersionSet
Source§fn in_code_storage_version() -> Self::InCodeStorageVersion
fn in_code_storage_version() -> Self::InCodeStorageVersion
storage_version attribute, or
[NoStorageVersionSet] if the attribute is missing.Source§fn on_chain_storage_version() -> StorageVersion
fn on_chain_storage_version() -> StorageVersion
§fn current_storage_version() -> Self::InCodeStorageVersion
fn current_storage_version() -> Self::InCodeStorageVersion
in_code_storage_version and will be removed after March 2024.Self::current_storage_version] instead. Read moreSource§impl<T: Config<I>, I: 'static> Hooks<<<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number> for Pallet<T, I>
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
fn on_initialize(_n: BlockNumber) -> Weight
§fn on_finalize(_n: BlockNumber)
fn on_finalize(_n: BlockNumber)
§fn on_idle(_n: BlockNumber, _remaining_weight: Weight) -> Weight
fn on_idle(_n: BlockNumber, _remaining_weight: Weight) -> Weight
Hooks::on_finalize]). Read more§fn on_poll(_n: BlockNumber, _weight: &mut WeightMeter)
fn on_poll(_n: BlockNumber, _weight: &mut WeightMeter)
§fn on_runtime_upgrade() -> Weight
fn on_runtime_upgrade() -> Weight
Executive pallet. Read more§fn offchain_worker(_n: BlockNumber)
fn offchain_worker(_n: BlockNumber)
§fn integrity_test()
fn integrity_test()
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.
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>
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 removalErr(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>
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 modificationErr(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
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>
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 digestShares: The number of shares assigned to the entryPosition: The variant/disposition of the entry
§Returns
Ok(Index)containing the prepared indexErr(DispatchError)if preparation fails
Source§fn get_entry_variant(
reason: &Self::Reason,
index_of: &Self::Digest,
entry_of: &Self::Digest,
) -> Result<Self::Position, DispatchError>
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 variantErr(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>
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
sharesisSome(zero), the entry is removed. - If
sharesisSome, both shares and variant are updated. - If
sharesisNone, only the variant is updated while retaining existing shares.
- If
- If the entry does not exist:
- If
sharesisSome(zero)orNone, the operation is a no-op and the original index is returned. - Otherwise, a new entry is added with the provided variant and shares.
- If
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.
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
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
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::PrepareForCommitreason - 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>
impl<T: Config<I>, I: 'static> IntegrityTest for Pallet<T, I>
Source§fn integrity_test()
fn integrity_test()
Hooks::integrity_test].Source§impl<T, I> LazyBalance for Pallet<T, I>where
T: Config<I>,
I: 'static,
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
type Asset = <<T as Config<I>>::Asset as Inspect<<T as Config>::AccountId>>::Balance
Source§type Rational = <T as Config<I>>::Bias
type Rational = <T as Config<I>>::Bias
Source§type Balance = ProductType<T, I, <<T as Config<I>>::BalanceContext as ModelContext>::Context, BalanceAsset, BalanceRational, BalanceTime, BalanceAddon>
type Balance = ProductType<T, I, <<T as Config<I>>::BalanceContext as ModelContext>::Context, BalanceAsset, BalanceRational, BalanceTime, BalanceAddon>
Source§type Limits = LimitsProduct<T, I>
type Limits = LimitsProduct<T, I>
Source§type Subject = DispatchPolicy
type Subject = DispatchPolicy
Source§type SnapShot = ProductType<T, I, <<T as Config<I>>::BalanceContext as ModelContext>::Context, SnapShotAsset, SnapShotRational, SnapShotTime, SnapShotAddon>
type SnapShot = ProductType<T, I, <<T as Config<I>>::BalanceContext as ModelContext>::Context, SnapShotAsset, SnapShotRational, SnapShotTime, SnapShotAddon>
Source§type Receipt = ProductType<T, I, <<T as Config<I>>::BalanceContext as ModelContext>::Context, ReceiptAsset, ReceiptRational, ReceiptTime, ReceiptAddon>
type Receipt = ProductType<T, I, <<T as Config<I>>::BalanceContext as ModelContext>::Context, ReceiptAsset, ReceiptRational, ReceiptTime, ReceiptAddon>
Source§type Output<'a> = LazyOutput<'a, T, I>
type Output<'a> = LazyOutput<'a, T, I>
Source§type BalanceFamily<'a> = <T as Config<I>>::BalanceFamily<'a>
type BalanceFamily<'a> = <T as Config<I>>::BalanceFamily<'a>
Source§type BalanceContext = <T as Config<I>>::BalanceContext
type BalanceContext = <T as Config<I>>::BalanceContext
Source§fn can_deposit<'a>(input: Self::Input<'a>) -> Self::Output<'a>
fn can_deposit<'a>(input: Self::Input<'a>) -> Self::Output<'a>
CanDeposit of the plugin family - LazyBalanceRoot
Returns whether a deposit is permitted.Source§fn can_withdraw<'a>(input: Self::Input<'a>) -> Self::Output<'a>
fn can_withdraw<'a>(input: Self::Input<'a>) -> Self::Output<'a>
CanWithdraw of the plugin family - LazyBalanceRoot
Returns whether a withdrawal is permitted.Source§fn can_mint<'a>(input: Self::Input<'a>) -> Self::Output<'a>
fn can_mint<'a>(input: Self::Input<'a>) -> Self::Output<'a>
CanMint of the plugin family - LazyBalanceRoot
Returns whether minting is permitted.Source§fn can_reap<'a>(input: Self::Input<'a>) -> Self::Output<'a>
fn can_reap<'a>(input: Self::Input<'a>) -> Self::Output<'a>
CanReap of the plugin family - LazyBalanceRoot
Returns whether reaping is permitted.Source§fn deposit<'a>(input: Self::Input<'a>) -> Self::Output<'a>
fn deposit<'a>(input: Self::Input<'a>) -> Self::Output<'a>
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>
fn withdraw<'a>(input: Self::Input<'a>) -> Self::Output<'a>
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>
fn mint<'a>(input: Self::Input<'a>) -> Self::Output<'a>
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>
fn reap<'a>(input: Self::Input<'a>) -> Self::Output<'a>
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>
fn drain<'a>(input: Self::Input<'a>) -> Self::Output<'a>
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>
fn total_value<'a>(input: Self::Input<'a>) -> Self::Output<'a>
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>
fn receipt_active_value<'a>(input: Self::Input<'a>) -> Self::Output<'a>
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>
fn has_deposits<'a>(input: Self::Input<'a>) -> Self::Output<'a>
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>
fn receipt_deposit_value<'a>(input: Self::Input<'a>) -> Self::Output<'a>
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>
fn deposit_limits<'a>(input: Self::Input<'a>) -> Self::Output<'a>
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>
fn mint_limits<'a>(input: Self::Input<'a>) -> Self::Output<'a>
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>
fn reap_limits<'a>(input: Self::Input<'a>) -> Self::Output<'a>
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>
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>)
fn offchain_worker(n: BlockNumberFor<T>)
Source§impl<T: Config<I>, I: 'static> OnFinalize<<<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number> for Pallet<T, I>
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>)
fn on_finalize(n: BlockNumberFor<T>)
Hooks::on_finalize].Source§impl<T: Config<I>, I: 'static> OnGenesis for Pallet<T, I>
impl<T: Config<I>, I: 'static> OnGenesis for Pallet<T, I>
Source§fn on_genesis()
fn on_genesis()
Source§impl<T: Config<I>, I: 'static> OnIdle<<<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number> for Pallet<T, I>
impl<T: Config<I>, I: 'static> OnIdle<<<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number> for Pallet<T, I>
Source§impl<T: Config<I>, I: 'static> OnInitialize<<<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number> for Pallet<T, I>
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
fn on_initialize(n: BlockNumberFor<T>) -> Weight
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>
impl<T: Config<I>, I: 'static> OnPoll<<<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number> for Pallet<T, I>
Source§impl<T: Config<I>, I: 'static> OnRuntimeUpgrade for Pallet<T, I>
impl<T: Config<I>, I: 'static> OnRuntimeUpgrade for Pallet<T, I>
Source§fn on_runtime_upgrade() -> Weight
fn on_runtime_upgrade() -> Weight
Hooks::on_runtime_upgrade].Source§impl<T: Config<I>, I: 'static> PalletInfoAccess for Pallet<T, I>
impl<T: Config<I>, I: 'static> PalletInfoAccess for Pallet<T, I>
Source§fn module_name() -> &'static str
fn module_name() -> &'static str
Source§fn crate_version() -> CrateVersion
fn crate_version() -> CrateVersion
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.
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>
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>
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 balanceErr(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
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 recoveredErr(DispatchError)withReleasePoolToRecoverif 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
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 foundErr(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
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 setErr(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
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>
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 variantErr(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
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
sharesisNone.
- If the slot does not exist:
- Creates a new slot if non-zero
sharesis provided. - Does nothing if
sharesis zero. - Returns an error if
sharesisNone(no slot to update and no data to create).
- Creates a new slot if non-zero
§Returns
Ok(())if the operation completes successfullyErr(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,
)
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:
Event::PoolSlotifshares > 0Event::PoolSlotRemovedifshares == 0
Events are emitted only if Config::EmitEvents is true.
Source§impl<T: Config<I>, I: 'static> StorageInfoTrait for Pallet<T, I>
impl<T: Config<I>, I: 'static> StorageInfoTrait for Pallet<T, I>
fn storage_info() -> Vec<StorageInfo>
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.
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)
type Key = (<T as Config>::AccountId, <T as Config<I>>::Position, <T as Config<I>>::Time)
Source§type Value = ProductType<T, I, <<T as Config<I>>::BalanceContext as ModelContext>::Context, SnapShotAsset, SnapShotRational, SnapShotTime, SnapShotAddon>
type Value = ProductType<T, I, <<T as Config<I>>::BalanceContext as ModelContext>::Context, SnapShotAsset, SnapShotRational, SnapShotTime, SnapShotAddon>
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>)
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>)
Key is transformed into storage keys. Read moreSource§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>>
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>>
Source§type Query = Option<ProductType<T, I, <<T as Config<I>>::BalanceContext as ModelContext>::Context, SnapShotAsset, SnapShotRational, SnapShotTime, SnapShotAddon>>
type Query = Option<ProductType<T, I, <<T as Config<I>>::BalanceContext as ModelContext>::Context, SnapShotAsset, SnapShotRational, SnapShotTime, SnapShotAddon>>
Source§fn contains_key(key: Self::Key) -> bool
fn contains_key(key: Self::Key) -> bool
key exists.Source§fn mutate<R>(key: Self::Key, f: impl FnOnce(&mut Option<Self::Value>) -> R) -> R
fn mutate<R>(key: Self::Key, f: impl FnOnce(&mut Option<Self::Value>) -> R) -> R
key in-place. Read moreSource§fn iter() -> impl Iterator<Item = (<Self::KeyGen as KeyGenerator>::Key, Self::Value)>
fn iter() -> impl Iterator<Item = (<Self::KeyGen as KeyGenerator>::Key, Self::Value)>
(full_key, value) pairs.Source§fn iter_keys() -> impl Iterator<Item = <Self::KeyGen as KeyGenerator>::Key>
fn iter_keys() -> impl Iterator<Item = <Self::KeyGen as KeyGenerator>::Key>
Source§fn iter_values() -> impl Iterator<Item = Self::Value>
fn iter_values() -> impl Iterator<Item = Self::Value>
Source§fn drain() -> impl Iterator<Item = (<Self::KeyGen as KeyGenerator>::Key, Self::Value)>
fn drain() -> impl Iterator<Item = (<Self::KeyGen as KeyGenerator>::Key, Self::Value)>
(key, value) pairs.Source§fn iter_prefix_values<P>(prefix: P) -> impl Iterator<Item = Self::Value>where
Self::KeyGen: HasKeyPrefix<P>,
fn iter_prefix_values<P>(prefix: P) -> impl Iterator<Item = Self::Value>where
Self::KeyGen: HasKeyPrefix<P>,
Source§fn iter_prefix<P>(
prefix: P,
) -> impl Iterator<Item = (<Self::KeyGen as HasKeyPrefix<P>>::Suffix, Self::Value)>where
Self::KeyGen: HasReversibleKeyPrefix<P>,
fn iter_prefix<P>(
prefix: P,
) -> impl Iterator<Item = (<Self::KeyGen as HasKeyPrefix<P>>::Suffix, Self::Value)>where
Self::KeyGen: HasReversibleKeyPrefix<P>,
(suffix, value) under a prefix. Read moreSource§impl<T: Config<I>, I: 'static> WhitelistedStorageKeys for Pallet<T, I>
impl<T: Config<I>, I: 'static> WhitelistedStorageKeys for Pallet<T, I>
Source§fn whitelisted_storage_keys() -> Vec<TrackedStorageKey>
fn whitelisted_storage_keys() -> Vec<TrackedStorageKey>
Vec<TrackedStorageKey> indicating the storage keys that
should be whitelisted during benchmarking. This means that those keys
will be excluded from the benchmarking performance calculation.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>where
T: RefUnwindSafe,
I: RefUnwindSafe,
impl<T, I> Send for Pallet<T, I>
impl<T, I> Sync for Pallet<T, I>
impl<T, I> Unpin for Pallet<T, I>
impl<T, I> UnwindSafe for Pallet<T, I>where
T: UnwindSafe,
I: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> CheckedConversion for T
impl<T> CheckedConversion for T
§fn checked_from<T>(t: T) -> Option<Self>where
Self: TryFrom<T>,
fn checked_from<T>(t: T) -> Option<Self>where
Self: TryFrom<T>,
§fn checked_into<T>(self) -> Option<T>where
Self: TryInto<T>,
fn checked_into<T>(self) -> Option<T>where
Self: TryInto<T>,
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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 moreSource§impl<T, U, Tag> IntoTag<U, Tag> for Twhere
U: FromTag<T, Tag>,
Tag: DiscriminantTag,
impl<T, U, Tag> IntoTag<U, Tag> for Twhere
U: FromTag<T, Tag>,
Tag: DiscriminantTag,
§impl<Src, Dest> IntoTuple<Dest> for Srcwhere
Dest: FromTuple<Src>,
impl<Src, Dest> IntoTuple<Dest> for Srcwhere
Dest: FromTuple<Src>,
fn into_tuple(self) -> Dest
§impl<T> IsType<T> for T
impl<T> IsType<T> for T
§impl<T, Outer> IsWrappedBy<Outer> for T
impl<T, Outer> IsWrappedBy<Outer> for T
Source§impl<T, Time> Logging<Time> for Twhere
Time: Time,
impl<T, Time> Logging<Time> for Twhere
Time: Time,
Source§const FALLBACK_TARGET: &'static str = "routine"
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
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
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
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
Source§fn info(
err: &Self::Logger,
timestamp: Timestamp,
target: Option<&str>,
fmt: Option<fn(Timestamp, &Self::Level, &str, &str) -> String>,
) -> Self::Loggerwhere
Self: Sized,
fn info(
err: &Self::Logger,
timestamp: Timestamp,
target: Option<&str>,
fmt: Option<fn(Timestamp, &Self::Level, &str, &str) -> String>,
) -> Self::Loggerwhere
Self: Sized,
Source§fn warn(
err: &Self::Logger,
timestamp: Timestamp,
target: Option<&str>,
fmt: Option<fn(Timestamp, &Self::Level, &str, &str) -> String>,
) -> Self::Loggerwhere
Self: Sized,
fn warn(
err: &Self::Logger,
timestamp: Timestamp,
target: Option<&str>,
fmt: Option<fn(Timestamp, &Self::Level, &str, &str) -> String>,
) -> Self::Loggerwhere
Self: Sized,
§impl<T> SaturatedConversion for T
impl<T> SaturatedConversion for T
§fn saturated_from<T>(t: T) -> Selfwhere
Self: UniqueSaturatedFrom<T>,
fn saturated_from<T>(t: T) -> Selfwhere
Self: UniqueSaturatedFrom<T>,
§fn saturated_into<T>(self) -> Twhere
Self: UniqueSaturatedInto<T>,
fn saturated_into<T>(self) -> Twhere
Self: UniqueSaturatedInto<T>,
T. Read more§impl<T, U> TryIntoKey<U> for Twhere
U: TryFromKey<T>,
impl<T, U> TryIntoKey<U> for Twhere
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 Swhere
T: UncheckedFrom<S>,
impl<S, T> UncheckedInto<T> for Swhere
T: UncheckedFrom<S>,
§fn unchecked_into(self) -> T
fn unchecked_into(self) -> T
unchecked_from.§impl<T, S> UniqueSaturatedInto<T> for S
impl<T, S> UniqueSaturatedInto<T> for S
§fn unique_saturated_into(self) -> T
fn unique_saturated_into(self) -> T
T.