Skip to content

Commit

Permalink
Regenerate Rust SDK and bump version (#46)
Browse files Browse the repository at this point in the history
  • Loading branch information
zhenlu authored Jun 5, 2024
1 parent b2d5c30 commit ab0670c
Show file tree
Hide file tree
Showing 71 changed files with 1,151 additions and 199 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ resolver = "2"
members = [
"lightspark",
"lightspark-remote-signing",
"examples/*",
"examples/lightspark-remote-signing-server",
]
3 changes: 3 additions & 0 deletions lightspark/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Changelog

# v0.9.0
- Update API objects.

# v0.8.1
- Remove openssl dependency from reqwest.

Expand Down
2 changes: 1 addition & 1 deletion lightspark/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name = "lightspark"
description = "Lightspark Rust SDK"
authors = ["Lightspark Group, Inc. <[email protected]>"]
version = "0.8.2"
version = "0.9.0"
edition = "2021"
documentation = "https://docs.lightspark.com/lightspark-sdk/getting-started?language=Rust"
homepage = "https://www.lightspark.com/"
Expand Down
4 changes: 2 additions & 2 deletions lightspark/README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Lightspark Rust SDK - v0.8.2
# Lightspark Rust SDK - v0.9.0

The Lightspark Rust SDK provides a convenient way to interact with the Lightspark services from applications written in the Rust language.

***WARNING: This SDK is in version 0.8.1 (active development). It means that its APIs may not be fully stable. Please expect that changes to the APIs may happen until we move to v1.0.0.***
***WARNING: This SDK is in version 0.9.0 (active development). It means that its APIs may not be fully stable. Please expect that changes to the APIs may happen until we move to v1.0.0.***

## Documentation

Expand Down
2 changes: 1 addition & 1 deletion lightspark/examples/example.rs
Original file line number Diff line number Diff line change
Expand Up @@ -557,7 +557,7 @@ async fn main() {
}
};
if let Ok(channels_connection) = node
.get_channels(&client.requester, Some(10), None, None)
.get_channels(&client.requester, Some(10), None, None, None, None)
.await
{
println!(
Expand Down
2 changes: 1 addition & 1 deletion lightspark/examples/two_node_example.rs
Original file line number Diff line number Diff line change
Expand Up @@ -527,7 +527,7 @@ async fn main() {
}
};
if let Ok(channels_connection) = node
.get_channels(&client.requester, Some(10), None, None)
.get_channels(&client.requester, Some(10), None, None, None, None)
.await
{
println!("{} has {} channel(s):", node_1, channels_connection.count);
Expand Down
21 changes: 19 additions & 2 deletions lightspark/src/objects/account.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ impl Account {
api_token_client_id: client_id
api_token_name: name
api_token_permissions: permissions
api_token_is_deleted: is_deleted
}
}
}
Expand Down Expand Up @@ -958,6 +959,7 @@ impl Account {
currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
}
incoming_payment_transaction_hash: transaction_hash
incoming_payment_is_uma: is_uma
incoming_payment_destination: destination {
id
}
Expand All @@ -976,6 +978,7 @@ impl Account {
currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
}
}
incoming_payment_is_internal_payment: is_internal_payment
}
... on OutgoingPayment {
__typename
Expand All @@ -993,6 +996,7 @@ impl Account {
currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
}
outgoing_payment_transaction_hash: transaction_hash
outgoing_payment_is_uma: is_uma
outgoing_payment_origin: origin {
id
}
Expand Down Expand Up @@ -1319,6 +1323,8 @@ impl Account {
}
}
outgoing_payment_payment_preimage: payment_preimage
outgoing_payment_is_internal_payment: is_internal_payment
outgoing_payment_idempotency_key: idempotency_key
}
... on RoutingTransaction {
__typename
Expand Down Expand Up @@ -1777,13 +1783,14 @@ impl Account {
bitcoin_networks: Option<Vec<BitcoinNetwork>>,
statuses: Option<Vec<WithdrawalRequestStatus>>,
node_ids: Option<Vec<String>>,
idempotency_keys: Option<Vec<String>>,
after_date: Option<DateTime<Utc>>,
before_date: Option<DateTime<Utc>>,
) -> Result<AccountToWithdrawalRequestsConnection, Error> {
let query = "query FetchAccountToWithdrawalRequestsConnection($entity_id: ID!, $first: Int, $after: String, $bitcoin_networks: [BitcoinNetwork!], $statuses: [WithdrawalRequestStatus!], $node_ids: [ID!], $after_date: DateTime, $before_date: DateTime) {
let query = "query FetchAccountToWithdrawalRequestsConnection($entity_id: ID!, $first: Int, $after: String, $bitcoin_networks: [BitcoinNetwork!], $statuses: [WithdrawalRequestStatus!], $node_ids: [ID!], $idempotency_keys: [String!], $after_date: DateTime, $before_date: DateTime) {
entity(id: $entity_id) {
... on Account {
withdrawal_requests(, first: $first, after: $after, bitcoin_networks: $bitcoin_networks, statuses: $statuses, node_ids: $node_ids, after_date: $after_date, before_date: $before_date) {
withdrawal_requests(, first: $first, after: $after, bitcoin_networks: $bitcoin_networks, statuses: $statuses, node_ids: $node_ids, idempotency_keys: $idempotency_keys, after_date: $after_date, before_date: $before_date) {
__typename
account_to_withdrawal_requests_connection_count: count
account_to_withdrawal_requests_connection_page_info: page_info {
Expand Down Expand Up @@ -1830,13 +1837,22 @@ impl Account {
currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
}
withdrawal_request_total_fees: total_fees {
__typename
currency_amount_original_value: original_value
currency_amount_original_unit: original_unit
currency_amount_preferred_currency_unit: preferred_currency_unit
currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
}
withdrawal_request_bitcoin_address: bitcoin_address
withdrawal_request_withdrawal_mode: withdrawal_mode
withdrawal_request_status: status
withdrawal_request_completed_at: completed_at
withdrawal_request_withdrawal: withdrawal {
id
}
withdrawal_request_idempotency_key: idempotency_key
}
}
}
Expand All @@ -1849,6 +1865,7 @@ impl Account {
variables.insert("bitcoin_networks", bitcoin_networks.into());
variables.insert("statuses", statuses.into());
variables.insert("node_ids", node_ids.into());
variables.insert("idempotency_keys", idempotency_keys.into());
variables.insert("after_date", after_date.map(|dt| dt.to_rfc3339()).into());
variables.insert("before_date", before_date.map(|dt| dt.to_rfc3339()).into());

Expand Down
1 change: 1 addition & 0 deletions lightspark/src/objects/account_to_nodes_connection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use crate::objects::connection::Connection;
use crate::objects::lightspark_node::LightsparkNodeEnum;
use crate::objects::page_info::PageInfo;
use serde::{Deserialize, Serialize};

use std::vec::Vec;

/// A connection between an account and the nodes it manages.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
// Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
use crate::objects::payment_request::PaymentRequestEnum;
use serde::{Deserialize, Serialize};
use std::vec::Vec;

use crate::objects::connection::Connection;
use crate::objects::page_info::PageInfo;
use crate::objects::payment_request::PaymentRequestEnum;
use std::vec::Vec;

#[derive(Debug, Clone, Deserialize, Serialize)]
pub struct AccountToPaymentRequestsConnection {
Expand Down
4 changes: 2 additions & 2 deletions lightspark/src/objects/account_to_transactions_connection.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
// Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
use crate::objects::transaction::TransactionEnum;
use serde::{Deserialize, Serialize};
use std::vec::Vec;

use crate::objects::connection::Connection;
use crate::objects::currency_amount::CurrencyAmount;
use crate::objects::page_info::PageInfo;
use crate::objects::transaction::TransactionEnum;
use std::vec::Vec;

#[derive(Debug, Clone, Deserialize, Serialize)]
pub struct AccountToTransactionsConnection {
Expand Down
12 changes: 12 additions & 0 deletions lightspark/src/objects/api_token.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
use crate::objects::audit_log_actor::AuditLogActor;
use crate::objects::entity::Entity;
use crate::objects::permission::Permission;
use crate::types::custom_date_formats::custom_date_format;
Expand Down Expand Up @@ -34,11 +35,21 @@ pub struct ApiToken {
#[serde(rename = "api_token_permissions")]
pub permissions: Vec<Permission>,

/// Whether the api token has been deleted.
#[serde(rename = "api_token_is_deleted")]
pub is_deleted: bool,

/// The typename of the object
#[serde(rename = "__typename")]
pub typename: String,
}

impl AuditLogActor for ApiToken {
fn type_name(&self) -> &'static str {
"ApiToken"
}
}

impl Entity for ApiToken {
/// The unique identifier of this entity across all Lightspark systems. Should be treated as an opaque string.
fn get_id(&self) -> String {
Expand Down Expand Up @@ -87,5 +98,6 @@ fragment ApiTokenFragment on ApiToken {
api_token_client_id: client_id
api_token_name: name
api_token_permissions: permissions
api_token_is_deleted: is_deleted
}
";
40 changes: 40 additions & 0 deletions lightspark/src/objects/audit_log_actor.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
// Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
use super::api_token::ApiToken;
use crate::objects::entity::Entity;
use serde::{Deserialize, Deserializer, Serialize};
use serde_json::Value;

pub trait AuditLogActor: Entity {
fn type_name(&self) -> &'static str;
}

#[allow(clippy::large_enum_variant)]
#[derive(Debug, Clone, Serialize)]
pub enum AuditLogActorEnum {
ApiToken(ApiToken),
}

impl<'de> Deserialize<'de> for AuditLogActorEnum {
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where
D: Deserializer<'de>,
{
let value = Value::deserialize(deserializer)?;
if let Some(typename) = value.get("__typename").and_then(Value::as_str) {
match typename {
"ApiToken" => {
let obj = ApiToken::deserialize(value).map_err(|err| {
serde::de::Error::custom(format!("Serde JSON Error {}", err))
})?;
Ok(AuditLogActorEnum::ApiToken(obj))
}

_ => Err(serde::de::Error::custom("unknown typename")),
}
} else {
Err(serde::de::Error::custom(
"missing __typename field on AuditLogActor",
))
}
}
}
1 change: 1 addition & 0 deletions lightspark/src/objects/cancel_invoice_input.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
use serde::{Deserialize, Serialize};

/// The unique identifier of the Invoice that should be cancelled. The invoice is supposed to be open, not settled and not expired.
#[derive(Debug, Clone, Deserialize, Serialize)]
pub struct CancelInvoiceInput {
pub invoice_id: String,
Expand Down
1 change: 1 addition & 0 deletions lightspark/src/objects/cancel_invoice_output.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
use crate::types::entity_wrapper::EntityWrapper;
use serde::{Deserialize, Serialize};

/// The Invoice that was cancelled. If the invoice was already cancelled, the same invoice is returned.
#[derive(Debug, Clone, Deserialize, Serialize)]
pub struct CancelInvoiceOutput {
#[serde(rename = "cancel_invoice_output_invoice")]
Expand Down
4 changes: 2 additions & 2 deletions lightspark/src/objects/channel_closing_transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ pub struct ChannelClosingTransaction {
#[serde(rename = "channel_closing_transaction_transaction_hash")]
pub transaction_hash: Option<String>,

/// The fees that were paid by the wallet sending the transaction to commit it to the Bitcoin blockchain.
/// The fees that were paid by the node for this transaction.
#[serde(rename = "channel_closing_transaction_fees")]
pub fees: Option<CurrencyAmount>,

Expand Down Expand Up @@ -82,7 +82,7 @@ pub struct ChannelClosingTransaction {
}

impl OnChainTransaction for ChannelClosingTransaction {
/// The fees that were paid by the wallet sending the transaction to commit it to the Bitcoin blockchain.
/// The fees that were paid by the node for this transaction.
fn get_fees(&self) -> Option<CurrencyAmount> {
self.fees.clone()
}
Expand Down
4 changes: 2 additions & 2 deletions lightspark/src/objects/channel_opening_transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ pub struct ChannelOpeningTransaction {
#[serde(rename = "channel_opening_transaction_transaction_hash")]
pub transaction_hash: Option<String>,

/// The fees that were paid by the wallet sending the transaction to commit it to the Bitcoin blockchain.
/// The fees that were paid by the node for this transaction.
#[serde(rename = "channel_opening_transaction_fees")]
pub fees: Option<CurrencyAmount>,

Expand Down Expand Up @@ -82,7 +82,7 @@ pub struct ChannelOpeningTransaction {
}

impl OnChainTransaction for ChannelOpeningTransaction {
/// The fees that were paid by the wallet sending the transaction to commit it to the Bitcoin blockchain.
/// The fees that were paid by the node for this transaction.
fn get_fees(&self) -> Option<CurrencyAmount> {
self.fees.clone()
}
Expand Down
Loading

0 comments on commit ab0670c

Please sign in to comment.