@buildonspark/spark-sdk 0.1.41 → 0.1.43

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 (156) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/android/src/main/jniLibs/arm64-v8a/libuniffi_spark_frost.so +0 -0
  3. package/android/src/main/jniLibs/armeabi-v7a/libuniffi_spark_frost.so +0 -0
  4. package/android/src/main/jniLibs/x86/libuniffi_spark_frost.so +0 -0
  5. package/android/src/main/jniLibs/x86_64/libuniffi_spark_frost.so +0 -0
  6. package/dist/LightningSendFeeEstimateInput-BgOhEAI-.d.cts +10 -0
  7. package/dist/LightningSendFeeEstimateInput-BgOhEAI-.d.ts +10 -0
  8. package/dist/{RequestLightningSendInput-mXUWn_cp.d.ts → RequestLightningSendInput-D7fZdT4A.d.ts} +35 -16
  9. package/dist/{RequestLightningSendInput-DXcLoiCe.d.cts → RequestLightningSendInput-Na1mHdWg.d.cts} +35 -16
  10. package/dist/address/index.cjs +38 -7
  11. package/dist/address/index.d.cts +2 -2
  12. package/dist/address/index.d.ts +2 -2
  13. package/dist/address/index.js +3 -3
  14. package/dist/{chunk-ATEHMLKP.js → chunk-6AFUC5M2.js} +1 -1
  15. package/dist/{chunk-ZXDE2XMU.js → chunk-BUTZWYBW.js} +9 -6
  16. package/dist/{chunk-7EFSUADA.js → chunk-DOA6QXYQ.js} +1 -0
  17. package/dist/{chunk-J5W5Q2ZP.js → chunk-DQYKQJRZ.js} +291 -7
  18. package/dist/{chunk-TWF35O6M.js → chunk-GSI4OLXZ.js} +32 -1
  19. package/dist/{chunk-2ZXXLPG2.js → chunk-GYQR4B4P.js} +5 -4
  20. package/dist/{chunk-ROKY5KS4.js → chunk-HRQRRDSS.js} +53 -15
  21. package/dist/{chunk-YEZDPUFY.js → chunk-IRW5TWMH.js} +8 -8
  22. package/dist/{chunk-7VMYMQLF.js → chunk-NSJF5F5O.js} +1 -1
  23. package/dist/{chunk-TM4TOEOX.js → chunk-O4RYNJNB.js} +3 -3
  24. package/dist/{chunk-MGPRLH6Q.js → chunk-QNNSEJ4P.js} +1 -1
  25. package/dist/{chunk-UKT6OFLO.js → chunk-TIUBYNN5.js} +13 -7
  26. package/dist/{chunk-6YVPOQ2A.js → chunk-TOSP3INR.js} +235 -143
  27. package/dist/chunk-VFJQNBFX.js +21 -0
  28. package/dist/{chunk-KKSU7OZO.js → chunk-WWOTVNPP.js} +195 -67
  29. package/dist/{chunk-HK6LPV6Z.js → chunk-Z5HIAYFT.js} +1 -1
  30. package/dist/graphql/objects/index.cjs +229 -135
  31. package/dist/graphql/objects/index.d.cts +54 -9
  32. package/dist/graphql/objects/index.d.ts +54 -9
  33. package/dist/graphql/objects/index.js +3 -3
  34. package/dist/{index-OSDtPMmC.d.ts → index-7RYRH5wc.d.ts} +10 -8
  35. package/dist/{index-CFh4uWzi.d.cts → index-BJOc8Ur-.d.cts} +10 -8
  36. package/dist/index.cjs +790 -315
  37. package/dist/index.d.cts +8 -7
  38. package/dist/index.d.ts +8 -7
  39. package/dist/index.js +26 -26
  40. package/dist/index.node.cjs +790 -315
  41. package/dist/index.node.d.cts +9 -8
  42. package/dist/index.node.d.ts +9 -8
  43. package/dist/index.node.js +26 -26
  44. package/dist/native/index.cjs +812 -332
  45. package/dist/native/index.d.cts +53 -18
  46. package/dist/native/index.d.ts +53 -18
  47. package/dist/native/index.js +659 -181
  48. package/dist/{network-BiwBmoOg.d.cts → network-D5lKssVl.d.cts} +1 -1
  49. package/dist/{network-BF2GYPye.d.ts → network-xkBSpaTn.d.ts} +1 -1
  50. package/dist/proto/lrc20.d.cts +1 -1
  51. package/dist/proto/lrc20.d.ts +1 -1
  52. package/dist/proto/spark.d.cts +1 -1
  53. package/dist/proto/spark.d.ts +1 -1
  54. package/dist/proto/spark_token.d.cts +1 -1
  55. package/dist/proto/spark_token.d.ts +1 -1
  56. package/dist/{sdk-types-CfhdFnsA.d.cts → sdk-types-B-q9py_P.d.cts} +1 -1
  57. package/dist/{sdk-types-MnQrHolg.d.ts → sdk-types-BPoPgzda.d.ts} +1 -1
  58. package/dist/services/config.cjs +118 -69
  59. package/dist/services/config.d.cts +6 -4
  60. package/dist/services/config.d.ts +6 -4
  61. package/dist/services/config.js +9 -9
  62. package/dist/services/connection.cjs +95 -15
  63. package/dist/services/connection.d.cts +6 -4
  64. package/dist/services/connection.d.ts +6 -4
  65. package/dist/services/connection.js +3 -3
  66. package/dist/services/index.cjs +487 -117
  67. package/dist/services/index.d.cts +5 -4
  68. package/dist/services/index.d.ts +5 -4
  69. package/dist/services/index.js +19 -19
  70. package/dist/services/lrc-connection.cjs +50 -7
  71. package/dist/services/lrc-connection.d.cts +5 -4
  72. package/dist/services/lrc-connection.d.ts +5 -4
  73. package/dist/services/lrc-connection.js +3 -3
  74. package/dist/services/token-transactions.cjs +351 -36
  75. package/dist/services/token-transactions.d.cts +5 -4
  76. package/dist/services/token-transactions.d.ts +5 -4
  77. package/dist/services/token-transactions.js +6 -6
  78. package/dist/services/wallet-config.cjs +1 -0
  79. package/dist/services/wallet-config.d.cts +6 -4
  80. package/dist/services/wallet-config.d.ts +6 -4
  81. package/dist/services/wallet-config.js +1 -1
  82. package/dist/signer/signer.cjs +117 -64
  83. package/dist/signer/signer.d.cts +4 -3
  84. package/dist/signer/signer.d.ts +4 -3
  85. package/dist/signer/signer.js +15 -7
  86. package/dist/{signer-CylxIujU.d.ts → signer-IO3oMRNj.d.cts} +2 -1
  87. package/dist/{signer-BhLS7SYR.d.cts → signer-wqesWifN.d.ts} +2 -1
  88. package/dist/{spark-DjR1b3TC.d.cts → spark-CDm4gqS6.d.cts} +1 -1
  89. package/dist/{spark-DjR1b3TC.d.ts → spark-CDm4gqS6.d.ts} +1 -1
  90. package/dist/types/index.cjs +282 -188
  91. package/dist/types/index.d.cts +7 -6
  92. package/dist/types/index.d.ts +7 -6
  93. package/dist/types/index.js +3 -3
  94. package/dist/utils/index.cjs +90 -58
  95. package/dist/utils/index.d.cts +6 -5
  96. package/dist/utils/index.d.ts +6 -5
  97. package/dist/utils/index.js +16 -16
  98. package/ios/spark_frostFFI.xcframework/ios-arm64/SparkFrost +0 -0
  99. package/ios/spark_frostFFI.xcframework/ios-arm64/spark_frostFFI.framework/spark_frostFFI +0 -0
  100. package/ios/spark_frostFFI.xcframework/ios-arm64_x86_64-simulator/SparkFrost +0 -0
  101. package/ios/spark_frostFFI.xcframework/ios-arm64_x86_64-simulator/spark_frostFFI.framework/spark_frostFFI +0 -0
  102. package/ios/spark_frostFFI.xcframework/macos-arm64_x86_64/spark_frostFFI.framework/spark_frostFFI +0 -0
  103. package/package.json +4 -4
  104. package/src/constants.ts +21 -0
  105. package/src/errors/base.ts +43 -1
  106. package/src/graphql/client.ts +4 -0
  107. package/src/graphql/mutations/RequestLightningSend.ts +2 -0
  108. package/src/graphql/objects/ClaimStaticDepositInput.ts +1 -1
  109. package/src/graphql/objects/ClaimStaticDepositStatus.ts +4 -2
  110. package/src/graphql/objects/Connection.ts +7 -7
  111. package/src/graphql/objects/CoopExitFeeEstimate.ts +1 -1
  112. package/src/graphql/objects/CoopExitFeeQuote.ts +202 -0
  113. package/src/graphql/objects/CoopExitFeeQuoteInput.ts +41 -0
  114. package/src/graphql/objects/CoopExitFeeQuoteOutput.ts +45 -0
  115. package/src/graphql/objects/CoopExitRequest.ts +21 -0
  116. package/src/graphql/objects/CurrencyUnit.ts +26 -28
  117. package/src/graphql/objects/Entity.ts +84 -0
  118. package/src/graphql/objects/Invoice.ts +2 -2
  119. package/src/graphql/objects/Leaf.ts +1 -1
  120. package/src/graphql/objects/LeavesSwapFeeEstimateOutput.ts +1 -1
  121. package/src/graphql/objects/LeavesSwapRequest.ts +6 -0
  122. package/src/graphql/objects/LightningReceiveRequest.ts +11 -0
  123. package/src/graphql/objects/LightningSendFeeEstimateInput.ts +8 -0
  124. package/src/graphql/objects/LightningSendFeeEstimateOutput.ts +1 -1
  125. package/src/graphql/objects/LightningSendRequest.ts +3 -0
  126. package/src/graphql/objects/RequestCoopExitInput.ts +8 -0
  127. package/src/graphql/objects/RequestLeavesSwapInput.ts +5 -1
  128. package/src/graphql/objects/RequestLightningReceiveInput.ts +9 -2
  129. package/src/graphql/objects/RequestLightningSendInput.ts +8 -0
  130. package/src/graphql/objects/SparkCoopExitRequestStatus.ts +2 -0
  131. package/src/graphql/objects/SparkUserRequestType.ts +2 -0
  132. package/src/graphql/objects/SparkWalletUser.ts +20 -0
  133. package/src/graphql/objects/UserRequest.ts +32 -0
  134. package/src/graphql/objects/VerifyChallengeInput.ts +1 -1
  135. package/src/graphql/objects/index.ts +12 -3
  136. package/src/graphql/queries/LightningSendFeeEstimate.ts +2 -0
  137. package/src/logger.ts +3 -0
  138. package/src/native/index.ts +1 -0
  139. package/src/services/config.ts +4 -0
  140. package/src/services/connection.ts +68 -29
  141. package/src/services/coop-exit.ts +1 -1
  142. package/src/services/lightning.ts +25 -1
  143. package/src/services/lrc-connection.ts +3 -3
  144. package/src/services/token-transactions.ts +6 -2
  145. package/src/services/wallet-config.ts +2 -0
  146. package/src/signer/signer.ts +4 -1
  147. package/src/spark-wallet/spark-wallet.ts +51 -15
  148. package/src/spark-wallet/types.ts +1 -0
  149. package/src/tests/errors.test.ts +58 -0
  150. package/src/tests/integration/lightning.test.ts +184 -0
  151. package/src/tests/integration/ssp/static_deposit.test.ts +1 -2
  152. package/src/tests/tokens.test.ts +52 -3
  153. package/src/utils/token-hashing.ts +335 -1
  154. package/dist/LightningSendFeeEstimateInput-CJvPnCSB.d.cts +0 -5
  155. package/dist/LightningSendFeeEstimateInput-CJvPnCSB.d.ts +0 -5
  156. package/dist/chunk-HKAKEKCE.js +0 -8
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@buildonspark/spark-sdk",
3
- "version": "0.1.41",
3
+ "version": "0.1.43",
4
4
  "author": "",
5
5
  "license": "Apache-2.0",
6
6
  "main": "./dist/index.js",
@@ -140,7 +140,7 @@
140
140
  "prettier": "^3.5.1",
141
141
  "publint": "^0.3.9",
142
142
  "react": "19.0.0",
143
- "react-native": "^0.79.2",
143
+ "react-native": "0.79.4",
144
144
  "react-native-get-random-values": "^1.11.0",
145
145
  "ts-jest": "^29.2.5",
146
146
  "tsup": "^8.4.0",
@@ -149,8 +149,8 @@
149
149
  "dependencies": {
150
150
  "@bitcoinerlab/secp256k1": "^1.1.1",
151
151
  "@bufbuild/protobuf": "^2.2.5",
152
- "@buildonspark/lrc20-sdk": "0.0.57",
153
- "@lightsparkdev/core": "^1.4.1",
152
+ "@buildonspark/lrc20-sdk": "0.0.58",
153
+ "@lightsparkdev/core": "^1.4.2",
154
154
  "@noble/curves": "^1.8.0",
155
155
  "@noble/hashes": "^1.7.1",
156
156
  "@opentelemetry/api": "^1.9.0",
package/src/constants.ts CHANGED
@@ -1,4 +1,25 @@
1
+ import { isNode } from "@lightsparkdev/core";
2
+
1
3
  export const isReactNative =
2
4
  typeof navigator !== "undefined" && navigator.product === "ReactNative";
3
5
 
4
6
  export const isBun = globalThis.Bun !== undefined;
7
+
8
+ declare const __PACKAGE_VERSION__: string;
9
+
10
+ export const packageVersion =
11
+ typeof __PACKAGE_VERSION__ !== "undefined" ? __PACKAGE_VERSION__ : "unknown";
12
+
13
+ let baseEnvStr = "unknown";
14
+ if (isNode) {
15
+ baseEnvStr = `node/${process.version}`;
16
+ } else if (isReactNative) {
17
+ baseEnvStr = "react-native";
18
+ } else {
19
+ const userAgent =
20
+ (typeof navigator !== "undefined" && navigator.userAgent) ||
21
+ "unknown-user-agent";
22
+ baseEnvStr = `browser/${userAgent}`;
23
+ }
24
+
25
+ export const clientEnv = `js-spark-sdk/${packageVersion} ${baseEnvStr}`;
@@ -1,3 +1,5 @@
1
+ import { bytesToHex } from "@noble/hashes/utils";
2
+
1
3
  export class SparkSDKError extends Error {
2
4
  public readonly context: Record<string, unknown>;
3
5
  public readonly originalError?: Error;
@@ -45,7 +47,7 @@ function getMessage(
45
47
  originalError?: Error,
46
48
  ) {
47
49
  const contextStr = Object.entries(context)
48
- .map(([key, value]) => `${key}: ${JSON.stringify(value)}`)
50
+ .map(([key, value]) => `${key}: ${safeStringify(value)}`)
49
51
  .join(", ");
50
52
 
51
53
  const originalErrorStr = originalError
@@ -54,3 +56,43 @@ function getMessage(
54
56
 
55
57
  return `SparkSDKError: ${message}${contextStr ? `\nContext: ${contextStr}` : ""}${originalErrorStr}`;
56
58
  }
59
+
60
+ function safeStringify(value: unknown): string {
61
+ const replacer = (_: string, v: unknown) => {
62
+ /* Handle BigInt explicitly because JSON.stringify throws a TypeError when encountering it at any depth. */
63
+ if (typeof v === "bigint") {
64
+ return v.toString();
65
+ }
66
+ if (v instanceof Uint8Array) {
67
+ return formatUint8Array(v);
68
+ }
69
+ return v;
70
+ };
71
+
72
+ /* If the value itself is a BigInt (top-level), stringify will still throw, so convert beforehand. */
73
+ if (typeof value === "bigint") {
74
+ return `"${value.toString()}"`;
75
+ }
76
+
77
+ /* Format Uint8Array as hex instead of record */
78
+ if (value instanceof Uint8Array) {
79
+ return `"${formatUint8Array(value)}"`;
80
+ }
81
+
82
+ try {
83
+ const result = JSON.stringify(value, replacer);
84
+ /* JSON.stringify returns undefined for unsupported types like undefined, function, or symbol.
85
+ In those cases, fall back to String(value) for a more informative output. */
86
+ return result === undefined ? String(value) : result;
87
+ } catch {
88
+ try {
89
+ return String(value);
90
+ } catch {
91
+ return "[Unserializable]";
92
+ }
93
+ }
94
+ }
95
+
96
+ function formatUint8Array(arr: Uint8Array): string {
97
+ return `Uint8Array(0x${bytesToHex(arr)})`;
98
+ }
@@ -169,11 +169,13 @@ export default class SspClient {
169
169
 
170
170
  async getLightningSendFeeEstimate(
171
171
  encodedInvoice: string,
172
+ amountSats?: number,
172
173
  ): Promise<LightningSendFeeEstimateOutput | null> {
173
174
  return await this.executeRawQuery({
174
175
  queryPayload: LightningSendFeeEstimate,
175
176
  variables: {
176
177
  encoded_invoice: encodedInvoice,
178
+ amount_sats: amountSats,
177
179
  },
178
180
  constructObject: (response: { lightning_send_fee_estimate: any }) => {
179
181
  return LightningSendFeeEstimateOutputFromJson(
@@ -276,12 +278,14 @@ export default class SspClient {
276
278
  async requestLightningSend({
277
279
  encodedInvoice,
278
280
  idempotencyKey,
281
+ amountSats,
279
282
  }: RequestLightningSendInput): Promise<LightningSendRequest | null> {
280
283
  return await this.executeRawQuery({
281
284
  queryPayload: RequestLightningSend,
282
285
  variables: {
283
286
  encoded_invoice: encodedInvoice,
284
287
  idempotency_key: idempotencyKey,
288
+ amount_sats: amountSats,
285
289
  },
286
290
  constructObject: (response: { request_lightning_send: any }) => {
287
291
  return LightningSendRequestFromJson(
@@ -3,10 +3,12 @@ export const RequestLightningSend = `
3
3
  mutation RequestLightningSend(
4
4
  $encoded_invoice: String!
5
5
  $idempotency_key: String!
6
+ $amount_sats: Long
6
7
  ) {
7
8
  request_lightning_send(input: {
8
9
  encoded_invoice: $encoded_invoice
9
10
  idempotency_key: $idempotency_key
11
+ amount_sats: $amount_sats
10
12
  }) {
11
13
  request {
12
14
  ...LightningSendRequestFragment
@@ -2,8 +2,8 @@
2
2
  // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
3
3
 
4
4
 
5
- import ClaimStaticDepositRequestType from './ClaimStaticDepositRequestType.js';
6
5
  import BitcoinNetwork from './BitcoinNetwork.js';
6
+ import ClaimStaticDepositRequestType from './ClaimStaticDepositRequestType.js';
7
7
 
8
8
 
9
9
  interface ClaimStaticDepositInput {
@@ -21,10 +21,12 @@ REFUND_SIGNING_FAILED = "REFUND_SIGNING_FAILED",
21
21
 
22
22
  UTXO_SWAPPING_FAILED = "UTXO_SWAPPING_FAILED",
23
23
 
24
- TRANSFER_FAILED = "TRANSFER_FAILED",
25
-
26
24
  TRANSFER_COMPLETED = "TRANSFER_COMPLETED",
27
25
 
26
+ SPEND_TX_CREATED = "SPEND_TX_CREATED",
27
+
28
+ SPEND_TX_BROADCAST = "SPEND_TX_BROADCAST",
29
+
28
30
  }
29
31
 
30
32
  export default ClaimStaticDepositStatus;
@@ -2,16 +2,16 @@
2
2
  // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
3
3
 
4
4
 
5
- import SparkWalletUserToUserRequestsConnection from './SparkWalletUserToUserRequestsConnection.js';
6
- import { LightsparkException } from '@lightsparkdev/core';
7
- import {PageInfoToJson} from './PageInfo.js';
5
+ import {UserRequestFromJson} from './UserRequest.js';
6
+ import PageInfo from './PageInfo.js';
8
7
  import {PageInfoFromJson} from './PageInfo.js';
9
8
  import {LeafFromJson} from './Leaf.js';
10
- import PageInfo from './PageInfo.js';
11
- import {LeafToJson} from './Leaf.js';
12
- import SparkTransferToLeavesConnection from './SparkTransferToLeavesConnection.js';
9
+ import { LightsparkException } from '@lightsparkdev/core';
10
+ import SparkWalletUserToUserRequestsConnection from './SparkWalletUserToUserRequestsConnection.js';
11
+ import {PageInfoToJson} from './PageInfo.js';
13
12
  import {UserRequestToJson} from './UserRequest.js';
14
- import {UserRequestFromJson} from './UserRequest.js';
13
+ import SparkTransferToLeavesConnection from './SparkTransferToLeavesConnection.js';
14
+ import {LeafToJson} from './Leaf.js';
15
15
 
16
16
 
17
17
  interface Connection {
@@ -2,9 +2,9 @@
2
2
  // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
3
3
 
4
4
 
5
+ import CurrencyAmount from './CurrencyAmount.js';
5
6
  import {CurrencyAmountFromJson} from './CurrencyAmount.js';
6
7
  import {CurrencyAmountToJson} from './CurrencyAmount.js';
7
- import CurrencyAmount from './CurrencyAmount.js';
8
8
 
9
9
 
10
10
  interface CoopExitFeeEstimate {
@@ -0,0 +1,202 @@
1
+ // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
2
+
3
+ import { Query, isObject } from "@lightsparkdev/core";
4
+ import BitcoinNetwork from "./BitcoinNetwork.js";
5
+ import CurrencyAmount, {
6
+ CurrencyAmountFromJson,
7
+ CurrencyAmountToJson,
8
+ } from "./CurrencyAmount.js";
9
+
10
+ interface CoopExitFeeQuote {
11
+ /**
12
+ * The unique identifier of this entity across all Lightspark systems. Should be treated as an opaque
13
+ * string.
14
+ **/
15
+ id: string;
16
+
17
+ /** The date and time when the entity was first created. **/
18
+ createdAt: string;
19
+
20
+ /** The date and time when the entity was last updated. **/
21
+ updatedAt: string;
22
+
23
+ /** The network the coop exit fee quote is on. **/
24
+ network: BitcoinNetwork;
25
+
26
+ /** The total currency amount of all the nodes user swapped for the coop exit quote. **/
27
+ totalAmount: CurrencyAmount;
28
+
29
+ /** The fee user pays for the coop exit not including the L1 broadcast fee when exit speed is fast. **/
30
+ userFeeFast: CurrencyAmount;
31
+
32
+ /** The fee user pays for the coop exit not including the L1 broadcast fee when exit speed is medium. **/
33
+ userFeeMedium: CurrencyAmount;
34
+
35
+ /** The fee user pays for the coop exit not including the L1 broadcast fee when exit speed is slow. **/
36
+ userFeeSlow: CurrencyAmount;
37
+
38
+ /** The L1 broadcast fee user pays for the coop exit when exit speed is fast. **/
39
+ l1BroadcastFeeFast: CurrencyAmount;
40
+
41
+ /** The L1 broadcast fee user pays for the coop exit when exit speed is medium. **/
42
+ l1BroadcastFeeMedium: CurrencyAmount;
43
+
44
+ /** The L1 broadcast fee user pays for the coop exit when exit speed is slow. **/
45
+ l1BroadcastFeeSlow: CurrencyAmount;
46
+
47
+ /** The time when the coop exit fee quote expires. **/
48
+ expiresAt: string;
49
+
50
+ /** The typename of the object **/
51
+ typename: string;
52
+ }
53
+
54
+ export const CoopExitFeeQuoteFromJson = (obj: any): CoopExitFeeQuote => {
55
+ return {
56
+ id: obj["coop_exit_fee_quote_id"],
57
+ createdAt: obj["coop_exit_fee_quote_created_at"],
58
+ updatedAt: obj["coop_exit_fee_quote_updated_at"],
59
+ network:
60
+ BitcoinNetwork[obj["coop_exit_fee_quote_network"]] ??
61
+ BitcoinNetwork.FUTURE_VALUE,
62
+ totalAmount: CurrencyAmountFromJson(
63
+ obj["coop_exit_fee_quote_total_amount"],
64
+ ),
65
+ userFeeFast: CurrencyAmountFromJson(
66
+ obj["coop_exit_fee_quote_user_fee_fast"],
67
+ ),
68
+ userFeeMedium: CurrencyAmountFromJson(
69
+ obj["coop_exit_fee_quote_user_fee_medium"],
70
+ ),
71
+ userFeeSlow: CurrencyAmountFromJson(
72
+ obj["coop_exit_fee_quote_user_fee_slow"],
73
+ ),
74
+ l1BroadcastFeeFast: CurrencyAmountFromJson(
75
+ obj["coop_exit_fee_quote_l1_broadcast_fee_fast"],
76
+ ),
77
+ l1BroadcastFeeMedium: CurrencyAmountFromJson(
78
+ obj["coop_exit_fee_quote_l1_broadcast_fee_medium"],
79
+ ),
80
+ l1BroadcastFeeSlow: CurrencyAmountFromJson(
81
+ obj["coop_exit_fee_quote_l1_broadcast_fee_slow"],
82
+ ),
83
+ expiresAt: obj["coop_exit_fee_quote_expires_at"],
84
+ typename: "CoopExitFeeQuote",
85
+ } as CoopExitFeeQuote;
86
+ };
87
+ export const CoopExitFeeQuoteToJson = (obj: CoopExitFeeQuote): any => {
88
+ return {
89
+ __typename: "CoopExitFeeQuote",
90
+ coop_exit_fee_quote_id: obj.id,
91
+ coop_exit_fee_quote_created_at: obj.createdAt,
92
+ coop_exit_fee_quote_updated_at: obj.updatedAt,
93
+ coop_exit_fee_quote_network: obj.network,
94
+ coop_exit_fee_quote_total_amount: CurrencyAmountToJson(obj.totalAmount),
95
+ coop_exit_fee_quote_user_fee_fast: CurrencyAmountToJson(obj.userFeeFast),
96
+ coop_exit_fee_quote_user_fee_medium: CurrencyAmountToJson(
97
+ obj.userFeeMedium,
98
+ ),
99
+ coop_exit_fee_quote_user_fee_slow: CurrencyAmountToJson(obj.userFeeSlow),
100
+ coop_exit_fee_quote_l1_broadcast_fee_fast: CurrencyAmountToJson(
101
+ obj.l1BroadcastFeeFast,
102
+ ),
103
+ coop_exit_fee_quote_l1_broadcast_fee_medium: CurrencyAmountToJson(
104
+ obj.l1BroadcastFeeMedium,
105
+ ),
106
+ coop_exit_fee_quote_l1_broadcast_fee_slow: CurrencyAmountToJson(
107
+ obj.l1BroadcastFeeSlow,
108
+ ),
109
+ coop_exit_fee_quote_expires_at: obj.expiresAt,
110
+ };
111
+ };
112
+
113
+ export const FRAGMENT = `
114
+ fragment CoopExitFeeQuoteFragment on CoopExitFeeQuote {
115
+ __typename
116
+ coop_exit_fee_quote_id: id
117
+ coop_exit_fee_quote_created_at: created_at
118
+ coop_exit_fee_quote_updated_at: updated_at
119
+ coop_exit_fee_quote_network: network
120
+ coop_exit_fee_quote_total_amount: total_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
+ coop_exit_fee_quote_user_fee_fast: user_fee_fast {
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
+ coop_exit_fee_quote_user_fee_medium: user_fee_medium {
137
+ __typename
138
+ currency_amount_original_value: original_value
139
+ currency_amount_original_unit: original_unit
140
+ currency_amount_preferred_currency_unit: preferred_currency_unit
141
+ currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
142
+ currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
143
+ }
144
+ coop_exit_fee_quote_user_fee_slow: user_fee_slow {
145
+ __typename
146
+ currency_amount_original_value: original_value
147
+ currency_amount_original_unit: original_unit
148
+ currency_amount_preferred_currency_unit: preferred_currency_unit
149
+ currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
150
+ currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
151
+ }
152
+ coop_exit_fee_quote_l1_broadcast_fee_fast: l1_broadcast_fee_fast {
153
+ __typename
154
+ currency_amount_original_value: original_value
155
+ currency_amount_original_unit: original_unit
156
+ currency_amount_preferred_currency_unit: preferred_currency_unit
157
+ currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
158
+ currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
159
+ }
160
+ coop_exit_fee_quote_l1_broadcast_fee_medium: l1_broadcast_fee_medium {
161
+ __typename
162
+ currency_amount_original_value: original_value
163
+ currency_amount_original_unit: original_unit
164
+ currency_amount_preferred_currency_unit: preferred_currency_unit
165
+ currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
166
+ currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
167
+ }
168
+ coop_exit_fee_quote_l1_broadcast_fee_slow: l1_broadcast_fee_slow {
169
+ __typename
170
+ currency_amount_original_value: original_value
171
+ currency_amount_original_unit: original_unit
172
+ currency_amount_preferred_currency_unit: preferred_currency_unit
173
+ currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
174
+ currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
175
+ }
176
+ coop_exit_fee_quote_expires_at: expires_at
177
+ }`;
178
+
179
+ export const getCoopExitFeeQuoteQuery = (
180
+ id: string,
181
+ ): Query<CoopExitFeeQuote> => {
182
+ return {
183
+ queryPayload: `
184
+ query GetCoopExitFeeQuote($id: ID!) {
185
+ entity(id: $id) {
186
+ ... on CoopExitFeeQuote {
187
+ ...CoopExitFeeQuoteFragment
188
+ }
189
+ }
190
+ }
191
+
192
+ ${FRAGMENT}
193
+ `,
194
+ variables: { id },
195
+ constructObject: (data: unknown) =>
196
+ isObject(data) && "entity" in data && isObject(data.entity)
197
+ ? CoopExitFeeQuoteFromJson(data.entity)
198
+ : null,
199
+ };
200
+ };
201
+
202
+ export default CoopExitFeeQuote;
@@ -0,0 +1,41 @@
1
+
2
+ // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
3
+
4
+
5
+
6
+
7
+
8
+ interface CoopExitFeeQuoteInput {
9
+
10
+
11
+ leafExternalIds: string[];
12
+
13
+ withdrawalAddress: string;
14
+
15
+
16
+
17
+
18
+ }
19
+
20
+ export const CoopExitFeeQuoteInputFromJson = (obj: any): CoopExitFeeQuoteInput => {
21
+ return {
22
+ leafExternalIds: obj["coop_exit_fee_quote_input_leaf_external_ids"],
23
+ withdrawalAddress: obj["coop_exit_fee_quote_input_withdrawal_address"],
24
+
25
+ } as CoopExitFeeQuoteInput;
26
+
27
+ }
28
+ export const CoopExitFeeQuoteInputToJson = (obj: CoopExitFeeQuoteInput): any => {
29
+ return {
30
+ coop_exit_fee_quote_input_leaf_external_ids: obj.leafExternalIds,
31
+ coop_exit_fee_quote_input_withdrawal_address: obj.withdrawalAddress,
32
+
33
+ }
34
+
35
+ }
36
+
37
+
38
+
39
+
40
+
41
+ export default CoopExitFeeQuoteInput;
@@ -0,0 +1,45 @@
1
+
2
+ // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
3
+
4
+
5
+
6
+
7
+
8
+ interface CoopExitFeeQuoteOutput {
9
+
10
+
11
+ quoteId: string;
12
+
13
+
14
+
15
+
16
+ }
17
+
18
+ export const CoopExitFeeQuoteOutputFromJson = (obj: any): CoopExitFeeQuoteOutput => {
19
+ return {
20
+ quoteId: obj["coop_exit_fee_quote_output_quote"].id,
21
+
22
+ } as CoopExitFeeQuoteOutput;
23
+
24
+ }
25
+ export const CoopExitFeeQuoteOutputToJson = (obj: CoopExitFeeQuoteOutput): any => {
26
+ return {
27
+ coop_exit_fee_quote_output_quote: { id: obj.quoteId },
28
+
29
+ }
30
+
31
+ }
32
+
33
+
34
+ export const FRAGMENT = `
35
+ fragment CoopExitFeeQuoteOutputFragment on CoopExitFeeQuoteOutput {
36
+ __typename
37
+ coop_exit_fee_quote_output_quote: quote {
38
+ id
39
+ }
40
+ }`;
41
+
42
+
43
+
44
+
45
+ export default CoopExitFeeQuoteOutput;
@@ -6,6 +6,7 @@ import CurrencyAmount, {
6
6
  CurrencyAmountFromJson,
7
7
  CurrencyAmountToJson,
8
8
  } from "./CurrencyAmount.js";
9
+ import ExitSpeed from "./ExitSpeed.js";
9
10
  import SparkCoopExitRequestStatus from "./SparkCoopExitRequestStatus.js";
10
11
  import Transfer, { TransferFromJson } from "./Transfer.js";
11
12
 
@@ -49,6 +50,12 @@ interface CoopExitRequest {
49
50
  /** The typename of the object **/
50
51
  typename: string;
51
52
 
53
+ /** The fee quote user requested for this coop exit. **/
54
+ feeQuoteId?: string | undefined;
55
+
56
+ /** The exit speed user requested for this coop exit. **/
57
+ exitSpeed?: ExitSpeed | undefined;
58
+
52
59
  /** The swap transfer. **/
53
60
  transfer?: Transfer | undefined;
54
61
  }
@@ -73,6 +80,11 @@ export const CoopExitRequestFromJson = (obj: any): CoopExitRequest => {
73
80
  rawCoopExitTransaction: obj["coop_exit_request_raw_coop_exit_transaction"],
74
81
  coopExitTxid: obj["coop_exit_request_coop_exit_txid"],
75
82
  typename: "CoopExitRequest",
83
+ feeQuoteId: obj["coop_exit_request_fee_quote"]?.id ?? undefined,
84
+ exitSpeed: !!obj["coop_exit_request_exit_speed"]
85
+ ? (ExitSpeed[obj["coop_exit_request_exit_speed"]] ??
86
+ ExitSpeed.FUTURE_VALUE)
87
+ : null,
76
88
  transfer: !!obj["coop_exit_request_transfer"]
77
89
  ? TransferFromJson(obj["coop_exit_request_transfer"])
78
90
  : undefined,
@@ -89,6 +101,8 @@ export const CoopExitRequestToJson = (obj: CoopExitRequest): any => {
89
101
  coop_exit_request_l1_broadcast_fee: CurrencyAmountToJson(
90
102
  obj.l1BroadcastFee,
91
103
  ),
104
+ coop_exit_request_fee_quote: { id: obj.feeQuoteId },
105
+ coop_exit_request_exit_speed: obj.exitSpeed,
92
106
  coop_exit_request_status: obj.status,
93
107
  coop_exit_request_expires_at: obj.expiresAt,
94
108
  coop_exit_request_raw_connector_transaction: obj.rawConnectorTransaction,
@@ -123,6 +137,10 @@ fragment CoopExitRequestFragment on CoopExitRequest {
123
137
  currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
124
138
  currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
125
139
  }
140
+ coop_exit_request_fee_quote: fee_quote {
141
+ id
142
+ }
143
+ coop_exit_request_exit_speed: exit_speed
126
144
  coop_exit_request_status: status
127
145
  coop_exit_request_expires_at: expires_at
128
146
  coop_exit_request_raw_connector_transaction: raw_connector_transaction
@@ -139,6 +157,9 @@ fragment CoopExitRequestFragment on CoopExitRequest {
139
157
  currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
140
158
  }
141
159
  transfer_spark_id: spark_id
160
+ transfer_user_request: user_request {
161
+ id
162
+ }
142
163
  }
143
164
  }`;
144
165
 
@@ -1,34 +1,32 @@
1
-
2
1
  // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
3
2
 
4
3
  /** 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
- /** Euro. **/
24
- EUR = "EUR",
25
- /** 0.000000001 (10e-9) Bitcoin or a billionth of a Bitcoin. We recommend using the Satoshi unit instead when possible. **/
26
- NANOBITCOIN = "NANOBITCOIN",
27
- /** 0.000001 (10e-6) Bitcoin or a millionth of a Bitcoin. We recommend using the Satoshi unit instead when possible. **/
28
- MICROBITCOIN = "MICROBITCOIN",
29
- /** 0.001 (10e-3) Bitcoin or a thousandth of a Bitcoin. We recommend using the Satoshi unit instead when possible. **/
30
- MILLIBITCOIN = "MILLIBITCOIN",
31
-
4
+ export enum CurrencyUnit {
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
+ /** Bitcoin is the cryptocurrency native to the Bitcoin network. It is used as the native medium for value transfer for the Lightning Network. **/
11
+ BITCOIN = "BITCOIN",
12
+ /** 0.00000001 (10e-8) Bitcoin or one hundred millionth of a Bitcoin. This is the unit most commonly used in Lightning transactions. **/
13
+ SATOSHI = "SATOSHI",
14
+ /** 0.001 Satoshi, or 10e-11 Bitcoin. We recommend using the Satoshi unit instead when possible. **/
15
+ MILLISATOSHI = "MILLISATOSHI",
16
+ /** United States Dollar. **/
17
+ USD = "USD",
18
+ /** Mexican Peso. **/
19
+ MXN = "MXN",
20
+ /** Philippine Peso. **/
21
+ PHP = "PHP",
22
+ /** Euro. **/
23
+ EUR = "EUR",
24
+ /** 0.000000001 (10e-9) Bitcoin or a billionth of a Bitcoin. We recommend using the Satoshi unit instead when possible. **/
25
+ NANOBITCOIN = "NANOBITCOIN",
26
+ /** 0.000001 (10e-6) Bitcoin or a millionth of a Bitcoin. We recommend using the Satoshi unit instead when possible. **/
27
+ MICROBITCOIN = "MICROBITCOIN",
28
+ /** 0.001 (10e-3) Bitcoin or a thousandth of a Bitcoin. We recommend using the Satoshi unit instead when possible. **/
29
+ MILLIBITCOIN = "MILLIBITCOIN",
32
30
  }
33
31
 
34
32
  export default CurrencyUnit;