@buildonspark/spark-sdk 0.0.8 → 0.0.9

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 (105) hide show
  1. package/dist/LightningSendRequest-CNJFhLVc.d.cts +374 -0
  2. package/dist/LightningSendRequest-CNJFhLVc.d.ts +374 -0
  3. package/dist/auto-bind.d.ts +7 -0
  4. package/dist/auto-bind.js +41 -0
  5. package/dist/auto-bind.js.map +1 -0
  6. package/dist/chunk-5SAJ52IV.js +10309 -0
  7. package/dist/chunk-COXVABEU.js +1524 -0
  8. package/dist/chunk-F4JW24C4.js +78 -0
  9. package/dist/chunk-H4A2WXR3.js +331 -0
  10. package/dist/chunk-HTNOFUHX.js +1547 -0
  11. package/dist/chunk-JQFHUW4I.js +21 -0
  12. package/dist/chunk-K3Y7DVLD.js +19 -0
  13. package/dist/chunk-NDKNVHGP.js +127 -0
  14. package/dist/chunk-PMVJGQCP.js +627 -0
  15. package/dist/chunk-QX3ZJH2S.js +527 -0
  16. package/dist/chunk-SL2YOBVM.js +127 -0
  17. package/dist/chunk-SWCOMKD6.js +333 -0
  18. package/dist/chunk-SWFFNBSR.js +1244 -0
  19. package/dist/chunk-WLK5POBV.js +527 -0
  20. package/dist/chunk-WZ74TD7N.js +660 -0
  21. package/dist/chunk-WZYVI3M3.js +1244 -0
  22. package/dist/chunk-ZGU3XW7W.js +78 -0
  23. package/dist/connection-BgWj7Hnd.d.cts +77 -0
  24. package/dist/connection-BgbVJtzh.d.ts +77 -0
  25. package/dist/connection-DX-9yFl8.d.ts +77 -0
  26. package/dist/connection-hITj9Mgk.d.cts +77 -0
  27. package/dist/graphql/objects/index.cjs +626 -0
  28. package/dist/graphql/objects/index.d.cts +140 -0
  29. package/dist/index.cjs +17202 -0
  30. package/dist/index.d.cts +413 -0
  31. package/dist/index.d.ts +413 -0
  32. package/dist/index.js +3390 -0
  33. package/dist/proto/spark.cjs +10451 -0
  34. package/dist/proto/spark.d.cts +3 -0
  35. package/dist/services/config.d.ts +2 -0
  36. package/dist/services/config.js +5 -0
  37. package/dist/services/config.js.map +1 -1
  38. package/dist/services/connection.d.ts +1 -0
  39. package/dist/services/connection.js +19 -12
  40. package/dist/services/connection.js.map +1 -1
  41. package/dist/services/index.cjs +12503 -0
  42. package/dist/services/index.d.cts +23 -0
  43. package/dist/services/index.d.ts +23 -0
  44. package/dist/services/index.js +17 -0
  45. package/dist/services/lightning.js +16 -4
  46. package/dist/services/lightning.js.map +1 -1
  47. package/dist/services/lrc20.d.ts +5 -0
  48. package/dist/services/lrc20.js +27 -0
  49. package/dist/services/lrc20.js.map +1 -0
  50. package/dist/services/token-transactions.js +21 -3
  51. package/dist/services/token-transactions.js.map +1 -1
  52. package/dist/services/transfer.d.ts +1 -0
  53. package/dist/services/transfer.js +109 -3
  54. package/dist/services/transfer.js.map +1 -1
  55. package/dist/services/tree-creation.d.ts +0 -1
  56. package/dist/services/tree-creation.js +4 -9
  57. package/dist/services/tree-creation.js.map +1 -1
  58. package/dist/signer/signer.cjs +894 -0
  59. package/dist/signer/signer.d.cts +5 -0
  60. package/dist/signer/signer.d.ts +2 -0
  61. package/dist/signer/signer.js +9 -3
  62. package/dist/signer/signer.js.map +1 -1
  63. package/dist/signer-BaC_ZP1g.d.ts +138 -0
  64. package/dist/signer-C6h1OnSQ.d.cts +138 -0
  65. package/dist/signer-CO4owhHI.d.ts +154 -0
  66. package/dist/signer-DDkpXvNZ.d.cts +154 -0
  67. package/dist/spark-BUTdOtMz.d.cts +1170 -0
  68. package/dist/spark-BUTdOtMz.d.ts +1170 -0
  69. package/dist/spark-sdk.d.ts +25 -18
  70. package/dist/spark-sdk.js +257 -142
  71. package/dist/spark-sdk.js.map +1 -1
  72. package/dist/tests/adaptor-signature.test.js +1 -2
  73. package/dist/tests/adaptor-signature.test.js.map +1 -1
  74. package/dist/tests/coop-exit.test.js.map +1 -1
  75. package/dist/tests/lightning.test.js.map +1 -1
  76. package/dist/tests/test-util.cjs +12269 -0
  77. package/dist/tests/test-util.d.cts +90 -0
  78. package/dist/tests/test-util.d.ts +19 -0
  79. package/dist/tests/test-util.js +19 -0
  80. package/dist/tests/test-util.js.map +1 -1
  81. package/dist/tests/transfer.test.js.map +1 -1
  82. package/dist/types/grpc.d.ts +1 -1
  83. package/dist/utils/index.cjs +1825 -0
  84. package/dist/utils/index.d.cts +280 -0
  85. package/dist/utils/keys.d.ts +2 -0
  86. package/dist/utils/keys.js +4 -0
  87. package/dist/utils/keys.js.map +1 -1
  88. package/dist/utils/network.d.ts +17 -0
  89. package/dist/utils/network.js +16 -0
  90. package/dist/utils/network.js.map +1 -1
  91. package/dist/utils/response-validation.js.map +1 -1
  92. package/dist/utils/token-hashing.js +1 -2
  93. package/dist/utils/token-hashing.js.map +1 -1
  94. package/dist/utils/transaction.d.ts +3 -5
  95. package/dist/utils/transaction.js +14 -16
  96. package/dist/utils/transaction.js.map +1 -1
  97. package/dist/utils/wasm-wrapper.js +4 -4
  98. package/dist/utils/wasm-wrapper.js.map +1 -1
  99. package/dist/wasm/spark_bindings.js +7 -3
  100. package/dist/wasm/spark_bindings.js.map +1 -1
  101. package/dist/wasm/spark_bindings_bg.wasm +0 -0
  102. package/package.json +12 -1
  103. package/dist/tests/jest.setup.d.ts +0 -1
  104. package/dist/tests/jest.setup.js +0 -8
  105. package/dist/tests/jest.setup.js.map +0 -1
@@ -1,9 +1,10 @@
1
1
  import { LeafWithPreviousTransactionData, QueryAllTransfersResponse, Transfer, TreeNode } from "./proto/spark.js";
2
- import { WalletConfigService } from "./services/config.js";
2
+ import { WalletConfig, WalletConfigService } from "./services/config.js";
3
3
  import { ConnectionManager } from "./services/connection.js";
4
4
  import { TransferService } from "./services/transfer.js";
5
5
  import { SparkSigner } from "./signer/signer.js";
6
- import { Network } from "./utils/network.js";
6
+ import { NetworkType } from "./utils/network.js";
7
+ import { LRC20WalletApiConfig, LRCWallet } from "@buildonspark/lrc20-sdk";
7
8
  export type CreateLightningInvoiceParams = {
8
9
  amountSats: number;
9
10
  memo: string;
@@ -18,7 +19,7 @@ export type SendTransferParams = {
18
19
  receiverPubKey: string;
19
20
  expiryTime?: Date;
20
21
  };
21
- type InitWalletResponse = {
22
+ export type InitWalletResponse = {
22
23
  balance: bigint;
23
24
  tokenBalance: Map<string, {
24
25
  balance: bigint;
@@ -31,29 +32,32 @@ type InitWalletResponse = {
31
32
  * and interacting with the Lightning Network.
32
33
  */
33
34
  export declare class SparkWallet {
34
- #private;
35
35
  protected config: WalletConfigService;
36
36
  protected connectionManager: ConnectionManager;
37
+ protected lrc20Wallet: LRCWallet | undefined;
37
38
  private depositService;
38
39
  protected transferService: TransferService;
39
40
  private treeCreationService;
40
41
  private lightningService;
41
42
  private coopExitService;
42
43
  private tokenTransactionService;
43
- private sendTransferMutex;
44
44
  private claimTransferMutex;
45
+ private leavesMutex;
46
+ private optimizationInProgress;
45
47
  private sspClient;
46
48
  private wasmModule;
47
49
  protected leaves: TreeNode[];
48
50
  protected tokenLeaves: Map<string, LeafWithPreviousTransactionData[]>;
49
- constructor(network: Network, signer?: SparkSigner);
51
+ constructor(network: NetworkType, signer?: SparkSigner, config?: WalletConfig);
50
52
  private initWasm;
51
53
  private initializeWallet;
54
+ private getLeaves;
52
55
  private selectLeaves;
53
56
  private selectLeavesForSwap;
54
- private getLeaves;
57
+ private areLeavesInefficient;
55
58
  private optimizeLeaves;
56
59
  private syncWallet;
60
+ private withLeaves;
57
61
  private isInitialized;
58
62
  /**
59
63
  * Gets the identity public key of the wallet.
@@ -82,7 +86,7 @@ export declare class SparkWallet {
82
86
  * - balance: The wallet's initial balance in satoshis
83
87
  * - tokenBalance: Map of token balances and leaf counts
84
88
  */
85
- initWallet(mnemonicOrSeed?: Uint8Array | string): Promise<InitWalletResponse>;
89
+ initWallet(mnemonicOrSeed?: Uint8Array | string, enableLRC20Wallet?: boolean, lrc20WalletApiConfig?: LRC20WalletApiConfig): Promise<InitWalletResponse>;
86
90
  private initWalletFromMnemonic;
87
91
  /**
88
92
  * Initializes a wallet from a seed.
@@ -115,7 +119,7 @@ export declare class SparkWallet {
115
119
  * You can use the forceRefetch option to synchronize your wallet and claim any
116
120
  * pending incoming lightning payment, spark transfer, or bitcoin deposit before returning the balance.
117
121
  *
118
- * @param {boolean} [forceRefetch=false] - Synchronizes the wallet before returning the balance
122
+ * @param {boolean} [forceRefetch=true] - Synchronizes the wallet before returning the balance
119
123
  * @returns {Promise<Object>} Object containing:
120
124
  * - balance: The wallet's current balance in satoshis
121
125
  * - tokenBalances: Map of token balances and leaf counts
@@ -150,13 +154,7 @@ export declare class SparkWallet {
150
154
  * @private
151
155
  */
152
156
  private finalizeDeposit;
153
- /**
154
- * Claims any pending deposits to the wallet.
155
- *
156
- * @returns {Promise<TreeNode[]>} The nodes created from the claimed deposits
157
- * @private
158
- */
159
- private claimDeposits;
157
+ claimDeposit(txid: string): Promise<TreeNode[] | undefined>;
160
158
  /**
161
159
  * Queries the mempool for transactions associated with an address.
162
160
  *
@@ -194,6 +192,13 @@ export declare class SparkWallet {
194
192
  * @private
195
193
  */
196
194
  private _sendTransfer;
195
+ /**
196
+ * Internal method to refresh timelock nodes.
197
+ *
198
+ * @param {string} nodeId - The optional ID of the node to refresh. If not provided, all nodes will be checked.
199
+ * @returns {Promise<void>}
200
+ */
201
+ refreshTimelockNodes(nodeId?: string): Promise<void>;
197
202
  /**
198
203
  * Claims a specific transfer.
199
204
  *
@@ -326,7 +331,7 @@ export declare class SparkWallet {
326
331
  * @param {LeafWithPreviousTransactionData[]} [params.selectedLeaves] - Optional specific leaves to use for the transfer
327
332
  * @returns {Promise<string>} The transaction ID of the token transfer
328
333
  */
329
- sendSparkTokenTransfer({ tokenPublicKey, tokenAmount, receiverSparkAddress, selectedLeaves, }: {
334
+ transferTokens({ tokenPublicKey, tokenAmount, receiverSparkAddress, selectedLeaves, }: {
330
335
  tokenPublicKey: string;
331
336
  tokenAmount: bigint;
332
337
  receiverSparkAddress: string;
@@ -341,5 +346,7 @@ export declare class SparkWallet {
341
346
  * @private
342
347
  */
343
348
  private selectTokenLeaves;
349
+ withdrawTokens(tokenPublicKey: string, receiverPublicKey?: string, leafIds?: string[]): Promise<{
350
+ txid: string;
351
+ } | undefined>;
344
352
  }
345
- export {};