@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,45 @@
1
+
2
+ // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
3
+
4
+
5
+
6
+
7
+
8
+ interface CompleteCoopExitOutput {
9
+
10
+
11
+ requestId: string;
12
+
13
+
14
+
15
+
16
+ }
17
+
18
+ export const CompleteCoopExitOutputFromJson = (obj: any): CompleteCoopExitOutput => {
19
+ return {
20
+ requestId: obj["complete_coop_exit_output_request"].id,
21
+
22
+ } as CompleteCoopExitOutput;
23
+
24
+ }
25
+ export const CompleteCoopExitOutputToJson = (obj: CompleteCoopExitOutput): any => {
26
+ return {
27
+ complete_coop_exit_output_request: { id: obj.requestId },
28
+
29
+ }
30
+
31
+ }
32
+
33
+
34
+ export const FRAGMENT = `
35
+ fragment CompleteCoopExitOutputFragment on CompleteCoopExitOutput {
36
+ __typename
37
+ complete_coop_exit_output_request: request {
38
+ id
39
+ }
40
+ }`;
41
+
42
+
43
+
44
+
45
+ export default CompleteCoopExitOutput;
@@ -0,0 +1,45 @@
1
+
2
+ // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
3
+
4
+
5
+
6
+
7
+
8
+ interface CompleteLeavesSwapInput {
9
+
10
+
11
+ adaptorSecretKey: string;
12
+
13
+ userOutboundTransferExternalId: string;
14
+
15
+ leavesSwapRequestId: string;
16
+
17
+
18
+
19
+
20
+ }
21
+
22
+ export const CompleteLeavesSwapInputFromJson = (obj: any): CompleteLeavesSwapInput => {
23
+ return {
24
+ adaptorSecretKey: obj["complete_leaves_swap_input_adaptor_secret_key"],
25
+ userOutboundTransferExternalId: obj["complete_leaves_swap_input_user_outbound_transfer_external_id"],
26
+ leavesSwapRequestId: obj["complete_leaves_swap_input_leaves_swap_request_id"],
27
+
28
+ } as CompleteLeavesSwapInput;
29
+
30
+ }
31
+ export const CompleteLeavesSwapInputToJson = (obj: CompleteLeavesSwapInput): any => {
32
+ return {
33
+ complete_leaves_swap_input_adaptor_secret_key: obj.adaptorSecretKey,
34
+ complete_leaves_swap_input_user_outbound_transfer_external_id: obj.userOutboundTransferExternalId,
35
+ complete_leaves_swap_input_leaves_swap_request_id: obj.leavesSwapRequestId,
36
+
37
+ }
38
+
39
+ }
40
+
41
+
42
+
43
+
44
+
45
+ export default CompleteLeavesSwapInput;
@@ -0,0 +1,45 @@
1
+
2
+ // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
3
+
4
+
5
+
6
+
7
+
8
+ interface CompleteLeavesSwapOutput {
9
+
10
+
11
+ requestId: string;
12
+
13
+
14
+
15
+
16
+ }
17
+
18
+ export const CompleteLeavesSwapOutputFromJson = (obj: any): CompleteLeavesSwapOutput => {
19
+ return {
20
+ requestId: obj["complete_leaves_swap_output_request"].id,
21
+
22
+ } as CompleteLeavesSwapOutput;
23
+
24
+ }
25
+ export const CompleteLeavesSwapOutputToJson = (obj: CompleteLeavesSwapOutput): any => {
26
+ return {
27
+ complete_leaves_swap_output_request: { id: obj.requestId },
28
+
29
+ }
30
+
31
+ }
32
+
33
+
34
+ export const FRAGMENT = `
35
+ fragment CompleteLeavesSwapOutputFragment on CompleteLeavesSwapOutput {
36
+ __typename
37
+ complete_leaves_swap_output_request: request {
38
+ id
39
+ }
40
+ }`;
41
+
42
+
43
+
44
+
45
+ export default CompleteLeavesSwapOutput;
@@ -0,0 +1,41 @@
1
+
2
+ // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
3
+
4
+
5
+
6
+
7
+
8
+ interface CompleteSeedReleaseInput {
9
+
10
+
11
+ phoneNumber: string;
12
+
13
+ code: string;
14
+
15
+
16
+
17
+
18
+ }
19
+
20
+ export const CompleteSeedReleaseInputFromJson = (obj: any): CompleteSeedReleaseInput => {
21
+ return {
22
+ phoneNumber: obj["complete_seed_release_input_phone_number"],
23
+ code: obj["complete_seed_release_input_code"],
24
+
25
+ } as CompleteSeedReleaseInput;
26
+
27
+ }
28
+ export const CompleteSeedReleaseInputToJson = (obj: CompleteSeedReleaseInput): any => {
29
+ return {
30
+ complete_seed_release_input_phone_number: obj.phoneNumber,
31
+ complete_seed_release_input_code: obj.code,
32
+
33
+ }
34
+
35
+ }
36
+
37
+
38
+
39
+
40
+
41
+ export default CompleteSeedReleaseInput;
@@ -0,0 +1,43 @@
1
+
2
+ // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
3
+
4
+
5
+
6
+
7
+
8
+ interface CompleteSeedReleaseOutput {
9
+
10
+
11
+ seed: string;
12
+
13
+
14
+
15
+
16
+ }
17
+
18
+ export const CompleteSeedReleaseOutputFromJson = (obj: any): CompleteSeedReleaseOutput => {
19
+ return {
20
+ seed: obj["complete_seed_release_output_seed"],
21
+
22
+ } as CompleteSeedReleaseOutput;
23
+
24
+ }
25
+ export const CompleteSeedReleaseOutputToJson = (obj: CompleteSeedReleaseOutput): any => {
26
+ return {
27
+ complete_seed_release_output_seed: obj.seed,
28
+
29
+ }
30
+
31
+ }
32
+
33
+
34
+ export const FRAGMENT = `
35
+ fragment CompleteSeedReleaseOutputFragment on CompleteSeedReleaseOutput {
36
+ __typename
37
+ complete_seed_release_output_seed: seed
38
+ }`;
39
+
40
+
41
+
42
+
43
+ export default CompleteSeedReleaseOutput;
@@ -0,0 +1,90 @@
1
+
2
+ // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
3
+
4
+
5
+ import SparkTransferToLeavesConnection from './SparkTransferToLeavesConnection.js';
6
+ import {PageInfoToJson} from './PageInfo.js';
7
+ import {LeafToJson} from './Leaf.js';
8
+ import {PageInfoFromJson} from './PageInfo.js';
9
+ import { LightsparkException } from '@lightsparkdev/core';
10
+ import {LeafFromJson} from './Leaf.js';
11
+ import PageInfo from './PageInfo.js';
12
+
13
+
14
+ interface Connection {
15
+
16
+
17
+ /**
18
+ * The total count of objects in this connection, using the current filters. It is different from the
19
+ * number of objects returned in the current page (in the `entities` field).
20
+ **/
21
+ count: number;
22
+
23
+ /** An object that holds pagination information about the objects in this connection. **/
24
+ pageInfo: PageInfo;
25
+
26
+ /** The typename of the object **/
27
+ typename: string;
28
+
29
+
30
+
31
+
32
+ }
33
+
34
+ export const ConnectionFromJson = (obj: any): Connection => {
35
+ if (obj["__typename"] == "SparkTransferToLeavesConnection") {
36
+ return {
37
+ count: obj["spark_transfer_to_leaves_connection_count"],
38
+ pageInfo: PageInfoFromJson(obj["spark_transfer_to_leaves_connection_page_info"]),
39
+ entities: obj["spark_transfer_to_leaves_connection_entities"].map((e) => LeafFromJson(e)),
40
+ typename: "SparkTransferToLeavesConnection",
41
+ } as SparkTransferToLeavesConnection;
42
+
43
+ } throw new LightsparkException("DeserializationError", `Couldn't find a concrete type for interface Connection corresponding to the typename=${obj["__typename"]}`)
44
+ }
45
+ export const ConnectionToJson = (obj: Connection): any => {
46
+ if (obj.typename == "SparkTransferToLeavesConnection") {
47
+ const sparkTransferToLeavesConnection = obj as SparkTransferToLeavesConnection;
48
+ return {
49
+ __typename: "SparkTransferToLeavesConnection",spark_transfer_to_leaves_connection_count: sparkTransferToLeavesConnection.count,
50
+ spark_transfer_to_leaves_connection_page_info: PageInfoToJson(sparkTransferToLeavesConnection.pageInfo),
51
+ spark_transfer_to_leaves_connection_entities: sparkTransferToLeavesConnection.entities.map((e) => LeafToJson(e)),
52
+
53
+ }
54
+
55
+ } throw new LightsparkException("DeserializationError", `Couldn't find a concrete type for interface Connection corresponding to the typename=${obj.typename}`)
56
+ }
57
+
58
+
59
+ export const FRAGMENT = `
60
+ fragment ConnectionFragment on Connection {
61
+ __typename
62
+ ... on SparkTransferToLeavesConnection {
63
+ __typename
64
+ spark_transfer_to_leaves_connection_count: count
65
+ spark_transfer_to_leaves_connection_page_info: page_info {
66
+ __typename
67
+ page_info_has_next_page: has_next_page
68
+ page_info_has_previous_page: has_previous_page
69
+ page_info_start_cursor: start_cursor
70
+ page_info_end_cursor: end_cursor
71
+ }
72
+ spark_transfer_to_leaves_connection_entities: entities {
73
+ __typename
74
+ leaf_amount: amount {
75
+ __typename
76
+ currency_amount_original_value: original_value
77
+ currency_amount_original_unit: original_unit
78
+ currency_amount_preferred_currency_unit: preferred_currency_unit
79
+ currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
80
+ currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
81
+ }
82
+ leaf_spark_node_id: spark_node_id
83
+ }
84
+ }
85
+ }`;
86
+
87
+
88
+
89
+
90
+ export default Connection;
@@ -0,0 +1,41 @@
1
+
2
+ // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
3
+
4
+
5
+
6
+
7
+
8
+ interface CoopExitFeeEstimateInput {
9
+
10
+
11
+ leafExternalIds: string[];
12
+
13
+ withdrawalAddress: string;
14
+
15
+
16
+
17
+
18
+ }
19
+
20
+ export const CoopExitFeeEstimateInputFromJson = (obj: any): CoopExitFeeEstimateInput => {
21
+ return {
22
+ leafExternalIds: obj["coop_exit_fee_estimate_input_leaf_external_ids"],
23
+ withdrawalAddress: obj["coop_exit_fee_estimate_input_withdrawal_address"],
24
+
25
+ } as CoopExitFeeEstimateInput;
26
+
27
+ }
28
+ export const CoopExitFeeEstimateInputToJson = (obj: CoopExitFeeEstimateInput): any => {
29
+ return {
30
+ coop_exit_fee_estimate_input_leaf_external_ids: obj.leafExternalIds,
31
+ coop_exit_fee_estimate_input_withdrawal_address: obj.withdrawalAddress,
32
+
33
+ }
34
+
35
+ }
36
+
37
+
38
+
39
+
40
+
41
+ export default CoopExitFeeEstimateInput;
@@ -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 CoopExitFeeEstimateOutput {
11
+
12
+
13
+ feeEstimate: CurrencyAmount;
14
+
15
+
16
+
17
+
18
+ }
19
+
20
+ export const CoopExitFeeEstimateOutputFromJson = (obj: any): CoopExitFeeEstimateOutput => {
21
+ return {
22
+ feeEstimate: CurrencyAmountFromJson(obj["coop_exit_fee_estimate_output_fee_estimate"]),
23
+
24
+ } as CoopExitFeeEstimateOutput;
25
+
26
+ }
27
+ export const CoopExitFeeEstimateOutputToJson = (obj: CoopExitFeeEstimateOutput): any => {
28
+ return {
29
+ coop_exit_fee_estimate_output_fee_estimate: CurrencyAmountToJson(obj.feeEstimate),
30
+
31
+ }
32
+
33
+ }
34
+
35
+
36
+ export const FRAGMENT = `
37
+ fragment CoopExitFeeEstimateOutputFragment on CoopExitFeeEstimateOutput {
38
+ __typename
39
+ coop_exit_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 CoopExitFeeEstimateOutput;
@@ -0,0 +1,118 @@
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 SparkCoopExitRequestStatus from './SparkCoopExitRequestStatus.js';
8
+ import CurrencyAmount from './CurrencyAmount.js';
9
+ import { Query, isObject } from '@lightsparkdev/core';
10
+
11
+
12
+ interface CoopExitRequest {
13
+
14
+
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 the entity was first created. **/
22
+ createdAt: string;
23
+
24
+ /** The date and time when the entity was last updated. **/
25
+ updatedAt: string;
26
+
27
+ /**
28
+ * The fee includes what user pays for the coop exit and the L1 broadcast fee. The amount user will
29
+ * receive on L1 is total_amount - fee.
30
+ **/
31
+ fee: CurrencyAmount;
32
+
33
+ /** The status of the request. **/
34
+ status: SparkCoopExitRequestStatus;
35
+
36
+ /** The time when the coop exit request expires and the UTXOs are released. **/
37
+ expiresAt: string;
38
+
39
+ /** The raw connector transaction. **/
40
+ rawConnectorTransaction: string;
41
+
42
+ /** The typename of the object **/
43
+ typename: string;
44
+
45
+
46
+
47
+
48
+ }
49
+
50
+ export const CoopExitRequestFromJson = (obj: any): CoopExitRequest => {
51
+ return {
52
+ id: obj["coop_exit_request_id"],
53
+ createdAt: obj["coop_exit_request_created_at"],
54
+ updatedAt: obj["coop_exit_request_updated_at"],
55
+ fee: CurrencyAmountFromJson(obj["coop_exit_request_fee"]),
56
+ status: SparkCoopExitRequestStatus[obj["coop_exit_request_status"]] ?? SparkCoopExitRequestStatus.FUTURE_VALUE,
57
+ expiresAt: obj["coop_exit_request_expires_at"],
58
+ rawConnectorTransaction: obj["coop_exit_request_raw_connector_transaction"],
59
+ typename: "CoopExitRequest",
60
+ } as CoopExitRequest;
61
+
62
+ }
63
+ export const CoopExitRequestToJson = (obj: CoopExitRequest): any => {
64
+ return {
65
+ __typename: "CoopExitRequest",coop_exit_request_id: obj.id,
66
+ coop_exit_request_created_at: obj.createdAt,
67
+ coop_exit_request_updated_at: obj.updatedAt,
68
+ coop_exit_request_fee: CurrencyAmountToJson(obj.fee),
69
+ coop_exit_request_status: obj.status,
70
+ coop_exit_request_expires_at: obj.expiresAt,
71
+ coop_exit_request_raw_connector_transaction: obj.rawConnectorTransaction,
72
+
73
+ }
74
+
75
+ }
76
+
77
+
78
+ export const FRAGMENT = `
79
+ fragment CoopExitRequestFragment on CoopExitRequest {
80
+ __typename
81
+ coop_exit_request_id: id
82
+ coop_exit_request_created_at: created_at
83
+ coop_exit_request_updated_at: updated_at
84
+ coop_exit_request_fee: fee {
85
+ __typename
86
+ currency_amount_original_value: original_value
87
+ currency_amount_original_unit: original_unit
88
+ currency_amount_preferred_currency_unit: preferred_currency_unit
89
+ currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
90
+ currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
91
+ }
92
+ coop_exit_request_status: status
93
+ coop_exit_request_expires_at: expires_at
94
+ coop_exit_request_raw_connector_transaction: raw_connector_transaction
95
+ }`;
96
+
97
+
98
+
99
+ export const getCoopExitRequestQuery = (id: string): Query<CoopExitRequest> => {
100
+ return {
101
+ queryPayload: `
102
+ query GetCoopExitRequest($id: ID!) {
103
+ entity(id: $id) {
104
+ ... on CoopExitRequest {
105
+ ...CoopExitRequestFragment
106
+ }
107
+ }
108
+ }
109
+
110
+ ${FRAGMENT}
111
+ `,
112
+ variables: {id},
113
+ constructObject: (data: unknown) => isObject(data) && "entity" in data && isObject(data.entity) ? CoopExitRequestFromJson(data.entity) : null,
114
+ }
115
+ }
116
+
117
+
118
+ export default CoopExitRequest;
@@ -0,0 +1,74 @@
1
+
2
+ // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
3
+
4
+
5
+ import CurrencyUnit from './CurrencyUnit.js';
6
+
7
+ /** This object represents the value and unit for an amount of currency. **/
8
+ interface CurrencyAmount {
9
+
10
+
11
+ /** The original numeric value for this CurrencyAmount. **/
12
+ originalValue: number;
13
+
14
+ /** The original unit of currency for this CurrencyAmount. **/
15
+ originalUnit: CurrencyUnit;
16
+
17
+ /** The unit of user's preferred currency. **/
18
+ preferredCurrencyUnit: CurrencyUnit;
19
+
20
+ /**
21
+ * The rounded numeric value for this CurrencyAmount in the very base level of user's preferred
22
+ * currency. For example, for USD, the value will be in cents.
23
+ **/
24
+ preferredCurrencyValueRounded: number;
25
+
26
+ /**
27
+ * The approximate float value for this CurrencyAmount in the very base level of user's preferred
28
+ * currency. For example, for USD, the value will be in cents.
29
+ **/
30
+ preferredCurrencyValueApprox: number;
31
+
32
+
33
+
34
+
35
+ }
36
+
37
+ export const CurrencyAmountFromJson = (obj: any): CurrencyAmount => {
38
+ return {
39
+ originalValue: obj["currency_amount_original_value"],
40
+ originalUnit: CurrencyUnit[obj["currency_amount_original_unit"]] ?? CurrencyUnit.FUTURE_VALUE,
41
+ preferredCurrencyUnit: CurrencyUnit[obj["currency_amount_preferred_currency_unit"]] ?? CurrencyUnit.FUTURE_VALUE,
42
+ preferredCurrencyValueRounded: obj["currency_amount_preferred_currency_value_rounded"],
43
+ preferredCurrencyValueApprox: obj["currency_amount_preferred_currency_value_approx"],
44
+
45
+ } as CurrencyAmount;
46
+
47
+ }
48
+ export const CurrencyAmountToJson = (obj: CurrencyAmount): any => {
49
+ return {
50
+ currency_amount_original_value: obj.originalValue,
51
+ currency_amount_original_unit: obj.originalUnit,
52
+ currency_amount_preferred_currency_unit: obj.preferredCurrencyUnit,
53
+ currency_amount_preferred_currency_value_rounded: obj.preferredCurrencyValueRounded,
54
+ currency_amount_preferred_currency_value_approx: obj.preferredCurrencyValueApprox,
55
+
56
+ }
57
+
58
+ }
59
+
60
+
61
+ export const FRAGMENT = `
62
+ fragment CurrencyAmountFragment on CurrencyAmount {
63
+ __typename
64
+ currency_amount_original_value: original_value
65
+ currency_amount_original_unit: original_unit
66
+ currency_amount_preferred_currency_unit: preferred_currency_unit
67
+ currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
68
+ currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
69
+ }`;
70
+
71
+
72
+
73
+
74
+ export default CurrencyAmount;
@@ -0,0 +1,32 @@
1
+
2
+ // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
3
+
4
+ /** This enum identifies the unit of currency associated with a CurrencyAmount. **/
5
+ export enum CurrencyUnit {
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
+ /** Bitcoin is the cryptocurrency native to the Bitcoin network. It is used as the native medium for value transfer for the Lightning Network. **/
12
+ BITCOIN = "BITCOIN",
13
+ /** 0.00000001 (10e-8) Bitcoin or one hundred millionth of a Bitcoin. This is the unit most commonly used in Lightning transactions. **/
14
+ SATOSHI = "SATOSHI",
15
+ /** 0.001 Satoshi, or 10e-11 Bitcoin. We recommend using the Satoshi unit instead when possible. **/
16
+ MILLISATOSHI = "MILLISATOSHI",
17
+ /** United States Dollar. **/
18
+ USD = "USD",
19
+ /** Mexican Peso. **/
20
+ MXN = "MXN",
21
+ /** Philippine Peso. **/
22
+ PHP = "PHP",
23
+ /** 0.000000001 (10e-9) Bitcoin or a billionth of a Bitcoin. We recommend using the Satoshi unit instead when possible. **/
24
+ NANOBITCOIN = "NANOBITCOIN",
25
+ /** 0.000001 (10e-6) Bitcoin or a millionth of a Bitcoin. We recommend using the Satoshi unit instead when possible. **/
26
+ MICROBITCOIN = "MICROBITCOIN",
27
+ /** 0.001 (10e-3) Bitcoin or a thousandth of a Bitcoin. We recommend using the Satoshi unit instead when possible. **/
28
+ MILLIBITCOIN = "MILLIBITCOIN",
29
+
30
+ }
31
+
32
+ export default CurrencyUnit;