sui_jsonrpc/msgs/
balance_changes.rs

1// Copyright (c) Mysten Labs, Inc.
2// SPDX-License-Identifier: Apache-2.0
3
4use std::fmt::Display;
5
6use af_sui_types::TypeTag;
7use af_sui_types::sui::object::Owner;
8use serde::{Deserialize, Serialize};
9use serde_with::{DisplayFromStr, serde_as};
10
11#[serde_as]
12#[derive(Debug, Clone, Deserialize, Serialize, PartialEq, Eq)]
13#[serde(rename_all = "camelCase")]
14pub struct BalanceChange {
15    /// Owner of the balance change
16    pub owner: Owner,
17    // #[serde_as(as = "SuiTypeTag")]
18    #[serde_as(as = "DisplayFromStr")]
19    pub coin_type: TypeTag,
20    /// The amount indicate the balance value changes,
21    /// negative amount means spending coin value and positive means receiving coin value.
22    #[serde_as(as = "DisplayFromStr")]
23    pub amount: i128,
24}
25
26impl Display for BalanceChange {
27    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
28        write!(
29            f,
30            " ┌──\n │ Owner: {} \n │ CoinType: {} \n │ Amount: {}\n └──",
31            self.owner, self.coin_type, self.amount
32        )
33    }
34}