@buildonspark/issuer-sdk 0.0.96 → 0.0.97

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,12 @@
1
1
  # @buildonspark/issuer-sdk
2
2
 
3
+ ## 0.0.97
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies
8
+ - @buildonspark/spark-sdk@0.3.4
9
+
3
10
  ## 0.0.96
4
11
 
5
12
  ### Patch Changes
@@ -153,26 +153,6 @@ var IssuerTokenTransactionService = class extends TokenTransactionService {
153
153
  constructor(config, connectionManager) {
154
154
  super(config, connectionManager);
155
155
  }
156
- async constructMintTokenTransactionV0(tokenPublicKey, tokenAmount) {
157
- return {
158
- network: this.config.getNetworkProto(),
159
- tokenInputs: {
160
- $case: "mintInput",
161
- mintInput: {
162
- issuerPublicKey: tokenPublicKey,
163
- issuerProvidedTimestamp: Date.now()
164
- }
165
- },
166
- tokenOutputs: [
167
- {
168
- ownerPublicKey: tokenPublicKey,
169
- tokenPublicKey,
170
- tokenAmount: numberToBytesBE(tokenAmount, 16)
171
- }
172
- ],
173
- sparkOperatorIdentityPublicKeys: super.collectOperatorIdentityPublicKeys()
174
- };
175
- }
176
156
  async constructMintTokenTransaction(rawTokenIdentifierBytes, issuerTokenPublicKey, tokenAmount) {
177
157
  return {
178
158
  version: 2,
@@ -472,23 +452,15 @@ var IssuerSparkWallet = class _IssuerSparkWallet extends SparkWallet {
472
452
  * @returns The transaction ID of the mint operation
473
453
  */
474
454
  async mintTokens(tokenAmount) {
475
- let tokenTransaction;
476
455
  const issuerTokenPublicKey = await super.getIdentityPublicKey();
477
456
  const issuerTokenPublicKeyBytes = hexToBytes2(issuerTokenPublicKey);
478
457
  const tokenMetadata = await this.getIssuerTokenMetadata();
479
458
  const rawTokenIdentifier = tokenMetadata.rawTokenIdentifier;
480
- if (this.config.getTokenTransactionVersion() === "V0") {
481
- tokenTransaction = await this.issuerTokenTransactionService.constructMintTokenTransactionV0(
482
- issuerTokenPublicKeyBytes,
483
- tokenAmount
484
- );
485
- } else {
486
- tokenTransaction = await this.issuerTokenTransactionService.constructMintTokenTransaction(
487
- rawTokenIdentifier,
488
- issuerTokenPublicKeyBytes,
489
- tokenAmount
490
- );
491
- }
459
+ const tokenTransaction = await this.issuerTokenTransactionService.constructMintTokenTransaction(
460
+ rawTokenIdentifier,
461
+ issuerTokenPublicKeyBytes,
462
+ tokenAmount
463
+ );
492
464
  return await this.issuerTokenTransactionService.broadcastTokenTransaction(
493
465
  tokenTransaction
494
466
  );
package/dist/index.cjs CHANGED
@@ -175,26 +175,6 @@ var IssuerTokenTransactionService = class extends import_spark_sdk3.TokenTransac
175
175
  constructor(config, connectionManager) {
176
176
  super(config, connectionManager);
177
177
  }
178
- async constructMintTokenTransactionV0(tokenPublicKey, tokenAmount) {
179
- return {
180
- network: this.config.getNetworkProto(),
181
- tokenInputs: {
182
- $case: "mintInput",
183
- mintInput: {
184
- issuerPublicKey: tokenPublicKey,
185
- issuerProvidedTimestamp: Date.now()
186
- }
187
- },
188
- tokenOutputs: [
189
- {
190
- ownerPublicKey: tokenPublicKey,
191
- tokenPublicKey,
192
- tokenAmount: (0, import_utils3.numberToBytesBE)(tokenAmount, 16)
193
- }
194
- ],
195
- sparkOperatorIdentityPublicKeys: super.collectOperatorIdentityPublicKeys()
196
- };
197
- }
198
178
  async constructMintTokenTransaction(rawTokenIdentifierBytes, issuerTokenPublicKey, tokenAmount) {
199
179
  return {
200
180
  version: 2,
@@ -494,23 +474,15 @@ var IssuerSparkWallet = class _IssuerSparkWallet extends import_spark_sdk5.Spark
494
474
  * @returns The transaction ID of the mint operation
495
475
  */
496
476
  async mintTokens(tokenAmount) {
497
- let tokenTransaction;
498
477
  const issuerTokenPublicKey = await super.getIdentityPublicKey();
499
478
  const issuerTokenPublicKeyBytes = (0, import_utils4.hexToBytes)(issuerTokenPublicKey);
500
479
  const tokenMetadata = await this.getIssuerTokenMetadata();
501
480
  const rawTokenIdentifier = tokenMetadata.rawTokenIdentifier;
502
- if (this.config.getTokenTransactionVersion() === "V0") {
503
- tokenTransaction = await this.issuerTokenTransactionService.constructMintTokenTransactionV0(
504
- issuerTokenPublicKeyBytes,
505
- tokenAmount
506
- );
507
- } else {
508
- tokenTransaction = await this.issuerTokenTransactionService.constructMintTokenTransaction(
509
- rawTokenIdentifier,
510
- issuerTokenPublicKeyBytes,
511
- tokenAmount
512
- );
513
- }
481
+ const tokenTransaction = await this.issuerTokenTransactionService.constructMintTokenTransaction(
482
+ rawTokenIdentifier,
483
+ issuerTokenPublicKeyBytes,
484
+ tokenAmount
485
+ );
514
486
  return await this.issuerTokenTransactionService.broadcastTokenTransaction(
515
487
  tokenTransaction
516
488
  );
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  IssuerSparkWallet
3
- } from "./chunk-HQI3Y4QH.js";
3
+ } from "./chunk-GKBNEYTU.js";
4
4
  import "./chunk-7B4B24XF.js";
5
5
 
6
6
  // src/issuer-wallet/issuer-spark-wallet.browser.ts
@@ -175,26 +175,6 @@ var IssuerTokenTransactionService = class extends import_spark_sdk3.TokenTransac
175
175
  constructor(config, connectionManager) {
176
176
  super(config, connectionManager);
177
177
  }
178
- async constructMintTokenTransactionV0(tokenPublicKey, tokenAmount) {
179
- return {
180
- network: this.config.getNetworkProto(),
181
- tokenInputs: {
182
- $case: "mintInput",
183
- mintInput: {
184
- issuerPublicKey: tokenPublicKey,
185
- issuerProvidedTimestamp: Date.now()
186
- }
187
- },
188
- tokenOutputs: [
189
- {
190
- ownerPublicKey: tokenPublicKey,
191
- tokenPublicKey,
192
- tokenAmount: (0, import_utils3.numberToBytesBE)(tokenAmount, 16)
193
- }
194
- ],
195
- sparkOperatorIdentityPublicKeys: super.collectOperatorIdentityPublicKeys()
196
- };
197
- }
198
178
  async constructMintTokenTransaction(rawTokenIdentifierBytes, issuerTokenPublicKey, tokenAmount) {
199
179
  return {
200
180
  version: 2,
@@ -494,23 +474,15 @@ var IssuerSparkWallet = class _IssuerSparkWallet extends import_spark_sdk5.Spark
494
474
  * @returns The transaction ID of the mint operation
495
475
  */
496
476
  async mintTokens(tokenAmount) {
497
- let tokenTransaction;
498
477
  const issuerTokenPublicKey = await super.getIdentityPublicKey();
499
478
  const issuerTokenPublicKeyBytes = (0, import_utils4.hexToBytes)(issuerTokenPublicKey);
500
479
  const tokenMetadata = await this.getIssuerTokenMetadata();
501
480
  const rawTokenIdentifier = tokenMetadata.rawTokenIdentifier;
502
- if (this.config.getTokenTransactionVersion() === "V0") {
503
- tokenTransaction = await this.issuerTokenTransactionService.constructMintTokenTransactionV0(
504
- issuerTokenPublicKeyBytes,
505
- tokenAmount
506
- );
507
- } else {
508
- tokenTransaction = await this.issuerTokenTransactionService.constructMintTokenTransaction(
509
- rawTokenIdentifier,
510
- issuerTokenPublicKeyBytes,
511
- tokenAmount
512
- );
513
- }
481
+ const tokenTransaction = await this.issuerTokenTransactionService.constructMintTokenTransaction(
482
+ rawTokenIdentifier,
483
+ issuerTokenPublicKeyBytes,
484
+ tokenAmount
485
+ );
514
486
  return await this.issuerTokenTransactionService.broadcastTokenTransaction(
515
487
  tokenTransaction
516
488
  );
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  IssuerSparkWallet
3
- } from "./chunk-HQI3Y4QH.js";
3
+ } from "./chunk-GKBNEYTU.js";
4
4
  import "./chunk-7B4B24XF.js";
5
5
 
6
6
  // src/issuer-wallet/issuer-spark-wallet.node.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@buildonspark/issuer-sdk",
3
- "version": "0.0.96",
3
+ "version": "0.0.97",
4
4
  "description": "Spark Issuer SDK for token issuance",
5
5
  "license": "Apache-2.0",
6
6
  "module": "./dist/index.js",
@@ -72,7 +72,7 @@
72
72
  "types": "tsc"
73
73
  },
74
74
  "dependencies": {
75
- "@buildonspark/spark-sdk": "0.3.3",
75
+ "@buildonspark/spark-sdk": "0.3.4",
76
76
  "@noble/curves": "^1.8.0",
77
77
  "@scure/btc-signer": "^1.5.0",
78
78
  "buffer": "^6.0.3"
@@ -12,11 +12,7 @@ import {
12
12
  ValidationError,
13
13
  type ConfigOptions,
14
14
  } from "@buildonspark/spark-sdk";
15
- import {
16
- OutputWithPreviousTransactionData,
17
- TokenTransaction as TokenTransactionV0,
18
- } from "@buildonspark/spark-sdk/proto/spark";
19
- import { TokenTransaction } from "@buildonspark/spark-sdk/proto/spark_token";
15
+ import { OutputWithPreviousTransactionData } from "@buildonspark/spark-sdk/proto/spark";
20
16
  import { bytesToHex, bytesToNumberBE, hexToBytes } from "@noble/curves/utils";
21
17
  import { TokenFreezeService } from "../services/freeze.js";
22
18
  import { IssuerTokenTransactionService } from "../services/token-transactions.js";
@@ -241,27 +237,18 @@ export class IssuerSparkWallet extends SparkWallet {
241
237
  * @returns The transaction ID of the mint operation
242
238
  */
243
239
  public async mintTokens(tokenAmount: bigint): Promise<string> {
244
- let tokenTransaction: TokenTransactionV0 | TokenTransaction;
245
240
  const issuerTokenPublicKey = await super.getIdentityPublicKey();
246
241
  const issuerTokenPublicKeyBytes = hexToBytes(issuerTokenPublicKey);
247
242
 
248
243
  const tokenMetadata = await this.getIssuerTokenMetadata();
249
244
  const rawTokenIdentifier: Uint8Array = tokenMetadata.rawTokenIdentifier;
250
245
 
251
- if (this.config.getTokenTransactionVersion() === "V0") {
252
- tokenTransaction =
253
- await this.issuerTokenTransactionService.constructMintTokenTransactionV0(
254
- issuerTokenPublicKeyBytes,
255
- tokenAmount,
256
- );
257
- } else {
258
- tokenTransaction =
259
- await this.issuerTokenTransactionService.constructMintTokenTransaction(
260
- rawTokenIdentifier,
261
- issuerTokenPublicKeyBytes,
262
- tokenAmount,
263
- );
264
- }
246
+ const tokenTransaction =
247
+ await this.issuerTokenTransactionService.constructMintTokenTransaction(
248
+ rawTokenIdentifier,
249
+ issuerTokenPublicKeyBytes,
250
+ tokenAmount,
251
+ );
265
252
 
266
253
  return await this.issuerTokenTransactionService.broadcastTokenTransaction(
267
254
  tokenTransaction,
@@ -3,7 +3,6 @@ import {
3
3
  WalletConfigService,
4
4
  type ConnectionManager,
5
5
  } from "@buildonspark/spark-sdk";
6
- import { TokenTransaction as TokenTransactionV0 } from "@buildonspark/spark-sdk/proto/spark";
7
6
  import { TokenTransaction } from "@buildonspark/spark-sdk/proto/spark_token";
8
7
  import { numberToBytesBE } from "@noble/curves/utils";
9
8
 
@@ -15,31 +14,6 @@ export class IssuerTokenTransactionService extends TokenTransactionService {
15
14
  super(config, connectionManager);
16
15
  }
17
16
 
18
- async constructMintTokenTransactionV0(
19
- tokenPublicKey: Uint8Array,
20
- tokenAmount: bigint,
21
- ): Promise<TokenTransactionV0> {
22
- return {
23
- network: this.config.getNetworkProto(),
24
- tokenInputs: {
25
- $case: "mintInput",
26
- mintInput: {
27
- issuerPublicKey: tokenPublicKey,
28
- issuerProvidedTimestamp: Date.now(),
29
- },
30
- },
31
- tokenOutputs: [
32
- {
33
- ownerPublicKey: tokenPublicKey,
34
- tokenPublicKey: tokenPublicKey,
35
- tokenAmount: numberToBytesBE(tokenAmount, 16),
36
- },
37
- ],
38
- sparkOperatorIdentityPublicKeys:
39
- super.collectOperatorIdentityPublicKeys(),
40
- };
41
- }
42
-
43
17
  async constructMintTokenTransaction(
44
18
  rawTokenIdentifierBytes: Uint8Array,
45
19
  issuerTokenPublicKey: Uint8Array,
@@ -5,40 +5,25 @@ import {
5
5
  WalletConfig,
6
6
  } from "@buildonspark/spark-sdk";
7
7
  import { jest } from "@jest/globals";
8
- import { hexToBytes, bytesToHex } from "@noble/curves/utils";
8
+ import { bytesToHex } from "@noble/curves/utils";
9
9
  import { IssuerSparkWalletTesting } from "../utils/issuer-test-wallet.js";
10
10
  import { SparkWalletTesting } from "../utils/spark-testing-wallet.js";
11
11
  import { BitcoinFaucet } from "@buildonspark/spark-sdk/test-utils";
12
+ import { InvoiceStatus } from "@buildonspark/spark-sdk/proto/spark";
12
13
 
13
- export const TOKENS_V0_SCHNORR_CONFIG: Required<ConfigOptions> = {
14
+ export const TOKENS_SCHNORR_CONFIG: Required<ConfigOptions> = {
14
15
  ...WalletConfig.LOCAL,
15
- tokenTransactionVersion: "V0",
16
16
  tokenSignatures: "SCHNORR",
17
17
  };
18
18
 
19
- export const TOKENS_V1_SCHNORR_CONFIG: Required<ConfigOptions> = {
20
- ...WalletConfig.LOCAL,
21
- tokenTransactionVersion: "V1",
22
- tokenSignatures: "SCHNORR",
23
- };
24
-
25
- export const TOKENS_V0_ECDSA_CONFIG: Required<ConfigOptions> = {
26
- ...WalletConfig.LOCAL,
27
- tokenSignatures: "ECDSA",
28
- tokenTransactionVersion: "V0",
29
- };
30
-
31
- export const TOKENS_V1_ECDSA_CONFIG: Required<ConfigOptions> = {
19
+ export const TOKENS_ECDSA_CONFIG: Required<ConfigOptions> = {
32
20
  ...WalletConfig.LOCAL,
33
21
  tokenSignatures: "ECDSA",
34
- tokenTransactionVersion: "V1",
35
22
  };
36
23
 
37
24
  const TEST_CONFIGS = [
38
- { name: "TV0E", config: TOKENS_V0_ECDSA_CONFIG },
39
- { name: "TV0S", config: TOKENS_V0_SCHNORR_CONFIG },
40
- { name: "TV1E", config: TOKENS_V1_ECDSA_CONFIG },
41
- { name: "TV1S", config: TOKENS_V1_SCHNORR_CONFIG },
25
+ { name: "TE", config: TOKENS_ECDSA_CONFIG },
26
+ { name: "TS", config: TOKENS_SCHNORR_CONFIG },
42
27
  ];
43
28
 
44
29
  const brokenTestFn = process.env.GITHUB_ACTIONS ? it.skip : it;
@@ -198,8 +183,10 @@ describe.each(TEST_CONFIGS)(
198
183
  expect(userBalance.balance).toBeGreaterThanOrEqual(tokenAmount);
199
184
  });
200
185
 
201
- const tv1It = name.startsWith("TV1") ? it.skip : it.skip;
202
- tv1It("should transfer tokens using spark invoices", async () => {
186
+ // const tv1It = name.startsWith("TV1") ? it.skip : it.skip;
187
+ // TODO: (CNT-493) Re-enable invoice functionality once spark address migration is complete
188
+ const skipInvoiceTest = it.skip;
189
+ skipInvoiceTest("should transfer tokens using spark invoices", async () => {
203
190
  const tokenAmount: bigint = 777n;
204
191
  const initialIssuerBalance = 100000n;
205
192
 
@@ -254,201 +241,217 @@ describe.each(TEST_CONFIGS)(
254
241
  expect(receiverBalance.balance).toEqual(tokenAmount);
255
242
  });
256
243
 
257
- tv1It("should transfer tokens using multiple spark invoices", async () => {
258
- const amount1: bigint = 111n;
259
- const amount2: bigint = 222n;
260
- const amount3: bigint = 333n;
261
- const totalAmount: bigint = amount1 + amount2 + amount3;
262
- const initialIssuerBalance = 100000n;
244
+ skipInvoiceTest(
245
+ "should transfer tokens using multiple spark invoices",
246
+ async () => {
247
+ const amount1: bigint = 111n;
248
+ const amount2: bigint = 222n;
249
+ const amount3: bigint = 333n;
250
+ const totalAmount: bigint = amount1 + amount2 + amount3;
251
+ const initialIssuerBalance = 100000n;
263
252
 
264
- const { wallet: issuerWallet } =
265
- await IssuerSparkWalletTesting.initialize({
266
- options: config,
267
- });
268
- const { wallet: receiverWallet1 } = await SparkWalletTesting.initialize({
269
- options: config,
270
- });
271
- const { wallet: receiverWallet2 } = await SparkWalletTesting.initialize({
272
- options: config,
273
- });
253
+ const { wallet: issuerWallet } =
254
+ await IssuerSparkWalletTesting.initialize({
255
+ options: config,
256
+ });
257
+ const { wallet: receiverWallet1 } = await SparkWalletTesting.initialize(
258
+ {
259
+ options: config,
260
+ },
261
+ );
262
+ const { wallet: receiverWallet2 } = await SparkWalletTesting.initialize(
263
+ {
264
+ options: config,
265
+ },
266
+ );
274
267
 
275
- await issuerWallet.createToken({
276
- tokenName: `${name}INVM`,
277
- tokenTicker: "INM",
278
- decimals: 0,
279
- isFreezable: false,
280
- maxSupply: 1_000_000n,
281
- });
268
+ await issuerWallet.createToken({
269
+ tokenName: `${name}INVM`,
270
+ tokenTicker: "INM",
271
+ decimals: 0,
272
+ isFreezable: false,
273
+ maxSupply: 1_000_000n,
274
+ });
282
275
 
283
- await issuerWallet.mintTokens(initialIssuerBalance);
276
+ await issuerWallet.mintTokens(initialIssuerBalance);
284
277
 
285
- const issuerBalanceAfterMint = await issuerWallet.getIssuerTokenBalance();
286
- expect(issuerBalanceAfterMint).toBeDefined();
287
- expect(issuerBalanceAfterMint.balance).toBe(initialIssuerBalance);
288
- const tokenIdentifier = issuerBalanceAfterMint.tokenIdentifier!;
289
- const issuerBalanceBeforeTransfer = issuerBalanceAfterMint.balance;
278
+ const issuerBalanceAfterMint =
279
+ await issuerWallet.getIssuerTokenBalance();
280
+ expect(issuerBalanceAfterMint).toBeDefined();
281
+ expect(issuerBalanceAfterMint.balance).toBe(initialIssuerBalance);
282
+ const tokenIdentifier = issuerBalanceAfterMint.tokenIdentifier!;
283
+ const issuerBalanceBeforeTransfer = issuerBalanceAfterMint.balance;
290
284
 
291
- const invoice1 = await receiverWallet1.createTokensInvoice({
292
- amount: amount1,
293
- tokenIdentifier,
294
- memo: "Invoice #1",
295
- expiryTime: new Date(Date.now() + 1000 * 60 * 60 * 24),
296
- });
285
+ const invoice1 = await receiverWallet1.createTokensInvoice({
286
+ amount: amount1,
287
+ tokenIdentifier,
288
+ memo: "Invoice #1",
289
+ expiryTime: new Date(Date.now() + 1000 * 60 * 60 * 24),
290
+ });
297
291
 
298
- const invoice2 = await receiverWallet1.createTokensInvoice({
299
- amount: amount2,
300
- tokenIdentifier,
301
- memo: "Invoice #2",
302
- expiryTime: new Date(Date.now() + 1000 * 60 * 60 * 24),
303
- });
292
+ const invoice2 = await receiverWallet1.createTokensInvoice({
293
+ amount: amount2,
294
+ tokenIdentifier,
295
+ memo: "Invoice #2",
296
+ expiryTime: new Date(Date.now() + 1000 * 60 * 60 * 24),
297
+ });
304
298
 
305
- const invoice3 = await receiverWallet2.createTokensInvoice({
306
- amount: amount3,
307
- tokenIdentifier,
308
- memo: "Invoice #3",
309
- expiryTime: new Date(Date.now() + 1000 * 60 * 60 * 24),
310
- });
299
+ const invoice3 = await receiverWallet2.createTokensInvoice({
300
+ amount: amount3,
301
+ tokenIdentifier,
302
+ memo: "Invoice #3",
303
+ expiryTime: new Date(Date.now() + 1000 * 60 * 60 * 24),
304
+ });
311
305
 
312
- const { tokenTransactionSuccess } =
313
- await issuerWallet.fulfillSparkInvoice([
314
- { invoice: invoice1 },
315
- { invoice: invoice2 },
316
- { invoice: invoice3 },
317
- ]);
318
- expect(tokenTransactionSuccess.length).toBe(1);
319
- expect(tokenTransactionSuccess[0].txid).toBeDefined();
320
- expect(tokenTransactionSuccess[0].txid.length).toBeGreaterThan(0);
306
+ const { tokenTransactionSuccess } =
307
+ await issuerWallet.fulfillSparkInvoice([
308
+ { invoice: invoice1 },
309
+ { invoice: invoice2 },
310
+ { invoice: invoice3 },
311
+ ]);
312
+ expect(tokenTransactionSuccess.length).toBe(1);
313
+ expect(tokenTransactionSuccess[0].txid).toBeDefined();
314
+ expect(tokenTransactionSuccess[0].txid.length).toBeGreaterThan(0);
321
315
 
322
- const issuerBalanceAfter = (await issuerWallet.getIssuerTokenBalance())
323
- .balance;
324
- expect(issuerBalanceAfter).toEqual(
325
- issuerBalanceBeforeTransfer - totalAmount,
326
- );
316
+ const issuerBalanceAfter = (await issuerWallet.getIssuerTokenBalance())
317
+ .balance;
318
+ expect(issuerBalanceAfter).toEqual(
319
+ issuerBalanceBeforeTransfer - totalAmount,
320
+ );
327
321
 
328
- const receiver1BalanceObj = await receiverWallet1.getBalance();
329
- const receiver1Balance = filterTokenBalanceForTokenIdentifier(
330
- receiver1BalanceObj?.tokenBalances,
331
- tokenIdentifier!,
332
- );
333
- expect(receiver1Balance.balance).toEqual(amount1 + amount2);
322
+ const receiver1BalanceObj = await receiverWallet1.getBalance();
323
+ const receiver1Balance = filterTokenBalanceForTokenIdentifier(
324
+ receiver1BalanceObj?.tokenBalances,
325
+ tokenIdentifier!,
326
+ );
327
+ expect(receiver1Balance.balance).toEqual(amount1 + amount2);
334
328
 
335
- const receiver2BalanceObj = await receiverWallet2.getBalance();
336
- const receiver2Balance = filterTokenBalanceForTokenIdentifier(
337
- receiver2BalanceObj?.tokenBalances,
338
- tokenIdentifier!,
339
- );
340
- expect(receiver2Balance.balance).toEqual(amount3);
341
- });
329
+ const receiver2BalanceObj = await receiverWallet2.getBalance();
330
+ const receiver2Balance = filterTokenBalanceForTokenIdentifier(
331
+ receiver2BalanceObj?.tokenBalances,
332
+ tokenIdentifier!,
333
+ );
334
+ expect(receiver2Balance.balance).toEqual(amount3);
335
+ },
336
+ );
342
337
 
343
- tv1It("should fail to fulfill an expired spark invoice", async () => {
344
- const tokenAmount: bigint = 123n;
345
- const initialIssuerBalance = 100000n;
338
+ skipInvoiceTest(
339
+ "should fail to fulfill an expired spark invoice",
340
+ async () => {
341
+ const tokenAmount: bigint = 123n;
342
+ const initialIssuerBalance = 100000n;
346
343
 
347
- const { wallet: issuerWallet } =
348
- await IssuerSparkWalletTesting.initialize({
344
+ const { wallet: issuerWallet } =
345
+ await IssuerSparkWalletTesting.initialize({
346
+ options: config,
347
+ });
348
+ const { wallet: receiverWallet } = await SparkWalletTesting.initialize({
349
349
  options: config,
350
350
  });
351
- const { wallet: receiverWallet } = await SparkWalletTesting.initialize({
352
- options: config,
353
- });
354
351
 
355
- await issuerWallet.createToken({
356
- tokenName: `${name}INVEXP`,
357
- tokenTicker: "INVX",
358
- decimals: 0,
359
- isFreezable: false,
360
- maxSupply: 1_000_000n,
361
- });
352
+ await issuerWallet.createToken({
353
+ tokenName: `${name}INVEXP`,
354
+ tokenTicker: "INVX",
355
+ decimals: 0,
356
+ isFreezable: false,
357
+ maxSupply: 1_000_000n,
358
+ });
362
359
 
363
- await issuerWallet.mintTokens(initialIssuerBalance);
360
+ await issuerWallet.mintTokens(initialIssuerBalance);
364
361
 
365
- const issuerBalanceAfterMint = await issuerWallet.getIssuerTokenBalance();
366
- expect(issuerBalanceAfterMint).toBeDefined();
367
- expect(issuerBalanceAfterMint.balance).toBe(initialIssuerBalance);
368
- const tokenIdentifier = issuerBalanceAfterMint.tokenIdentifier!;
369
- const issuerBalanceBefore = issuerBalanceAfterMint.balance;
362
+ const issuerBalanceAfterMint =
363
+ await issuerWallet.getIssuerTokenBalance();
364
+ expect(issuerBalanceAfterMint).toBeDefined();
365
+ expect(issuerBalanceAfterMint.balance).toBe(initialIssuerBalance);
366
+ const tokenIdentifier = issuerBalanceAfterMint.tokenIdentifier!;
367
+ const issuerBalanceBefore = issuerBalanceAfterMint.balance;
370
368
 
371
- const expiredInvoice = await receiverWallet.createTokensInvoice({
372
- amount: tokenAmount,
373
- tokenIdentifier,
374
- memo: "Expired invoice",
375
- expiryTime: new Date(Date.now() - 60_000),
376
- });
369
+ const expiredInvoice = await receiverWallet.createTokensInvoice({
370
+ amount: tokenAmount,
371
+ tokenIdentifier,
372
+ memo: "Expired invoice",
373
+ expiryTime: new Date(Date.now() - 60_000),
374
+ });
377
375
 
378
- const { invalidInvoices } = await issuerWallet.fulfillSparkInvoice([
379
- { invoice: expiredInvoice },
380
- ]);
381
- expect(invalidInvoices.length).toBe(1);
382
- expect(invalidInvoices[0].invoice).toBe(expiredInvoice);
376
+ const { invalidInvoices } = await issuerWallet.fulfillSparkInvoice([
377
+ { invoice: expiredInvoice },
378
+ ]);
379
+ expect(invalidInvoices.length).toBe(1);
380
+ expect(invalidInvoices[0].invoice).toBe(expiredInvoice);
383
381
 
384
- const issuerBalanceAfter = (await issuerWallet.getIssuerTokenBalance())
385
- .balance;
386
- expect(issuerBalanceAfter).toEqual(issuerBalanceBefore);
382
+ const issuerBalanceAfter = (await issuerWallet.getIssuerTokenBalance())
383
+ .balance;
384
+ expect(issuerBalanceAfter).toEqual(issuerBalanceBefore);
387
385
 
388
- const receiverBalanceObj = await receiverWallet.getBalance();
389
- const receiverBalance = filterTokenBalanceForTokenIdentifier(
390
- receiverBalanceObj?.tokenBalances,
391
- tokenIdentifier!,
392
- );
393
- expect(receiverBalance.balance).toEqual(0n);
394
- });
386
+ const receiverBalanceObj = await receiverWallet.getBalance();
387
+ const receiverBalance = filterTokenBalanceForTokenIdentifier(
388
+ receiverBalanceObj?.tokenBalances,
389
+ tokenIdentifier!,
390
+ );
391
+ expect(receiverBalance.balance).toEqual(0n);
392
+ },
393
+ );
395
394
 
396
- tv1It("should fulfill a spark invoice with null expiry", async () => {
397
- const tokenAmount: bigint = 321n;
398
- const initialIssuerBalance = 100000n;
395
+ skipInvoiceTest(
396
+ "should fulfill a spark invoice with null expiry",
397
+ async () => {
398
+ const tokenAmount: bigint = 321n;
399
+ const initialIssuerBalance = 100000n;
399
400
 
400
- const { wallet: issuerWallet } =
401
- await IssuerSparkWalletTesting.initialize({
401
+ const { wallet: issuerWallet } =
402
+ await IssuerSparkWalletTesting.initialize({
403
+ options: config,
404
+ });
405
+ const { wallet: receiverWallet } = await SparkWalletTesting.initialize({
402
406
  options: config,
403
407
  });
404
- const { wallet: receiverWallet } = await SparkWalletTesting.initialize({
405
- options: config,
406
- });
407
408
 
408
- await issuerWallet.createToken({
409
- tokenName: `${name}INVNULL`,
410
- tokenTicker: "INVN",
411
- decimals: 0,
412
- isFreezable: false,
413
- maxSupply: 1_000_000n,
414
- });
409
+ await issuerWallet.createToken({
410
+ tokenName: `${name}INVNULL`,
411
+ tokenTicker: "INVN",
412
+ decimals: 0,
413
+ isFreezable: false,
414
+ maxSupply: 1_000_000n,
415
+ });
415
416
 
416
- await issuerWallet.mintTokens(initialIssuerBalance);
417
+ await issuerWallet.mintTokens(initialIssuerBalance);
417
418
 
418
- const issuerBalanceAfterMint = await issuerWallet.getIssuerTokenBalance();
419
- expect(issuerBalanceAfterMint).toBeDefined();
420
- expect(issuerBalanceAfterMint.balance).toBe(initialIssuerBalance);
421
- const tokenIdentifier = issuerBalanceAfterMint.tokenIdentifier!;
422
- const issuerBalanceBefore = issuerBalanceAfterMint.balance;
419
+ const issuerBalanceAfterMint =
420
+ await issuerWallet.getIssuerTokenBalance();
421
+ expect(issuerBalanceAfterMint).toBeDefined();
422
+ expect(issuerBalanceAfterMint.balance).toBe(initialIssuerBalance);
423
+ const tokenIdentifier = issuerBalanceAfterMint.tokenIdentifier!;
424
+ const issuerBalanceBefore = issuerBalanceAfterMint.balance;
423
425
 
424
- const nullExpiryInvoice = await receiverWallet.createTokensInvoice({
425
- amount: tokenAmount,
426
- tokenIdentifier,
427
- memo: "Null expiry invoice",
428
- expiryTime: null as unknown as Date,
429
- });
426
+ const nullExpiryInvoice = await receiverWallet.createTokensInvoice({
427
+ amount: tokenAmount,
428
+ tokenIdentifier,
429
+ memo: "Null expiry invoice",
430
+ expiryTime: null as unknown as Date,
431
+ });
430
432
 
431
- const { tokenTransactionSuccess } =
432
- await issuerWallet.fulfillSparkInvoice([
433
- { invoice: nullExpiryInvoice },
434
- ]);
435
- expect(tokenTransactionSuccess.length).toBe(1);
436
- expect(tokenTransactionSuccess[0].txid).toBeDefined();
437
- expect(tokenTransactionSuccess[0].txid.length).toBeGreaterThan(0);
433
+ const { tokenTransactionSuccess } =
434
+ await issuerWallet.fulfillSparkInvoice([
435
+ { invoice: nullExpiryInvoice },
436
+ ]);
437
+ expect(tokenTransactionSuccess.length).toBe(1);
438
+ expect(tokenTransactionSuccess[0].txid).toBeDefined();
439
+ expect(tokenTransactionSuccess[0].txid.length).toBeGreaterThan(0);
438
440
 
439
- const issuerBalanceAfter = (await issuerWallet.getIssuerTokenBalance())
440
- .balance;
441
- expect(issuerBalanceAfter).toEqual(issuerBalanceBefore - tokenAmount);
441
+ const issuerBalanceAfter = (await issuerWallet.getIssuerTokenBalance())
442
+ .balance;
443
+ expect(issuerBalanceAfter).toEqual(issuerBalanceBefore - tokenAmount);
442
444
 
443
- const receiverBalanceObj = await receiverWallet.getBalance();
444
- const receiverBalance = filterTokenBalanceForTokenIdentifier(
445
- receiverBalanceObj?.tokenBalances,
446
- tokenIdentifier!,
447
- );
448
- expect(receiverBalance.balance).toEqual(tokenAmount);
449
- });
445
+ const receiverBalanceObj = await receiverWallet.getBalance();
446
+ const receiverBalance = filterTokenBalanceForTokenIdentifier(
447
+ receiverBalanceObj?.tokenBalances,
448
+ tokenIdentifier!,
449
+ );
450
+ expect(receiverBalance.balance).toEqual(tokenAmount);
451
+ },
452
+ );
450
453
 
451
- tv1It(
454
+ skipInvoiceTest(
452
455
  "should fulfill a tokens invoice without amount by passing amount parameter",
453
456
  async () => {
454
457
  const tokenAmount: bigint = 555n;
@@ -508,7 +511,7 @@ describe.each(TEST_CONFIGS)(
508
511
  },
509
512
  );
510
513
 
511
- tv1It(
514
+ skipInvoiceTest(
512
515
  `fulfillSparkInvoice successfully handles multiple mixed tokens and sats invoices`,
513
516
  async () => {
514
517
  const faucet = BitcoinFaucet.getInstance();
@@ -639,6 +642,26 @@ describe.each(TEST_CONFIGS)(
639
642
  expect(tokenTransactionSuccess.length).toBe(2); // two token assets - divided into two token transactions
640
643
  expect(tokenTransactionErrors.length).toBe(0);
641
644
  expect(invalidInvoices.length).toBe(0);
645
+ const invoicesToQuery = [
646
+ invoice1000,
647
+ invoice2000,
648
+ invoiceNilAmount,
649
+ sdkOneTokenInvoiceA,
650
+ sdkOneTokenInvoiceB,
651
+ sdkTwoTokenInvoiceA,
652
+ sdkTwoTokenNilAmountInvoiceB,
653
+ ];
654
+ const queryInvoiceResponse = await (sdk as any).querySparkInvoices(
655
+ invoicesToQuery,
656
+ );
657
+ expect(queryInvoiceResponse.invoiceStatuses.length).toBe(7);
658
+ for (let i = 0; i < queryInvoiceResponse.invoiceStatuses.length; i++) {
659
+ const response = queryInvoiceResponse.invoiceStatuses[i];
660
+ const invoiceStatus = response.status;
661
+ expect(invoiceStatus).toBeDefined();
662
+ expect(invoiceStatus).toBe(InvoiceStatus.FINALIZED);
663
+ expect(response.invoice).toBe(invoicesToQuery[i]);
664
+ }
642
665
  },
643
666
  );
644
667