@lightsparkdev/lightspark-sdk 0.4.9 → 0.4.11

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 (107) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/dist/{chunk-YTXDF6SQ.js → chunk-NXUFC5J7.js} +950 -246
  3. package/dist/{index-adeff42d.d.ts → index-3ffe9e7b.d.ts} +194 -56
  4. package/dist/index.cjs +963 -254
  5. package/dist/index.d.ts +2 -2
  6. package/dist/index.js +16 -9
  7. package/dist/objects/index.cjs +952 -246
  8. package/dist/objects/index.d.ts +1 -1
  9. package/dist/objects/index.js +5 -1
  10. package/package.json +4 -4
  11. package/src/__tests__/webhooks.test.ts +1 -1
  12. package/src/auth/AccountTokenAuthProvider.ts +4 -4
  13. package/src/client.ts +62 -63
  14. package/src/objects/Account.ts +46 -40
  15. package/src/objects/AccountToApiTokensConnection.ts +14 -9
  16. package/src/objects/AccountToChannelsConnection.ts +4 -4
  17. package/src/objects/AccountToNodesConnection.ts +13 -8
  18. package/src/objects/AccountToPaymentRequestsConnection.ts +22 -17
  19. package/src/objects/AccountToTransactionsConnection.ts +24 -19
  20. package/src/objects/AccountToWalletsConnection.ts +13 -8
  21. package/src/objects/ApiToken.ts +2 -1
  22. package/src/objects/Balances.ts +3 -2
  23. package/src/objects/BitcoinNetwork.ts +2 -1
  24. package/src/objects/BlockchainBalance.ts +1 -1
  25. package/src/objects/Channel.ts +6 -6
  26. package/src/objects/ChannelClosingTransaction.ts +4 -4
  27. package/src/objects/ChannelFees.ts +1 -0
  28. package/src/objects/ChannelOpeningTransaction.ts +4 -4
  29. package/src/objects/ChannelStatus.ts +1 -0
  30. package/src/objects/ChannelToTransactionsConnection.ts +4 -4
  31. package/src/objects/Connection.ts +387 -0
  32. package/src/objects/CreateApiTokenInput.ts +1 -1
  33. package/src/objects/CreateApiTokenOutput.ts +1 -1
  34. package/src/objects/CreateInvoiceInput.ts +12 -0
  35. package/src/objects/CreateLnurlInvoiceInput.ts +11 -1
  36. package/src/objects/CreateNodeWalletAddressInput.ts +1 -1
  37. package/src/objects/CreateNodeWalletAddressOutput.ts +1 -1
  38. package/src/objects/CreateTestModeInvoiceInput.ts +1 -1
  39. package/src/objects/CreateTestModeInvoiceOutput.ts +1 -1
  40. package/src/objects/CreateTestModePaymentInput.ts +1 -1
  41. package/src/objects/CreateTestModePaymentoutput.ts +2 -1
  42. package/src/objects/CryptoSanctionsScreeningProvider.ts +14 -0
  43. package/src/objects/CurrencyAmount.ts +1 -1
  44. package/src/objects/CurrencyUnit.ts +1 -0
  45. package/src/objects/DeleteApiTokenOutput.ts +1 -1
  46. package/src/objects/Deposit.ts +2 -2
  47. package/src/objects/Entity.ts +1 -1
  48. package/src/objects/FeeEstimate.ts +1 -0
  49. package/src/objects/GraphNode.ts +5 -5
  50. package/src/objects/Hop.ts +2 -2
  51. package/src/objects/HtlcAttemptFailureCode.ts +1 -0
  52. package/src/objects/IncomingPayment.ts +21 -8
  53. package/src/objects/IncomingPaymentAttempt.ts +4 -4
  54. package/src/objects/IncomingPaymentAttemptStatus.ts +1 -1
  55. package/src/objects/IncomingPaymentToAttemptsConnection.ts +23 -3
  56. package/src/objects/Invoice.ts +2 -2
  57. package/src/objects/InvoiceData.ts +1 -1
  58. package/src/objects/InvoiceType.ts +1 -0
  59. package/src/objects/LightningFeeEstimateForInvoiceInput.ts +1 -1
  60. package/src/objects/LightningFeeEstimateForNodeInput.ts +1 -1
  61. package/src/objects/LightningFeeEstimateOutput.ts +2 -2
  62. package/src/objects/LightningTransaction.ts +8 -8
  63. package/src/objects/LightsparkNode.ts +15 -9
  64. package/src/objects/LightsparkNodeOwner.ts +6 -6
  65. package/src/objects/LightsparkNodePurpose.ts +1 -0
  66. package/src/objects/LightsparkNodeToChannelsConnection.ts +14 -9
  67. package/src/objects/Node.ts +7 -8
  68. package/src/objects/NodeAddress.ts +1 -1
  69. package/src/objects/NodeAddressType.ts +1 -1
  70. package/src/objects/NodeToAddressesConnection.ts +2 -2
  71. package/src/objects/OnChainTransaction.ts +4 -5
  72. package/src/objects/OutgoingPayment.ts +16 -8
  73. package/src/objects/OutgoingPaymentAttempt.ts +18 -10
  74. package/src/objects/OutgoingPaymentAttemptStatus.ts +1 -1
  75. package/src/objects/OutgoingPaymentAttemptToHopsConnection.ts +23 -3
  76. package/src/objects/OutgoingPaymentToAttemptsConnection.ts +23 -3
  77. package/src/objects/PageInfo.ts +1 -0
  78. package/src/objects/PaymentFailureReason.ts +1 -0
  79. package/src/objects/PaymentRequest.ts +3 -3
  80. package/src/objects/PaymentRequestData.ts +2 -2
  81. package/src/objects/PaymentRequestStatus.ts +1 -0
  82. package/src/objects/Permission.ts +1 -0
  83. package/src/objects/RequestWithdrawalInput.ts +1 -1
  84. package/src/objects/RequestWithdrawalOutput.ts +1 -1
  85. package/src/objects/RiskRating.ts +18 -0
  86. package/src/objects/RoutingTransaction.ts +3 -3
  87. package/src/objects/RoutingTransactionFailureReason.ts +1 -0
  88. package/src/objects/ScreenBitcoinAddressesInput.ts +23 -0
  89. package/src/objects/ScreenBitcoinAddressesOutput.ts +25 -0
  90. package/src/objects/Transaction.ts +6 -6
  91. package/src/objects/TransactionFailures.ts +2 -1
  92. package/src/objects/TransactionStatus.ts +1 -0
  93. package/src/objects/TransactionType.ts +1 -0
  94. package/src/objects/Wallet.ts +636 -11
  95. package/src/objects/WalletStatus.ts +1 -0
  96. package/src/objects/WalletToPaymentRequestsConnection.ts +57 -0
  97. package/src/objects/WalletToTransactionsConnection.ts +57 -0
  98. package/src/objects/WebhookEventType.ts +3 -0
  99. package/src/objects/Withdrawal.ts +2 -2
  100. package/src/objects/WithdrawalMode.ts +1 -0
  101. package/src/objects/WithdrawalRequest.ts +8 -7
  102. package/src/objects/WithdrawalRequestStatus.ts +1 -0
  103. package/src/objects/WithdrawalRequestToChannelClosingTransactionsConnection.ts +2 -2
  104. package/src/objects/WithdrawalRequestToChannelOpeningTransactionsConnection.ts +2 -2
  105. package/src/objects/index.ts +7 -0
  106. package/src/webhooks.ts +1 -1
  107. package/src/objects/.eslintrc.cjs +0 -5
@@ -12,15 +12,25 @@ type CreateLnurlInvoiceInput = {
12
12
  * payment) of the resulting Bolt 11 invoice.
13
13
  **/
14
14
  metadataHash: string;
15
+
16
+ /** The expiry of the invoice in seconds. Default value is 86400 (1 day). **/
17
+ expirySecs?: number;
18
+
19
+ paymentHash?: string;
20
+
21
+ preimageNonce?: string;
15
22
  };
16
23
 
17
24
  export const CreateLnurlInvoiceInputFromJson = (
18
- obj: any
25
+ obj: any,
19
26
  ): CreateLnurlInvoiceInput => {
20
27
  return {
21
28
  nodeId: obj["create_lnurl_invoice_input_node_id"],
22
29
  amountMsats: obj["create_lnurl_invoice_input_amount_msats"],
23
30
  metadataHash: obj["create_lnurl_invoice_input_metadata_hash"],
31
+ expirySecs: obj["create_lnurl_invoice_input_expiry_secs"],
32
+ paymentHash: obj["create_lnurl_invoice_input_payment_hash"],
33
+ preimageNonce: obj["create_lnurl_invoice_input_preimage_nonce"],
24
34
  } as CreateLnurlInvoiceInput;
25
35
  };
26
36
 
@@ -5,7 +5,7 @@ type CreateNodeWalletAddressInput = {
5
5
  };
6
6
 
7
7
  export const CreateNodeWalletAddressInputFromJson = (
8
- obj: any
8
+ obj: any,
9
9
  ): CreateNodeWalletAddressInput => {
10
10
  return {
11
11
  nodeId: obj["create_node_wallet_address_input_node_id"],
@@ -7,7 +7,7 @@ type CreateNodeWalletAddressOutput = {
7
7
  };
8
8
 
9
9
  export const CreateNodeWalletAddressOutputFromJson = (
10
- obj: any
10
+ obj: any,
11
11
  ): CreateNodeWalletAddressOutput => {
12
12
  return {
13
13
  nodeId: obj["create_node_wallet_address_output_node"].id,
@@ -13,7 +13,7 @@ type CreateTestModeInvoiceInput = {
13
13
  };
14
14
 
15
15
  export const CreateTestModeInvoiceInputFromJson = (
16
- obj: any
16
+ obj: any,
17
17
  ): CreateTestModeInvoiceInput => {
18
18
  return {
19
19
  localNodeId: obj["create_test_mode_invoice_input_local_node_id"],
@@ -5,7 +5,7 @@ type CreateTestModeInvoiceOutput = {
5
5
  };
6
6
 
7
7
  export const CreateTestModeInvoiceOutputFromJson = (
8
- obj: any
8
+ obj: any,
9
9
  ): CreateTestModeInvoiceOutput => {
10
10
  return {
11
11
  encodedPaymentRequest:
@@ -15,7 +15,7 @@ type CreateTestModePaymentInput = {
15
15
  };
16
16
 
17
17
  export const CreateTestModePaymentInputFromJson = (
18
- obj: any
18
+ obj: any,
19
19
  ): CreateTestModePaymentInput => {
20
20
  return {
21
21
  localNodeId: obj["create_test_mode_payment_input_local_node_id"],
@@ -1,12 +1,13 @@
1
1
  // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
2
2
 
3
+ /** This is an object identifying the output of a test mode payment. This object can be used to retrieve the associated payment made from a Test Mode Payment call. **/
3
4
  type CreateTestModePaymentoutput = {
4
5
  /** The payment that has been sent. **/
5
6
  paymentId: string;
6
7
  };
7
8
 
8
9
  export const CreateTestModePaymentoutputFromJson = (
9
- obj: any
10
+ obj: any,
10
11
  ): CreateTestModePaymentoutput => {
11
12
  return {
12
13
  paymentId: obj["create_test_mode_paymentoutput_payment"].id,
@@ -0,0 +1,14 @@
1
+ // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
2
+
3
+ /** This is an enum identifying a type of crypto sanctions screening provider. **/
4
+ export enum CryptoSanctionsScreeningProvider {
5
+ /**
6
+ * This is an enum value that represents values that could be added in the future.
7
+ * Clients should support unknown values as more of them could be added without notice.
8
+ */
9
+ FUTURE_VALUE = "FUTURE_VALUE",
10
+
11
+ CHAINALYSIS = "CHAINALYSIS",
12
+ }
13
+
14
+ export default CryptoSanctionsScreeningProvider;
@@ -2,7 +2,7 @@
2
2
 
3
3
  import CurrencyUnit from "./CurrencyUnit.js";
4
4
 
5
- /** Represents the value and unit for an amount of currency. **/
5
+ /** This object represents the value and unit for an amount of currency. **/
6
6
  type CurrencyAmount = {
7
7
  /** The original numeric value for this CurrencyAmount. **/
8
8
  originalValue: number;
@@ -1,5 +1,6 @@
1
1
  // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
2
2
 
3
+ /** This enum identifies the unit of currency associated with a CurrencyAmount. **/
3
4
  export enum CurrencyUnit {
4
5
  /**
5
6
  * This is an enum value that represents values that could be added in the future.
@@ -5,7 +5,7 @@ type DeleteApiTokenOutput = {
5
5
  };
6
6
 
7
7
  export const DeleteApiTokenOutputFromJson = (
8
- obj: any
8
+ obj: any,
9
9
  ): DeleteApiTokenOutput => {
10
10
  return {
11
11
  accountId: obj["delete_api_token_output_account"].id,
@@ -1,6 +1,6 @@
1
1
  // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
2
2
 
3
- import type { Query } from "@lightsparkdev/core";
3
+ import { type Query } from "@lightsparkdev/core";
4
4
  import type CurrencyAmount from "./CurrencyAmount.js";
5
5
  import { CurrencyAmountFromJson } from "./CurrencyAmount.js";
6
6
  import type Entity from "./Entity.js";
@@ -8,7 +8,7 @@ import type OnChainTransaction from "./OnChainTransaction.js";
8
8
  import type Transaction from "./Transaction.js";
9
9
  import TransactionStatus from "./TransactionStatus.js";
10
10
 
11
- /** The transaction on Bitcoin blockchain to fund the Lightspark node's wallet. **/
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
12
  type Deposit = OnChainTransaction &
13
13
  Transaction &
14
14
  Entity & {
@@ -1,6 +1,6 @@
1
1
  // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
2
2
 
3
- /** This interface is used by all the entities in the Lightspark systems. 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. **/
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
4
  type Entity = {
5
5
  /**
6
6
  * The unique identifier of this entity across all Lightspark systems. Should be treated as an opaque
@@ -3,6 +3,7 @@
3
3
  import type CurrencyAmount from "./CurrencyAmount.js";
4
4
  import { CurrencyAmountFromJson } from "./CurrencyAmount.js";
5
5
 
6
+ /** This object represents the estimated L1 transaction fees for the Bitcoin network. Fee estimates are separated by potential confirmation speeds for settlement. **/
6
7
  type FeeEstimate = {
7
8
  feeFast: CurrencyAmount;
8
9
 
@@ -1,6 +1,6 @@
1
1
  // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
2
2
 
3
- import type { Query } from "@lightsparkdev/core";
3
+ 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";
@@ -9,7 +9,7 @@ import type NodeAddressType from "./NodeAddressType.js";
9
9
  import type NodeToAddressesConnection from "./NodeToAddressesConnection.js";
10
10
  import { NodeToAddressesConnectionFromJson } from "./NodeToAddressesConnection.js";
11
11
 
12
- /** This is a node on the Lightning Network, managed by a third party. The information about this node is public data that has been obtained by observing the Lightning Network. **/
12
+ /** 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
13
  class GraphNode implements Node {
14
14
  constructor(
15
15
  public readonly id: string,
@@ -21,7 +21,7 @@ class GraphNode implements Node {
21
21
  public readonly alias?: string,
22
22
  public readonly color?: string,
23
23
  public readonly conductivity?: number,
24
- public readonly publicKey?: string
24
+ public readonly publicKey?: string,
25
25
  ) {
26
26
  autoBind(this);
27
27
  }
@@ -29,7 +29,7 @@ class GraphNode implements Node {
29
29
  public async getAddresses(
30
30
  client: LightsparkClient,
31
31
  first: number | undefined = undefined,
32
- types: NodeAddressType[] | undefined = undefined
32
+ types: NodeAddressType[] | undefined = undefined,
33
33
  ): Promise<NodeToAddressesConnection> {
34
34
  return (await client.executeRawQuery({
35
35
  queryPayload: `
@@ -88,7 +88,7 @@ export const GraphNodeFromJson = (obj: any): GraphNode => {
88
88
  obj["graph_node_alias"],
89
89
  obj["graph_node_color"],
90
90
  obj["graph_node_conductivity"],
91
- obj["graph_node_public_key"]
91
+ obj["graph_node_public_key"],
92
92
  );
93
93
  };
94
94
 
@@ -1,11 +1,11 @@
1
1
  // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
2
2
 
3
- import type { Query } from "@lightsparkdev/core";
3
+ import { type Query } from "@lightsparkdev/core";
4
4
  import type CurrencyAmount from "./CurrencyAmount.js";
5
5
  import { CurrencyAmountFromJson } from "./CurrencyAmount.js";
6
6
  import type Entity from "./Entity.js";
7
7
 
8
- /** One hop signifies a payment moving one node ahead on a payment route; a list of sequential hops defines the path from sender node to recipient node for a payment attempt. **/
8
+ /** 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
9
  type Hop = Entity & {
10
10
  /**
11
11
  * The unique identifier of this entity across all Lightspark systems. Should be treated as an opaque
@@ -1,5 +1,6 @@
1
1
  // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
2
2
 
3
+ /** This is an enum representing a particular reason why an htlc sent over the Lightning Network may have failed. **/
3
4
  export enum HtlcAttemptFailureCode {
4
5
  /**
5
6
  * This is an enum value that represents values that could be added in the future.
@@ -1,6 +1,6 @@
1
1
  // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
2
2
 
3
- import type { Query } from "@lightsparkdev/core";
3
+ 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";
@@ -11,7 +11,7 @@ import { IncomingPaymentToAttemptsConnectionFromJson } from "./IncomingPaymentTo
11
11
  import type LightningTransaction from "./LightningTransaction.js";
12
12
  import TransactionStatus from "./TransactionStatus.js";
13
13
 
14
- /** A transaction that was sent to a Lightspark node on the Lightning Network. **/
14
+ /** 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. **/
15
15
  class IncomingPayment implements LightningTransaction {
16
16
  constructor(
17
17
  public readonly id: string,
@@ -24,7 +24,7 @@ class IncomingPayment implements LightningTransaction {
24
24
  public readonly resolvedAt?: string,
25
25
  public readonly transactionHash?: string,
26
26
  public readonly originId?: string,
27
- public readonly paymentRequestId?: string
27
+ public readonly paymentRequestId?: string,
28
28
  ) {
29
29
  autoBind(this);
30
30
  }
@@ -32,16 +32,24 @@ class IncomingPayment implements LightningTransaction {
32
32
  public async getAttempts(
33
33
  client: LightsparkClient,
34
34
  first: number | undefined = undefined,
35
- statuses: IncomingPaymentAttemptStatus[] | undefined = undefined
35
+ statuses: IncomingPaymentAttemptStatus[] | undefined = undefined,
36
+ after: string | undefined = undefined,
36
37
  ): Promise<IncomingPaymentToAttemptsConnection> {
37
38
  return (await client.executeRawQuery({
38
39
  queryPayload: `
39
- query FetchIncomingPaymentToAttemptsConnection($entity_id: ID!, $first: Int, $statuses: [IncomingPaymentAttemptStatus!]) {
40
+ query FetchIncomingPaymentToAttemptsConnection($entity_id: ID!, $first: Int, $statuses: [IncomingPaymentAttemptStatus!], $after: String) {
40
41
  entity(id: $entity_id) {
41
42
  ... on IncomingPayment {
42
- attempts(, first: $first, statuses: $statuses) {
43
+ attempts(, first: $first, statuses: $statuses, after: $after) {
43
44
  __typename
44
45
  incoming_payment_to_attempts_connection_count: count
46
+ incoming_payment_to_attempts_connection_page_info: page_info {
47
+ __typename
48
+ page_info_has_next_page: has_next_page
49
+ page_info_has_previous_page: has_previous_page
50
+ page_info_start_cursor: start_cursor
51
+ page_info_end_cursor: end_cursor
52
+ }
45
53
  incoming_payment_to_attempts_connection_entities: entities {
46
54
  __typename
47
55
  incoming_payment_attempt_id: id
@@ -66,7 +74,12 @@ query FetchIncomingPaymentToAttemptsConnection($entity_id: ID!, $first: Int, $st
66
74
  }
67
75
  }
68
76
  `,
69
- variables: { entity_id: this.id, first: first, statuses: statuses },
77
+ variables: {
78
+ entity_id: this.id,
79
+ first: first,
80
+ statuses: statuses,
81
+ after: after,
82
+ },
70
83
  constructObject: (json) => {
71
84
  const connection = json["entity"]["attempts"];
72
85
  return IncomingPaymentToAttemptsConnectionFromJson(connection);
@@ -106,7 +119,7 @@ export const IncomingPaymentFromJson = (obj: any): IncomingPayment => {
106
119
  obj["incoming_payment_resolved_at"],
107
120
  obj["incoming_payment_transaction_hash"],
108
121
  obj["incoming_payment_origin"]?.id ?? undefined,
109
- obj["incoming_payment_payment_request"]?.id ?? undefined
122
+ obj["incoming_payment_payment_request"]?.id ?? undefined,
110
123
  );
111
124
  };
112
125
 
@@ -1,12 +1,12 @@
1
1
  // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
2
2
 
3
- import type { Query } from "@lightsparkdev/core";
3
+ import { type Query } from "@lightsparkdev/core";
4
4
  import type CurrencyAmount from "./CurrencyAmount.js";
5
5
  import { CurrencyAmountFromJson } from "./CurrencyAmount.js";
6
6
  import type Entity from "./Entity.js";
7
7
  import IncomingPaymentAttemptStatus from "./IncomingPaymentAttemptStatus.js";
8
8
 
9
- /** An attempt for a payment over a route from sender node to recipient node. **/
9
+ /** 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
10
  type IncomingPaymentAttempt = Entity & {
11
11
  /**
12
12
  * The unique identifier of this entity across all Lightspark systems. Should be treated as an opaque
@@ -37,7 +37,7 @@ type IncomingPaymentAttempt = Entity & {
37
37
  };
38
38
 
39
39
  export const IncomingPaymentAttemptFromJson = (
40
- obj: any
40
+ obj: any,
41
41
  ): IncomingPaymentAttempt => {
42
42
  return {
43
43
  id: obj["incoming_payment_attempt_id"],
@@ -75,7 +75,7 @@ fragment IncomingPaymentAttemptFragment on IncomingPaymentAttempt {
75
75
  }`;
76
76
 
77
77
  export const getIncomingPaymentAttemptQuery = (
78
- id: string
78
+ id: string,
79
79
  ): Query<IncomingPaymentAttempt> => {
80
80
  return {
81
81
  queryPayload: `
@@ -1,6 +1,6 @@
1
1
  // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
2
2
 
3
- /** Enum that enumerates all the possible status of an incoming payment attempt. **/
3
+ /** This is an enum that enumerates all potential statuses for an incoming payment attempt. **/
4
4
  export enum IncomingPaymentAttemptStatus {
5
5
  /**
6
6
  * This is an enum value that represents values that could be added in the future.
@@ -1,28 +1,41 @@
1
1
  // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
2
2
 
3
+ import type Connection from "./Connection.js";
3
4
  import type IncomingPaymentAttempt from "./IncomingPaymentAttempt.js";
4
5
  import { IncomingPaymentAttemptFromJson } from "./IncomingPaymentAttempt.js";
6
+ import type PageInfo from "./PageInfo.js";
7
+ import { PageInfoFromJson } from "./PageInfo.js";
5
8
 
6
9
  /** The connection from incoming payment to all attempts. **/
7
- type IncomingPaymentToAttemptsConnection = {
10
+ type IncomingPaymentToAttemptsConnection = Connection & {
8
11
  /**
9
12
  * The total count of objects in this connection, using the current filters. It is different from the
10
13
  * number of objects returned in the current page (in the `entities` field).
11
14
  **/
12
15
  count: number;
13
16
 
17
+ /** An object that holds pagination information about the objects in this connection. **/
18
+ pageInfo: PageInfo;
19
+
14
20
  /** The incoming payment attempts for the current page of this connection. **/
15
21
  entities: IncomingPaymentAttempt[];
22
+
23
+ /** The typename of the object **/
24
+ typename: string;
16
25
  };
17
26
 
18
27
  export const IncomingPaymentToAttemptsConnectionFromJson = (
19
- obj: any
28
+ obj: any,
20
29
  ): IncomingPaymentToAttemptsConnection => {
21
30
  return {
22
31
  count: obj["incoming_payment_to_attempts_connection_count"],
32
+ pageInfo: PageInfoFromJson(
33
+ obj["incoming_payment_to_attempts_connection_page_info"],
34
+ ),
23
35
  entities: obj["incoming_payment_to_attempts_connection_entities"].map((e) =>
24
- IncomingPaymentAttemptFromJson(e)
36
+ IncomingPaymentAttemptFromJson(e),
25
37
  ),
38
+ typename: "IncomingPaymentToAttemptsConnection",
26
39
  } as IncomingPaymentToAttemptsConnection;
27
40
  };
28
41
 
@@ -30,6 +43,13 @@ export const FRAGMENT = `
30
43
  fragment IncomingPaymentToAttemptsConnectionFragment on IncomingPaymentToAttemptsConnection {
31
44
  __typename
32
45
  incoming_payment_to_attempts_connection_count: count
46
+ incoming_payment_to_attempts_connection_page_info: page_info {
47
+ __typename
48
+ page_info_has_next_page: has_next_page
49
+ page_info_has_previous_page: has_previous_page
50
+ page_info_start_cursor: start_cursor
51
+ page_info_end_cursor: end_cursor
52
+ }
33
53
  incoming_payment_to_attempts_connection_entities: entities {
34
54
  id
35
55
  }
@@ -1,6 +1,6 @@
1
1
  // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
2
2
 
3
- import type { Query } from "@lightsparkdev/core";
3
+ import { type Query } from "@lightsparkdev/core";
4
4
  import type CurrencyAmount from "./CurrencyAmount.js";
5
5
  import { CurrencyAmountFromJson } from "./CurrencyAmount.js";
6
6
  import type Entity from "./Entity.js";
@@ -9,7 +9,7 @@ import { InvoiceDataFromJson } from "./InvoiceData.js";
9
9
  import type PaymentRequest from "./PaymentRequest.js";
10
10
  import PaymentRequestStatus from "./PaymentRequestStatus.js";
11
11
 
12
- /** This object represents a BOLT #11 invoice (https://github.com/lightning/bolts/blob/master/11-payment-encoding.md) initiated by a Lightspark Node. **/
12
+ /** This object represents a BOLT #11 invoice (https://github.com/lightning/bolts/blob/master/11-payment-encoding.md) created by a Lightspark Node. You can retrieve this object to receive relevant payment information for a specific invoice generated by a Lightspark node. **/
13
13
  type Invoice = PaymentRequest &
14
14
  Entity & {
15
15
  /**
@@ -7,7 +7,7 @@ import type Node from "./Node.js";
7
7
  import { NodeFromJson } from "./Node.js";
8
8
  import type PaymentRequestData from "./PaymentRequestData.js";
9
9
 
10
- /** This object represents the BOLT #11 invoice protocol for Lightning Payments. See https://github.com/lightning/bolts/blob/master/11-payment-encoding.md. **/
10
+ /** This object represents the data associated with a BOLT #11 invoice. You can retrieve this object to receive the relevant data associated with a specific invoice. **/
11
11
  type InvoiceData = PaymentRequestData & {
12
12
  encodedPaymentRequest: string;
13
13
 
@@ -1,5 +1,6 @@
1
1
  // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
2
2
 
3
+ /** This is an enum for potential invoice types. **/
3
4
  export enum InvoiceType {
4
5
  /**
5
6
  * This is an enum value that represents values that could be added in the future.
@@ -15,7 +15,7 @@ type LightningFeeEstimateForInvoiceInput = {
15
15
  };
16
16
 
17
17
  export const LightningFeeEstimateForInvoiceInputFromJson = (
18
- obj: any
18
+ obj: any,
19
19
  ): LightningFeeEstimateForInvoiceInput => {
20
20
  return {
21
21
  nodeId: obj["lightning_fee_estimate_for_invoice_input_node_id"],
@@ -12,7 +12,7 @@ type LightningFeeEstimateForNodeInput = {
12
12
  };
13
13
 
14
14
  export const LightningFeeEstimateForNodeInputFromJson = (
15
- obj: any
15
+ obj: any,
16
16
  ): LightningFeeEstimateForNodeInput => {
17
17
  return {
18
18
  nodeId: obj["lightning_fee_estimate_for_node_input_node_id"],
@@ -9,11 +9,11 @@ type LightningFeeEstimateOutput = {
9
9
  };
10
10
 
11
11
  export const LightningFeeEstimateOutputFromJson = (
12
- obj: any
12
+ obj: any,
13
13
  ): LightningFeeEstimateOutput => {
14
14
  return {
15
15
  feeEstimate: CurrencyAmountFromJson(
16
- obj["lightning_fee_estimate_output_fee_estimate"]
16
+ obj["lightning_fee_estimate_output_fee_estimate"],
17
17
  ),
18
18
  } as LightningFeeEstimateOutput;
19
19
  };
@@ -1,7 +1,6 @@
1
1
  // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
2
2
 
3
- import type { Query } from "@lightsparkdev/core";
4
- import { LightsparkException } from "@lightsparkdev/core";
3
+ import { LightsparkException, type Query } from "@lightsparkdev/core";
5
4
  import type CurrencyAmount from "./CurrencyAmount.js";
6
5
  import { CurrencyAmountFromJson } from "./CurrencyAmount.js";
7
6
  import type Entity from "./Entity.js";
@@ -15,6 +14,7 @@ import RoutingTransactionFailureReason from "./RoutingTransactionFailureReason.j
15
14
  import type Transaction from "./Transaction.js";
16
15
  import TransactionStatus from "./TransactionStatus.js";
17
16
 
17
+ /** This is an object representing a transaction made over the Lightning Network. You can retrieve this object to receive information about a specific transaction made over Lightning for a Lightspark node. **/
18
18
  type LightningTransaction = Transaction &
19
19
  Entity & {
20
20
  /**
@@ -46,7 +46,7 @@ type LightningTransaction = Transaction &
46
46
  };
47
47
 
48
48
  export const LightningTransactionFromJson = (
49
- obj: any
49
+ obj: any,
50
50
  ): LightningTransaction => {
51
51
  if (obj["__typename"] == "IncomingPayment") {
52
52
  return new IncomingPayment(
@@ -61,7 +61,7 @@ export const LightningTransactionFromJson = (
61
61
  obj["incoming_payment_resolved_at"],
62
62
  obj["incoming_payment_transaction_hash"],
63
63
  obj["incoming_payment_origin"]?.id ?? undefined,
64
- obj["incoming_payment_payment_request"]?.id ?? undefined
64
+ obj["incoming_payment_payment_request"]?.id ?? undefined,
65
65
  );
66
66
  }
67
67
  if (obj["__typename"] == "OutgoingPayment") {
@@ -82,7 +82,7 @@ export const LightningTransactionFromJson = (
82
82
  : undefined,
83
83
  !!obj["outgoing_payment_payment_request_data"]
84
84
  ? PaymentRequestDataFromJson(
85
- obj["outgoing_payment_payment_request_data"]
85
+ obj["outgoing_payment_payment_request_data"],
86
86
  )
87
87
  : undefined,
88
88
  !!obj["outgoing_payment_failure_reason"]
@@ -91,7 +91,7 @@ export const LightningTransactionFromJson = (
91
91
  : null,
92
92
  !!obj["outgoing_payment_failure_message"]
93
93
  ? RichTextFromJson(obj["outgoing_payment_failure_message"])
94
- : undefined
94
+ : undefined,
95
95
  );
96
96
  }
97
97
  if (obj["__typename"] == "RoutingTransaction") {
@@ -125,7 +125,7 @@ export const LightningTransactionFromJson = (
125
125
  }
126
126
  throw new LightsparkException(
127
127
  "DeserializationError",
128
- `Couldn't find a concrete type for interface LightningTransaction corresponding to the typename=${obj["__typename"]}`
128
+ `Couldn't find a concrete type for interface LightningTransaction corresponding to the typename=${obj["__typename"]}`,
129
129
  );
130
130
  };
131
131
 
@@ -376,7 +376,7 @@ fragment LightningTransactionFragment on LightningTransaction {
376
376
  }`;
377
377
 
378
378
  export const getLightningTransactionQuery = (
379
- id: string
379
+ id: string,
380
380
  ): Query<LightningTransaction> => {
381
381
  return {
382
382
  queryPayload: `
@@ -1,6 +1,6 @@
1
1
  // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
2
2
 
3
- import type { Query } from "@lightsparkdev/core";
3
+ 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";
@@ -42,7 +42,7 @@ class LightsparkNode implements Node {
42
42
  public readonly localBalance?: CurrencyAmount,
43
43
  public readonly purpose?: LightsparkNodePurpose,
44
44
  public readonly remoteBalance?: CurrencyAmount,
45
- public readonly status?: LightsparkNodeStatus
45
+ public readonly status?: LightsparkNodeStatus,
46
46
  ) {
47
47
  autoBind(this);
48
48
  }
@@ -50,7 +50,7 @@ class LightsparkNode implements Node {
50
50
  public async getAddresses(
51
51
  client: LightsparkClient,
52
52
  first: number | undefined = undefined,
53
- types: NodeAddressType[] | undefined = undefined
53
+ types: NodeAddressType[] | undefined = undefined,
54
54
  ): Promise<NodeToAddressesConnection> {
55
55
  return (await client.executeRawQuery({
56
56
  queryPayload: `
@@ -81,15 +81,17 @@ query FetchNodeToAddressesConnection($entity_id: ID!, $first: Int, $types: [Node
81
81
  public async getChannels(
82
82
  client: LightsparkClient,
83
83
  first: number | undefined = undefined,
84
- statuses: ChannelStatus[] | undefined = undefined
84
+ statuses: ChannelStatus[] | undefined = undefined,
85
+ after: string | undefined = undefined,
85
86
  ): Promise<LightsparkNodeToChannelsConnection> {
86
87
  return (await client.executeRawQuery({
87
88
  queryPayload: `
88
- query FetchLightsparkNodeToChannelsConnection($entity_id: ID!, $first: Int, $statuses: [ChannelStatus!]) {
89
+ query FetchLightsparkNodeToChannelsConnection($entity_id: ID!, $first: Int, $statuses: [ChannelStatus!], $after: String) {
89
90
  entity(id: $entity_id) {
90
91
  ... on LightsparkNode {
91
- channels(, first: $first, statuses: $statuses) {
92
+ channels(, first: $first, statuses: $statuses, after: $after) {
92
93
  __typename
94
+ lightspark_node_to_channels_connection_count: count
93
95
  lightspark_node_to_channels_connection_page_info: page_info {
94
96
  __typename
95
97
  page_info_has_next_page: has_next_page
@@ -97,7 +99,6 @@ query FetchLightsparkNodeToChannelsConnection($entity_id: ID!, $first: Int, $sta
97
99
  page_info_start_cursor: start_cursor
98
100
  page_info_end_cursor: end_cursor
99
101
  }
100
- lightspark_node_to_channels_connection_count: count
101
102
  lightspark_node_to_channels_connection_entities: entities {
102
103
  __typename
103
104
  channel_id: id
@@ -197,7 +198,12 @@ query FetchLightsparkNodeToChannelsConnection($entity_id: ID!, $first: Int, $sta
197
198
  }
198
199
  }
199
200
  `,
200
- variables: { entity_id: this.id, first: first, statuses: statuses },
201
+ variables: {
202
+ entity_id: this.id,
203
+ first: first,
204
+ statuses: statuses,
205
+ after: after,
206
+ },
201
207
  constructObject: (json) => {
202
208
  const connection = json["entity"]["channels"];
203
209
  return LightsparkNodeToChannelsConnectionFromJson(connection);
@@ -264,7 +270,7 @@ export const LightsparkNodeFromJson = (obj: any): LightsparkNode => {
264
270
  !!obj["lightspark_node_status"]
265
271
  ? LightsparkNodeStatus[obj["lightspark_node_status"]] ??
266
272
  LightsparkNodeStatus.FUTURE_VALUE
267
- : null
273
+ : null,
268
274
  );
269
275
  };
270
276