@buildonspark/issuer-sdk 0.0.83 → 0.0.85
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 +21 -0
- package/dist/chunk-HOLMXKFE.js +663 -0
- package/dist/index.cjs +61 -64
- package/dist/index.d.cts +8 -156
- package/dist/index.d.ts +8 -156
- package/dist/index.js +13 -669
- package/dist/index.node.cjs +708 -0
- package/dist/index.node.d.cts +14 -0
- package/dist/index.node.d.ts +14 -0
- package/dist/index.node.js +34 -0
- package/dist/issuer-spark-wallet-BFzkv4X5.d.cts +164 -0
- package/dist/issuer-spark-wallet-BFzkv4X5.d.ts +164 -0
- package/package.json +23 -5
- package/src/index.node.ts +2 -0
- package/src/index.ts +1 -1
- package/src/issuer-wallet/issuer-spark-wallet.browser.ts +33 -0
- package/src/issuer-wallet/issuer-spark-wallet.node.ts +33 -0
- package/src/issuer-wallet/issuer-spark-wallet.ts +46 -66
- package/src/tests/integration/spark.test.ts +434 -375
- package/src/tests/stress/transfers.test.ts +12 -19
- package/src/tests/utils/issuer-test-wallet.ts +1 -1
package/dist/index.cjs
CHANGED
|
@@ -20,7 +20,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
20
20
|
// src/index.ts
|
|
21
21
|
var index_exports = {};
|
|
22
22
|
__export(index_exports, {
|
|
23
|
-
IssuerSparkWallet: () =>
|
|
23
|
+
IssuerSparkWallet: () => IssuerSparkWalletBrowser
|
|
24
24
|
});
|
|
25
25
|
module.exports = __toCommonJS(index_exports);
|
|
26
26
|
|
|
@@ -41,7 +41,6 @@ if (typeof window !== "undefined") {
|
|
|
41
41
|
// src/issuer-wallet/issuer-spark-wallet.ts
|
|
42
42
|
var import_lrc20_sdk = require("@buildonspark/lrc20-sdk");
|
|
43
43
|
var import_spark_sdk5 = require("@buildonspark/spark-sdk");
|
|
44
|
-
var import_core = require("@lightsparkdev/core");
|
|
45
44
|
var import_spark_sdk6 = require("@buildonspark/spark-sdk");
|
|
46
45
|
var import_utils4 = require("@noble/curves/abstract/utils");
|
|
47
46
|
var import_spark_sdk7 = require("@buildonspark/spark-sdk");
|
|
@@ -336,57 +335,13 @@ var IssuerSparkWallet = class _IssuerSparkWallet extends import_spark_sdk5.Spark
|
|
|
336
335
|
options
|
|
337
336
|
}) {
|
|
338
337
|
const wallet = new _IssuerSparkWallet(options, signer);
|
|
338
|
+
wallet.initializeTracer(wallet);
|
|
339
339
|
const initResponse = await wallet.initWallet(mnemonicOrSeed, accountNumber);
|
|
340
|
-
if (import_core.isNode) {
|
|
341
|
-
wallet.wrapIssuerSparkWalletWithTracing();
|
|
342
|
-
}
|
|
343
340
|
return {
|
|
344
341
|
wallet,
|
|
345
342
|
...initResponse
|
|
346
343
|
};
|
|
347
344
|
}
|
|
348
|
-
wrapIssuerSparkWalletWithTracing() {
|
|
349
|
-
this.getIssuerTokenBalance = this.wrapWithOtelSpan(
|
|
350
|
-
"SparkIssuerWallet.getIssuerTokenBalance",
|
|
351
|
-
this.getIssuerTokenBalance.bind(this)
|
|
352
|
-
);
|
|
353
|
-
this.getIssuerTokenMetadata = this.wrapWithOtelSpan(
|
|
354
|
-
"SparkIssuerWallet.getIssuerTokenMetadata",
|
|
355
|
-
this.getIssuerTokenMetadata.bind(this)
|
|
356
|
-
);
|
|
357
|
-
this.getIssuerTokenIdentifier = this.wrapWithOtelSpan(
|
|
358
|
-
"SparkIssuerWallet.getIssuerTokenIdentifier",
|
|
359
|
-
this.getIssuerTokenIdentifier.bind(this)
|
|
360
|
-
);
|
|
361
|
-
this.createToken = this.wrapWithOtelSpan(
|
|
362
|
-
"SparkIssuerWallet.createToken",
|
|
363
|
-
this.createToken.bind(this)
|
|
364
|
-
);
|
|
365
|
-
this.mintTokens = this.wrapWithOtelSpan(
|
|
366
|
-
"SparkIssuerWallet.mintTokens",
|
|
367
|
-
this.mintTokens.bind(this)
|
|
368
|
-
);
|
|
369
|
-
this.burnTokens = this.wrapWithOtelSpan(
|
|
370
|
-
"SparkIssuerWallet.burnTokens",
|
|
371
|
-
this.burnTokens.bind(this)
|
|
372
|
-
);
|
|
373
|
-
this.freezeTokens = this.wrapWithOtelSpan(
|
|
374
|
-
"SparkIssuerWallet.freezeTokens",
|
|
375
|
-
this.freezeTokens.bind(this)
|
|
376
|
-
);
|
|
377
|
-
this.unfreezeTokens = this.wrapWithOtelSpan(
|
|
378
|
-
"SparkIssuerWallet.unfreezeTokens",
|
|
379
|
-
this.unfreezeTokens.bind(this)
|
|
380
|
-
);
|
|
381
|
-
this.getIssuerTokenDistribution = this.wrapWithOtelSpan(
|
|
382
|
-
"SparkIssuerWallet.getIssuerTokenDistribution",
|
|
383
|
-
this.getIssuerTokenDistribution.bind(this)
|
|
384
|
-
);
|
|
385
|
-
this.announceTokenL1 = this.wrapWithOtelSpan(
|
|
386
|
-
"SparkIssuerWallet.announceTokenL1",
|
|
387
|
-
this.announceTokenL1.bind(this)
|
|
388
|
-
);
|
|
389
|
-
}
|
|
390
345
|
constructor(configOptions, signer) {
|
|
391
346
|
super(configOptions, signer);
|
|
392
347
|
this.issuerTokenTransactionService = new IssuerTokenTransactionService(
|
|
@@ -397,6 +352,7 @@ var IssuerSparkWallet = class _IssuerSparkWallet extends import_spark_sdk5.Spark
|
|
|
397
352
|
this.config,
|
|
398
353
|
this.connectionManager
|
|
399
354
|
);
|
|
355
|
+
this.wrapIssuerSparkWalletMethodsWithTracing();
|
|
400
356
|
}
|
|
401
357
|
/**
|
|
402
358
|
* Gets the token balance for the issuer's token.
|
|
@@ -570,9 +526,6 @@ var IssuerSparkWallet = class _IssuerSparkWallet extends import_spark_sdk5.Spark
|
|
|
570
526
|
network: this.config.getNetworkType()
|
|
571
527
|
});
|
|
572
528
|
const issuerTokenIdentifier = await this.getIssuerTokenIdentifier();
|
|
573
|
-
if (issuerTokenIdentifier === null) {
|
|
574
|
-
throw new import_spark_sdk5.ValidationError("Issuer token identifier not found");
|
|
575
|
-
}
|
|
576
529
|
return await this.transferTokens({
|
|
577
530
|
tokenIdentifier: issuerTokenIdentifier,
|
|
578
531
|
tokenAmount,
|
|
@@ -592,13 +545,6 @@ var IssuerSparkWallet = class _IssuerSparkWallet extends import_spark_sdk5.Spark
|
|
|
592
545
|
this.config.getNetworkType()
|
|
593
546
|
);
|
|
594
547
|
const issuerTokenIdentifier = await this.getIssuerTokenIdentifier();
|
|
595
|
-
if (issuerTokenIdentifier === null) {
|
|
596
|
-
throw new import_spark_sdk5.ValidationError("Issuer token identifier not found", {
|
|
597
|
-
field: "issuerTokenIdentifier",
|
|
598
|
-
value: issuerTokenIdentifier,
|
|
599
|
-
expected: "non-null token identifier"
|
|
600
|
-
});
|
|
601
|
-
}
|
|
602
548
|
const rawTokenIdentifier = (0, import_spark_sdk7.decodeBech32mTokenIdentifier)(
|
|
603
549
|
issuerTokenIdentifier,
|
|
604
550
|
this.config.getNetworkType()
|
|
@@ -625,13 +571,6 @@ var IssuerSparkWallet = class _IssuerSparkWallet extends import_spark_sdk5.Spark
|
|
|
625
571
|
this.config.getNetworkType()
|
|
626
572
|
);
|
|
627
573
|
const issuerTokenIdentifier = await this.getIssuerTokenIdentifier();
|
|
628
|
-
if (issuerTokenIdentifier === null) {
|
|
629
|
-
throw new import_spark_sdk5.ValidationError("Issuer token identifier not found", {
|
|
630
|
-
field: "issuerTokenIdentifier",
|
|
631
|
-
value: issuerTokenIdentifier,
|
|
632
|
-
expected: "non-null token identifier"
|
|
633
|
-
});
|
|
634
|
-
}
|
|
635
574
|
const rawTokenIdentifier = (0, import_spark_sdk7.decodeBech32mTokenIdentifier)(
|
|
636
575
|
issuerTokenIdentifier,
|
|
637
576
|
this.config.getNetworkType()
|
|
@@ -704,6 +643,64 @@ var IssuerSparkWallet = class _IssuerSparkWallet extends import_spark_sdk5.Spark
|
|
|
704
643
|
);
|
|
705
644
|
}
|
|
706
645
|
}
|
|
646
|
+
getTraceName(methodName) {
|
|
647
|
+
return `IssuerSparkWallet.${methodName}`;
|
|
648
|
+
}
|
|
649
|
+
wrapPublicIssuerSparkWalletMethodWithOtelSpan(methodName) {
|
|
650
|
+
const original = this[methodName];
|
|
651
|
+
if (typeof original !== "function") {
|
|
652
|
+
throw new Error(
|
|
653
|
+
`Method ${methodName} is not a function on IssuerSparkWallet.`
|
|
654
|
+
);
|
|
655
|
+
}
|
|
656
|
+
const wrapped = this.wrapWithOtelSpan(
|
|
657
|
+
this.getTraceName(methodName),
|
|
658
|
+
original.bind(this)
|
|
659
|
+
);
|
|
660
|
+
this[methodName] = wrapped;
|
|
661
|
+
}
|
|
662
|
+
wrapIssuerSparkWalletMethodsWithTracing() {
|
|
663
|
+
const methods = [
|
|
664
|
+
"getIssuerTokenBalance",
|
|
665
|
+
"getIssuerTokenMetadata",
|
|
666
|
+
"getIssuerTokenIdentifier",
|
|
667
|
+
"createToken",
|
|
668
|
+
"mintTokens",
|
|
669
|
+
"burnTokens",
|
|
670
|
+
"freezeTokens",
|
|
671
|
+
"unfreezeTokens",
|
|
672
|
+
"getIssuerTokenDistribution",
|
|
673
|
+
"announceTokenL1"
|
|
674
|
+
];
|
|
675
|
+
methods.forEach(
|
|
676
|
+
(m) => this.wrapPublicIssuerSparkWalletMethodWithOtelSpan(m)
|
|
677
|
+
);
|
|
678
|
+
}
|
|
679
|
+
};
|
|
680
|
+
|
|
681
|
+
// src/issuer-wallet/issuer-spark-wallet.browser.ts
|
|
682
|
+
var import_spark_sdk10 = require("@buildonspark/spark-sdk");
|
|
683
|
+
var IssuerSparkWalletBrowser = class _IssuerSparkWalletBrowser extends IssuerSparkWallet {
|
|
684
|
+
static async initialize({
|
|
685
|
+
mnemonicOrSeed,
|
|
686
|
+
accountNumber,
|
|
687
|
+
signer,
|
|
688
|
+
options
|
|
689
|
+
}) {
|
|
690
|
+
const wallet = new _IssuerSparkWalletBrowser(options, signer);
|
|
691
|
+
wallet.initializeTracer(wallet);
|
|
692
|
+
const initResponse = await wallet.initWallet(mnemonicOrSeed, accountNumber);
|
|
693
|
+
return {
|
|
694
|
+
wallet,
|
|
695
|
+
...initResponse
|
|
696
|
+
};
|
|
697
|
+
}
|
|
698
|
+
initializeTracerEnv({
|
|
699
|
+
spanProcessors,
|
|
700
|
+
traceUrls
|
|
701
|
+
}) {
|
|
702
|
+
(0, import_spark_sdk10.initializeTracerEnv)({ spanProcessors, traceUrls });
|
|
703
|
+
}
|
|
707
704
|
};
|
|
708
705
|
// Annotate the CommonJS export names for ESM import in node:
|
|
709
706
|
0 && (module.exports = {
|
package/dist/index.d.cts
CHANGED
|
@@ -1,162 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { I as IssuerSparkWallet } from './issuer-spark-wallet-BFzkv4X5.cjs';
|
|
2
|
+
export { a as IssuerTokenMetadata, T as TokenDistribution } from './issuer-spark-wallet-BFzkv4X5.cjs';
|
|
3
|
+
import { SparkWalletProps } from '@buildonspark/spark-sdk';
|
|
4
|
+
import '@buildonspark/spark-sdk/proto/spark';
|
|
3
5
|
|
|
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 */
|
|
29
|
-
tokenPublicKey: string;
|
|
30
|
-
/** Human-readable name of the token (e.g., SparkToken)*/
|
|
31
|
-
tokenName: string;
|
|
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 */
|
|
37
|
-
maxSupply: bigint;
|
|
38
|
-
/** Whether the token is freezable */
|
|
39
|
-
isFreezable: boolean;
|
|
40
|
-
};
|
|
41
|
-
interface TokenDistribution {
|
|
42
|
-
totalCirculatingSupply: bigint;
|
|
43
|
-
totalIssued: bigint;
|
|
44
|
-
totalBurned: bigint;
|
|
45
|
-
numHoldingAddress: number;
|
|
46
|
-
numConfirmedTransactions: bigint;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
* Represents a Spark wallet with minting capabilities.
|
|
51
|
-
* This class extends the base SparkWallet with additional functionality for token minting,
|
|
52
|
-
* burning, and freezing operations.
|
|
53
|
-
*/
|
|
54
|
-
declare class IssuerSparkWallet extends SparkWallet {
|
|
55
|
-
private issuerTokenTransactionService;
|
|
56
|
-
private tokenFreezeService;
|
|
57
|
-
protected tracerId: string;
|
|
58
|
-
/**
|
|
59
|
-
* Initializes a new IssuerSparkWallet instance.
|
|
60
|
-
* @param options - Configuration options for the wallet
|
|
61
|
-
* @returns An object containing the initialized wallet and initialization response
|
|
62
|
-
*/
|
|
6
|
+
declare class IssuerSparkWalletBrowser extends IssuerSparkWallet {
|
|
63
7
|
static initialize({ mnemonicOrSeed, accountNumber, signer, options, }: SparkWalletProps): Promise<{
|
|
64
8
|
mnemonic?: string | undefined;
|
|
65
|
-
wallet:
|
|
66
|
-
}>;
|
|
67
|
-
private wrapIssuerSparkWalletWithTracing;
|
|
68
|
-
protected constructor(configOptions?: ConfigOptions, signer?: SparkSigner);
|
|
69
|
-
/**
|
|
70
|
-
* Gets the token balance for the issuer's token.
|
|
71
|
-
* @returns An object containing the token balance as a bigint
|
|
72
|
-
*/
|
|
73
|
-
getIssuerTokenBalance(): Promise<{
|
|
74
|
-
tokenIdentifier: Bech32mTokenIdentifier | undefined;
|
|
75
|
-
balance: bigint;
|
|
76
|
-
}>;
|
|
77
|
-
/**
|
|
78
|
-
* Retrieves information about the issuer's token.
|
|
79
|
-
* @returns An object containing token information including public key, name, symbol, decimals, max supply, and freeze status
|
|
80
|
-
* @throws {NetworkError} If the token metadata cannot be retrieved
|
|
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>;
|
|
111
|
-
/**
|
|
112
|
-
* Mints new tokens
|
|
113
|
-
* @param tokenAmount - The amount of tokens to mint
|
|
114
|
-
* @returns The transaction ID of the mint operation
|
|
115
|
-
*/
|
|
116
|
-
mintTokens(tokenAmount: bigint): Promise<string>;
|
|
117
|
-
/**
|
|
118
|
-
* Burns issuer's tokens
|
|
119
|
-
* @param tokenAmount - The amount of tokens to burn
|
|
120
|
-
* @param selectedOutputs - Optional array of outputs to use for the burn operation
|
|
121
|
-
* @returns The transaction ID of the burn operation
|
|
122
|
-
*/
|
|
123
|
-
burnTokens(tokenAmount: bigint, selectedOutputs?: OutputWithPreviousTransactionData[]): Promise<string>;
|
|
124
|
-
/**
|
|
125
|
-
* Freezes tokens associated with a specific Spark address.
|
|
126
|
-
* @param sparkAddress - The Spark address whose tokens should be frozen
|
|
127
|
-
* @returns An object containing the IDs of impacted outputs and the total amount of frozen tokens
|
|
128
|
-
*/
|
|
129
|
-
freezeTokens(sparkAddress: string): Promise<{
|
|
130
|
-
impactedOutputIds: string[];
|
|
131
|
-
impactedTokenAmount: bigint;
|
|
132
|
-
}>;
|
|
133
|
-
/**
|
|
134
|
-
* Unfreezes previously frozen tokens associated with a specific Spark address.
|
|
135
|
-
* @param sparkAddress - The Spark address whose tokens should be unfrozen
|
|
136
|
-
* @returns An object containing the IDs of impacted outputs and the total amount of unfrozen tokens
|
|
137
|
-
*/
|
|
138
|
-
unfreezeTokens(sparkAddress: string): Promise<{
|
|
139
|
-
impactedOutputIds: string[];
|
|
140
|
-
impactedTokenAmount: bigint;
|
|
9
|
+
wallet: IssuerSparkWalletBrowser;
|
|
141
10
|
}>;
|
|
142
|
-
|
|
143
|
-
* Retrieves the distribution information for the issuer's token.
|
|
144
|
-
* @throws {NotImplementedError} This feature is not yet supported
|
|
145
|
-
*/
|
|
146
|
-
getIssuerTokenDistribution(): Promise<TokenDistribution>;
|
|
147
|
-
/**
|
|
148
|
-
* Announces a new token on the L1 (Bitcoin) network.
|
|
149
|
-
* @param tokenName - The name of the token
|
|
150
|
-
* @param tokenTicker - The ticker symbol for the token
|
|
151
|
-
* @param decimals - The number of decimal places for the token
|
|
152
|
-
* @param maxSupply - The maximum supply of the token
|
|
153
|
-
* @param isFreezable - Whether the token can be frozen
|
|
154
|
-
* @param feeRateSatsPerVb - The fee rate in satoshis per virtual byte (default: 4.0)
|
|
155
|
-
* @returns The transaction ID of the announcement
|
|
156
|
-
* @throws {ValidationError} If decimals is not a safe integer
|
|
157
|
-
* @throws {NetworkError} If the announcement transaction cannot be broadcast
|
|
158
|
-
*/
|
|
159
|
-
announceTokenL1(tokenName: string, tokenTicker: string, decimals: number, maxSupply: bigint, isFreezable: boolean, feeRateSatsPerVb?: number): Promise<string>;
|
|
11
|
+
protected initializeTracerEnv({ spanProcessors, traceUrls, }: Parameters<IssuerSparkWallet["initializeTracerEnv"]>[0]): void;
|
|
160
12
|
}
|
|
161
13
|
|
|
162
|
-
export {
|
|
14
|
+
export { IssuerSparkWalletBrowser as IssuerSparkWallet };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,162 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { I as IssuerSparkWallet } from './issuer-spark-wallet-BFzkv4X5.js';
|
|
2
|
+
export { a as IssuerTokenMetadata, T as TokenDistribution } from './issuer-spark-wallet-BFzkv4X5.js';
|
|
3
|
+
import { SparkWalletProps } from '@buildonspark/spark-sdk';
|
|
4
|
+
import '@buildonspark/spark-sdk/proto/spark';
|
|
3
5
|
|
|
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 */
|
|
29
|
-
tokenPublicKey: string;
|
|
30
|
-
/** Human-readable name of the token (e.g., SparkToken)*/
|
|
31
|
-
tokenName: string;
|
|
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 */
|
|
37
|
-
maxSupply: bigint;
|
|
38
|
-
/** Whether the token is freezable */
|
|
39
|
-
isFreezable: boolean;
|
|
40
|
-
};
|
|
41
|
-
interface TokenDistribution {
|
|
42
|
-
totalCirculatingSupply: bigint;
|
|
43
|
-
totalIssued: bigint;
|
|
44
|
-
totalBurned: bigint;
|
|
45
|
-
numHoldingAddress: number;
|
|
46
|
-
numConfirmedTransactions: bigint;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
* Represents a Spark wallet with minting capabilities.
|
|
51
|
-
* This class extends the base SparkWallet with additional functionality for token minting,
|
|
52
|
-
* burning, and freezing operations.
|
|
53
|
-
*/
|
|
54
|
-
declare class IssuerSparkWallet extends SparkWallet {
|
|
55
|
-
private issuerTokenTransactionService;
|
|
56
|
-
private tokenFreezeService;
|
|
57
|
-
protected tracerId: string;
|
|
58
|
-
/**
|
|
59
|
-
* Initializes a new IssuerSparkWallet instance.
|
|
60
|
-
* @param options - Configuration options for the wallet
|
|
61
|
-
* @returns An object containing the initialized wallet and initialization response
|
|
62
|
-
*/
|
|
6
|
+
declare class IssuerSparkWalletBrowser extends IssuerSparkWallet {
|
|
63
7
|
static initialize({ mnemonicOrSeed, accountNumber, signer, options, }: SparkWalletProps): Promise<{
|
|
64
8
|
mnemonic?: string | undefined;
|
|
65
|
-
wallet:
|
|
66
|
-
}>;
|
|
67
|
-
private wrapIssuerSparkWalletWithTracing;
|
|
68
|
-
protected constructor(configOptions?: ConfigOptions, signer?: SparkSigner);
|
|
69
|
-
/**
|
|
70
|
-
* Gets the token balance for the issuer's token.
|
|
71
|
-
* @returns An object containing the token balance as a bigint
|
|
72
|
-
*/
|
|
73
|
-
getIssuerTokenBalance(): Promise<{
|
|
74
|
-
tokenIdentifier: Bech32mTokenIdentifier | undefined;
|
|
75
|
-
balance: bigint;
|
|
76
|
-
}>;
|
|
77
|
-
/**
|
|
78
|
-
* Retrieves information about the issuer's token.
|
|
79
|
-
* @returns An object containing token information including public key, name, symbol, decimals, max supply, and freeze status
|
|
80
|
-
* @throws {NetworkError} If the token metadata cannot be retrieved
|
|
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>;
|
|
111
|
-
/**
|
|
112
|
-
* Mints new tokens
|
|
113
|
-
* @param tokenAmount - The amount of tokens to mint
|
|
114
|
-
* @returns The transaction ID of the mint operation
|
|
115
|
-
*/
|
|
116
|
-
mintTokens(tokenAmount: bigint): Promise<string>;
|
|
117
|
-
/**
|
|
118
|
-
* Burns issuer's tokens
|
|
119
|
-
* @param tokenAmount - The amount of tokens to burn
|
|
120
|
-
* @param selectedOutputs - Optional array of outputs to use for the burn operation
|
|
121
|
-
* @returns The transaction ID of the burn operation
|
|
122
|
-
*/
|
|
123
|
-
burnTokens(tokenAmount: bigint, selectedOutputs?: OutputWithPreviousTransactionData[]): Promise<string>;
|
|
124
|
-
/**
|
|
125
|
-
* Freezes tokens associated with a specific Spark address.
|
|
126
|
-
* @param sparkAddress - The Spark address whose tokens should be frozen
|
|
127
|
-
* @returns An object containing the IDs of impacted outputs and the total amount of frozen tokens
|
|
128
|
-
*/
|
|
129
|
-
freezeTokens(sparkAddress: string): Promise<{
|
|
130
|
-
impactedOutputIds: string[];
|
|
131
|
-
impactedTokenAmount: bigint;
|
|
132
|
-
}>;
|
|
133
|
-
/**
|
|
134
|
-
* Unfreezes previously frozen tokens associated with a specific Spark address.
|
|
135
|
-
* @param sparkAddress - The Spark address whose tokens should be unfrozen
|
|
136
|
-
* @returns An object containing the IDs of impacted outputs and the total amount of unfrozen tokens
|
|
137
|
-
*/
|
|
138
|
-
unfreezeTokens(sparkAddress: string): Promise<{
|
|
139
|
-
impactedOutputIds: string[];
|
|
140
|
-
impactedTokenAmount: bigint;
|
|
9
|
+
wallet: IssuerSparkWalletBrowser;
|
|
141
10
|
}>;
|
|
142
|
-
|
|
143
|
-
* Retrieves the distribution information for the issuer's token.
|
|
144
|
-
* @throws {NotImplementedError} This feature is not yet supported
|
|
145
|
-
*/
|
|
146
|
-
getIssuerTokenDistribution(): Promise<TokenDistribution>;
|
|
147
|
-
/**
|
|
148
|
-
* Announces a new token on the L1 (Bitcoin) network.
|
|
149
|
-
* @param tokenName - The name of the token
|
|
150
|
-
* @param tokenTicker - The ticker symbol for the token
|
|
151
|
-
* @param decimals - The number of decimal places for the token
|
|
152
|
-
* @param maxSupply - The maximum supply of the token
|
|
153
|
-
* @param isFreezable - Whether the token can be frozen
|
|
154
|
-
* @param feeRateSatsPerVb - The fee rate in satoshis per virtual byte (default: 4.0)
|
|
155
|
-
* @returns The transaction ID of the announcement
|
|
156
|
-
* @throws {ValidationError} If decimals is not a safe integer
|
|
157
|
-
* @throws {NetworkError} If the announcement transaction cannot be broadcast
|
|
158
|
-
*/
|
|
159
|
-
announceTokenL1(tokenName: string, tokenTicker: string, decimals: number, maxSupply: bigint, isFreezable: boolean, feeRateSatsPerVb?: number): Promise<string>;
|
|
11
|
+
protected initializeTracerEnv({ spanProcessors, traceUrls, }: Parameters<IssuerSparkWallet["initializeTracerEnv"]>[0]): void;
|
|
160
12
|
}
|
|
161
13
|
|
|
162
|
-
export {
|
|
14
|
+
export { IssuerSparkWalletBrowser as IssuerSparkWallet };
|