@buildonspark/spark-sdk 0.1.25 → 0.1.26

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.
@@ -1,6 +1,7 @@
1
1
  import {
2
2
  WalletConfigService
3
- } from "../chunk-NXSLIDA6.js";
3
+ } from "../chunk-VTZVTLU4.js";
4
+ import "../chunk-TT5MFF6V.js";
4
5
  import "../chunk-QE6JYJ77.js";
5
6
  import "../chunk-NGNWJXBO.js";
6
7
  import "../chunk-2TLUMISN.js";
@@ -9,7 +10,6 @@ import "../chunk-IBYIV3NW.js";
9
10
  import "../chunk-4GQZLBIR.js";
10
11
  import "../chunk-7Z7Y2PCW.js";
11
12
  import "../chunk-GPC7GYUG.js";
12
- import "../chunk-TT5MFF6V.js";
13
13
  import "../chunk-TNZ6QAWE.js";
14
14
  export {
15
15
  WalletConfigService
@@ -1,6 +1,21 @@
1
1
  import {
2
2
  WalletConfigService
3
- } from "../chunk-NXSLIDA6.js";
3
+ } from "../chunk-VTZVTLU4.js";
4
+ import {
5
+ ELECTRS_CREDENTIALS,
6
+ LOCAL_WALLET_CONFIG,
7
+ LOCAL_WALLET_CONFIG_ECDSA,
8
+ LOCAL_WALLET_CONFIG_SCHNORR,
9
+ MAINNET_WALLET_CONFIG,
10
+ REGTEST_WALLET_CONFIG,
11
+ getElectrsUrl,
12
+ getLocalSigningOperators,
13
+ getLrc20NodeUrl,
14
+ getLrc20Url,
15
+ getSspIdentityPublicKey,
16
+ getSspSchemaEndpoint,
17
+ getSspUrl
18
+ } from "../chunk-TT5MFF6V.js";
4
19
  import "../chunk-QE6JYJ77.js";
5
20
  import "../chunk-NGNWJXBO.js";
6
21
  import "../chunk-2TLUMISN.js";
@@ -17,21 +32,6 @@ import "../chunk-IBYIV3NW.js";
17
32
  import "../chunk-4GQZLBIR.js";
18
33
  import "../chunk-7Z7Y2PCW.js";
19
34
  import "../chunk-GPC7GYUG.js";
20
- import {
21
- ELECTRS_CREDENTIALS,
22
- LOCAL_WALLET_CONFIG,
23
- LOCAL_WALLET_CONFIG_ECDSA,
24
- LOCAL_WALLET_CONFIG_SCHNORR,
25
- MAINNET_WALLET_CONFIG,
26
- REGTEST_WALLET_CONFIG,
27
- getElectrsUrl,
28
- getLocalSigningOperators,
29
- getLrc20NodeUrl,
30
- getLrc20Url,
31
- getSspIdentityPublicKey,
32
- getSspSchemaEndpoint,
33
- getSspUrl
34
- } from "../chunk-TT5MFF6V.js";
35
35
  import "../chunk-TNZ6QAWE.js";
36
36
  export {
37
37
  ConnectionManager,
@@ -137,8 +137,9 @@ declare class SparkWallet extends EventEmitter {
137
137
  protected connectionManager: ConnectionManager;
138
138
  protected lrc20ConnectionManager: ILrc20ConnectionManager;
139
139
  protected lrc20Wallet: LRCWallet | undefined;
140
- private depositService;
141
140
  protected transferService: TransferService;
141
+ protected tracerId: string;
142
+ private depositService;
142
143
  private treeCreationService;
143
144
  private lightningService;
144
145
  private coopExitService;
@@ -476,6 +477,14 @@ declare class SparkWallet extends EventEmitter {
476
477
  tokenAmount: bigint;
477
478
  receiverSparkAddress: string;
478
479
  }[], selectedOutputs?: OutputWithPreviousTransactionData[]): Promise<string>;
480
+ /**
481
+ * Retrieves token transaction history for specified tokens owned by the wallet.
482
+ * Can optionally filter by specific transaction hashes.
483
+ *
484
+ * @param tokenPublicKeys - Array of token public keys to query transactions for
485
+ * @param tokenTransactionHashes - Optional array of specific transaction hashes to filter by
486
+ * @returns Promise resolving to array of token transactions with their current status
487
+ */
479
488
  queryTokenTransactions(tokenPublicKeys: string[], tokenTransactionHashes?: string[]): Promise<TokenTransactionWithStatus[]>;
480
489
  getTokenL1Address(): Promise<string>;
481
490
  /**
@@ -137,8 +137,9 @@ declare class SparkWallet extends EventEmitter {
137
137
  protected connectionManager: ConnectionManager;
138
138
  protected lrc20ConnectionManager: ILrc20ConnectionManager;
139
139
  protected lrc20Wallet: LRCWallet | undefined;
140
- private depositService;
141
140
  protected transferService: TransferService;
141
+ protected tracerId: string;
142
+ private depositService;
142
143
  private treeCreationService;
143
144
  private lightningService;
144
145
  private coopExitService;
@@ -476,6 +477,14 @@ declare class SparkWallet extends EventEmitter {
476
477
  tokenAmount: bigint;
477
478
  receiverSparkAddress: string;
478
479
  }[], selectedOutputs?: OutputWithPreviousTransactionData[]): Promise<string>;
480
+ /**
481
+ * Retrieves token transaction history for specified tokens owned by the wallet.
482
+ * Can optionally filter by specific transaction hashes.
483
+ *
484
+ * @param tokenPublicKeys - Array of token public keys to query transactions for
485
+ * @param tokenTransactionHashes - Optional array of specific transaction hashes to filter by
486
+ * @returns Promise resolving to array of token transactions with their current status
487
+ */
479
488
  queryTokenTransactions(tokenPublicKeys: string[], tokenTransactionHashes?: string[]): Promise<TokenTransactionWithStatus[]>;
480
489
  getTokenL1Address(): Promise<string>;
481
490
  /**
@@ -1,7 +1,7 @@
1
1
  import { Q as QueryTransfersResponse, e as Transfer, b as TreeNode } from '../spark-iap2IUw_.cjs';
2
2
  import { ConfigOptions } from '../services/wallet-config.cjs';
3
3
  import { S as SparkSigner } from '../signer-GXP_J56h.cjs';
4
- import { c as SparkWallet, S as SparkWalletProps } from '../spark-wallet-CnMcVywa.cjs';
4
+ import { c as SparkWallet, S as SparkWalletProps } from '../spark-wallet-DNklv7QR.cjs';
5
5
  import { Transaction } from '@scure/btc-signer';
6
6
  import { TransactionInput, TransactionOutput } from '@scure/btc-signer/psbt';
7
7
  import '@bufbuild/protobuf/wire';
@@ -1,7 +1,7 @@
1
1
  import { Q as QueryTransfersResponse, e as Transfer, b as TreeNode } from '../spark-iap2IUw_.js';
2
2
  import { ConfigOptions } from '../services/wallet-config.js';
3
3
  import { S as SparkSigner } from '../signer-BadE1lSY.js';
4
- import { c as SparkWallet, S as SparkWalletProps } from '../spark-wallet-BrFeAWDB.js';
4
+ import { c as SparkWallet, S as SparkWalletProps } from '../spark-wallet-Bb43IsYU.js';
5
5
  import { Transaction } from '@scure/btc-signer';
6
6
  import { TransactionInput, TransactionOutput } from '@scure/btc-signer/psbt';
7
7
  import '@bufbuild/protobuf/wire';
@@ -6,7 +6,10 @@ import {
6
6
  } from "../chunk-ASPK2HFV.js";
7
7
  import {
8
8
  WalletConfigService
9
- } from "../chunk-NXSLIDA6.js";
9
+ } from "../chunk-VTZVTLU4.js";
10
+ import {
11
+ LOCAL_WALLET_CONFIG
12
+ } from "../chunk-TT5MFF6V.js";
10
13
  import "../chunk-QE6JYJ77.js";
11
14
  import {
12
15
  getNetwork
@@ -24,9 +27,6 @@ import {
24
27
  RPCError
25
28
  } from "../chunk-7Z7Y2PCW.js";
26
29
  import "../chunk-GPC7GYUG.js";
27
- import {
28
- LOCAL_WALLET_CONFIG
29
- } from "../chunk-TT5MFF6V.js";
30
30
  import "../chunk-TNZ6QAWE.js";
31
31
 
32
32
  // src/tests/test-util.ts
@@ -4,7 +4,7 @@ import {
4
4
  getLatestDepositTxId,
5
5
  getNextTransactionSequence,
6
6
  getTransactionSequence
7
- } from "../chunk-G5ADKRQI.js";
7
+ } from "../chunk-LI5VQWVO.js";
8
8
  import {
9
9
  computeTaprootKeyNoScript,
10
10
  getP2TRAddressFromPkScript,
@@ -20,6 +20,7 @@ import {
20
20
  } from "../chunk-ASPK2HFV.js";
21
21
  import "../chunk-JYTR74T3.js";
22
22
  import "../chunk-XFLRFB5W.js";
23
+ import "../chunk-TT5MFF6V.js";
23
24
  import {
24
25
  LRC_WALLET_NETWORK,
25
26
  LRC_WALLET_NETWORK_TYPE,
@@ -71,7 +72,6 @@ import {
71
72
  import "../chunk-4GQZLBIR.js";
72
73
  import "../chunk-7Z7Y2PCW.js";
73
74
  import "../chunk-GPC7GYUG.js";
74
- import "../chunk-TT5MFF6V.js";
75
75
  import "../chunk-TNZ6QAWE.js";
76
76
  export {
77
77
  LRC_WALLET_NETWORK,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@buildonspark/spark-sdk",
3
- "version": "0.1.25",
3
+ "version": "0.1.26",
4
4
  "author": "",
5
5
  "license": "Apache-2.0",
6
6
  "main": "./dist/index.js",
@@ -1,2 +1,4 @@
1
1
  export { ReactNativeSparkSigner } from "../signer/signer.react-native.js";
2
+ /* Enable some consumers to use named import DefaultSparkSigner regardless of module, see LIG-7662 */
3
+ export { ReactNativeSparkSigner as DefaultSparkSigner } from "../signer/signer.react-native.js";
2
4
  export { SparkWallet } from "../spark-wallet.js";
@@ -432,10 +432,7 @@ export class TransferService extends BaseTransferService {
432
432
 
433
433
  async claimTransfer(transfer: Transfer, leaves: LeafKeyTweak[]) {
434
434
  let proofMap: Map<string, Uint8Array[]> | undefined;
435
- if (
436
- transfer.status === TransferStatus.TRANSFER_STATUS_SENDER_KEY_TWEAKED ||
437
- transfer.status === TransferStatus.TRANSFER_STATUS_RECEIVER_KEY_TWEAKED
438
- ) {
435
+ if (transfer.status === TransferStatus.TRANSFER_STATUS_SENDER_KEY_TWEAKED) {
439
436
  proofMap = await this.claimTransferTweakKeys(transfer, leaves);
440
437
  }
441
438
  const signatures = await this.claimTransferSignRefunds(
@@ -181,9 +181,10 @@ export class SparkWallet extends EventEmitter {
181
181
  protected connectionManager: ConnectionManager;
182
182
  protected lrc20ConnectionManager: ILrc20ConnectionManager;
183
183
  protected lrc20Wallet: LRCWallet | undefined;
184
+ protected transferService: TransferService;
185
+ protected tracerId = "spark-sdk";
184
186
 
185
187
  private depositService: DepositService;
186
- protected transferService: TransferService;
187
188
  private treeCreationService: TreeCreationService;
188
189
  private lightningService: LightningService;
189
190
  private coopExitService: CoopExitService;
@@ -362,10 +363,7 @@ export class SparkWallet extends EventEmitter {
362
363
  }: SparkWalletProps) {
363
364
  const wallet = new SparkWallet(options, signer);
364
365
  const initResponse = await wallet.initWallet(mnemonicOrSeed, accountNumber);
365
- if (isNode) {
366
- await wallet.initializeTracer("spark-sdk");
367
- wallet.wrapSparkWalletWithTracing();
368
- }
366
+
369
367
  return {
370
368
  wallet,
371
369
  ...initResponse,
@@ -474,11 +472,11 @@ export class SparkWallet extends EventEmitter {
474
472
  // which prevents the process from exiting. To avoid that (e.g. in CLI tools),
475
473
  // we manually unref the socket so Node can shut down when nothing else is active.
476
474
  //
477
- // The gRPC client doesnt expose the socket directly, so we dig through
475
+ // The gRPC client doesn't expose the socket directly, so we dig through
478
476
  // internal fields to find it. This is a bit of a hack and may break if the
479
477
  // internals change.
480
478
  //
481
- // Since the socket isnt always immediately available, we retry with setTimeout
479
+ // Since the socket isn't always immediately available, we retry with setTimeout
482
480
  // until it shows up.
483
481
  const maybeUnref = () => {
484
482
  const internalChannel = (channel as any).internalChannel;
@@ -502,6 +500,10 @@ export class SparkWallet extends EventEmitter {
502
500
 
503
501
  try {
504
502
  for await (const data of stream) {
503
+ if (this.streamController?.signal.aborted) {
504
+ break;
505
+ }
506
+
505
507
  if (data.event?.$case === "connected") {
506
508
  console.log("connected");
507
509
  this.emit("stream:connected");
@@ -813,6 +815,11 @@ export class SparkWallet extends EventEmitter {
813
815
  this.config.lrc20ApiConfig,
814
816
  );
815
817
 
818
+ if (isNode) {
819
+ await this.initializeTracer(this.tracerId);
820
+ this.wrapSparkWalletWithTracing();
821
+ }
822
+
816
823
  return {
817
824
  mnemonic,
818
825
  };
@@ -2506,6 +2513,14 @@ export class SparkWallet extends EventEmitter {
2506
2513
  );
2507
2514
  }
2508
2515
 
2516
+ /**
2517
+ * Retrieves token transaction history for specified tokens owned by the wallet.
2518
+ * Can optionally filter by specific transaction hashes.
2519
+ *
2520
+ * @param tokenPublicKeys - Array of token public keys to query transactions for
2521
+ * @param tokenTransactionHashes - Optional array of specific transaction hashes to filter by
2522
+ * @returns Promise resolving to array of token transactions with their current status
2523
+ */
2509
2524
  public async queryTokenTransactions(
2510
2525
  tokenPublicKeys: string[],
2511
2526
  tokenTransactionHashes?: string[],
@@ -1,27 +0,0 @@
1
- export {
2
- type CallOptions,
3
- type ClientError,
4
- type ClientMiddleware,
5
- type ClientMiddlewareCall,
6
- type ClientMiddlewareCallRequest,
7
- type ClientMiddlewareCallResponse,
8
- composeClientMiddleware,
9
- type Metadata,
10
- type MetadataConstructor,
11
- type MetadataInit,
12
- type MetadataValue,
13
- type MethodDescriptor,
14
- Status,
15
- FetchTransport,
16
- WebsocketTransport,
17
- NodeHttpTransport,
18
- createClientFactory,
19
- createClient,
20
- type Channel,
21
- type Client,
22
- type CompatServiceDefinition,
23
- type NormalizedServiceDefinition,
24
- type ServiceDefinition,
25
- type DefaultCallOptions,
26
- createChannel,
27
- } from "nice-grpc-web";
@@ -1,27 +0,0 @@
1
- export {
2
- type CallOptions,
3
- type ClientError,
4
- type ClientMiddleware,
5
- type ClientMiddlewareCall,
6
- type ClientMiddlewareCallRequest,
7
- type ClientMiddlewareCallResponse,
8
- composeClientMiddleware,
9
- type Metadata,
10
- type MetadataConstructor,
11
- type MetadataInit,
12
- type MetadataValue,
13
- type MethodDescriptor,
14
- Status,
15
- FetchTransport,
16
- WebsocketTransport,
17
- NodeHttpTransport,
18
- createClientFactory,
19
- createClient,
20
- type Channel,
21
- type Client,
22
- type CompatServiceDefinition,
23
- type NormalizedServiceDefinition,
24
- type ServiceDefinition,
25
- type DefaultCallOptions,
26
- createChannel,
27
- } from "nice-grpc-web";