pub trait StateTransitionAddressEstimatedFeeValidation: StateTransitionEstimatedFeeValidation {
// Required method
fn calculate_amount_available(
&self,
remaining_balances: &BTreeMap<PlatformAddress, (AddressNonce, Credits)>,
) -> Credits;
// Provided method
fn validate_estimated_fee(
&self,
remaining_balances: &BTreeMap<PlatformAddress, (AddressNonce, Credits)>,
platform_version: &PlatformVersion,
) -> Result<ConsensusValidationResult<Credits>, ProtocolError> { ... }
}Expand description
Trait for validating that address-based state transitions have sufficient funds for fees.
This trait extends fee estimation with validation capabilities specific to address-based state transitions that pay fees from address balances rather than identity balances.
Required Methods§
Sourcefn calculate_amount_available(
&self,
remaining_balances: &BTreeMap<PlatformAddress, (AddressNonce, Credits)>,
) -> Credits
fn calculate_amount_available( &self, remaining_balances: &BTreeMap<PlatformAddress, (AddressNonce, Credits)>, ) -> Credits
Calculates the total amount available for fee payment based on the fee strategy.
This examines the transition’s fee strategy and sums up the available credits
from inputs (via DeductFromInput) and outputs (via ReduceOutput) that are
designated for fee payment.
§Arguments
remaining_balances- The remaining balances of addresses after input amounts are consumed.
§Returns
The total credits available for fee payment.
Provided Methods§
Sourcefn validate_estimated_fee(
&self,
remaining_balances: &BTreeMap<PlatformAddress, (AddressNonce, Credits)>,
platform_version: &PlatformVersion,
) -> Result<ConsensusValidationResult<Credits>, ProtocolError>
fn validate_estimated_fee( &self, remaining_balances: &BTreeMap<PlatformAddress, (AddressNonce, Credits)>, platform_version: &PlatformVersion, ) -> Result<ConsensusValidationResult<Credits>, ProtocolError>
Validates that sufficient funds are available to cover the estimated fee.
This is a pre-check validation to quickly verify that the addresses referenced in the fee strategy have enough remaining balance to pay the estimated fee.
§Arguments
remaining_balances- The remaining balances of addresses after input amounts are consumed.platform_version- The platform version containing fee configuration.
§Returns
A validation result. If validation fails, contains an AddressesNotEnoughFundsError.