drive/util/batch/drive_op_batch/
system.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::fee::Credits;
7use dpp::platform_value::Bytes36;
8
9use dpp::asset_lock::reduced_asset_lock_value::AssetLockValue;
10
11use dpp::version::PlatformVersion;
12use grovedb::batch::KeyInfoPath;
13use grovedb::{EstimatedLayerInformation, TransactionArg};
14use std::collections::HashMap;
15
16#[derive(Clone, Debug)]
18pub enum SystemOperationType {
19 AddToSystemCredits {
21 amount: Credits,
23 },
24 RemoveFromSystemCredits {
26 amount: Credits,
28 },
29 AddUsedAssetLock {
32 asset_lock_outpoint: Bytes36,
34 asset_lock_value: AssetLockValue,
36 },
37}
38
39impl DriveLowLevelOperationConverter for SystemOperationType {
40 fn into_low_level_drive_operations(
41 self,
42 drive: &Drive,
43 estimated_costs_only_with_layer_info: &mut Option<
44 HashMap<KeyInfoPath, EstimatedLayerInformation>,
45 >,
46 _block_info: &BlockInfo,
47 transaction: TransactionArg,
48 platform_version: &PlatformVersion,
49 ) -> Result<Vec<LowLevelDriveOperation>, Error> {
50 match self {
51 SystemOperationType::AddToSystemCredits { amount } => drive
52 .add_to_system_credits_operations(
53 amount,
54 estimated_costs_only_with_layer_info,
55 transaction,
56 platform_version,
57 ),
58 SystemOperationType::RemoveFromSystemCredits { amount } => drive
59 .remove_from_system_credits_operations(
60 amount,
61 estimated_costs_only_with_layer_info,
62 transaction,
63 platform_version,
64 ),
65 SystemOperationType::AddUsedAssetLock {
66 asset_lock_outpoint,
67 asset_lock_value,
68 } => drive.add_asset_lock_outpoint_operations(
69 &asset_lock_outpoint,
70 asset_lock_value,
71 estimated_costs_only_with_layer_info,
72 platform_version,
73 ),
74 }
75 }
76}