@buildonspark/issuer-sdk 0.0.78 → 0.0.80
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 +18 -0
- package/dist/{chunk-5MYKP7NN.js → chunk-7B4B24XF.js} +4 -0
- package/dist/index.cjs +189 -24
- package/dist/index.d.cts +31 -2
- package/dist/index.d.ts +31 -2
- package/dist/index.js +185 -16
- package/dist/proto/spark.js +1 -1
- package/package.json +4 -4
- package/src/issuer-wallet/issuer-spark-wallet.ts +103 -10
- package/src/services/token-transactions.ts +36 -4
- package/src/tests/integration/spark.test.ts +64 -18
- package/src/tests/stress/transfers.test.ts +13 -6
- package/src/tests/token-create.test.ts +85 -0
- package/src/utils/create-validation.ts +92 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# @buildonspark/issuer-sdk
|
|
2
2
|
|
|
3
|
+
## 0.0.80
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- tokens changes
|
|
8
|
+
- Bech32mTokenIdentifier prefix change from "btk" -> "btkn"
|
|
9
|
+
|
|
10
|
+
- Updated dependencies
|
|
11
|
+
- @buildonspark/lrc20-sdk@0.0.60
|
|
12
|
+
- @buildonspark/spark-sdk@0.2.1
|
|
13
|
+
|
|
14
|
+
## 0.0.79
|
|
15
|
+
|
|
16
|
+
### Patch Changes
|
|
17
|
+
|
|
18
|
+
- Updated dependencies
|
|
19
|
+
- @buildonspark/spark-sdk@0.2.0
|
|
20
|
+
|
|
3
21
|
## 0.0.78
|
|
4
22
|
|
|
5
23
|
### Patch Changes
|
package/dist/index.cjs
CHANGED
|
@@ -40,9 +40,9 @@ 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_sdk4 = require("@buildonspark/spark-sdk");
|
|
44
|
-
var import_core = require("@lightsparkdev/core");
|
|
45
43
|
var import_spark_sdk5 = require("@buildonspark/spark-sdk");
|
|
44
|
+
var import_core = require("@lightsparkdev/core");
|
|
45
|
+
var import_spark_sdk6 = require("@buildonspark/spark-sdk");
|
|
46
46
|
var import_utils4 = require("@noble/curves/abstract/utils");
|
|
47
47
|
|
|
48
48
|
// src/services/freeze.ts
|
|
@@ -181,20 +181,21 @@ var IssuerTokenTransactionService = class extends import_spark_sdk3.TokenTransac
|
|
|
181
181
|
sparkOperatorIdentityPublicKeys: super.collectOperatorIdentityPublicKeys()
|
|
182
182
|
};
|
|
183
183
|
}
|
|
184
|
-
async constructMintTokenTransaction(
|
|
184
|
+
async constructMintTokenTransaction(rawTokenIdentifierBytes, issuerTokenPublicKey, tokenAmount) {
|
|
185
185
|
return {
|
|
186
186
|
version: 1,
|
|
187
187
|
network: this.config.getNetworkProto(),
|
|
188
188
|
tokenInputs: {
|
|
189
189
|
$case: "mintInput",
|
|
190
190
|
mintInput: {
|
|
191
|
-
issuerPublicKey:
|
|
191
|
+
issuerPublicKey: issuerTokenPublicKey,
|
|
192
|
+
tokenIdentifier: rawTokenIdentifierBytes
|
|
192
193
|
}
|
|
193
194
|
},
|
|
194
195
|
tokenOutputs: [
|
|
195
196
|
{
|
|
196
|
-
ownerPublicKey:
|
|
197
|
-
|
|
197
|
+
ownerPublicKey: issuerTokenPublicKey,
|
|
198
|
+
tokenIdentifier: rawTokenIdentifierBytes,
|
|
198
199
|
tokenAmount: (0, import_utils3.numberToBytesBE)(tokenAmount, 16)
|
|
199
200
|
}
|
|
200
201
|
],
|
|
@@ -203,12 +204,105 @@ var IssuerTokenTransactionService = class extends import_spark_sdk3.TokenTransac
|
|
|
203
204
|
expiryTime: void 0
|
|
204
205
|
};
|
|
205
206
|
}
|
|
207
|
+
async constructCreateTokenTransaction(tokenPublicKey, tokenName, tokenTicker, decimals, maxSupply, isFreezable) {
|
|
208
|
+
return {
|
|
209
|
+
version: 1,
|
|
210
|
+
network: this.config.getNetworkProto(),
|
|
211
|
+
tokenInputs: {
|
|
212
|
+
$case: "createInput",
|
|
213
|
+
createInput: {
|
|
214
|
+
issuerPublicKey: tokenPublicKey,
|
|
215
|
+
tokenName,
|
|
216
|
+
tokenTicker,
|
|
217
|
+
decimals,
|
|
218
|
+
maxSupply: (0, import_utils3.numberToBytesBE)(maxSupply, 16),
|
|
219
|
+
isFreezable
|
|
220
|
+
}
|
|
221
|
+
},
|
|
222
|
+
tokenOutputs: [],
|
|
223
|
+
clientCreatedTimestamp: /* @__PURE__ */ new Date(),
|
|
224
|
+
sparkOperatorIdentityPublicKeys: super.collectOperatorIdentityPublicKeys(),
|
|
225
|
+
expiryTime: void 0
|
|
226
|
+
};
|
|
227
|
+
}
|
|
206
228
|
};
|
|
207
229
|
|
|
208
230
|
// src/issuer-wallet/issuer-spark-wallet.ts
|
|
209
|
-
var
|
|
231
|
+
var import_spark_sdk7 = require("@buildonspark/spark-sdk");
|
|
232
|
+
|
|
233
|
+
// src/utils/create-validation.ts
|
|
234
|
+
var import_spark_sdk4 = require("@buildonspark/spark-sdk");
|
|
235
|
+
function isNfcNormalized(value) {
|
|
236
|
+
return value.normalize("NFC") === value;
|
|
237
|
+
}
|
|
238
|
+
var MIN_NAME_SIZE = 3;
|
|
239
|
+
var MAX_NAME_SIZE = 20;
|
|
240
|
+
var MIN_SYMBOL_SIZE = 3;
|
|
241
|
+
var MAX_SYMBOL_SIZE = 6;
|
|
242
|
+
var MAX_DECIMALS = 255;
|
|
243
|
+
var MAXIMUM_MAX_SUPPLY = (1n << 128n) - 1n;
|
|
244
|
+
function validateTokenParameters(tokenName, tokenTicker, decimals, maxSupply) {
|
|
245
|
+
if (!isNfcNormalized(tokenName)) {
|
|
246
|
+
throw new import_spark_sdk4.ValidationError("Token name must be NFC-normalised UTF-8", {
|
|
247
|
+
field: "tokenName",
|
|
248
|
+
value: tokenName,
|
|
249
|
+
expected: "NFC normalised string"
|
|
250
|
+
});
|
|
251
|
+
}
|
|
252
|
+
if (!isNfcNormalized(tokenTicker)) {
|
|
253
|
+
throw new import_spark_sdk4.ValidationError("Token ticker must be NFC-normalised UTF-8", {
|
|
254
|
+
field: "tokenTicker",
|
|
255
|
+
value: tokenTicker,
|
|
256
|
+
expected: "NFC normalised string"
|
|
257
|
+
});
|
|
258
|
+
}
|
|
259
|
+
const nameBytes = import_buffer.Buffer.from(tokenName, "utf-8").length;
|
|
260
|
+
if (nameBytes < MIN_NAME_SIZE || nameBytes > MAX_NAME_SIZE) {
|
|
261
|
+
throw new import_spark_sdk4.ValidationError(
|
|
262
|
+
`Token name must be between ${MIN_NAME_SIZE} and ${MAX_NAME_SIZE} bytes`,
|
|
263
|
+
{
|
|
264
|
+
field: "tokenName",
|
|
265
|
+
value: tokenName,
|
|
266
|
+
actualLength: nameBytes,
|
|
267
|
+
expected: `>=${MIN_NAME_SIZE} and <=${MAX_NAME_SIZE}`
|
|
268
|
+
}
|
|
269
|
+
);
|
|
270
|
+
}
|
|
271
|
+
const tickerBytes = import_buffer.Buffer.from(tokenTicker, "utf-8").length;
|
|
272
|
+
if (tickerBytes < MIN_SYMBOL_SIZE || tickerBytes > MAX_SYMBOL_SIZE) {
|
|
273
|
+
throw new import_spark_sdk4.ValidationError(
|
|
274
|
+
`Token ticker must be between ${MIN_SYMBOL_SIZE} and ${MAX_SYMBOL_SIZE} bytes`,
|
|
275
|
+
{
|
|
276
|
+
field: "tokenTicker",
|
|
277
|
+
value: tokenTicker,
|
|
278
|
+
actualLength: tickerBytes,
|
|
279
|
+
expected: `>=${MIN_SYMBOL_SIZE} and <=${MAX_SYMBOL_SIZE}`
|
|
280
|
+
}
|
|
281
|
+
);
|
|
282
|
+
}
|
|
283
|
+
if (!Number.isSafeInteger(decimals) || decimals < 0 || decimals > MAX_DECIMALS) {
|
|
284
|
+
throw new import_spark_sdk4.ValidationError(
|
|
285
|
+
`Decimals must be an integer between 0 and ${MAX_DECIMALS}`,
|
|
286
|
+
{
|
|
287
|
+
field: "decimals",
|
|
288
|
+
value: decimals,
|
|
289
|
+
expected: `>=0 and <=${MAX_DECIMALS}`
|
|
290
|
+
}
|
|
291
|
+
);
|
|
292
|
+
}
|
|
293
|
+
if (maxSupply < 0n || maxSupply > MAXIMUM_MAX_SUPPLY) {
|
|
294
|
+
throw new import_spark_sdk4.ValidationError(`maxSupply must be between 0 and 2^128-1`, {
|
|
295
|
+
field: "maxSupply",
|
|
296
|
+
value: maxSupply.toString(),
|
|
297
|
+
expected: `>=0 and <=${MAXIMUM_MAX_SUPPLY.toString()}`
|
|
298
|
+
});
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
// src/issuer-wallet/issuer-spark-wallet.ts
|
|
303
|
+
var import_spark_sdk8 = require("@buildonspark/spark-sdk");
|
|
210
304
|
var BURN_ADDRESS = "02".repeat(33);
|
|
211
|
-
var IssuerSparkWallet = class _IssuerSparkWallet extends
|
|
305
|
+
var IssuerSparkWallet = class _IssuerSparkWallet extends import_spark_sdk5.SparkWallet {
|
|
212
306
|
issuerTokenTransactionService;
|
|
213
307
|
tokenFreezeService;
|
|
214
308
|
tracerId = "issuer-sdk";
|
|
@@ -242,6 +336,10 @@ var IssuerSparkWallet = class _IssuerSparkWallet extends import_spark_sdk4.Spark
|
|
|
242
336
|
"SparkIssuerWallet.getIssuerTokenMetadata",
|
|
243
337
|
this.getIssuerTokenMetadata.bind(this)
|
|
244
338
|
);
|
|
339
|
+
this.getIssuerTokenIdentifier = this.wrapWithOtelSpan(
|
|
340
|
+
"SparkIssuerWallet.getIssuerTokenIdentifier",
|
|
341
|
+
this.getIssuerTokenIdentifier.bind(this)
|
|
342
|
+
);
|
|
245
343
|
this.mintTokens = this.wrapWithOtelSpan(
|
|
246
344
|
"SparkIssuerWallet.mintTokens",
|
|
247
345
|
this.mintTokens.bind(this)
|
|
@@ -290,22 +388,28 @@ var IssuerSparkWallet = class _IssuerSparkWallet extends import_spark_sdk4.Spark
|
|
|
290
388
|
);
|
|
291
389
|
if (!balanceObj.tokenBalances || issuerBalance === void 0) {
|
|
292
390
|
return {
|
|
391
|
+
tokenIdentifier: void 0,
|
|
293
392
|
balance: 0n
|
|
294
393
|
};
|
|
295
394
|
}
|
|
296
395
|
return {
|
|
396
|
+
tokenIdentifier: issuerBalance[0] ?? void 0,
|
|
297
397
|
balance: issuerBalance[1].balance
|
|
298
398
|
};
|
|
299
399
|
}
|
|
300
400
|
/**
|
|
301
|
-
* Retrieves
|
|
401
|
+
* Retrieves information about the issuer's token.
|
|
302
402
|
* @returns An object containing token information including public key, name, symbol, decimals, max supply, and freeze status
|
|
303
403
|
* @throws {NetworkError} If the token metadata cannot be retrieved
|
|
304
404
|
*/
|
|
305
405
|
async getIssuerTokenMetadata() {
|
|
306
406
|
const issuerPublicKey = await super.getIdentityPublicKey();
|
|
307
|
-
|
|
308
|
-
|
|
407
|
+
const tokenMetadata = this.tokenMetadata;
|
|
408
|
+
const cachedIssuerTokenMetadata = [...tokenMetadata.entries()].find(
|
|
409
|
+
([, metadata]) => (0, import_utils4.bytesToHex)(metadata.issuerPublicKey) === issuerPublicKey
|
|
410
|
+
);
|
|
411
|
+
if (cachedIssuerTokenMetadata !== void 0) {
|
|
412
|
+
const metadata = cachedIssuerTokenMetadata[1];
|
|
309
413
|
return {
|
|
310
414
|
tokenPublicKey: (0, import_utils4.bytesToHex)(metadata.issuerPublicKey),
|
|
311
415
|
rawTokenIdentifier: metadata.tokenIdentifier,
|
|
@@ -324,7 +428,7 @@ var IssuerSparkWallet = class _IssuerSparkWallet extends import_spark_sdk4.Spark
|
|
|
324
428
|
issuerPublicKeys: Array.of((0, import_utils4.hexToBytes)(issuerPublicKey))
|
|
325
429
|
});
|
|
326
430
|
if (response.tokenMetadata.length === 0) {
|
|
327
|
-
throw new
|
|
431
|
+
throw new import_spark_sdk5.ValidationError(
|
|
328
432
|
"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
433
|
{
|
|
330
434
|
field: "tokenMetadata",
|
|
@@ -336,7 +440,11 @@ var IssuerSparkWallet = class _IssuerSparkWallet extends import_spark_sdk4.Spark
|
|
|
336
440
|
);
|
|
337
441
|
}
|
|
338
442
|
const metadata = response.tokenMetadata[0];
|
|
339
|
-
|
|
443
|
+
const tokenIdentifier = (0, import_spark_sdk8.encodeBech32mTokenIdentifier)({
|
|
444
|
+
tokenIdentifier: metadata.tokenIdentifier,
|
|
445
|
+
network: this.config.getNetworkType()
|
|
446
|
+
});
|
|
447
|
+
this.tokenMetadata.set(tokenIdentifier, metadata);
|
|
340
448
|
return {
|
|
341
449
|
tokenPublicKey: (0, import_utils4.bytesToHex)(metadata.issuerPublicKey),
|
|
342
450
|
rawTokenIdentifier: metadata.tokenIdentifier,
|
|
@@ -347,28 +455,80 @@ var IssuerSparkWallet = class _IssuerSparkWallet extends import_spark_sdk4.Spark
|
|
|
347
455
|
isFreezable: metadata.isFreezable
|
|
348
456
|
};
|
|
349
457
|
} catch (error) {
|
|
350
|
-
throw new
|
|
458
|
+
throw new import_spark_sdk5.NetworkError("Failed to fetch token metadata", {
|
|
351
459
|
errorCount: 1,
|
|
352
460
|
errors: error instanceof Error ? error.message : String(error)
|
|
353
461
|
});
|
|
354
462
|
}
|
|
355
463
|
}
|
|
464
|
+
/**
|
|
465
|
+
* Retrieves the bech32m encoded token identifier for the issuer's token.
|
|
466
|
+
* @returns The bech32m encoded token identifier for the issuer's token
|
|
467
|
+
* @throws {NetworkError} If the token identifier cannot be retrieved
|
|
468
|
+
*/
|
|
469
|
+
async getIssuerTokenIdentifier() {
|
|
470
|
+
const tokenMetadata = await this.getIssuerTokenMetadata();
|
|
471
|
+
return (0, import_spark_sdk8.encodeBech32mTokenIdentifier)({
|
|
472
|
+
tokenIdentifier: tokenMetadata.rawTokenIdentifier,
|
|
473
|
+
network: this.config.getNetworkType()
|
|
474
|
+
});
|
|
475
|
+
}
|
|
476
|
+
/**
|
|
477
|
+
* Create a new token on Spark.
|
|
478
|
+
*
|
|
479
|
+
* @param params - Object containing token creation parameters.
|
|
480
|
+
* @param params.tokenName - The name of the token.
|
|
481
|
+
* @param params.tokenTicker - The ticker symbol for the token.
|
|
482
|
+
* @param params.decimals - The number of decimal places for the token.
|
|
483
|
+
* @param params.isFreezable - Whether the token can be frozen.
|
|
484
|
+
* @param [params.maxSupply=0n] - (Optional) The maximum supply of the token. Defaults to <code>0n</code>.
|
|
485
|
+
*
|
|
486
|
+
* @returns The transaction ID of the announcement.
|
|
487
|
+
*
|
|
488
|
+
* @throws {ValidationError} If `decimals` is not a safe integer or other validation fails.
|
|
489
|
+
* @throws {NetworkError} If the announcement transaction cannot be broadcast.
|
|
490
|
+
*/
|
|
491
|
+
async createToken({
|
|
492
|
+
tokenName,
|
|
493
|
+
tokenTicker,
|
|
494
|
+
decimals,
|
|
495
|
+
isFreezable,
|
|
496
|
+
maxSupply = 0n
|
|
497
|
+
}) {
|
|
498
|
+
validateTokenParameters(tokenName, tokenTicker, decimals, maxSupply);
|
|
499
|
+
const issuerPublicKey = await super.getIdentityPublicKey();
|
|
500
|
+
const tokenTransaction = await this.issuerTokenTransactionService.constructCreateTokenTransaction(
|
|
501
|
+
(0, import_utils4.hexToBytes)(issuerPublicKey),
|
|
502
|
+
tokenName,
|
|
503
|
+
tokenTicker,
|
|
504
|
+
decimals,
|
|
505
|
+
maxSupply,
|
|
506
|
+
isFreezable
|
|
507
|
+
);
|
|
508
|
+
return await this.issuerTokenTransactionService.broadcastTokenTransaction(
|
|
509
|
+
tokenTransaction
|
|
510
|
+
);
|
|
511
|
+
}
|
|
356
512
|
/**
|
|
357
513
|
* Mints new tokens
|
|
358
514
|
* @param tokenAmount - The amount of tokens to mint
|
|
359
515
|
* @returns The transaction ID of the mint operation
|
|
360
516
|
*/
|
|
361
517
|
async mintTokens(tokenAmount) {
|
|
362
|
-
const tokenPublicKey = await super.getIdentityPublicKey();
|
|
363
518
|
let tokenTransaction;
|
|
519
|
+
const issuerTokenPublicKey = await super.getIdentityPublicKey();
|
|
520
|
+
const issuerTokenPublicKeyBytes = (0, import_utils4.hexToBytes)(issuerTokenPublicKey);
|
|
521
|
+
const tokenMetadata = await this.getIssuerTokenMetadata();
|
|
522
|
+
const rawTokenIdentifier = tokenMetadata.rawTokenIdentifier;
|
|
364
523
|
if (this.config.getTokenTransactionVersion() === "V0") {
|
|
365
524
|
tokenTransaction = await this.issuerTokenTransactionService.constructMintTokenTransactionV0(
|
|
366
|
-
|
|
525
|
+
issuerTokenPublicKeyBytes,
|
|
367
526
|
tokenAmount
|
|
368
527
|
);
|
|
369
528
|
} else {
|
|
370
529
|
tokenTransaction = await this.issuerTokenTransactionService.constructMintTokenTransaction(
|
|
371
|
-
|
|
530
|
+
rawTokenIdentifier,
|
|
531
|
+
issuerTokenPublicKeyBytes,
|
|
372
532
|
tokenAmount
|
|
373
533
|
);
|
|
374
534
|
}
|
|
@@ -383,12 +543,16 @@ var IssuerSparkWallet = class _IssuerSparkWallet extends import_spark_sdk4.Spark
|
|
|
383
543
|
* @returns The transaction ID of the burn operation
|
|
384
544
|
*/
|
|
385
545
|
async burnTokens(tokenAmount, selectedOutputs) {
|
|
386
|
-
const burnAddress = (0,
|
|
546
|
+
const burnAddress = (0, import_spark_sdk6.encodeSparkAddress)({
|
|
387
547
|
identityPublicKey: BURN_ADDRESS,
|
|
388
548
|
network: this.config.getNetworkType()
|
|
389
549
|
});
|
|
550
|
+
const issuerTokenIdentifier = await this.getIssuerTokenIdentifier();
|
|
551
|
+
if (issuerTokenIdentifier === null) {
|
|
552
|
+
throw new import_spark_sdk5.ValidationError("Issuer token identifier not found");
|
|
553
|
+
}
|
|
390
554
|
return await this.transferTokens({
|
|
391
|
-
|
|
555
|
+
tokenIdentifier: issuerTokenIdentifier,
|
|
392
556
|
tokenAmount,
|
|
393
557
|
receiverSparkAddress: burnAddress,
|
|
394
558
|
selectedOutputs
|
|
@@ -402,7 +566,7 @@ var IssuerSparkWallet = class _IssuerSparkWallet extends import_spark_sdk4.Spark
|
|
|
402
566
|
async freezeTokens(sparkAddress) {
|
|
403
567
|
await this.syncTokenOutputs();
|
|
404
568
|
const tokenPublicKey = await super.getIdentityPublicKey();
|
|
405
|
-
const decodedOwnerPubkey = (0,
|
|
569
|
+
const decodedOwnerPubkey = (0, import_spark_sdk6.decodeSparkAddress)(
|
|
406
570
|
sparkAddress,
|
|
407
571
|
this.config.getNetworkType()
|
|
408
572
|
);
|
|
@@ -424,7 +588,7 @@ var IssuerSparkWallet = class _IssuerSparkWallet extends import_spark_sdk4.Spark
|
|
|
424
588
|
async unfreezeTokens(sparkAddress) {
|
|
425
589
|
await this.syncTokenOutputs();
|
|
426
590
|
const tokenPublicKey = await super.getIdentityPublicKey();
|
|
427
|
-
const decodedOwnerPubkey = (0,
|
|
591
|
+
const decodedOwnerPubkey = (0, import_spark_sdk6.decodeSparkAddress)(
|
|
428
592
|
sparkAddress,
|
|
429
593
|
this.config.getNetworkType()
|
|
430
594
|
);
|
|
@@ -443,7 +607,7 @@ var IssuerSparkWallet = class _IssuerSparkWallet extends import_spark_sdk4.Spark
|
|
|
443
607
|
* @throws {NotImplementedError} This feature is not yet supported
|
|
444
608
|
*/
|
|
445
609
|
async getIssuerTokenDistribution() {
|
|
446
|
-
throw new
|
|
610
|
+
throw new import_spark_sdk7.NotImplementedError("Token distribution is not yet supported");
|
|
447
611
|
}
|
|
448
612
|
/**
|
|
449
613
|
* Announces a new token on the L1 (Bitcoin) network.
|
|
@@ -458,8 +622,9 @@ var IssuerSparkWallet = class _IssuerSparkWallet extends import_spark_sdk4.Spark
|
|
|
458
622
|
* @throws {NetworkError} If the announcement transaction cannot be broadcast
|
|
459
623
|
*/
|
|
460
624
|
async announceTokenL1(tokenName, tokenTicker, decimals, maxSupply, isFreezable, feeRateSatsPerVb = 4) {
|
|
625
|
+
validateTokenParameters(tokenName, tokenTicker, decimals, maxSupply);
|
|
461
626
|
if (!Number.isSafeInteger(decimals)) {
|
|
462
|
-
throw new
|
|
627
|
+
throw new import_spark_sdk5.ValidationError("Decimals must be less than 2^53", {
|
|
463
628
|
field: "decimals",
|
|
464
629
|
value: decimals,
|
|
465
630
|
expected: "smaller or equal to " + Number.MAX_SAFE_INTEGER
|
|
@@ -485,7 +650,7 @@ var IssuerSparkWallet = class _IssuerSparkWallet extends import_spark_sdk4.Spark
|
|
|
485
650
|
);
|
|
486
651
|
return txId;
|
|
487
652
|
} catch (error) {
|
|
488
|
-
throw new
|
|
653
|
+
throw new import_spark_sdk5.NetworkError(
|
|
489
654
|
"Failed to broadcast announcement transaction on L1",
|
|
490
655
|
{
|
|
491
656
|
operation: "broadcastRawBtcTransaction",
|
package/dist/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { SparkWallet, SparkWalletProps, ConfigOptions, SparkSigner } from '@buildonspark/spark-sdk';
|
|
1
|
+
import { SparkWallet, SparkWalletProps, ConfigOptions, SparkSigner, Bech32mTokenIdentifier } from '@buildonspark/spark-sdk';
|
|
2
2
|
import { OutputWithPreviousTransactionData } from '@buildonspark/spark-sdk/proto/spark';
|
|
3
3
|
|
|
4
4
|
/**
|
|
@@ -71,14 +71,43 @@ declare class IssuerSparkWallet extends SparkWallet {
|
|
|
71
71
|
* @returns An object containing the token balance as a bigint
|
|
72
72
|
*/
|
|
73
73
|
getIssuerTokenBalance(): Promise<{
|
|
74
|
+
tokenIdentifier: Bech32mTokenIdentifier | undefined;
|
|
74
75
|
balance: bigint;
|
|
75
76
|
}>;
|
|
76
77
|
/**
|
|
77
|
-
* Retrieves
|
|
78
|
+
* Retrieves information about the issuer's token.
|
|
78
79
|
* @returns An object containing token information including public key, name, symbol, decimals, max supply, and freeze status
|
|
79
80
|
* @throws {NetworkError} If the token metadata cannot be retrieved
|
|
80
81
|
*/
|
|
81
82
|
getIssuerTokenMetadata(): Promise<IssuerTokenMetadata>;
|
|
83
|
+
/**
|
|
84
|
+
* Retrieves the bech32m encoded token identifier for the issuer's token.
|
|
85
|
+
* @returns The bech32m encoded token identifier for the issuer's token
|
|
86
|
+
* @throws {NetworkError} If the token identifier cannot be retrieved
|
|
87
|
+
*/
|
|
88
|
+
getIssuerTokenIdentifier(): Promise<Bech32mTokenIdentifier | null>;
|
|
89
|
+
/**
|
|
90
|
+
* Create a new token on Spark.
|
|
91
|
+
*
|
|
92
|
+
* @param params - Object containing token creation parameters.
|
|
93
|
+
* @param params.tokenName - The name of the token.
|
|
94
|
+
* @param params.tokenTicker - The ticker symbol for the token.
|
|
95
|
+
* @param params.decimals - The number of decimal places for the token.
|
|
96
|
+
* @param params.isFreezable - Whether the token can be frozen.
|
|
97
|
+
* @param [params.maxSupply=0n] - (Optional) The maximum supply of the token. Defaults to <code>0n</code>.
|
|
98
|
+
*
|
|
99
|
+
* @returns The transaction ID of the announcement.
|
|
100
|
+
*
|
|
101
|
+
* @throws {ValidationError} If `decimals` is not a safe integer or other validation fails.
|
|
102
|
+
* @throws {NetworkError} If the announcement transaction cannot be broadcast.
|
|
103
|
+
*/
|
|
104
|
+
createToken({ tokenName, tokenTicker, decimals, isFreezable, maxSupply, }: {
|
|
105
|
+
tokenName: string;
|
|
106
|
+
tokenTicker: string;
|
|
107
|
+
decimals: number;
|
|
108
|
+
isFreezable: boolean;
|
|
109
|
+
maxSupply?: bigint;
|
|
110
|
+
}): Promise<string>;
|
|
82
111
|
/**
|
|
83
112
|
* Mints new tokens
|
|
84
113
|
* @param tokenAmount - The amount of tokens to mint
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { SparkWallet, SparkWalletProps, ConfigOptions, SparkSigner } from '@buildonspark/spark-sdk';
|
|
1
|
+
import { SparkWallet, SparkWalletProps, ConfigOptions, SparkSigner, Bech32mTokenIdentifier } from '@buildonspark/spark-sdk';
|
|
2
2
|
import { OutputWithPreviousTransactionData } from '@buildonspark/spark-sdk/proto/spark';
|
|
3
3
|
|
|
4
4
|
/**
|
|
@@ -71,14 +71,43 @@ declare class IssuerSparkWallet extends SparkWallet {
|
|
|
71
71
|
* @returns An object containing the token balance as a bigint
|
|
72
72
|
*/
|
|
73
73
|
getIssuerTokenBalance(): Promise<{
|
|
74
|
+
tokenIdentifier: Bech32mTokenIdentifier | undefined;
|
|
74
75
|
balance: bigint;
|
|
75
76
|
}>;
|
|
76
77
|
/**
|
|
77
|
-
* Retrieves
|
|
78
|
+
* Retrieves information about the issuer's token.
|
|
78
79
|
* @returns An object containing token information including public key, name, symbol, decimals, max supply, and freeze status
|
|
79
80
|
* @throws {NetworkError} If the token metadata cannot be retrieved
|
|
80
81
|
*/
|
|
81
82
|
getIssuerTokenMetadata(): Promise<IssuerTokenMetadata>;
|
|
83
|
+
/**
|
|
84
|
+
* Retrieves the bech32m encoded token identifier for the issuer's token.
|
|
85
|
+
* @returns The bech32m encoded token identifier for the issuer's token
|
|
86
|
+
* @throws {NetworkError} If the token identifier cannot be retrieved
|
|
87
|
+
*/
|
|
88
|
+
getIssuerTokenIdentifier(): Promise<Bech32mTokenIdentifier | null>;
|
|
89
|
+
/**
|
|
90
|
+
* Create a new token on Spark.
|
|
91
|
+
*
|
|
92
|
+
* @param params - Object containing token creation parameters.
|
|
93
|
+
* @param params.tokenName - The name of the token.
|
|
94
|
+
* @param params.tokenTicker - The ticker symbol for the token.
|
|
95
|
+
* @param params.decimals - The number of decimal places for the token.
|
|
96
|
+
* @param params.isFreezable - Whether the token can be frozen.
|
|
97
|
+
* @param [params.maxSupply=0n] - (Optional) The maximum supply of the token. Defaults to <code>0n</code>.
|
|
98
|
+
*
|
|
99
|
+
* @returns The transaction ID of the announcement.
|
|
100
|
+
*
|
|
101
|
+
* @throws {ValidationError} If `decimals` is not a safe integer or other validation fails.
|
|
102
|
+
* @throws {NetworkError} If the announcement transaction cannot be broadcast.
|
|
103
|
+
*/
|
|
104
|
+
createToken({ tokenName, tokenTicker, decimals, isFreezable, maxSupply, }: {
|
|
105
|
+
tokenName: string;
|
|
106
|
+
tokenTicker: string;
|
|
107
|
+
decimals: number;
|
|
108
|
+
isFreezable: boolean;
|
|
109
|
+
maxSupply?: bigint;
|
|
110
|
+
}): Promise<string>;
|
|
82
111
|
/**
|
|
83
112
|
* Mints new tokens
|
|
84
113
|
* @param tokenAmount - The amount of tokens to mint
|