@buildonspark/issuer-sdk 0.1.2 → 0.1.4

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.
@@ -23,10 +23,10 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
23
23
  // src/index.react-native.ts
24
24
  var index_react_native_exports = {};
25
25
  __export(index_react_native_exports, {
26
- DefaultSparkSigner: () => import_spark_sdk6.DefaultSparkSigner,
26
+ DefaultSparkSigner: () => import_spark_sdk7.DefaultSparkSigner,
27
27
  IssuerSparkWallet: () => IssuerSparkWalletReactNative,
28
- UnsafeStatelessSparkSigner: () => import_spark_sdk6.UnsafeStatelessSparkSigner,
29
- WalletConfig: () => import_spark_sdk7.WalletConfig
28
+ UnsafeStatelessSparkSigner: () => import_spark_sdk7.UnsafeStatelessSparkSigner,
29
+ WalletConfig: () => import_spark_sdk8.WalletConfig
30
30
  });
31
31
  module.exports = __toCommonJS(index_react_native_exports);
32
32
 
@@ -278,6 +278,9 @@ var IssuerTokenTransactionService = class extends import_spark_sdk3.TokenTransac
278
278
  }
279
279
  };
280
280
 
281
+ // src/issuer-wallet/issuer-spark-wallet.ts
282
+ var import_spark_sdk6 = require("@buildonspark/spark-sdk");
283
+
281
284
  // src/utils/create-validation.ts
282
285
  var import_spark_sdk4 = require("@buildonspark/spark-sdk");
283
286
  function isNfcNormalized(value) {
@@ -385,49 +388,70 @@ var IssuerSparkWallet = class extends import_spark_sdk5.SparkWallet {
385
388
  }
386
389
  /**
387
390
  * Gets the token balance for the issuer's token.
391
+ * @deprecated Use getIssuerTokenBalances() instead. This method will be removed in a future version.
388
392
  * @returns An object containing the token balance as a bigint
393
+ *
394
+ * @throws {SparkValidationError} If multiple tokens are found for this issuer
389
395
  */
390
396
  async getIssuerTokenBalance() {
391
397
  const publicKey = await super.getIdentityPublicKey();
392
398
  const balanceObj = await this.getBalance();
393
- const issuerBalance = [...balanceObj.tokenBalances.entries()].find(
399
+ const issuerBalance = [...balanceObj.tokenBalances.entries()].filter(
394
400
  ([, info]) => info.tokenMetadata.tokenPublicKey === publicKey
395
401
  );
396
- if (!balanceObj.tokenBalances || issuerBalance === void 0) {
402
+ if (issuerBalance.length > 1) {
403
+ throw new import_spark_sdk5.SparkValidationError(
404
+ "Multiple tokens found for this issuer. Use getIssuerTokenBalances() instead.",
405
+ {
406
+ field: "issuerTokenBalance",
407
+ expected: "single token",
408
+ actual: `${issuerBalance.length} tokens`
409
+ }
410
+ );
411
+ }
412
+ if (issuerBalance.length === 0) {
397
413
  return {
398
414
  tokenIdentifier: void 0,
399
415
  balance: 0n
400
416
  };
401
417
  }
402
418
  return {
403
- tokenIdentifier: issuerBalance[0] ?? void 0,
404
- balance: issuerBalance[1].balance
419
+ tokenIdentifier: issuerBalance[0][0],
420
+ balance: issuerBalance[0][1].balance
405
421
  };
406
422
  }
423
+ /**
424
+ * Gets the token balances for the tokens that were issued by this user.
425
+ * @returns An array of objects containing the token identifier and balance
426
+ */
427
+ async getIssuerTokenBalances() {
428
+ const publicKey = await super.getIdentityPublicKey();
429
+ const balanceObj = await this.getBalance();
430
+ const issuerBalance = [...balanceObj.tokenBalances.entries()].filter(
431
+ ([, info]) => info.tokenMetadata.tokenPublicKey === publicKey
432
+ );
433
+ if (issuerBalance.length === 0) {
434
+ return [
435
+ {
436
+ tokenIdentifier: void 0,
437
+ balance: 0n
438
+ }
439
+ ];
440
+ }
441
+ return issuerBalance.map(([tokenIdentifier, { balance }]) => ({
442
+ tokenIdentifier,
443
+ balance
444
+ }));
445
+ }
407
446
  /**
408
447
  * Retrieves information about the issuer's token.
409
- * @returns An object containing token information including public key, name, symbol, decimals, max supply, and freeze status
448
+ * @deprecated Use getIssuerTokensMetadata() instead. This method will be removed in a future version.
449
+ * @returns An object containing token information including public key, name, symbol, decimals, max supply, freeze status, and extra metadata
410
450
  * @throws {SparkRequestError} If the token metadata cannot be retrieved
451
+ * @throws {SparkValidationError} If multiple tokens are found for this issuer
411
452
  */
412
453
  async getIssuerTokenMetadata() {
413
454
  const issuerPublicKey = await super.getIdentityPublicKey();
414
- const tokenMetadata = this.tokenMetadata;
415
- const cachedIssuerTokenMetadata = [...tokenMetadata.entries()].find(
416
- ([, metadata]) => (0, import_utils4.bytesToHex)(metadata.issuerPublicKey) === issuerPublicKey
417
- );
418
- if (cachedIssuerTokenMetadata !== void 0) {
419
- const metadata = cachedIssuerTokenMetadata[1];
420
- return {
421
- tokenPublicKey: (0, import_utils4.bytesToHex)(metadata.issuerPublicKey),
422
- rawTokenIdentifier: metadata.tokenIdentifier,
423
- tokenName: metadata.tokenName,
424
- tokenTicker: metadata.tokenTicker,
425
- decimals: metadata.decimals,
426
- maxSupply: (0, import_utils4.bytesToNumberBE)(metadata.maxSupply),
427
- isFreezable: metadata.isFreezable,
428
- extraMetadata: metadata.extraMetadata ? new Uint8Array(metadata.extraMetadata) : void 0
429
- };
430
- }
431
455
  const sparkTokenClient = await this.connectionManager.createSparkTokenClient(
432
456
  this.config.getCoordinatorAddress()
433
457
  );
@@ -447,12 +471,21 @@ var IssuerSparkWallet = class extends import_spark_sdk5.SparkWallet {
447
471
  }
448
472
  );
449
473
  }
474
+ if (response.tokenMetadata.length > 1) {
475
+ throw new import_spark_sdk5.SparkValidationError(
476
+ "Multiple tokens found for this issuer. Please migrate to getIssuerTokensMetadata() instead.",
477
+ {
478
+ field: "tokenMetadata",
479
+ value: response.tokenMetadata
480
+ }
481
+ );
482
+ }
450
483
  const metadata = response.tokenMetadata[0];
451
- const tokenIdentifier = (0, import_spark_sdk5.encodeBech32mTokenIdentifier)({
484
+ const bech32mTokenIdentifier = (0, import_spark_sdk5.encodeBech32mTokenIdentifier)({
452
485
  tokenIdentifier: metadata.tokenIdentifier,
453
486
  network: this.config.getNetworkType()
454
487
  });
455
- this.tokenMetadata.set(tokenIdentifier, metadata);
488
+ this.tokenMetadata.set(bech32mTokenIdentifier, metadata);
456
489
  return {
457
490
  tokenPublicKey: (0, import_utils4.bytesToHex)(metadata.issuerPublicKey),
458
491
  rawTokenIdentifier: metadata.tokenIdentifier,
@@ -461,47 +494,110 @@ var IssuerSparkWallet = class extends import_spark_sdk5.SparkWallet {
461
494
  decimals: metadata.decimals,
462
495
  maxSupply: (0, import_utils4.bytesToNumberBE)(metadata.maxSupply),
463
496
  isFreezable: metadata.isFreezable,
464
- extraMetadata: metadata.extraMetadata
497
+ extraMetadata: metadata.extraMetadata ? new Uint8Array(metadata.extraMetadata) : void 0,
498
+ bech32mTokenIdentifier
465
499
  };
466
500
  } catch (error) {
467
501
  throw new import_spark_sdk5.SparkRequestError("Failed to fetch token metadata", { error });
468
502
  }
469
503
  }
504
+ /**
505
+ * Retrieves information about the tokens that were issued by this user.
506
+ * @returns An array of objects containing token information including public key, name, symbol, decimals, max supply, freeze status, and extra metadata
507
+ * @throws {SparkRequestError} If the token metadata cannot be retrieved
508
+ */
509
+ async getIssuerTokensMetadata() {
510
+ const issuerPublicKey = await super.getIdentityPublicKey();
511
+ const sparkTokenClient = await this.connectionManager.createSparkTokenClient(
512
+ this.config.getCoordinatorAddress()
513
+ );
514
+ try {
515
+ const response = await sparkTokenClient.query_token_metadata({
516
+ issuerPublicKeys: Array.of((0, import_utils4.hexToBytes)(issuerPublicKey))
517
+ });
518
+ if (response.tokenMetadata.length === 0) {
519
+ throw new import_spark_sdk5.SparkValidationError(
520
+ "Token metadata not found - If a token has not yet been created, please create it first. Try again in a few seconds.",
521
+ {
522
+ field: "tokenMetadata",
523
+ value: response.tokenMetadata,
524
+ expected: "non-empty array",
525
+ actualLength: response.tokenMetadata.length,
526
+ expectedLength: 1
527
+ }
528
+ );
529
+ }
530
+ const tokenMetadata = [];
531
+ for (const metadata of response.tokenMetadata) {
532
+ const bech32mTokenIdentifier = (0, import_spark_sdk5.encodeBech32mTokenIdentifier)({
533
+ tokenIdentifier: metadata.tokenIdentifier,
534
+ network: this.config.getNetworkType()
535
+ });
536
+ this.tokenMetadata.set(bech32mTokenIdentifier, metadata);
537
+ tokenMetadata.push({
538
+ tokenPublicKey: (0, import_utils4.bytesToHex)(metadata.issuerPublicKey),
539
+ rawTokenIdentifier: metadata.tokenIdentifier,
540
+ tokenName: metadata.tokenName,
541
+ tokenTicker: metadata.tokenTicker,
542
+ decimals: metadata.decimals,
543
+ maxSupply: (0, import_utils4.bytesToNumberBE)(metadata.maxSupply),
544
+ isFreezable: metadata.isFreezable,
545
+ extraMetadata: metadata.extraMetadata ? new Uint8Array(metadata.extraMetadata) : void 0,
546
+ bech32mTokenIdentifier
547
+ });
548
+ }
549
+ return tokenMetadata;
550
+ } catch (error) {
551
+ throw new import_spark_sdk5.SparkRequestError("Failed to fetch token metadata", { error });
552
+ }
553
+ }
470
554
  /**
471
555
  * Retrieves the bech32m encoded token identifier for the issuer's token.
556
+ * @deprecated Use getIssuerTokenIdentifiers() instead. This method will be removed in a future version.
472
557
  * @returns The bech32m encoded token identifier for the issuer's token
473
558
  * @throws {SparkRequestError} If the token identifier cannot be retrieved
559
+ * @throws {SparkValidationError} If multiple tokens are found for this issuer
474
560
  */
475
561
  async getIssuerTokenIdentifier() {
476
- const tokenMetadata = await this.getIssuerTokenMetadata();
477
- return (0, import_spark_sdk5.encodeBech32mTokenIdentifier)({
478
- tokenIdentifier: tokenMetadata.rawTokenIdentifier,
479
- network: this.config.getNetworkType()
480
- });
562
+ const tokensMetadata = await this.getIssuerTokensMetadata();
563
+ if (tokensMetadata.length > 1) {
564
+ throw new import_spark_sdk5.SparkValidationError(
565
+ "Multiple tokens found. Use getIssuerTokenIdentifiers() instead.",
566
+ {
567
+ method: "getIssuerTokenIdentifier",
568
+ availableTokens: tokensMetadata.map((t) => ({
569
+ tokenName: t.tokenName,
570
+ tokenTicker: t.tokenTicker,
571
+ bech32mTokenIdentifier: (0, import_spark_sdk5.encodeBech32mTokenIdentifier)({
572
+ tokenIdentifier: t.rawTokenIdentifier,
573
+ network: this.config.getNetworkType()
574
+ })
575
+ }))
576
+ }
577
+ );
578
+ }
579
+ if (tokensMetadata.length === 0) {
580
+ throw new import_spark_sdk5.SparkValidationError("No tokens found. Create a token first.");
581
+ }
582
+ return tokensMetadata[0].bech32mTokenIdentifier;
481
583
  }
482
584
  /**
483
- * Create a new token on Spark.
484
- *
485
- * @param params - Object containing token creation parameters.
486
- * @param params.tokenName - The name of the token.
487
- * @param params.tokenTicker - The ticker symbol for the token.
488
- * @param params.decimals - The number of decimal places for the token.
489
- * @param params.isFreezable - Whether the token can be frozen.
490
- * @param [params.maxSupply=0n] - (Optional) The maximum supply of the token. Defaults to <code>0n</code>.
491
- * @param params.extraMetadata - (Optional) This can be used to store additional bytes data to be associated with a token, like image data.
492
- *
493
- * @returns The transaction ID of the announcement.
494
- *
495
- * @throws {SparkValidationError} If `decimals` is not a safe integer or other validation fails.
496
- * @throws {SparkRequestError} If the announcement transaction cannot be broadcast.
585
+ * Retrieves the bech32m encoded token identifier for the issuer's token.
586
+ * @returns The bech32m encoded token identifier for the issuer's token
587
+ * @throws {SparkRequestError} If the token identifier cannot be retrieved
497
588
  */
589
+ async getIssuerTokenIdentifiers() {
590
+ const tokensMetadata = await this.getIssuerTokensMetadata();
591
+ return tokensMetadata.map((metadata) => metadata.bech32mTokenIdentifier);
592
+ }
498
593
  async createToken({
499
594
  tokenName,
500
595
  tokenTicker,
501
596
  decimals,
502
597
  isFreezable,
503
598
  maxSupply = 0n,
504
- extraMetadata
599
+ extraMetadata,
600
+ returnIdentifierForCreate = false
505
601
  }) {
506
602
  validateTokenParameters(
507
603
  tokenName,
@@ -521,9 +617,30 @@ var IssuerSparkWallet = class extends import_spark_sdk5.SparkWallet {
521
617
  isFreezable,
522
618
  extraMetadata
523
619
  );
524
- return await this.issuerTokenTransactionService.broadcastTokenTransaction(
620
+ const { finalTokenTransactionHash, tokenIdentifier } = await this.issuerTokenTransactionService.broadcastTokenTransactionDetailed(
525
621
  tokenTransaction
526
622
  );
623
+ const txHash = (0, import_utils4.bytesToHex)(finalTokenTransactionHash);
624
+ if (returnIdentifierForCreate) {
625
+ if (!tokenIdentifier) {
626
+ throw new import_spark_sdk5.SparkRequestError(
627
+ "Server response missing expected field: tokenIdentifier",
628
+ {
629
+ operation: "broadcast_transaction",
630
+ field: "tokenIdentifier"
631
+ }
632
+ );
633
+ }
634
+ const bech32mTokenIdentifier = (0, import_spark_sdk5.encodeBech32mTokenIdentifier)({
635
+ tokenIdentifier,
636
+ network: this.config.getNetworkType()
637
+ });
638
+ return {
639
+ tokenIdentifier: bech32mTokenIdentifier,
640
+ transactionHash: txHash
641
+ };
642
+ }
643
+ return txHash;
527
644
  } else {
528
645
  const partialTokenTransaction = await this.issuerTokenTransactionService.constructPartialCreateTokenTransaction(
529
646
  (0, import_utils4.hexToBytes)(issuerPublicKey),
@@ -534,21 +651,75 @@ var IssuerSparkWallet = class extends import_spark_sdk5.SparkWallet {
534
651
  isFreezable,
535
652
  extraMetadata
536
653
  );
537
- return await this.issuerTokenTransactionService.broadcastTokenTransactionV3(
654
+ const broadcastResponse = await this.issuerTokenTransactionService.broadcastTokenTransactionV3Detailed(
538
655
  partialTokenTransaction
539
656
  );
657
+ const finalHash = await (0, import_spark_sdk6.hashFinalTokenTransaction)(
658
+ broadcastResponse.finalTokenTransaction
659
+ );
660
+ const finalTransactionHash = (0, import_utils4.bytesToHex)(finalHash);
661
+ if (returnIdentifierForCreate) {
662
+ if (!broadcastResponse.tokenIdentifier) {
663
+ throw new import_spark_sdk5.SparkRequestError(
664
+ "Server response missing expected field: tokenIdentifier",
665
+ {
666
+ operation: "broadcast_transaction",
667
+ field: "tokenIdentifier"
668
+ }
669
+ );
670
+ }
671
+ const tokenIdentifier = (0, import_spark_sdk5.encodeBech32mTokenIdentifier)({
672
+ tokenIdentifier: broadcastResponse.tokenIdentifier,
673
+ network: this.config.getNetworkType()
674
+ });
675
+ return {
676
+ tokenIdentifier,
677
+ transactionHash: finalTransactionHash
678
+ };
679
+ }
680
+ return finalTransactionHash;
540
681
  }
541
682
  }
542
- /**
543
- * Mints new tokens
544
- * @param tokenAmount - The amount of tokens to mint
545
- * @returns The transaction ID of the mint operation
546
- */
547
- async mintTokens(tokenAmount) {
683
+ async mintTokens(tokenAmountOrParams) {
684
+ let tokenAmount;
685
+ let bech32mTokenIdentifier;
686
+ if (typeof tokenAmountOrParams === "bigint") {
687
+ tokenAmount = tokenAmountOrParams;
688
+ bech32mTokenIdentifier = void 0;
689
+ } else {
690
+ tokenAmount = tokenAmountOrParams.tokenAmount;
691
+ bech32mTokenIdentifier = tokenAmountOrParams.tokenIdentifier;
692
+ }
548
693
  const issuerTokenPublicKey = await super.getIdentityPublicKey();
549
694
  const issuerTokenPublicKeyBytes = (0, import_utils4.hexToBytes)(issuerTokenPublicKey);
550
- const tokenMetadata = await this.getIssuerTokenMetadata();
551
- const rawTokenIdentifier = tokenMetadata.rawTokenIdentifier;
695
+ const tokensMetadata = await this.getIssuerTokensMetadata();
696
+ if (bech32mTokenIdentifier === void 0) {
697
+ if (tokensMetadata.length > 1) {
698
+ throw new import_spark_sdk5.SparkValidationError(
699
+ "Multiple tokens found. Please use mintTokens({ tokenAmount, tokenIdentifier }) instead.",
700
+ {
701
+ field: "tokenIdentifier",
702
+ availableTokens: tokensMetadata.map((t) => ({
703
+ tokenName: t.tokenName,
704
+ tokenTicker: t.tokenTicker,
705
+ bech32mTokenIdentifier: (0, import_spark_sdk5.encodeBech32mTokenIdentifier)({
706
+ tokenIdentifier: t.rawTokenIdentifier,
707
+ network: this.config.getNetworkType()
708
+ })
709
+ }))
710
+ }
711
+ );
712
+ }
713
+ const encodedTokenIdentifier = (0, import_spark_sdk5.encodeBech32mTokenIdentifier)({
714
+ tokenIdentifier: tokensMetadata[0].rawTokenIdentifier,
715
+ network: this.config.getNetworkType()
716
+ });
717
+ bech32mTokenIdentifier = encodedTokenIdentifier;
718
+ }
719
+ const rawTokenIdentifier = (0, import_spark_sdk5.decodeBech32mTokenIdentifier)(
720
+ bech32mTokenIdentifier,
721
+ this.config.getNetworkType()
722
+ ).tokenIdentifier;
552
723
  if (this.config.getTokenTransactionVersion() === "V2") {
553
724
  const tokenTransaction = await this.issuerTokenTransactionService.constructMintTokenTransaction(
554
725
  rawTokenIdentifier,
@@ -569,39 +740,108 @@ var IssuerSparkWallet = class extends import_spark_sdk5.SparkWallet {
569
740
  );
570
741
  }
571
742
  }
572
- /**
573
- * Burns issuer's tokens
574
- * @param tokenAmount - The amount of tokens to burn
575
- * @param selectedOutputs - Optional array of outputs to use for the burn operation
576
- * @returns The transaction ID of the burn operation
577
- */
578
- async burnTokens(tokenAmount, selectedOutputs) {
743
+ async burnTokens(tokenAmountOrParams, selectedOutputs) {
744
+ let bech32mTokenIdentifier;
745
+ let tokenAmount;
746
+ let outputs;
747
+ if (typeof tokenAmountOrParams === "bigint") {
748
+ tokenAmount = tokenAmountOrParams;
749
+ outputs = selectedOutputs;
750
+ const tokenIdentifiers = await this.getIssuerTokenIdentifiers();
751
+ if (tokenIdentifiers.length > 1) {
752
+ throw new import_spark_sdk5.SparkValidationError(
753
+ "Multiple tokens found. Use burnTokens({ tokenIdentifier, tokenAmount, selectedOutputs }) to specify which token to burn.",
754
+ {
755
+ field: "tokenIdentifier",
756
+ availableTokens: tokenIdentifiers
757
+ }
758
+ );
759
+ }
760
+ if (tokenIdentifiers.length === 0) {
761
+ throw new import_spark_sdk5.SparkValidationError(
762
+ "No tokens found. Create a token first."
763
+ );
764
+ }
765
+ bech32mTokenIdentifier = tokenIdentifiers[0];
766
+ } else {
767
+ tokenAmount = tokenAmountOrParams.tokenAmount;
768
+ outputs = tokenAmountOrParams.selectedOutputs;
769
+ if (tokenAmountOrParams.tokenIdentifier) {
770
+ const tokenIdentifiers = await this.getIssuerTokenIdentifiers();
771
+ const tokenIdentifier = tokenIdentifiers.find(
772
+ (identifier) => identifier === tokenAmountOrParams.tokenIdentifier
773
+ );
774
+ if (!tokenIdentifier) {
775
+ throw new import_spark_sdk5.SparkValidationError("Token not found for this issuer", {
776
+ field: "tokenIdentifier",
777
+ value: tokenAmountOrParams.tokenIdentifier
778
+ });
779
+ }
780
+ bech32mTokenIdentifier = tokenAmountOrParams.tokenIdentifier;
781
+ } else {
782
+ const tokenIdentifiers = await this.getIssuerTokenIdentifiers();
783
+ if (tokenIdentifiers.length === 0) {
784
+ throw new import_spark_sdk5.SparkValidationError(
785
+ "No tokens found. Create a token first."
786
+ );
787
+ }
788
+ if (tokenIdentifiers.length > 1) {
789
+ throw new import_spark_sdk5.SparkValidationError(
790
+ "Multiple tokens found. Please specify tokenIdentifier in parameters.",
791
+ {
792
+ field: "tokenIdentifier",
793
+ availableTokens: tokenIdentifiers
794
+ }
795
+ );
796
+ }
797
+ bech32mTokenIdentifier = tokenIdentifiers[0];
798
+ }
799
+ }
579
800
  const burnAddress = (0, import_spark_sdk5.encodeSparkAddress)({
580
801
  identityPublicKey: BURN_ADDRESS,
581
802
  network: this.config.getNetworkType()
582
803
  });
583
- const issuerTokenIdentifier = await this.getIssuerTokenIdentifier();
584
804
  return await this.transferTokens({
585
- tokenIdentifier: issuerTokenIdentifier,
805
+ tokenIdentifier: bech32mTokenIdentifier,
586
806
  tokenAmount,
587
807
  receiverSparkAddress: burnAddress,
588
- selectedOutputs
808
+ selectedOutputs: outputs
589
809
  });
590
810
  }
591
- /**
592
- * Freezes tokens associated with a specific Spark address.
593
- * @param sparkAddress - The Spark address whose tokens should be frozen
594
- * @returns An object containing the IDs of impacted outputs and the total amount of frozen tokens
595
- */
596
- async freezeTokens(sparkAddress) {
597
- await this.syncTokenOutputs();
811
+ async freezeTokens(sparkAddressOrParams) {
812
+ let bech32mTokenIdentifier;
813
+ let sparkAddress;
814
+ if (typeof sparkAddressOrParams === "string") {
815
+ sparkAddress = sparkAddressOrParams;
816
+ bech32mTokenIdentifier = void 0;
817
+ } else {
818
+ sparkAddress = sparkAddressOrParams.sparkAddress;
819
+ bech32mTokenIdentifier = sparkAddressOrParams.tokenIdentifier;
820
+ }
598
821
  const decodedOwnerPubkey = (0, import_spark_sdk5.decodeSparkAddress)(
599
822
  sparkAddress,
600
823
  this.config.getNetworkType()
601
824
  );
602
- const issuerTokenIdentifier = await this.getIssuerTokenIdentifier();
825
+ if (bech32mTokenIdentifier === void 0) {
826
+ const tokenIdentifiers = await this.getIssuerTokenIdentifiers();
827
+ if (tokenIdentifiers.length === 0) {
828
+ throw new import_spark_sdk5.SparkValidationError(
829
+ "No tokens found. Create a token first."
830
+ );
831
+ }
832
+ if (tokenIdentifiers.length > 1) {
833
+ throw new import_spark_sdk5.SparkValidationError(
834
+ "Multiple tokens found. Use freezeTokens({ tokenIdentifier, sparkAddress }) instead.",
835
+ {
836
+ field: "tokenIdentifier",
837
+ availableTokens: tokenIdentifiers
838
+ }
839
+ );
840
+ }
841
+ bech32mTokenIdentifier = tokenIdentifiers[0];
842
+ }
603
843
  const rawTokenIdentifier = (0, import_spark_sdk5.decodeBech32mTokenIdentifier)(
604
- issuerTokenIdentifier,
844
+ bech32mTokenIdentifier,
605
845
  this.config.getNetworkType()
606
846
  ).tokenIdentifier;
607
847
  const response = await this.tokenFreezeService.freezeTokens({
@@ -614,20 +854,35 @@ var IssuerSparkWallet = class extends import_spark_sdk5.SparkWallet {
614
854
  impactedTokenAmount: tokenAmount
615
855
  };
616
856
  }
617
- /**
618
- * Unfreezes previously frozen tokens associated with a specific Spark address.
619
- * @param sparkAddress - The Spark address whose tokens should be unfrozen
620
- * @returns An object containing the IDs of impacted outputs and the total amount of unfrozen tokens
621
- */
622
- async unfreezeTokens(sparkAddress) {
623
- await this.syncTokenOutputs();
857
+ async unfreezeTokens(sparkAddressOrParams) {
858
+ let bech32mTokenIdentifier;
859
+ let sparkAddress;
860
+ if (typeof sparkAddressOrParams === "string") {
861
+ sparkAddress = sparkAddressOrParams;
862
+ bech32mTokenIdentifier = void 0;
863
+ } else {
864
+ sparkAddress = sparkAddressOrParams.sparkAddress;
865
+ bech32mTokenIdentifier = sparkAddressOrParams.tokenIdentifier;
866
+ }
867
+ if (bech32mTokenIdentifier === void 0) {
868
+ const tokenIdentifiers = await this.getIssuerTokenIdentifiers();
869
+ if (tokenIdentifiers.length > 1) {
870
+ throw new import_spark_sdk5.SparkValidationError(
871
+ "Multiple tokens found. Use unfreezeTokens({ tokenIdentifier, sparkAddress }) instead.",
872
+ {
873
+ field: "tokenIdentifier",
874
+ availableTokens: tokenIdentifiers
875
+ }
876
+ );
877
+ }
878
+ bech32mTokenIdentifier = tokenIdentifiers[0];
879
+ }
624
880
  const decodedOwnerPubkey = (0, import_spark_sdk5.decodeSparkAddress)(
625
881
  sparkAddress,
626
882
  this.config.getNetworkType()
627
883
  );
628
- const issuerTokenIdentifier = await this.getIssuerTokenIdentifier();
629
884
  const rawTokenIdentifier = (0, import_spark_sdk5.decodeBech32mTokenIdentifier)(
630
- issuerTokenIdentifier,
885
+ bech32mTokenIdentifier,
631
886
  this.config.getNetworkType()
632
887
  ).tokenIdentifier;
633
888
  const response = await this.tokenFreezeService.unfreezeTokens({
@@ -673,8 +928,11 @@ var IssuerSparkWallet = class extends import_spark_sdk5.SparkWallet {
673
928
  };
674
929
  var PUBLIC_ISSUER_SPARK_WALLET_METHODS = [
675
930
  "getIssuerTokenBalance",
931
+ "getIssuerTokenBalances",
676
932
  "getIssuerTokenMetadata",
933
+ "getIssuerTokensMetadata",
677
934
  "getIssuerTokenIdentifier",
935
+ "getIssuerTokenIdentifiers",
678
936
  "createToken",
679
937
  "mintTokens",
680
938
  "burnTokens",
@@ -688,8 +946,8 @@ var IssuerSparkWalletReactNative = class extends IssuerSparkWallet {
688
946
  };
689
947
 
690
948
  // src/index-shared.ts
691
- var import_spark_sdk6 = require("@buildonspark/spark-sdk");
692
949
  var import_spark_sdk7 = require("@buildonspark/spark-sdk");
950
+ var import_spark_sdk8 = require("@buildonspark/spark-sdk");
693
951
  // Annotate the CommonJS export names for ESM import in node:
694
952
  0 && (module.exports = {
695
953
  DefaultSparkSigner,