@buildonspark/issuer-sdk 0.0.76 → 0.0.78

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,23 @@
1
1
  # @buildonspark/issuer-sdk
2
2
 
3
+ ## 0.0.78
4
+
5
+ ### Patch Changes
6
+
7
+ - - Renamed getIssuerTokenInfo() to getIssuerTokenMetadata() to better reflect its purpose
8
+ - Renamed fields to match the new API response (e.g., tokenSymbol → tokenTicker, tokenDecimals → decimals)
9
+ - Updated dependencies
10
+ - @buildonspark/spark-sdk@0.1.47
11
+
12
+ ## 0.0.77
13
+
14
+ ### Patch Changes
15
+
16
+ - Upgrades to token transfers
17
+ - Updated dependencies
18
+ - @buildonspark/lrc20-sdk@0.0.59
19
+ - @buildonspark/spark-sdk@0.1.46
20
+
3
21
  ## 0.0.76
4
22
 
5
23
  ### Patch Changes
package/dist/index.cjs CHANGED
@@ -40,13 +40,13 @@ if (typeof window !== "undefined") {
40
40
 
41
41
  // src/issuer-wallet/issuer-spark-wallet.ts
42
42
  var import_lrc20_sdk = require("@buildonspark/lrc20-sdk");
43
- var import_spark_sdk3 = require("@buildonspark/spark-sdk");
43
+ var import_spark_sdk4 = require("@buildonspark/spark-sdk");
44
44
  var import_core = require("@lightsparkdev/core");
45
- var import_address = require("@buildonspark/spark-sdk/address");
46
- var import_utils5 = require("@noble/curves/abstract/utils");
45
+ var import_spark_sdk5 = require("@buildonspark/spark-sdk");
46
+ var import_utils4 = require("@noble/curves/abstract/utils");
47
47
 
48
48
  // src/services/freeze.ts
49
- var import_utils2 = require("@buildonspark/spark-sdk/utils");
49
+ var import_spark_sdk2 = require("@buildonspark/spark-sdk");
50
50
 
51
51
  // src/utils/token-hashing.ts
52
52
  var import_utils = require("@scure/btc-signer/utils");
@@ -98,8 +98,7 @@ function hashFreezeTokensPayload(payload) {
98
98
  }
99
99
 
100
100
  // src/services/freeze.ts
101
- var import_spark_sdk2 = require("@buildonspark/spark-sdk");
102
- var import_utils3 = require("@noble/curves/abstract/utils");
101
+ var import_utils2 = require("@noble/curves/abstract/utils");
103
102
  var TokenFreezeService = class {
104
103
  config;
105
104
  connectionManager;
@@ -124,7 +123,7 @@ var TokenFreezeService = class {
124
123
  tokenPublicKey,
125
124
  shouldUnfreeze,
126
125
  issuerProvidedTimestamp,
127
- operatorIdentityPublicKey: (0, import_utils3.hexToBytes)(operator.identityPublicKey)
126
+ operatorIdentityPublicKey: (0, import_utils2.hexToBytes)(operator.identityPublicKey)
128
127
  };
129
128
  const hashedPayload = hashFreezeTokensPayload(freezeTokensPayload);
130
129
  const issuerSignature = await this.config.signer.signMessageWithIdentityKey(hashedPayload);
@@ -150,15 +149,15 @@ var TokenFreezeService = class {
150
149
  }
151
150
  })
152
151
  );
153
- const successfulResponses = (0, import_utils2.collectResponses)(freezeResponses);
152
+ const successfulResponses = (0, import_spark_sdk2.collectResponses)(freezeResponses);
154
153
  return successfulResponses[0].response;
155
154
  }
156
155
  };
157
156
 
158
157
  // src/services/token-transactions.ts
159
- var import_token_transactions = require("@buildonspark/spark-sdk/token-transactions");
160
- var import_utils4 = require("@noble/curves/abstract/utils");
161
- var IssuerTokenTransactionService = class extends import_token_transactions.TokenTransactionService {
158
+ var import_spark_sdk3 = require("@buildonspark/spark-sdk");
159
+ var import_utils3 = require("@noble/curves/abstract/utils");
160
+ var IssuerTokenTransactionService = class extends import_spark_sdk3.TokenTransactionService {
162
161
  constructor(config, connectionManager) {
163
162
  super(config, connectionManager);
164
163
  }
@@ -176,7 +175,7 @@ var IssuerTokenTransactionService = class extends import_token_transactions.Toke
176
175
  {
177
176
  ownerPublicKey: tokenPublicKey,
178
177
  tokenPublicKey,
179
- tokenAmount: (0, import_utils4.numberToBytesBE)(tokenAmount, 16)
178
+ tokenAmount: (0, import_utils3.numberToBytesBE)(tokenAmount, 16)
180
179
  }
181
180
  ],
182
181
  sparkOperatorIdentityPublicKeys: super.collectOperatorIdentityPublicKeys()
@@ -196,7 +195,7 @@ var IssuerTokenTransactionService = class extends import_token_transactions.Toke
196
195
  {
197
196
  ownerPublicKey: tokenPublicKey,
198
197
  tokenPublicKey,
199
- tokenAmount: (0, import_utils4.numberToBytesBE)(tokenAmount, 16)
198
+ tokenAmount: (0, import_utils3.numberToBytesBE)(tokenAmount, 16)
200
199
  }
201
200
  ],
202
201
  clientCreatedTimestamp: /* @__PURE__ */ new Date(),
@@ -207,9 +206,9 @@ var IssuerTokenTransactionService = class extends import_token_transactions.Toke
207
206
  };
208
207
 
209
208
  // src/issuer-wallet/issuer-spark-wallet.ts
210
- var import_spark_sdk4 = require("@buildonspark/spark-sdk");
209
+ var import_spark_sdk6 = require("@buildonspark/spark-sdk");
211
210
  var BURN_ADDRESS = "02".repeat(33);
212
- var IssuerSparkWallet = class _IssuerSparkWallet extends import_spark_sdk3.SparkWallet {
211
+ var IssuerSparkWallet = class _IssuerSparkWallet extends import_spark_sdk4.SparkWallet {
213
212
  issuerTokenTransactionService;
214
213
  tokenFreezeService;
215
214
  tracerId = "issuer-sdk";
@@ -239,9 +238,9 @@ var IssuerSparkWallet = class _IssuerSparkWallet extends import_spark_sdk3.Spark
239
238
  "SparkIssuerWallet.getIssuerTokenBalance",
240
239
  this.getIssuerTokenBalance.bind(this)
241
240
  );
242
- this.getIssuerTokenInfo = this.wrapWithOtelSpan(
243
- "SparkIssuerWallet.getIssuerTokenInfo",
244
- this.getIssuerTokenInfo.bind(this)
241
+ this.getIssuerTokenMetadata = this.wrapWithOtelSpan(
242
+ "SparkIssuerWallet.getIssuerTokenMetadata",
243
+ this.getIssuerTokenMetadata.bind(this)
245
244
  );
246
245
  this.mintTokens = this.wrapWithOtelSpan(
247
246
  "SparkIssuerWallet.mintTokens",
@@ -299,29 +298,56 @@ var IssuerSparkWallet = class _IssuerSparkWallet extends import_spark_sdk3.Spark
299
298
  };
300
299
  }
301
300
  /**
302
- * Retrieves information about the issuer's token.
301
+ * Retrieves metadata about the issuer's token.
303
302
  * @returns An object containing token information including public key, name, symbol, decimals, max supply, and freeze status
304
- * @throws {NetworkError} If the token info cannot be retrieved
303
+ * @throws {NetworkError} If the token metadata cannot be retrieved
305
304
  */
306
- async getIssuerTokenInfo() {
307
- const lrc20Client = await this.lrc20ConnectionManager.createLrc20Client();
305
+ async getIssuerTokenMetadata() {
306
+ const issuerPublicKey = await super.getIdentityPublicKey();
307
+ if (this.tokenMetadata.has(issuerPublicKey)) {
308
+ const metadata = this.tokenMetadata.get(issuerPublicKey);
309
+ return {
310
+ tokenPublicKey: (0, import_utils4.bytesToHex)(metadata.issuerPublicKey),
311
+ rawTokenIdentifier: metadata.tokenIdentifier,
312
+ tokenName: metadata.tokenName,
313
+ tokenTicker: metadata.tokenTicker,
314
+ decimals: metadata.decimals,
315
+ maxSupply: (0, import_utils4.bytesToNumberBE)(metadata.maxSupply),
316
+ isFreezable: metadata.isFreezable
317
+ };
318
+ }
319
+ const sparkTokenClient = await this.connectionManager.createSparkTokenClient(
320
+ this.config.getCoordinatorAddress()
321
+ );
308
322
  try {
309
- const tokenInfo = await lrc20Client.getTokenPubkeyInfo({
310
- publicKeys: [(0, import_utils5.hexToBytes)(await super.getIdentityPublicKey())]
323
+ const response = await sparkTokenClient.query_token_metadata({
324
+ issuerPublicKeys: Array.of((0, import_utils4.hexToBytes)(issuerPublicKey))
311
325
  });
312
- const info = tokenInfo.tokenPubkeyInfos[0];
326
+ if (response.tokenMetadata.length === 0) {
327
+ throw new import_spark_sdk4.ValidationError(
328
+ "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.",
329
+ {
330
+ field: "tokenMetadata",
331
+ value: response.tokenMetadata,
332
+ expected: "non-empty array",
333
+ actualLength: response.tokenMetadata.length,
334
+ expectedLength: 1
335
+ }
336
+ );
337
+ }
338
+ const metadata = response.tokenMetadata[0];
339
+ this.tokenMetadata.set(issuerPublicKey, metadata);
313
340
  return {
314
- tokenPublicKey: (0, import_utils5.bytesToHex)(info.announcement.publicKey.publicKey),
315
- tokenName: info.announcement.name,
316
- tokenSymbol: info.announcement.symbol,
317
- tokenDecimals: Number((0, import_utils5.bytesToNumberBE)(info.announcement.decimal)),
318
- isFreezable: info.announcement.isFreezable,
319
- maxSupply: (0, import_utils5.bytesToNumberBE)(info.announcement.maxSupply),
320
- totalSupply: (0, import_utils5.bytesToNumberBE)(info.totalSupply)
341
+ tokenPublicKey: (0, import_utils4.bytesToHex)(metadata.issuerPublicKey),
342
+ rawTokenIdentifier: metadata.tokenIdentifier,
343
+ tokenName: metadata.tokenName,
344
+ tokenTicker: metadata.tokenTicker,
345
+ decimals: metadata.decimals,
346
+ maxSupply: (0, import_utils4.bytesToNumberBE)(metadata.maxSupply),
347
+ isFreezable: metadata.isFreezable
321
348
  };
322
349
  } catch (error) {
323
- throw new import_spark_sdk3.NetworkError("Failed to get token info", {
324
- operation: "getIssuerTokenInfo",
350
+ throw new import_spark_sdk4.NetworkError("Failed to fetch token metadata", {
325
351
  errorCount: 1,
326
352
  errors: error instanceof Error ? error.message : String(error)
327
353
  });
@@ -337,12 +363,12 @@ var IssuerSparkWallet = class _IssuerSparkWallet extends import_spark_sdk3.Spark
337
363
  let tokenTransaction;
338
364
  if (this.config.getTokenTransactionVersion() === "V0") {
339
365
  tokenTransaction = await this.issuerTokenTransactionService.constructMintTokenTransactionV0(
340
- (0, import_utils5.hexToBytes)(tokenPublicKey),
366
+ (0, import_utils4.hexToBytes)(tokenPublicKey),
341
367
  tokenAmount
342
368
  );
343
369
  } else {
344
370
  tokenTransaction = await this.issuerTokenTransactionService.constructMintTokenTransaction(
345
- (0, import_utils5.hexToBytes)(tokenPublicKey),
371
+ (0, import_utils4.hexToBytes)(tokenPublicKey),
346
372
  tokenAmount
347
373
  );
348
374
  }
@@ -357,7 +383,7 @@ var IssuerSparkWallet = class _IssuerSparkWallet extends import_spark_sdk3.Spark
357
383
  * @returns The transaction ID of the burn operation
358
384
  */
359
385
  async burnTokens(tokenAmount, selectedOutputs) {
360
- const burnAddress = (0, import_address.encodeSparkAddress)({
386
+ const burnAddress = (0, import_spark_sdk5.encodeSparkAddress)({
361
387
  identityPublicKey: BURN_ADDRESS,
362
388
  network: this.config.getNetworkType()
363
389
  });
@@ -376,15 +402,15 @@ var IssuerSparkWallet = class _IssuerSparkWallet extends import_spark_sdk3.Spark
376
402
  async freezeTokens(sparkAddress) {
377
403
  await this.syncTokenOutputs();
378
404
  const tokenPublicKey = await super.getIdentityPublicKey();
379
- const decodedOwnerPubkey = (0, import_address.decodeSparkAddress)(
405
+ const decodedOwnerPubkey = (0, import_spark_sdk5.decodeSparkAddress)(
380
406
  sparkAddress,
381
407
  this.config.getNetworkType()
382
408
  );
383
409
  const response = await this.tokenFreezeService.freezeTokens(
384
- (0, import_utils5.hexToBytes)(decodedOwnerPubkey.identityPublicKey),
385
- (0, import_utils5.hexToBytes)(tokenPublicKey)
410
+ (0, import_utils4.hexToBytes)(decodedOwnerPubkey.identityPublicKey),
411
+ (0, import_utils4.hexToBytes)(tokenPublicKey)
386
412
  );
387
- const tokenAmount = (0, import_utils5.bytesToNumberBE)(response.impactedTokenAmount);
413
+ const tokenAmount = (0, import_utils4.bytesToNumberBE)(response.impactedTokenAmount);
388
414
  return {
389
415
  impactedOutputIds: response.impactedOutputIds,
390
416
  impactedTokenAmount: tokenAmount
@@ -398,15 +424,15 @@ var IssuerSparkWallet = class _IssuerSparkWallet extends import_spark_sdk3.Spark
398
424
  async unfreezeTokens(sparkAddress) {
399
425
  await this.syncTokenOutputs();
400
426
  const tokenPublicKey = await super.getIdentityPublicKey();
401
- const decodedOwnerPubkey = (0, import_address.decodeSparkAddress)(
427
+ const decodedOwnerPubkey = (0, import_spark_sdk5.decodeSparkAddress)(
402
428
  sparkAddress,
403
429
  this.config.getNetworkType()
404
430
  );
405
431
  const response = await this.tokenFreezeService.unfreezeTokens(
406
- (0, import_utils5.hexToBytes)(decodedOwnerPubkey.identityPublicKey),
407
- (0, import_utils5.hexToBytes)(tokenPublicKey)
432
+ (0, import_utils4.hexToBytes)(decodedOwnerPubkey.identityPublicKey),
433
+ (0, import_utils4.hexToBytes)(tokenPublicKey)
408
434
  );
409
- const tokenAmount = (0, import_utils5.bytesToNumberBE)(response.impactedTokenAmount);
435
+ const tokenAmount = (0, import_utils4.bytesToNumberBE)(response.impactedTokenAmount);
410
436
  return {
411
437
  impactedOutputIds: response.impactedOutputIds,
412
438
  impactedTokenAmount: tokenAmount
@@ -417,7 +443,7 @@ var IssuerSparkWallet = class _IssuerSparkWallet extends import_spark_sdk3.Spark
417
443
  * @throws {NotImplementedError} This feature is not yet supported
418
444
  */
419
445
  async getIssuerTokenDistribution() {
420
- throw new import_spark_sdk4.NotImplementedError("Token distribution is not yet supported");
446
+ throw new import_spark_sdk6.NotImplementedError("Token distribution is not yet supported");
421
447
  }
422
448
  /**
423
449
  * Announces a new token on the L1 (Bitcoin) network.
@@ -433,7 +459,7 @@ var IssuerSparkWallet = class _IssuerSparkWallet extends import_spark_sdk3.Spark
433
459
  */
434
460
  async announceTokenL1(tokenName, tokenTicker, decimals, maxSupply, isFreezable, feeRateSatsPerVb = 4) {
435
461
  if (!Number.isSafeInteger(decimals)) {
436
- throw new import_spark_sdk3.ValidationError("Decimals must be less than 2^53", {
462
+ throw new import_spark_sdk4.ValidationError("Decimals must be less than 2^53", {
437
463
  field: "decimals",
438
464
  value: decimals,
439
465
  expected: "smaller or equal to " + Number.MAX_SAFE_INTEGER
@@ -459,7 +485,7 @@ var IssuerSparkWallet = class _IssuerSparkWallet extends import_spark_sdk3.Spark
459
485
  );
460
486
  return txId;
461
487
  } catch (error) {
462
- throw new import_spark_sdk3.NetworkError(
488
+ throw new import_spark_sdk4.NetworkError(
463
489
  "Failed to broadcast announcement transaction on L1",
464
490
  {
465
491
  operation: "broadcastRawBtcTransaction",
package/dist/index.d.cts CHANGED
@@ -1,18 +1,51 @@
1
- import { SparkWallet, SparkWalletProps } from '@buildonspark/spark-sdk';
1
+ import { SparkWallet, SparkWalletProps, ConfigOptions, SparkSigner } from '@buildonspark/spark-sdk';
2
2
  import { OutputWithPreviousTransactionData } from '@buildonspark/spark-sdk/proto/spark';
3
- import { ConfigOptions } from '@buildonspark/spark-sdk/services/wallet-config';
4
- import { TokenDistribution } from './types.cjs';
5
- import { SparkSigner } from '@buildonspark/spark-sdk/signer';
6
3
 
7
- type IssuerTokenInfo = {
4
+ /**
5
+ * Token metadata containing essential information about issuer's token.
6
+ * This is the wallet's internal representation with JavaScript-friendly types.
7
+ *
8
+ * rawTokenIdentifier: This is the raw binary token identifier - This is used to encode the human readable token identifier.
9
+ *
10
+ * tokenPublicKey: This is the hex-encoded public key of the token issuer - Same as issuerPublicKey.
11
+ *
12
+ * @example
13
+ * ```typescript
14
+ * const tokenMetadata: IssuerTokenMetadata = {
15
+ * rawTokenIdentifier: new Uint8Array([1, 2, 3]),
16
+ * tokenPublicKey: "0348fbb...",
17
+ * tokenName: "SparkToken",
18
+ * tokenTicker: "SPK",
19
+ * decimals: 8,
20
+ * maxSupply: 1000000n
21
+ * isFreezable: true
22
+ * };
23
+ * ```
24
+ */
25
+ type IssuerTokenMetadata = {
26
+ /** Raw binary token identifier - This is used to encode the human readable token identifier */
27
+ rawTokenIdentifier: Uint8Array;
28
+ /** Public key of the token issuer - Same as issuerPublicKey */
8
29
  tokenPublicKey: string;
30
+ /** Human-readable name of the token (e.g., SparkToken)*/
9
31
  tokenName: string;
10
- tokenSymbol: string;
11
- tokenDecimals: number;
32
+ /** Short ticker symbol for the token (e.g., "SPK") */
33
+ tokenTicker: string;
34
+ /** Number of decimal places for token amounts */
35
+ decimals: number;
36
+ /** Maximum supply of tokens that can ever be minted */
12
37
  maxSupply: bigint;
38
+ /** Whether the token is freezable */
13
39
  isFreezable: boolean;
14
- totalSupply: bigint;
15
40
  };
41
+ interface TokenDistribution {
42
+ totalCirculatingSupply: bigint;
43
+ totalIssued: bigint;
44
+ totalBurned: bigint;
45
+ numHoldingAddress: number;
46
+ numConfirmedTransactions: bigint;
47
+ }
48
+
16
49
  /**
17
50
  * Represents a Spark wallet with minting capabilities.
18
51
  * This class extends the base SparkWallet with additional functionality for token minting,
@@ -41,11 +74,11 @@ declare class IssuerSparkWallet extends SparkWallet {
41
74
  balance: bigint;
42
75
  }>;
43
76
  /**
44
- * Retrieves information about the issuer's token.
77
+ * Retrieves metadata about the issuer's token.
45
78
  * @returns An object containing token information including public key, name, symbol, decimals, max supply, and freeze status
46
- * @throws {NetworkError} If the token info cannot be retrieved
79
+ * @throws {NetworkError} If the token metadata cannot be retrieved
47
80
  */
48
- getIssuerTokenInfo(): Promise<IssuerTokenInfo | null>;
81
+ getIssuerTokenMetadata(): Promise<IssuerTokenMetadata>;
49
82
  /**
50
83
  * Mints new tokens
51
84
  * @param tokenAmount - The amount of tokens to mint
@@ -97,4 +130,4 @@ declare class IssuerSparkWallet extends SparkWallet {
97
130
  announceTokenL1(tokenName: string, tokenTicker: string, decimals: number, maxSupply: bigint, isFreezable: boolean, feeRateSatsPerVb?: number): Promise<string>;
98
131
  }
99
132
 
100
- export { IssuerSparkWallet, type IssuerTokenInfo };
133
+ export { IssuerSparkWallet, type IssuerTokenMetadata, type TokenDistribution };
package/dist/index.d.ts CHANGED
@@ -1,18 +1,51 @@
1
- import { SparkWallet, SparkWalletProps } from '@buildonspark/spark-sdk';
1
+ import { SparkWallet, SparkWalletProps, ConfigOptions, SparkSigner } from '@buildonspark/spark-sdk';
2
2
  import { OutputWithPreviousTransactionData } from '@buildonspark/spark-sdk/proto/spark';
3
- import { ConfigOptions } from '@buildonspark/spark-sdk/services/wallet-config';
4
- import { TokenDistribution } from './types.js';
5
- import { SparkSigner } from '@buildonspark/spark-sdk/signer';
6
3
 
7
- type IssuerTokenInfo = {
4
+ /**
5
+ * Token metadata containing essential information about issuer's token.
6
+ * This is the wallet's internal representation with JavaScript-friendly types.
7
+ *
8
+ * rawTokenIdentifier: This is the raw binary token identifier - This is used to encode the human readable token identifier.
9
+ *
10
+ * tokenPublicKey: This is the hex-encoded public key of the token issuer - Same as issuerPublicKey.
11
+ *
12
+ * @example
13
+ * ```typescript
14
+ * const tokenMetadata: IssuerTokenMetadata = {
15
+ * rawTokenIdentifier: new Uint8Array([1, 2, 3]),
16
+ * tokenPublicKey: "0348fbb...",
17
+ * tokenName: "SparkToken",
18
+ * tokenTicker: "SPK",
19
+ * decimals: 8,
20
+ * maxSupply: 1000000n
21
+ * isFreezable: true
22
+ * };
23
+ * ```
24
+ */
25
+ type IssuerTokenMetadata = {
26
+ /** Raw binary token identifier - This is used to encode the human readable token identifier */
27
+ rawTokenIdentifier: Uint8Array;
28
+ /** Public key of the token issuer - Same as issuerPublicKey */
8
29
  tokenPublicKey: string;
30
+ /** Human-readable name of the token (e.g., SparkToken)*/
9
31
  tokenName: string;
10
- tokenSymbol: string;
11
- tokenDecimals: number;
32
+ /** Short ticker symbol for the token (e.g., "SPK") */
33
+ tokenTicker: string;
34
+ /** Number of decimal places for token amounts */
35
+ decimals: number;
36
+ /** Maximum supply of tokens that can ever be minted */
12
37
  maxSupply: bigint;
38
+ /** Whether the token is freezable */
13
39
  isFreezable: boolean;
14
- totalSupply: bigint;
15
40
  };
41
+ interface TokenDistribution {
42
+ totalCirculatingSupply: bigint;
43
+ totalIssued: bigint;
44
+ totalBurned: bigint;
45
+ numHoldingAddress: number;
46
+ numConfirmedTransactions: bigint;
47
+ }
48
+
16
49
  /**
17
50
  * Represents a Spark wallet with minting capabilities.
18
51
  * This class extends the base SparkWallet with additional functionality for token minting,
@@ -41,11 +74,11 @@ declare class IssuerSparkWallet extends SparkWallet {
41
74
  balance: bigint;
42
75
  }>;
43
76
  /**
44
- * Retrieves information about the issuer's token.
77
+ * Retrieves metadata about the issuer's token.
45
78
  * @returns An object containing token information including public key, name, symbol, decimals, max supply, and freeze status
46
- * @throws {NetworkError} If the token info cannot be retrieved
79
+ * @throws {NetworkError} If the token metadata cannot be retrieved
47
80
  */
48
- getIssuerTokenInfo(): Promise<IssuerTokenInfo | null>;
81
+ getIssuerTokenMetadata(): Promise<IssuerTokenMetadata>;
49
82
  /**
50
83
  * Mints new tokens
51
84
  * @param tokenAmount - The amount of tokens to mint
@@ -97,4 +130,4 @@ declare class IssuerSparkWallet extends SparkWallet {
97
130
  announceTokenL1(tokenName: string, tokenTicker: string, decimals: number, maxSupply: bigint, isFreezable: boolean, feeRateSatsPerVb?: number): Promise<string>;
98
131
  }
99
132
 
100
- export { IssuerSparkWallet, type IssuerTokenInfo };
133
+ export { IssuerSparkWallet, type IssuerTokenMetadata, type TokenDistribution };
package/dist/index.js CHANGED
@@ -11,7 +11,7 @@ import { isNode } from "@lightsparkdev/core";
11
11
  import {
12
12
  decodeSparkAddress,
13
13
  encodeSparkAddress
14
- } from "@buildonspark/spark-sdk/address";
14
+ } from "@buildonspark/spark-sdk";
15
15
  import {
16
16
  bytesToHex,
17
17
  bytesToNumberBE,
@@ -19,7 +19,10 @@ import {
19
19
  } from "@noble/curves/abstract/utils";
20
20
 
21
21
  // src/services/freeze.ts
22
- import { collectResponses } from "@buildonspark/spark-sdk/utils";
22
+ import {
23
+ NetworkError,
24
+ collectResponses
25
+ } from "@buildonspark/spark-sdk";
23
26
 
24
27
  // src/utils/token-hashing.ts
25
28
  import { sha256 } from "@scure/btc-signer/utils";
@@ -71,7 +74,6 @@ function hashFreezeTokensPayload(payload) {
71
74
  }
72
75
 
73
76
  // src/services/freeze.ts
74
- import { NetworkError } from "@buildonspark/spark-sdk";
75
77
  import { hexToBytes } from "@noble/curves/abstract/utils";
76
78
  var TokenFreezeService = class {
77
79
  config;
@@ -129,7 +131,7 @@ var TokenFreezeService = class {
129
131
  };
130
132
 
131
133
  // src/services/token-transactions.ts
132
- import { TokenTransactionService } from "@buildonspark/spark-sdk/token-transactions";
134
+ import { TokenTransactionService } from "@buildonspark/spark-sdk";
133
135
  import { numberToBytesBE } from "@noble/curves/abstract/utils";
134
136
  var IssuerTokenTransactionService = class extends TokenTransactionService {
135
137
  constructor(config, connectionManager) {
@@ -212,9 +214,9 @@ var IssuerSparkWallet = class _IssuerSparkWallet extends SparkWallet {
212
214
  "SparkIssuerWallet.getIssuerTokenBalance",
213
215
  this.getIssuerTokenBalance.bind(this)
214
216
  );
215
- this.getIssuerTokenInfo = this.wrapWithOtelSpan(
216
- "SparkIssuerWallet.getIssuerTokenInfo",
217
- this.getIssuerTokenInfo.bind(this)
217
+ this.getIssuerTokenMetadata = this.wrapWithOtelSpan(
218
+ "SparkIssuerWallet.getIssuerTokenMetadata",
219
+ this.getIssuerTokenMetadata.bind(this)
218
220
  );
219
221
  this.mintTokens = this.wrapWithOtelSpan(
220
222
  "SparkIssuerWallet.mintTokens",
@@ -272,29 +274,56 @@ var IssuerSparkWallet = class _IssuerSparkWallet extends SparkWallet {
272
274
  };
273
275
  }
274
276
  /**
275
- * Retrieves information about the issuer's token.
277
+ * Retrieves metadata about the issuer's token.
276
278
  * @returns An object containing token information including public key, name, symbol, decimals, max supply, and freeze status
277
- * @throws {NetworkError} If the token info cannot be retrieved
279
+ * @throws {NetworkError} If the token metadata cannot be retrieved
278
280
  */
279
- async getIssuerTokenInfo() {
280
- const lrc20Client = await this.lrc20ConnectionManager.createLrc20Client();
281
+ async getIssuerTokenMetadata() {
282
+ const issuerPublicKey = await super.getIdentityPublicKey();
283
+ if (this.tokenMetadata.has(issuerPublicKey)) {
284
+ const metadata = this.tokenMetadata.get(issuerPublicKey);
285
+ return {
286
+ tokenPublicKey: bytesToHex(metadata.issuerPublicKey),
287
+ rawTokenIdentifier: metadata.tokenIdentifier,
288
+ tokenName: metadata.tokenName,
289
+ tokenTicker: metadata.tokenTicker,
290
+ decimals: metadata.decimals,
291
+ maxSupply: bytesToNumberBE(metadata.maxSupply),
292
+ isFreezable: metadata.isFreezable
293
+ };
294
+ }
295
+ const sparkTokenClient = await this.connectionManager.createSparkTokenClient(
296
+ this.config.getCoordinatorAddress()
297
+ );
281
298
  try {
282
- const tokenInfo = await lrc20Client.getTokenPubkeyInfo({
283
- publicKeys: [hexToBytes2(await super.getIdentityPublicKey())]
299
+ const response = await sparkTokenClient.query_token_metadata({
300
+ issuerPublicKeys: Array.of(hexToBytes2(issuerPublicKey))
284
301
  });
285
- const info = tokenInfo.tokenPubkeyInfos[0];
302
+ if (response.tokenMetadata.length === 0) {
303
+ throw new ValidationError2(
304
+ "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.",
305
+ {
306
+ field: "tokenMetadata",
307
+ value: response.tokenMetadata,
308
+ expected: "non-empty array",
309
+ actualLength: response.tokenMetadata.length,
310
+ expectedLength: 1
311
+ }
312
+ );
313
+ }
314
+ const metadata = response.tokenMetadata[0];
315
+ this.tokenMetadata.set(issuerPublicKey, metadata);
286
316
  return {
287
- tokenPublicKey: bytesToHex(info.announcement.publicKey.publicKey),
288
- tokenName: info.announcement.name,
289
- tokenSymbol: info.announcement.symbol,
290
- tokenDecimals: Number(bytesToNumberBE(info.announcement.decimal)),
291
- isFreezable: info.announcement.isFreezable,
292
- maxSupply: bytesToNumberBE(info.announcement.maxSupply),
293
- totalSupply: bytesToNumberBE(info.totalSupply)
317
+ tokenPublicKey: bytesToHex(metadata.issuerPublicKey),
318
+ rawTokenIdentifier: metadata.tokenIdentifier,
319
+ tokenName: metadata.tokenName,
320
+ tokenTicker: metadata.tokenTicker,
321
+ decimals: metadata.decimals,
322
+ maxSupply: bytesToNumberBE(metadata.maxSupply),
323
+ isFreezable: metadata.isFreezable
294
324
  };
295
325
  } catch (error) {
296
- throw new NetworkError2("Failed to get token info", {
297
- operation: "getIssuerTokenInfo",
326
+ throw new NetworkError2("Failed to fetch token metadata", {
298
327
  errorCount: 1,
299
328
  errors: error instanceof Error ? error.message : String(error)
300
329
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@buildonspark/issuer-sdk",
3
- "version": "0.0.76",
3
+ "version": "0.0.78",
4
4
  "description": "Spark Issuer SDK for token issuance",
5
5
  "license": "Apache-2.0",
6
6
  "module": "./dist/index.js",
@@ -12,17 +12,9 @@
12
12
  "import": "./dist/index.js",
13
13
  "require": "./dist/index.cjs"
14
14
  },
15
- "./types": {
16
- "import": "./dist/types.js",
17
- "require": "./dist/types.cjs"
18
- },
19
15
  "./proto/spark": {
20
16
  "import": "./dist/proto/spark.js",
21
17
  "require": "./dist/proto/spark.cjs"
22
- },
23
- "./proto/lrc20": {
24
- "import": "./dist/proto/lrc20.js",
25
- "require": "./dist/proto/lrc20.cjs"
26
18
  }
27
19
  },
28
20
  "browser": {
@@ -56,14 +48,14 @@
56
48
  "postversion": "yarn build",
57
49
  "test-cmd": "node --experimental-vm-modules $(yarn bin jest) --no-cache --runInBand --detectOpenHandles --forceExit",
58
50
  "test": "echo \"Error: no tests yet\"",
59
- "test:integration": "yarn test-cmd src/tests/integration/*.test.ts",
51
+ "test:integration": "HERMETIC_TEST=true yarn test-cmd src/tests/integration/*.test.ts",
60
52
  "test:stress": "yarn test-cmd src/tests/stress/*.test.ts",
61
53
  "types:watch": "tsc-absolute --watch",
62
54
  "types": "tsc"
63
55
  },
64
56
  "dependencies": {
65
- "@buildonspark/lrc20-sdk": "0.0.58",
66
- "@buildonspark/spark-sdk": "0.1.45",
57
+ "@buildonspark/lrc20-sdk": "0.0.59",
58
+ "@buildonspark/spark-sdk": "0.1.47",
67
59
  "@lightsparkdev/core": "^1.4.2",
68
60
  "@noble/curves": "^1.8.0",
69
61
  "@scure/btc-signer": "^1.5.0",
package/src/index.ts CHANGED
@@ -1 +1,2 @@
1
1
  export * from "./issuer-wallet/issuer-spark-wallet.js";
2
+ export * from "./issuer-wallet/types.js";