@buildonspark/issuer-sdk 0.0.85 → 0.0.87

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,25 @@
1
1
  # @buildonspark/issuer-sdk
2
2
 
3
+ ## 0.0.87
4
+
5
+ ### Patch Changes
6
+
7
+ - -- Added spark invoice support for token transfers
8
+ -- Added support for initialization SparkWallet with pre-existing keys
9
+ -- Return bare info in x-client-env
10
+ -- Improved test coverage for multiple coordinators
11
+ -- Improved retry mechanism for transfer claim
12
+ -- Improved error handling for alreaday exists
13
+ - Updated dependencies
14
+ - @buildonspark/spark-sdk@0.2.8
15
+
16
+ ## 0.0.86
17
+
18
+ ### Patch Changes
19
+
20
+ - Updated dependencies
21
+ - @buildonspark/spark-sdk@0.2.7
22
+
3
23
  ## 0.0.85
4
24
 
5
25
  ### Patch Changes
@@ -3,7 +3,6 @@ import {
3
3
  } from "./chunk-7B4B24XF.js";
4
4
 
5
5
  // src/issuer-wallet/issuer-spark-wallet.ts
6
- import { TokenPubkey, TokenPubkeyAnnouncement } from "@buildonspark/lrc20-sdk";
7
6
  import {
8
7
  NetworkError as NetworkError2,
9
8
  SparkWallet,
@@ -178,7 +177,7 @@ var IssuerTokenTransactionService = class extends TokenTransactionService {
178
177
  }
179
178
  async constructMintTokenTransaction(rawTokenIdentifierBytes, issuerTokenPublicKey, tokenAmount) {
180
179
  return {
181
- version: 1,
180
+ version: 2,
182
181
  network: this.config.getNetworkProto(),
183
182
  tokenInputs: {
184
183
  $case: "mintInput",
@@ -196,12 +195,13 @@ var IssuerTokenTransactionService = class extends TokenTransactionService {
196
195
  ],
197
196
  clientCreatedTimestamp: /* @__PURE__ */ new Date(),
198
197
  sparkOperatorIdentityPublicKeys: super.collectOperatorIdentityPublicKeys(),
199
- expiryTime: void 0
198
+ expiryTime: void 0,
199
+ invoiceAttachments: []
200
200
  };
201
201
  }
202
202
  async constructCreateTokenTransaction(tokenPublicKey, tokenName, tokenTicker, decimals, maxSupply, isFreezable) {
203
203
  return {
204
- version: 1,
204
+ version: 2,
205
205
  network: this.config.getNetworkProto(),
206
206
  tokenInputs: {
207
207
  $case: "createInput",
@@ -217,7 +217,8 @@ var IssuerTokenTransactionService = class extends TokenTransactionService {
217
217
  tokenOutputs: [],
218
218
  clientCreatedTimestamp: /* @__PURE__ */ new Date(),
219
219
  sparkOperatorIdentityPublicKeys: super.collectOperatorIdentityPublicKeys(),
220
- expiryTime: void 0
220
+ expiryTime: void 0,
221
+ invoiceAttachments: []
221
222
  };
222
223
  }
223
224
  };
@@ -316,6 +317,12 @@ var IssuerSparkWallet = class _IssuerSparkWallet extends SparkWallet {
316
317
  }) {
317
318
  const wallet = new _IssuerSparkWallet(options, signer);
318
319
  wallet.initializeTracer(wallet);
320
+ if (options && options.signerWithPreExistingKeys) {
321
+ await wallet.initWalletWithoutSeed();
322
+ return {
323
+ wallet
324
+ };
325
+ }
319
326
  const initResponse = await wallet.initWallet(mnemonicOrSeed, accountNumber);
320
327
  return {
321
328
  wallet,
@@ -387,7 +394,7 @@ var IssuerSparkWallet = class _IssuerSparkWallet extends SparkWallet {
387
394
  });
388
395
  if (response.tokenMetadata.length === 0) {
389
396
  throw new ValidationError3(
390
- "Token metadata not found - If a token has not yet been announced, please announce. If a token was recently announced, it is being confirmed. Try again in a few seconds.",
397
+ "Token metadata not found - If a token has not yet been created, please create it first. Try again in a few seconds.",
391
398
  {
392
399
  field: "tokenMetadata",
393
400
  value: response.tokenMetadata,
@@ -572,57 +579,6 @@ var IssuerSparkWallet = class _IssuerSparkWallet extends SparkWallet {
572
579
  async getIssuerTokenDistribution() {
573
580
  throw new NotImplementedError("Token distribution is not yet supported");
574
581
  }
575
- /**
576
- * Announces a new token on the L1 (Bitcoin) network.
577
- * @param tokenName - The name of the token
578
- * @param tokenTicker - The ticker symbol for the token
579
- * @param decimals - The number of decimal places for the token
580
- * @param maxSupply - The maximum supply of the token
581
- * @param isFreezable - Whether the token can be frozen
582
- * @param feeRateSatsPerVb - The fee rate in satoshis per virtual byte (default: 4.0)
583
- * @returns The transaction ID of the announcement
584
- * @throws {ValidationError} If decimals is not a safe integer
585
- * @throws {NetworkError} If the announcement transaction cannot be broadcast
586
- */
587
- async announceTokenL1(tokenName, tokenTicker, decimals, maxSupply, isFreezable, feeRateSatsPerVb = 4) {
588
- validateTokenParameters(tokenName, tokenTicker, decimals, maxSupply);
589
- if (!Number.isSafeInteger(decimals)) {
590
- throw new ValidationError3("Decimals must be less than 2^53", {
591
- field: "decimals",
592
- value: decimals,
593
- expected: "smaller or equal to " + Number.MAX_SAFE_INTEGER
594
- });
595
- }
596
- await this.lrc20Wallet.syncWallet();
597
- const tokenPublicKey = new TokenPubkey(this.lrc20Wallet.pubkey);
598
- const announcement = new TokenPubkeyAnnouncement(
599
- tokenPublicKey,
600
- tokenName,
601
- tokenTicker,
602
- decimals,
603
- maxSupply,
604
- isFreezable
605
- );
606
- try {
607
- const tx = await this.lrc20Wallet.prepareAnnouncement(
608
- announcement,
609
- feeRateSatsPerVb
610
- );
611
- const txId = await this.lrc20Wallet.broadcastRawBtcTransaction(
612
- tx.bitcoin_tx.toHex()
613
- );
614
- return txId;
615
- } catch (error) {
616
- throw new NetworkError2(
617
- "Failed to broadcast announcement transaction on L1",
618
- {
619
- operation: "broadcastRawBtcTransaction",
620
- errorCount: 1,
621
- errors: error instanceof Error ? error.message : String(error)
622
- }
623
- );
624
- }
625
- }
626
582
  getTraceName(methodName) {
627
583
  return `IssuerSparkWallet.${methodName}`;
628
584
  }
@@ -649,8 +605,7 @@ var IssuerSparkWallet = class _IssuerSparkWallet extends SparkWallet {
649
605
  "burnTokens",
650
606
  "freezeTokens",
651
607
  "unfreezeTokens",
652
- "getIssuerTokenDistribution",
653
- "announceTokenL1"
608
+ "getIssuerTokenDistribution"
654
609
  ];
655
610
  methods.forEach(
656
611
  (m) => this.wrapPublicIssuerSparkWalletMethodWithOtelSpan(m)
package/dist/index.cjs CHANGED
@@ -39,7 +39,6 @@ if (typeof window !== "undefined") {
39
39
  }
40
40
 
41
41
  // src/issuer-wallet/issuer-spark-wallet.ts
42
- var import_lrc20_sdk = require("@buildonspark/lrc20-sdk");
43
42
  var import_spark_sdk5 = require("@buildonspark/spark-sdk");
44
43
  var import_spark_sdk6 = require("@buildonspark/spark-sdk");
45
44
  var import_utils4 = require("@noble/curves/abstract/utils");
@@ -200,7 +199,7 @@ var IssuerTokenTransactionService = class extends import_spark_sdk3.TokenTransac
200
199
  }
201
200
  async constructMintTokenTransaction(rawTokenIdentifierBytes, issuerTokenPublicKey, tokenAmount) {
202
201
  return {
203
- version: 1,
202
+ version: 2,
204
203
  network: this.config.getNetworkProto(),
205
204
  tokenInputs: {
206
205
  $case: "mintInput",
@@ -218,12 +217,13 @@ var IssuerTokenTransactionService = class extends import_spark_sdk3.TokenTransac
218
217
  ],
219
218
  clientCreatedTimestamp: /* @__PURE__ */ new Date(),
220
219
  sparkOperatorIdentityPublicKeys: super.collectOperatorIdentityPublicKeys(),
221
- expiryTime: void 0
220
+ expiryTime: void 0,
221
+ invoiceAttachments: []
222
222
  };
223
223
  }
224
224
  async constructCreateTokenTransaction(tokenPublicKey, tokenName, tokenTicker, decimals, maxSupply, isFreezable) {
225
225
  return {
226
- version: 1,
226
+ version: 2,
227
227
  network: this.config.getNetworkProto(),
228
228
  tokenInputs: {
229
229
  $case: "createInput",
@@ -239,7 +239,8 @@ var IssuerTokenTransactionService = class extends import_spark_sdk3.TokenTransac
239
239
  tokenOutputs: [],
240
240
  clientCreatedTimestamp: /* @__PURE__ */ new Date(),
241
241
  sparkOperatorIdentityPublicKeys: super.collectOperatorIdentityPublicKeys(),
242
- expiryTime: void 0
242
+ expiryTime: void 0,
243
+ invoiceAttachments: []
243
244
  };
244
245
  }
245
246
  };
@@ -336,6 +337,12 @@ var IssuerSparkWallet = class _IssuerSparkWallet extends import_spark_sdk5.Spark
336
337
  }) {
337
338
  const wallet = new _IssuerSparkWallet(options, signer);
338
339
  wallet.initializeTracer(wallet);
340
+ if (options && options.signerWithPreExistingKeys) {
341
+ await wallet.initWalletWithoutSeed();
342
+ return {
343
+ wallet
344
+ };
345
+ }
339
346
  const initResponse = await wallet.initWallet(mnemonicOrSeed, accountNumber);
340
347
  return {
341
348
  wallet,
@@ -407,7 +414,7 @@ var IssuerSparkWallet = class _IssuerSparkWallet extends import_spark_sdk5.Spark
407
414
  });
408
415
  if (response.tokenMetadata.length === 0) {
409
416
  throw new import_spark_sdk5.ValidationError(
410
- "Token metadata not found - If a token has not yet been announced, please announce. If a token was recently announced, it is being confirmed. Try again in a few seconds.",
417
+ "Token metadata not found - If a token has not yet been created, please create it first. Try again in a few seconds.",
411
418
  {
412
419
  field: "tokenMetadata",
413
420
  value: response.tokenMetadata,
@@ -592,57 +599,6 @@ var IssuerSparkWallet = class _IssuerSparkWallet extends import_spark_sdk5.Spark
592
599
  async getIssuerTokenDistribution() {
593
600
  throw new import_spark_sdk8.NotImplementedError("Token distribution is not yet supported");
594
601
  }
595
- /**
596
- * Announces a new token on the L1 (Bitcoin) network.
597
- * @param tokenName - The name of the token
598
- * @param tokenTicker - The ticker symbol for the token
599
- * @param decimals - The number of decimal places for the token
600
- * @param maxSupply - The maximum supply of the token
601
- * @param isFreezable - Whether the token can be frozen
602
- * @param feeRateSatsPerVb - The fee rate in satoshis per virtual byte (default: 4.0)
603
- * @returns The transaction ID of the announcement
604
- * @throws {ValidationError} If decimals is not a safe integer
605
- * @throws {NetworkError} If the announcement transaction cannot be broadcast
606
- */
607
- async announceTokenL1(tokenName, tokenTicker, decimals, maxSupply, isFreezable, feeRateSatsPerVb = 4) {
608
- validateTokenParameters(tokenName, tokenTicker, decimals, maxSupply);
609
- if (!Number.isSafeInteger(decimals)) {
610
- throw new import_spark_sdk5.ValidationError("Decimals must be less than 2^53", {
611
- field: "decimals",
612
- value: decimals,
613
- expected: "smaller or equal to " + Number.MAX_SAFE_INTEGER
614
- });
615
- }
616
- await this.lrc20Wallet.syncWallet();
617
- const tokenPublicKey = new import_lrc20_sdk.TokenPubkey(this.lrc20Wallet.pubkey);
618
- const announcement = new import_lrc20_sdk.TokenPubkeyAnnouncement(
619
- tokenPublicKey,
620
- tokenName,
621
- tokenTicker,
622
- decimals,
623
- maxSupply,
624
- isFreezable
625
- );
626
- try {
627
- const tx = await this.lrc20Wallet.prepareAnnouncement(
628
- announcement,
629
- feeRateSatsPerVb
630
- );
631
- const txId = await this.lrc20Wallet.broadcastRawBtcTransaction(
632
- tx.bitcoin_tx.toHex()
633
- );
634
- return txId;
635
- } catch (error) {
636
- throw new import_spark_sdk5.NetworkError(
637
- "Failed to broadcast announcement transaction on L1",
638
- {
639
- operation: "broadcastRawBtcTransaction",
640
- errorCount: 1,
641
- errors: error instanceof Error ? error.message : String(error)
642
- }
643
- );
644
- }
645
- }
646
602
  getTraceName(methodName) {
647
603
  return `IssuerSparkWallet.${methodName}`;
648
604
  }
@@ -669,8 +625,7 @@ var IssuerSparkWallet = class _IssuerSparkWallet extends import_spark_sdk5.Spark
669
625
  "burnTokens",
670
626
  "freezeTokens",
671
627
  "unfreezeTokens",
672
- "getIssuerTokenDistribution",
673
- "announceTokenL1"
628
+ "getIssuerTokenDistribution"
674
629
  ];
675
630
  methods.forEach(
676
631
  (m) => this.wrapPublicIssuerSparkWalletMethodWithOtelSpan(m)
@@ -689,6 +644,12 @@ var IssuerSparkWalletBrowser = class _IssuerSparkWalletBrowser extends IssuerSpa
689
644
  }) {
690
645
  const wallet = new _IssuerSparkWalletBrowser(options, signer);
691
646
  wallet.initializeTracer(wallet);
647
+ if (options && options.signerWithPreExistingKeys) {
648
+ await wallet.initWalletWithoutSeed();
649
+ return {
650
+ wallet
651
+ };
652
+ }
692
653
  const initResponse = await wallet.initWallet(mnemonicOrSeed, accountNumber);
693
654
  return {
694
655
  wallet,
package/dist/index.d.cts CHANGED
@@ -1,5 +1,5 @@
1
- import { I as IssuerSparkWallet } from './issuer-spark-wallet-BFzkv4X5.cjs';
2
- export { a as IssuerTokenMetadata, T as TokenDistribution } from './issuer-spark-wallet-BFzkv4X5.cjs';
1
+ import { I as IssuerSparkWallet } from './issuer-spark-wallet-Bho-WrkK.cjs';
2
+ export { a as IssuerTokenMetadata, T as TokenDistribution } from './issuer-spark-wallet-Bho-WrkK.cjs';
3
3
  import { SparkWalletProps } from '@buildonspark/spark-sdk';
4
4
  import '@buildonspark/spark-sdk/proto/spark';
5
5
 
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { I as IssuerSparkWallet } from './issuer-spark-wallet-BFzkv4X5.js';
2
- export { a as IssuerTokenMetadata, T as TokenDistribution } from './issuer-spark-wallet-BFzkv4X5.js';
1
+ import { I as IssuerSparkWallet } from './issuer-spark-wallet-Bho-WrkK.js';
2
+ export { a as IssuerTokenMetadata, T as TokenDistribution } from './issuer-spark-wallet-Bho-WrkK.js';
3
3
  import { SparkWalletProps } from '@buildonspark/spark-sdk';
4
4
  import '@buildonspark/spark-sdk/proto/spark';
5
5
 
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  IssuerSparkWallet
3
- } from "./chunk-HOLMXKFE.js";
3
+ } from "./chunk-ZMLVOUPB.js";
4
4
  import "./chunk-7B4B24XF.js";
5
5
 
6
6
  // src/issuer-wallet/issuer-spark-wallet.browser.ts
@@ -16,6 +16,12 @@ var IssuerSparkWalletBrowser = class _IssuerSparkWalletBrowser extends IssuerSpa
16
16
  }) {
17
17
  const wallet = new _IssuerSparkWalletBrowser(options, signer);
18
18
  wallet.initializeTracer(wallet);
19
+ if (options && options.signerWithPreExistingKeys) {
20
+ await wallet.initWalletWithoutSeed();
21
+ return {
22
+ wallet
23
+ };
24
+ }
19
25
  const initResponse = await wallet.initWallet(mnemonicOrSeed, accountNumber);
20
26
  return {
21
27
  wallet,
@@ -39,7 +39,6 @@ if (typeof window !== "undefined") {
39
39
  }
40
40
 
41
41
  // src/issuer-wallet/issuer-spark-wallet.ts
42
- var import_lrc20_sdk = require("@buildonspark/lrc20-sdk");
43
42
  var import_spark_sdk5 = require("@buildonspark/spark-sdk");
44
43
  var import_spark_sdk6 = require("@buildonspark/spark-sdk");
45
44
  var import_utils4 = require("@noble/curves/abstract/utils");
@@ -200,7 +199,7 @@ var IssuerTokenTransactionService = class extends import_spark_sdk3.TokenTransac
200
199
  }
201
200
  async constructMintTokenTransaction(rawTokenIdentifierBytes, issuerTokenPublicKey, tokenAmount) {
202
201
  return {
203
- version: 1,
202
+ version: 2,
204
203
  network: this.config.getNetworkProto(),
205
204
  tokenInputs: {
206
205
  $case: "mintInput",
@@ -218,12 +217,13 @@ var IssuerTokenTransactionService = class extends import_spark_sdk3.TokenTransac
218
217
  ],
219
218
  clientCreatedTimestamp: /* @__PURE__ */ new Date(),
220
219
  sparkOperatorIdentityPublicKeys: super.collectOperatorIdentityPublicKeys(),
221
- expiryTime: void 0
220
+ expiryTime: void 0,
221
+ invoiceAttachments: []
222
222
  };
223
223
  }
224
224
  async constructCreateTokenTransaction(tokenPublicKey, tokenName, tokenTicker, decimals, maxSupply, isFreezable) {
225
225
  return {
226
- version: 1,
226
+ version: 2,
227
227
  network: this.config.getNetworkProto(),
228
228
  tokenInputs: {
229
229
  $case: "createInput",
@@ -239,7 +239,8 @@ var IssuerTokenTransactionService = class extends import_spark_sdk3.TokenTransac
239
239
  tokenOutputs: [],
240
240
  clientCreatedTimestamp: /* @__PURE__ */ new Date(),
241
241
  sparkOperatorIdentityPublicKeys: super.collectOperatorIdentityPublicKeys(),
242
- expiryTime: void 0
242
+ expiryTime: void 0,
243
+ invoiceAttachments: []
243
244
  };
244
245
  }
245
246
  };
@@ -336,6 +337,12 @@ var IssuerSparkWallet = class _IssuerSparkWallet extends import_spark_sdk5.Spark
336
337
  }) {
337
338
  const wallet = new _IssuerSparkWallet(options, signer);
338
339
  wallet.initializeTracer(wallet);
340
+ if (options && options.signerWithPreExistingKeys) {
341
+ await wallet.initWalletWithoutSeed();
342
+ return {
343
+ wallet
344
+ };
345
+ }
339
346
  const initResponse = await wallet.initWallet(mnemonicOrSeed, accountNumber);
340
347
  return {
341
348
  wallet,
@@ -407,7 +414,7 @@ var IssuerSparkWallet = class _IssuerSparkWallet extends import_spark_sdk5.Spark
407
414
  });
408
415
  if (response.tokenMetadata.length === 0) {
409
416
  throw new import_spark_sdk5.ValidationError(
410
- "Token metadata not found - If a token has not yet been announced, please announce. If a token was recently announced, it is being confirmed. Try again in a few seconds.",
417
+ "Token metadata not found - If a token has not yet been created, please create it first. Try again in a few seconds.",
411
418
  {
412
419
  field: "tokenMetadata",
413
420
  value: response.tokenMetadata,
@@ -592,57 +599,6 @@ var IssuerSparkWallet = class _IssuerSparkWallet extends import_spark_sdk5.Spark
592
599
  async getIssuerTokenDistribution() {
593
600
  throw new import_spark_sdk8.NotImplementedError("Token distribution is not yet supported");
594
601
  }
595
- /**
596
- * Announces a new token on the L1 (Bitcoin) network.
597
- * @param tokenName - The name of the token
598
- * @param tokenTicker - The ticker symbol for the token
599
- * @param decimals - The number of decimal places for the token
600
- * @param maxSupply - The maximum supply of the token
601
- * @param isFreezable - Whether the token can be frozen
602
- * @param feeRateSatsPerVb - The fee rate in satoshis per virtual byte (default: 4.0)
603
- * @returns The transaction ID of the announcement
604
- * @throws {ValidationError} If decimals is not a safe integer
605
- * @throws {NetworkError} If the announcement transaction cannot be broadcast
606
- */
607
- async announceTokenL1(tokenName, tokenTicker, decimals, maxSupply, isFreezable, feeRateSatsPerVb = 4) {
608
- validateTokenParameters(tokenName, tokenTicker, decimals, maxSupply);
609
- if (!Number.isSafeInteger(decimals)) {
610
- throw new import_spark_sdk5.ValidationError("Decimals must be less than 2^53", {
611
- field: "decimals",
612
- value: decimals,
613
- expected: "smaller or equal to " + Number.MAX_SAFE_INTEGER
614
- });
615
- }
616
- await this.lrc20Wallet.syncWallet();
617
- const tokenPublicKey = new import_lrc20_sdk.TokenPubkey(this.lrc20Wallet.pubkey);
618
- const announcement = new import_lrc20_sdk.TokenPubkeyAnnouncement(
619
- tokenPublicKey,
620
- tokenName,
621
- tokenTicker,
622
- decimals,
623
- maxSupply,
624
- isFreezable
625
- );
626
- try {
627
- const tx = await this.lrc20Wallet.prepareAnnouncement(
628
- announcement,
629
- feeRateSatsPerVb
630
- );
631
- const txId = await this.lrc20Wallet.broadcastRawBtcTransaction(
632
- tx.bitcoin_tx.toHex()
633
- );
634
- return txId;
635
- } catch (error) {
636
- throw new import_spark_sdk5.NetworkError(
637
- "Failed to broadcast announcement transaction on L1",
638
- {
639
- operation: "broadcastRawBtcTransaction",
640
- errorCount: 1,
641
- errors: error instanceof Error ? error.message : String(error)
642
- }
643
- );
644
- }
645
- }
646
602
  getTraceName(methodName) {
647
603
  return `IssuerSparkWallet.${methodName}`;
648
604
  }
@@ -669,8 +625,7 @@ var IssuerSparkWallet = class _IssuerSparkWallet extends import_spark_sdk5.Spark
669
625
  "burnTokens",
670
626
  "freezeTokens",
671
627
  "unfreezeTokens",
672
- "getIssuerTokenDistribution",
673
- "announceTokenL1"
628
+ "getIssuerTokenDistribution"
674
629
  ];
675
630
  methods.forEach(
676
631
  (m) => this.wrapPublicIssuerSparkWalletMethodWithOtelSpan(m)
@@ -689,6 +644,12 @@ var IssuerSparkWalletNodeJS = class _IssuerSparkWalletNodeJS extends IssuerSpark
689
644
  }) {
690
645
  const wallet = new _IssuerSparkWalletNodeJS(options, signer);
691
646
  wallet.initializeTracer(wallet);
647
+ if (options && options.signerWithPreExistingKeys) {
648
+ await wallet.initWalletWithoutSeed();
649
+ return {
650
+ wallet
651
+ };
652
+ }
692
653
  const initResponse = await wallet.initWallet(mnemonicOrSeed, accountNumber);
693
654
  return {
694
655
  wallet,
@@ -1,5 +1,5 @@
1
- import { I as IssuerSparkWallet } from './issuer-spark-wallet-BFzkv4X5.cjs';
2
- export { a as IssuerTokenMetadata, T as TokenDistribution } from './issuer-spark-wallet-BFzkv4X5.cjs';
1
+ import { I as IssuerSparkWallet } from './issuer-spark-wallet-Bho-WrkK.cjs';
2
+ export { a as IssuerTokenMetadata, T as TokenDistribution } from './issuer-spark-wallet-Bho-WrkK.cjs';
3
3
  import { SparkWalletProps } from '@buildonspark/spark-sdk';
4
4
  import '@buildonspark/spark-sdk/proto/spark';
5
5
 
@@ -1,5 +1,5 @@
1
- import { I as IssuerSparkWallet } from './issuer-spark-wallet-BFzkv4X5.js';
2
- export { a as IssuerTokenMetadata, T as TokenDistribution } from './issuer-spark-wallet-BFzkv4X5.js';
1
+ import { I as IssuerSparkWallet } from './issuer-spark-wallet-Bho-WrkK.js';
2
+ export { a as IssuerTokenMetadata, T as TokenDistribution } from './issuer-spark-wallet-Bho-WrkK.js';
3
3
  import { SparkWalletProps } from '@buildonspark/spark-sdk';
4
4
  import '@buildonspark/spark-sdk/proto/spark';
5
5
 
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  IssuerSparkWallet
3
- } from "./chunk-HOLMXKFE.js";
3
+ } from "./chunk-ZMLVOUPB.js";
4
4
  import "./chunk-7B4B24XF.js";
5
5
 
6
6
  // src/issuer-wallet/issuer-spark-wallet.node.ts
@@ -16,6 +16,12 @@ var IssuerSparkWalletNodeJS = class _IssuerSparkWalletNodeJS extends IssuerSpark
16
16
  }) {
17
17
  const wallet = new _IssuerSparkWalletNodeJS(options, signer);
18
18
  wallet.initializeTracer(wallet);
19
+ if (options && options.signerWithPreExistingKeys) {
20
+ await wallet.initWalletWithoutSeed();
21
+ return {
22
+ wallet
23
+ };
24
+ }
19
25
  const initResponse = await wallet.initWallet(mnemonicOrSeed, accountNumber);
20
26
  return {
21
27
  wallet,
@@ -143,19 +143,6 @@ declare class IssuerSparkWallet extends SparkWallet {
143
143
  * @throws {NotImplementedError} This feature is not yet supported
144
144
  */
145
145
  getIssuerTokenDistribution(): Promise<TokenDistribution>;
146
- /**
147
- * Announces a new token on the L1 (Bitcoin) network.
148
- * @param tokenName - The name of the token
149
- * @param tokenTicker - The ticker symbol for the token
150
- * @param decimals - The number of decimal places for the token
151
- * @param maxSupply - The maximum supply of the token
152
- * @param isFreezable - Whether the token can be frozen
153
- * @param feeRateSatsPerVb - The fee rate in satoshis per virtual byte (default: 4.0)
154
- * @returns The transaction ID of the announcement
155
- * @throws {ValidationError} If decimals is not a safe integer
156
- * @throws {NetworkError} If the announcement transaction cannot be broadcast
157
- */
158
- announceTokenL1(tokenName: string, tokenTicker: string, decimals: number, maxSupply: bigint, isFreezable: boolean, feeRateSatsPerVb?: number): Promise<string>;
159
146
  protected getTraceName(methodName: string): string;
160
147
  private wrapPublicIssuerSparkWalletMethodWithOtelSpan;
161
148
  private wrapIssuerSparkWalletMethodsWithTracing;
@@ -143,19 +143,6 @@ declare class IssuerSparkWallet extends SparkWallet {
143
143
  * @throws {NotImplementedError} This feature is not yet supported
144
144
  */
145
145
  getIssuerTokenDistribution(): Promise<TokenDistribution>;
146
- /**
147
- * Announces a new token on the L1 (Bitcoin) network.
148
- * @param tokenName - The name of the token
149
- * @param tokenTicker - The ticker symbol for the token
150
- * @param decimals - The number of decimal places for the token
151
- * @param maxSupply - The maximum supply of the token
152
- * @param isFreezable - Whether the token can be frozen
153
- * @param feeRateSatsPerVb - The fee rate in satoshis per virtual byte (default: 4.0)
154
- * @returns The transaction ID of the announcement
155
- * @throws {ValidationError} If decimals is not a safe integer
156
- * @throws {NetworkError} If the announcement transaction cannot be broadcast
157
- */
158
- announceTokenL1(tokenName: string, tokenTicker: string, decimals: number, maxSupply: bigint, isFreezable: boolean, feeRateSatsPerVb?: number): Promise<string>;
159
146
  protected getTraceName(methodName: string): string;
160
147
  private wrapPublicIssuerSparkWalletMethodWithOtelSpan;
161
148
  private wrapIssuerSparkWalletMethodsWithTracing;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@buildonspark/issuer-sdk",
3
- "version": "0.0.85",
3
+ "version": "0.0.87",
4
4
  "description": "Spark Issuer SDK for token issuance",
5
5
  "license": "Apache-2.0",
6
6
  "module": "./dist/index.js",
@@ -72,14 +72,10 @@
72
72
  "types": "tsc"
73
73
  },
74
74
  "dependencies": {
75
- "@buildonspark/lrc20-sdk": "0.0.61",
76
- "@buildonspark/spark-sdk": "0.2.6",
77
- "@lightsparkdev/core": "^1.4.2",
75
+ "@buildonspark/spark-sdk": "0.2.8",
78
76
  "@noble/curves": "^1.8.0",
79
77
  "@scure/btc-signer": "^1.5.0",
80
- "bitcoinjs-lib": "^6.1.5",
81
- "buffer": "^6.0.3",
82
- "ts-proto": "^2.6.1"
78
+ "buffer": "^6.0.3"
83
79
  },
84
80
  "devDependencies": {
85
81
  "@arethetypeswrong/cli": "^0.17.4",
@@ -14,6 +14,14 @@ export class IssuerSparkWalletBrowser extends BaseIssuerSparkWallet {
14
14
  const wallet = new IssuerSparkWalletBrowser(options, signer);
15
15
  wallet.initializeTracer(wallet);
16
16
 
17
+ if (options && options.signerWithPreExistingKeys) {
18
+ await wallet.initWalletWithoutSeed();
19
+
20
+ return {
21
+ wallet,
22
+ };
23
+ }
24
+
17
25
  const initResponse = await wallet.initWallet(mnemonicOrSeed, accountNumber);
18
26
 
19
27
  return {
@@ -14,6 +14,14 @@ export class IssuerSparkWalletNodeJS extends BaseIssuerSparkWallet {
14
14
  const wallet = new IssuerSparkWalletNodeJS(options, signer);
15
15
  wallet.initializeTracer(wallet);
16
16
 
17
+ if (options && options.signerWithPreExistingKeys) {
18
+ await wallet.initWalletWithoutSeed();
19
+
20
+ return {
21
+ wallet,
22
+ };
23
+ }
24
+
17
25
  const initResponse = await wallet.initWallet(mnemonicOrSeed, accountNumber);
18
26
 
19
27
  return {
@@ -1,11 +1,9 @@
1
- import { TokenPubkey, TokenPubkeyAnnouncement } from "@buildonspark/lrc20-sdk";
2
1
  import {
3
2
  NetworkError,
4
3
  SparkWallet,
5
4
  SparkWalletProps,
6
5
  ValidationError,
7
6
  } from "@buildonspark/spark-sdk";
8
- import { isNode } from "@lightsparkdev/core";
9
7
  import {
10
8
  decodeSparkAddress,
11
9
  encodeSparkAddress,
@@ -59,6 +57,14 @@ export class IssuerSparkWallet extends SparkWallet {
59
57
  const wallet = new IssuerSparkWallet(options, signer);
60
58
  wallet.initializeTracer(wallet);
61
59
 
60
+ if (options && options.signerWithPreExistingKeys) {
61
+ await wallet.initWalletWithoutSeed();
62
+
63
+ return {
64
+ wallet,
65
+ };
66
+ }
67
+
62
68
  const initResponse = await wallet.initWallet(mnemonicOrSeed, accountNumber);
63
69
 
64
70
  return {
@@ -142,7 +148,7 @@ export class IssuerSparkWallet extends SparkWallet {
142
148
  });
143
149
  if (response.tokenMetadata.length === 0) {
144
150
  throw new ValidationError(
145
- "Token metadata not found - If a token has not yet been announced, please announce. If a token was recently announced, it is being confirmed. Try again in a few seconds.",
151
+ "Token metadata not found - If a token has not yet been created, please create it first. Try again in a few seconds.",
146
152
  {
147
153
  field: "tokenMetadata",
148
154
  value: response.tokenMetadata,
@@ -371,72 +377,6 @@ export class IssuerSparkWallet extends SparkWallet {
371
377
  throw new NotImplementedError("Token distribution is not yet supported");
372
378
  }
373
379
 
374
- /**
375
- * Announces a new token on the L1 (Bitcoin) network.
376
- * @param tokenName - The name of the token
377
- * @param tokenTicker - The ticker symbol for the token
378
- * @param decimals - The number of decimal places for the token
379
- * @param maxSupply - The maximum supply of the token
380
- * @param isFreezable - Whether the token can be frozen
381
- * @param feeRateSatsPerVb - The fee rate in satoshis per virtual byte (default: 4.0)
382
- * @returns The transaction ID of the announcement
383
- * @throws {ValidationError} If decimals is not a safe integer
384
- * @throws {NetworkError} If the announcement transaction cannot be broadcast
385
- */
386
- public async announceTokenL1(
387
- tokenName: string,
388
- tokenTicker: string,
389
- decimals: number,
390
- maxSupply: bigint,
391
- isFreezable: boolean,
392
- feeRateSatsPerVb: number = 4.0,
393
- ): Promise<string> {
394
- validateTokenParameters(tokenName, tokenTicker, decimals, maxSupply);
395
-
396
- if (!Number.isSafeInteger(decimals)) {
397
- throw new ValidationError("Decimals must be less than 2^53", {
398
- field: "decimals",
399
- value: decimals,
400
- expected: "smaller or equal to " + Number.MAX_SAFE_INTEGER,
401
- });
402
- }
403
-
404
- await this.lrc20Wallet!.syncWallet();
405
-
406
- const tokenPublicKey = new TokenPubkey(this.lrc20Wallet!.pubkey);
407
-
408
- const announcement = new TokenPubkeyAnnouncement(
409
- tokenPublicKey,
410
- tokenName,
411
- tokenTicker,
412
- decimals,
413
- maxSupply,
414
- isFreezable,
415
- );
416
-
417
- try {
418
- const tx = await this.lrc20Wallet!.prepareAnnouncement(
419
- announcement,
420
- feeRateSatsPerVb,
421
- );
422
-
423
- const txId = await this.lrc20Wallet!.broadcastRawBtcTransaction(
424
- tx.bitcoin_tx.toHex(),
425
- );
426
-
427
- return txId;
428
- } catch (error) {
429
- throw new NetworkError(
430
- "Failed to broadcast announcement transaction on L1",
431
- {
432
- operation: "broadcastRawBtcTransaction",
433
- errorCount: 1,
434
- errors: error instanceof Error ? error.message : String(error),
435
- },
436
- );
437
- }
438
- }
439
-
440
380
  protected getTraceName(methodName: string) {
441
381
  return `IssuerSparkWallet.${methodName}`;
442
382
  }
@@ -471,7 +411,6 @@ export class IssuerSparkWallet extends SparkWallet {
471
411
  "freezeTokens",
472
412
  "unfreezeTokens",
473
413
  "getIssuerTokenDistribution",
474
- "announceTokenL1",
475
414
  ] as const;
476
415
 
477
416
  methods.forEach((m) =>
@@ -44,7 +44,7 @@ export class IssuerTokenTransactionService extends TokenTransactionService {
44
44
  tokenAmount: bigint,
45
45
  ): Promise<TokenTransaction> {
46
46
  return {
47
- version: 1,
47
+ version: 2,
48
48
  network: this.config.getNetworkProto(),
49
49
  tokenInputs: {
50
50
  $case: "mintInput",
@@ -64,6 +64,7 @@ export class IssuerTokenTransactionService extends TokenTransactionService {
64
64
  sparkOperatorIdentityPublicKeys:
65
65
  super.collectOperatorIdentityPublicKeys(),
66
66
  expiryTime: undefined,
67
+ invoiceAttachments: [],
67
68
  };
68
69
  }
69
70
 
@@ -76,7 +77,7 @@ export class IssuerTokenTransactionService extends TokenTransactionService {
76
77
  isFreezable: boolean,
77
78
  ): Promise<TokenTransaction> {
78
79
  return {
79
- version: 1,
80
+ version: 2,
80
81
  network: this.config.getNetworkProto(),
81
82
  tokenInputs: {
82
83
  $case: "createInput",
@@ -94,6 +95,7 @@ export class IssuerTokenTransactionService extends TokenTransactionService {
94
95
  sparkOperatorIdentityPublicKeys:
95
96
  super.collectOperatorIdentityPublicKeys(),
96
97
  expiryTime: undefined,
98
+ invoiceAttachments: [],
97
99
  };
98
100
  }
99
101
  }
@@ -76,33 +76,6 @@ describe.each(TEST_CONFIGS)(
76
76
  expect(metadata.decimals).toEqual(decimals);
77
77
  });
78
78
 
79
- it("should announce a token", async () => {
80
- const { wallet: issuerWallet } =
81
- await IssuerSparkWalletTesting.initialize({
82
- options: config,
83
- });
84
-
85
- const tokenName = `${name}Announcable`;
86
- const tokenTicker = "ANN";
87
- const maxSupply = 5000n;
88
- const decimals = 0;
89
-
90
- await fundAndAnnounce(
91
- issuerWallet,
92
- 5000n,
93
- 0,
94
- tokenName,
95
- tokenTicker,
96
- false,
97
- );
98
-
99
- const metadata = await issuerWallet.getIssuerTokenMetadata();
100
- expect(metadata.tokenName).toEqual(tokenName);
101
- expect(metadata.tokenTicker).toEqual(tokenTicker);
102
- expect(metadata.maxSupply).toEqual(maxSupply);
103
- expect(metadata.decimals).toEqual(decimals);
104
- });
105
-
106
79
  it("should fail on duplicate token creation", async () => {
107
80
  const { wallet: issuerWallet } =
108
81
  await IssuerSparkWalletTesting.initialize({
@@ -140,7 +113,7 @@ describe.each(TEST_CONFIGS)(
140
113
  await expect(wallet.mintTokens(tokenAmount)).rejects.toThrow();
141
114
  });
142
115
 
143
- it("should create, andfail when minting more than max supply", async () => {
116
+ it("should create, and fail when minting more than max supply", async () => {
144
117
  const tokenAmount: bigint = 1000n;
145
118
  const { wallet } = await IssuerSparkWalletTesting.initialize({
146
119
  options: config,
@@ -225,6 +198,306 @@ describe.each(TEST_CONFIGS)(
225
198
  expect(userBalance.balance).toBeGreaterThanOrEqual(tokenAmount);
226
199
  });
227
200
 
201
+ const tv1It = name.startsWith("TV1") ? it : it.skip;
202
+ tv1It("should transfer tokens using spark invoices", async () => {
203
+ const tokenAmount: bigint = 777n;
204
+ const initialIssuerBalance = 100000n;
205
+
206
+ const { wallet: issuerWallet } =
207
+ await IssuerSparkWalletTesting.initialize({
208
+ options: config,
209
+ });
210
+ const { wallet: receiverWallet } = await SparkWalletTesting.initialize({
211
+ options: config,
212
+ });
213
+
214
+ await issuerWallet.createToken({
215
+ tokenName: `${name}INV`,
216
+ tokenTicker: "INV",
217
+ decimals: 0,
218
+ isFreezable: false,
219
+ maxSupply: 1_000_000n,
220
+ });
221
+
222
+ await issuerWallet.mintTokens(initialIssuerBalance);
223
+
224
+ const issuerBalanceAfterMint = await issuerWallet.getIssuerTokenBalance();
225
+ expect(issuerBalanceAfterMint).toBeDefined();
226
+ expect(issuerBalanceAfterMint.balance).toBe(initialIssuerBalance);
227
+ const tokenIdentifier = issuerBalanceAfterMint.tokenIdentifier!;
228
+ const issuerBalanceBeforeTransfer = issuerBalanceAfterMint.balance;
229
+
230
+ const invoice = await receiverWallet.createTokensInvoice({
231
+ amount: tokenAmount,
232
+ tokenIdentifier,
233
+ memo: "Invoice test",
234
+ expiryTime: new Date(Date.now() + 1000 * 60 * 60 * 24),
235
+ });
236
+
237
+ const txId = await issuerWallet.fulfillSparkInvoice([{ invoice }]);
238
+ expect(typeof txId).toBe("string");
239
+ expect(txId.length).toBeGreaterThan(0);
240
+
241
+ const issuerBalanceAfter = (await issuerWallet.getIssuerTokenBalance())
242
+ .balance;
243
+ expect(issuerBalanceAfter).toEqual(
244
+ issuerBalanceBeforeTransfer - tokenAmount,
245
+ );
246
+
247
+ const receiverBalanceObj = await receiverWallet.getBalance();
248
+ const receiverBalance = filterTokenBalanceForTokenIdentifier(
249
+ receiverBalanceObj?.tokenBalances,
250
+ tokenIdentifier!,
251
+ );
252
+ expect(receiverBalance.balance).toEqual(tokenAmount);
253
+ });
254
+
255
+ tv1It("should transfer tokens using multiple spark invoices", async () => {
256
+ const amount1: bigint = 111n;
257
+ const amount2: bigint = 222n;
258
+ const amount3: bigint = 333n;
259
+ const totalAmount: bigint = amount1 + amount2 + amount3;
260
+ const initialIssuerBalance = 100000n;
261
+
262
+ const { wallet: issuerWallet } =
263
+ await IssuerSparkWalletTesting.initialize({
264
+ options: config,
265
+ });
266
+ const { wallet: receiverWallet1 } = await SparkWalletTesting.initialize({
267
+ options: config,
268
+ });
269
+ const { wallet: receiverWallet2 } = await SparkWalletTesting.initialize({
270
+ options: config,
271
+ });
272
+
273
+ await issuerWallet.createToken({
274
+ tokenName: `${name}INVM`,
275
+ tokenTicker: "INM",
276
+ decimals: 0,
277
+ isFreezable: false,
278
+ maxSupply: 1_000_000n,
279
+ });
280
+
281
+ await issuerWallet.mintTokens(initialIssuerBalance);
282
+
283
+ const issuerBalanceAfterMint = await issuerWallet.getIssuerTokenBalance();
284
+ expect(issuerBalanceAfterMint).toBeDefined();
285
+ expect(issuerBalanceAfterMint.balance).toBe(initialIssuerBalance);
286
+ const tokenIdentifier = issuerBalanceAfterMint.tokenIdentifier!;
287
+ const issuerBalanceBeforeTransfer = issuerBalanceAfterMint.balance;
288
+
289
+ const invoice1 = await receiverWallet1.createTokensInvoice({
290
+ amount: amount1,
291
+ tokenIdentifier,
292
+ memo: "Invoice #1",
293
+ expiryTime: new Date(Date.now() + 1000 * 60 * 60 * 24),
294
+ });
295
+
296
+ const invoice2 = await receiverWallet1.createTokensInvoice({
297
+ amount: amount2,
298
+ tokenIdentifier,
299
+ memo: "Invoice #2",
300
+ expiryTime: new Date(Date.now() + 1000 * 60 * 60 * 24),
301
+ });
302
+
303
+ const invoice3 = await receiverWallet2.createTokensInvoice({
304
+ amount: amount3,
305
+ tokenIdentifier,
306
+ memo: "Invoice #3",
307
+ expiryTime: new Date(Date.now() + 1000 * 60 * 60 * 24),
308
+ });
309
+
310
+ const txId = await issuerWallet.fulfillSparkInvoice([
311
+ { invoice: invoice1 },
312
+ { invoice: invoice2 },
313
+ { invoice: invoice3 },
314
+ ]);
315
+ expect(typeof txId).toBe("string");
316
+ expect(txId.length).toBeGreaterThan(0);
317
+
318
+ const issuerBalanceAfter = (await issuerWallet.getIssuerTokenBalance())
319
+ .balance;
320
+ expect(issuerBalanceAfter).toEqual(
321
+ issuerBalanceBeforeTransfer - totalAmount,
322
+ );
323
+
324
+ const receiver1BalanceObj = await receiverWallet1.getBalance();
325
+ const receiver1Balance = filterTokenBalanceForTokenIdentifier(
326
+ receiver1BalanceObj?.tokenBalances,
327
+ tokenIdentifier!,
328
+ );
329
+ expect(receiver1Balance.balance).toEqual(amount1 + amount2);
330
+
331
+ const receiver2BalanceObj = await receiverWallet2.getBalance();
332
+ const receiver2Balance = filterTokenBalanceForTokenIdentifier(
333
+ receiver2BalanceObj?.tokenBalances,
334
+ tokenIdentifier!,
335
+ );
336
+ expect(receiver2Balance.balance).toEqual(amount3);
337
+ });
338
+
339
+ tv1It("should fail to fulfill an expired spark invoice", async () => {
340
+ const tokenAmount: bigint = 123n;
341
+ const initialIssuerBalance = 100000n;
342
+
343
+ const { wallet: issuerWallet } =
344
+ await IssuerSparkWalletTesting.initialize({
345
+ options: config,
346
+ });
347
+ const { wallet: receiverWallet } = await SparkWalletTesting.initialize({
348
+ options: config,
349
+ });
350
+
351
+ await issuerWallet.createToken({
352
+ tokenName: `${name}INVEXP`,
353
+ tokenTicker: "INVX",
354
+ decimals: 0,
355
+ isFreezable: false,
356
+ maxSupply: 1_000_000n,
357
+ });
358
+
359
+ await issuerWallet.mintTokens(initialIssuerBalance);
360
+
361
+ const issuerBalanceAfterMint = await issuerWallet.getIssuerTokenBalance();
362
+ expect(issuerBalanceAfterMint).toBeDefined();
363
+ expect(issuerBalanceAfterMint.balance).toBe(initialIssuerBalance);
364
+ const tokenIdentifier = issuerBalanceAfterMint.tokenIdentifier!;
365
+ const issuerBalanceBefore = issuerBalanceAfterMint.balance;
366
+
367
+ const expiredInvoice = await receiverWallet.createTokensInvoice({
368
+ amount: tokenAmount,
369
+ tokenIdentifier,
370
+ memo: "Expired invoice",
371
+ expiryTime: new Date(Date.now() - 60_000),
372
+ });
373
+
374
+ await expect(
375
+ issuerWallet.fulfillSparkInvoice([{ invoice: expiredInvoice }]),
376
+ ).rejects.toThrow("expired");
377
+
378
+ const issuerBalanceAfter = (await issuerWallet.getIssuerTokenBalance())
379
+ .balance;
380
+ expect(issuerBalanceAfter).toEqual(issuerBalanceBefore);
381
+
382
+ const receiverBalanceObj = await receiverWallet.getBalance();
383
+ const receiverBalance = filterTokenBalanceForTokenIdentifier(
384
+ receiverBalanceObj?.tokenBalances,
385
+ tokenIdentifier!,
386
+ );
387
+ expect(receiverBalance.balance).toEqual(0n);
388
+ });
389
+
390
+ tv1It("should fulfill a spark invoice with null expiry", async () => {
391
+ const tokenAmount: bigint = 321n;
392
+ const initialIssuerBalance = 100000n;
393
+
394
+ const { wallet: issuerWallet } =
395
+ await IssuerSparkWalletTesting.initialize({
396
+ options: config,
397
+ });
398
+ const { wallet: receiverWallet } = await SparkWalletTesting.initialize({
399
+ options: config,
400
+ });
401
+
402
+ await issuerWallet.createToken({
403
+ tokenName: `${name}INVNULL`,
404
+ tokenTicker: "INVN",
405
+ decimals: 0,
406
+ isFreezable: false,
407
+ maxSupply: 1_000_000n,
408
+ });
409
+
410
+ await issuerWallet.mintTokens(initialIssuerBalance);
411
+
412
+ const issuerBalanceAfterMint = await issuerWallet.getIssuerTokenBalance();
413
+ expect(issuerBalanceAfterMint).toBeDefined();
414
+ expect(issuerBalanceAfterMint.balance).toBe(initialIssuerBalance);
415
+ const tokenIdentifier = issuerBalanceAfterMint.tokenIdentifier!;
416
+ const issuerBalanceBefore = issuerBalanceAfterMint.balance;
417
+
418
+ const nullExpiryInvoice = await receiverWallet.createTokensInvoice({
419
+ amount: tokenAmount,
420
+ tokenIdentifier,
421
+ memo: "Null expiry invoice",
422
+ expiryTime: null as unknown as Date,
423
+ });
424
+
425
+ const txId = await issuerWallet.fulfillSparkInvoice([
426
+ { invoice: nullExpiryInvoice },
427
+ ]);
428
+ expect(typeof txId).toBe("string");
429
+ expect(txId.length).toBeGreaterThan(0);
430
+
431
+ const issuerBalanceAfter = (await issuerWallet.getIssuerTokenBalance())
432
+ .balance;
433
+ expect(issuerBalanceAfter).toEqual(issuerBalanceBefore - tokenAmount);
434
+
435
+ const receiverBalanceObj = await receiverWallet.getBalance();
436
+ const receiverBalance = filterTokenBalanceForTokenIdentifier(
437
+ receiverBalanceObj?.tokenBalances,
438
+ tokenIdentifier!,
439
+ );
440
+ expect(receiverBalance.balance).toEqual(tokenAmount);
441
+ });
442
+
443
+ tv1It(
444
+ "should fulfill a tokens invoice without amount by passing amount parameter",
445
+ async () => {
446
+ const tokenAmount: bigint = 555n;
447
+ const initialIssuerBalance = 100000n;
448
+
449
+ const { wallet: issuerWallet } =
450
+ await IssuerSparkWalletTesting.initialize({
451
+ options: config,
452
+ });
453
+ const { wallet: receiverWallet } = await SparkWalletTesting.initialize({
454
+ options: config,
455
+ });
456
+
457
+ await issuerWallet.createToken({
458
+ tokenName: `${name}INVAOPT`,
459
+ tokenTicker: "INO",
460
+ decimals: 0,
461
+ isFreezable: false,
462
+ maxSupply: 1_000_000n,
463
+ });
464
+
465
+ await issuerWallet.mintTokens(initialIssuerBalance);
466
+
467
+ const issuerBalanceAfterMint =
468
+ await issuerWallet.getIssuerTokenBalance();
469
+ expect(issuerBalanceAfterMint).toBeDefined();
470
+ expect(issuerBalanceAfterMint.balance).toBe(initialIssuerBalance);
471
+ const tokenIdentifier = issuerBalanceAfterMint.tokenIdentifier!;
472
+ const issuerBalanceBeforeTransfer = issuerBalanceAfterMint.balance;
473
+
474
+ const invoiceWithoutAmount = await receiverWallet.createTokensInvoice({
475
+ tokenIdentifier,
476
+ memo: "Invoice without preset amount",
477
+ expiryTime: new Date(Date.now() + 1000 * 60 * 60 * 24),
478
+ });
479
+
480
+ const txId = await (issuerWallet as any).fulfillSparkInvoice([
481
+ { invoice: invoiceWithoutAmount, amount: tokenAmount },
482
+ ]);
483
+ expect(typeof txId).toBe("string");
484
+ expect(txId.length).toBeGreaterThan(0);
485
+
486
+ const issuerBalanceAfter = (await issuerWallet.getIssuerTokenBalance())
487
+ .balance;
488
+ expect(issuerBalanceAfter).toEqual(
489
+ issuerBalanceBeforeTransfer - tokenAmount,
490
+ );
491
+
492
+ const receiverBalanceObj = await receiverWallet.getBalance();
493
+ const receiverBalance = filterTokenBalanceForTokenIdentifier(
494
+ receiverBalanceObj?.tokenBalances,
495
+ tokenIdentifier!,
496
+ );
497
+ expect(receiverBalance.balance).toEqual(tokenAmount);
498
+ },
499
+ );
500
+
228
501
  it("should create, mint, and batchtransfer tokens", async () => {
229
502
  const tokenAmount: bigint = 999n;
230
503
 
@@ -577,15 +850,6 @@ describe.each(TEST_CONFIGS)(
577
850
  });
578
851
  });
579
852
 
580
- it("should be able to anounce a token with name of size equal to MAX_SYMBOL_SIZE", async () => {
581
- const { wallet: issuerWallet } =
582
- await IssuerSparkWalletTesting.initialize({
583
- options: config,
584
- });
585
-
586
- await fundAndAnnounce(issuerWallet, 100000n, 0, "MST", "TESTAA", false);
587
- });
588
-
589
853
  it("should be able to create a token with symbol of size equal to MAX_NAME_SIZE", async () => {
590
854
  const { wallet: issuerWallet } =
591
855
  await IssuerSparkWalletTesting.initialize({
@@ -601,22 +865,6 @@ describe.each(TEST_CONFIGS)(
601
865
  });
602
866
  });
603
867
 
604
- it("should be able to announce a token with symbol of size equal to MAX_NAME_SIZE", async () => {
605
- const { wallet: issuerWallet } =
606
- await IssuerSparkWalletTesting.initialize({
607
- options: config,
608
- });
609
-
610
- await fundAndAnnounce(
611
- issuerWallet,
612
- 100000n,
613
- 0,
614
- "ABCDEFGHIJKLMNOPQ",
615
- "MQS",
616
- false,
617
- );
618
- });
619
-
620
868
  it("should create, mint, freeze, and unfreeze tokens", async () => {
621
869
  const tokenAmount: bigint = 1000n;
622
870
  const { wallet: issuerWallet } =
@@ -785,39 +1033,3 @@ describe.each(TEST_CONFIGS)(
785
1033
  });
786
1034
  },
787
1035
  );
788
-
789
- async function fundAndAnnounce(
790
- wallet: IssuerSparkWallet,
791
- maxSupply: bigint = 100000n,
792
- decimals: number = 0,
793
- tokenName: string = "TestToken1",
794
- tokenSymbol: string = "TT1",
795
- isFreezable: boolean = false,
796
- ) {
797
- // Faucet funds to the Issuer wallet because announcing a token
798
- // requires ownership of an L1 UTXO.
799
- const faucet = BitcoinFaucet.getInstance();
800
- const l1WalletPubKey = await wallet.getTokenL1Address();
801
- await faucet.sendToAddress(l1WalletPubKey, 100_000n);
802
- await faucet.mineBlocks(6);
803
-
804
- await new Promise((resolve) => setTimeout(resolve, 3000));
805
-
806
- try {
807
- const response = await wallet.announceTokenL1(
808
- tokenName,
809
- tokenSymbol,
810
- decimals,
811
- maxSupply,
812
- isFreezable,
813
- );
814
- console.log("Announce token response:", response);
815
- } catch (error: any) {
816
- console.error("Error when announcing token on L1:", error);
817
- throw error;
818
- }
819
- await faucet.mineBlocks(2);
820
-
821
- const SECONDS = 1000;
822
- await new Promise((resolve) => setTimeout(resolve, 3 * SECONDS));
823
- }
@@ -1,19 +0,0 @@
1
- import { Network } from "@buildonspark/spark-sdk";
2
- import { networks } from "bitcoinjs-lib";
3
- import { NetworkType } from "@buildonspark/lrc20-sdk";
4
-
5
- export const LRC_WALLET_NETWORK = Object.freeze({
6
- [Network.MAINNET]: networks.bitcoin,
7
- [Network.TESTNET]: networks.testnet,
8
- [Network.SIGNET]: networks.testnet,
9
- [Network.REGTEST]: networks.regtest,
10
- [Network.LOCAL]: networks.regtest,
11
- });
12
-
13
- export const LRC_WALLET_NETWORK_TYPE = Object.freeze({
14
- [Network.MAINNET]: NetworkType.MAINNET,
15
- [Network.TESTNET]: NetworkType.TESTNET,
16
- [Network.SIGNET]: NetworkType.TESTNET,
17
- [Network.REGTEST]: NetworkType.REGTEST,
18
- [Network.LOCAL]: NetworkType.REGTEST,
19
- });