https://github.com/dougefresh/fireblocks-sdk-rs
https://github.com/dougefresh/fireblocks-sdk-rs
Last synced: 7 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/dougefresh/fireblocks-sdk-rs
- Owner: dougEfresh
- License: mit
- Created: 2024-02-20T18:26:49.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-09-30T13:54:39.000Z (8 months ago)
- Last Synced: 2024-11-18T18:07:24.575Z (6 months ago)
- Language: Rust
- Size: 147 KB
- Stars: 2
- Watchers: 3
- Forks: 1
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Support: SUPPORTED_ENDPOINTS.md
Awesome Lists containing this project
README
# Overview
`fireblocks_sdk` is an async library for the Fireblocks [API](https://docs.fireblocks.com/api/swagger-ui/#)
!!!! Note this is community driven project and not affiliated with [Fireblocks](https://fireblocks.io) !!!!!
# Getting Started
```shell
cargo install fireblocks-sdk
```See developer [portal](https://developers.fireblocks.com/docs/introduction) and sign up for a [sandbox](https://developers.fireblocks.com/docs/sandbox-quickstart) account
# Quick Start
```rust
use {
fireblocks_sdk::{
apis::vaults_api::{GetPagedVaultAccountsParams, GetVaultAccountParams},
ClientBuilder,
},
std::{fs::File, io::Read, time::Duration},
};fn load_secret() -> anyhow::Result> {
match std::env::var("FIREBLOCKS_SECRET").ok() {
Some(secret) => Ok(secret.into_bytes()),
None => {
let secret = std::env::var("FIREBLOCKS_SECRET_FILE")
.expect("failed find secret key in FIREBLOCKS_SECRET or FIREBLOCKS_SECRET_FILE");
let mut file = File::open(secret).expect("file not found");
let mut secret: String = String::new();
file.read_to_string(&mut secret)
.expect("something went wrong reading the file");
Ok(secret.into_bytes())
}
}
}#[tokio::main]
async fn main() -> anyhow::Result<()> {
let api_key = std::env::var("FIREBLOCKS_API_KEY")?;
let secret = load_secret()?;
let client = ClientBuilder::new(&api_key, &secret)
.with_sandbox()
.with_timeout(Duration::from_secs(10))
.with_connect_timeout(Duration::from_secs(5))
.build()?;let id = String::from("0");
let params = GetVaultAccountParams {
vault_account_id: id.clone(),
};
let vault_account = client.vaults_api().get_vault_account(params).await?;
println!("vault account: {vault_account:#?}");let params = GetPagedVaultAccountsParams::builder().limit(50.0).build();
let vault_accounts = client.vaults_api().get_paged_vault_accounts(params).await?;
println!("vault accounts: {:#?}", vault_accounts);
Ok(())
}
```# APIs
The [fireblocks_sdk::Client](./struct.Client.html) is a small wrapper to the auto-generate [fireblocks_sdk::apis::ApiClient](./apis/struct.ApiClient.html) using openapi generator.
```rust
use crate::fireblocks_sdk::apis::Api;
use fireblocks_sdk::Client;fn demo(client: Client) {
// Access to generated API client
let api_client = client.apis();
// External Wallet Api (whitlisted)
let external_wallet_api = api_client.whitelisted_external_wallets_api();
}
```## Bon builder
Parameters to [APIs](fireblocks_sdk::apis::ApiClient) use [bon](https://crates.io/crates/bon) to all API endpoints (both query and body)
## Caveats
The openapi-generator decided that all integers are floats. Annoying yes, but it is what it is.
# Development
Create a .env file
```shell
cp .env-sameple .env
```Edit .env and configure your API and secret key in FIREBLOCKS_SECRET or FIREBLOCKS_SECRET_FILE. You also need to create some whitlisted (see [tests/wallets.rs](./tests/wallets.rs) for details)
Run tests:
```shell
cargo test
```Run a single test:
```shell
cargo test --test wallets
```---
# Docs
Code was generatered by Fireblocks openapi [spec](https://raw.githubusercontent.com/fireblocks/fireblocks-openapi-spec/refs/heads/main/api-spec-v2.yaml) using [openapi-generator](./Makefile) with this [config](./generator/config.yaml)
See [docs](./docs/README.md)