@buildonspark/issuer-sdk 0.0.41 → 0.0.42

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/dist/index.cjs CHANGED
@@ -456,6 +456,13 @@ var IssuerSparkWallet = class _IssuerSparkWallet extends import_spark_sdk3.Spark
456
456
  };
457
457
  }
458
458
  async getIssuerTokenActivity(pageSize = 100, cursor, operationTypes, beforeTimestamp, afterTimestamp) {
459
+ if (!Number.isSafeInteger(pageSize)) {
460
+ throw new import_spark_sdk3.ValidationError("Page size must be less than 2^53", {
461
+ field: "pageSize",
462
+ value: pageSize,
463
+ expected: "smaller or equal to " + Number.MAX_SAFE_INTEGER
464
+ });
465
+ }
459
466
  const lrc20Client = await this.lrc20ConnectionManager.createLrc20Client();
460
467
  try {
461
468
  const transactions = await lrc20Client.listTransactions({
@@ -479,6 +486,13 @@ var IssuerSparkWallet = class _IssuerSparkWallet extends import_spark_sdk3.Spark
479
486
  throw new import_spark_sdk4.NotImplementedError("Token distribution is not yet supported");
480
487
  }
481
488
  async announceTokenL1(tokenName, tokenTicker, decimals, maxSupply, isFreezable, feeRateSatsPerVb = 4) {
489
+ if (!Number.isSafeInteger(decimals)) {
490
+ throw new import_spark_sdk3.ValidationError("Decimals must be less than 2^53", {
491
+ field: "decimals",
492
+ value: decimals,
493
+ expected: "smaller or equal to " + Number.MAX_SAFE_INTEGER
494
+ });
495
+ }
482
496
  await this.lrc20Wallet.syncWallet();
483
497
  const tokenPublicKey = new import_lrc20_sdk2.TokenPubkey(this.lrc20Wallet.pubkey);
484
498
  const announcement = new import_lrc20_sdk2.TokenPubkeyAnnouncement(
package/dist/index.js CHANGED
@@ -4,7 +4,8 @@ import "./chunk-GB7N6I5O.js";
4
4
  import { TokenPubkey, TokenPubkeyAnnouncement } from "@buildonspark/lrc20-sdk";
5
5
  import {
6
6
  NetworkError as NetworkError2,
7
- SparkWallet
7
+ SparkWallet,
8
+ ValidationError as ValidationError2
8
9
  } from "@buildonspark/spark-sdk";
9
10
  import {
10
11
  decodeSparkAddress,
@@ -433,6 +434,13 @@ var IssuerSparkWallet = class _IssuerSparkWallet extends SparkWallet {
433
434
  };
434
435
  }
435
436
  async getIssuerTokenActivity(pageSize = 100, cursor, operationTypes, beforeTimestamp, afterTimestamp) {
437
+ if (!Number.isSafeInteger(pageSize)) {
438
+ throw new ValidationError2("Page size must be less than 2^53", {
439
+ field: "pageSize",
440
+ value: pageSize,
441
+ expected: "smaller or equal to " + Number.MAX_SAFE_INTEGER
442
+ });
443
+ }
436
444
  const lrc20Client = await this.lrc20ConnectionManager.createLrc20Client();
437
445
  try {
438
446
  const transactions = await lrc20Client.listTransactions({
@@ -456,6 +464,13 @@ var IssuerSparkWallet = class _IssuerSparkWallet extends SparkWallet {
456
464
  throw new NotImplementedError("Token distribution is not yet supported");
457
465
  }
458
466
  async announceTokenL1(tokenName, tokenTicker, decimals, maxSupply, isFreezable, feeRateSatsPerVb = 4) {
467
+ if (!Number.isSafeInteger(decimals)) {
468
+ throw new ValidationError2("Decimals must be less than 2^53", {
469
+ field: "decimals",
470
+ value: decimals,
471
+ expected: "smaller or equal to " + Number.MAX_SAFE_INTEGER
472
+ });
473
+ }
459
474
  await this.lrc20Wallet.syncWallet();
460
475
  const tokenPublicKey = new TokenPubkey(this.lrc20Wallet.pubkey);
461
476
  const announcement = new TokenPubkeyAnnouncement(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@buildonspark/issuer-sdk",
3
- "version": "0.0.41",
3
+ "version": "0.0.42",
4
4
  "description": "Spark Issuer SDK for token issuance",
5
5
  "license": "Apache-2.0",
6
6
  "module": "./dist/index.js",
@@ -54,8 +54,8 @@
54
54
  },
55
55
  "dependencies": {
56
56
  "@bufbuild/protobuf": "^2.2.5",
57
- "@buildonspark/lrc20-sdk": "0.0.38",
58
- "@buildonspark/spark-sdk": "0.1.10",
57
+ "@buildonspark/lrc20-sdk": "0.0.39",
58
+ "@buildonspark/spark-sdk": "0.1.11",
59
59
  "@noble/curves": "^1.8.0",
60
60
  "@scure/btc-signer": "^1.5.0",
61
61
  "bitcoinjs-lib": "^6.1.5",
@@ -7,6 +7,7 @@ import {
7
7
  NetworkError,
8
8
  SparkWallet,
9
9
  SparkWalletProps,
10
+ ValidationError,
10
11
  } from "@buildonspark/spark-sdk";
11
12
  import {
12
13
  decodeSparkAddress,
@@ -185,6 +186,14 @@ export class IssuerSparkWallet extends SparkWallet {
185
186
  beforeTimestamp?: Date,
186
187
  afterTimestamp?: Date,
187
188
  ): Promise<GetTokenActivityResponse> {
189
+ if (!Number.isSafeInteger(pageSize)) {
190
+ throw new ValidationError("Page size must be less than 2^53", {
191
+ field: "pageSize",
192
+ value: pageSize,
193
+ expected: "smaller or equal to " + Number.MAX_SAFE_INTEGER,
194
+ });
195
+ }
196
+
188
197
  const lrc20Client = await this.lrc20ConnectionManager.createLrc20Client();
189
198
 
190
199
  try {
@@ -219,8 +228,15 @@ export class IssuerSparkWallet extends SparkWallet {
219
228
  isFreezable: boolean,
220
229
  feeRateSatsPerVb: number = 4.0,
221
230
  ): Promise<string> {
222
- await this.lrc20Wallet!.syncWallet();
231
+ if (!Number.isSafeInteger(decimals)) {
232
+ throw new ValidationError("Decimals must be less than 2^53", {
233
+ field: "decimals",
234
+ value: decimals,
235
+ expected: "smaller or equal to " + Number.MAX_SAFE_INTEGER,
236
+ });
237
+ }
223
238
 
239
+ await this.lrc20Wallet!.syncWallet();
224
240
  const tokenPublicKey = new TokenPubkey(this.lrc20Wallet!.pubkey);
225
241
 
226
242
  const announcement = new TokenPubkeyAnnouncement(
@@ -30,13 +30,34 @@ describe("token integration tests", () => {
30
30
  },
31
31
  );
32
32
 
33
+ brokenTestFn(
34
+ "should fail when announce decimal is greater than 2^53",
35
+ async () => {
36
+ const tokenAmount: bigint = 1000n;
37
+ const { wallet } = await IssuerSparkWalletTesting.initialize({
38
+ options: LOCAL_WALLET_CONFIG_ECDSA,
39
+ });
40
+
41
+ await expect(
42
+ await fundAndAnnounce(
43
+ wallet,
44
+ tokenAmount,
45
+ 2 ** 53,
46
+ "TestToken",
47
+ "TT1",
48
+ false,
49
+ ),
50
+ ).rejects.toThrow();
51
+ },
52
+ );
53
+
33
54
  brokenTestFn("should fail when minting more than max supply", async () => {
34
55
  const tokenAmount: bigint = 1000n;
35
56
  const { wallet } = await IssuerSparkWalletTesting.initialize({
36
57
  options: LOCAL_WALLET_CONFIG_SCHNORR,
37
58
  });
38
59
 
39
- await fundAndAnnounce(wallet, 2n, "MaxSupplyToken", "MST");
60
+ await fundAndAnnounce(wallet, 2n, 0, "MaxSupplyToken", "MST");
40
61
  await expect(wallet.mintTokens(tokenAmount)).rejects.toThrow();
41
62
  });
42
63
 
@@ -50,7 +71,7 @@ describe("token integration tests", () => {
50
71
  options: LOCAL_WALLET_CONFIG_SCHNORR,
51
72
  });
52
73
 
53
- await fundAndAnnounce(wallet, 100000n, tokenName, tokenSymbol);
74
+ await fundAndAnnounce(wallet, 100000n, 0, tokenName, tokenSymbol);
54
75
 
55
76
  const publicKeyInfo = await wallet.getIssuerTokenInfo();
56
77
 
@@ -95,7 +116,13 @@ describe("token integration tests", () => {
95
116
  },
96
117
  );
97
118
 
98
- await fundAndAnnounce(issuerWallet, 100000n, "ECDSATransferToken", "ETT");
119
+ await fundAndAnnounce(
120
+ issuerWallet,
121
+ 100000n,
122
+ 0,
123
+ "ECDSATransferToken",
124
+ "ETT",
125
+ );
99
126
 
100
127
  await issuerWallet.mintTokens(tokenAmount);
101
128
  await issuerWallet.transferTokens({
@@ -128,7 +155,7 @@ describe("token integration tests", () => {
128
155
  options: LOCAL_WALLET_CONFIG_ECDSA,
129
156
  });
130
157
 
131
- await fundAndAnnounce(issuerWallet, 100000n, "MonitoringToken", "MOT");
158
+ await fundAndAnnounce(issuerWallet, 100000n, 0, "MonitoringToken", "MOT");
132
159
 
133
160
  await issuerWallet.mintTokens(tokenAmount);
134
161
  await issuerWallet.transferTokens({
@@ -175,6 +202,7 @@ describe("token integration tests", () => {
175
202
  await fundAndAnnounce(
176
203
  issuerWallet,
177
204
  100000n,
205
+ 0,
178
206
  "SchnorrTransferToken",
179
207
  "STT",
180
208
  );
@@ -207,7 +235,13 @@ describe("token integration tests", () => {
207
235
  options: LOCAL_WALLET_CONFIG_ECDSA,
208
236
  });
209
237
 
210
- await fundAndAnnounce(issuerWallet, 100000n, "ECDSAFreezeToken", "EFT");
238
+ await fundAndAnnounce(
239
+ issuerWallet,
240
+ 100000n,
241
+ 0,
242
+ "ECDSAFreezeToken",
243
+ "EFT",
244
+ );
211
245
  await issuerWallet.mintTokens(tokenAmount);
212
246
 
213
247
  // Check issuer balance after minting
@@ -261,7 +295,13 @@ describe("token integration tests", () => {
261
295
  options: LOCAL_WALLET_CONFIG_SCHNORR,
262
296
  });
263
297
 
264
- await fundAndAnnounce(issuerWallet, 100000n, "SchnorrFreezeToken", "SFT");
298
+ await fundAndAnnounce(
299
+ issuerWallet,
300
+ 100000n,
301
+ 0,
302
+ "SchnorrFreezeToken",
303
+ "SFT",
304
+ );
265
305
 
266
306
  await issuerWallet.mintTokens(tokenAmount);
267
307
 
@@ -315,7 +355,7 @@ describe("token integration tests", () => {
315
355
  options: LOCAL_WALLET_CONFIG_ECDSA,
316
356
  });
317
357
 
318
- await fundAndAnnounce(issuerWallet, 100000n, "ECDSABurnToken", "EBT");
358
+ await fundAndAnnounce(issuerWallet, 100000n, 0, "ECDSABurnToken", "EBT");
319
359
  await issuerWallet.mintTokens(tokenAmount);
320
360
 
321
361
  const issuerTokenBalance = (await issuerWallet.getIssuerTokenBalance())
@@ -340,7 +380,13 @@ describe("token integration tests", () => {
340
380
  options: LOCAL_WALLET_CONFIG_SCHNORR,
341
381
  });
342
382
 
343
- await fundAndAnnounce(issuerWallet, 100000n, "SchnorrBurnToken", "SBT");
383
+ await fundAndAnnounce(
384
+ issuerWallet,
385
+ 100000n,
386
+ 0,
387
+ "SchnorrBurnToken",
388
+ "SBT",
389
+ );
344
390
  await issuerWallet.mintTokens(tokenAmount);
345
391
 
346
392
  const issuerTokenBalance = (await issuerWallet.getIssuerTokenBalance())
@@ -373,8 +419,10 @@ describe("token integration tests", () => {
373
419
  await fundAndAnnounce(
374
420
  issuerWallet,
375
421
  100000n,
422
+ 0,
376
423
  "ECDSAFullCycleToken",
377
424
  "EFCT",
425
+ false,
378
426
  );
379
427
  await issuerWallet.mintTokens(tokenAmount);
380
428
 
@@ -445,6 +493,7 @@ describe("token integration tests", () => {
445
493
  await fundAndAnnounce(
446
494
  issuerWallet,
447
495
  100000n,
496
+ 0,
448
497
  "SchnorrFullCycleToken",
449
498
  "SFCT",
450
499
  );
@@ -506,8 +555,10 @@ describe("token integration tests", () => {
506
555
  async function fundAndAnnounce(
507
556
  wallet: IssuerSparkWallet,
508
557
  maxSupply: bigint = 100000n,
558
+ decimals: number = 0,
509
559
  tokenName: string = "TestToken1",
510
560
  tokenSymbol: string = "TT1",
561
+ isFreezable: boolean = false,
511
562
  ) {
512
563
  // Faucet funds to the Issuer wallet because announcing a token
513
564
  // requires ownership of an L1 UTXO.
@@ -522,9 +573,9 @@ async function fundAndAnnounce(
522
573
  const response = await wallet.announceTokenL1(
523
574
  tokenName,
524
575
  tokenSymbol,
525
- 0,
576
+ decimals,
526
577
  maxSupply,
527
- false,
578
+ isFreezable,
528
579
  );
529
580
  console.log("Announce token response:", response);
530
581
  } catch (error: any) {