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)]
25pub enum SystemOperationType {
26 AddToSystemCredits {
28 amount: Credits,
30 },
31 RemoveFromSystemCredits {
33 amount: Credits,
35 },
36 AddUsedAssetLock {
39 asset_lock_outpoint: Bytes36,
41 asset_lock_value: AssetLockValue,
43 },
44}
45
46impl DriveLowLevelOperationConverter for SystemOperationType {
47 fn into_low_level_drive_operations(
48 self,
49 drive: &Drive,
50 estimated_costs_only_with_layer_info: &mut Option<
51 HashMap<KeyInfoPath, EstimatedLayerInformation>,
52 >,
53 _block_info: &BlockInfo,
54 transaction: TransactionArg,
55 platform_version: &PlatformVersion,
56 ) -> Result<Vec<LowLevelDriveOperation>, Error> {
57 match self {
58 SystemOperationType::AddToSystemCredits { amount } => drive
59 .add_to_system_credits_operations(
60 amount,
61 estimated_costs_only_with_layer_info,
62 transaction,
63 platform_version,
64 ),
65 SystemOperationType::RemoveFromSystemCredits { amount } => drive
66 .remove_from_system_credits_operations(
67 amount,
68 estimated_costs_only_with_layer_info,
69 transaction,
70 platform_version,
71 ),
72 SystemOperationType::AddUsedAssetLock {
73 asset_lock_outpoint,
74 asset_lock_value,
75 } => drive.add_asset_lock_outpoint_operations(
76 &asset_lock_outpoint,
77 asset_lock_value,
78 estimated_costs_only_with_layer_info,
79 platform_version,
80 ),
81 }
82 }
83}