Skip to content

Commit

Permalink
Regenerating SDKs following introspection of schemas. (#57)
Browse files Browse the repository at this point in the history
  • Loading branch information
JasonCWang authored Oct 10, 2024
1 parent 8cdabd8 commit 8f0afa6
Show file tree
Hide file tree
Showing 23 changed files with 88 additions and 28 deletions.
2 changes: 1 addition & 1 deletion lightspark-remote-signing/src/handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ impl Handler {
SigningRequest::ReleaseCounterpartyPerCommitmentSecretRequest(_) => None,
};

Ok(response.map(|r| Some(r.graphql_response())).flatten())
Ok(response.map(|r| r.graphql_response()))
}
}

Expand Down
2 changes: 2 additions & 0 deletions lightspark/src/objects/account.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1752,6 +1752,8 @@ impl Account {
currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
}
invoice_is_uma: is_uma
invoice_is_lnurl: is_lnurl
}
}
}
Expand Down
3 changes: 1 addition & 2 deletions lightspark/src/objects/account_to_nodes_connection.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
// Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
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;

use crate::objects::connection::Connection;

/// A connection between an account and the nodes it manages.
#[derive(Debug, Clone, Deserialize, Serialize)]
pub struct AccountToNodesConnection {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
// Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
use crate::objects::connection::Connection;
use crate::objects::page_info::PageInfo;
use crate::objects::payment_request::PaymentRequestEnum;
use serde::{Deserialize, Serialize};

use crate::objects::connection::Connection;
use std::vec::Vec;

#[derive(Debug, Clone, Deserialize, Serialize)]
Expand Down
3 changes: 1 addition & 2 deletions lightspark/src/objects/account_to_transactions_connection.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
// Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
use crate::objects::connection::Connection;
use crate::objects::currency_amount::CurrencyAmount;
use crate::objects::page_info::PageInfo;
use crate::objects::transaction::TransactionEnum;
use serde::{Deserialize, Serialize};

use crate::objects::connection::Connection;
use std::vec::Vec;

#[derive(Debug, Clone, Deserialize, Serialize)]
Expand Down
5 changes: 5 additions & 0 deletions lightspark/src/objects/create_uma_invoice_input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,18 @@ use serde::{Deserialize, Serialize};

#[derive(Debug, Clone, Deserialize, Serialize)]
pub struct CreateUmaInvoiceInput {
/// The node from which to create the invoice.
pub node_id: String,

/// The amount for which the invoice should be created, in millisatoshis.
pub amount_msats: i64,

/// The SHA256 hash of the UMA metadata payload. This will be present in the h-tag (SHA256 purpose of payment) of the resulting Bolt 11 invoice.
pub metadata_hash: String,

/// The expiry of the invoice in seconds. Default value is 86400 (1 day).
pub expiry_secs: Option<i64>,

/// An optional, monthly-rotated, unique hashed identifier corresponding to the receiver of the payment.
pub receiver_hash: Option<String>,
}
5 changes: 5 additions & 0 deletions lightspark/src/objects/currency_unit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ pub enum CurrencyUnit {
#[serde(rename = "USD")]
Usd,
/// Mexican Peso.
#[serde(rename = "MXN")]
Mxn,
/// 0.000000001 (10e-9) Bitcoin or a billionth of a Bitcoin. We recommend using the Satoshi unit instead when possible.
#[serde(rename = "NANOBITCOIN")]
Expand Down Expand Up @@ -49,6 +53,7 @@ impl fmt::Display for CurrencyUnit {
Self::Satoshi => write!(f, "SATOSHI"),
Self::Millisatoshi => write!(f, "MILLISATOSHI"),
Self::Usd => write!(f, "USD"),
Self::Mxn => write!(f, "MXN"),
Self::Nanobitcoin => write!(f, "NANOBITCOIN"),
Self::Microbitcoin => write!(f, "MICROBITCOIN"),
Self::Millibitcoin => write!(f, "MILLIBITCOIN"),
Expand Down
2 changes: 2 additions & 0 deletions lightspark/src/objects/fund_node_input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,6 @@ pub struct FundNodeInput {
pub node_id: String,

pub amount_sats: Option<i64>,

pub funding_address: Option<String>,
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
use crate::objects::transaction_status::TransactionStatus;
use serde::{Deserialize, Serialize};
use std::vec::Vec;

#[derive(Debug, Clone, Deserialize, Serialize)]
pub struct IncomingPaymentsForPaymentHashQueryInput {
/// The 32-byte hash of the payment preimage for which to fetch payments
pub payment_hash: String,

/// An optional filter to only query incoming payments of given statuses.
pub statuses: Option<Vec<TransactionStatus>>,
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
use crate::objects::incoming_payment::IncomingPayment;
use serde::{Deserialize, Serialize};
use std::vec::Vec;

#[derive(Debug, Clone, Deserialize, Serialize)]
pub struct IncomingPaymentsForPaymentHashQueryOutput {
#[serde(rename = "incoming_payments_for_payment_hash_query_output_payments")]
pub payments: Vec<IncomingPayment>,
}

pub const FRAGMENT: &str = "
fragment IncomingPaymentsForPaymentHashQueryOutputFragment on IncomingPaymentsForPaymentHashQueryOutput {
__typename
incoming_payments_for_payment_hash_query_output_payments: payments {
id
}
}
";
10 changes: 10 additions & 0 deletions lightspark/src/objects/invoice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,14 @@ pub struct Invoice {
#[serde(rename = "invoice_amount_paid")]
pub amount_paid: Option<CurrencyAmount>,

/// Whether this invoice is an UMA invoice or not. NOTE: this field is only set if the invoice was created using the recommended `create_uma_invoice` function.
#[serde(rename = "invoice_is_uma")]
pub is_uma: Option<bool>,

/// Whether this invoice is an LNURL invoice or not. NOTE: this field is only set if the invoice was created using the recommended `create_lnurl_invoice` function.
#[serde(rename = "invoice_is_lnurl")]
pub is_lnurl: Option<bool>,

/// The typename of the object
#[serde(rename = "__typename")]
pub typename: String,
Expand Down Expand Up @@ -403,5 +411,7 @@ fragment InvoiceFragment on Invoice {
currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
}
invoice_is_uma: is_uma
invoice_is_lnurl: is_lnurl
}
";
3 changes: 1 addition & 2 deletions lightspark/src/objects/invoice_data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@ use crate::objects::currency_amount::CurrencyAmount;
use crate::objects::node::NodeEnum;
use crate::objects::payment_request_data::PaymentRequestData;
use crate::types::custom_date_formats::custom_date_format;
use serde::{Deserialize, Serialize};

use chrono::{DateTime, Utc};
use serde::{Deserialize, Serialize};

/// This object represents the data associated with a BOLT #11 invoice. You can retrieve this object to receive the relevant data associated with a specific invoice.
#[derive(Debug, Clone, Deserialize, Serialize)]
Expand Down
9 changes: 4 additions & 5 deletions lightspark/src/objects/lightspark_node.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
// Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
use super::lightspark_node_with_o_s_k::LightsparkNodeWithOSK;
use crate::objects::balances::Balances;
use crate::objects::entity::Entity;
use crate::objects::node::Node;
use serde_json::Value;

use super::lightspark_node_with_remote_signing::LightsparkNodeWithRemoteSigning;
use crate::objects::balances::Balances;
use crate::objects::blockchain_balance::BlockchainBalance;
use crate::objects::currency_amount::CurrencyAmount;
use crate::objects::entity::Entity;
use crate::objects::lightspark_node_status::LightsparkNodeStatus;
use crate::objects::node::Node;
use crate::types::entity_wrapper::EntityWrapper;
use serde::{Deserialize, Deserializer, Serialize};
use serde_json::Value;
use std::vec::Vec;

pub trait LightsparkNode: Node + Entity {
Expand Down
5 changes: 2 additions & 3 deletions lightspark/src/objects/lightspark_node_with_o_s_k.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::error::Error;
use crate::objects::balances::Balances;
use crate::objects::bitcoin_network::BitcoinNetwork;
use crate::objects::blockchain_balance::BlockchainBalance;
Expand All @@ -10,6 +11,7 @@ use crate::objects::lightspark_node::LightsparkNode;
use crate::objects::lightspark_node_status::LightsparkNodeStatus;
use crate::objects::lightspark_node_to_channels_connection::LightsparkNodeToChannelsConnection;
use crate::objects::lightspark_node_to_daily_liquidity_forecasts_connection::LightsparkNodeToDailyLiquidityForecastsConnection;
use crate::objects::node::Node;
use crate::objects::node_address_type::NodeAddressType;
use crate::objects::node_to_addresses_connection::NodeToAddressesConnection;
use crate::objects::secret::Secret;
Expand All @@ -24,9 +26,6 @@ use serde_json::Value;
use std::collections::HashMap;
use std::vec::Vec;

use crate::error::Error;
use crate::objects::node::Node;

/// This is a Lightspark node with OSK.
#[derive(Debug, Clone, Deserialize, Serialize)]
pub struct LightsparkNodeWithOSK {
Expand Down
5 changes: 2 additions & 3 deletions lightspark/src/objects/lightspark_node_with_remote_signing.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::error::Error;
use crate::objects::balances::Balances;
use crate::objects::bitcoin_network::BitcoinNetwork;
use crate::objects::blockchain_balance::BlockchainBalance;
Expand All @@ -10,6 +11,7 @@ use crate::objects::lightspark_node::LightsparkNode;
use crate::objects::lightspark_node_status::LightsparkNodeStatus;
use crate::objects::lightspark_node_to_channels_connection::LightsparkNodeToChannelsConnection;
use crate::objects::lightspark_node_to_daily_liquidity_forecasts_connection::LightsparkNodeToDailyLiquidityForecastsConnection;
use crate::objects::node::Node;
use crate::objects::node_address_type::NodeAddressType;
use crate::objects::node_to_addresses_connection::NodeToAddressesConnection;
use crate::types::custom_date_formats::custom_date_format;
Expand All @@ -23,9 +25,6 @@ use serde_json::Value;
use std::collections::HashMap;
use std::vec::Vec;

use crate::error::Error;
use crate::objects::node::Node;

/// This is a Lightspark node with remote signing.
#[derive(Debug, Clone, Deserialize, Serialize)]
pub struct LightsparkNodeWithRemoteSigning {
Expand Down
2 changes: 2 additions & 0 deletions lightspark/src/objects/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ pub mod incoming_payment_attempt_status;
pub mod incoming_payment_to_attempts_connection;
pub mod incoming_payments_for_invoice_query_input;
pub mod incoming_payments_for_invoice_query_output;
pub mod incoming_payments_for_payment_hash_query_input;
pub mod incoming_payments_for_payment_hash_query_output;
pub mod invoice;
pub mod invoice_data;
pub mod invoice_for_payment_hash_input;
Expand Down
7 changes: 3 additions & 4 deletions lightspark/src/objects/outgoing_payment.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
// Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
use crate::error::Error;
use crate::objects::currency_amount::CurrencyAmount;
use crate::objects::entity::Entity;
use crate::objects::lightning_transaction::LightningTransaction;
use crate::objects::outgoing_payment_to_attempts_connection::OutgoingPaymentToAttemptsConnection;
use crate::objects::payment_failure_reason::PaymentFailureReason;
use crate::objects::payment_request_data::PaymentRequestDataEnum;
use crate::objects::post_transaction_data::PostTransactionData;
use crate::objects::rich_text::RichText;
use crate::objects::transaction::Transaction;
use crate::objects::transaction_status::TransactionStatus;
use crate::types::custom_date_formats::custom_date_format;
use crate::types::custom_date_formats::custom_date_format_option;
Expand All @@ -18,10 +21,6 @@ use serde_json::Value;
use std::collections::HashMap;
use std::vec::Vec;

use crate::error::Error;
use crate::objects::post_transaction_data::PostTransactionData;
use crate::objects::transaction::Transaction;

/// This object represents a Lightning Network payment sent from a Lightspark Node. You can retrieve this object to receive payment related information about any payment sent from your Lightspark Node on the Lightning Network.
#[derive(Debug, Clone, Deserialize, Serialize)]
pub struct OutgoingPayment {
Expand Down
5 changes: 5 additions & 0 deletions lightspark/src/objects/region_code.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1002,6 +1002,10 @@ pub enum RegionCode {
#[serde(rename = "ZW")]
Zw,
/// The code representing a fake region for testing.
#[serde(rename = "NN")]
Nn,
}

impl From<RegionCode> for Value {
Expand Down Expand Up @@ -1262,6 +1266,7 @@ impl fmt::Display for RegionCode {
Self::Ye => write!(f, "YE"),
Self::Zm => write!(f, "ZM"),
Self::Zw => write!(f, "ZW"),
Self::Nn => write!(f, "NN"),
}
}
}
2 changes: 2 additions & 0 deletions lightspark/src/objects/wallet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1078,6 +1078,8 @@ impl Wallet {
currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
}
invoice_is_uma: is_uma
invoice_is_lnurl: is_lnurl
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
// Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
use crate::objects::connection::Connection;
use crate::objects::page_info::PageInfo;
use crate::objects::payment_request::PaymentRequestEnum;
use serde::{Deserialize, Serialize};

use crate::objects::connection::Connection;
use std::vec::Vec;

#[derive(Debug, Clone, Deserialize, Serialize)]
Expand Down
3 changes: 1 addition & 2 deletions lightspark/src/objects/wallet_to_transactions_connection.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
// Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
use crate::objects::connection::Connection;
use crate::objects::page_info::PageInfo;
use crate::objects::transaction::TransactionEnum;
use serde::{Deserialize, Serialize};

use crate::objects::connection::Connection;
use std::vec::Vec;

#[derive(Debug, Clone, Deserialize, Serialize)]
Expand Down
4 changes: 4 additions & 0 deletions lightspark/src/objects/webhook_event_type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ pub enum WebhookEventType {

#[serde(rename = "HIGH_BALANCE")]
HighBalance,

#[serde(rename = "CHANNEL_OPENING_FEES")]
ChannelOpeningFees,
}

impl From<WebhookEventType> for Value {
Expand All @@ -72,6 +75,7 @@ impl fmt::Display for WebhookEventType {
Self::RemoteSigning => write!(f, "REMOTE_SIGNING"),
Self::LowBalance => write!(f, "LOW_BALANCE"),
Self::HighBalance => write!(f, "HIGH_BALANCE"),
Self::ChannelOpeningFees => write!(f, "CHANNEL_OPENING_FEES"),
}
}
}
1 change: 1 addition & 0 deletions lightspark/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ pub fn value_millisatoshi(amount: &CurrencyAmount) -> Result<i64, Error> {
crate::objects::currency_unit::CurrencyUnit::Satoshi => Ok(amount.original_value * 1000),
crate::objects::currency_unit::CurrencyUnit::Millisatoshi => Ok(amount.original_value),
crate::objects::currency_unit::CurrencyUnit::Usd => Err(Error::InvalidCurrencyConversion),
crate::objects::currency_unit::CurrencyUnit::Mxn => Err(Error::InvalidCurrencyConversion),
crate::objects::currency_unit::CurrencyUnit::Nanobitcoin => Ok(amount.original_value * 100),
crate::objects::currency_unit::CurrencyUnit::Microbitcoin => {
Ok(amount.original_value * 100_000)
Expand Down

0 comments on commit 8f0afa6

Please sign in to comment.