@lightsparkdev/lightspark-sdk 1.1.6 → 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 (123) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/dist/{chunk-7UNNCH5S.js → chunk-VTPDR6P4.js} +1270 -342
  3. package/dist/{index-5235e43b.d.ts → index-f040db9f.d.ts} +707 -407
  4. package/dist/index.cjs +1247 -319
  5. package/dist/index.d.ts +2 -2
  6. package/dist/index.js +7 -7
  7. package/dist/objects/index.cjs +1180 -306
  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 +175 -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 +66 -6
  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 +184 -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/HtlcAttemptFailureCode.ts +2 -0
  53. package/src/objects/IdAndSignature.ts +8 -2
  54. package/src/objects/IncomingPayment.ts +33 -7
  55. package/src/objects/IncomingPaymentAttempt.ts +21 -5
  56. package/src/objects/IncomingPaymentToAttemptsConnection.ts +21 -5
  57. package/src/objects/Invoice.ts +91 -24
  58. package/src/objects/InvoiceData.ts +75 -6
  59. package/src/objects/LightningFeeEstimateForInvoiceInput.ts +13 -3
  60. package/src/objects/LightningFeeEstimateForNodeInput.ts +12 -2
  61. package/src/objects/LightningFeeEstimateOutput.ts +15 -3
  62. package/src/objects/LightningTransaction.ts +171 -28
  63. package/src/objects/LightsparkNode.ts +311 -208
  64. package/src/objects/LightsparkNodeOwner.ts +35 -4
  65. package/src/objects/LightsparkNodeToChannelsConnection.ts +17 -4
  66. package/src/objects/LightsparkNodeWithOSK.ts +97 -15
  67. package/src/objects/LightsparkNodeWithRemoteSigning.ts +93 -13
  68. package/src/objects/Node.ts +269 -67
  69. package/src/objects/NodeAddress.ts +8 -2
  70. package/src/objects/NodeToAddressesConnection.ts +13 -3
  71. package/src/objects/OnChainTransaction.ts +156 -44
  72. package/src/objects/OutgoingPayment.ts +127 -14
  73. package/src/objects/OutgoingPaymentAttempt.ts +57 -8
  74. package/src/objects/OutgoingPaymentAttemptToHopsConnection.ts +18 -5
  75. package/src/objects/OutgoingPaymentToAttemptsConnection.ts +17 -4
  76. package/src/objects/OutgoingPaymentsForInvoiceQueryInput.ts +12 -3
  77. package/src/objects/OutgoingPaymentsForInvoiceQueryOutput.ts +11 -2
  78. package/src/objects/PageInfo.ts +14 -6
  79. package/src/objects/PayInvoiceInput.ts +12 -3
  80. package/src/objects/PayInvoiceOutput.ts +7 -2
  81. package/src/objects/PayUmaInvoiceInput.ts +12 -3
  82. package/src/objects/PaymentRequest.ts +81 -5
  83. package/src/objects/PaymentRequestData.ts +81 -4
  84. package/src/objects/PostTransactionData.ts +12 -3
  85. package/src/objects/RegisterPaymentInput.ts +10 -2
  86. package/src/objects/RegisterPaymentOutput.ts +9 -2
  87. package/src/objects/ReleaseChannelPerCommitmentSecretInput.ts +13 -2
  88. package/src/objects/ReleaseChannelPerCommitmentSecretOutput.ts +9 -2
  89. package/src/objects/ReleasePaymentPreimageInput.ts +10 -2
  90. package/src/objects/ReleasePaymentPreimageOutput.ts +9 -2
  91. package/src/objects/RequestWithdrawalInput.ts +12 -2
  92. package/src/objects/RequestWithdrawalOutput.ts +9 -2
  93. package/src/objects/RichText.ts +7 -2
  94. package/src/objects/RoutingTransaction.ts +62 -41
  95. package/src/objects/ScreenNodeInput.ts +8 -2
  96. package/src/objects/ScreenNodeOutput.ts +7 -2
  97. package/src/objects/Secret.ts +8 -2
  98. package/src/objects/SendPaymentInput.ts +11 -2
  99. package/src/objects/SendPaymentOutput.ts +7 -2
  100. package/src/objects/SetInvoicePaymentHashInput.ts +12 -3
  101. package/src/objects/SetInvoicePaymentHashOutput.ts +9 -2
  102. package/src/objects/SignInvoiceInput.ts +9 -2
  103. package/src/objects/SignInvoiceOutput.ts +7 -2
  104. package/src/objects/SignMessagesInput.ts +13 -3
  105. package/src/objects/SignMessagesOutput.ts +13 -3
  106. package/src/objects/Signable.ts +10 -3
  107. package/src/objects/SignablePayload.ts +18 -5
  108. package/src/objects/Transaction.ts +260 -9
  109. package/src/objects/TransactionFailures.ts +11 -4
  110. package/src/objects/UpdateChannelPerCommitmentPointInput.ts +13 -2
  111. package/src/objects/UpdateChannelPerCommitmentPointOutput.ts +9 -2
  112. package/src/objects/UpdateNodeSharedSecretInput.ts +10 -2
  113. package/src/objects/UpdateNodeSharedSecretOutput.ts +9 -2
  114. package/src/objects/Wallet.ts +130 -5
  115. package/src/objects/WalletToPaymentRequestsConnection.ts +21 -5
  116. package/src/objects/WalletToTransactionsConnection.ts +16 -5
  117. package/src/objects/Withdrawal.ts +77 -61
  118. package/src/objects/WithdrawalRequest.ts +25 -4
  119. package/src/objects/WithdrawalRequestToChannelClosingTransactionsConnection.ts +19 -4
  120. package/src/objects/WithdrawalRequestToChannelOpeningTransactionsConnection.ts +19 -4
  121. package/src/objects/index.ts +5 -2
  122. package/src/tests/integration/client.test.ts +46 -7
  123. package/src/tests/serialization.test.ts +18 -0
@@ -1,231 +1,141 @@
1
1
  // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
2
2
 
3
3
  import { LightsparkException, type Query } from "@lightsparkdev/core";
4
- import autoBind from "auto-bind";
5
4
  import type LightsparkClient from "../client.js";
5
+ import type Balances from "./Balances.js";
6
+ import { BalancesFromJson, BalancesToJson } from "./Balances.js";
6
7
  import BitcoinNetwork from "./BitcoinNetwork.js";
7
8
  import type BlockchainBalance from "./BlockchainBalance.js";
8
- import { BlockchainBalanceFromJson } from "./BlockchainBalance.js";
9
+ import {
10
+ BlockchainBalanceFromJson,
11
+ BlockchainBalanceToJson,
12
+ } from "./BlockchainBalance.js";
9
13
  import type ChannelStatus from "./ChannelStatus.js";
10
14
  import type CurrencyAmount from "./CurrencyAmount.js";
11
- import { CurrencyAmountFromJson } from "./CurrencyAmount.js";
15
+ import {
16
+ CurrencyAmountFromJson,
17
+ CurrencyAmountToJson,
18
+ } from "./CurrencyAmount.js";
12
19
  import LightsparkNodeStatus from "./LightsparkNodeStatus.js";
13
20
  import type LightsparkNodeToChannelsConnection from "./LightsparkNodeToChannelsConnection.js";
14
- import { LightsparkNodeToChannelsConnectionFromJson } from "./LightsparkNodeToChannelsConnection.js";
15
21
  import LightsparkNodeWithOSK from "./LightsparkNodeWithOSK.js";
16
22
  import LightsparkNodeWithRemoteSigning from "./LightsparkNodeWithRemoteSigning.js";
17
- import type Node from "./Node.js";
18
23
  import type NodeAddressType from "./NodeAddressType.js";
19
24
  import type NodeToAddressesConnection from "./NodeToAddressesConnection.js";
20
- import { NodeToAddressesConnectionFromJson } from "./NodeToAddressesConnection.js";
21
- import { SecretFromJson } from "./Secret.js";
25
+ import { SecretFromJson, SecretToJson } from "./Secret.js";
22
26
 
23
27
  /** This is an object representing a node managed by Lightspark and owned by the current connected account. This object contains information about the node’s configuration, state, and metadata. **/
24
- class LightsparkNode implements Node {
25
- constructor(
26
- public readonly id: string,
27
- public readonly createdAt: string,
28
- public readonly updatedAt: string,
29
- public readonly bitcoinNetwork: BitcoinNetwork,
30
- public readonly displayName: string,
31
- public readonly ownerId: string,
32
- public readonly umaPrescreeningUtxos: string[],
33
- public readonly typename: string,
34
- public readonly alias?: string,
35
- public readonly color?: string,
36
- public readonly conductivity?: number,
37
- public readonly publicKey?: string,
38
- public readonly status?: LightsparkNodeStatus,
39
- public readonly totalBalance?: CurrencyAmount,
40
- public readonly totalLocalBalance?: CurrencyAmount,
41
- public readonly localBalance?: CurrencyAmount,
42
- public readonly remoteBalance?: CurrencyAmount,
43
- public readonly blockchainBalance?: BlockchainBalance,
44
- ) {
45
- autoBind(this);
46
- }
28
+ interface LightsparkNode {
29
+ /**
30
+ * The unique identifier of this entity across all Lightspark systems. Should be treated as an opaque
31
+ * string.
32
+ **/
33
+ id: string;
47
34
 
48
- public async getAddresses(
49
- client: LightsparkClient,
50
- first: number | undefined = undefined,
51
- types: NodeAddressType[] | undefined = undefined,
52
- ): Promise<NodeToAddressesConnection> {
53
- return (await client.executeRawQuery({
54
- queryPayload: `
55
- query FetchNodeToAddressesConnection($entity_id: ID!, $first: Int, $types: [NodeAddressType!]) {
56
- entity(id: $entity_id) {
57
- ... on LightsparkNode {
58
- addresses(, first: $first, types: $types) {
59
- __typename
60
- node_to_addresses_connection_count: count
61
- node_to_addresses_connection_entities: entities {
62
- __typename
63
- node_address_address: address
64
- node_address_type: type
65
- }
66
- }
67
- }
68
- }
69
- }
70
- `,
71
- variables: { entity_id: this.id, first: first, types: types },
72
- constructObject: (json) => {
73
- const connection = json["entity"]["addresses"];
74
- return NodeToAddressesConnectionFromJson(connection);
75
- },
76
- }))!;
77
- }
35
+ /** The date and time when the entity was first created. **/
36
+ createdAt: string;
78
37
 
79
- public async getChannels(
80
- client: LightsparkClient,
81
- first: number | undefined = undefined,
82
- statuses: ChannelStatus[] | undefined = undefined,
83
- after: string | undefined = undefined,
84
- ): Promise<LightsparkNodeToChannelsConnection> {
85
- return (await client.executeRawQuery({
86
- queryPayload: `
87
- query FetchLightsparkNodeToChannelsConnection($entity_id: ID!, $first: Int, $statuses: [ChannelStatus!], $after: String) {
88
- entity(id: $entity_id) {
89
- ... on LightsparkNode {
90
- channels(, first: $first, statuses: $statuses, after: $after) {
91
- __typename
92
- lightspark_node_to_channels_connection_count: count
93
- lightspark_node_to_channels_connection_page_info: page_info {
94
- __typename
95
- page_info_has_next_page: has_next_page
96
- page_info_has_previous_page: has_previous_page
97
- page_info_start_cursor: start_cursor
98
- page_info_end_cursor: end_cursor
99
- }
100
- lightspark_node_to_channels_connection_entities: entities {
101
- __typename
102
- channel_id: id
103
- channel_created_at: created_at
104
- channel_updated_at: updated_at
105
- channel_funding_transaction: funding_transaction {
106
- id
107
- }
108
- channel_capacity: capacity {
109
- __typename
110
- currency_amount_original_value: original_value
111
- currency_amount_original_unit: original_unit
112
- currency_amount_preferred_currency_unit: preferred_currency_unit
113
- currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
114
- currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
115
- }
116
- channel_local_balance: local_balance {
117
- __typename
118
- currency_amount_original_value: original_value
119
- currency_amount_original_unit: original_unit
120
- currency_amount_preferred_currency_unit: preferred_currency_unit
121
- currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
122
- currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
123
- }
124
- channel_local_unsettled_balance: local_unsettled_balance {
125
- __typename
126
- currency_amount_original_value: original_value
127
- currency_amount_original_unit: original_unit
128
- currency_amount_preferred_currency_unit: preferred_currency_unit
129
- currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
130
- currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
131
- }
132
- channel_remote_balance: remote_balance {
133
- __typename
134
- currency_amount_original_value: original_value
135
- currency_amount_original_unit: original_unit
136
- currency_amount_preferred_currency_unit: preferred_currency_unit
137
- currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
138
- currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
139
- }
140
- channel_remote_unsettled_balance: remote_unsettled_balance {
141
- __typename
142
- currency_amount_original_value: original_value
143
- currency_amount_original_unit: original_unit
144
- currency_amount_preferred_currency_unit: preferred_currency_unit
145
- currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
146
- currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
147
- }
148
- channel_unsettled_balance: unsettled_balance {
149
- __typename
150
- currency_amount_original_value: original_value
151
- currency_amount_original_unit: original_unit
152
- currency_amount_preferred_currency_unit: preferred_currency_unit
153
- currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
154
- currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
155
- }
156
- channel_total_balance: total_balance {
157
- __typename
158
- currency_amount_original_value: original_value
159
- currency_amount_original_unit: original_unit
160
- currency_amount_preferred_currency_unit: preferred_currency_unit
161
- currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
162
- currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
163
- }
164
- channel_status: status
165
- channel_estimated_force_closure_wait_minutes: estimated_force_closure_wait_minutes
166
- channel_commit_fee: commit_fee {
167
- __typename
168
- currency_amount_original_value: original_value
169
- currency_amount_original_unit: original_unit
170
- currency_amount_preferred_currency_unit: preferred_currency_unit
171
- currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
172
- currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
173
- }
174
- channel_fees: fees {
175
- __typename
176
- channel_fees_base_fee: base_fee {
177
- __typename
178
- currency_amount_original_value: original_value
179
- currency_amount_original_unit: original_unit
180
- currency_amount_preferred_currency_unit: preferred_currency_unit
181
- currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
182
- currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
183
- }
184
- channel_fees_fee_rate_per_mil: fee_rate_per_mil
185
- }
186
- channel_remote_node: remote_node {
187
- id
188
- }
189
- channel_local_node: local_node {
190
- id
191
- }
192
- channel_short_channel_id: short_channel_id
193
- }
194
- }
195
- }
196
- }
197
- }
198
- `,
199
- variables: {
200
- entity_id: this.id,
201
- first: first,
202
- statuses: statuses,
203
- after: after,
204
- },
205
- constructObject: (json) => {
206
- const connection = json["entity"]["channels"];
207
- return LightsparkNodeToChannelsConnectionFromJson(connection);
208
- },
209
- }))!;
210
- }
38
+ /** The date and time when the entity was last updated. **/
39
+ updatedAt: string;
211
40
 
212
- static getLightsparkNodeQuery(id: string): Query<LightsparkNode> {
213
- return {
214
- queryPayload: `
215
- query GetLightsparkNode($id: ID!) {
216
- entity(id: $id) {
217
- ... on LightsparkNode {
218
- ...LightsparkNodeFragment
219
- }
220
- }
221
- }
41
+ /** The Bitcoin Network this node is deployed in. **/
42
+ bitcoinNetwork: BitcoinNetwork;
222
43
 
223
- ${FRAGMENT}
224
- `,
225
- variables: { id },
226
- constructObject: (data: any) => LightsparkNodeFromJson(data.entity),
227
- };
228
- }
44
+ /**
45
+ * The name of this node in the network. It will be the most human-readable option possible, depending
46
+ * on the data available for this node.
47
+ **/
48
+ displayName: string;
49
+
50
+ /** The owner of this LightsparkNode. **/
51
+ ownerId: string;
52
+
53
+ /**
54
+ * The utxos of the channels that are connected to this node. This is used in uma flow for
55
+ * pre-screening.
56
+ **/
57
+ umaPrescreeningUtxos: string[];
58
+
59
+ /** The typename of the object **/
60
+ typename: string;
61
+
62
+ /**
63
+ * A name that identifies the node. It has no importance in terms of operating the node, it is just a
64
+ * way to identify and search for commercial services or popular nodes. This alias can be changed at
65
+ * any time by the node operator.
66
+ **/
67
+ alias?: string | undefined;
68
+
69
+ /**
70
+ * A hexadecimal string that describes a color. For example "#000000" is black, "#FFFFFF" is white. It
71
+ * has no importance in terms of operating the node, it is just a way to visually differentiate nodes.
72
+ * That color can be changed at any time by the node operator.
73
+ **/
74
+ color?: string | undefined;
75
+
76
+ /**
77
+ * A summary metric used to capture how well positioned a node is to send, receive, or route
78
+ * transactions efficiently. Maximizing a node's conductivity helps a node’s transactions to be
79
+ * capital efficient. The value is an integer ranging between 0 and 10 (bounds included).
80
+ **/
81
+ conductivity?: number | undefined;
82
+
83
+ /** The public key of this node. It acts as a unique identifier of this node in the Lightning Network. **/
84
+ publicKey?: string | undefined;
85
+
86
+ /** The current status of this node. **/
87
+ status?: LightsparkNodeStatus | undefined;
88
+
89
+ /**
90
+ * The sum of the balance on the Bitcoin Network, channel balances, and commit fees on this node.
91
+ *
92
+ * @deprecated Use `balances` instead.
93
+ **/
94
+ totalBalance?: CurrencyAmount | undefined;
95
+
96
+ /**
97
+ * The total sum of the channel balances (online and offline) on this node.
98
+ *
99
+ * @deprecated Use `balances` instead.
100
+ **/
101
+ totalLocalBalance?: CurrencyAmount | undefined;
102
+
103
+ /**
104
+ * The sum of the channel balances (online only) that are available to send on this node.
105
+ *
106
+ * @deprecated Use `balances` instead.
107
+ **/
108
+ localBalance?: CurrencyAmount | undefined;
109
+
110
+ /**
111
+ * The sum of the channel balances that are available to receive on this node.
112
+ *
113
+ * @deprecated Use `balances` instead.
114
+ **/
115
+ remoteBalance?: CurrencyAmount | undefined;
116
+
117
+ /**
118
+ * The details of the balance of this node on the Bitcoin Network.
119
+ *
120
+ * @deprecated Use `balances` instead.
121
+ **/
122
+ blockchainBalance?: BlockchainBalance | undefined;
123
+
124
+ /** The balances that describe the funds in this node. **/
125
+ balances?: Balances | undefined;
126
+
127
+ getAddresses(
128
+ client: LightsparkClient,
129
+ first?: number | undefined,
130
+ types?: NodeAddressType[] | undefined,
131
+ ): Promise<NodeToAddressesConnection>;
132
+
133
+ getChannels(
134
+ client: LightsparkClient,
135
+ first?: number | undefined,
136
+ statuses?: ChannelStatus[] | undefined,
137
+ after?: string | undefined,
138
+ ): Promise<LightsparkNodeToChannelsConnection>;
229
139
  }
230
140
 
231
141
  export const LightsparkNodeFromJson = (obj: any): LightsparkNode => {
@@ -273,6 +183,9 @@ export const LightsparkNodeFromJson = (obj: any): LightsparkNode => {
273
183
  obj["lightspark_node_with_o_s_k_blockchain_balance"],
274
184
  )
275
185
  : undefined,
186
+ !!obj["lightspark_node_with_o_s_k_balances"]
187
+ ? BalancesFromJson(obj["lightspark_node_with_o_s_k_balances"])
188
+ : undefined,
276
189
  !!obj["lightspark_node_with_o_s_k_encrypted_signing_private_key"]
277
190
  ? SecretFromJson(
278
191
  obj["lightspark_node_with_o_s_k_encrypted_signing_private_key"],
@@ -326,6 +239,9 @@ export const LightsparkNodeFromJson = (obj: any): LightsparkNode => {
326
239
  obj["lightspark_node_with_remote_signing_blockchain_balance"],
327
240
  )
328
241
  : undefined,
242
+ !!obj["lightspark_node_with_remote_signing_balances"]
243
+ ? BalancesFromJson(obj["lightspark_node_with_remote_signing_balances"])
244
+ : undefined,
329
245
  );
330
246
  }
331
247
  throw new LightsparkException(
@@ -333,6 +249,121 @@ export const LightsparkNodeFromJson = (obj: any): LightsparkNode => {
333
249
  `Couldn't find a concrete type for interface LightsparkNode corresponding to the typename=${obj["__typename"]}`,
334
250
  );
335
251
  };
252
+ export const LightsparkNodeToJson = (obj: LightsparkNode): any => {
253
+ if (obj.typename == "LightsparkNodeWithOSK") {
254
+ const lightsparkNodeWithOSK = obj as LightsparkNodeWithOSK;
255
+ return {
256
+ __typename: "LightsparkNodeWithOSK",
257
+ lightspark_node_with_o_s_k_id: lightsparkNodeWithOSK.id,
258
+ lightspark_node_with_o_s_k_created_at: lightsparkNodeWithOSK.createdAt,
259
+ lightspark_node_with_o_s_k_updated_at: lightsparkNodeWithOSK.updatedAt,
260
+ lightspark_node_with_o_s_k_alias: lightsparkNodeWithOSK.alias,
261
+ lightspark_node_with_o_s_k_bitcoin_network:
262
+ lightsparkNodeWithOSK.bitcoinNetwork,
263
+ lightspark_node_with_o_s_k_color: lightsparkNodeWithOSK.color,
264
+ lightspark_node_with_o_s_k_conductivity:
265
+ lightsparkNodeWithOSK.conductivity,
266
+ lightspark_node_with_o_s_k_display_name:
267
+ lightsparkNodeWithOSK.displayName,
268
+ lightspark_node_with_o_s_k_public_key: lightsparkNodeWithOSK.publicKey,
269
+ lightspark_node_with_o_s_k_owner: { id: lightsparkNodeWithOSK.ownerId },
270
+ lightspark_node_with_o_s_k_status: lightsparkNodeWithOSK.status,
271
+ lightspark_node_with_o_s_k_total_balance:
272
+ lightsparkNodeWithOSK.totalBalance
273
+ ? CurrencyAmountToJson(lightsparkNodeWithOSK.totalBalance)
274
+ : undefined,
275
+ lightspark_node_with_o_s_k_total_local_balance:
276
+ lightsparkNodeWithOSK.totalLocalBalance
277
+ ? CurrencyAmountToJson(lightsparkNodeWithOSK.totalLocalBalance)
278
+ : undefined,
279
+ lightspark_node_with_o_s_k_local_balance:
280
+ lightsparkNodeWithOSK.localBalance
281
+ ? CurrencyAmountToJson(lightsparkNodeWithOSK.localBalance)
282
+ : undefined,
283
+ lightspark_node_with_o_s_k_remote_balance:
284
+ lightsparkNodeWithOSK.remoteBalance
285
+ ? CurrencyAmountToJson(lightsparkNodeWithOSK.remoteBalance)
286
+ : undefined,
287
+ lightspark_node_with_o_s_k_blockchain_balance:
288
+ lightsparkNodeWithOSK.blockchainBalance
289
+ ? BlockchainBalanceToJson(lightsparkNodeWithOSK.blockchainBalance)
290
+ : undefined,
291
+ lightspark_node_with_o_s_k_uma_prescreening_utxos:
292
+ lightsparkNodeWithOSK.umaPrescreeningUtxos,
293
+ lightspark_node_with_o_s_k_balances: lightsparkNodeWithOSK.balances
294
+ ? BalancesToJson(lightsparkNodeWithOSK.balances)
295
+ : undefined,
296
+ lightspark_node_with_o_s_k_encrypted_signing_private_key:
297
+ lightsparkNodeWithOSK.encryptedSigningPrivateKey
298
+ ? SecretToJson(lightsparkNodeWithOSK.encryptedSigningPrivateKey)
299
+ : undefined,
300
+ };
301
+ }
302
+ if (obj.typename == "LightsparkNodeWithRemoteSigning") {
303
+ const lightsparkNodeWithRemoteSigning =
304
+ obj as LightsparkNodeWithRemoteSigning;
305
+ return {
306
+ __typename: "LightsparkNodeWithRemoteSigning",
307
+ lightspark_node_with_remote_signing_id:
308
+ lightsparkNodeWithRemoteSigning.id,
309
+ lightspark_node_with_remote_signing_created_at:
310
+ lightsparkNodeWithRemoteSigning.createdAt,
311
+ lightspark_node_with_remote_signing_updated_at:
312
+ lightsparkNodeWithRemoteSigning.updatedAt,
313
+ lightspark_node_with_remote_signing_alias:
314
+ lightsparkNodeWithRemoteSigning.alias,
315
+ lightspark_node_with_remote_signing_bitcoin_network:
316
+ lightsparkNodeWithRemoteSigning.bitcoinNetwork,
317
+ lightspark_node_with_remote_signing_color:
318
+ lightsparkNodeWithRemoteSigning.color,
319
+ lightspark_node_with_remote_signing_conductivity:
320
+ lightsparkNodeWithRemoteSigning.conductivity,
321
+ lightspark_node_with_remote_signing_display_name:
322
+ lightsparkNodeWithRemoteSigning.displayName,
323
+ lightspark_node_with_remote_signing_public_key:
324
+ lightsparkNodeWithRemoteSigning.publicKey,
325
+ lightspark_node_with_remote_signing_owner: {
326
+ id: lightsparkNodeWithRemoteSigning.ownerId,
327
+ },
328
+ lightspark_node_with_remote_signing_status:
329
+ lightsparkNodeWithRemoteSigning.status,
330
+ lightspark_node_with_remote_signing_total_balance:
331
+ lightsparkNodeWithRemoteSigning.totalBalance
332
+ ? CurrencyAmountToJson(lightsparkNodeWithRemoteSigning.totalBalance)
333
+ : undefined,
334
+ lightspark_node_with_remote_signing_total_local_balance:
335
+ lightsparkNodeWithRemoteSigning.totalLocalBalance
336
+ ? CurrencyAmountToJson(
337
+ lightsparkNodeWithRemoteSigning.totalLocalBalance,
338
+ )
339
+ : undefined,
340
+ lightspark_node_with_remote_signing_local_balance:
341
+ lightsparkNodeWithRemoteSigning.localBalance
342
+ ? CurrencyAmountToJson(lightsparkNodeWithRemoteSigning.localBalance)
343
+ : undefined,
344
+ lightspark_node_with_remote_signing_remote_balance:
345
+ lightsparkNodeWithRemoteSigning.remoteBalance
346
+ ? CurrencyAmountToJson(lightsparkNodeWithRemoteSigning.remoteBalance)
347
+ : undefined,
348
+ lightspark_node_with_remote_signing_blockchain_balance:
349
+ lightsparkNodeWithRemoteSigning.blockchainBalance
350
+ ? BlockchainBalanceToJson(
351
+ lightsparkNodeWithRemoteSigning.blockchainBalance,
352
+ )
353
+ : undefined,
354
+ lightspark_node_with_remote_signing_uma_prescreening_utxos:
355
+ lightsparkNodeWithRemoteSigning.umaPrescreeningUtxos,
356
+ lightspark_node_with_remote_signing_balances:
357
+ lightsparkNodeWithRemoteSigning.balances
358
+ ? BalancesToJson(lightsparkNodeWithRemoteSigning.balances)
359
+ : undefined,
360
+ };
361
+ }
362
+ throw new LightsparkException(
363
+ "DeserializationError",
364
+ `Couldn't find a concrete type for interface LightsparkNode corresponding to the typename=${obj.typename}`,
365
+ );
366
+ };
336
367
 
337
368
  export const FRAGMENT = `
338
369
  fragment LightsparkNodeFragment on LightsparkNode {
@@ -436,6 +467,33 @@ fragment LightsparkNodeFragment on LightsparkNode {
436
467
  }
437
468
  }
438
469
  lightspark_node_with_o_s_k_uma_prescreening_utxos: uma_prescreening_utxos
470
+ lightspark_node_with_o_s_k_balances: balances {
471
+ __typename
472
+ balances_owned_balance: owned_balance {
473
+ __typename
474
+ currency_amount_original_value: original_value
475
+ currency_amount_original_unit: original_unit
476
+ currency_amount_preferred_currency_unit: preferred_currency_unit
477
+ currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
478
+ currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
479
+ }
480
+ balances_available_to_send_balance: available_to_send_balance {
481
+ __typename
482
+ currency_amount_original_value: original_value
483
+ currency_amount_original_unit: original_unit
484
+ currency_amount_preferred_currency_unit: preferred_currency_unit
485
+ currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
486
+ currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
487
+ }
488
+ balances_available_to_withdraw_balance: available_to_withdraw_balance {
489
+ __typename
490
+ currency_amount_original_value: original_value
491
+ currency_amount_original_unit: original_unit
492
+ currency_amount_preferred_currency_unit: preferred_currency_unit
493
+ currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
494
+ currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
495
+ }
496
+ }
439
497
  lightspark_node_with_o_s_k_encrypted_signing_private_key: encrypted_signing_private_key {
440
498
  __typename
441
499
  secret_encrypted_value: encrypted_value
@@ -541,7 +599,52 @@ fragment LightsparkNodeFragment on LightsparkNode {
541
599
  }
542
600
  }
543
601
  lightspark_node_with_remote_signing_uma_prescreening_utxos: uma_prescreening_utxos
602
+ lightspark_node_with_remote_signing_balances: balances {
603
+ __typename
604
+ balances_owned_balance: owned_balance {
605
+ __typename
606
+ currency_amount_original_value: original_value
607
+ currency_amount_original_unit: original_unit
608
+ currency_amount_preferred_currency_unit: preferred_currency_unit
609
+ currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
610
+ currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
611
+ }
612
+ balances_available_to_send_balance: available_to_send_balance {
613
+ __typename
614
+ currency_amount_original_value: original_value
615
+ currency_amount_original_unit: original_unit
616
+ currency_amount_preferred_currency_unit: preferred_currency_unit
617
+ currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
618
+ currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
619
+ }
620
+ balances_available_to_withdraw_balance: available_to_withdraw_balance {
621
+ __typename
622
+ currency_amount_original_value: original_value
623
+ currency_amount_original_unit: original_unit
624
+ currency_amount_preferred_currency_unit: preferred_currency_unit
625
+ currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
626
+ currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
627
+ }
628
+ }
544
629
  }
545
630
  }`;
546
631
 
632
+ export const getLightsparkNodeQuery = (id: string): Query<LightsparkNode> => {
633
+ return {
634
+ queryPayload: `
635
+ query GetLightsparkNode($id: ID!) {
636
+ entity(id: $id) {
637
+ ... on LightsparkNode {
638
+ ...LightsparkNodeFragment
639
+ }
640
+ }
641
+ }
642
+
643
+ ${FRAGMENT}
644
+ `,
645
+ variables: { id },
646
+ constructObject: (data: any) => LightsparkNodeFromJson(data.entity),
647
+ };
648
+ };
649
+
547
650
  export default LightsparkNode;
@@ -2,13 +2,12 @@
2
2
 
3
3
  import { LightsparkException, type Query } from "@lightsparkdev/core";
4
4
  import Account from "./Account.js";
5
- import { BalancesFromJson } from "./Balances.js";
6
- import type Entity from "./Entity.js";
5
+ import { BalancesFromJson, BalancesToJson } from "./Balances.js";
7
6
  import Wallet from "./Wallet.js";
8
7
  import WalletStatus from "./WalletStatus.js";
9
8
 
10
9
  /** This is an object representing the owner of a LightsparkNode. **/
11
- type LightsparkNodeOwner = Entity & {
10
+ interface LightsparkNodeOwner {
12
11
  /**
13
12
  * The unique identifier of this entity across all Lightspark systems. Should be treated as an opaque
14
13
  * string.
@@ -23,7 +22,7 @@ type LightsparkNodeOwner = Entity & {
23
22
 
24
23
  /** The typename of the object **/
25
24
  typename: string;
26
- };
25
+ }
27
26
 
28
27
  export const LightsparkNodeOwnerFromJson = (obj: any): LightsparkNodeOwner => {
29
28
  if (obj["__typename"] == "Account") {
@@ -55,6 +54,38 @@ export const LightsparkNodeOwnerFromJson = (obj: any): LightsparkNodeOwner => {
55
54
  `Couldn't find a concrete type for interface LightsparkNodeOwner corresponding to the typename=${obj["__typename"]}`,
56
55
  );
57
56
  };
57
+ export const LightsparkNodeOwnerToJson = (obj: LightsparkNodeOwner): any => {
58
+ if (obj.typename == "Account") {
59
+ const account = obj as Account;
60
+ return {
61
+ __typename: "Account",
62
+ account_id: account.id,
63
+ account_created_at: account.createdAt,
64
+ account_updated_at: account.updatedAt,
65
+ account_name: account.name,
66
+ };
67
+ }
68
+ if (obj.typename == "Wallet") {
69
+ const wallet = obj as Wallet;
70
+ return {
71
+ __typename: "Wallet",
72
+ wallet_id: wallet.id,
73
+ wallet_created_at: wallet.createdAt,
74
+ wallet_updated_at: wallet.updatedAt,
75
+ wallet_last_login_at: wallet.lastLoginAt,
76
+ wallet_balances: wallet.balances
77
+ ? BalancesToJson(wallet.balances)
78
+ : undefined,
79
+ wallet_third_party_identifier: wallet.thirdPartyIdentifier,
80
+ wallet_account: { id: wallet.accountId } ?? undefined,
81
+ wallet_status: wallet.status,
82
+ };
83
+ }
84
+ throw new LightsparkException(
85
+ "DeserializationError",
86
+ `Couldn't find a concrete type for interface LightsparkNodeOwner corresponding to the typename=${obj.typename}`,
87
+ );
88
+ };
58
89
 
59
90
  export const FRAGMENT = `
60
91
  fragment LightsparkNodeOwnerFragment on LightsparkNodeOwner {
@@ -2,11 +2,10 @@
2
2
 
3
3
  import type Channel from "./Channel.js";
4
4
  import { ChannelFromJson } from "./Channel.js";
5
- import type Connection from "./Connection.js";
6
5
  import type PageInfo from "./PageInfo.js";
7
- import { PageInfoFromJson } from "./PageInfo.js";
6
+ import { PageInfoFromJson, PageInfoToJson } from "./PageInfo.js";
8
7
 
9
- type LightsparkNodeToChannelsConnection = Connection & {
8
+ interface LightsparkNodeToChannelsConnection {
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 LightsparkNodeToChannelsConnection = Connection & {
21
20
 
22
21
  /** The typename of the object **/
23
22
  typename: string;
24
- };
23
+ }
25
24
 
26
25
  export const LightsparkNodeToChannelsConnectionFromJson = (
27
26
  obj: any,
@@ -37,6 +36,20 @@ export const LightsparkNodeToChannelsConnectionFromJson = (
37
36
  typename: "LightsparkNodeToChannelsConnection",
38
37
  } as LightsparkNodeToChannelsConnection;
39
38
  };
39
+ export const LightsparkNodeToChannelsConnectionToJson = (
40
+ obj: LightsparkNodeToChannelsConnection,
41
+ ): any => {
42
+ return {
43
+ __typename: "LightsparkNodeToChannelsConnection",
44
+ lightspark_node_to_channels_connection_count: obj.count,
45
+ lightspark_node_to_channels_connection_page_info: PageInfoToJson(
46
+ obj.pageInfo,
47
+ ),
48
+ lightspark_node_to_channels_connection_entities: obj.entities.map((e) =>
49
+ e.toJson(),
50
+ ),
51
+ };
52
+ };
40
53
 
41
54
  export const FRAGMENT = `
42
55
  fragment LightsparkNodeToChannelsConnectionFragment on LightsparkNodeToChannelsConnection {