@buildonspark/spark-sdk 0.1.43 → 0.1.44

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 (112) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/dist/{RequestLightningSendInput-Na1mHdWg.d.cts → RequestLightningSendInput-BxbCtwpV.d.cts} +43 -4
  3. package/dist/{RequestLightningSendInput-D7fZdT4A.d.ts → RequestLightningSendInput-RGel43ks.d.ts} +43 -4
  4. package/dist/address/index.d.cts +2 -2
  5. package/dist/address/index.d.ts +2 -2
  6. package/dist/address/index.js +2 -2
  7. package/dist/{chunk-M6A4KFIG.js → chunk-4Q2ZDYYU.js} +332 -221
  8. package/dist/{chunk-WWOTVNPP.js → chunk-A2ZLMH6I.js} +323 -142
  9. package/dist/{chunk-VA7MV4MZ.js → chunk-B3AMIGJG.js} +1 -1
  10. package/dist/{chunk-DQYKQJRZ.js → chunk-CIZNCBKE.js} +29 -9
  11. package/dist/{chunk-BUTZWYBW.js → chunk-DAXGVPVM.js} +2 -2
  12. package/dist/{chunk-DOA6QXYQ.js → chunk-EKFD62HN.js} +2 -1
  13. package/dist/{chunk-TIUBYNN5.js → chunk-HTMXTJRK.js} +1 -1
  14. package/dist/{chunk-TOSP3INR.js → chunk-I54FARY2.js} +4 -2
  15. package/dist/{chunk-MIVX3GHD.js → chunk-K4BJARWM.js} +1 -1
  16. package/dist/{chunk-O4RYNJNB.js → chunk-KEKGSH7B.js} +1 -1
  17. package/dist/{chunk-GYQR4B4P.js → chunk-NBCNYDWJ.js} +2 -2
  18. package/dist/{chunk-ABZA6R5S.js → chunk-SQKXGAIR.js} +1 -1
  19. package/dist/{chunk-VFJQNBFX.js → chunk-UBT6EDVJ.js} +5 -2
  20. package/dist/{chunk-HRQRRDSS.js → chunk-WPTRVD2V.js} +3 -3
  21. package/dist/{chunk-IRW5TWMH.js → chunk-XX4RRWOX.js} +5 -5
  22. package/dist/graphql/objects/index.d.cts +5 -43
  23. package/dist/graphql/objects/index.d.ts +5 -43
  24. package/dist/graphql/objects/index.js +1 -1
  25. package/dist/{index-BJOc8Ur-.d.cts → index-CZmDdSts.d.cts} +24 -10
  26. package/dist/{index-7RYRH5wc.d.ts → index-ClIRO_3y.d.ts} +24 -10
  27. package/dist/index.cjs +827 -414
  28. package/dist/index.d.cts +6 -6
  29. package/dist/index.d.ts +6 -6
  30. package/dist/index.js +15 -15
  31. package/dist/index.node.cjs +830 -417
  32. package/dist/index.node.d.cts +7 -7
  33. package/dist/index.node.d.ts +7 -7
  34. package/dist/index.node.js +18 -18
  35. package/dist/native/index.cjs +827 -414
  36. package/dist/native/index.d.cts +88 -23
  37. package/dist/native/index.d.ts +88 -23
  38. package/dist/native/index.js +819 -407
  39. package/dist/{network-D5lKssVl.d.cts → network-CfxLnaot.d.cts} +1 -1
  40. package/dist/{network-xkBSpaTn.d.ts → network-CroCOQ0B.d.ts} +1 -1
  41. package/dist/proto/lrc20.d.cts +1 -1
  42. package/dist/proto/lrc20.d.ts +1 -1
  43. package/dist/proto/lrc20.js +2 -2
  44. package/dist/proto/spark.cjs +332 -221
  45. package/dist/proto/spark.d.cts +1 -1
  46. package/dist/proto/spark.d.ts +1 -1
  47. package/dist/proto/spark.js +3 -5
  48. package/dist/proto/spark_token.cjs +149 -9
  49. package/dist/proto/spark_token.d.cts +1 -1
  50. package/dist/proto/spark_token.d.ts +1 -1
  51. package/dist/proto/spark_token.js +2 -2
  52. package/dist/{sdk-types-B-q9py_P.d.cts → sdk-types-BeCBoozO.d.cts} +1 -1
  53. package/dist/{sdk-types-BPoPgzda.d.ts → sdk-types-CTbTdDbE.d.ts} +1 -1
  54. package/dist/services/config.cjs +7 -3
  55. package/dist/services/config.d.cts +4 -4
  56. package/dist/services/config.d.ts +4 -4
  57. package/dist/services/config.js +5 -5
  58. package/dist/services/connection.cjs +334 -218
  59. package/dist/services/connection.d.cts +4 -4
  60. package/dist/services/connection.d.ts +4 -4
  61. package/dist/services/connection.js +4 -4
  62. package/dist/services/index.cjs +364 -227
  63. package/dist/services/index.d.cts +4 -4
  64. package/dist/services/index.d.ts +4 -4
  65. package/dist/services/index.js +9 -9
  66. package/dist/services/lrc-connection.cjs +5 -2
  67. package/dist/services/lrc-connection.d.cts +4 -4
  68. package/dist/services/lrc-connection.d.ts +4 -4
  69. package/dist/services/lrc-connection.js +4 -4
  70. package/dist/services/token-transactions.cjs +28 -8
  71. package/dist/services/token-transactions.d.cts +4 -4
  72. package/dist/services/token-transactions.d.ts +4 -4
  73. package/dist/services/token-transactions.js +3 -3
  74. package/dist/services/wallet-config.cjs +2 -1
  75. package/dist/services/wallet-config.d.cts +4 -4
  76. package/dist/services/wallet-config.d.ts +4 -4
  77. package/dist/services/wallet-config.js +1 -1
  78. package/dist/signer/signer.cjs +5 -2
  79. package/dist/signer/signer.d.cts +2 -2
  80. package/dist/signer/signer.d.ts +2 -2
  81. package/dist/signer/signer.js +2 -2
  82. package/dist/{signer-wqesWifN.d.ts → signer-D7vfYik9.d.ts} +1 -1
  83. package/dist/{signer-IO3oMRNj.d.cts → signer-DaY8c60s.d.cts} +1 -1
  84. package/dist/{spark-CDm4gqS6.d.ts → spark-C4ZrsgjC.d.cts} +47 -29
  85. package/dist/{spark-CDm4gqS6.d.cts → spark-C4ZrsgjC.d.ts} +47 -29
  86. package/dist/types/index.cjs +331 -219
  87. package/dist/types/index.d.cts +5 -5
  88. package/dist/types/index.d.ts +5 -5
  89. package/dist/types/index.js +3 -3
  90. package/dist/utils/index.cjs +298 -28
  91. package/dist/utils/index.d.cts +5 -5
  92. package/dist/utils/index.d.ts +5 -5
  93. package/dist/utils/index.js +6 -6
  94. package/package.json +1 -1
  95. package/src/constants.ts +5 -1
  96. package/src/graphql/client.ts +28 -0
  97. package/src/graphql/mutations/RequestCoopExit.ts +6 -0
  98. package/src/graphql/mutations/RequestSwapLeaves.ts +2 -0
  99. package/src/graphql/queries/GetCoopExitFeeQuote.ts +20 -0
  100. package/src/proto/spark.ts +454 -322
  101. package/src/services/token-transactions.ts +12 -0
  102. package/src/services/transfer.ts +0 -3
  103. package/src/services/wallet-config.ts +1 -0
  104. package/src/spark-wallet/spark-wallet.node.ts +3 -3
  105. package/src/spark-wallet/spark-wallet.ts +301 -125
  106. package/src/tests/integration/deposit.test.ts +16 -0
  107. package/src/tests/integration/ssp/coop-exit.test.ts +85 -21
  108. package/src/tests/integration/ssp/swap.test.ts +47 -0
  109. package/src/tests/tokens.test.ts +3 -2
  110. package/src/utils/token-hashing.ts +28 -10
  111. package/src/utils/transaction.ts +2 -2
  112. package/src/logger.ts +0 -3
@@ -23,6 +23,7 @@ import ClaimStaticDepositOutput, {
23
23
  } from "./objects/ClaimStaticDepositOutput.js";
24
24
  import ClaimStaticDepositRequestType from "./objects/ClaimStaticDepositRequestType.js";
25
25
  import { CoopExitFeeEstimatesOutputFromJson } from "./objects/CoopExitFeeEstimatesOutput.js";
26
+ import { CoopExitFeeQuoteFromJson } from "./objects/CoopExitFeeQuote.js";
26
27
  import CoopExitRequest, {
27
28
  CoopExitRequestFromJson,
28
29
  } from "./objects/CoopExitRequest.js";
@@ -33,6 +34,8 @@ import type {
33
34
  CompleteLeavesSwapInput,
34
35
  CoopExitFeeEstimatesInput,
35
36
  CoopExitFeeEstimatesOutput,
37
+ CoopExitFeeQuote,
38
+ CoopExitFeeQuoteInput,
36
39
  GetChallengeOutput,
37
40
  LeavesSwapFeeEstimateOutput,
38
41
  LightningSendRequest,
@@ -63,6 +66,7 @@ import VerifyChallengeOutput, {
63
66
  } from "./objects/VerifyChallengeOutput.js";
64
67
  import { CoopExitFeeEstimate } from "./queries/CoopExitFeeEstimate.js";
65
68
  import { GetClaimDepositQuote } from "./queries/GetClaimDepositQuote.js";
69
+ import { GetCoopExitFeeQuote } from "./queries/GetCoopExitFeeQuote.js";
66
70
  import { LeavesSwapFeeEstimate } from "./queries/LeavesSwapFeeEstimate.js";
67
71
  import { LightningSendFeeEstimate } from "./queries/LightningSendFeeEstimate.js";
68
72
  import { GetTransfer } from "./queries/Transfer.js";
@@ -229,6 +233,9 @@ export default class SspClient {
229
233
  withdrawalAddress,
230
234
  idempotencyKey,
231
235
  exitSpeed,
236
+ feeLeafExternalIds,
237
+ feeQuoteId,
238
+ withdrawAll,
232
239
  }: RequestCoopExitInput): Promise<CoopExitRequest | null> {
233
240
  return await this.executeRawQuery({
234
241
  queryPayload: RequestCoopExit,
@@ -237,6 +244,9 @@ export default class SspClient {
237
244
  withdrawal_address: withdrawalAddress,
238
245
  idempotency_key: idempotencyKey,
239
246
  exit_speed: exitSpeed,
247
+ fee_leaf_external_ids: feeLeafExternalIds,
248
+ fee_quote_id: feeQuoteId,
249
+ withdraw_all: withdrawAll,
240
250
  },
241
251
  constructObject: (response: { request_coop_exit: any }) => {
242
252
  return CoopExitRequestFromJson(response.request_coop_exit.request);
@@ -302,6 +312,7 @@ export default class SspClient {
302
312
  feeSats,
303
313
  userLeaves,
304
314
  idempotencyKey,
315
+ targetAmountSatsList,
305
316
  }: RequestLeavesSwapInput): Promise<LeavesSwapRequest | null> {
306
317
  const query = {
307
318
  queryPayload: RequestSwapLeaves,
@@ -312,6 +323,7 @@ export default class SspClient {
312
323
  fee_sats: feeSats,
313
324
  user_leaves: userLeaves,
314
325
  idempotency_key: idempotencyKey,
326
+ target_amount_sats_list: targetAmountSatsList,
315
327
  },
316
328
  constructObject: (response: { request_leaves_swap: any }) => {
317
329
  if (!response.request_leaves_swap) {
@@ -538,6 +550,22 @@ export default class SspClient {
538
550
  new Date(verifyChallenge.validUntil),
539
551
  );
540
552
  }
553
+
554
+ async getCoopExitFeeQuote({
555
+ leafExternalIds,
556
+ withdrawalAddress,
557
+ }: CoopExitFeeQuoteInput): Promise<CoopExitFeeQuote | null> {
558
+ return await this.executeRawQuery({
559
+ queryPayload: GetCoopExitFeeQuote,
560
+ variables: {
561
+ leaf_external_ids: leafExternalIds,
562
+ withdrawal_address: withdrawalAddress,
563
+ },
564
+ constructObject: (response: { coop_exit_fee_quote: any }) => {
565
+ return CoopExitFeeQuoteFromJson(response.coop_exit_fee_quote.quote);
566
+ },
567
+ });
568
+ }
541
569
  }
542
570
 
543
571
  class SparkAuthProvider implements AuthProvider {
@@ -6,6 +6,9 @@ export const RequestCoopExit = `
6
6
  $withdrawal_address: String!
7
7
  $idempotency_key: String!
8
8
  $exit_speed: ExitSpeed!
9
+ $withdraw_all: Boolean
10
+ $fee_leaf_external_ids: [UUID!]
11
+ $fee_quote_id: ID
9
12
  ) {
10
13
  request_coop_exit(
11
14
  input: {
@@ -13,6 +16,9 @@ export const RequestCoopExit = `
13
16
  withdrawal_address: $withdrawal_address
14
17
  idempotency_key: $idempotency_key
15
18
  exit_speed: $exit_speed
19
+ withdraw_all: $withdraw_all
20
+ fee_leaf_external_ids: $fee_leaf_external_ids
21
+ fee_quote_id: $fee_quote_id
16
22
  }
17
23
  ) {
18
24
  request {
@@ -8,6 +8,7 @@ export const RequestSwapLeaves = `
8
8
  $fee_sats: Long!
9
9
  $user_leaves: [UserLeafInput!]!
10
10
  $idempotency_key: String!
11
+ $target_amount_sats_list: [Long!]
11
12
  ) {
12
13
  request_leaves_swap(input: {
13
14
  adaptor_pubkey: $adaptor_pubkey
@@ -16,6 +17,7 @@ export const RequestSwapLeaves = `
16
17
  fee_sats: $fee_sats
17
18
  user_leaves: $user_leaves
18
19
  idempotency_key: $idempotency_key
20
+ target_amount_sats_list: $target_amount_sats_list
19
21
  }) {
20
22
  request {
21
23
  ...LeavesSwapRequestFragment
@@ -0,0 +1,20 @@
1
+ import { FRAGMENT as CoopExitFeeQuoteFragment } from "../objects/CoopExitFeeQuote.js";
2
+
3
+ export const GetCoopExitFeeQuote = `
4
+ query CoopExitFeeQuote(
5
+ $leaf_external_ids: [UUID!]!
6
+ $withdrawal_address: String!
7
+ ) {
8
+ coop_exit_fee_quote(
9
+ input: {
10
+ leaf_external_ids: $leaf_external_ids,
11
+ withdrawal_address: $withdrawal_address
12
+ }
13
+ ) {
14
+ quote {
15
+ ...CoopExitFeeQuoteFragment
16
+ }
17
+ }
18
+ }
19
+ ${CoopExitFeeQuoteFragment}
20
+ `;