@buildonspark/spark-sdk 0.0.15 → 0.0.16

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 (131) hide show
  1. package/dist/services/wallet-config.d.ts +1 -0
  2. package/dist/services/wallet-config.js +1 -0
  3. package/dist/services/wallet-config.js.map +1 -1
  4. package/dist/spark-sdk.d.ts +1 -1
  5. package/dist/spark-sdk.js +3 -3
  6. package/dist/spark-sdk.js.map +1 -1
  7. package/package.json +4 -3
  8. package/src/examples/example.js +247 -0
  9. package/src/examples/example.ts +207 -0
  10. package/src/graphql/client.ts +282 -0
  11. package/src/graphql/mutations/CompleteCoopExit.ts +19 -0
  12. package/src/graphql/mutations/CompleteLeavesSwap.ts +17 -0
  13. package/src/graphql/mutations/RequestCoopExit.ts +20 -0
  14. package/src/graphql/mutations/RequestLightningReceive.ts +26 -0
  15. package/src/graphql/mutations/RequestLightningSend.ts +17 -0
  16. package/src/graphql/mutations/RequestSwapLeaves.ts +24 -0
  17. package/src/graphql/objects/BitcoinNetwork.ts +22 -0
  18. package/src/graphql/objects/CompleteCoopExitInput.ts +41 -0
  19. package/src/graphql/objects/CompleteCoopExitOutput.ts +45 -0
  20. package/src/graphql/objects/CompleteLeavesSwapInput.ts +45 -0
  21. package/src/graphql/objects/CompleteLeavesSwapOutput.ts +45 -0
  22. package/src/graphql/objects/CompleteSeedReleaseInput.ts +41 -0
  23. package/src/graphql/objects/CompleteSeedReleaseOutput.ts +43 -0
  24. package/src/graphql/objects/Connection.ts +90 -0
  25. package/src/graphql/objects/CoopExitFeeEstimateInput.ts +41 -0
  26. package/src/graphql/objects/CoopExitFeeEstimateOutput.ts +52 -0
  27. package/src/graphql/objects/CoopExitRequest.ts +118 -0
  28. package/src/graphql/objects/CurrencyAmount.ts +74 -0
  29. package/src/graphql/objects/CurrencyUnit.ts +32 -0
  30. package/src/graphql/objects/Entity.ts +202 -0
  31. package/src/graphql/objects/GetChallengeInput.ts +37 -0
  32. package/src/graphql/objects/GetChallengeOutput.ts +43 -0
  33. package/src/graphql/objects/Invoice.ts +83 -0
  34. package/src/graphql/objects/Leaf.ts +59 -0
  35. package/src/graphql/objects/LeavesSwapFeeEstimateInput.ts +37 -0
  36. package/src/graphql/objects/LeavesSwapFeeEstimateOutput.ts +52 -0
  37. package/src/graphql/objects/LeavesSwapRequest.ts +192 -0
  38. package/src/graphql/objects/LightningReceiveFeeEstimateInput.ts +41 -0
  39. package/src/graphql/objects/LightningReceiveFeeEstimateOutput.ts +52 -0
  40. package/src/graphql/objects/LightningReceiveRequest.ts +147 -0
  41. package/src/graphql/objects/LightningReceiveRequestStatus.ts +34 -0
  42. package/src/graphql/objects/LightningSendFeeEstimateInput.ts +37 -0
  43. package/src/graphql/objects/LightningSendFeeEstimateOutput.ts +52 -0
  44. package/src/graphql/objects/LightningSendRequest.ts +134 -0
  45. package/src/graphql/objects/LightningSendRequestStatus.ts +28 -0
  46. package/src/graphql/objects/NotifyReceiverTransferInput.ts +41 -0
  47. package/src/graphql/objects/PageInfo.ts +58 -0
  48. package/src/graphql/objects/Provider.ts +41 -0
  49. package/src/graphql/objects/RequestCoopExitInput.ts +41 -0
  50. package/src/graphql/objects/RequestCoopExitOutput.ts +45 -0
  51. package/src/graphql/objects/RequestLeavesSwapInput.ts +55 -0
  52. package/src/graphql/objects/RequestLeavesSwapOutput.ts +45 -0
  53. package/src/graphql/objects/RequestLightningReceiveInput.ts +58 -0
  54. package/src/graphql/objects/RequestLightningReceiveOutput.ts +45 -0
  55. package/src/graphql/objects/RequestLightningSendInput.ts +41 -0
  56. package/src/graphql/objects/RequestLightningSendOutput.ts +45 -0
  57. package/src/graphql/objects/SparkCoopExitRequestStatus.ts +20 -0
  58. package/src/graphql/objects/SparkLeavesSwapRequestStatus.ts +20 -0
  59. package/src/graphql/objects/SparkTransferToLeavesConnection.ts +79 -0
  60. package/src/graphql/objects/SparkWalletUser.ts +86 -0
  61. package/src/graphql/objects/StartSeedReleaseInput.ts +37 -0
  62. package/src/graphql/objects/SwapLeaf.ts +53 -0
  63. package/src/graphql/objects/Transfer.ts +98 -0
  64. package/src/graphql/objects/UserLeafInput.ts +28 -0
  65. package/src/graphql/objects/VerifyChallengeInput.ts +51 -0
  66. package/src/graphql/objects/VerifyChallengeOutput.ts +43 -0
  67. package/src/graphql/objects/WalletUserIdentityPublicKeyInput.ts +37 -0
  68. package/src/graphql/objects/WalletUserIdentityPublicKeyOutput.ts +43 -0
  69. package/src/graphql/objects/index.ts +67 -0
  70. package/src/graphql/queries/CoopExitFeeEstimate.ts +18 -0
  71. package/src/graphql/queries/CurrentUser.ts +10 -0
  72. package/src/graphql/queries/LightningReceiveFeeEstimate.ts +18 -0
  73. package/src/graphql/queries/LightningSendFeeEstimate.ts +16 -0
  74. package/src/proto/common.ts +431 -0
  75. package/src/proto/google/protobuf/descriptor.ts +6625 -0
  76. package/src/proto/google/protobuf/duration.ts +197 -0
  77. package/src/proto/google/protobuf/empty.ts +83 -0
  78. package/src/proto/google/protobuf/timestamp.ts +226 -0
  79. package/src/proto/mock.ts +151 -0
  80. package/src/proto/spark.ts +12727 -0
  81. package/src/proto/spark_authn.ts +673 -0
  82. package/src/proto/validate/validate.ts +6047 -0
  83. package/src/services/config.ts +71 -0
  84. package/src/services/connection.ts +264 -0
  85. package/src/services/coop-exit.ts +190 -0
  86. package/src/services/deposit.ts +327 -0
  87. package/src/services/lightning.ts +341 -0
  88. package/src/services/lrc20.ts +42 -0
  89. package/src/services/token-transactions.ts +499 -0
  90. package/src/services/transfer.ts +1188 -0
  91. package/src/services/tree-creation.ts +618 -0
  92. package/src/services/wallet-config.ts +141 -0
  93. package/src/signer/signer.ts +531 -0
  94. package/src/spark-sdk.ts +1644 -0
  95. package/src/tests/adaptor-signature.test.ts +64 -0
  96. package/src/tests/bitcoin.test.ts +122 -0
  97. package/src/tests/coop-exit.test.ts +233 -0
  98. package/src/tests/deposit.test.ts +98 -0
  99. package/src/tests/keys.test.ts +82 -0
  100. package/src/tests/lightning.test.ts +307 -0
  101. package/src/tests/secret-sharing.test.ts +63 -0
  102. package/src/tests/swap.test.ts +252 -0
  103. package/src/tests/test-util.ts +92 -0
  104. package/src/tests/tokens.test.ts +47 -0
  105. package/src/tests/transfer.test.ts +371 -0
  106. package/src/tests/tree-creation.test.ts +56 -0
  107. package/src/tests/utils/spark-testing-wallet.ts +37 -0
  108. package/src/tests/utils/test-faucet.ts +257 -0
  109. package/src/types/grpc.ts +8 -0
  110. package/src/types/index.ts +3 -0
  111. package/src/utils/adaptor-signature.ts +189 -0
  112. package/src/utils/bitcoin.ts +138 -0
  113. package/src/utils/crypto.ts +14 -0
  114. package/src/utils/index.ts +12 -0
  115. package/src/utils/keys.ts +92 -0
  116. package/src/utils/mempool.ts +42 -0
  117. package/src/utils/network.ts +70 -0
  118. package/src/utils/proof.ts +17 -0
  119. package/src/utils/response-validation.ts +26 -0
  120. package/src/utils/secret-sharing.ts +263 -0
  121. package/src/utils/signing.ts +96 -0
  122. package/src/utils/token-hashing.ts +163 -0
  123. package/src/utils/token-keyshares.ts +31 -0
  124. package/src/utils/token-transactions.ts +71 -0
  125. package/src/utils/transaction.ts +45 -0
  126. package/src/utils/wasm-wrapper.ts +57 -0
  127. package/src/utils/wasm.ts +154 -0
  128. package/src/wasm/spark_bindings.d.ts +208 -0
  129. package/src/wasm/spark_bindings.js +1161 -0
  130. package/src/wasm/spark_bindings_bg.wasm +0 -0
  131. package/src/wasm/spark_bindings_bg.wasm.d.ts +136 -0
@@ -0,0 +1,192 @@
1
+ // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
2
+
3
+ import Entity from "./Entity.js";
4
+ import SparkLeavesSwapRequestStatus from "./SparkLeavesSwapRequestStatus.js";
5
+ import { CurrencyAmountToJson } from "./CurrencyAmount.js";
6
+ import { CurrencyAmountFromJson } from "./CurrencyAmount.js";
7
+ import { TransferFromJson } from "./Transfer.js";
8
+ import { SwapLeafToJson } from "./SwapLeaf.js";
9
+ import SwapLeaf from "./SwapLeaf.js";
10
+ import CurrencyAmount from "./CurrencyAmount.js";
11
+ import { Query, isObject } from "@lightsparkdev/core";
12
+ import Transfer from "./Transfer.js";
13
+ import { SwapLeafFromJson } from "./SwapLeaf.js";
14
+
15
+ interface LeavesSwapRequest {
16
+ /**
17
+ * The unique identifier of this entity across all Lightspark systems. Should be treated as an opaque
18
+ * string.
19
+ **/
20
+ id: string;
21
+
22
+ /** The date and time when the entity was first created. **/
23
+ createdAt: string;
24
+
25
+ /** The date and time when the entity was last updated. **/
26
+ updatedAt: string;
27
+
28
+ /** The status of the request. **/
29
+ status: SparkLeavesSwapRequestStatus;
30
+
31
+ /** The total amount of leaves user sent for swap. **/
32
+ totalAmount: CurrencyAmount;
33
+
34
+ /** The target amount of leaves user wanted to get from the swap. **/
35
+ targetAmount: CurrencyAmount;
36
+
37
+ /** The fee user needs to pay for swap. **/
38
+ fee: CurrencyAmount;
39
+
40
+ /** The leaves transfer to user. **/
41
+ inboundTransfer: Transfer;
42
+
43
+ /** The time when the leaves swap request expires. **/
44
+ expiresAt: string;
45
+
46
+ /** The swap leaves returned to the user **/
47
+ swapLeaves: SwapLeaf[];
48
+
49
+ /** The typename of the object **/
50
+ typename: string;
51
+
52
+ /** The leaves transfer out from user. **/
53
+ outboundTransfer?: Transfer | undefined;
54
+ }
55
+
56
+ export const LeavesSwapRequestFromJson = (obj: any): LeavesSwapRequest => {
57
+ return {
58
+ id: obj["leaves_swap_request_id"],
59
+ createdAt: obj["leaves_swap_request_created_at"],
60
+ updatedAt: obj["leaves_swap_request_updated_at"],
61
+ status:
62
+ SparkLeavesSwapRequestStatus[obj["leaves_swap_request_status"]] ??
63
+ SparkLeavesSwapRequestStatus.FUTURE_VALUE,
64
+ totalAmount: CurrencyAmountFromJson(
65
+ obj["leaves_swap_request_total_amount"],
66
+ ),
67
+ targetAmount: CurrencyAmountFromJson(
68
+ obj["leaves_swap_request_target_amount"],
69
+ ),
70
+ fee: CurrencyAmountFromJson(obj["leaves_swap_request_fee"]),
71
+ inboundTransfer: TransferFromJson(
72
+ obj["leaves_swap_request_inbound_transfer"],
73
+ ),
74
+ expiresAt: obj["leaves_swap_request_expires_at"],
75
+ swapLeaves: obj["leaves_swap_request_swap_leaves"].map((e) =>
76
+ SwapLeafFromJson(e),
77
+ ),
78
+ typename: "LeavesSwapRequest",
79
+ outboundTransfer: !!obj["leaves_swap_request_outbound_transfer"]
80
+ ? TransferFromJson(obj["leaves_swap_request_outbound_transfer"])
81
+ : undefined,
82
+ } as LeavesSwapRequest;
83
+ };
84
+ export const LeavesSwapRequestToJson = (obj: LeavesSwapRequest): any => {
85
+ return {
86
+ __typename: "LeavesSwapRequest",
87
+ leaves_swap_request_id: obj.id,
88
+ leaves_swap_request_created_at: obj.createdAt,
89
+ leaves_swap_request_updated_at: obj.updatedAt,
90
+ leaves_swap_request_status: obj.status,
91
+ leaves_swap_request_total_amount: CurrencyAmountToJson(obj.totalAmount),
92
+ leaves_swap_request_target_amount: CurrencyAmountToJson(obj.targetAmount),
93
+ leaves_swap_request_fee: CurrencyAmountToJson(obj.fee),
94
+ leaves_swap_request_inbound_transfer: obj.inboundTransfer.toJson(),
95
+ leaves_swap_request_outbound_transfer: obj.outboundTransfer
96
+ ? obj.outboundTransfer.toJson()
97
+ : undefined,
98
+ leaves_swap_request_expires_at: obj.expiresAt,
99
+ leaves_swap_request_swap_leaves: obj.swapLeaves.map((e) =>
100
+ SwapLeafToJson(e),
101
+ ),
102
+ };
103
+ };
104
+
105
+ export const FRAGMENT = `
106
+ fragment LeavesSwapRequestFragment on LeavesSwapRequest {
107
+ __typename
108
+ leaves_swap_request_id: id
109
+ leaves_swap_request_created_at: created_at
110
+ leaves_swap_request_updated_at: updated_at
111
+ leaves_swap_request_status: status
112
+ leaves_swap_request_total_amount: total_amount {
113
+ __typename
114
+ currency_amount_original_value: original_value
115
+ currency_amount_original_unit: original_unit
116
+ currency_amount_preferred_currency_unit: preferred_currency_unit
117
+ currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
118
+ currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
119
+ }
120
+ leaves_swap_request_target_amount: target_amount {
121
+ __typename
122
+ currency_amount_original_value: original_value
123
+ currency_amount_original_unit: original_unit
124
+ currency_amount_preferred_currency_unit: preferred_currency_unit
125
+ currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
126
+ currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
127
+ }
128
+ leaves_swap_request_fee: fee {
129
+ __typename
130
+ currency_amount_original_value: original_value
131
+ currency_amount_original_unit: original_unit
132
+ currency_amount_preferred_currency_unit: preferred_currency_unit
133
+ currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
134
+ currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
135
+ }
136
+ leaves_swap_request_inbound_transfer: inbound_transfer {
137
+ __typename
138
+ transfer_total_amount: total_amount {
139
+ __typename
140
+ currency_amount_original_value: original_value
141
+ currency_amount_original_unit: original_unit
142
+ currency_amount_preferred_currency_unit: preferred_currency_unit
143
+ currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
144
+ currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
145
+ }
146
+ transfer_spark_id: spark_id
147
+ }
148
+ leaves_swap_request_outbound_transfer: outbound_transfer {
149
+ __typename
150
+ transfer_total_amount: total_amount {
151
+ __typename
152
+ currency_amount_original_value: original_value
153
+ currency_amount_original_unit: original_unit
154
+ currency_amount_preferred_currency_unit: preferred_currency_unit
155
+ currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
156
+ currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
157
+ }
158
+ transfer_spark_id: spark_id
159
+ }
160
+ leaves_swap_request_expires_at: expires_at
161
+ leaves_swap_request_swap_leaves: swap_leaves {
162
+ __typename
163
+ swap_leaf_leaf_id: leaf_id
164
+ swap_leaf_raw_unsigned_refund_transaction: raw_unsigned_refund_transaction
165
+ swap_leaf_adaptor_signed_signature: adaptor_signed_signature
166
+ }
167
+ }`;
168
+
169
+ export const getLeavesSwapRequestQuery = (
170
+ id: string,
171
+ ): Query<LeavesSwapRequest> => {
172
+ return {
173
+ queryPayload: `
174
+ query GetLeavesSwapRequest($id: ID!) {
175
+ entity(id: $id) {
176
+ ... on LeavesSwapRequest {
177
+ ...LeavesSwapRequestFragment
178
+ }
179
+ }
180
+ }
181
+
182
+ ${FRAGMENT}
183
+ `,
184
+ variables: { id },
185
+ constructObject: (data: unknown) =>
186
+ isObject(data) && "entity" in data && isObject(data.entity)
187
+ ? LeavesSwapRequestFromJson(data.entity)
188
+ : null,
189
+ };
190
+ };
191
+
192
+ export default LeavesSwapRequest;
@@ -0,0 +1,41 @@
1
+
2
+ // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
3
+
4
+
5
+ import BitcoinNetwork from './BitcoinNetwork.js';
6
+
7
+
8
+ interface LightningReceiveFeeEstimateInput {
9
+
10
+
11
+ network: BitcoinNetwork;
12
+
13
+ amountSats: number;
14
+
15
+
16
+
17
+
18
+ }
19
+
20
+ export const LightningReceiveFeeEstimateInputFromJson = (obj: any): LightningReceiveFeeEstimateInput => {
21
+ return {
22
+ network: BitcoinNetwork[obj["lightning_receive_fee_estimate_input_network"]] ?? BitcoinNetwork.FUTURE_VALUE,
23
+ amountSats: obj["lightning_receive_fee_estimate_input_amount_sats"],
24
+
25
+ } as LightningReceiveFeeEstimateInput;
26
+
27
+ }
28
+ export const LightningReceiveFeeEstimateInputToJson = (obj: LightningReceiveFeeEstimateInput): any => {
29
+ return {
30
+ lightning_receive_fee_estimate_input_network: obj.network,
31
+ lightning_receive_fee_estimate_input_amount_sats: obj.amountSats,
32
+
33
+ }
34
+
35
+ }
36
+
37
+
38
+
39
+
40
+
41
+ export default LightningReceiveFeeEstimateInput;
@@ -0,0 +1,52 @@
1
+
2
+ // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
3
+
4
+
5
+ import {CurrencyAmountToJson} from './CurrencyAmount.js';
6
+ import {CurrencyAmountFromJson} from './CurrencyAmount.js';
7
+ import CurrencyAmount from './CurrencyAmount.js';
8
+
9
+
10
+ interface LightningReceiveFeeEstimateOutput {
11
+
12
+
13
+ feeEstimate: CurrencyAmount;
14
+
15
+
16
+
17
+
18
+ }
19
+
20
+ export const LightningReceiveFeeEstimateOutputFromJson = (obj: any): LightningReceiveFeeEstimateOutput => {
21
+ return {
22
+ feeEstimate: CurrencyAmountFromJson(obj["lightning_receive_fee_estimate_output_fee_estimate"]),
23
+
24
+ } as LightningReceiveFeeEstimateOutput;
25
+
26
+ }
27
+ export const LightningReceiveFeeEstimateOutputToJson = (obj: LightningReceiveFeeEstimateOutput): any => {
28
+ return {
29
+ lightning_receive_fee_estimate_output_fee_estimate: CurrencyAmountToJson(obj.feeEstimate),
30
+
31
+ }
32
+
33
+ }
34
+
35
+
36
+ export const FRAGMENT = `
37
+ fragment LightningReceiveFeeEstimateOutputFragment on LightningReceiveFeeEstimateOutput {
38
+ __typename
39
+ lightning_receive_fee_estimate_output_fee_estimate: fee_estimate {
40
+ __typename
41
+ currency_amount_original_value: original_value
42
+ currency_amount_original_unit: original_unit
43
+ currency_amount_preferred_currency_unit: preferred_currency_unit
44
+ currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
45
+ currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
46
+ }
47
+ }`;
48
+
49
+
50
+
51
+
52
+ export default LightningReceiveFeeEstimateOutput;
@@ -0,0 +1,147 @@
1
+
2
+ // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
3
+
4
+ import Entity from './Entity.js';
5
+ import {CurrencyAmountToJson} from './CurrencyAmount.js';
6
+ import {CurrencyAmountFromJson} from './CurrencyAmount.js';
7
+ import Invoice from './Invoice.js';
8
+ import {InvoiceFromJson} from './Invoice.js';
9
+ import {TransferFromJson} from './Transfer.js';
10
+ import LightningReceiveRequestStatus from './LightningReceiveRequestStatus.js';
11
+ import CurrencyAmount from './CurrencyAmount.js';
12
+ import { Query, isObject } from '@lightsparkdev/core';
13
+ import Transfer from './Transfer.js';
14
+ import {InvoiceToJson} from './Invoice.js';
15
+
16
+
17
+ interface LightningReceiveRequest {
18
+
19
+
20
+ /**
21
+ * The unique identifier of this entity across all Lightspark systems. Should be treated as an opaque
22
+ * string.
23
+ **/
24
+ id: string;
25
+
26
+ /** The date and time when the entity was first created. **/
27
+ createdAt: string;
28
+
29
+ /** The date and time when the entity was last updated. **/
30
+ updatedAt: string;
31
+
32
+ /** The lightning invoice generated to receive lightning payment. **/
33
+ invoice: Invoice;
34
+
35
+ /** The fee charged for receiving the lightning invoice. **/
36
+ fee: CurrencyAmount;
37
+
38
+ /** The status of the request. **/
39
+ status: LightningReceiveRequestStatus;
40
+
41
+ /** The typename of the object **/
42
+ typename: string;
43
+
44
+ /** The leaves transfer after lightning payment was received. **/
45
+ transfer?: Transfer | undefined;
46
+
47
+
48
+
49
+
50
+ }
51
+
52
+ export const LightningReceiveRequestFromJson = (obj: any): LightningReceiveRequest => {
53
+ return {
54
+ id: obj["lightning_receive_request_id"],
55
+ createdAt: obj["lightning_receive_request_created_at"],
56
+ updatedAt: obj["lightning_receive_request_updated_at"],
57
+ invoice: InvoiceFromJson(obj["lightning_receive_request_invoice"]),
58
+ fee: CurrencyAmountFromJson(obj["lightning_receive_request_fee"]),
59
+ status: LightningReceiveRequestStatus[obj["lightning_receive_request_status"]] ?? LightningReceiveRequestStatus.FUTURE_VALUE,
60
+ typename: "LightningReceiveRequest", transfer: (!!obj["lightning_receive_request_transfer"] ? TransferFromJson(obj["lightning_receive_request_transfer"]) : undefined),
61
+
62
+ } as LightningReceiveRequest;
63
+
64
+ }
65
+ export const LightningReceiveRequestToJson = (obj: LightningReceiveRequest): any => {
66
+ return {
67
+ __typename: "LightningReceiveRequest",lightning_receive_request_id: obj.id,
68
+ lightning_receive_request_created_at: obj.createdAt,
69
+ lightning_receive_request_updated_at: obj.updatedAt,
70
+ lightning_receive_request_invoice: InvoiceToJson(obj.invoice),
71
+ lightning_receive_request_fee: CurrencyAmountToJson(obj.fee),
72
+ lightning_receive_request_status: obj.status,
73
+ lightning_receive_request_transfer: (obj.transfer ? obj.transfer.toJson() : undefined),
74
+
75
+ }
76
+
77
+ }
78
+
79
+
80
+ export const FRAGMENT = `
81
+ fragment LightningReceiveRequestFragment on LightningReceiveRequest {
82
+ __typename
83
+ lightning_receive_request_id: id
84
+ lightning_receive_request_created_at: created_at
85
+ lightning_receive_request_updated_at: updated_at
86
+ lightning_receive_request_invoice: invoice {
87
+ __typename
88
+ invoice_encoded_envoice: encoded_envoice
89
+ invoice_bitcoin_network: bitcoin_network
90
+ invoice_payment_hash: payment_hash
91
+ invoice_amount: amount {
92
+ __typename
93
+ currency_amount_original_value: original_value
94
+ currency_amount_original_unit: original_unit
95
+ currency_amount_preferred_currency_unit: preferred_currency_unit
96
+ currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
97
+ currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
98
+ }
99
+ invoice_created_at: created_at
100
+ invoice_expires_at: expires_at
101
+ invoice_memo: memo
102
+ }
103
+ lightning_receive_request_fee: fee {
104
+ __typename
105
+ currency_amount_original_value: original_value
106
+ currency_amount_original_unit: original_unit
107
+ currency_amount_preferred_currency_unit: preferred_currency_unit
108
+ currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
109
+ currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
110
+ }
111
+ lightning_receive_request_status: status
112
+ lightning_receive_request_transfer: transfer {
113
+ __typename
114
+ transfer_total_amount: total_amount {
115
+ __typename
116
+ currency_amount_original_value: original_value
117
+ currency_amount_original_unit: original_unit
118
+ currency_amount_preferred_currency_unit: preferred_currency_unit
119
+ currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
120
+ currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
121
+ }
122
+ transfer_spark_id: spark_id
123
+ }
124
+ }`;
125
+
126
+
127
+
128
+ export const getLightningReceiveRequestQuery = (id: string): Query<LightningReceiveRequest> => {
129
+ return {
130
+ queryPayload: `
131
+ query GetLightningReceiveRequest($id: ID!) {
132
+ entity(id: $id) {
133
+ ... on LightningReceiveRequest {
134
+ ...LightningReceiveRequestFragment
135
+ }
136
+ }
137
+ }
138
+
139
+ ${FRAGMENT}
140
+ `,
141
+ variables: {id},
142
+ constructObject: (data: unknown) => isObject(data) && "entity" in data && isObject(data.entity) ? LightningReceiveRequestFromJson(data.entity) : null,
143
+ }
144
+ }
145
+
146
+
147
+ export default LightningReceiveRequest;
@@ -0,0 +1,34 @@
1
+
2
+ // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
3
+
4
+
5
+ export enum LightningReceiveRequestStatus {
6
+ /**
7
+ * This is an enum value that represents values that could be added in the future.
8
+ * Clients should support unknown values as more of them could be added without notice.
9
+ */
10
+ FUTURE_VALUE = "FUTURE_VALUE",
11
+
12
+ INVOICE_CREATED = "INVOICE_CREATED",
13
+
14
+ TRANSFER_CREATED = "TRANSFER_CREATED",
15
+
16
+ TRANSFER_CREATION_FAILED = "TRANSFER_CREATION_FAILED",
17
+
18
+ REFUND_SIGNING_COMMITMENTS_QUERYING_FAILED = "REFUND_SIGNING_COMMITMENTS_QUERYING_FAILED",
19
+
20
+ REFUND_SIGNING_FAILED = "REFUND_SIGNING_FAILED",
21
+
22
+ PAYMENT_PREIMAGE_RECOVERED = "PAYMENT_PREIMAGE_RECOVERED",
23
+
24
+ PAYMENT_PREIMAGE_RECOVERING_FAILED = "PAYMENT_PREIMAGE_RECOVERING_FAILED",
25
+
26
+ LIGHTNING_PAYMENT_RECEIVED = "LIGHTNING_PAYMENT_RECEIVED",
27
+
28
+ TRANSFER_FAILED = "TRANSFER_FAILED",
29
+
30
+ TRANSFER_COMPLETED = "TRANSFER_COMPLETED",
31
+
32
+ }
33
+
34
+ export default LightningReceiveRequestStatus;
@@ -0,0 +1,37 @@
1
+
2
+ // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
3
+
4
+
5
+
6
+
7
+
8
+ interface LightningSendFeeEstimateInput {
9
+
10
+
11
+ encodedInvoice: string;
12
+
13
+
14
+
15
+
16
+ }
17
+
18
+ export const LightningSendFeeEstimateInputFromJson = (obj: any): LightningSendFeeEstimateInput => {
19
+ return {
20
+ encodedInvoice: obj["lightning_send_fee_estimate_input_encoded_invoice"],
21
+
22
+ } as LightningSendFeeEstimateInput;
23
+
24
+ }
25
+ export const LightningSendFeeEstimateInputToJson = (obj: LightningSendFeeEstimateInput): any => {
26
+ return {
27
+ lightning_send_fee_estimate_input_encoded_invoice: obj.encodedInvoice,
28
+
29
+ }
30
+
31
+ }
32
+
33
+
34
+
35
+
36
+
37
+ export default LightningSendFeeEstimateInput;
@@ -0,0 +1,52 @@
1
+
2
+ // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
3
+
4
+
5
+ import {CurrencyAmountToJson} from './CurrencyAmount.js';
6
+ import {CurrencyAmountFromJson} from './CurrencyAmount.js';
7
+ import CurrencyAmount from './CurrencyAmount.js';
8
+
9
+
10
+ interface LightningSendFeeEstimateOutput {
11
+
12
+
13
+ feeEstimate: CurrencyAmount;
14
+
15
+
16
+
17
+
18
+ }
19
+
20
+ export const LightningSendFeeEstimateOutputFromJson = (obj: any): LightningSendFeeEstimateOutput => {
21
+ return {
22
+ feeEstimate: CurrencyAmountFromJson(obj["lightning_send_fee_estimate_output_fee_estimate"]),
23
+
24
+ } as LightningSendFeeEstimateOutput;
25
+
26
+ }
27
+ export const LightningSendFeeEstimateOutputToJson = (obj: LightningSendFeeEstimateOutput): any => {
28
+ return {
29
+ lightning_send_fee_estimate_output_fee_estimate: CurrencyAmountToJson(obj.feeEstimate),
30
+
31
+ }
32
+
33
+ }
34
+
35
+
36
+ export const FRAGMENT = `
37
+ fragment LightningSendFeeEstimateOutputFragment on LightningSendFeeEstimateOutput {
38
+ __typename
39
+ lightning_send_fee_estimate_output_fee_estimate: fee_estimate {
40
+ __typename
41
+ currency_amount_original_value: original_value
42
+ currency_amount_original_unit: original_unit
43
+ currency_amount_preferred_currency_unit: preferred_currency_unit
44
+ currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
45
+ currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
46
+ }
47
+ }`;
48
+
49
+
50
+
51
+
52
+ export default LightningSendFeeEstimateOutput;
@@ -0,0 +1,134 @@
1
+
2
+ // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
3
+
4
+ import Entity from './Entity.js';
5
+ import {CurrencyAmountToJson} from './CurrencyAmount.js';
6
+ import {CurrencyAmountFromJson} from './CurrencyAmount.js';
7
+ import LightningSendRequestStatus from './LightningSendRequestStatus.js';
8
+ import {TransferFromJson} from './Transfer.js';
9
+ import CurrencyAmount from './CurrencyAmount.js';
10
+ import { Query, isObject } from '@lightsparkdev/core';
11
+ import Transfer from './Transfer.js';
12
+
13
+
14
+ interface LightningSendRequest {
15
+
16
+
17
+ /**
18
+ * The unique identifier of this entity across all Lightspark systems. Should be treated as an opaque
19
+ * string.
20
+ **/
21
+ id: string;
22
+
23
+ /** The date and time when the entity was first created. **/
24
+ createdAt: string;
25
+
26
+ /** The date and time when the entity was last updated. **/
27
+ updatedAt: string;
28
+
29
+ /** The lightning invoice user requested to pay. **/
30
+ encodedInvoice: string;
31
+
32
+ /** The fee charged for paying the lightning invoice. **/
33
+ fee: CurrencyAmount;
34
+
35
+ /** The idempotency key of the request. **/
36
+ idempotencyKey: string;
37
+
38
+ /** The status of the request. **/
39
+ status: LightningSendRequestStatus;
40
+
41
+ /** The typename of the object **/
42
+ typename: string;
43
+
44
+ /** The leaves transfer after lightning payment was sent. **/
45
+ transfer?: Transfer | undefined;
46
+
47
+
48
+
49
+
50
+ }
51
+
52
+ export const LightningSendRequestFromJson = (obj: any): LightningSendRequest => {
53
+ return {
54
+ id: obj["lightning_send_request_id"],
55
+ createdAt: obj["lightning_send_request_created_at"],
56
+ updatedAt: obj["lightning_send_request_updated_at"],
57
+ encodedInvoice: obj["lightning_send_request_encoded_invoice"],
58
+ fee: CurrencyAmountFromJson(obj["lightning_send_request_fee"]),
59
+ idempotencyKey: obj["lightning_send_request_idempotency_key"],
60
+ status: LightningSendRequestStatus[obj["lightning_send_request_status"]] ?? LightningSendRequestStatus.FUTURE_VALUE,
61
+ typename: "LightningSendRequest", transfer: (!!obj["lightning_send_request_transfer"] ? TransferFromJson(obj["lightning_send_request_transfer"]) : undefined),
62
+
63
+ } as LightningSendRequest;
64
+
65
+ }
66
+ export const LightningSendRequestToJson = (obj: LightningSendRequest): any => {
67
+ return {
68
+ __typename: "LightningSendRequest",lightning_send_request_id: obj.id,
69
+ lightning_send_request_created_at: obj.createdAt,
70
+ lightning_send_request_updated_at: obj.updatedAt,
71
+ lightning_send_request_encoded_invoice: obj.encodedInvoice,
72
+ lightning_send_request_fee: CurrencyAmountToJson(obj.fee),
73
+ lightning_send_request_idempotency_key: obj.idempotencyKey,
74
+ lightning_send_request_status: obj.status,
75
+ lightning_send_request_transfer: (obj.transfer ? obj.transfer.toJson() : undefined),
76
+
77
+ }
78
+
79
+ }
80
+
81
+
82
+ export const FRAGMENT = `
83
+ fragment LightningSendRequestFragment on LightningSendRequest {
84
+ __typename
85
+ lightning_send_request_id: id
86
+ lightning_send_request_created_at: created_at
87
+ lightning_send_request_updated_at: updated_at
88
+ lightning_send_request_encoded_invoice: encoded_invoice
89
+ lightning_send_request_fee: fee {
90
+ __typename
91
+ currency_amount_original_value: original_value
92
+ currency_amount_original_unit: original_unit
93
+ currency_amount_preferred_currency_unit: preferred_currency_unit
94
+ currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
95
+ currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
96
+ }
97
+ lightning_send_request_idempotency_key: idempotency_key
98
+ lightning_send_request_status: status
99
+ lightning_send_request_transfer: transfer {
100
+ __typename
101
+ transfer_total_amount: total_amount {
102
+ __typename
103
+ currency_amount_original_value: original_value
104
+ currency_amount_original_unit: original_unit
105
+ currency_amount_preferred_currency_unit: preferred_currency_unit
106
+ currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
107
+ currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
108
+ }
109
+ transfer_spark_id: spark_id
110
+ }
111
+ }`;
112
+
113
+
114
+
115
+ export const getLightningSendRequestQuery = (id: string): Query<LightningSendRequest> => {
116
+ return {
117
+ queryPayload: `
118
+ query GetLightningSendRequest($id: ID!) {
119
+ entity(id: $id) {
120
+ ... on LightningSendRequest {
121
+ ...LightningSendRequestFragment
122
+ }
123
+ }
124
+ }
125
+
126
+ ${FRAGMENT}
127
+ `,
128
+ variables: {id},
129
+ constructObject: (data: unknown) => isObject(data) && "entity" in data && isObject(data.entity) ? LightningSendRequestFromJson(data.entity) : null,
130
+ }
131
+ }
132
+
133
+
134
+ export default LightningSendRequest;