Trait CommitOps

Source
pub trait CommitOps<Proprietor, Pallet>
where Pallet: LazyBalance<Asset = <Pallet as InspectAsset<Proprietor>>::Asset, Variant = Pallet::Position, Id = Pallet::Digest> + DigestModel<Proprietor> + CommitVariant<Proprietor>,
{
Show 15 methods // Required methods fn place_commit_of( who: &Proprietor, reason: &Pallet::Reason, digest_model: &Pallet::Model, value: <Pallet as InspectAsset<Proprietor>>::Asset, variant: &Pallet::Position, qualifier: &Pallet::Intent, ) -> Result<<Pallet as InspectAsset<Proprietor>>::Asset, DispatchError>; fn place_digest_commit( who: &Proprietor, reason: &Pallet::Reason, digest: &Pallet::Digest, value: <Pallet as InspectAsset<Proprietor>>::Asset, variant: &Pallet::Position, qualifier: &Pallet::Intent, ) -> Result<<Pallet as InspectAsset<Proprietor>>::Asset, DispatchError>; fn place_index_commit( who: &Proprietor, reason: &Pallet::Reason, index_of: &Pallet::Digest, value: <Pallet as InspectAsset<Proprietor>>::Asset, variant: &Pallet::Position, qualifier: &Pallet::Intent, ) -> Result<<Pallet as InspectAsset<Proprietor>>::Asset, DispatchError>; fn place_pool_commit( who: &Proprietor, reason: &Pallet::Reason, pool_of: &Pallet::Digest, value: <Pallet as InspectAsset<Proprietor>>::Asset, variant: &Pallet::Position, qualifier: &Pallet::Intent, ) -> Result<<Pallet as InspectAsset<Proprietor>>::Asset, DispatchError>; fn raise_commit_of( who: &Proprietor, reason: &Pallet::Reason, digest_model: &Pallet::Model, value: <Pallet as InspectAsset<Proprietor>>::Asset, qualifier: &Pallet::Intent, ) -> Result<<Pallet as InspectAsset<Proprietor>>::Asset, DispatchError>; fn raise_digest_commit( who: &Proprietor, reason: &Pallet::Reason, digest: &Pallet::Digest, value: <Pallet as InspectAsset<Proprietor>>::Asset, qualifier: &Pallet::Intent, ) -> Result<<Pallet as InspectAsset<Proprietor>>::Asset, DispatchError>; fn raise_index_commit( who: &Proprietor, reason: &Pallet::Reason, index_of: &Pallet::Digest, value: <Pallet as InspectAsset<Proprietor>>::Asset, qualifier: &Pallet::Intent, ) -> Result<<Pallet as InspectAsset<Proprietor>>::Asset, DispatchError>; fn raise_pool_commit( who: &Proprietor, reason: &Pallet::Reason, pool_of: &Pallet::Digest, value: <Pallet as InspectAsset<Proprietor>>::Asset, qualifier: &Pallet::Intent, ) -> Result<<Pallet as InspectAsset<Proprietor>>::Asset, DispatchError>; fn resolve_commit_of( who: &Proprietor, reason: &Pallet::Reason, digest_model: &Pallet::Model, ) -> Result<<Pallet as InspectAsset<Proprietor>>::Asset, DispatchError>; fn resolve_digest_commit( who: &Proprietor, reason: &Pallet::Reason, digest: &Pallet::Digest, ) -> Result<<Pallet as InspectAsset<Proprietor>>::Asset, DispatchError>; fn resolve_index_commit( who: &Proprietor, reason: &Pallet::Reason, index_of: &Pallet::Digest, ) -> Result<<Pallet as InspectAsset<Proprietor>>::Asset, DispatchError>; fn resolve_pool_commit( who: &Proprietor, reason: &Pallet::Reason, pool_of: &Pallet::Digest, ) -> Result<<Pallet as InspectAsset<Proprietor>>::Asset, DispatchError>; fn set_total_value( reason: &Pallet::Reason, value: <Pallet as InspectAsset<Proprietor>>::Asset, ); // Provided methods fn add_to_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 { ... }
}
Expand description

Defines the core operations for managing commitments within digest models.

This trait provides a unified interface for placing, raising, and resolving commitments across all digest variants - direct, index, and pool.

This trait defines low-level, unchecked operations - callers are responsible for ensuring validity and equilibrium before invoking these functions.

§Generics

  • Proprietor - the entity (e.g. account, vault, or manager) controlling the asset.
  • Pallet - the public struct implementing Commitment traits and LazyBalance, ensuring consistent asset accounting across the commitment system.

Required Methods§

Source

fn place_commit_of( who: &Proprietor, reason: &Pallet::Reason, digest_model: &Pallet::Model, value: <Pallet as InspectAsset<Proprietor>>::Asset, variant: &Pallet::Position, qualifier: &Pallet::Intent, ) -> Result<<Pallet as InspectAsset<Proprietor>>::Asset, DispatchError>

Places a commitment using a fully resolved/wrapped digest model and a specified digest’s balance variant.

This function assumes the digest has already been found-valid and wrapped appropriately, so it directly handles the act of only committing the given value under the specified reason.

It only defines low-level, unchecked operations - callers are responsible for ensuring validity and equilibrium before invoking this function.

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

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

Places a commitment for a direct digest under a given reason and variant.

This function handles the placement of a commitment when the digest is a valid, single, direct item (not an index or pool). It records the committed value associated with the specific reason and digest, respecting the commitment rules.

It only defines low-level, unchecked operations - callers are responsible for ensuring validity and equilibrium before invoking this function.

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

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

Places a commitment for a index digest under a given reason and variant.

This function handles the placement of a commitment when the digest is a index. It records the committed value associated respecting the commitment rules - “One Reason, One Digest Commit” and uses high level structures to bypass it safely.

It only defines low-level, unchecked operations - callers are responsible for ensuring validity and equilibrium before invoking this function.

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

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

Places a commitment for a pool digest under a given reason and variant.

This function handles the placement of a commitment when the digest is a pool. It records the committed value associated respecting the commitment rules- “One Reason, One Digest Commit” and uses high level structures to bypass it safely.

It only defines low-level, unchecked operations - callers are responsible for ensuring validity and equilibrium before invoking this function.

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

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

Raises an existing commitment by adding a new commitment instance.

Commitments are immutable; each raise adds a new commit instance - by shareing semantics with existing commit of the reason. How accumulation is handled depends on the context: direct digest, index, or pool.

It only defines low-level, unchecked operations - callers are responsible for ensuring validity and equilibrium before invoking this function.

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

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

Adds a new instance of a commitment for a direct digest.

Commitments are immutable and cannot be changed once created. This enforces invariants by adding new commit instances to the same digest and reason.

It only defines low-level, unchecked operations - callers are responsible for ensuring validity and equilibrium before invoking this function.

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

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

Adds a new instance of a commitment for an index digest.

Commitments are immutable and cannot be changed once created. This enforces invariants by adding new commit instances to the same index digest and reason.

It only defines low-level, unchecked operations - callers are responsible for ensuring validity and equilibrium before invoking this function.

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

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

Adds a new instance of a commitment for a pool digest.

The pool should release and recover itself, adding the raised value. It may also record instances of commits for the proprietor to the pool rather than to its slot digest, since it collectively manages funds for commitments by the pool itself acting like a pseudo-proprietor.

It only defines low-level, unchecked operations - callers are responsible for ensuring validity and equilibrium before invoking this function.

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

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

Resolves and finalizes a commitment for a fully resolved digest model.

This method closes the commitment and provides the final withdrawn asset value from the commitment to the reason.

It only defines low-level, unchecked operations - callers are responsible for ensuring validity and equilibrium before invoking this function.

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

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

Resolves and finalizes a commitment for a direct digest.

This method closes the direct digest commitment and provides the final withdrawn asset value from the commitment to the reason.

It only defines low-level, unchecked operations - callers are responsible for ensuring validity and equilibrium before invoking this function.

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

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

Resolves and finalizes a commitment for an index digest.

This method closes the index digest commitment and provides the final withdrawn asset value from the commitment to the reason.

It only defines low-level, unchecked operations - callers are responsible for ensuring validity and equilibrium before invoking this function.

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

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

Resolves and finalizes a commitment for a pool digest.

This method closes the pool digest commitment and provides the final withdrawn asset value from the commitment to the reason.

It only defines low-level, unchecked operations - callers are responsible for ensuring validity and equilibrium before invoking this function.

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

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

Sets the total asset value for a given reason.

This is a low-level function and should only be used when equilibrium is maintained, meaning the value being set must correctly reflect the committed state of the system for the reason.

Provided Methods§

Source

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

Adds a given asset value to the total value for the specified reason.

It only defines low-level, unchecked operations - callers are responsible for ensuring validity and equilibrium before invoking this function.

§Returns
  • Ok(()) if the addition succeeds
  • Err(DispatchError) with Overflow if adding causes overflow
Source

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

Subtracts a given asset value from the total value for the specified reason.

It only defines low-level, unchecked operations - callers are responsible for ensuring validity and equilibrium before invoking this function.

§Returns
  • Ok(()) if the subtraction succeeds
  • Err(DispatchError) with Underflow if subtraction would underflow

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

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

Implements the CommitOps trait for the pallet

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