use crate::objects::currency_amount::CurrencyAmount;
use crate::objects::entity::Entity;
use crate::objects::on_chain_transaction::OnChainTransaction;
use crate::objects::transaction::Transaction;
use crate::objects::transaction_status::TransactionStatus;
use crate::types::custom_date_formats::custom_date_format;
use crate::types::custom_date_formats::custom_date_format_option;
use crate::types::entity_wrapper::EntityWrapper;
use crate::types::get_entity::GetEntity;
use chrono::{DateTime, Utc};
use serde::Deserialize;
use std::vec::Vec;
#[derive(Clone, Deserialize)]
pub struct ChannelClosingTransaction {
#[serde(rename = "channel_closing_transaction_id")]
pub id: String,
#[serde(
with = "custom_date_format",
rename = "channel_closing_transaction_created_at"
)]
pub created_at: DateTime<Utc>,
#[serde(
with = "custom_date_format",
rename = "channel_closing_transaction_updated_at"
)]
pub updated_at: DateTime<Utc>,
#[serde(rename = "channel_closing_transaction_status")]
pub status: TransactionStatus,
#[serde(
with = "custom_date_format_option",
rename = "channel_closing_transaction_resolved_at"
)]
pub resolved_at: Option<DateTime<Utc>>,
#[serde(rename = "channel_closing_transaction_amount")]
pub amount: CurrencyAmount,
#[serde(rename = "channel_closing_transaction_transaction_hash")]
pub transaction_hash: Option<String>,
#[serde(rename = "channel_closing_transaction_fees")]
pub fees: Option<CurrencyAmount>,
#[serde(rename = "channel_closing_transaction_block_hash")]
pub block_hash: Option<String>,
#[serde(rename = "channel_closing_transaction_block_height")]
pub block_height: i64,
#[serde(rename = "channel_closing_transaction_destination_addresses")]
pub destination_addresses: Vec<String>,
#[serde(rename = "channel_closing_transaction_num_confirmations")]
pub num_confirmations: Option<i64>,
#[serde(rename = "channel_closing_transaction_channel")]
pub channel: Option<EntityWrapper>,
}
impl OnChainTransaction for ChannelClosingTransaction {
fn get_fees(&self) -> Option<CurrencyAmount> {
self.fees.clone()
}
fn get_block_hash(&self) -> Option<String> {
self.block_hash.clone()
}
fn get_block_height(&self) -> i64 {
self.block_height
}
fn get_destination_addresses(&self) -> Vec<String> {
self.destination_addresses.clone()
}
fn get_num_confirmations(&self) -> Option<i64> {
self.num_confirmations
}
fn type_name(&self) -> &'static str {
"ChannelClosingTransaction"
}
}
impl Transaction for ChannelClosingTransaction {
fn get_status(&self) -> TransactionStatus {
self.status.clone()
}
fn get_resolved_at(&self) -> Option<DateTime<Utc>> {
self.resolved_at
}
fn get_amount(&self) -> CurrencyAmount {
self.amount.clone()
}
fn get_transaction_hash(&self) -> Option<String> {
self.transaction_hash.clone()
}
fn type_name(&self) -> &'static str {
"ChannelClosingTransaction"
}
}
impl Entity for ChannelClosingTransaction {
fn get_id(&self) -> String {
self.id.clone()
}
fn get_created_at(&self) -> DateTime<Utc> {
self.created_at
}
fn get_updated_at(&self) -> DateTime<Utc> {
self.updated_at
}
fn type_name(&self) -> &'static str {
"ChannelClosingTransaction"
}
}
impl GetEntity for ChannelClosingTransaction {
fn get_entity_query() -> String {
format!(
"
query GetEntity($id: ID!) {{
entity(id: $id) {{
... on ChannelClosingTransaction {{
... ChannelClosingTransactionFragment
}}
}}
}}
{}",
FRAGMENT
)
}
}
pub const FRAGMENT: &str = "
fragment ChannelClosingTransactionFragment on ChannelClosingTransaction {
__typename
channel_closing_transaction_id: id
channel_closing_transaction_created_at: created_at
channel_closing_transaction_updated_at: updated_at
channel_closing_transaction_status: status
channel_closing_transaction_resolved_at: resolved_at
channel_closing_transaction_amount: amount {
__typename
currency_amount_original_value: original_value
currency_amount_original_unit: original_unit
currency_amount_preferred_currency_unit: preferred_currency_unit
currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
}
channel_closing_transaction_transaction_hash: transaction_hash
channel_closing_transaction_fees: fees {
__typename
currency_amount_original_value: original_value
currency_amount_original_unit: original_unit
currency_amount_preferred_currency_unit: preferred_currency_unit
currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
}
channel_closing_transaction_block_hash: block_hash
channel_closing_transaction_block_height: block_height
channel_closing_transaction_destination_addresses: destination_addresses
channel_closing_transaction_num_confirmations: num_confirmations
channel_closing_transaction_channel: channel {
id
}
}
";