hopr_api/chain/
values.rs

1use std::{error::Error, time::Duration};
2
3pub use hopr_chain_types::ContractAddresses;
4use hopr_crypto_types::prelude::Hash;
5pub use hopr_internal_types::prelude::WinningProbability;
6pub use hopr_primitive_types::balance::HoprBalance;
7
8/// Contains domain separator information.
9#[derive(Clone, Copy, Debug, PartialEq, Eq)]
10pub struct DomainSeparators {
11    /// HOPR Ledger smart contract domain separator.
12    pub ledger: Hash,
13    /// HOPR Node Safe Registry smart contract domain separator.
14    pub safe_registry: Hash,
15    /// HOPR Channels smart contract domain separator.
16    pub channel: Hash,
17}
18
19/// Contains information about the HOPR on-chain network deployment.
20#[derive(Clone, Debug, PartialEq, Eq)]
21pub struct ChainInfo {
22    /// ID of the blockchain network (e.g.: `0x64` for Gnosis Chain)
23    pub chain_id: u64,
24    /// Name of the HOPR network (e.g.: `dufour`)
25    pub hopr_network_name: String,
26    /// Addresses of the deployed HOPR smart contracts.
27    pub contract_addresses: ContractAddresses,
28}
29
30/// Retrieves various on-chain information.
31#[async_trait::async_trait]
32#[auto_impl::auto_impl(&, Box, Arc)]
33pub trait ChainValues {
34    type Error: Error + Send + Sync + 'static;
35    /// Retrieves the domain separators of HOPR smart contracts.
36    async fn domain_separators(&self) -> Result<DomainSeparators, Self::Error>;
37    /// Retrieves the network-set minimum incoming ticket winning probability.
38    async fn minimum_incoming_ticket_win_prob(&self) -> Result<WinningProbability, Self::Error>;
39    /// Retrieves the network-set minimum ticket price.
40    async fn minimum_ticket_price(&self) -> Result<HoprBalance, Self::Error>;
41    /// Gets the grace period for channel closure finalization.
42    async fn channel_closure_notice_period(&self) -> Result<Duration, Self::Error>;
43    /// Gets the information about the HOPR network on-chain deployment.
44    async fn chain_info(&self) -> Result<ChainInfo, Self::Error>;
45}