fireblocks_sdk/
lib.rs

1#![doc = include_str!("../README.md")]
2use {
3    chrono::{DateTime, Utc},
4    std::fmt::Display,
5};
6mod assets;
7mod client;
8pub mod error;
9mod transaction_status;
10use serde::de::DeserializeOwned;
11pub use transaction_status::TransactionStatus;
12pub(crate) mod jwt;
13mod log;
14#[cfg(feature = "page")]
15mod paged_client;
16mod wallet;
17#[cfg(feature = "page")]
18pub use paged_client::{PagedClient, TransactionStream, VaultStream};
19pub use {
20    crate::error::*,
21    apis::{
22        ApiClient,
23        configuration::{ApiKey, Configuration},
24    },
25    assets::{
26        ASSET_BTC,
27        ASSET_BTC_TEST,
28        ASSET_DOGE,
29        ASSET_DOGE_TEST,
30        ASSET_ETH,
31        ASSET_ETH_TEST,
32        ASSET_SOL,
33        ASSET_SOL_TEST,
34        Asset,
35    },
36    client::{Client, ClientBuilder},
37    wallet::WalletContainer,
38};
39
40pub const FIREBLOCKS_API: &str = "https://api.fireblocks.io/v1";
41pub const FIREBLOCKS_SANDBOX_API: &str = "https://sandbox-api.fireblocks.io/v1";
42pub type Epoch = DateTime<Utc>;
43pub type Result<T> = std::result::Result<T, FireblocksError>;
44pub type QueryParams = Vec<(String, String)>;
45
46#[derive(Debug, Clone, Copy)]
47pub enum WalletType {
48    Internal,
49    External,
50    Contract,
51}
52
53impl Display for WalletType {
54    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
55        write!(f, "{}", match &self {
56            Self::Internal => "Internal",
57            Self::External => "External",
58            Self::Contract => "Contract",
59        })
60    }
61}
62
63#[allow(clippy::all, clippy::pedantic, clippy::nursery)]
64pub mod apis;
65#[allow(clippy::all, clippy::pedantic, clippy::nursery)]
66pub mod models;
67
68pub(crate) fn deserialize_wrapper<T: DeserializeOwned>(content: &str) -> serde_json::Result<T> {
69    match serde_json::from_str(content) {
70        Ok(value) => Ok(value),
71        Err(err) => {
72            tracing::error!("Failed to decode: {err}\n{content}");
73            Err(err)
74        }
75    }
76}