@buildonspark/issuer-sdk 0.1.3 → 0.1.5

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.
@@ -260,6 +260,9 @@ var IssuerTokenTransactionService = class extends TokenTransactionService {
260
260
  }
261
261
  };
262
262
 
263
+ // src/issuer-wallet/issuer-spark-wallet.ts
264
+ import { hashFinalTokenTransaction } from "@buildonspark/spark-sdk";
265
+
263
266
  // src/utils/create-validation.ts
264
267
  import { SparkValidationError as SparkValidationError2 } from "@buildonspark/spark-sdk";
265
268
  function isNfcNormalized(value) {
@@ -367,49 +370,70 @@ var IssuerSparkWallet = class extends SparkWallet {
367
370
  }
368
371
  /**
369
372
  * Gets the token balance for the issuer's token.
373
+ * @deprecated Use getIssuerTokenBalances() instead. This method will be removed in a future version.
370
374
  * @returns An object containing the token balance as a bigint
375
+ *
376
+ * @throws {SparkValidationError} If multiple tokens are found for this issuer
371
377
  */
372
378
  async getIssuerTokenBalance() {
373
379
  const publicKey = await super.getIdentityPublicKey();
374
380
  const balanceObj = await this.getBalance();
375
- const issuerBalance = [...balanceObj.tokenBalances.entries()].find(
381
+ const issuerBalance = [...balanceObj.tokenBalances.entries()].filter(
376
382
  ([, info]) => info.tokenMetadata.tokenPublicKey === publicKey
377
383
  );
378
- if (!balanceObj.tokenBalances || issuerBalance === void 0) {
384
+ if (issuerBalance.length > 1) {
385
+ throw new SparkValidationError3(
386
+ "Multiple tokens found for this issuer. Use getIssuerTokenBalances() instead.",
387
+ {
388
+ field: "issuerTokenBalance",
389
+ expected: "single token",
390
+ actual: `${issuerBalance.length} tokens`
391
+ }
392
+ );
393
+ }
394
+ if (issuerBalance.length === 0) {
379
395
  return {
380
396
  tokenIdentifier: void 0,
381
397
  balance: 0n
382
398
  };
383
399
  }
384
400
  return {
385
- tokenIdentifier: issuerBalance[0] ?? void 0,
386
- balance: issuerBalance[1].balance
401
+ tokenIdentifier: issuerBalance[0][0],
402
+ balance: issuerBalance[0][1].balance
387
403
  };
388
404
  }
405
+ /**
406
+ * Gets the token balances for the tokens that were issued by this user.
407
+ * @returns An array of objects containing the token identifier and balance
408
+ */
409
+ async getIssuerTokenBalances() {
410
+ const publicKey = await super.getIdentityPublicKey();
411
+ const balanceObj = await this.getBalance();
412
+ const issuerBalance = [...balanceObj.tokenBalances.entries()].filter(
413
+ ([, info]) => info.tokenMetadata.tokenPublicKey === publicKey
414
+ );
415
+ if (issuerBalance.length === 0) {
416
+ return [
417
+ {
418
+ tokenIdentifier: void 0,
419
+ balance: 0n
420
+ }
421
+ ];
422
+ }
423
+ return issuerBalance.map(([tokenIdentifier, { balance }]) => ({
424
+ tokenIdentifier,
425
+ balance
426
+ }));
427
+ }
389
428
  /**
390
429
  * Retrieves information about the issuer's token.
391
- * @returns An object containing token information including public key, name, symbol, decimals, max supply, and freeze status
430
+ * @deprecated Use getIssuerTokensMetadata() instead. This method will be removed in a future version.
431
+ * @returns An object containing token information including public key, name, symbol, decimals, max supply, freeze status, and extra metadata
392
432
  * @throws {SparkRequestError} If the token metadata cannot be retrieved
433
+ * @throws {SparkValidationError} If multiple tokens are found for this issuer
393
434
  */
394
435
  async getIssuerTokenMetadata() {
395
436
  const issuerPublicKey = await super.getIdentityPublicKey();
396
- const tokenMetadata = this.tokenMetadata;
397
- const cachedIssuerTokenMetadata = [...tokenMetadata.entries()].find(
398
- ([, metadata]) => bytesToHex(metadata.issuerPublicKey) === issuerPublicKey
399
- );
400
- if (cachedIssuerTokenMetadata !== void 0) {
401
- const metadata = cachedIssuerTokenMetadata[1];
402
- return {
403
- tokenPublicKey: bytesToHex(metadata.issuerPublicKey),
404
- rawTokenIdentifier: metadata.tokenIdentifier,
405
- tokenName: metadata.tokenName,
406
- tokenTicker: metadata.tokenTicker,
407
- decimals: metadata.decimals,
408
- maxSupply: bytesToNumberBE(metadata.maxSupply),
409
- isFreezable: metadata.isFreezable,
410
- extraMetadata: metadata.extraMetadata ? new Uint8Array(metadata.extraMetadata) : void 0
411
- };
412
- }
413
437
  const sparkTokenClient = await this.connectionManager.createSparkTokenClient(
414
438
  this.config.getCoordinatorAddress()
415
439
  );
@@ -429,12 +453,21 @@ var IssuerSparkWallet = class extends SparkWallet {
429
453
  }
430
454
  );
431
455
  }
456
+ if (response.tokenMetadata.length > 1) {
457
+ throw new SparkValidationError3(
458
+ "Multiple tokens found for this issuer. Please migrate to getIssuerTokensMetadata() instead.",
459
+ {
460
+ field: "tokenMetadata",
461
+ value: response.tokenMetadata
462
+ }
463
+ );
464
+ }
432
465
  const metadata = response.tokenMetadata[0];
433
- const tokenIdentifier = encodeBech32mTokenIdentifier({
466
+ const bech32mTokenIdentifier = encodeBech32mTokenIdentifier({
434
467
  tokenIdentifier: metadata.tokenIdentifier,
435
468
  network: this.config.getNetworkType()
436
469
  });
437
- this.tokenMetadata.set(tokenIdentifier, metadata);
470
+ this.tokenMetadata.set(bech32mTokenIdentifier, metadata);
438
471
  return {
439
472
  tokenPublicKey: bytesToHex(metadata.issuerPublicKey),
440
473
  rawTokenIdentifier: metadata.tokenIdentifier,
@@ -443,47 +476,110 @@ var IssuerSparkWallet = class extends SparkWallet {
443
476
  decimals: metadata.decimals,
444
477
  maxSupply: bytesToNumberBE(metadata.maxSupply),
445
478
  isFreezable: metadata.isFreezable,
446
- extraMetadata: metadata.extraMetadata
479
+ extraMetadata: metadata.extraMetadata ? new Uint8Array(metadata.extraMetadata) : void 0,
480
+ bech32mTokenIdentifier
447
481
  };
448
482
  } catch (error) {
449
483
  throw new SparkRequestError2("Failed to fetch token metadata", { error });
450
484
  }
451
485
  }
486
+ /**
487
+ * Retrieves information about the tokens that were issued by this user.
488
+ * @returns An array of objects containing token information including public key, name, symbol, decimals, max supply, freeze status, and extra metadata
489
+ * @throws {SparkRequestError} If the token metadata cannot be retrieved
490
+ */
491
+ async getIssuerTokensMetadata() {
492
+ const issuerPublicKey = await super.getIdentityPublicKey();
493
+ const sparkTokenClient = await this.connectionManager.createSparkTokenClient(
494
+ this.config.getCoordinatorAddress()
495
+ );
496
+ try {
497
+ const response = await sparkTokenClient.query_token_metadata({
498
+ issuerPublicKeys: Array.of(hexToBytes2(issuerPublicKey))
499
+ });
500
+ if (response.tokenMetadata.length === 0) {
501
+ throw new SparkValidationError3(
502
+ "Token metadata not found - If a token has not yet been created, please create it first. Try again in a few seconds.",
503
+ {
504
+ field: "tokenMetadata",
505
+ value: response.tokenMetadata,
506
+ expected: "non-empty array",
507
+ actualLength: response.tokenMetadata.length,
508
+ expectedLength: 1
509
+ }
510
+ );
511
+ }
512
+ const tokenMetadata = [];
513
+ for (const metadata of response.tokenMetadata) {
514
+ const bech32mTokenIdentifier = encodeBech32mTokenIdentifier({
515
+ tokenIdentifier: metadata.tokenIdentifier,
516
+ network: this.config.getNetworkType()
517
+ });
518
+ this.tokenMetadata.set(bech32mTokenIdentifier, metadata);
519
+ tokenMetadata.push({
520
+ tokenPublicKey: bytesToHex(metadata.issuerPublicKey),
521
+ rawTokenIdentifier: metadata.tokenIdentifier,
522
+ tokenName: metadata.tokenName,
523
+ tokenTicker: metadata.tokenTicker,
524
+ decimals: metadata.decimals,
525
+ maxSupply: bytesToNumberBE(metadata.maxSupply),
526
+ isFreezable: metadata.isFreezable,
527
+ extraMetadata: metadata.extraMetadata ? new Uint8Array(metadata.extraMetadata) : void 0,
528
+ bech32mTokenIdentifier
529
+ });
530
+ }
531
+ return tokenMetadata;
532
+ } catch (error) {
533
+ throw new SparkRequestError2("Failed to fetch token metadata", { error });
534
+ }
535
+ }
452
536
  /**
453
537
  * Retrieves the bech32m encoded token identifier for the issuer's token.
538
+ * @deprecated Use getIssuerTokenIdentifiers() instead. This method will be removed in a future version.
454
539
  * @returns The bech32m encoded token identifier for the issuer's token
455
540
  * @throws {SparkRequestError} If the token identifier cannot be retrieved
541
+ * @throws {SparkValidationError} If multiple tokens are found for this issuer
456
542
  */
457
543
  async getIssuerTokenIdentifier() {
458
- const tokenMetadata = await this.getIssuerTokenMetadata();
459
- return encodeBech32mTokenIdentifier({
460
- tokenIdentifier: tokenMetadata.rawTokenIdentifier,
461
- network: this.config.getNetworkType()
462
- });
544
+ const tokensMetadata = await this.getIssuerTokensMetadata();
545
+ if (tokensMetadata.length > 1) {
546
+ throw new SparkValidationError3(
547
+ "Multiple tokens found. Use getIssuerTokenIdentifiers() instead.",
548
+ {
549
+ method: "getIssuerTokenIdentifier",
550
+ availableTokens: tokensMetadata.map((t) => ({
551
+ tokenName: t.tokenName,
552
+ tokenTicker: t.tokenTicker,
553
+ bech32mTokenIdentifier: encodeBech32mTokenIdentifier({
554
+ tokenIdentifier: t.rawTokenIdentifier,
555
+ network: this.config.getNetworkType()
556
+ })
557
+ }))
558
+ }
559
+ );
560
+ }
561
+ if (tokensMetadata.length === 0) {
562
+ throw new SparkValidationError3("No tokens found. Create a token first.");
563
+ }
564
+ return tokensMetadata[0].bech32mTokenIdentifier;
463
565
  }
464
566
  /**
465
- * Create a new token on Spark.
466
- *
467
- * @param params - Object containing token creation parameters.
468
- * @param params.tokenName - The name of the token.
469
- * @param params.tokenTicker - The ticker symbol for the token.
470
- * @param params.decimals - The number of decimal places for the token.
471
- * @param params.isFreezable - Whether the token can be frozen.
472
- * @param [params.maxSupply=0n] - (Optional) The maximum supply of the token. Defaults to <code>0n</code>.
473
- * @param params.extraMetadata - (Optional) This can be used to store additional bytes data to be associated with a token, like image data.
474
- *
475
- * @returns The transaction ID of the announcement.
476
- *
477
- * @throws {SparkValidationError} If `decimals` is not a safe integer or other validation fails.
478
- * @throws {SparkRequestError} If the announcement transaction cannot be broadcast.
567
+ * Retrieves the bech32m encoded token identifier for the issuer's token.
568
+ * @returns The bech32m encoded token identifier for the issuer's token
569
+ * @throws {SparkRequestError} If the token identifier cannot be retrieved
479
570
  */
571
+ async getIssuerTokenIdentifiers() {
572
+ const tokensMetadata = await this.getIssuerTokensMetadata();
573
+ return tokensMetadata.map((metadata) => metadata.bech32mTokenIdentifier);
574
+ }
480
575
  async createToken({
481
576
  tokenName,
482
577
  tokenTicker,
483
578
  decimals,
484
579
  isFreezable,
485
580
  maxSupply = 0n,
486
- extraMetadata
581
+ extraMetadata,
582
+ returnIdentifierForCreate = false
487
583
  }) {
488
584
  validateTokenParameters(
489
585
  tokenName,
@@ -503,9 +599,30 @@ var IssuerSparkWallet = class extends SparkWallet {
503
599
  isFreezable,
504
600
  extraMetadata
505
601
  );
506
- return await this.issuerTokenTransactionService.broadcastTokenTransaction(
602
+ const { finalTokenTransactionHash, tokenIdentifier } = await this.issuerTokenTransactionService.broadcastTokenTransactionDetailed(
507
603
  tokenTransaction
508
604
  );
605
+ const txHash = bytesToHex(finalTokenTransactionHash);
606
+ if (returnIdentifierForCreate) {
607
+ if (!tokenIdentifier) {
608
+ throw new SparkRequestError2(
609
+ "Server response missing expected field: tokenIdentifier",
610
+ {
611
+ operation: "broadcast_transaction",
612
+ field: "tokenIdentifier"
613
+ }
614
+ );
615
+ }
616
+ const bech32mTokenIdentifier = encodeBech32mTokenIdentifier({
617
+ tokenIdentifier,
618
+ network: this.config.getNetworkType()
619
+ });
620
+ return {
621
+ tokenIdentifier: bech32mTokenIdentifier,
622
+ transactionHash: txHash
623
+ };
624
+ }
625
+ return txHash;
509
626
  } else {
510
627
  const partialTokenTransaction = await this.issuerTokenTransactionService.constructPartialCreateTokenTransaction(
511
628
  hexToBytes2(issuerPublicKey),
@@ -516,21 +633,75 @@ var IssuerSparkWallet = class extends SparkWallet {
516
633
  isFreezable,
517
634
  extraMetadata
518
635
  );
519
- return await this.issuerTokenTransactionService.broadcastTokenTransactionV3(
636
+ const broadcastResponse = await this.issuerTokenTransactionService.broadcastTokenTransactionV3Detailed(
520
637
  partialTokenTransaction
521
638
  );
639
+ const finalHash = await hashFinalTokenTransaction(
640
+ broadcastResponse.finalTokenTransaction
641
+ );
642
+ const finalTransactionHash = bytesToHex(finalHash);
643
+ if (returnIdentifierForCreate) {
644
+ if (!broadcastResponse.tokenIdentifier) {
645
+ throw new SparkRequestError2(
646
+ "Server response missing expected field: tokenIdentifier",
647
+ {
648
+ operation: "broadcast_transaction",
649
+ field: "tokenIdentifier"
650
+ }
651
+ );
652
+ }
653
+ const tokenIdentifier = encodeBech32mTokenIdentifier({
654
+ tokenIdentifier: broadcastResponse.tokenIdentifier,
655
+ network: this.config.getNetworkType()
656
+ });
657
+ return {
658
+ tokenIdentifier,
659
+ transactionHash: finalTransactionHash
660
+ };
661
+ }
662
+ return finalTransactionHash;
522
663
  }
523
664
  }
524
- /**
525
- * Mints new tokens
526
- * @param tokenAmount - The amount of tokens to mint
527
- * @returns The transaction ID of the mint operation
528
- */
529
- async mintTokens(tokenAmount) {
665
+ async mintTokens(tokenAmountOrParams) {
666
+ let tokenAmount;
667
+ let bech32mTokenIdentifier;
668
+ if (typeof tokenAmountOrParams === "bigint") {
669
+ tokenAmount = tokenAmountOrParams;
670
+ bech32mTokenIdentifier = void 0;
671
+ } else {
672
+ tokenAmount = tokenAmountOrParams.tokenAmount;
673
+ bech32mTokenIdentifier = tokenAmountOrParams.tokenIdentifier;
674
+ }
530
675
  const issuerTokenPublicKey = await super.getIdentityPublicKey();
531
676
  const issuerTokenPublicKeyBytes = hexToBytes2(issuerTokenPublicKey);
532
- const tokenMetadata = await this.getIssuerTokenMetadata();
533
- const rawTokenIdentifier = tokenMetadata.rawTokenIdentifier;
677
+ const tokensMetadata = await this.getIssuerTokensMetadata();
678
+ if (bech32mTokenIdentifier === void 0) {
679
+ if (tokensMetadata.length > 1) {
680
+ throw new SparkValidationError3(
681
+ "Multiple tokens found. Please use mintTokens({ tokenAmount, tokenIdentifier }) instead.",
682
+ {
683
+ field: "tokenIdentifier",
684
+ availableTokens: tokensMetadata.map((t) => ({
685
+ tokenName: t.tokenName,
686
+ tokenTicker: t.tokenTicker,
687
+ bech32mTokenIdentifier: encodeBech32mTokenIdentifier({
688
+ tokenIdentifier: t.rawTokenIdentifier,
689
+ network: this.config.getNetworkType()
690
+ })
691
+ }))
692
+ }
693
+ );
694
+ }
695
+ const encodedTokenIdentifier = encodeBech32mTokenIdentifier({
696
+ tokenIdentifier: tokensMetadata[0].rawTokenIdentifier,
697
+ network: this.config.getNetworkType()
698
+ });
699
+ bech32mTokenIdentifier = encodedTokenIdentifier;
700
+ }
701
+ const rawTokenIdentifier = decodeBech32mTokenIdentifier(
702
+ bech32mTokenIdentifier,
703
+ this.config.getNetworkType()
704
+ ).tokenIdentifier;
534
705
  if (this.config.getTokenTransactionVersion() === "V2") {
535
706
  const tokenTransaction = await this.issuerTokenTransactionService.constructMintTokenTransaction(
536
707
  rawTokenIdentifier,
@@ -551,39 +722,108 @@ var IssuerSparkWallet = class extends SparkWallet {
551
722
  );
552
723
  }
553
724
  }
554
- /**
555
- * Burns issuer's tokens
556
- * @param tokenAmount - The amount of tokens to burn
557
- * @param selectedOutputs - Optional array of outputs to use for the burn operation
558
- * @returns The transaction ID of the burn operation
559
- */
560
- async burnTokens(tokenAmount, selectedOutputs) {
725
+ async burnTokens(tokenAmountOrParams, selectedOutputs) {
726
+ let bech32mTokenIdentifier;
727
+ let tokenAmount;
728
+ let outputs;
729
+ if (typeof tokenAmountOrParams === "bigint") {
730
+ tokenAmount = tokenAmountOrParams;
731
+ outputs = selectedOutputs;
732
+ const tokenIdentifiers = await this.getIssuerTokenIdentifiers();
733
+ if (tokenIdentifiers.length > 1) {
734
+ throw new SparkValidationError3(
735
+ "Multiple tokens found. Use burnTokens({ tokenIdentifier, tokenAmount, selectedOutputs }) to specify which token to burn.",
736
+ {
737
+ field: "tokenIdentifier",
738
+ availableTokens: tokenIdentifiers
739
+ }
740
+ );
741
+ }
742
+ if (tokenIdentifiers.length === 0) {
743
+ throw new SparkValidationError3(
744
+ "No tokens found. Create a token first."
745
+ );
746
+ }
747
+ bech32mTokenIdentifier = tokenIdentifiers[0];
748
+ } else {
749
+ tokenAmount = tokenAmountOrParams.tokenAmount;
750
+ outputs = tokenAmountOrParams.selectedOutputs;
751
+ if (tokenAmountOrParams.tokenIdentifier) {
752
+ const tokenIdentifiers = await this.getIssuerTokenIdentifiers();
753
+ const tokenIdentifier = tokenIdentifiers.find(
754
+ (identifier) => identifier === tokenAmountOrParams.tokenIdentifier
755
+ );
756
+ if (!tokenIdentifier) {
757
+ throw new SparkValidationError3("Token not found for this issuer", {
758
+ field: "tokenIdentifier",
759
+ value: tokenAmountOrParams.tokenIdentifier
760
+ });
761
+ }
762
+ bech32mTokenIdentifier = tokenAmountOrParams.tokenIdentifier;
763
+ } else {
764
+ const tokenIdentifiers = await this.getIssuerTokenIdentifiers();
765
+ if (tokenIdentifiers.length === 0) {
766
+ throw new SparkValidationError3(
767
+ "No tokens found. Create a token first."
768
+ );
769
+ }
770
+ if (tokenIdentifiers.length > 1) {
771
+ throw new SparkValidationError3(
772
+ "Multiple tokens found. Please specify tokenIdentifier in parameters.",
773
+ {
774
+ field: "tokenIdentifier",
775
+ availableTokens: tokenIdentifiers
776
+ }
777
+ );
778
+ }
779
+ bech32mTokenIdentifier = tokenIdentifiers[0];
780
+ }
781
+ }
561
782
  const burnAddress = encodeSparkAddress({
562
783
  identityPublicKey: BURN_ADDRESS,
563
784
  network: this.config.getNetworkType()
564
785
  });
565
- const issuerTokenIdentifier = await this.getIssuerTokenIdentifier();
566
786
  return await this.transferTokens({
567
- tokenIdentifier: issuerTokenIdentifier,
787
+ tokenIdentifier: bech32mTokenIdentifier,
568
788
  tokenAmount,
569
789
  receiverSparkAddress: burnAddress,
570
- selectedOutputs
790
+ selectedOutputs: outputs
571
791
  });
572
792
  }
573
- /**
574
- * Freezes tokens associated with a specific Spark address.
575
- * @param sparkAddress - The Spark address whose tokens should be frozen
576
- * @returns An object containing the IDs of impacted outputs and the total amount of frozen tokens
577
- */
578
- async freezeTokens(sparkAddress) {
579
- await this.syncTokenOutputs();
793
+ async freezeTokens(sparkAddressOrParams) {
794
+ let bech32mTokenIdentifier;
795
+ let sparkAddress;
796
+ if (typeof sparkAddressOrParams === "string") {
797
+ sparkAddress = sparkAddressOrParams;
798
+ bech32mTokenIdentifier = void 0;
799
+ } else {
800
+ sparkAddress = sparkAddressOrParams.sparkAddress;
801
+ bech32mTokenIdentifier = sparkAddressOrParams.tokenIdentifier;
802
+ }
580
803
  const decodedOwnerPubkey = decodeSparkAddress(
581
804
  sparkAddress,
582
805
  this.config.getNetworkType()
583
806
  );
584
- const issuerTokenIdentifier = await this.getIssuerTokenIdentifier();
807
+ if (bech32mTokenIdentifier === void 0) {
808
+ const tokenIdentifiers = await this.getIssuerTokenIdentifiers();
809
+ if (tokenIdentifiers.length === 0) {
810
+ throw new SparkValidationError3(
811
+ "No tokens found. Create a token first."
812
+ );
813
+ }
814
+ if (tokenIdentifiers.length > 1) {
815
+ throw new SparkValidationError3(
816
+ "Multiple tokens found. Use freezeTokens({ tokenIdentifier, sparkAddress }) instead.",
817
+ {
818
+ field: "tokenIdentifier",
819
+ availableTokens: tokenIdentifiers
820
+ }
821
+ );
822
+ }
823
+ bech32mTokenIdentifier = tokenIdentifiers[0];
824
+ }
585
825
  const rawTokenIdentifier = decodeBech32mTokenIdentifier(
586
- issuerTokenIdentifier,
826
+ bech32mTokenIdentifier,
587
827
  this.config.getNetworkType()
588
828
  ).tokenIdentifier;
589
829
  const response = await this.tokenFreezeService.freezeTokens({
@@ -596,20 +836,35 @@ var IssuerSparkWallet = class extends SparkWallet {
596
836
  impactedTokenAmount: tokenAmount
597
837
  };
598
838
  }
599
- /**
600
- * Unfreezes previously frozen tokens associated with a specific Spark address.
601
- * @param sparkAddress - The Spark address whose tokens should be unfrozen
602
- * @returns An object containing the IDs of impacted outputs and the total amount of unfrozen tokens
603
- */
604
- async unfreezeTokens(sparkAddress) {
605
- await this.syncTokenOutputs();
839
+ async unfreezeTokens(sparkAddressOrParams) {
840
+ let bech32mTokenIdentifier;
841
+ let sparkAddress;
842
+ if (typeof sparkAddressOrParams === "string") {
843
+ sparkAddress = sparkAddressOrParams;
844
+ bech32mTokenIdentifier = void 0;
845
+ } else {
846
+ sparkAddress = sparkAddressOrParams.sparkAddress;
847
+ bech32mTokenIdentifier = sparkAddressOrParams.tokenIdentifier;
848
+ }
849
+ if (bech32mTokenIdentifier === void 0) {
850
+ const tokenIdentifiers = await this.getIssuerTokenIdentifiers();
851
+ if (tokenIdentifiers.length > 1) {
852
+ throw new SparkValidationError3(
853
+ "Multiple tokens found. Use unfreezeTokens({ tokenIdentifier, sparkAddress }) instead.",
854
+ {
855
+ field: "tokenIdentifier",
856
+ availableTokens: tokenIdentifiers
857
+ }
858
+ );
859
+ }
860
+ bech32mTokenIdentifier = tokenIdentifiers[0];
861
+ }
606
862
  const decodedOwnerPubkey = decodeSparkAddress(
607
863
  sparkAddress,
608
864
  this.config.getNetworkType()
609
865
  );
610
- const issuerTokenIdentifier = await this.getIssuerTokenIdentifier();
611
866
  const rawTokenIdentifier = decodeBech32mTokenIdentifier(
612
- issuerTokenIdentifier,
867
+ bech32mTokenIdentifier,
613
868
  this.config.getNetworkType()
614
869
  ).tokenIdentifier;
615
870
  const response = await this.tokenFreezeService.unfreezeTokens({
@@ -655,8 +910,11 @@ var IssuerSparkWallet = class extends SparkWallet {
655
910
  };
656
911
  var PUBLIC_ISSUER_SPARK_WALLET_METHODS = [
657
912
  "getIssuerTokenBalance",
913
+ "getIssuerTokenBalances",
658
914
  "getIssuerTokenMetadata",
915
+ "getIssuerTokensMetadata",
659
916
  "getIssuerTokenIdentifier",
917
+ "getIssuerTokenIdentifiers",
660
918
  "createToken",
661
919
  "mintTokens",
662
920
  "burnTokens",