drive/util/batch/drive_op_batch/
prefunded_specialized_balance.rs1use crate::drive::Drive;
2use crate::error::Error;
3use crate::fees::op::LowLevelDriveOperation;
4use crate::util::batch::drive_op_batch::DriveLowLevelOperationConverter;
5use dpp::block::block_info::BlockInfo;
6use dpp::identifier::Identifier;
7use grovedb::batch::KeyInfoPath;
8use grovedb::{EstimatedLayerInformation, TransactionArg};
9use platform_version::version::PlatformVersion;
10use std::collections::HashMap;
11
12#[derive(Clone, Debug)]
14pub enum PrefundedSpecializedBalanceOperationType {
15 CreateNewPrefundedBalance {
17 prefunded_specialized_balance_id: Identifier,
19 add_balance: u64,
21 },
22 DeductFromPrefundedBalance {
24 prefunded_specialized_balance_id: Identifier,
26 remove_balance: u64,
28 },
29}
30
31impl DriveLowLevelOperationConverter for PrefundedSpecializedBalanceOperationType {
32 fn into_low_level_drive_operations(
33 self,
34 drive: &Drive,
35 estimated_costs_only_with_layer_info: &mut Option<
36 HashMap<KeyInfoPath, EstimatedLayerInformation>,
37 >,
38 _block_info: &BlockInfo,
39 transaction: TransactionArg,
40 platform_version: &PlatformVersion,
41 ) -> Result<Vec<LowLevelDriveOperation>, Error> {
42 match self {
43 PrefundedSpecializedBalanceOperationType::CreateNewPrefundedBalance {
44 prefunded_specialized_balance_id: specialized_balance_id,
45 add_balance: added_balance,
46 } => drive.add_prefunded_specialized_balance_operations(
47 specialized_balance_id,
48 added_balance,
49 estimated_costs_only_with_layer_info,
50 transaction,
51 platform_version,
52 ),
53 PrefundedSpecializedBalanceOperationType::DeductFromPrefundedBalance {
54 prefunded_specialized_balance_id: specialized_balance_id,
55 remove_balance: removed_balance,
56 } => drive.deduct_from_prefunded_specialized_balance_operations(
57 specialized_balance_id,
58 removed_balance,
59 estimated_costs_only_with_layer_info,
60 transaction,
61 platform_version,
62 ),
63 }
64 }
65}