Repository: MystenLabs/sui
File: crates/sui-indexer-alt-graphql/src/api/types/transaction_kind/programmable/inputs/balance_withdraw.rs (Rust)

Code before:
    FundsWithdrawalArg as NativeFundsWithdrawalArg, Reservation as NativeReservation,
    WithdrawFrom as NativeWithdrawFrom,
};

use crate::{api::scalars::uint53::UInt53, api::types::move_type::MoveType, scope::Scope};

/// Input for withdrawing funds from an accumulator.
#[derive(SimpleObject, Clone)]
pub struct BalanceWithdraw {
    pub reservation: Option<WithdrawalReservation>,

    /// The type of the funds accumulator to withdraw from (e.g. `0x2::balance::Balance<0x2::sui::SUI>`).
    pub type_arg: Option<MoveType>,

    pub withdraw_from: Option<WithdrawFrom>,
}

/// Reservation details for a withdrawal.
#[derive(Union, Clone)]
pub enum WithdrawalReservation {
    EntireBalance(EntireBalance),
    MaxAmountU64(MaxAmountU64),
}

#[derive(SimpleObject, Clone)]
pub struct EntireBalance {
    /// Placeholder field.
    #[graphql(name = "_")]
    pub dummy: Option<bool>,
}

#[derive(SimpleObject, Clone)]
pub struct MaxAmountU64 {
    pub amount: Option<UInt53>,
}

#[derive(Enum, Copy, Clone, Eq, PartialEq)]
pub enum WithdrawFrom {
    Sender,
    Sponsor,
}

impl BalanceWithdraw {
    pub fn from_native(withdrawal: NativeFundsWithdrawalArg, scope: Scope) -> Self {
        let NativeFundsWithdrawalArg {
            reservation,
            type_arg,
            withdraw_from,
        } = withdrawal;

        let reservation = Some(match reservation {

Review comment (suggestion):
```suggestion
pub struct WithdrawEntireBalance {
```

Code after:
use move_core_types::account_address::AccountAddress;
use sui_types::transaction::FundsWithdrawalArg as NativeFundsWithdrawalArg;
use sui_types::transaction::Reservation as NativeReservation;
use sui_types::transaction::WithdrawFrom as NativeWithdrawFrom;
use sui_types::transaction::WithdrawalTypeArg as NativeWithdrawalTypeArg;
use sui_types::type_input::StructInput;
use sui_types::type_input::TypeInput;

use crate::api::scalars::big_int::BigInt;
use crate::api::types::move_type::MoveType;
use crate::scope::Scope;

/// Input for withdrawing funds from an accumulator.
#[derive(SimpleObject, Clone)]
pub struct BalanceWithdraw {
    /// How much to withdraw from the accumulator.
    pub reservation: Option<WithdrawalReservation>,

    /// The type of the funds accumulator to withdraw from (e.g. `0x2::balance::Balance<0x2::sui::SUI>`).
    #[graphql(name = "type")]
    pub type_: Option<MoveType>,

    /// The account to withdraw funds from.
    pub withdraw_from: Option<WithdrawFrom>,
}

/// Reservation details for a withdrawal.
#[derive(Union, Clone)]
pub enum WithdrawalReservation {
    MaxAmountU64(WithdrawMaxAmountU64),
}

#[derive(SimpleObject, Clone)]
pub struct WithdrawMaxAmountU64 {
    pub amount: Option<BigInt>,
}

/// The account to withdraw funds from.
#[derive(Enum, Copy, Clone, Eq, PartialEq)]
pub enum WithdrawFrom {
    /// The funds are withdrawn from the transaction sender's account.
    Sender,
    /// The funds are withdrawn from the sponsor's account.
    Sponsor,
}

impl BalanceWithdraw {
    pub fn from_native(withdrawal: NativeFundsWithdrawalArg, scope: Scope) -> Self {
        let NativeFundsWithdrawalArg {
            reservation,
            type_arg,