@lightsparkdev/lightspark-sdk 1.1.7 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (121) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/dist/{chunk-7UT6YX37.js → chunk-VTPDR6P4.js} +393 -275
  3. package/dist/{index-d31f4469.d.ts → index-f040db9f.d.ts} +678 -386
  4. package/dist/index.cjs +396 -278
  5. package/dist/index.d.ts +2 -2
  6. package/dist/index.js +7 -7
  7. package/dist/objects/index.cjs +395 -277
  8. package/dist/objects/index.d.ts +1 -1
  9. package/dist/objects/index.js +5 -5
  10. package/package.json +2 -2
  11. package/src/objects/Account.ts +13 -2
  12. package/src/objects/AccountToApiTokensConnection.ts +16 -5
  13. package/src/objects/AccountToChannelsConnection.ts +9 -0
  14. package/src/objects/AccountToNodesConnection.ts +19 -5
  15. package/src/objects/AccountToPaymentRequestsConnection.ts +21 -5
  16. package/src/objects/AccountToTransactionsConnection.ts +33 -9
  17. package/src/objects/AccountToWalletsConnection.ts +13 -4
  18. package/src/objects/ApiToken.ts +13 -3
  19. package/src/objects/Balances.ts +17 -3
  20. package/src/objects/BlockchainBalance.ts +34 -9
  21. package/src/objects/Channel.ts +61 -16
  22. package/src/objects/ChannelClosingTransaction.ts +81 -61
  23. package/src/objects/ChannelFees.ts +16 -5
  24. package/src/objects/ChannelOpeningTransaction.ts +81 -61
  25. package/src/objects/ChannelSnapshot.ts +32 -8
  26. package/src/objects/ChannelToTransactionsConnection.ts +26 -6
  27. package/src/objects/Connection.ts +205 -10
  28. package/src/objects/CreateApiTokenInput.ts +8 -2
  29. package/src/objects/CreateApiTokenOutput.ts +9 -3
  30. package/src/objects/CreateInvoiceInput.ts +14 -5
  31. package/src/objects/CreateInvoiceOutput.ts +7 -2
  32. package/src/objects/CreateLnurlInvoiceInput.ts +13 -3
  33. package/src/objects/CreateNodeWalletAddressInput.ts +9 -2
  34. package/src/objects/CreateNodeWalletAddressOutput.ts +10 -2
  35. package/src/objects/CreateTestModeInvoiceInput.ts +14 -4
  36. package/src/objects/CreateTestModeInvoiceOutput.ts +10 -2
  37. package/src/objects/CreateTestModePaymentInput.ts +12 -3
  38. package/src/objects/CreateTestModePaymentoutput.ts +12 -2
  39. package/src/objects/CreateUmaInvoiceInput.ts +13 -3
  40. package/src/objects/CurrencyAmount.ts +13 -2
  41. package/src/objects/DeclineToSignMessagesInput.ts +9 -2
  42. package/src/objects/DeclineToSignMessagesOutput.ts +15 -3
  43. package/src/objects/DeleteApiTokenInput.ts +7 -2
  44. package/src/objects/DeleteApiTokenOutput.ts +7 -2
  45. package/src/objects/Deposit.ts +77 -61
  46. package/src/objects/Entity.ts +2 -2
  47. package/src/objects/FeeEstimate.ts +12 -3
  48. package/src/objects/FundNodeInput.ts +9 -3
  49. package/src/objects/FundNodeOutput.ts +11 -3
  50. package/src/objects/GraphNode.ts +21 -5
  51. package/src/objects/Hop.ts +27 -9
  52. package/src/objects/IdAndSignature.ts +8 -2
  53. package/src/objects/IncomingPayment.ts +33 -7
  54. package/src/objects/IncomingPaymentAttempt.ts +21 -5
  55. package/src/objects/IncomingPaymentToAttemptsConnection.ts +21 -5
  56. package/src/objects/Invoice.ts +37 -24
  57. package/src/objects/InvoiceData.ts +21 -6
  58. package/src/objects/LightningFeeEstimateForInvoiceInput.ts +13 -3
  59. package/src/objects/LightningFeeEstimateForNodeInput.ts +12 -2
  60. package/src/objects/LightningFeeEstimateOutput.ts +15 -3
  61. package/src/objects/LightningTransaction.ts +117 -28
  62. package/src/objects/LightsparkNode.ts +250 -210
  63. package/src/objects/LightsparkNodeOwner.ts +35 -4
  64. package/src/objects/LightsparkNodeToChannelsConnection.ts +17 -4
  65. package/src/objects/LightsparkNodeWithOSK.ts +66 -17
  66. package/src/objects/LightsparkNodeWithRemoteSigning.ts +62 -15
  67. package/src/objects/Node.ts +209 -68
  68. package/src/objects/NodeAddress.ts +8 -2
  69. package/src/objects/NodeToAddressesConnection.ts +13 -3
  70. package/src/objects/OnChainTransaction.ts +156 -44
  71. package/src/objects/OutgoingPayment.ts +53 -14
  72. package/src/objects/OutgoingPaymentAttempt.ts +37 -8
  73. package/src/objects/OutgoingPaymentAttemptToHopsConnection.ts +18 -5
  74. package/src/objects/OutgoingPaymentToAttemptsConnection.ts +17 -4
  75. package/src/objects/OutgoingPaymentsForInvoiceQueryInput.ts +12 -3
  76. package/src/objects/OutgoingPaymentsForInvoiceQueryOutput.ts +11 -2
  77. package/src/objects/PageInfo.ts +14 -6
  78. package/src/objects/PayInvoiceInput.ts +12 -3
  79. package/src/objects/PayInvoiceOutput.ts +7 -2
  80. package/src/objects/PayUmaInvoiceInput.ts +12 -3
  81. package/src/objects/PaymentRequest.ts +27 -5
  82. package/src/objects/PaymentRequestData.ts +27 -4
  83. package/src/objects/PostTransactionData.ts +12 -3
  84. package/src/objects/RegisterPaymentInput.ts +10 -2
  85. package/src/objects/RegisterPaymentOutput.ts +9 -2
  86. package/src/objects/ReleaseChannelPerCommitmentSecretInput.ts +13 -2
  87. package/src/objects/ReleaseChannelPerCommitmentSecretOutput.ts +9 -2
  88. package/src/objects/ReleasePaymentPreimageInput.ts +10 -2
  89. package/src/objects/ReleasePaymentPreimageOutput.ts +9 -2
  90. package/src/objects/RequestWithdrawalInput.ts +12 -2
  91. package/src/objects/RequestWithdrawalOutput.ts +9 -2
  92. package/src/objects/RichText.ts +7 -2
  93. package/src/objects/RoutingTransaction.ts +62 -41
  94. package/src/objects/ScreenNodeInput.ts +8 -2
  95. package/src/objects/ScreenNodeOutput.ts +7 -2
  96. package/src/objects/Secret.ts +8 -2
  97. package/src/objects/SendPaymentInput.ts +11 -2
  98. package/src/objects/SendPaymentOutput.ts +7 -2
  99. package/src/objects/SetInvoicePaymentHashInput.ts +12 -3
  100. package/src/objects/SetInvoicePaymentHashOutput.ts +9 -2
  101. package/src/objects/SignInvoiceInput.ts +9 -2
  102. package/src/objects/SignInvoiceOutput.ts +7 -2
  103. package/src/objects/SignMessagesInput.ts +13 -3
  104. package/src/objects/SignMessagesOutput.ts +13 -3
  105. package/src/objects/Signable.ts +10 -3
  106. package/src/objects/SignablePayload.ts +18 -5
  107. package/src/objects/Transaction.ts +206 -9
  108. package/src/objects/TransactionFailures.ts +11 -4
  109. package/src/objects/UpdateChannelPerCommitmentPointInput.ts +13 -2
  110. package/src/objects/UpdateChannelPerCommitmentPointOutput.ts +9 -2
  111. package/src/objects/UpdateNodeSharedSecretInput.ts +10 -2
  112. package/src/objects/UpdateNodeSharedSecretOutput.ts +9 -2
  113. package/src/objects/Wallet.ts +22 -5
  114. package/src/objects/WalletToPaymentRequestsConnection.ts +21 -5
  115. package/src/objects/WalletToTransactionsConnection.ts +16 -5
  116. package/src/objects/Withdrawal.ts +77 -61
  117. package/src/objects/WithdrawalRequest.ts +25 -4
  118. package/src/objects/WithdrawalRequestToChannelClosingTransactionsConnection.ts +19 -4
  119. package/src/objects/WithdrawalRequestToChannelOpeningTransactionsConnection.ts +19 -4
  120. package/src/objects/index.ts +5 -2
  121. package/src/tests/serialization.test.ts +18 -0
@@ -1,8 +1,8 @@
1
1
  // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
2
2
 
3
- type UpdateNodeSharedSecretOutput = {
3
+ interface UpdateNodeSharedSecretOutput {
4
4
  nodeId: string;
5
- };
5
+ }
6
6
 
7
7
  export const UpdateNodeSharedSecretOutputFromJson = (
8
8
  obj: any,
@@ -11,6 +11,13 @@ export const UpdateNodeSharedSecretOutputFromJson = (
11
11
  nodeId: obj["update_node_shared_secret_output_node"].id,
12
12
  } as UpdateNodeSharedSecretOutput;
13
13
  };
14
+ export const UpdateNodeSharedSecretOutputToJson = (
15
+ obj: UpdateNodeSharedSecretOutput,
16
+ ): any => {
17
+ return {
18
+ update_node_shared_secret_output_node: { id: obj.nodeId },
19
+ };
20
+ };
14
21
 
15
22
  export const FRAGMENT = `
16
23
  fragment UpdateNodeSharedSecretOutputFragment on UpdateNodeSharedSecretOutput {
@@ -4,9 +4,10 @@ import { type Query } from "@lightsparkdev/core";
4
4
  import autoBind from "auto-bind";
5
5
  import type LightsparkClient from "../client.js";
6
6
  import type Balances from "./Balances.js";
7
- import { BalancesFromJson } from "./Balances.js";
7
+ import { BalancesFromJson, BalancesToJson } from "./Balances.js";
8
8
  import type CurrencyAmount from "./CurrencyAmount.js";
9
9
  import { CurrencyAmountFromJson } from "./CurrencyAmount.js";
10
+ import type Entity from "./Entity.js";
10
11
  import type LightsparkNodeOwner from "./LightsparkNodeOwner.js";
11
12
  import type TransactionStatus from "./TransactionStatus.js";
12
13
  import type TransactionType from "./TransactionType.js";
@@ -17,7 +18,7 @@ import type WalletToTransactionsConnection from "./WalletToTransactionsConnectio
17
18
  import { WalletToTransactionsConnectionFromJson } from "./WalletToTransactionsConnection.js";
18
19
 
19
20
  /** This object represents a Lightspark Wallet, tied to your Lightspark account. Wallets can be used to send or receive funds over the Lightning Network. You can retrieve this object to receive information about a specific wallet tied to your Lightspark account. **/
20
- class Wallet implements LightsparkNodeOwner {
21
+ class Wallet implements LightsparkNodeOwner, Entity {
21
22
  constructor(
22
23
  public readonly id: string,
23
24
  public readonly createdAt: string,
@@ -25,9 +26,9 @@ class Wallet implements LightsparkNodeOwner {
25
26
  public readonly thirdPartyIdentifier: string,
26
27
  public readonly status: WalletStatus,
27
28
  public readonly typename: string,
28
- public readonly lastLoginAt?: string,
29
- public readonly balances?: Balances,
30
- public readonly accountId?: string,
29
+ public readonly lastLoginAt?: string | undefined,
30
+ public readonly balances?: Balances | undefined,
31
+ public readonly accountId?: string | undefined,
31
32
  ) {
32
33
  autoBind(this);
33
34
  }
@@ -1057,6 +1058,22 @@ ${FRAGMENT}
1057
1058
  constructObject: (data: any) => WalletFromJson(data.entity),
1058
1059
  };
1059
1060
  }
1061
+
1062
+ public toJson() {
1063
+ return {
1064
+ __typename: "Wallet",
1065
+ wallet_id: this.id,
1066
+ wallet_created_at: this.createdAt,
1067
+ wallet_updated_at: this.updatedAt,
1068
+ wallet_last_login_at: this.lastLoginAt,
1069
+ wallet_balances: this.balances
1070
+ ? BalancesToJson(this.balances)
1071
+ : undefined,
1072
+ wallet_third_party_identifier: this.thirdPartyIdentifier,
1073
+ wallet_account: { id: this.accountId } ?? undefined,
1074
+ wallet_status: this.status,
1075
+ };
1076
+ }
1060
1077
  }
1061
1078
 
1062
1079
  export const WalletFromJson = (obj: any): Wallet => {
@@ -1,12 +1,14 @@
1
1
  // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
2
2
 
3
- import type Connection from "./Connection.js";
4
3
  import type PageInfo from "./PageInfo.js";
5
- import { PageInfoFromJson } from "./PageInfo.js";
4
+ import { PageInfoFromJson, PageInfoToJson } from "./PageInfo.js";
6
5
  import type PaymentRequest from "./PaymentRequest.js";
7
- import { PaymentRequestFromJson } from "./PaymentRequest.js";
6
+ import {
7
+ PaymentRequestFromJson,
8
+ PaymentRequestToJson,
9
+ } from "./PaymentRequest.js";
8
10
 
9
- type WalletToPaymentRequestsConnection = Connection & {
11
+ interface WalletToPaymentRequestsConnection {
10
12
  /**
11
13
  * The total count of objects in this connection, using the current filters. It is different from the
12
14
  * number of objects returned in the current page (in the `entities` field).
@@ -21,7 +23,7 @@ type WalletToPaymentRequestsConnection = Connection & {
21
23
 
22
24
  /** The typename of the object **/
23
25
  typename: string;
24
- };
26
+ }
25
27
 
26
28
  export const WalletToPaymentRequestsConnectionFromJson = (
27
29
  obj: any,
@@ -37,6 +39,20 @@ export const WalletToPaymentRequestsConnectionFromJson = (
37
39
  typename: "WalletToPaymentRequestsConnection",
38
40
  } as WalletToPaymentRequestsConnection;
39
41
  };
42
+ export const WalletToPaymentRequestsConnectionToJson = (
43
+ obj: WalletToPaymentRequestsConnection,
44
+ ): any => {
45
+ return {
46
+ __typename: "WalletToPaymentRequestsConnection",
47
+ wallet_to_payment_requests_connection_count: obj.count,
48
+ wallet_to_payment_requests_connection_page_info: PageInfoToJson(
49
+ obj.pageInfo,
50
+ ),
51
+ wallet_to_payment_requests_connection_entities: obj.entities.map((e) =>
52
+ PaymentRequestToJson(e),
53
+ ),
54
+ };
55
+ };
40
56
 
41
57
  export const FRAGMENT = `
42
58
  fragment WalletToPaymentRequestsConnectionFragment on WalletToPaymentRequestsConnection {
@@ -1,12 +1,11 @@
1
1
  // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
2
2
 
3
- import type Connection from "./Connection.js";
4
3
  import type PageInfo from "./PageInfo.js";
5
- import { PageInfoFromJson } from "./PageInfo.js";
4
+ import { PageInfoFromJson, PageInfoToJson } from "./PageInfo.js";
6
5
  import type Transaction from "./Transaction.js";
7
- import { TransactionFromJson } from "./Transaction.js";
6
+ import { TransactionFromJson, TransactionToJson } from "./Transaction.js";
8
7
 
9
- type WalletToTransactionsConnection = Connection & {
8
+ interface WalletToTransactionsConnection {
10
9
  /**
11
10
  * The total count of objects in this connection, using the current filters. It is different from the
12
11
  * number of objects returned in the current page (in the `entities` field).
@@ -21,7 +20,7 @@ type WalletToTransactionsConnection = Connection & {
21
20
 
22
21
  /** The typename of the object **/
23
22
  typename: string;
24
- };
23
+ }
25
24
 
26
25
  export const WalletToTransactionsConnectionFromJson = (
27
26
  obj: any,
@@ -37,6 +36,18 @@ export const WalletToTransactionsConnectionFromJson = (
37
36
  typename: "WalletToTransactionsConnection",
38
37
  } as WalletToTransactionsConnection;
39
38
  };
39
+ export const WalletToTransactionsConnectionToJson = (
40
+ obj: WalletToTransactionsConnection,
41
+ ): any => {
42
+ return {
43
+ __typename: "WalletToTransactionsConnection",
44
+ wallet_to_transactions_connection_count: obj.count,
45
+ wallet_to_transactions_connection_page_info: PageInfoToJson(obj.pageInfo),
46
+ wallet_to_transactions_connection_entities: obj.entities.map((e) =>
47
+ TransactionToJson(e),
48
+ ),
49
+ };
50
+ };
40
51
 
41
52
  export const FRAGMENT = `
42
53
  fragment WalletToTransactionsConnectionFragment on WalletToTransactionsConnection {
@@ -2,70 +2,68 @@
2
2
 
3
3
  import { type Query } from "@lightsparkdev/core";
4
4
  import type CurrencyAmount from "./CurrencyAmount.js";
5
- import { CurrencyAmountFromJson } from "./CurrencyAmount.js";
6
- import type Entity from "./Entity.js";
7
- import type OnChainTransaction from "./OnChainTransaction.js";
8
- import type Transaction from "./Transaction.js";
5
+ import {
6
+ CurrencyAmountFromJson,
7
+ CurrencyAmountToJson,
8
+ } from "./CurrencyAmount.js";
9
9
  import TransactionStatus from "./TransactionStatus.js";
10
10
 
11
11
  /** This object represents an L1 withdrawal from your Lightspark Node to any Bitcoin wallet. You can retrieve this object to receive detailed information about any L1 withdrawal associated with your Lightspark Node or account. **/
12
- type Withdrawal = OnChainTransaction &
13
- Transaction &
14
- Entity & {
15
- /**
16
- * The unique identifier of this entity across all Lightspark systems. Should be treated as an opaque
17
- * string.
18
- **/
19
- id: string;
20
-
21
- /** The date and time when this transaction was initiated. **/
22
- createdAt: string;
23
-
24
- /** The date and time when the entity was last updated. **/
25
- updatedAt: string;
26
-
27
- /** The current status of this transaction. **/
28
- status: TransactionStatus;
29
-
30
- /** The amount of money involved in this transaction. **/
31
- amount: CurrencyAmount;
32
-
33
- /**
34
- * The height of the block that included this transaction. This will be zero for unconfirmed
35
- * transactions.
36
- **/
37
- blockHeight: number;
38
-
39
- /** The Bitcoin blockchain addresses this transaction was sent to. **/
40
- destinationAddresses: string[];
41
-
42
- /** The Lightspark node this withdrawal originated from. **/
43
- originId: string;
44
-
45
- /** The typename of the object **/
46
- typename: string;
47
-
48
- /** The date and time when this transaction was completed or failed. **/
49
- resolvedAt?: string;
50
-
51
- /** The hash of this transaction, so it can be uniquely identified on the Lightning Network. **/
52
- transactionHash?: string;
53
-
54
- /**
55
- * The fees that were paid by the wallet sending the transaction to commit it to the Bitcoin
56
- * blockchain.
57
- **/
58
- fees?: CurrencyAmount;
59
-
60
- /**
61
- * The hash of the block that included this transaction. This will be null for unconfirmed
62
- * transactions.
63
- **/
64
- blockHash?: string;
65
-
66
- /** The number of blockchain confirmations for this transaction in real time. **/
67
- numConfirmations?: number;
68
- };
12
+ interface Withdrawal {
13
+ /**
14
+ * The unique identifier of this entity across all Lightspark systems. Should be treated as an opaque
15
+ * string.
16
+ **/
17
+ id: string;
18
+
19
+ /** The date and time when this transaction was initiated. **/
20
+ createdAt: string;
21
+
22
+ /** The date and time when the entity was last updated. **/
23
+ updatedAt: string;
24
+
25
+ /** The current status of this transaction. **/
26
+ status: TransactionStatus;
27
+
28
+ /** The amount of money involved in this transaction. **/
29
+ amount: CurrencyAmount;
30
+
31
+ /**
32
+ * The height of the block that included this transaction. This will be zero for unconfirmed
33
+ * transactions.
34
+ **/
35
+ blockHeight: number;
36
+
37
+ /** The Bitcoin blockchain addresses this transaction was sent to. **/
38
+ destinationAddresses: string[];
39
+
40
+ /** The Lightspark node this withdrawal originated from. **/
41
+ originId: string;
42
+
43
+ /** The typename of the object **/
44
+ typename: string;
45
+
46
+ /** The date and time when this transaction was completed or failed. **/
47
+ resolvedAt?: string | undefined;
48
+
49
+ /** The hash of this transaction, so it can be uniquely identified on the Lightning Network. **/
50
+ transactionHash?: string | undefined;
51
+
52
+ /**
53
+ * The fees that were paid by the wallet sending the transaction to commit it to the Bitcoin
54
+ * blockchain.
55
+ **/
56
+ fees?: CurrencyAmount | undefined;
57
+
58
+ /**
59
+ * The hash of the block that included this transaction. This will be null for unconfirmed
60
+ * transactions.
61
+ **/
62
+ blockHash?: string | undefined;
63
+
64
+ /** The number of blockchain confirmations for this transaction in real time. **/
65
+ numConfirmations?: number | undefined;
66
+ }
69
67
 
70
68
  export const WithdrawalFromJson = (obj: any): Withdrawal => {
71
69
  return {
@@ -89,6 +87,24 @@ export const WithdrawalFromJson = (obj: any): Withdrawal => {
89
87
  numConfirmations: obj["withdrawal_num_confirmations"],
90
88
  } as Withdrawal;
91
89
  };
90
+ export const WithdrawalToJson = (obj: Withdrawal): any => {
91
+ return {
92
+ __typename: "Withdrawal",
93
+ withdrawal_id: obj.id,
94
+ withdrawal_created_at: obj.createdAt,
95
+ withdrawal_updated_at: obj.updatedAt,
96
+ withdrawal_status: obj.status,
97
+ withdrawal_resolved_at: obj.resolvedAt,
98
+ withdrawal_amount: CurrencyAmountToJson(obj.amount),
99
+ withdrawal_transaction_hash: obj.transactionHash,
100
+ withdrawal_fees: obj.fees ? CurrencyAmountToJson(obj.fees) : undefined,
101
+ withdrawal_block_hash: obj.blockHash,
102
+ withdrawal_block_height: obj.blockHeight,
103
+ withdrawal_destination_addresses: obj.destinationAddresses,
104
+ withdrawal_num_confirmations: obj.numConfirmations,
105
+ withdrawal_origin: { id: obj.originId },
106
+ };
107
+ };
92
108
 
93
109
  export const FRAGMENT = `
94
110
  fragment WithdrawalFragment on Withdrawal {
@@ -4,7 +4,10 @@ import { type Query } from "@lightsparkdev/core";
4
4
  import autoBind from "auto-bind";
5
5
  import type LightsparkClient from "../client.js";
6
6
  import type CurrencyAmount from "./CurrencyAmount.js";
7
- import { CurrencyAmountFromJson } from "./CurrencyAmount.js";
7
+ import {
8
+ CurrencyAmountFromJson,
9
+ CurrencyAmountToJson,
10
+ } from "./CurrencyAmount.js";
8
11
  import type Entity from "./Entity.js";
9
12
  import WithdrawalMode from "./WithdrawalMode.js";
10
13
  import WithdrawalRequestStatus from "./WithdrawalRequestStatus.js";
@@ -24,9 +27,9 @@ class WithdrawalRequest implements Entity {
24
27
  public readonly withdrawalMode: WithdrawalMode,
25
28
  public readonly status: WithdrawalRequestStatus,
26
29
  public readonly typename: string,
27
- public readonly estimatedAmount?: CurrencyAmount,
28
- public readonly completedAt?: string,
29
- public readonly withdrawalId?: string,
30
+ public readonly estimatedAmount?: CurrencyAmount | undefined,
31
+ public readonly completedAt?: string | undefined,
32
+ public readonly withdrawalId?: string | undefined,
30
33
  ) {
31
34
  autoBind(this);
32
35
  }
@@ -180,6 +183,24 @@ ${FRAGMENT}
180
183
  constructObject: (data: any) => WithdrawalRequestFromJson(data.entity),
181
184
  };
182
185
  }
186
+
187
+ public toJson() {
188
+ return {
189
+ __typename: "WithdrawalRequest",
190
+ withdrawal_request_id: this.id,
191
+ withdrawal_request_created_at: this.createdAt,
192
+ withdrawal_request_updated_at: this.updatedAt,
193
+ withdrawal_request_amount: CurrencyAmountToJson(this.amount),
194
+ withdrawal_request_estimated_amount: this.estimatedAmount
195
+ ? CurrencyAmountToJson(this.estimatedAmount)
196
+ : undefined,
197
+ withdrawal_request_bitcoin_address: this.bitcoinAddress,
198
+ withdrawal_request_withdrawal_mode: this.withdrawalMode,
199
+ withdrawal_request_status: this.status,
200
+ withdrawal_request_completed_at: this.completedAt,
201
+ withdrawal_request_withdrawal: { id: this.withdrawalId } ?? undefined,
202
+ };
203
+ }
183
204
  }
184
205
 
185
206
  export const WithdrawalRequestFromJson = (obj: any): WithdrawalRequest => {
@@ -1,11 +1,14 @@
1
1
  // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
2
2
 
3
3
  import type ChannelClosingTransaction from "./ChannelClosingTransaction.js";
4
- import { ChannelClosingTransactionFromJson } from "./ChannelClosingTransaction.js";
4
+ import {
5
+ ChannelClosingTransactionFromJson,
6
+ ChannelClosingTransactionToJson,
7
+ } from "./ChannelClosingTransaction.js";
5
8
  import type PageInfo from "./PageInfo.js";
6
- import { PageInfoFromJson } from "./PageInfo.js";
9
+ import { PageInfoFromJson, PageInfoToJson } from "./PageInfo.js";
7
10
 
8
- type WithdrawalRequestToChannelClosingTransactionsConnection = {
11
+ interface WithdrawalRequestToChannelClosingTransactionsConnection {
9
12
  /** An object that holds pagination information about the objects in this connection. **/
10
13
  pageInfo: PageInfo;
11
14
 
@@ -17,7 +20,7 @@ type WithdrawalRequestToChannelClosingTransactionsConnection = {
17
20
 
18
21
  /** The channel closing transactions for the current page of this connection. **/
19
22
  entities: ChannelClosingTransaction[];
20
- };
23
+ }
21
24
 
22
25
  export const WithdrawalRequestToChannelClosingTransactionsConnectionFromJson = (
23
26
  obj: any,
@@ -37,6 +40,18 @@ export const WithdrawalRequestToChannelClosingTransactionsConnectionFromJson = (
37
40
  ].map((e) => ChannelClosingTransactionFromJson(e)),
38
41
  } as WithdrawalRequestToChannelClosingTransactionsConnection;
39
42
  };
43
+ export const WithdrawalRequestToChannelClosingTransactionsConnectionToJson = (
44
+ obj: WithdrawalRequestToChannelClosingTransactionsConnection,
45
+ ): any => {
46
+ return {
47
+ withdrawal_request_to_channel_closing_transactions_connection_page_info:
48
+ PageInfoToJson(obj.pageInfo),
49
+ withdrawal_request_to_channel_closing_transactions_connection_count:
50
+ obj.count,
51
+ withdrawal_request_to_channel_closing_transactions_connection_entities:
52
+ obj.entities.map((e) => ChannelClosingTransactionToJson(e)),
53
+ };
54
+ };
40
55
 
41
56
  export const FRAGMENT = `
42
57
  fragment WithdrawalRequestToChannelClosingTransactionsConnectionFragment on WithdrawalRequestToChannelClosingTransactionsConnection {
@@ -1,11 +1,14 @@
1
1
  // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
2
2
 
3
3
  import type ChannelOpeningTransaction from "./ChannelOpeningTransaction.js";
4
- import { ChannelOpeningTransactionFromJson } from "./ChannelOpeningTransaction.js";
4
+ import {
5
+ ChannelOpeningTransactionFromJson,
6
+ ChannelOpeningTransactionToJson,
7
+ } from "./ChannelOpeningTransaction.js";
5
8
  import type PageInfo from "./PageInfo.js";
6
- import { PageInfoFromJson } from "./PageInfo.js";
9
+ import { PageInfoFromJson, PageInfoToJson } from "./PageInfo.js";
7
10
 
8
- type WithdrawalRequestToChannelOpeningTransactionsConnection = {
11
+ interface WithdrawalRequestToChannelOpeningTransactionsConnection {
9
12
  /** An object that holds pagination information about the objects in this connection. **/
10
13
  pageInfo: PageInfo;
11
14
 
@@ -17,7 +20,7 @@ type WithdrawalRequestToChannelOpeningTransactionsConnection = {
17
20
 
18
21
  /** The channel opening transactions for the current page of this connection. **/
19
22
  entities: ChannelOpeningTransaction[];
20
- };
23
+ }
21
24
 
22
25
  export const WithdrawalRequestToChannelOpeningTransactionsConnectionFromJson = (
23
26
  obj: any,
@@ -37,6 +40,18 @@ export const WithdrawalRequestToChannelOpeningTransactionsConnectionFromJson = (
37
40
  ].map((e) => ChannelOpeningTransactionFromJson(e)),
38
41
  } as WithdrawalRequestToChannelOpeningTransactionsConnection;
39
42
  };
43
+ export const WithdrawalRequestToChannelOpeningTransactionsConnectionToJson = (
44
+ obj: WithdrawalRequestToChannelOpeningTransactionsConnection,
45
+ ): any => {
46
+ return {
47
+ withdrawal_request_to_channel_opening_transactions_connection_page_info:
48
+ PageInfoToJson(obj.pageInfo),
49
+ withdrawal_request_to_channel_opening_transactions_connection_count:
50
+ obj.count,
51
+ withdrawal_request_to_channel_opening_transactions_connection_entities:
52
+ obj.entities.map((e) => ChannelOpeningTransactionToJson(e)),
53
+ };
54
+ };
40
55
 
41
56
  export const FRAGMENT = `
42
57
  fragment WithdrawalRequestToChannelOpeningTransactionsConnectionFragment on WithdrawalRequestToChannelOpeningTransactionsConnection {
@@ -68,7 +68,10 @@ export {
68
68
  default as LightningTransaction,
69
69
  getLightningTransactionQuery,
70
70
  } from "./LightningTransaction.js";
71
- export { default as LightsparkNode } from "./LightsparkNode.js";
71
+ export {
72
+ default as LightsparkNode,
73
+ getLightsparkNodeQuery,
74
+ } from "./LightsparkNode.js";
72
75
  export {
73
76
  default as LightsparkNodeOwner,
74
77
  getLightsparkNodeOwnerQuery,
@@ -77,7 +80,7 @@ export { default as LightsparkNodeStatus } from "./LightsparkNodeStatus.js";
77
80
  export { default as LightsparkNodeToChannelsConnection } from "./LightsparkNodeToChannelsConnection.js";
78
81
  export { default as LightsparkNodeWithOSK } from "./LightsparkNodeWithOSK.js";
79
82
  export { default as LightsparkNodeWithRemoteSigning } from "./LightsparkNodeWithRemoteSigning.js";
80
- export { default as Node } from "./Node.js";
83
+ export { default as Node, getNodeQuery } from "./Node.js";
81
84
  export { default as NodeAddress } from "./NodeAddress.js";
82
85
  export { default as NodeAddressType } from "./NodeAddressType.js";
83
86
  export { default as NodeToAddressesConnection } from "./NodeToAddressesConnection.js";
@@ -0,0 +1,18 @@
1
+ import {
2
+ InvoiceDataFromJson,
3
+ InvoiceDataToJson,
4
+ } from "../objects/InvoiceData.js";
5
+
6
+ describe("Serialization", () => {
7
+ test("should serialize and deserialize InvoiceData to the same object", async () => {
8
+ const serialized = `{"__typename": "InvoiceData", "invoice_data_encoded_payment_request":"lnbcrt34170n1pj5vdn4pp56jhw0672v566u4rvl333v8hwwuvavvu9gx4a2mqag4pkrvm0hwkqhp5xaz278y6cejcvpqnndl4wfq3slgthjduwlfksg778aevn23v2pdscqzpgxqyz5vqsp5ee5jezfvjqvvz7hfwta3ekk8hs6dq36szkgp40qh7twa8upquxlq9qyyssqjg2slc95falxf2t67y0wu2w43qwfcvfflwl8tn4ppqw9tumwqxk36qkfct9p2w8c3yy2ld7c6nacy4ssv2gl6qyqfpmhl4jmarnjf8cpvjlxek","invoice_data_bitcoin_network":"REGTEST","invoice_data_payment_hash":"d4aee7ebca6535ae546cfc63161eee7719d6338541abd56c1d454361b36fbbac","invoice_data_amount":{"currency_amount_original_value":3417,"currency_amount_original_unit":"SATOSHI","currency_amount_preferred_currency_unit":"USD","currency_amount_preferred_currency_value_rounded":118,"currency_amount_preferred_currency_value_approx":118.89352818371607},"invoice_data_created_at":"2023-11-04T12:17:57Z","invoice_data_expires_at":"2023-11-05T12:17:57Z","invoice_data_memo":null,"invoice_data_destination":{"graph_node_id":"GraphNode:0189a572-6dba-cf00-0000-ac0908d34ea6","graph_node_created_at":"2023-07-30T06:18:07.162759Z","graph_node_updated_at":"2023-11-04T12:01:04.015414Z","graph_node_alias":"ls_test_vSViIQitob_SE","graph_node_bitcoin_network":"REGTEST","graph_node_color":"#3399ff","graph_node_conductivity":null,"graph_node_display_name":"ls_test_vSViIQitob_SE","graph_node_public_key":"02253935a5703a6f0429081e08d2defce0faa15f4d75305302284751d53a4e0608", "__typename":"GraphNode"}}`;
9
+ const deserialized = InvoiceDataFromJson(JSON.parse(serialized));
10
+ const reserialized = InvoiceDataToJson(deserialized);
11
+ expect(reserialized).toEqual(JSON.parse(serialized));
12
+
13
+ const deserializedAgain = InvoiceDataFromJson(reserialized);
14
+ expect(JSON.stringify(deserializedAgain)).toEqual(
15
+ JSON.stringify(deserialized),
16
+ );
17
+ });
18
+ });