@buildonspark/issuer-sdk 0.0.42 → 0.0.44
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 +63 -1
- package/dist/index.d.cts +67 -0
- package/dist/index.d.ts +67 -0
- package/dist/index.js +63 -1
- package/package.json +3 -3
- package/src/issuer-spark-wallet.ts +68 -1
package/dist/index.cjs
CHANGED
|
@@ -345,6 +345,11 @@ var BURN_ADDRESS = "02".repeat(33);
|
|
|
345
345
|
var IssuerSparkWallet = class _IssuerSparkWallet extends import_spark_sdk3.SparkWallet {
|
|
346
346
|
issuerTokenTransactionService;
|
|
347
347
|
tokenFreezeService;
|
|
348
|
+
/**
|
|
349
|
+
* Initializes a new IssuerSparkWallet instance.
|
|
350
|
+
* @param options - Configuration options for the wallet
|
|
351
|
+
* @returns An object containing the initialized wallet and initialization response
|
|
352
|
+
*/
|
|
348
353
|
static async initialize(options) {
|
|
349
354
|
const wallet = new _IssuerSparkWallet(options.options);
|
|
350
355
|
const initResponse = await wallet.initWallet(options.mnemonicOrSeed);
|
|
@@ -364,6 +369,10 @@ var IssuerSparkWallet = class _IssuerSparkWallet extends import_spark_sdk3.Spark
|
|
|
364
369
|
this.connectionManager
|
|
365
370
|
);
|
|
366
371
|
}
|
|
372
|
+
/**
|
|
373
|
+
* Gets the token balance for the issuer's token.
|
|
374
|
+
* @returns An object containing the token balance as a bigint
|
|
375
|
+
*/
|
|
367
376
|
async getIssuerTokenBalance() {
|
|
368
377
|
const publicKey = await super.getIdentityPublicKey();
|
|
369
378
|
const balanceObj = await this.getBalance();
|
|
@@ -376,6 +385,11 @@ var IssuerSparkWallet = class _IssuerSparkWallet extends import_spark_sdk3.Spark
|
|
|
376
385
|
balance: balanceObj.tokenBalances.get(publicKey).balance
|
|
377
386
|
};
|
|
378
387
|
}
|
|
388
|
+
/**
|
|
389
|
+
* Retrieves information about the issuer's token.
|
|
390
|
+
* @returns An object containing token information including public key, name, symbol, decimals, max supply, and freeze status
|
|
391
|
+
* @throws {NetworkError} If the token info cannot be retrieved
|
|
392
|
+
*/
|
|
379
393
|
async getIssuerTokenInfo() {
|
|
380
394
|
const lrc20Client = await this.lrc20ConnectionManager.createLrc20Client();
|
|
381
395
|
try {
|
|
@@ -399,6 +413,11 @@ var IssuerSparkWallet = class _IssuerSparkWallet extends import_spark_sdk3.Spark
|
|
|
399
413
|
});
|
|
400
414
|
}
|
|
401
415
|
}
|
|
416
|
+
/**
|
|
417
|
+
* Mints new tokens
|
|
418
|
+
* @param tokenAmount - The amount of tokens to mint
|
|
419
|
+
* @returns The transaction ID of the mint operation
|
|
420
|
+
*/
|
|
402
421
|
async mintTokens(tokenAmount) {
|
|
403
422
|
var tokenPublicKey = await super.getIdentityPublicKey();
|
|
404
423
|
const tokenTransaction = await this.issuerTokenTransactionService.constructMintTokenTransaction(
|
|
@@ -409,6 +428,12 @@ var IssuerSparkWallet = class _IssuerSparkWallet extends import_spark_sdk3.Spark
|
|
|
409
428
|
tokenTransaction
|
|
410
429
|
);
|
|
411
430
|
}
|
|
431
|
+
/**
|
|
432
|
+
* Burns issuer's tokens
|
|
433
|
+
* @param tokenAmount - The amount of tokens to burn
|
|
434
|
+
* @param selectedOutputs - Optional array of outputs to use for the burn operation
|
|
435
|
+
* @returns The transaction ID of the burn operation
|
|
436
|
+
*/
|
|
412
437
|
async burnTokens(tokenAmount, selectedOutputs) {
|
|
413
438
|
const burnAddress = (0, import_address.encodeSparkAddress)({
|
|
414
439
|
identityPublicKey: BURN_ADDRESS,
|
|
@@ -421,6 +446,11 @@ var IssuerSparkWallet = class _IssuerSparkWallet extends import_spark_sdk3.Spark
|
|
|
421
446
|
selectedOutputs
|
|
422
447
|
});
|
|
423
448
|
}
|
|
449
|
+
/**
|
|
450
|
+
* Freezes tokens associated with a specific Spark address.
|
|
451
|
+
* @param sparkAddress - The Spark address whose tokens should be frozen
|
|
452
|
+
* @returns An object containing the IDs of impacted outputs and the total amount of frozen tokens
|
|
453
|
+
*/
|
|
424
454
|
async freezeTokens(sparkAddress) {
|
|
425
455
|
await this.syncTokenOutputs();
|
|
426
456
|
const tokenPublicKey = await super.getIdentityPublicKey();
|
|
@@ -438,6 +468,11 @@ var IssuerSparkWallet = class _IssuerSparkWallet extends import_spark_sdk3.Spark
|
|
|
438
468
|
impactedTokenAmount: tokenAmount
|
|
439
469
|
};
|
|
440
470
|
}
|
|
471
|
+
/**
|
|
472
|
+
* Unfreezes previously frozen tokens associated with a specific Spark address.
|
|
473
|
+
* @param sparkAddress - The Spark address whose tokens should be unfrozen
|
|
474
|
+
* @returns An object containing the IDs of impacted outputs and the total amount of unfrozen tokens
|
|
475
|
+
*/
|
|
441
476
|
async unfreezeTokens(sparkAddress) {
|
|
442
477
|
await this.syncTokenOutputs();
|
|
443
478
|
const tokenPublicKey = await super.getIdentityPublicKey();
|
|
@@ -455,9 +490,20 @@ var IssuerSparkWallet = class _IssuerSparkWallet extends import_spark_sdk3.Spark
|
|
|
455
490
|
impactedTokenAmount: tokenAmount
|
|
456
491
|
};
|
|
457
492
|
}
|
|
493
|
+
/**
|
|
494
|
+
* Retrieves the activity history for the issuer's token.
|
|
495
|
+
* @param pageSize - The number of transactions to return per page (default: 100)
|
|
496
|
+
* @param cursor - Optional cursor for pagination
|
|
497
|
+
* @param operationTypes - Optional array of operation types to filter by
|
|
498
|
+
* @param beforeTimestamp - Optional timestamp to filter transactions before
|
|
499
|
+
* @param afterTimestamp - Optional timestamp to filter transactions after
|
|
500
|
+
* @returns An object containing the token activity data
|
|
501
|
+
* @throws {ValidationError} If pageSize is not a safe integer
|
|
502
|
+
* @throws {NetworkError} If the activity data cannot be retrieved
|
|
503
|
+
*/
|
|
458
504
|
async getIssuerTokenActivity(pageSize = 100, cursor, operationTypes, beforeTimestamp, afterTimestamp) {
|
|
459
505
|
if (!Number.isSafeInteger(pageSize)) {
|
|
460
|
-
throw new import_spark_sdk3.ValidationError("
|
|
506
|
+
throw new import_spark_sdk3.ValidationError("pageSize must be less than 2^53", {
|
|
461
507
|
field: "pageSize",
|
|
462
508
|
value: pageSize,
|
|
463
509
|
expected: "smaller or equal to " + Number.MAX_SAFE_INTEGER
|
|
@@ -482,9 +528,25 @@ var IssuerSparkWallet = class _IssuerSparkWallet extends import_spark_sdk3.Spark
|
|
|
482
528
|
});
|
|
483
529
|
}
|
|
484
530
|
}
|
|
531
|
+
/**
|
|
532
|
+
* Retrieves the distribution information for the issuer's token.
|
|
533
|
+
* @throws {NotImplementedError} This feature is not yet supported
|
|
534
|
+
*/
|
|
485
535
|
async getIssuerTokenDistribution() {
|
|
486
536
|
throw new import_spark_sdk4.NotImplementedError("Token distribution is not yet supported");
|
|
487
537
|
}
|
|
538
|
+
/**
|
|
539
|
+
* Announces a new token on the L1 (Bitcoin) network.
|
|
540
|
+
* @param tokenName - The name of the token
|
|
541
|
+
* @param tokenTicker - The ticker symbol for the token
|
|
542
|
+
* @param decimals - The number of decimal places for the token
|
|
543
|
+
* @param maxSupply - The maximum supply of the token
|
|
544
|
+
* @param isFreezable - Whether the token can be frozen
|
|
545
|
+
* @param feeRateSatsPerVb - The fee rate in satoshis per virtual byte (default: 4.0)
|
|
546
|
+
* @returns The transaction ID of the announcement
|
|
547
|
+
* @throws {ValidationError} If decimals is not a safe integer
|
|
548
|
+
* @throws {NetworkError} If the announcement transaction cannot be broadcast
|
|
549
|
+
*/
|
|
488
550
|
async announceTokenL1(tokenName, tokenTicker, decimals, maxSupply, isFreezable, feeRateSatsPerVb = 4) {
|
|
489
551
|
if (!Number.isSafeInteger(decimals)) {
|
|
490
552
|
throw new import_spark_sdk3.ValidationError("Decimals must be less than 2^53", {
|
package/dist/index.d.cts
CHANGED
|
@@ -12,30 +12,97 @@ type IssuerTokenInfo = {
|
|
|
12
12
|
maxSupply: bigint;
|
|
13
13
|
isFreezable: boolean;
|
|
14
14
|
};
|
|
15
|
+
/**
|
|
16
|
+
* Represents a Spark wallet with minting capabilities.
|
|
17
|
+
* This class extends the base SparkWallet with additional functionality for token minting,
|
|
18
|
+
* burning, and freezing operations.
|
|
19
|
+
*/
|
|
15
20
|
declare class IssuerSparkWallet extends SparkWallet {
|
|
16
21
|
private issuerTokenTransactionService;
|
|
17
22
|
private tokenFreezeService;
|
|
23
|
+
/**
|
|
24
|
+
* Initializes a new IssuerSparkWallet instance.
|
|
25
|
+
* @param options - Configuration options for the wallet
|
|
26
|
+
* @returns An object containing the initialized wallet and initialization response
|
|
27
|
+
*/
|
|
18
28
|
static initialize(options: SparkWalletProps): Promise<{
|
|
19
29
|
mnemonic?: string | undefined;
|
|
20
30
|
wallet: IssuerSparkWallet;
|
|
21
31
|
}>;
|
|
22
32
|
protected constructor(configOptions?: ConfigOptions);
|
|
33
|
+
/**
|
|
34
|
+
* Gets the token balance for the issuer's token.
|
|
35
|
+
* @returns An object containing the token balance as a bigint
|
|
36
|
+
*/
|
|
23
37
|
getIssuerTokenBalance(): Promise<{
|
|
24
38
|
balance: bigint;
|
|
25
39
|
}>;
|
|
40
|
+
/**
|
|
41
|
+
* Retrieves information about the issuer's token.
|
|
42
|
+
* @returns An object containing token information including public key, name, symbol, decimals, max supply, and freeze status
|
|
43
|
+
* @throws {NetworkError} If the token info cannot be retrieved
|
|
44
|
+
*/
|
|
26
45
|
getIssuerTokenInfo(): Promise<IssuerTokenInfo | null>;
|
|
46
|
+
/**
|
|
47
|
+
* Mints new tokens
|
|
48
|
+
* @param tokenAmount - The amount of tokens to mint
|
|
49
|
+
* @returns The transaction ID of the mint operation
|
|
50
|
+
*/
|
|
27
51
|
mintTokens(tokenAmount: bigint): Promise<string>;
|
|
52
|
+
/**
|
|
53
|
+
* Burns issuer's tokens
|
|
54
|
+
* @param tokenAmount - The amount of tokens to burn
|
|
55
|
+
* @param selectedOutputs - Optional array of outputs to use for the burn operation
|
|
56
|
+
* @returns The transaction ID of the burn operation
|
|
57
|
+
*/
|
|
28
58
|
burnTokens(tokenAmount: bigint, selectedOutputs?: OutputWithPreviousTransactionData[]): Promise<string>;
|
|
59
|
+
/**
|
|
60
|
+
* Freezes tokens associated with a specific Spark address.
|
|
61
|
+
* @param sparkAddress - The Spark address whose tokens should be frozen
|
|
62
|
+
* @returns An object containing the IDs of impacted outputs and the total amount of frozen tokens
|
|
63
|
+
*/
|
|
29
64
|
freezeTokens(sparkAddress: string): Promise<{
|
|
30
65
|
impactedOutputIds: string[];
|
|
31
66
|
impactedTokenAmount: bigint;
|
|
32
67
|
}>;
|
|
68
|
+
/**
|
|
69
|
+
* Unfreezes previously frozen tokens associated with a specific Spark address.
|
|
70
|
+
* @param sparkAddress - The Spark address whose tokens should be unfrozen
|
|
71
|
+
* @returns An object containing the IDs of impacted outputs and the total amount of unfrozen tokens
|
|
72
|
+
*/
|
|
33
73
|
unfreezeTokens(sparkAddress: string): Promise<{
|
|
34
74
|
impactedOutputIds: string[];
|
|
35
75
|
impactedTokenAmount: bigint;
|
|
36
76
|
}>;
|
|
77
|
+
/**
|
|
78
|
+
* Retrieves the activity history for the issuer's token.
|
|
79
|
+
* @param pageSize - The number of transactions to return per page (default: 100)
|
|
80
|
+
* @param cursor - Optional cursor for pagination
|
|
81
|
+
* @param operationTypes - Optional array of operation types to filter by
|
|
82
|
+
* @param beforeTimestamp - Optional timestamp to filter transactions before
|
|
83
|
+
* @param afterTimestamp - Optional timestamp to filter transactions after
|
|
84
|
+
* @returns An object containing the token activity data
|
|
85
|
+
* @throws {ValidationError} If pageSize is not a safe integer
|
|
86
|
+
* @throws {NetworkError} If the activity data cannot be retrieved
|
|
87
|
+
*/
|
|
37
88
|
getIssuerTokenActivity(pageSize?: number, cursor?: ListAllTokenTransactionsCursor, operationTypes?: OperationType[], beforeTimestamp?: Date, afterTimestamp?: Date): Promise<GetTokenActivityResponse>;
|
|
89
|
+
/**
|
|
90
|
+
* Retrieves the distribution information for the issuer's token.
|
|
91
|
+
* @throws {NotImplementedError} This feature is not yet supported
|
|
92
|
+
*/
|
|
38
93
|
getIssuerTokenDistribution(): Promise<TokenDistribution>;
|
|
94
|
+
/**
|
|
95
|
+
* Announces a new token on the L1 (Bitcoin) network.
|
|
96
|
+
* @param tokenName - The name of the token
|
|
97
|
+
* @param tokenTicker - The ticker symbol for the token
|
|
98
|
+
* @param decimals - The number of decimal places for the token
|
|
99
|
+
* @param maxSupply - The maximum supply of the token
|
|
100
|
+
* @param isFreezable - Whether the token can be frozen
|
|
101
|
+
* @param feeRateSatsPerVb - The fee rate in satoshis per virtual byte (default: 4.0)
|
|
102
|
+
* @returns The transaction ID of the announcement
|
|
103
|
+
* @throws {ValidationError} If decimals is not a safe integer
|
|
104
|
+
* @throws {NetworkError} If the announcement transaction cannot be broadcast
|
|
105
|
+
*/
|
|
39
106
|
announceTokenL1(tokenName: string, tokenTicker: string, decimals: number, maxSupply: bigint, isFreezable: boolean, feeRateSatsPerVb?: number): Promise<string>;
|
|
40
107
|
}
|
|
41
108
|
|
package/dist/index.d.ts
CHANGED
|
@@ -12,30 +12,97 @@ type IssuerTokenInfo = {
|
|
|
12
12
|
maxSupply: bigint;
|
|
13
13
|
isFreezable: boolean;
|
|
14
14
|
};
|
|
15
|
+
/**
|
|
16
|
+
* Represents a Spark wallet with minting capabilities.
|
|
17
|
+
* This class extends the base SparkWallet with additional functionality for token minting,
|
|
18
|
+
* burning, and freezing operations.
|
|
19
|
+
*/
|
|
15
20
|
declare class IssuerSparkWallet extends SparkWallet {
|
|
16
21
|
private issuerTokenTransactionService;
|
|
17
22
|
private tokenFreezeService;
|
|
23
|
+
/**
|
|
24
|
+
* Initializes a new IssuerSparkWallet instance.
|
|
25
|
+
* @param options - Configuration options for the wallet
|
|
26
|
+
* @returns An object containing the initialized wallet and initialization response
|
|
27
|
+
*/
|
|
18
28
|
static initialize(options: SparkWalletProps): Promise<{
|
|
19
29
|
mnemonic?: string | undefined;
|
|
20
30
|
wallet: IssuerSparkWallet;
|
|
21
31
|
}>;
|
|
22
32
|
protected constructor(configOptions?: ConfigOptions);
|
|
33
|
+
/**
|
|
34
|
+
* Gets the token balance for the issuer's token.
|
|
35
|
+
* @returns An object containing the token balance as a bigint
|
|
36
|
+
*/
|
|
23
37
|
getIssuerTokenBalance(): Promise<{
|
|
24
38
|
balance: bigint;
|
|
25
39
|
}>;
|
|
40
|
+
/**
|
|
41
|
+
* Retrieves information about the issuer's token.
|
|
42
|
+
* @returns An object containing token information including public key, name, symbol, decimals, max supply, and freeze status
|
|
43
|
+
* @throws {NetworkError} If the token info cannot be retrieved
|
|
44
|
+
*/
|
|
26
45
|
getIssuerTokenInfo(): Promise<IssuerTokenInfo | null>;
|
|
46
|
+
/**
|
|
47
|
+
* Mints new tokens
|
|
48
|
+
* @param tokenAmount - The amount of tokens to mint
|
|
49
|
+
* @returns The transaction ID of the mint operation
|
|
50
|
+
*/
|
|
27
51
|
mintTokens(tokenAmount: bigint): Promise<string>;
|
|
52
|
+
/**
|
|
53
|
+
* Burns issuer's tokens
|
|
54
|
+
* @param tokenAmount - The amount of tokens to burn
|
|
55
|
+
* @param selectedOutputs - Optional array of outputs to use for the burn operation
|
|
56
|
+
* @returns The transaction ID of the burn operation
|
|
57
|
+
*/
|
|
28
58
|
burnTokens(tokenAmount: bigint, selectedOutputs?: OutputWithPreviousTransactionData[]): Promise<string>;
|
|
59
|
+
/**
|
|
60
|
+
* Freezes tokens associated with a specific Spark address.
|
|
61
|
+
* @param sparkAddress - The Spark address whose tokens should be frozen
|
|
62
|
+
* @returns An object containing the IDs of impacted outputs and the total amount of frozen tokens
|
|
63
|
+
*/
|
|
29
64
|
freezeTokens(sparkAddress: string): Promise<{
|
|
30
65
|
impactedOutputIds: string[];
|
|
31
66
|
impactedTokenAmount: bigint;
|
|
32
67
|
}>;
|
|
68
|
+
/**
|
|
69
|
+
* Unfreezes previously frozen tokens associated with a specific Spark address.
|
|
70
|
+
* @param sparkAddress - The Spark address whose tokens should be unfrozen
|
|
71
|
+
* @returns An object containing the IDs of impacted outputs and the total amount of unfrozen tokens
|
|
72
|
+
*/
|
|
33
73
|
unfreezeTokens(sparkAddress: string): Promise<{
|
|
34
74
|
impactedOutputIds: string[];
|
|
35
75
|
impactedTokenAmount: bigint;
|
|
36
76
|
}>;
|
|
77
|
+
/**
|
|
78
|
+
* Retrieves the activity history for the issuer's token.
|
|
79
|
+
* @param pageSize - The number of transactions to return per page (default: 100)
|
|
80
|
+
* @param cursor - Optional cursor for pagination
|
|
81
|
+
* @param operationTypes - Optional array of operation types to filter by
|
|
82
|
+
* @param beforeTimestamp - Optional timestamp to filter transactions before
|
|
83
|
+
* @param afterTimestamp - Optional timestamp to filter transactions after
|
|
84
|
+
* @returns An object containing the token activity data
|
|
85
|
+
* @throws {ValidationError} If pageSize is not a safe integer
|
|
86
|
+
* @throws {NetworkError} If the activity data cannot be retrieved
|
|
87
|
+
*/
|
|
37
88
|
getIssuerTokenActivity(pageSize?: number, cursor?: ListAllTokenTransactionsCursor, operationTypes?: OperationType[], beforeTimestamp?: Date, afterTimestamp?: Date): Promise<GetTokenActivityResponse>;
|
|
89
|
+
/**
|
|
90
|
+
* Retrieves the distribution information for the issuer's token.
|
|
91
|
+
* @throws {NotImplementedError} This feature is not yet supported
|
|
92
|
+
*/
|
|
38
93
|
getIssuerTokenDistribution(): Promise<TokenDistribution>;
|
|
94
|
+
/**
|
|
95
|
+
* Announces a new token on the L1 (Bitcoin) network.
|
|
96
|
+
* @param tokenName - The name of the token
|
|
97
|
+
* @param tokenTicker - The ticker symbol for the token
|
|
98
|
+
* @param decimals - The number of decimal places for the token
|
|
99
|
+
* @param maxSupply - The maximum supply of the token
|
|
100
|
+
* @param isFreezable - Whether the token can be frozen
|
|
101
|
+
* @param feeRateSatsPerVb - The fee rate in satoshis per virtual byte (default: 4.0)
|
|
102
|
+
* @returns The transaction ID of the announcement
|
|
103
|
+
* @throws {ValidationError} If decimals is not a safe integer
|
|
104
|
+
* @throws {NetworkError} If the announcement transaction cannot be broadcast
|
|
105
|
+
*/
|
|
39
106
|
announceTokenL1(tokenName: string, tokenTicker: string, decimals: number, maxSupply: bigint, isFreezable: boolean, feeRateSatsPerVb?: number): Promise<string>;
|
|
40
107
|
}
|
|
41
108
|
|
package/dist/index.js
CHANGED
|
@@ -323,6 +323,11 @@ var BURN_ADDRESS = "02".repeat(33);
|
|
|
323
323
|
var IssuerSparkWallet = class _IssuerSparkWallet extends SparkWallet {
|
|
324
324
|
issuerTokenTransactionService;
|
|
325
325
|
tokenFreezeService;
|
|
326
|
+
/**
|
|
327
|
+
* Initializes a new IssuerSparkWallet instance.
|
|
328
|
+
* @param options - Configuration options for the wallet
|
|
329
|
+
* @returns An object containing the initialized wallet and initialization response
|
|
330
|
+
*/
|
|
326
331
|
static async initialize(options) {
|
|
327
332
|
const wallet = new _IssuerSparkWallet(options.options);
|
|
328
333
|
const initResponse = await wallet.initWallet(options.mnemonicOrSeed);
|
|
@@ -342,6 +347,10 @@ var IssuerSparkWallet = class _IssuerSparkWallet extends SparkWallet {
|
|
|
342
347
|
this.connectionManager
|
|
343
348
|
);
|
|
344
349
|
}
|
|
350
|
+
/**
|
|
351
|
+
* Gets the token balance for the issuer's token.
|
|
352
|
+
* @returns An object containing the token balance as a bigint
|
|
353
|
+
*/
|
|
345
354
|
async getIssuerTokenBalance() {
|
|
346
355
|
const publicKey = await super.getIdentityPublicKey();
|
|
347
356
|
const balanceObj = await this.getBalance();
|
|
@@ -354,6 +363,11 @@ var IssuerSparkWallet = class _IssuerSparkWallet extends SparkWallet {
|
|
|
354
363
|
balance: balanceObj.tokenBalances.get(publicKey).balance
|
|
355
364
|
};
|
|
356
365
|
}
|
|
366
|
+
/**
|
|
367
|
+
* Retrieves information about the issuer's token.
|
|
368
|
+
* @returns An object containing token information including public key, name, symbol, decimals, max supply, and freeze status
|
|
369
|
+
* @throws {NetworkError} If the token info cannot be retrieved
|
|
370
|
+
*/
|
|
357
371
|
async getIssuerTokenInfo() {
|
|
358
372
|
const lrc20Client = await this.lrc20ConnectionManager.createLrc20Client();
|
|
359
373
|
try {
|
|
@@ -377,6 +391,11 @@ var IssuerSparkWallet = class _IssuerSparkWallet extends SparkWallet {
|
|
|
377
391
|
});
|
|
378
392
|
}
|
|
379
393
|
}
|
|
394
|
+
/**
|
|
395
|
+
* Mints new tokens
|
|
396
|
+
* @param tokenAmount - The amount of tokens to mint
|
|
397
|
+
* @returns The transaction ID of the mint operation
|
|
398
|
+
*/
|
|
380
399
|
async mintTokens(tokenAmount) {
|
|
381
400
|
var tokenPublicKey = await super.getIdentityPublicKey();
|
|
382
401
|
const tokenTransaction = await this.issuerTokenTransactionService.constructMintTokenTransaction(
|
|
@@ -387,6 +406,12 @@ var IssuerSparkWallet = class _IssuerSparkWallet extends SparkWallet {
|
|
|
387
406
|
tokenTransaction
|
|
388
407
|
);
|
|
389
408
|
}
|
|
409
|
+
/**
|
|
410
|
+
* Burns issuer's tokens
|
|
411
|
+
* @param tokenAmount - The amount of tokens to burn
|
|
412
|
+
* @param selectedOutputs - Optional array of outputs to use for the burn operation
|
|
413
|
+
* @returns The transaction ID of the burn operation
|
|
414
|
+
*/
|
|
390
415
|
async burnTokens(tokenAmount, selectedOutputs) {
|
|
391
416
|
const burnAddress = encodeSparkAddress({
|
|
392
417
|
identityPublicKey: BURN_ADDRESS,
|
|
@@ -399,6 +424,11 @@ var IssuerSparkWallet = class _IssuerSparkWallet extends SparkWallet {
|
|
|
399
424
|
selectedOutputs
|
|
400
425
|
});
|
|
401
426
|
}
|
|
427
|
+
/**
|
|
428
|
+
* Freezes tokens associated with a specific Spark address.
|
|
429
|
+
* @param sparkAddress - The Spark address whose tokens should be frozen
|
|
430
|
+
* @returns An object containing the IDs of impacted outputs and the total amount of frozen tokens
|
|
431
|
+
*/
|
|
402
432
|
async freezeTokens(sparkAddress) {
|
|
403
433
|
await this.syncTokenOutputs();
|
|
404
434
|
const tokenPublicKey = await super.getIdentityPublicKey();
|
|
@@ -416,6 +446,11 @@ var IssuerSparkWallet = class _IssuerSparkWallet extends SparkWallet {
|
|
|
416
446
|
impactedTokenAmount: tokenAmount
|
|
417
447
|
};
|
|
418
448
|
}
|
|
449
|
+
/**
|
|
450
|
+
* Unfreezes previously frozen tokens associated with a specific Spark address.
|
|
451
|
+
* @param sparkAddress - The Spark address whose tokens should be unfrozen
|
|
452
|
+
* @returns An object containing the IDs of impacted outputs and the total amount of unfrozen tokens
|
|
453
|
+
*/
|
|
419
454
|
async unfreezeTokens(sparkAddress) {
|
|
420
455
|
await this.syncTokenOutputs();
|
|
421
456
|
const tokenPublicKey = await super.getIdentityPublicKey();
|
|
@@ -433,9 +468,20 @@ var IssuerSparkWallet = class _IssuerSparkWallet extends SparkWallet {
|
|
|
433
468
|
impactedTokenAmount: tokenAmount
|
|
434
469
|
};
|
|
435
470
|
}
|
|
471
|
+
/**
|
|
472
|
+
* Retrieves the activity history for the issuer's token.
|
|
473
|
+
* @param pageSize - The number of transactions to return per page (default: 100)
|
|
474
|
+
* @param cursor - Optional cursor for pagination
|
|
475
|
+
* @param operationTypes - Optional array of operation types to filter by
|
|
476
|
+
* @param beforeTimestamp - Optional timestamp to filter transactions before
|
|
477
|
+
* @param afterTimestamp - Optional timestamp to filter transactions after
|
|
478
|
+
* @returns An object containing the token activity data
|
|
479
|
+
* @throws {ValidationError} If pageSize is not a safe integer
|
|
480
|
+
* @throws {NetworkError} If the activity data cannot be retrieved
|
|
481
|
+
*/
|
|
436
482
|
async getIssuerTokenActivity(pageSize = 100, cursor, operationTypes, beforeTimestamp, afterTimestamp) {
|
|
437
483
|
if (!Number.isSafeInteger(pageSize)) {
|
|
438
|
-
throw new ValidationError2("
|
|
484
|
+
throw new ValidationError2("pageSize must be less than 2^53", {
|
|
439
485
|
field: "pageSize",
|
|
440
486
|
value: pageSize,
|
|
441
487
|
expected: "smaller or equal to " + Number.MAX_SAFE_INTEGER
|
|
@@ -460,9 +506,25 @@ var IssuerSparkWallet = class _IssuerSparkWallet extends SparkWallet {
|
|
|
460
506
|
});
|
|
461
507
|
}
|
|
462
508
|
}
|
|
509
|
+
/**
|
|
510
|
+
* Retrieves the distribution information for the issuer's token.
|
|
511
|
+
* @throws {NotImplementedError} This feature is not yet supported
|
|
512
|
+
*/
|
|
463
513
|
async getIssuerTokenDistribution() {
|
|
464
514
|
throw new NotImplementedError("Token distribution is not yet supported");
|
|
465
515
|
}
|
|
516
|
+
/**
|
|
517
|
+
* Announces a new token on the L1 (Bitcoin) network.
|
|
518
|
+
* @param tokenName - The name of the token
|
|
519
|
+
* @param tokenTicker - The ticker symbol for the token
|
|
520
|
+
* @param decimals - The number of decimal places for the token
|
|
521
|
+
* @param maxSupply - The maximum supply of the token
|
|
522
|
+
* @param isFreezable - Whether the token can be frozen
|
|
523
|
+
* @param feeRateSatsPerVb - The fee rate in satoshis per virtual byte (default: 4.0)
|
|
524
|
+
* @returns The transaction ID of the announcement
|
|
525
|
+
* @throws {ValidationError} If decimals is not a safe integer
|
|
526
|
+
* @throws {NetworkError} If the announcement transaction cannot be broadcast
|
|
527
|
+
*/
|
|
466
528
|
async announceTokenL1(tokenName, tokenTicker, decimals, maxSupply, isFreezable, feeRateSatsPerVb = 4) {
|
|
467
529
|
if (!Number.isSafeInteger(decimals)) {
|
|
468
530
|
throw new ValidationError2("Decimals must be less than 2^53", {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@buildonspark/issuer-sdk",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.44",
|
|
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.
|
|
58
|
-
"@buildonspark/spark-sdk": "0.1.
|
|
57
|
+
"@buildonspark/lrc20-sdk": "0.0.41",
|
|
58
|
+
"@buildonspark/spark-sdk": "0.1.13",
|
|
59
59
|
"@noble/curves": "^1.8.0",
|
|
60
60
|
"@scure/btc-signer": "^1.5.0",
|
|
61
61
|
"bitcoinjs-lib": "^6.1.5",
|
|
@@ -37,10 +37,20 @@ export type IssuerTokenInfo = {
|
|
|
37
37
|
isFreezable: boolean;
|
|
38
38
|
};
|
|
39
39
|
|
|
40
|
+
/**
|
|
41
|
+
* Represents a Spark wallet with minting capabilities.
|
|
42
|
+
* This class extends the base SparkWallet with additional functionality for token minting,
|
|
43
|
+
* burning, and freezing operations.
|
|
44
|
+
*/
|
|
40
45
|
export class IssuerSparkWallet extends SparkWallet {
|
|
41
46
|
private issuerTokenTransactionService: IssuerTokenTransactionService;
|
|
42
47
|
private tokenFreezeService: TokenFreezeService;
|
|
43
48
|
|
|
49
|
+
/**
|
|
50
|
+
* Initializes a new IssuerSparkWallet instance.
|
|
51
|
+
* @param options - Configuration options for the wallet
|
|
52
|
+
* @returns An object containing the initialized wallet and initialization response
|
|
53
|
+
*/
|
|
44
54
|
public static async initialize(options: SparkWalletProps) {
|
|
45
55
|
const wallet = new IssuerSparkWallet(options.options);
|
|
46
56
|
|
|
@@ -63,6 +73,10 @@ export class IssuerSparkWallet extends SparkWallet {
|
|
|
63
73
|
);
|
|
64
74
|
}
|
|
65
75
|
|
|
76
|
+
/**
|
|
77
|
+
* Gets the token balance for the issuer's token.
|
|
78
|
+
* @returns An object containing the token balance as a bigint
|
|
79
|
+
*/
|
|
66
80
|
public async getIssuerTokenBalance(): Promise<{
|
|
67
81
|
balance: bigint;
|
|
68
82
|
}> {
|
|
@@ -79,6 +93,11 @@ export class IssuerSparkWallet extends SparkWallet {
|
|
|
79
93
|
};
|
|
80
94
|
}
|
|
81
95
|
|
|
96
|
+
/**
|
|
97
|
+
* Retrieves information about the issuer's token.
|
|
98
|
+
* @returns An object containing token information including public key, name, symbol, decimals, max supply, and freeze status
|
|
99
|
+
* @throws {NetworkError} If the token info cannot be retrieved
|
|
100
|
+
*/
|
|
82
101
|
public async getIssuerTokenInfo(): Promise<IssuerTokenInfo | null> {
|
|
83
102
|
const lrc20Client = await this.lrc20ConnectionManager.createLrc20Client();
|
|
84
103
|
|
|
@@ -105,6 +124,11 @@ export class IssuerSparkWallet extends SparkWallet {
|
|
|
105
124
|
}
|
|
106
125
|
}
|
|
107
126
|
|
|
127
|
+
/**
|
|
128
|
+
* Mints new tokens
|
|
129
|
+
* @param tokenAmount - The amount of tokens to mint
|
|
130
|
+
* @returns The transaction ID of the mint operation
|
|
131
|
+
*/
|
|
108
132
|
public async mintTokens(tokenAmount: bigint): Promise<string> {
|
|
109
133
|
var tokenPublicKey = await super.getIdentityPublicKey();
|
|
110
134
|
|
|
@@ -119,6 +143,12 @@ export class IssuerSparkWallet extends SparkWallet {
|
|
|
119
143
|
);
|
|
120
144
|
}
|
|
121
145
|
|
|
146
|
+
/**
|
|
147
|
+
* Burns issuer's tokens
|
|
148
|
+
* @param tokenAmount - The amount of tokens to burn
|
|
149
|
+
* @param selectedOutputs - Optional array of outputs to use for the burn operation
|
|
150
|
+
* @returns The transaction ID of the burn operation
|
|
151
|
+
*/
|
|
122
152
|
public async burnTokens(
|
|
123
153
|
tokenAmount: bigint,
|
|
124
154
|
selectedOutputs?: OutputWithPreviousTransactionData[],
|
|
@@ -135,6 +165,11 @@ export class IssuerSparkWallet extends SparkWallet {
|
|
|
135
165
|
});
|
|
136
166
|
}
|
|
137
167
|
|
|
168
|
+
/**
|
|
169
|
+
* Freezes tokens associated with a specific Spark address.
|
|
170
|
+
* @param sparkAddress - The Spark address whose tokens should be frozen
|
|
171
|
+
* @returns An object containing the IDs of impacted outputs and the total amount of frozen tokens
|
|
172
|
+
*/
|
|
138
173
|
public async freezeTokens(
|
|
139
174
|
sparkAddress: string,
|
|
140
175
|
): Promise<{ impactedOutputIds: string[]; impactedTokenAmount: bigint }> {
|
|
@@ -158,6 +193,11 @@ export class IssuerSparkWallet extends SparkWallet {
|
|
|
158
193
|
};
|
|
159
194
|
}
|
|
160
195
|
|
|
196
|
+
/**
|
|
197
|
+
* Unfreezes previously frozen tokens associated with a specific Spark address.
|
|
198
|
+
* @param sparkAddress - The Spark address whose tokens should be unfrozen
|
|
199
|
+
* @returns An object containing the IDs of impacted outputs and the total amount of unfrozen tokens
|
|
200
|
+
*/
|
|
161
201
|
public async unfreezeTokens(
|
|
162
202
|
sparkAddress: string,
|
|
163
203
|
): Promise<{ impactedOutputIds: string[]; impactedTokenAmount: bigint }> {
|
|
@@ -179,6 +219,17 @@ export class IssuerSparkWallet extends SparkWallet {
|
|
|
179
219
|
};
|
|
180
220
|
}
|
|
181
221
|
|
|
222
|
+
/**
|
|
223
|
+
* Retrieves the activity history for the issuer's token.
|
|
224
|
+
* @param pageSize - The number of transactions to return per page (default: 100)
|
|
225
|
+
* @param cursor - Optional cursor for pagination
|
|
226
|
+
* @param operationTypes - Optional array of operation types to filter by
|
|
227
|
+
* @param beforeTimestamp - Optional timestamp to filter transactions before
|
|
228
|
+
* @param afterTimestamp - Optional timestamp to filter transactions after
|
|
229
|
+
* @returns An object containing the token activity data
|
|
230
|
+
* @throws {ValidationError} If pageSize is not a safe integer
|
|
231
|
+
* @throws {NetworkError} If the activity data cannot be retrieved
|
|
232
|
+
*/
|
|
182
233
|
public async getIssuerTokenActivity(
|
|
183
234
|
pageSize: number = 100,
|
|
184
235
|
cursor?: ListAllTokenTransactionsCursor,
|
|
@@ -187,7 +238,7 @@ export class IssuerSparkWallet extends SparkWallet {
|
|
|
187
238
|
afterTimestamp?: Date,
|
|
188
239
|
): Promise<GetTokenActivityResponse> {
|
|
189
240
|
if (!Number.isSafeInteger(pageSize)) {
|
|
190
|
-
throw new ValidationError("
|
|
241
|
+
throw new ValidationError("pageSize must be less than 2^53", {
|
|
191
242
|
field: "pageSize",
|
|
192
243
|
value: pageSize,
|
|
193
244
|
expected: "smaller or equal to " + Number.MAX_SAFE_INTEGER,
|
|
@@ -216,10 +267,26 @@ export class IssuerSparkWallet extends SparkWallet {
|
|
|
216
267
|
}
|
|
217
268
|
}
|
|
218
269
|
|
|
270
|
+
/**
|
|
271
|
+
* Retrieves the distribution information for the issuer's token.
|
|
272
|
+
* @throws {NotImplementedError} This feature is not yet supported
|
|
273
|
+
*/
|
|
219
274
|
public async getIssuerTokenDistribution(): Promise<TokenDistribution> {
|
|
220
275
|
throw new NotImplementedError("Token distribution is not yet supported");
|
|
221
276
|
}
|
|
222
277
|
|
|
278
|
+
/**
|
|
279
|
+
* Announces a new token on the L1 (Bitcoin) network.
|
|
280
|
+
* @param tokenName - The name of the token
|
|
281
|
+
* @param tokenTicker - The ticker symbol for the token
|
|
282
|
+
* @param decimals - The number of decimal places for the token
|
|
283
|
+
* @param maxSupply - The maximum supply of the token
|
|
284
|
+
* @param isFreezable - Whether the token can be frozen
|
|
285
|
+
* @param feeRateSatsPerVb - The fee rate in satoshis per virtual byte (default: 4.0)
|
|
286
|
+
* @returns The transaction ID of the announcement
|
|
287
|
+
* @throws {ValidationError} If decimals is not a safe integer
|
|
288
|
+
* @throws {NetworkError} If the announcement transaction cannot be broadcast
|
|
289
|
+
*/
|
|
223
290
|
public async announceTokenL1(
|
|
224
291
|
tokenName: string,
|
|
225
292
|
tokenTicker: string,
|