pub trait CommitBalance<Proprietor, Pallet>where
Pallet: LazyBalance<Asset = <Pallet as InspectAsset<Proprietor>>::Asset> + InspectAsset<Proprietor> + Commitment<Proprietor>,{
type Imbalance;
// Required methods
fn resolve_imbalance(
who: &Proprietor,
imbalance: Self::Imbalance,
) -> Result<<Pallet as InspectAsset<Proprietor>>::Asset, DispatchError>;
fn deduct_balance(
who: &Proprietor,
value: <Pallet as InspectAsset<Proprietor>>::Asset,
qualifier: &Pallet::Intent,
) -> Result<<Pallet as InspectAsset<Proprietor>>::Asset, DispatchError>;
fn deduct_from_imbalance(
imbalance: &mut Self::Imbalance,
value: <Pallet as InspectAsset<Proprietor>>::Asset,
) -> Result<Self::Imbalance, DispatchError>;
}Expand description
Provides low-level balance management and reconciliation behavior
for Commitment systems.
Commitment frameworks often employ unbalanced fungible traits rather than automatically balanced ones. This enables explicit safety enforcement and auditability by requiring all balance mismatches to be resolved intentionally rather than implicitly.
This trait defines how those imbalances and balance adjustments should be handled consistently across the system.
It only defines low-level, unchecked operations - callers are responsible for ensuring validity and equilibrium before invoking this function.
§Generics
- Proprietor - the entity (e.g. account, vault, or manager) owning or controlling the underlying asset balance.
- Pallet - the pallet public struct which implements
Commitmenttraits for consumer pallet usage, and provides the required commitment abstraction. - The implementing
Palletmust provideLazyBalancewith guarantees that all balance operations remain consistent with the commitment system’s underlying asset accounting.
Required Associated Types§
Required Methods§
Sourcefn resolve_imbalance(
who: &Proprietor,
imbalance: Self::Imbalance,
) -> Result<<Pallet as InspectAsset<Proprietor>>::Asset, DispatchError>
fn resolve_imbalance( who: &Proprietor, imbalance: Self::Imbalance, ) -> Result<<Pallet as InspectAsset<Proprietor>>::Asset, DispatchError>
Resolves an imbalance in a proprietor’s committed balance.
Used when a digest’s value adjustment causes a mismatch in deposited versus withdrawn amounts.
Ensures the underlying asset accounting remains correct by minting, burning, or otherwise reconciling the imbalance.
It only defines low-level, unchecked operations - callers are responsible for ensuring validity and equilibrium before invoking this function.
§Returns
Ok(Asset)containing the final balanced valueErr(DispatchError)if reconciliation fails
Sourcefn deduct_balance(
who: &Proprietor,
value: <Pallet as InspectAsset<Proprietor>>::Asset,
qualifier: &Pallet::Intent,
) -> Result<<Pallet as InspectAsset<Proprietor>>::Asset, DispatchError>
fn deduct_balance( who: &Proprietor, value: <Pallet as InspectAsset<Proprietor>>::Asset, qualifier: &Pallet::Intent, ) -> Result<<Pallet as InspectAsset<Proprietor>>::Asset, DispatchError>
Deducts a specified asset value from the proprietor’s available balance.
This function deducts the requested amount according to the given qualifier - exactness or best effort along with force rules to determine whether and how the deduction should proceed.
It only defines low-level, unchecked operations - callers are responsible for ensuring validity and equilibrium before invoking this function.
§Returns
Ok(Asset)containing the actual deducted valueErr(DispatchError)if the deduction fails
Sourcefn deduct_from_imbalance(
imbalance: &mut Self::Imbalance,
value: <Pallet as InspectAsset<Proprietor>>::Asset,
) -> Result<Self::Imbalance, DispatchError>
fn deduct_from_imbalance( imbalance: &mut Self::Imbalance, value: <Pallet as InspectAsset<Proprietor>>::Asset, ) -> Result<Self::Imbalance, DispatchError>
Deducts a specified asset value from a imbalance (effectively mutating it).
This function deducts the exact amount, maintains equillibrium and
returns another imbalance - to be resolved (typically by Self::resolve_imbalance).
This provides extracting new-imbalances from existing imbalances safely.
It only defines low-level, unchecked operations - callers are responsible for ensuring validity and equilibrium before invoking this function.
§Returns
Ok(Imbalance)containing the new imbalanceErr(DispatchError)if the deduction fails
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> 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.