Skip to content

Commit

Permalink
fix: cleanup a bit
Browse files Browse the repository at this point in the history
  • Loading branch information
IroncladDev committed Jun 20, 2024
1 parent bef9150 commit 662e0d5
Show file tree
Hide file tree
Showing 21 changed files with 608 additions and 635 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion wrappers/fedimint_clientd_rs/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "fedimint_clientd_rs"
version = "0.0.1"
version = "0.0.2"
edition = "2021"
description = "Rust client for hitting the REST endpoints on a fedimint clientd"
repository = "https://github.com/fedimint/fedimint-clientd"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
use serde_json::Value;
pub mod types;

use crate::{
options::JoinOptions,
types::{
DiscoverVersionRequest, DiscoverVersionResponse, FederationIdsResponse, InfoResponse,
JoinRequest, JoinResponse, ListOperationsRequest, ListOperationsResponse,
},
FedimintClient,
};
use crate::FedimintClient;
use serde_json::Value;
pub use types::*;

impl FedimintClient {
/// Returns info about each joined federation
Expand Down Expand Up @@ -65,7 +60,7 @@ impl FedimintClient {
Ok(res) => {
if options.set_active_federation_id {
let _ = self
.set_active_federation_id(
.switch_federation_id(
res.clone().this_federation_id,
options.use_default_gateway,
)
Expand Down
80 changes: 80 additions & 0 deletions wrappers/fedimint_clientd_rs/src/client/admin/types.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
#![allow(non_snake_case)]

use serde::{Deserialize, Serialize};
use serde_json::Value;
use std::collections::HashMap;

use crate::client::types::{FederationInfo, OperationOutput};

#[derive(Debug, Clone, Eq, PartialEq, Serialize, Deserialize)]
pub struct ListOperationsRequest {
pub limit: u64,
pub federationId: String,
}

#[derive(Debug, Clone, Eq, PartialEq, Serialize, Deserialize)]
pub struct JoinRequest {
pub inviteCode: String,
pub useManualSecret: bool,
}

#[derive(Debug, Clone, Eq, PartialEq, Serialize, Deserialize)]
pub struct DiscoverVersionRequest {
pub threshold: usize,
}

pub type InfoResponse = HashMap<String, FederationInfo>;

pub type DiscoverVersionResponse = HashMap<String, Value>;

#[derive(Debug, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct ListOperationsResponse {
pub operations: Vec<OperationOutput>,
}

#[derive(Debug, Clone, Eq, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct FederationIdsResponse {
pub federation_ids: Vec<String>,
}

#[derive(Debug, Clone, Eq, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct JoinResponse {
pub this_federation_id: String,
pub federation_ids: Vec<String>,
}

pub struct JoinOptions {
pub invite_code: String,
pub use_default_gateway: bool,
pub set_active_federation_id: bool,
pub use_manual_secret: bool,
}

impl JoinOptions {
pub fn new(invite_code: String) -> Self {
JoinOptions {
invite_code,
set_active_federation_id: false,
use_default_gateway: false,
use_manual_secret: false,
}
}

pub fn set_active_federation_id(mut self) -> Self {
self.set_active_federation_id = true;
self
}

pub fn use_default_gateway(mut self) -> Self {
self.use_default_gateway = true;
self
}

pub fn use_manual_secret(mut self) -> Self {
self.use_manual_secret = true;
self
}
}
89 changes: 0 additions & 89 deletions wrappers/fedimint_clientd_rs/src/client/base.rs

This file was deleted.

76 changes: 0 additions & 76 deletions wrappers/fedimint_clientd_rs/src/client/http.rs

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
use crate::{
options::{InvoiceOptions, PayOptions, TweakedInvoiceOptions},
types::{
AwaitInvoiceRequest, AwaitInvoiceResponse, ClaimPubkeyTweakRequest, CreateInvoiceRequest,
CreateInvoiceResponse, CreateTweakedInvoiceRequest, Gateway, LightningPayRequest,
LightningPayResponse, LightningPaymentResponse, ListGatewaysRequest,
},
FedimintClient,
};
pub mod types;

use super::types::Gateway;
use crate::FedimintClient;
pub use types::*;

impl FedimintClient {
pub async fn create_invoice(
Expand Down
Loading

0 comments on commit 662e0d5

Please sign in to comment.