use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct AccountList {
pub stake_address: String,
pub stake_address_hex: String,
#[serde(skip_serializing_if = "Option::is_none")]
pub script_hash: Option<String>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct AccountInfo {
pub stake_address: String,
pub status: AccountStatus,
#[serde(skip_serializing_if = "Option::is_none")]
pub delegated_drep: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub delegated_pool: Option<String>,
pub total_balance: String,
pub utxo: String,
pub rewards: String,
pub withdrawals: String,
pub rewards_available: String,
pub deposit: String,
pub reserves: String,
pub treasury: String,
}
#[derive(Debug, Clone, Copy, Serialize, Deserialize, PartialEq)]
#[serde(rename_all = "snake_case")]
pub enum AccountStatus {
Registered,
NotRegistered,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct AccountRewards {
pub stake_address: String,
pub rewards: Vec<RewardInfo>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct RewardInfo {
pub earned_epoch: u64,
pub spendable_epoch: u64,
pub amount: String,
#[serde(rename = "type")]
pub reward_type: RewardType,
pub pool_id: Option<String>,
}
#[derive(Debug, Clone, Serialize, Deserialize, Copy, PartialEq)]
#[serde(rename_all = "lowercase")]
pub enum RewardType {
Member,
Leader,
Treasury,
Reserves,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct AccountUpdates {
pub stake_address: String,
pub updates: Vec<AccountUpdate>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct AccountUpdate {
pub action_type: AccountActionType,
pub tx_hash: String,
pub epoch_no: u64,
pub epoch_slot: u64,
pub absolute_slot: u64,
pub block_time: u64,
}
#[derive(Debug, Clone, Serialize, Deserialize, Copy, PartialEq)]
#[serde(rename_all = "lowercase")]
pub enum AccountActionType {
Registration,
Delegation,
Withdrawal,
Deregistration,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct AccountAddresses {
pub stake_address: String,
pub addresses: Vec<String>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct AccountAssets {
pub stake_address: String,
pub policy_id: String,
pub asset_name: String,
pub fingerprint: String,
#[serde(skip_serializing_if = "Option::is_none")]
pub decimals: Option<u64>,
pub quantity: String,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct AccountHistory {
pub stake_address: String,
pub history: Vec<AccountHistoryEntry>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct AccountHistoryEntry {
pub pool_id: String,
pub epoch_no: u64,
pub active_stake: String,
}
impl AccountInfo {
pub fn new(
stake_address: String,
status: AccountStatus,
total_balance: String,
utxo: String,
rewards: String,
withdrawals: String,
rewards_available: String,
deposit: String,
reserves: String,
treasury: String,
) -> Self {
Self {
stake_address,
status,
delegated_drep: None,
delegated_pool: None,
total_balance,
utxo,
rewards,
withdrawals,
rewards_available,
deposit,
reserves,
treasury,
}
}
}