@buildonspark/issuer-sdk 0.1.7 → 0.1.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,20 @@
1
1
  # @buildonspark/issuer-sdk
2
2
 
3
+ ## 0.1.9
4
+
5
+ ### Patch Changes
6
+
7
+ - - Freeze/Unfreeze Return Type Change: freezeTokens() and unfreezeTokens() now return impactedTokenOutputs: TokenOutputRef[] instead of impactedOutputIds: string[]. This provides richer output information including the token ID for each affected output.
8
+ - Updated dependencies
9
+ - @buildonspark/spark-sdk@0.5.9
10
+
11
+ ## 0.1.8
12
+
13
+ ### Patch Changes
14
+
15
+ - Updated dependencies
16
+ - @buildonspark/spark-sdk@0.5.8
17
+
3
18
  ## 0.1.7
4
19
 
5
20
  ### Patch Changes
package/README.md CHANGED
@@ -1,3 +1,128 @@
1
- # Welcome to Spark!
1
+ # Spark Issuer SDK
2
2
 
3
- You can find our official documentation at https://docs.spark.money/issuing/introduction
3
+ For complete documentation, visit [https://docs.spark.money](https://docs.spark.money)
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @buildonspark/issuer-sdk @buildonspark/spark-sdk
9
+ # or
10
+ yarn add @buildonspark/issuer-sdk @buildonspark/spark-sdk
11
+ # or
12
+ pnpm add @buildonspark/issuer-sdk @buildonspark/spark-sdk
13
+ ```
14
+
15
+ ## Quick Start
16
+
17
+ ### Initialize an Issuer Wallet
18
+
19
+ ```typescript
20
+ import { IssuerSparkWallet } from "@buildonspark/issuer-sdk";
21
+
22
+ // Create a new issuer wallet (generates a new mnemonic)
23
+ const { wallet, mnemonic } = await IssuerSparkWallet.create({
24
+ options: {
25
+ network: "MAINNET", // or "REGTEST" for testing
26
+ },
27
+ });
28
+
29
+ // Or initialize with an existing mnemonic
30
+ const wallet = await IssuerSparkWallet.initialize({
31
+ mnemonicOrSeed: "your twelve word mnemonic phrase here ...",
32
+ options: {
33
+ network: "MAINNET",
34
+ },
35
+ });
36
+ ```
37
+
38
+ ### Create a Token
39
+
40
+ ```typescript
41
+ const token = await wallet.createToken({
42
+ tokenName: "My Token",
43
+ tokenTicker: "MTK",
44
+ decimals: 8,
45
+ maxSupply: 1000000n,
46
+ isFreezable: true,
47
+ });
48
+
49
+ console.log(`Token created: ${token.tokenIdentifier}`);
50
+ ```
51
+
52
+ ### Mint Tokens
53
+
54
+ ```typescript
55
+ // Mint tokens to your own wallet
56
+ const mintResult = await wallet.mintTokens({
57
+ tokenIdentifier: "spark1...",
58
+ tokenAmount: 10000n,
59
+ });
60
+
61
+ // To distribute tokens to others, mint first then transfer
62
+ await wallet.mintTokens({
63
+ tokenIdentifier: "spark1...",
64
+ tokenAmount: 5000n,
65
+ });
66
+
67
+ await wallet.transferTokens({
68
+ tokenIdentifier: "spark1...",
69
+ receiverSparkAddress: "sp1q...",
70
+ tokenAmount: 5000n,
71
+ });
72
+ ```
73
+
74
+ ### Check Issuer Token Balance
75
+
76
+ ```typescript
77
+ // Get balance for all tokens you've issued
78
+ const balances = await wallet.getIssuerTokenBalances();
79
+ for (const [tokenId, info] of balances) {
80
+ console.log(`${info.tokenMetadata.tokenName}: ${info.balance}`);
81
+ }
82
+ ```
83
+
84
+ ### Freeze/Unfreeze Tokens
85
+
86
+ ```typescript
87
+ // Freeze tokens at a Spark address (requires isFreezable: true during creation)
88
+ await wallet.freezeTokens({
89
+ tokenIdentifier: "spark1...",
90
+ sparkAddress: "sp1q...",
91
+ });
92
+
93
+ // Unfreeze tokens at a Spark address
94
+ await wallet.unfreezeTokens({
95
+ tokenIdentifier: "spark1...",
96
+ sparkAddress: "sp1q...",
97
+ });
98
+ ```
99
+
100
+ ### Burn Tokens
101
+
102
+ ```typescript
103
+ const burnResult = await wallet.burnTokens({
104
+ tokenIdentifier: "spark1...",
105
+ tokenAmount: 1000n,
106
+ });
107
+ ```
108
+
109
+ ### Query Token Transactions
110
+
111
+ ```typescript
112
+ const transactions = await wallet.getTokenTransactions({
113
+ tokenIdentifier: "spark1...",
114
+ limit: 50,
115
+ });
116
+
117
+ for (const tx of transactions) {
118
+ console.log(`TX: ${tx.id}, Amount: ${tx.amount}`);
119
+ }
120
+ ```
121
+
122
+ ## Platform Support
123
+
124
+ The SDK supports multiple JavaScript runtimes:
125
+
126
+ - **Browser** - Web applications with WASM crypto
127
+ - **Node.js** - Server-side applications
128
+ - **React Native** - Mobile applications
@@ -1,5 +1,5 @@
1
1
  import { AggregateFrostParams, Bech32mTokenIdentifier, ConfigOptions, ConfigOptions as ConfigOptions$1, ConnectionManager, DefaultSparkSigner, DerivedHDKey, DummyTx, IKeyPackage, KeyDerivation, KeyDerivationType, KeyPair, SignFrostParams, SigningCommitment, SigningCommitmentWithOptionalNonce, SigningNonce, SparkSigner, SparkSigner as SparkSigner$1, SparkWallet, SplitSecretWithProofsParams, SubtractSplitAndEncryptParams, SubtractSplitAndEncryptResult, UnsafeStatelessSparkSigner, WalletConfig, WalletConfigService, WalletConfigService as WalletConfigService$1 } from "@buildonspark/spark-sdk";
2
- import { OutputWithPreviousTransactionData } from "@buildonspark/spark-sdk/proto/spark_token";
2
+ import { OutputWithPreviousTransactionData, TokenOutputRef } from "@buildonspark/spark-sdk/proto/spark_token";
3
3
 
4
4
  //#region src/issuer-wallet/types.d.ts
5
5
  /**
@@ -218,7 +218,7 @@ declare abstract class IssuerSparkWallet extends SparkWallet {
218
218
  * @throws {SparkValidationError} If no tokens are found for this issuer
219
219
  */
220
220
  freezeTokens(sparkAddress: string): Promise<{
221
- impactedOutputIds: string[];
221
+ impactedTokenOutputs: TokenOutputRef[];
222
222
  impactedTokenAmount: bigint;
223
223
  }>;
224
224
  /**
@@ -235,7 +235,7 @@ declare abstract class IssuerSparkWallet extends SparkWallet {
235
235
  tokenIdentifier: Bech32mTokenIdentifier;
236
236
  sparkAddress: string;
237
237
  }): Promise<{
238
- impactedOutputIds: string[];
238
+ impactedTokenOutputs: TokenOutputRef[];
239
239
  impactedTokenAmount: bigint;
240
240
  }>;
241
241
  /**
@@ -247,7 +247,7 @@ declare abstract class IssuerSparkWallet extends SparkWallet {
247
247
  * @throws {SparkValidationError} If no tokens are found for this issuer
248
248
  */
249
249
  unfreezeTokens(sparkAddress: string): Promise<{
250
- impactedOutputIds: string[];
250
+ impactedTokenOutputs: TokenOutputRef[];
251
251
  impactedTokenAmount: bigint;
252
252
  }>;
253
253
  /**
@@ -266,7 +266,7 @@ declare abstract class IssuerSparkWallet extends SparkWallet {
266
266
  tokenIdentifier: Bech32mTokenIdentifier;
267
267
  sparkAddress: string;
268
268
  }): Promise<{
269
- impactedOutputIds: string[];
269
+ impactedTokenOutputs: TokenOutputRef[];
270
270
  impactedTokenAmount: bigint;
271
271
  }>;
272
272
  /**
@@ -538,7 +538,7 @@ var IssuerSparkWallet = class extends SparkWallet {
538
538
  });
539
539
  const tokenAmount = bytesToNumberBE(response.impactedTokenAmount);
540
540
  return {
541
- impactedOutputIds: response.impactedOutputIds,
541
+ impactedTokenOutputs: response.impactedTokenOutputs,
542
542
  impactedTokenAmount: tokenAmount
543
543
  };
544
544
  }
@@ -569,7 +569,7 @@ var IssuerSparkWallet = class extends SparkWallet {
569
569
  });
570
570
  const tokenAmount = bytesToNumberBE(response.impactedTokenAmount);
571
571
  return {
572
- impactedOutputIds: response.impactedOutputIds,
572
+ impactedTokenOutputs: response.impactedTokenOutputs,
573
573
  impactedTokenAmount: tokenAmount
574
574
  };
575
575
  }
@@ -538,7 +538,7 @@ var IssuerSparkWallet = class extends _buildonspark_spark_sdk.SparkWallet {
538
538
  });
539
539
  const tokenAmount = (0, _noble_curves_utils.bytesToNumberBE)(response.impactedTokenAmount);
540
540
  return {
541
- impactedOutputIds: response.impactedOutputIds,
541
+ impactedTokenOutputs: response.impactedTokenOutputs,
542
542
  impactedTokenAmount: tokenAmount
543
543
  };
544
544
  }
@@ -569,7 +569,7 @@ var IssuerSparkWallet = class extends _buildonspark_spark_sdk.SparkWallet {
569
569
  });
570
570
  const tokenAmount = (0, _noble_curves_utils.bytesToNumberBE)(response.impactedTokenAmount);
571
571
  return {
572
- impactedOutputIds: response.impactedOutputIds,
572
+ impactedTokenOutputs: response.impactedTokenOutputs,
573
573
  impactedTokenAmount: tokenAmount
574
574
  };
575
575
  }
@@ -1,5 +1,5 @@
1
1
  import { AggregateFrostParams, Bech32mTokenIdentifier, ConfigOptions, ConfigOptions as ConfigOptions$1, ConnectionManager, DefaultSparkSigner, DerivedHDKey, DummyTx, IKeyPackage, KeyDerivation, KeyDerivationType, KeyPair, SignFrostParams, SigningCommitment, SigningCommitmentWithOptionalNonce, SigningNonce, SparkSigner, SparkSigner as SparkSigner$1, SparkWallet, SplitSecretWithProofsParams, SubtractSplitAndEncryptParams, SubtractSplitAndEncryptResult, UnsafeStatelessSparkSigner, WalletConfig, WalletConfigService, WalletConfigService as WalletConfigService$1 } from "@buildonspark/spark-sdk";
2
- import { OutputWithPreviousTransactionData } from "@buildonspark/spark-sdk/proto/spark_token";
2
+ import { OutputWithPreviousTransactionData, TokenOutputRef } from "@buildonspark/spark-sdk/proto/spark_token";
3
3
 
4
4
  //#region src/issuer-wallet/types.d.ts
5
5
  /**
@@ -218,7 +218,7 @@ declare abstract class IssuerSparkWallet extends SparkWallet {
218
218
  * @throws {SparkValidationError} If no tokens are found for this issuer
219
219
  */
220
220
  freezeTokens(sparkAddress: string): Promise<{
221
- impactedOutputIds: string[];
221
+ impactedTokenOutputs: TokenOutputRef[];
222
222
  impactedTokenAmount: bigint;
223
223
  }>;
224
224
  /**
@@ -235,7 +235,7 @@ declare abstract class IssuerSparkWallet extends SparkWallet {
235
235
  tokenIdentifier: Bech32mTokenIdentifier;
236
236
  sparkAddress: string;
237
237
  }): Promise<{
238
- impactedOutputIds: string[];
238
+ impactedTokenOutputs: TokenOutputRef[];
239
239
  impactedTokenAmount: bigint;
240
240
  }>;
241
241
  /**
@@ -247,7 +247,7 @@ declare abstract class IssuerSparkWallet extends SparkWallet {
247
247
  * @throws {SparkValidationError} If no tokens are found for this issuer
248
248
  */
249
249
  unfreezeTokens(sparkAddress: string): Promise<{
250
- impactedOutputIds: string[];
250
+ impactedTokenOutputs: TokenOutputRef[];
251
251
  impactedTokenAmount: bigint;
252
252
  }>;
253
253
  /**
@@ -266,7 +266,7 @@ declare abstract class IssuerSparkWallet extends SparkWallet {
266
266
  tokenIdentifier: Bech32mTokenIdentifier;
267
267
  sparkAddress: string;
268
268
  }): Promise<{
269
- impactedOutputIds: string[];
269
+ impactedTokenOutputs: TokenOutputRef[];
270
270
  impactedTokenAmount: bigint;
271
271
  }>;
272
272
  /**
@@ -1,5 +1,5 @@
1
1
  import { AggregateFrostParams, Bech32mTokenIdentifier, ConfigOptions, ConfigOptions as ConfigOptions$1, ConnectionManager, DefaultSparkSigner, DerivedHDKey, DummyTx, IKeyPackage, KeyDerivation, KeyDerivationType, KeyPair, SignFrostParams, SigningCommitment, SigningCommitmentWithOptionalNonce, SigningNonce, SparkSigner, SparkSigner as SparkSigner$1, SparkWallet, SplitSecretWithProofsParams, SubtractSplitAndEncryptParams, SubtractSplitAndEncryptResult, UnsafeStatelessSparkSigner, WalletConfig, WalletConfigService, WalletConfigService as WalletConfigService$1 } from "@buildonspark/spark-sdk";
2
- import { OutputWithPreviousTransactionData } from "@buildonspark/spark-sdk/proto/spark_token";
2
+ import { OutputWithPreviousTransactionData, TokenOutputRef } from "@buildonspark/spark-sdk/proto/spark_token";
3
3
 
4
4
  //#region src/issuer-wallet/types.d.ts
5
5
  /**
@@ -218,7 +218,7 @@ declare abstract class IssuerSparkWallet extends SparkWallet {
218
218
  * @throws {SparkValidationError} If no tokens are found for this issuer
219
219
  */
220
220
  freezeTokens(sparkAddress: string): Promise<{
221
- impactedOutputIds: string[];
221
+ impactedTokenOutputs: TokenOutputRef[];
222
222
  impactedTokenAmount: bigint;
223
223
  }>;
224
224
  /**
@@ -235,7 +235,7 @@ declare abstract class IssuerSparkWallet extends SparkWallet {
235
235
  tokenIdentifier: Bech32mTokenIdentifier;
236
236
  sparkAddress: string;
237
237
  }): Promise<{
238
- impactedOutputIds: string[];
238
+ impactedTokenOutputs: TokenOutputRef[];
239
239
  impactedTokenAmount: bigint;
240
240
  }>;
241
241
  /**
@@ -247,7 +247,7 @@ declare abstract class IssuerSparkWallet extends SparkWallet {
247
247
  * @throws {SparkValidationError} If no tokens are found for this issuer
248
248
  */
249
249
  unfreezeTokens(sparkAddress: string): Promise<{
250
- impactedOutputIds: string[];
250
+ impactedTokenOutputs: TokenOutputRef[];
251
251
  impactedTokenAmount: bigint;
252
252
  }>;
253
253
  /**
@@ -266,7 +266,7 @@ declare abstract class IssuerSparkWallet extends SparkWallet {
266
266
  tokenIdentifier: Bech32mTokenIdentifier;
267
267
  sparkAddress: string;
268
268
  }): Promise<{
269
- impactedOutputIds: string[];
269
+ impactedTokenOutputs: TokenOutputRef[];
270
270
  impactedTokenAmount: bigint;
271
271
  }>;
272
272
  /**
@@ -538,7 +538,7 @@ var IssuerSparkWallet = class extends SparkWallet {
538
538
  });
539
539
  const tokenAmount = bytesToNumberBE(response.impactedTokenAmount);
540
540
  return {
541
- impactedOutputIds: response.impactedOutputIds,
541
+ impactedTokenOutputs: response.impactedTokenOutputs,
542
542
  impactedTokenAmount: tokenAmount
543
543
  };
544
544
  }
@@ -569,7 +569,7 @@ var IssuerSparkWallet = class extends SparkWallet {
569
569
  });
570
570
  const tokenAmount = bytesToNumberBE(response.impactedTokenAmount);
571
571
  return {
572
- impactedOutputIds: response.impactedOutputIds,
572
+ impactedTokenOutputs: response.impactedTokenOutputs,
573
573
  impactedTokenAmount: tokenAmount
574
574
  };
575
575
  }
@@ -581,7 +581,7 @@ var IssuerSparkWallet = class extends _buildonspark_spark_sdk.SparkWallet {
581
581
  });
582
582
  const tokenAmount = (0, _noble_curves_utils.bytesToNumberBE)(response.impactedTokenAmount);
583
583
  return {
584
- impactedOutputIds: response.impactedOutputIds,
584
+ impactedTokenOutputs: response.impactedTokenOutputs,
585
585
  impactedTokenAmount: tokenAmount
586
586
  };
587
587
  }
@@ -612,7 +612,7 @@ var IssuerSparkWallet = class extends _buildonspark_spark_sdk.SparkWallet {
612
612
  });
613
613
  const tokenAmount = (0, _noble_curves_utils.bytesToNumberBE)(response.impactedTokenAmount);
614
614
  return {
615
- impactedOutputIds: response.impactedOutputIds,
615
+ impactedTokenOutputs: response.impactedTokenOutputs,
616
616
  impactedTokenAmount: tokenAmount
617
617
  };
618
618
  }
@@ -1,6 +1,6 @@
1
1
 
2
2
  import { AggregateFrostParams, Bech32mTokenIdentifier, ConfigOptions, ConfigOptions as ConfigOptions$1, DefaultSparkSigner, DerivedHDKey, DummyTx, IKeyPackage, KeyDerivation, KeyDerivationType, KeyPair, SignFrostParams, SigningCommitment, SigningCommitmentWithOptionalNonce, SigningNonce, SparkSigner, SparkSigner as SparkSigner$1, SparkWallet, SplitSecretWithProofsParams, SubtractSplitAndEncryptParams, SubtractSplitAndEncryptResult, UnsafeStatelessSparkSigner, WalletConfig, WalletConfigService } from "@buildonspark/spark-sdk";
3
- import { OutputWithPreviousTransactionData } from "@buildonspark/spark-sdk/proto/spark_token";
3
+ import { OutputWithPreviousTransactionData, TokenOutputRef } from "@buildonspark/spark-sdk/proto/spark_token";
4
4
 
5
5
  //#region src/issuer-wallet/types.d.ts
6
6
  /**
@@ -219,7 +219,7 @@ declare abstract class IssuerSparkWallet extends SparkWallet {
219
219
  * @throws {SparkValidationError} If no tokens are found for this issuer
220
220
  */
221
221
  freezeTokens(sparkAddress: string): Promise<{
222
- impactedOutputIds: string[];
222
+ impactedTokenOutputs: TokenOutputRef[];
223
223
  impactedTokenAmount: bigint;
224
224
  }>;
225
225
  /**
@@ -236,7 +236,7 @@ declare abstract class IssuerSparkWallet extends SparkWallet {
236
236
  tokenIdentifier: Bech32mTokenIdentifier;
237
237
  sparkAddress: string;
238
238
  }): Promise<{
239
- impactedOutputIds: string[];
239
+ impactedTokenOutputs: TokenOutputRef[];
240
240
  impactedTokenAmount: bigint;
241
241
  }>;
242
242
  /**
@@ -248,7 +248,7 @@ declare abstract class IssuerSparkWallet extends SparkWallet {
248
248
  * @throws {SparkValidationError} If no tokens are found for this issuer
249
249
  */
250
250
  unfreezeTokens(sparkAddress: string): Promise<{
251
- impactedOutputIds: string[];
251
+ impactedTokenOutputs: TokenOutputRef[];
252
252
  impactedTokenAmount: bigint;
253
253
  }>;
254
254
  /**
@@ -267,7 +267,7 @@ declare abstract class IssuerSparkWallet extends SparkWallet {
267
267
  tokenIdentifier: Bech32mTokenIdentifier;
268
268
  sparkAddress: string;
269
269
  }): Promise<{
270
- impactedOutputIds: string[];
270
+ impactedTokenOutputs: TokenOutputRef[];
271
271
  impactedTokenAmount: bigint;
272
272
  }>;
273
273
  /**
@@ -1,6 +1,6 @@
1
1
 
2
2
  import { AggregateFrostParams, Bech32mTokenIdentifier, ConfigOptions, ConfigOptions as ConfigOptions$1, DefaultSparkSigner, DerivedHDKey, DummyTx, IKeyPackage, KeyDerivation, KeyDerivationType, KeyPair, SignFrostParams, SigningCommitment, SigningCommitmentWithOptionalNonce, SigningNonce, SparkSigner, SparkSigner as SparkSigner$1, SparkWallet, SplitSecretWithProofsParams, SubtractSplitAndEncryptParams, SubtractSplitAndEncryptResult, UnsafeStatelessSparkSigner, WalletConfig, WalletConfigService } from "@buildonspark/spark-sdk";
3
- import { OutputWithPreviousTransactionData } from "@buildonspark/spark-sdk/proto/spark_token";
3
+ import { OutputWithPreviousTransactionData, TokenOutputRef } from "@buildonspark/spark-sdk/proto/spark_token";
4
4
 
5
5
  //#region src/issuer-wallet/types.d.ts
6
6
  /**
@@ -219,7 +219,7 @@ declare abstract class IssuerSparkWallet extends SparkWallet {
219
219
  * @throws {SparkValidationError} If no tokens are found for this issuer
220
220
  */
221
221
  freezeTokens(sparkAddress: string): Promise<{
222
- impactedOutputIds: string[];
222
+ impactedTokenOutputs: TokenOutputRef[];
223
223
  impactedTokenAmount: bigint;
224
224
  }>;
225
225
  /**
@@ -236,7 +236,7 @@ declare abstract class IssuerSparkWallet extends SparkWallet {
236
236
  tokenIdentifier: Bech32mTokenIdentifier;
237
237
  sparkAddress: string;
238
238
  }): Promise<{
239
- impactedOutputIds: string[];
239
+ impactedTokenOutputs: TokenOutputRef[];
240
240
  impactedTokenAmount: bigint;
241
241
  }>;
242
242
  /**
@@ -248,7 +248,7 @@ declare abstract class IssuerSparkWallet extends SparkWallet {
248
248
  * @throws {SparkValidationError} If no tokens are found for this issuer
249
249
  */
250
250
  unfreezeTokens(sparkAddress: string): Promise<{
251
- impactedOutputIds: string[];
251
+ impactedTokenOutputs: TokenOutputRef[];
252
252
  impactedTokenAmount: bigint;
253
253
  }>;
254
254
  /**
@@ -267,7 +267,7 @@ declare abstract class IssuerSparkWallet extends SparkWallet {
267
267
  tokenIdentifier: Bech32mTokenIdentifier;
268
268
  sparkAddress: string;
269
269
  }): Promise<{
270
- impactedOutputIds: string[];
270
+ impactedTokenOutputs: TokenOutputRef[];
271
271
  impactedTokenAmount: bigint;
272
272
  }>;
273
273
  /**
@@ -581,7 +581,7 @@ var IssuerSparkWallet = class extends SparkWallet {
581
581
  });
582
582
  const tokenAmount = bytesToNumberBE(response.impactedTokenAmount);
583
583
  return {
584
- impactedOutputIds: response.impactedOutputIds,
584
+ impactedTokenOutputs: response.impactedTokenOutputs,
585
585
  impactedTokenAmount: tokenAmount
586
586
  };
587
587
  }
@@ -612,7 +612,7 @@ var IssuerSparkWallet = class extends SparkWallet {
612
612
  });
613
613
  const tokenAmount = bytesToNumberBE(response.impactedTokenAmount);
614
614
  return {
615
- impactedOutputIds: response.impactedOutputIds,
615
+ impactedTokenOutputs: response.impactedTokenOutputs,
616
616
  impactedTokenAmount: tokenAmount
617
617
  };
618
618
  }
package/package.json CHANGED
@@ -1,8 +1,14 @@
1
1
  {
2
2
  "name": "@buildonspark/issuer-sdk",
3
- "version": "0.1.7",
3
+ "version": "0.1.9",
4
4
  "description": "Spark Issuer SDK for token issuance",
5
5
  "license": "Apache-2.0",
6
+ "keywords": [
7
+ "bitcoin",
8
+ "spark",
9
+ "token",
10
+ "issuing"
11
+ ],
6
12
  "main": "./dist/index.browser.js",
7
13
  "types": "./dist/index.browser.d.ts",
8
14
  "module": "./dist/index.browser.js",
@@ -76,7 +82,7 @@
76
82
  "types": "tsc"
77
83
  },
78
84
  "dependencies": {
79
- "@buildonspark/spark-sdk": "0.5.7",
85
+ "@buildonspark/spark-sdk": "0.5.9",
80
86
  "@noble/curves": "^1.8.0",
81
87
  "@scure/btc-signer": "^1.5.0",
82
88
  "buffer": "^6.0.3"
@@ -11,7 +11,10 @@ import {
11
11
  SparkValidationError,
12
12
  type ConfigOptions,
13
13
  } from "@buildonspark/spark-sdk";
14
- import { OutputWithPreviousTransactionData } from "@buildonspark/spark-sdk/proto/spark_token";
14
+ import {
15
+ OutputWithPreviousTransactionData,
16
+ TokenOutputRef,
17
+ } from "@buildonspark/spark-sdk/proto/spark_token";
15
18
  import { bytesToHex, bytesToNumberBE, hexToBytes } from "@noble/curves/utils";
16
19
  import { TokenFreezeService } from "../services/freeze.js";
17
20
  import { IssuerTokenTransactionService } from "../services/token-transactions.js";
@@ -633,9 +636,10 @@ export abstract class IssuerSparkWallet extends SparkWallet {
633
636
  * @throws {SparkValidationError} If multiple tokens are found for this issuer
634
637
  * @throws {SparkValidationError} If no tokens are found for this issuer
635
638
  */
636
- public async freezeTokens(
637
- sparkAddress: string,
638
- ): Promise<{ impactedOutputIds: string[]; impactedTokenAmount: bigint }>;
639
+ public async freezeTokens(sparkAddress: string): Promise<{
640
+ impactedTokenOutputs: TokenOutputRef[];
641
+ impactedTokenAmount: bigint;
642
+ }>;
639
643
 
640
644
  /**
641
645
  * Freezes tokens associated with a specific Spark address.
@@ -650,7 +654,10 @@ export abstract class IssuerSparkWallet extends SparkWallet {
650
654
  }: {
651
655
  tokenIdentifier: Bech32mTokenIdentifier;
652
656
  sparkAddress: string;
653
- }): Promise<{ impactedOutputIds: string[]; impactedTokenAmount: bigint }>;
657
+ }): Promise<{
658
+ impactedTokenOutputs: TokenOutputRef[];
659
+ impactedTokenAmount: bigint;
660
+ }>;
654
661
 
655
662
  public async freezeTokens(
656
663
  sparkAddressOrParams:
@@ -659,7 +666,10 @@ export abstract class IssuerSparkWallet extends SparkWallet {
659
666
  tokenIdentifier: Bech32mTokenIdentifier;
660
667
  sparkAddress: string;
661
668
  },
662
- ): Promise<{ impactedOutputIds: string[]; impactedTokenAmount: bigint }> {
669
+ ): Promise<{
670
+ impactedTokenOutputs: TokenOutputRef[];
671
+ impactedTokenAmount: bigint;
672
+ }> {
663
673
  let bech32mTokenIdentifier: Bech32mTokenIdentifier | undefined;
664
674
  let sparkAddress: string;
665
675
 
@@ -711,7 +721,7 @@ export abstract class IssuerSparkWallet extends SparkWallet {
711
721
  const tokenAmount = bytesToNumberBE(response.impactedTokenAmount);
712
722
 
713
723
  return {
714
- impactedOutputIds: response.impactedOutputIds,
724
+ impactedTokenOutputs: response.impactedTokenOutputs,
715
725
  impactedTokenAmount: tokenAmount,
716
726
  };
717
727
  }
@@ -724,9 +734,10 @@ export abstract class IssuerSparkWallet extends SparkWallet {
724
734
  * @throws {SparkValidationError} If multiple tokens are found for this issuer
725
735
  * @throws {SparkValidationError} If no tokens are found for this issuer
726
736
  */
727
- public async unfreezeTokens(
728
- sparkAddress: string,
729
- ): Promise<{ impactedOutputIds: string[]; impactedTokenAmount: bigint }>;
737
+ public async unfreezeTokens(sparkAddress: string): Promise<{
738
+ impactedTokenOutputs: TokenOutputRef[];
739
+ impactedTokenAmount: bigint;
740
+ }>;
730
741
 
731
742
  /**
732
743
  * Unfreezes previously frozen tokens associated with a specific Spark address.
@@ -743,7 +754,10 @@ export abstract class IssuerSparkWallet extends SparkWallet {
743
754
  }: {
744
755
  tokenIdentifier: Bech32mTokenIdentifier;
745
756
  sparkAddress: string;
746
- }): Promise<{ impactedOutputIds: string[]; impactedTokenAmount: bigint }>;
757
+ }): Promise<{
758
+ impactedTokenOutputs: TokenOutputRef[];
759
+ impactedTokenAmount: bigint;
760
+ }>;
747
761
 
748
762
  public async unfreezeTokens(
749
763
  sparkAddressOrParams:
@@ -752,7 +766,10 @@ export abstract class IssuerSparkWallet extends SparkWallet {
752
766
  tokenIdentifier: Bech32mTokenIdentifier;
753
767
  sparkAddress: string;
754
768
  },
755
- ): Promise<{ impactedOutputIds: string[]; impactedTokenAmount: bigint }> {
769
+ ): Promise<{
770
+ impactedTokenOutputs: TokenOutputRef[];
771
+ impactedTokenAmount: bigint;
772
+ }> {
756
773
  let bech32mTokenIdentifier: Bech32mTokenIdentifier | undefined;
757
774
  let sparkAddress: string;
758
775
 
@@ -802,7 +819,7 @@ export abstract class IssuerSparkWallet extends SparkWallet {
802
819
  const tokenAmount = bytesToNumberBE(response.impactedTokenAmount);
803
820
 
804
821
  return {
805
- impactedOutputIds: response.impactedOutputIds,
822
+ impactedTokenOutputs: response.impactedTokenOutputs,
806
823
  impactedTokenAmount: tokenAmount,
807
824
  };
808
825
  }
@@ -248,7 +248,7 @@ describe.each(TEST_CONFIGS)(
248
248
  tokenIdentifier: firstTokenIdentifier,
249
249
  sparkAddress: receiverAddress,
250
250
  });
251
- expect(freezeResponse.impactedOutputIds.length).toBeGreaterThan(0);
251
+ expect(freezeResponse.impactedTokenOutputs.length).toBeGreaterThan(0);
252
252
  expect(freezeResponse.impactedTokenAmount).toEqual(TOKEN_AMOUNT);
253
253
 
254
254
  // Should fail to transfer tokens because the outputs are frozen
@@ -281,7 +281,7 @@ describe.each(TEST_CONFIGS)(
281
281
  tokenIdentifier: firstTokenIdentifier,
282
282
  sparkAddress: receiverAddress,
283
283
  });
284
- expect(unfreezeResponse.impactedOutputIds.length).toBeGreaterThan(0);
284
+ expect(unfreezeResponse.impactedTokenOutputs.length).toBeGreaterThan(0);
285
285
  expect(unfreezeResponse.impactedTokenAmount).toEqual(TOKEN_AMOUNT);
286
286
 
287
287
  // Outputs unfrozen, transfer should succeed
@@ -418,7 +418,7 @@ describe.each(TEST_CONFIGS)(
418
418
  // Legacy single token issuer method should succeed when only one token is created
419
419
  const freezeResponse =
420
420
  await issuerWallet.freezeTokens(receiverSparkAddress);
421
- expect(freezeResponse.impactedOutputIds.length).toBeGreaterThan(0);
421
+ expect(freezeResponse.impactedTokenOutputs.length).toBeGreaterThan(0);
422
422
  expect(freezeResponse.impactedTokenAmount).toEqual(TOKEN_AMOUNT);
423
423
 
424
424
  // Should fail to transfer tokens because the outputs are frozen
@@ -434,7 +434,7 @@ describe.each(TEST_CONFIGS)(
434
434
  // Legacy single token issuer method should succeed when only one token is created
435
435
  const unfreezeResponse =
436
436
  await issuerWallet.unfreezeTokens(receiverSparkAddress);
437
- expect(unfreezeResponse.impactedOutputIds.length).toBeGreaterThan(0);
437
+ expect(unfreezeResponse.impactedTokenOutputs.length).toBeGreaterThan(0);
438
438
  expect(unfreezeResponse.impactedTokenAmount).toEqual(TOKEN_AMOUNT);
439
439
 
440
440
  const transferBackToIssuerOfUnfrozenToken =
@@ -435,6 +435,8 @@ describe.each(TEST_CONFIGS)(
435
435
  3_000n,
436
436
  );
437
437
 
438
+ await faucet.mineBlocksAndWaitForMiningToComplete(3);
439
+
438
440
  await sdk.claimDeposit(oneThousand.id);
439
441
  await sdk.claimDeposit(twoThousand.id);
440
442
  await sdk.claimDeposit(threeThousand.id);
@@ -58,12 +58,12 @@ describe.each(TEST_CONFIGS)(
58
58
  expect(userBalanceAfterTransfer.balance).toEqual(tokenAmount);
59
59
 
60
60
  const freezeResponse = await issuerWallet.freezeTokens(userSparkAddress);
61
- expect(freezeResponse.impactedOutputIds.length).toBeGreaterThan(0);
61
+ expect(freezeResponse.impactedTokenOutputs.length).toBeGreaterThan(0);
62
62
  expect(freezeResponse.impactedTokenAmount).toEqual(tokenAmount);
63
63
 
64
64
  const unfreezeResponse =
65
65
  await issuerWallet.unfreezeTokens(userSparkAddress);
66
- expect(unfreezeResponse.impactedOutputIds.length).toBeGreaterThan(0);
66
+ expect(unfreezeResponse.impactedTokenOutputs.length).toBeGreaterThan(0);
67
67
  expect(unfreezeResponse.impactedTokenAmount).toEqual(tokenAmount);
68
68
  });
69
69
 
@@ -1,6 +1,9 @@
1
- import { filterTokenBalanceForTokenIdentifier } from "@buildonspark/spark-sdk";
1
+ import {
2
+ filterTokenBalanceForTokenIdentifier,
3
+ NetworkType,
4
+ } from "@buildonspark/spark-sdk";
2
5
  import { jest } from "@jest/globals";
3
- import { bytesToHex } from "@noble/curves/utils";
6
+ import { bytesToHex, bytesToNumberBE } from "@noble/curves/utils";
4
7
  import { IssuerSparkWalletTesting } from "../utils/issuer-test-wallet.js";
5
8
  import { SparkWalletTesting } from "@buildonspark/spark-sdk/test-utils";
6
9
  import { TEST_CONFIGS } from "./test-configs.js";
@@ -109,7 +112,7 @@ describe.each(TEST_CONFIGS)(
109
112
 
110
113
  await issuerWallet.burnTokens(250n);
111
114
 
112
- const res = await issuerWallet.queryTokenTransactions({
115
+ const res = await issuerWallet.queryTokenTransactionsWithFilters({
113
116
  tokenIdentifiers: [tokenIdentifier!],
114
117
  sparkAddresses: [await issuerWallet.getSparkAddress()],
115
118
  });
@@ -156,8 +159,11 @@ describe.each(TEST_CONFIGS)(
156
159
  });
157
160
 
158
161
  const tokenIdentifier = await issuerWallet.getIssuerTokenIdentifier();
162
+ const issuerPublicKey = await issuerWallet.getIdentityPublicKey();
163
+ const issuerSparkAddress = await issuerWallet.getSparkAddress();
164
+ const userSparkAddress = await userWallet.getSparkAddress();
159
165
 
160
- await issuerWallet.mintTokens(tokenAmount);
166
+ const mintTxHash = await issuerWallet.mintTokens(tokenAmount);
161
167
 
162
168
  {
163
169
  const res = await issuerWallet.queryTokenTransactions({
@@ -168,10 +174,19 @@ describe.each(TEST_CONFIGS)(
168
174
  expect(amount_of_transactions).toEqual(1);
169
175
  }
170
176
 
177
+ {
178
+ const res = await issuerWallet.queryTokenTransactionsWithFilters({
179
+ tokenIdentifiers: [tokenIdentifier!],
180
+ });
181
+ const transactions = res.tokenTransactionsWithStatus;
182
+ const amount_of_transactions = transactions.length;
183
+ expect(amount_of_transactions).toEqual(1);
184
+ }
185
+
171
186
  await issuerWallet.transferTokens({
172
187
  tokenAmount,
173
188
  tokenIdentifier: tokenIdentifier!,
174
- receiverSparkAddress: await userWallet.getSparkAddress(),
189
+ receiverSparkAddress: userSparkAddress,
175
190
  });
176
191
 
177
192
  {
@@ -183,16 +198,52 @@ describe.each(TEST_CONFIGS)(
183
198
  expect(amount_of_transactions).toEqual(2);
184
199
  }
185
200
 
201
+ {
202
+ const res = await issuerWallet.queryTokenTransactionsWithFilters({
203
+ tokenIdentifiers: [tokenIdentifier!],
204
+ });
205
+ const transactions = res.tokenTransactionsWithStatus;
206
+ const amount_of_transactions = transactions.length;
207
+ expect(amount_of_transactions).toEqual(2);
208
+ }
209
+
186
210
  for (let index = 0; index < 100; ++index) {
187
211
  const dynamicAmount = BigInt(index + 1);
188
212
  await issuerWallet.mintTokens(dynamicAmount);
189
213
  await issuerWallet.transferTokens({
190
214
  tokenAmount: dynamicAmount,
191
215
  tokenIdentifier: tokenIdentifier!,
192
- receiverSparkAddress: await userWallet.getSparkAddress(),
216
+ receiverSparkAddress: userSparkAddress,
193
217
  });
194
218
  }
195
219
 
220
+ {
221
+ const res = await issuerWallet.queryTokenTransactionsByTxHashes([
222
+ mintTxHash!,
223
+ ]);
224
+ const transactions = res.tokenTransactionsWithStatus;
225
+ expect(transactions.length).toEqual(1);
226
+ expect(bytesToHex(transactions[0].tokenTransactionHash)).toEqual(
227
+ mintTxHash,
228
+ );
229
+ expect(transactions[0].tokenTransaction?.tokenInputs?.$case).toEqual(
230
+ "mintInput",
231
+ );
232
+ expect(
233
+ bytesToHex(
234
+ transactions[0].tokenTransaction?.tokenOutputs?.[0]
235
+ ?.ownerPublicKey!,
236
+ ),
237
+ ).toEqual(issuerPublicKey);
238
+ expect(
239
+ BigInt(
240
+ bytesToNumberBE(
241
+ transactions[0].tokenTransaction?.tokenOutputs?.[0]?.tokenAmount!,
242
+ ),
243
+ ),
244
+ ).toEqual(tokenAmount);
245
+ }
246
+
196
247
  {
197
248
  const res = await issuerWallet.queryTokenTransactions({
198
249
  tokenIdentifiers: [tokenIdentifier!],
@@ -203,6 +254,79 @@ describe.each(TEST_CONFIGS)(
203
254
  expect(amount_of_transactions).toEqual(10);
204
255
  }
205
256
 
257
+ {
258
+ const res = await issuerWallet.queryTokenTransactionsWithFilters({
259
+ tokenIdentifiers: [tokenIdentifier!],
260
+ pageSize: 10,
261
+ });
262
+ const transactions = res.tokenTransactionsWithStatus;
263
+ const amount_of_transactions = transactions.length;
264
+ expect(amount_of_transactions).toEqual(10);
265
+ }
266
+
267
+ {
268
+ const res = await issuerWallet.queryTokenTransactionsWithFilters({
269
+ tokenIdentifiers: [tokenIdentifier!],
270
+ issuerPublicKeys: [issuerPublicKey],
271
+ pageSize: 10,
272
+ });
273
+ const transactions = res.tokenTransactionsWithStatus;
274
+ const amount_of_transactions = transactions.length;
275
+ expect(amount_of_transactions).toEqual(10);
276
+ }
277
+
278
+ {
279
+ const res = await issuerWallet.queryTokenTransactionsWithFilters({
280
+ tokenIdentifiers: [tokenIdentifier!],
281
+ sparkAddresses: [issuerSparkAddress],
282
+ pageSize: 5,
283
+ });
284
+ const transactions = res.tokenTransactionsWithStatus;
285
+ const pageInfo = res.pageResponse;
286
+ expect(transactions.length).toEqual(5);
287
+ expect(pageInfo?.hasNextPage).toEqual(true);
288
+ expect(pageInfo?.nextCursor).not.toEqual("");
289
+ const nextCursor = pageInfo?.nextCursor ?? "";
290
+
291
+ const nextRes = await issuerWallet.queryTokenTransactionsWithFilters({
292
+ tokenIdentifiers: [tokenIdentifier!],
293
+ sparkAddresses: [issuerSparkAddress],
294
+ pageSize: 5,
295
+ cursor: nextCursor,
296
+ });
297
+ const nextTransactions = nextRes.tokenTransactionsWithStatus;
298
+ const nextPageInfo = nextRes.pageResponse;
299
+ expect(nextTransactions.length).toEqual(5);
300
+ expect(nextPageInfo?.hasPreviousPage).toEqual(true);
301
+ expect(nextPageInfo?.previousCursor).not.toEqual("");
302
+
303
+ const seenHashes = new Set(
304
+ transactions.map((tx) => bytesToHex(tx.tokenTransactionHash)),
305
+ );
306
+ nextTransactions.forEach((tx) => {
307
+ const hash = bytesToHex(tx.tokenTransactionHash);
308
+ expect(seenHashes.has(hash)).toEqual(false);
309
+ });
310
+
311
+ const prevRes = await issuerWallet.queryTokenTransactionsWithFilters({
312
+ tokenIdentifiers: [tokenIdentifier!],
313
+ sparkAddresses: [issuerSparkAddress],
314
+ pageSize: 5,
315
+ cursor: nextPageInfo?.previousCursor ?? "",
316
+ direction: "PREVIOUS",
317
+ });
318
+ const prevTransactions = prevRes.tokenTransactionsWithStatus;
319
+ expect(prevTransactions.length).toEqual(5);
320
+
321
+ const prevHashes = new Set(
322
+ prevTransactions.map((tx) => bytesToHex(tx.tokenTransactionHash)),
323
+ );
324
+ transactions.forEach((tx) => {
325
+ const hash = bytesToHex(tx.tokenTransactionHash);
326
+ expect(prevHashes.has(hash)).toEqual(true);
327
+ });
328
+ }
329
+
206
330
  {
207
331
  let hashset_of_all_transactions: Set<String> = new Set();
208
332