use std::{error::Error, time::Duration};
pub use hopr_types::{
chain::ContractAddresses, internal::prelude::WinningProbability, primitive::balance::HoprBalance,
};
use hopr_types::{
crypto::prelude::Hash,
primitive::{
balance::{Balance, Currency},
prelude::Address,
},
};
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct DomainSeparators {
pub ledger: Hash,
pub safe_registry: Hash,
pub channel: Hash,
}
#[derive(Clone, Debug, PartialEq, Eq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct ChainInfo {
pub chain_id: u64,
pub hopr_network_name: String,
pub contract_addresses: ContractAddresses,
}
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct RedemptionStats {
pub redeemed_count: u64,
pub redeemed_value: HoprBalance,
}
#[async_trait::async_trait]
#[auto_impl::auto_impl(&, Box, Arc)]
pub trait ChainValues {
type Error: Error + Send + Sync + 'static;
async fn balance<C: Currency, A: Into<Address> + Send>(&self, address: A) -> Result<Balance<C>, Self::Error>;
async fn domain_separators(&self) -> Result<DomainSeparators, Self::Error>;
async fn minimum_incoming_ticket_win_prob(&self) -> Result<WinningProbability, Self::Error>;
async fn minimum_ticket_price(&self) -> Result<HoprBalance, Self::Error>;
async fn key_binding_fee(&self) -> Result<HoprBalance, Self::Error>;
async fn channel_closure_notice_period(&self) -> Result<Duration, Self::Error>;
async fn chain_info(&self) -> Result<ChainInfo, Self::Error>;
async fn redemption_stats<A: Into<Address> + Send>(&self, safe_addr: A) -> Result<RedemptionStats, Self::Error>;
async fn typical_resolution_time(&self) -> Result<Duration, Self::Error>;
}