@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,9 +1,9 @@
1
1
  // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
2
2
 
3
- type DeclineToSignMessagesInput = {
3
+ interface DeclineToSignMessagesInput {
4
4
  /** List of payload ids to decline to sign because validation failed. **/
5
5
  payloadIds: string[];
6
- };
6
+ }
7
7
 
8
8
  export const DeclineToSignMessagesInputFromJson = (
9
9
  obj: any,
@@ -12,5 +12,12 @@ export const DeclineToSignMessagesInputFromJson = (
12
12
  payloadIds: obj["decline_to_sign_messages_input_payload_ids"],
13
13
  } as DeclineToSignMessagesInput;
14
14
  };
15
+ export const DeclineToSignMessagesInputToJson = (
16
+ obj: DeclineToSignMessagesInput,
17
+ ): any => {
18
+ return {
19
+ decline_to_sign_messages_input_payload_ids: obj.payloadIds,
20
+ };
21
+ };
15
22
 
16
23
  export default DeclineToSignMessagesInput;
@@ -1,11 +1,14 @@
1
1
  // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
2
2
 
3
3
  import type SignablePayload from "./SignablePayload.js";
4
- import { SignablePayloadFromJson } from "./SignablePayload.js";
4
+ import {
5
+ SignablePayloadFromJson,
6
+ SignablePayloadToJson,
7
+ } from "./SignablePayload.js";
5
8
 
6
- type DeclineToSignMessagesOutput = {
9
+ interface DeclineToSignMessagesOutput {
7
10
  declinedPayloads: SignablePayload[];
8
- };
11
+ }
9
12
 
10
13
  export const DeclineToSignMessagesOutputFromJson = (
11
14
  obj: any,
@@ -16,6 +19,15 @@ export const DeclineToSignMessagesOutputFromJson = (
16
19
  ].map((e) => SignablePayloadFromJson(e)),
17
20
  } as DeclineToSignMessagesOutput;
18
21
  };
22
+ export const DeclineToSignMessagesOutputToJson = (
23
+ obj: DeclineToSignMessagesOutput,
24
+ ): any => {
25
+ return {
26
+ decline_to_sign_messages_output_declined_payloads: obj.declinedPayloads.map(
27
+ (e) => SignablePayloadToJson(e),
28
+ ),
29
+ };
30
+ };
19
31
 
20
32
  export const FRAGMENT = `
21
33
  fragment DeclineToSignMessagesOutputFragment on DeclineToSignMessagesOutput {
@@ -1,13 +1,18 @@
1
1
  // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
2
2
 
3
- type DeleteApiTokenInput = {
3
+ interface DeleteApiTokenInput {
4
4
  apiTokenId: string;
5
- };
5
+ }
6
6
 
7
7
  export const DeleteApiTokenInputFromJson = (obj: any): DeleteApiTokenInput => {
8
8
  return {
9
9
  apiTokenId: obj["delete_api_token_input_api_token_id"],
10
10
  } as DeleteApiTokenInput;
11
11
  };
12
+ export const DeleteApiTokenInputToJson = (obj: DeleteApiTokenInput): any => {
13
+ return {
14
+ delete_api_token_input_api_token_id: obj.apiTokenId,
15
+ };
16
+ };
12
17
 
13
18
  export default DeleteApiTokenInput;
@@ -1,8 +1,8 @@
1
1
  // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
2
2
 
3
- type DeleteApiTokenOutput = {
3
+ interface DeleteApiTokenOutput {
4
4
  accountId: string;
5
- };
5
+ }
6
6
 
7
7
  export const DeleteApiTokenOutputFromJson = (
8
8
  obj: any,
@@ -11,6 +11,11 @@ export const DeleteApiTokenOutputFromJson = (
11
11
  accountId: obj["delete_api_token_output_account"].id,
12
12
  } as DeleteApiTokenOutput;
13
13
  };
14
+ export const DeleteApiTokenOutputToJson = (obj: DeleteApiTokenOutput): any => {
15
+ return {
16
+ delete_api_token_output_account: { id: obj.accountId },
17
+ };
18
+ };
14
19
 
15
20
  export const FRAGMENT = `
16
21
  fragment DeleteApiTokenOutputFragment on DeleteApiTokenOutput {
@@ -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 a Deposit made to a Lightspark node wallet. This operation occurs for any L1 funding transaction to the wallet. You can retrieve this object to receive detailed information about the deposit. **/
12
- type Deposit = 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 recipient Lightspark node this deposit was sent to. **/
43
- destinationId: 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 Deposit {
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 recipient Lightspark node this deposit was sent to. **/
41
+ destinationId: 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 DepositFromJson = (obj: any): Deposit => {
71
69
  return {
@@ -89,6 +87,24 @@ export const DepositFromJson = (obj: any): Deposit => {
89
87
  numConfirmations: obj["deposit_num_confirmations"],
90
88
  } as Deposit;
91
89
  };
90
+ export const DepositToJson = (obj: Deposit): any => {
91
+ return {
92
+ __typename: "Deposit",
93
+ deposit_id: obj.id,
94
+ deposit_created_at: obj.createdAt,
95
+ deposit_updated_at: obj.updatedAt,
96
+ deposit_status: obj.status,
97
+ deposit_resolved_at: obj.resolvedAt,
98
+ deposit_amount: CurrencyAmountToJson(obj.amount),
99
+ deposit_transaction_hash: obj.transactionHash,
100
+ deposit_fees: obj.fees ? CurrencyAmountToJson(obj.fees) : undefined,
101
+ deposit_block_hash: obj.blockHash,
102
+ deposit_block_height: obj.blockHeight,
103
+ deposit_destination_addresses: obj.destinationAddresses,
104
+ deposit_num_confirmations: obj.numConfirmations,
105
+ deposit_destination: { id: obj.destinationId },
106
+ };
107
+ };
92
108
 
93
109
  export const FRAGMENT = `
94
110
  fragment DepositFragment on Deposit {
@@ -1,7 +1,7 @@
1
1
  // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
2
2
 
3
3
  /** This interface is used by all the entities in the Lightspark system. It defines a few core fields that are available everywhere. Any object that implements this interface can be queried using the `entity` query and its ID. **/
4
- type Entity = {
4
+ interface Entity {
5
5
  /**
6
6
  * The unique identifier of this entity across all Lightspark systems. Should be treated as an opaque
7
7
  * string.
@@ -16,7 +16,7 @@ type Entity = {
16
16
 
17
17
  /** The typename of the object **/
18
18
  typename: string;
19
- };
19
+ }
20
20
 
21
21
  export const FRAGMENT = `
22
22
  fragment EntityFragment on Entity {
@@ -1,14 +1,17 @@
1
1
  // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
2
2
 
3
3
  import type CurrencyAmount from "./CurrencyAmount.js";
4
- import { CurrencyAmountFromJson } from "./CurrencyAmount.js";
4
+ import {
5
+ CurrencyAmountFromJson,
6
+ CurrencyAmountToJson,
7
+ } from "./CurrencyAmount.js";
5
8
 
6
9
  /** This object represents the estimated L1 transaction fees for the Bitcoin network. Fee estimates are separated by potential confirmation speeds for settlement. **/
7
- type FeeEstimate = {
10
+ interface FeeEstimate {
8
11
  feeFast: CurrencyAmount;
9
12
 
10
13
  feeMin: CurrencyAmount;
11
- };
14
+ }
12
15
 
13
16
  export const FeeEstimateFromJson = (obj: any): FeeEstimate => {
14
17
  return {
@@ -16,6 +19,12 @@ export const FeeEstimateFromJson = (obj: any): FeeEstimate => {
16
19
  feeMin: CurrencyAmountFromJson(obj["fee_estimate_fee_min"]),
17
20
  } as FeeEstimate;
18
21
  };
22
+ export const FeeEstimateToJson = (obj: FeeEstimate): any => {
23
+ return {
24
+ fee_estimate_fee_fast: CurrencyAmountToJson(obj.feeFast),
25
+ fee_estimate_fee_min: CurrencyAmountToJson(obj.feeMin),
26
+ };
27
+ };
19
28
 
20
29
  export const FRAGMENT = `
21
30
  fragment FeeEstimateFragment on FeeEstimate {
@@ -1,10 +1,10 @@
1
1
  // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
2
2
 
3
- type FundNodeInput = {
3
+ interface FundNodeInput {
4
4
  nodeId: string;
5
5
 
6
- amountSats?: number;
7
- };
6
+ amountSats?: number | undefined;
7
+ }
8
8
 
9
9
  export const FundNodeInputFromJson = (obj: any): FundNodeInput => {
10
10
  return {
@@ -12,5 +12,11 @@ export const FundNodeInputFromJson = (obj: any): FundNodeInput => {
12
12
  amountSats: obj["fund_node_input_amount_sats"],
13
13
  } as FundNodeInput;
14
14
  };
15
+ export const FundNodeInputToJson = (obj: FundNodeInput): any => {
16
+ return {
17
+ fund_node_input_node_id: obj.nodeId,
18
+ fund_node_input_amount_sats: obj.amountSats,
19
+ };
20
+ };
15
21
 
16
22
  export default FundNodeInput;
@@ -1,17 +1,25 @@
1
1
  // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
2
2
 
3
3
  import type CurrencyAmount from "./CurrencyAmount.js";
4
- import { CurrencyAmountFromJson } from "./CurrencyAmount.js";
4
+ import {
5
+ CurrencyAmountFromJson,
6
+ CurrencyAmountToJson,
7
+ } from "./CurrencyAmount.js";
5
8
 
6
- type FundNodeOutput = {
9
+ interface FundNodeOutput {
7
10
  amount: CurrencyAmount;
8
- };
11
+ }
9
12
 
10
13
  export const FundNodeOutputFromJson = (obj: any): FundNodeOutput => {
11
14
  return {
12
15
  amount: CurrencyAmountFromJson(obj["fund_node_output_amount"]),
13
16
  } as FundNodeOutput;
14
17
  };
18
+ export const FundNodeOutputToJson = (obj: FundNodeOutput): any => {
19
+ return {
20
+ fund_node_output_amount: CurrencyAmountToJson(obj.amount),
21
+ };
22
+ };
15
23
 
16
24
  export const FRAGMENT = `
17
25
  fragment FundNodeOutputFragment on FundNodeOutput {
@@ -4,13 +4,14 @@ import { type Query } from "@lightsparkdev/core";
4
4
  import autoBind from "auto-bind";
5
5
  import type LightsparkClient from "../client.js";
6
6
  import BitcoinNetwork from "./BitcoinNetwork.js";
7
+ import type Entity from "./Entity.js";
7
8
  import type Node from "./Node.js";
8
9
  import type NodeAddressType from "./NodeAddressType.js";
9
10
  import type NodeToAddressesConnection from "./NodeToAddressesConnection.js";
10
11
  import { NodeToAddressesConnectionFromJson } from "./NodeToAddressesConnection.js";
11
12
 
12
13
  /** This object represents a node that exists on the Lightning Network, including nodes not managed by Lightspark. You can retrieve this object to get publicly available information about any node on the Lightning Network. **/
13
- class GraphNode implements Node {
14
+ class GraphNode implements Node, Entity {
14
15
  constructor(
15
16
  public readonly id: string,
16
17
  public readonly createdAt: string,
@@ -18,10 +19,10 @@ class GraphNode implements Node {
18
19
  public readonly bitcoinNetwork: BitcoinNetwork,
19
20
  public readonly displayName: string,
20
21
  public readonly typename: string,
21
- public readonly alias?: string,
22
- public readonly color?: string,
23
- public readonly conductivity?: number,
24
- public readonly publicKey?: string,
22
+ public readonly alias?: string | undefined,
23
+ public readonly color?: string | undefined,
24
+ public readonly conductivity?: number | undefined,
25
+ public readonly publicKey?: string | undefined,
25
26
  ) {
26
27
  autoBind(this);
27
28
  }
@@ -74,6 +75,21 @@ ${FRAGMENT}
74
75
  constructObject: (data: any) => GraphNodeFromJson(data.entity),
75
76
  };
76
77
  }
78
+
79
+ public toJson() {
80
+ return {
81
+ __typename: "GraphNode",
82
+ graph_node_id: this.id,
83
+ graph_node_created_at: this.createdAt,
84
+ graph_node_updated_at: this.updatedAt,
85
+ graph_node_alias: this.alias,
86
+ graph_node_bitcoin_network: this.bitcoinNetwork,
87
+ graph_node_color: this.color,
88
+ graph_node_conductivity: this.conductivity,
89
+ graph_node_display_name: this.displayName,
90
+ graph_node_public_key: this.publicKey,
91
+ };
92
+ }
77
93
  }
78
94
 
79
95
  export const GraphNodeFromJson = (obj: any): GraphNode => {
@@ -2,11 +2,13 @@
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";
5
+ import {
6
+ CurrencyAmountFromJson,
7
+ CurrencyAmountToJson,
8
+ } from "./CurrencyAmount.js";
7
9
 
8
10
  /** This object represents a specific node that existed on a particular payment route. You can retrieve this object to get information about a node on a particular payment path and all payment-relevant information for that node. **/
9
- type Hop = Entity & {
11
+ interface Hop {
10
12
  /**
11
13
  * The unique identifier of this entity across all Lightspark systems. Should be treated as an opaque
12
14
  * string.
@@ -26,20 +28,20 @@ type Hop = Entity & {
26
28
  typename: string;
27
29
 
28
30
  /** The destination node of the hop. **/
29
- destinationId?: string;
31
+ destinationId?: string | undefined;
30
32
 
31
33
  /** The public key of the node to which the hop is bound. **/
32
- publicKey?: string;
34
+ publicKey?: string | undefined;
33
35
 
34
36
  /** The amount that is to be forwarded to the destination node. **/
35
- amountToForward?: CurrencyAmount;
37
+ amountToForward?: CurrencyAmount | undefined;
36
38
 
37
39
  /** The fees to be collected by the source node for forwarding the payment over the hop. **/
38
- fee?: CurrencyAmount;
40
+ fee?: CurrencyAmount | undefined;
39
41
 
40
42
  /** The block height at which an unsettled HTLC is considered expired. **/
41
- expiryBlockHeight?: number;
42
- };
43
+ expiryBlockHeight?: number | undefined;
44
+ }
43
45
 
44
46
  export const HopFromJson = (obj: any): Hop => {
45
47
  return {
@@ -57,6 +59,22 @@ export const HopFromJson = (obj: any): Hop => {
57
59
  expiryBlockHeight: obj["hop_expiry_block_height"],
58
60
  } as Hop;
59
61
  };
62
+ export const HopToJson = (obj: Hop): any => {
63
+ return {
64
+ __typename: "Hop",
65
+ hop_id: obj.id,
66
+ hop_created_at: obj.createdAt,
67
+ hop_updated_at: obj.updatedAt,
68
+ hop_destination: { id: obj.destinationId } ?? undefined,
69
+ hop_index: obj.index,
70
+ hop_public_key: obj.publicKey,
71
+ hop_amount_to_forward: obj.amountToForward
72
+ ? CurrencyAmountToJson(obj.amountToForward)
73
+ : undefined,
74
+ hop_fee: obj.fee ? CurrencyAmountToJson(obj.fee) : undefined,
75
+ hop_expiry_block_height: obj.expiryBlockHeight,
76
+ };
77
+ };
60
78
 
61
79
  export const FRAGMENT = `
62
80
  fragment HopFragment on Hop {
@@ -1,12 +1,12 @@
1
1
  // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
2
2
 
3
- type IdAndSignature = {
3
+ interface IdAndSignature {
4
4
  /** The id of the message. **/
5
5
  id: string;
6
6
 
7
7
  /** The signature of the message. **/
8
8
  signature: string;
9
- };
9
+ }
10
10
 
11
11
  export const IdAndSignatureFromJson = (obj: any): IdAndSignature => {
12
12
  return {
@@ -14,5 +14,11 @@ export const IdAndSignatureFromJson = (obj: any): IdAndSignature => {
14
14
  signature: obj["id_and_signature_signature"],
15
15
  } as IdAndSignature;
16
16
  };
17
+ export const IdAndSignatureToJson = (obj: IdAndSignature): any => {
18
+ return {
19
+ id_and_signature_id: obj.id,
20
+ id_and_signature_signature: obj.signature,
21
+ };
22
+ };
17
23
 
18
24
  export default IdAndSignature;
@@ -4,17 +4,25 @@ 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";
11
+ import type Entity from "./Entity.js";
8
12
  import type IncomingPaymentAttemptStatus from "./IncomingPaymentAttemptStatus.js";
9
13
  import type IncomingPaymentToAttemptsConnection from "./IncomingPaymentToAttemptsConnection.js";
10
14
  import { IncomingPaymentToAttemptsConnectionFromJson } from "./IncomingPaymentToAttemptsConnection.js";
11
15
  import type LightningTransaction from "./LightningTransaction.js";
12
16
  import type PostTransactionData from "./PostTransactionData.js";
13
- import { PostTransactionDataFromJson } from "./PostTransactionData.js";
17
+ import {
18
+ PostTransactionDataFromJson,
19
+ PostTransactionDataToJson,
20
+ } from "./PostTransactionData.js";
21
+ import type Transaction from "./Transaction.js";
14
22
  import TransactionStatus from "./TransactionStatus.js";
15
23
 
16
24
  /** This object represents any payment sent to a Lightspark node on the Lightning Network. You can retrieve this object to receive payment related information about a specific payment received by a Lightspark node. **/
17
- class IncomingPayment implements LightningTransaction {
25
+ class IncomingPayment implements LightningTransaction, Transaction, Entity {
18
26
  constructor(
19
27
  public readonly id: string,
20
28
  public readonly createdAt: string,
@@ -23,10 +31,10 @@ class IncomingPayment implements LightningTransaction {
23
31
  public readonly amount: CurrencyAmount,
24
32
  public readonly destinationId: string,
25
33
  public readonly typename: string,
26
- public readonly resolvedAt?: string,
27
- public readonly transactionHash?: string,
28
- public readonly paymentRequestId?: string,
29
- public readonly umaPostTransactionData?: PostTransactionData[],
34
+ public readonly resolvedAt?: string | undefined,
35
+ public readonly transactionHash?: string | undefined,
36
+ public readonly paymentRequestId?: string | undefined,
37
+ public readonly umaPostTransactionData?: PostTransactionData[] | undefined,
30
38
  ) {
31
39
  autoBind(this);
32
40
  }
@@ -106,6 +114,24 @@ ${FRAGMENT}
106
114
  constructObject: (data: any) => IncomingPaymentFromJson(data.entity),
107
115
  };
108
116
  }
117
+
118
+ public toJson() {
119
+ return {
120
+ __typename: "IncomingPayment",
121
+ incoming_payment_id: this.id,
122
+ incoming_payment_created_at: this.createdAt,
123
+ incoming_payment_updated_at: this.updatedAt,
124
+ incoming_payment_status: this.status,
125
+ incoming_payment_resolved_at: this.resolvedAt,
126
+ incoming_payment_amount: CurrencyAmountToJson(this.amount),
127
+ incoming_payment_transaction_hash: this.transactionHash,
128
+ incoming_payment_destination: { id: this.destinationId },
129
+ incoming_payment_payment_request:
130
+ { id: this.paymentRequestId } ?? undefined,
131
+ incoming_payment_uma_post_transaction_data:
132
+ this.umaPostTransactionData?.map((e) => PostTransactionDataToJson(e)),
133
+ };
134
+ }
109
135
  }
110
136
 
111
137
  export const IncomingPaymentFromJson = (obj: any): IncomingPayment => {
@@ -2,12 +2,14 @@
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";
5
+ import {
6
+ CurrencyAmountFromJson,
7
+ CurrencyAmountToJson,
8
+ } from "./CurrencyAmount.js";
7
9
  import IncomingPaymentAttemptStatus from "./IncomingPaymentAttemptStatus.js";
8
10
 
9
11
  /** This object represents any attempted payment sent to a Lightspark node on the Lightning Network. You can retrieve this object to receive payment related information about a specific incoming payment attempt. **/
10
- type IncomingPaymentAttempt = Entity & {
12
+ interface IncomingPaymentAttempt {
11
13
  /**
12
14
  * The unique identifier of this entity across all Lightspark systems. Should be treated as an opaque
13
15
  * string.
@@ -33,8 +35,8 @@ type IncomingPaymentAttempt = Entity & {
33
35
  typename: string;
34
36
 
35
37
  /** The time the incoming payment attempt failed or succeeded. **/
36
- resolvedAt?: string;
37
- };
38
+ resolvedAt?: string | undefined;
39
+ }
38
40
 
39
41
  export const IncomingPaymentAttemptFromJson = (
40
42
  obj: any,
@@ -52,6 +54,20 @@ export const IncomingPaymentAttemptFromJson = (
52
54
  resolvedAt: obj["incoming_payment_attempt_resolved_at"],
53
55
  } as IncomingPaymentAttempt;
54
56
  };
57
+ export const IncomingPaymentAttemptToJson = (
58
+ obj: IncomingPaymentAttempt,
59
+ ): any => {
60
+ return {
61
+ __typename: "IncomingPaymentAttempt",
62
+ incoming_payment_attempt_id: obj.id,
63
+ incoming_payment_attempt_created_at: obj.createdAt,
64
+ incoming_payment_attempt_updated_at: obj.updatedAt,
65
+ incoming_payment_attempt_status: obj.status,
66
+ incoming_payment_attempt_resolved_at: obj.resolvedAt,
67
+ incoming_payment_attempt_amount: CurrencyAmountToJson(obj.amount),
68
+ incoming_payment_attempt_channel: { id: obj.channelId },
69
+ };
70
+ };
55
71
 
56
72
  export const FRAGMENT = `
57
73
  fragment IncomingPaymentAttemptFragment on IncomingPaymentAttempt {