drive/util/batch/drive_op_batch/
address_funds.rs1use crate::drive::Drive;
2use crate::error::Error;
3use crate::fees::op::LowLevelDriveOperation;
4use crate::util::batch::drive_op_batch::DriveLowLevelOperationConverter;
5use dpp::address_funds::PlatformAddress;
6use dpp::block::block_info::BlockInfo;
7use dpp::fee::Credits;
8use dpp::prelude::AddressNonce;
9use grovedb::batch::KeyInfoPath;
10use grovedb::{EstimatedLayerInformation, TransactionArg};
11use platform_version::version::PlatformVersion;
12use std::collections::HashMap;
13
14#[derive(Clone, Debug)]
16pub enum AddressFundsOperationType {
17 SetBalanceToAddress {
20 address: PlatformAddress,
22 nonce: AddressNonce,
24 balance: Credits,
26 },
27 AddBalanceToAddress {
30 address: PlatformAddress,
32 balance_to_add: Credits,
34 },
35}
36
37impl DriveLowLevelOperationConverter for AddressFundsOperationType {
38 fn into_low_level_drive_operations(
39 self,
40 drive: &Drive,
41 estimated_costs_only_with_layer_info: &mut Option<
42 HashMap<KeyInfoPath, EstimatedLayerInformation>,
43 >,
44 _block_info: &BlockInfo,
45 transaction: TransactionArg,
46 platform_version: &PlatformVersion,
47 ) -> Result<Vec<LowLevelDriveOperation>, Error> {
48 match self {
49 AddressFundsOperationType::SetBalanceToAddress {
50 address,
51 nonce,
52 balance,
53 } => drive.set_balance_to_address_operations(
54 address,
55 nonce,
56 balance,
57 estimated_costs_only_with_layer_info,
58 platform_version,
59 ),
60 AddressFundsOperationType::AddBalanceToAddress {
61 address,
62 balance_to_add,
63 } => drive.add_balance_to_address_operations(
64 address,
65 balance_to_add,
66 estimated_costs_only_with_layer_info,
67 transaction,
68 platform_version,
69 ),
70 }
71 }
72}