@buildonspark/issuer-sdk 0.0.84 → 0.0.86
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-NRKE2XKD.js +610 -0
- package/dist/index.cjs +58 -114
- 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 +655 -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-Bho-WrkK.d.cts +151 -0
- package/dist/issuer-spark-wallet-Bho-WrkK.d.ts +151 -0
- package/package.json +23 -7
- 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 +38 -126
- package/src/tests/integration/spark.test.ts +317 -323
- package/src/tests/stress/transfers.test.ts +12 -19
- package/src/tests/utils/issuer-test-wallet.ts +1 -1
- package/src/utils/constants.ts +0 -19
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
|
|
|
@@ -39,9 +39,7 @@ if (typeof window !== "undefined") {
|
|
|
39
39
|
}
|
|
40
40
|
|
|
41
41
|
// src/issuer-wallet/issuer-spark-wallet.ts
|
|
42
|
-
var import_lrc20_sdk = require("@buildonspark/lrc20-sdk");
|
|
43
42
|
var import_spark_sdk5 = require("@buildonspark/spark-sdk");
|
|
44
|
-
var import_core = require("@lightsparkdev/core");
|
|
45
43
|
var import_spark_sdk6 = require("@buildonspark/spark-sdk");
|
|
46
44
|
var import_utils4 = require("@noble/curves/abstract/utils");
|
|
47
45
|
var import_spark_sdk7 = require("@buildonspark/spark-sdk");
|
|
@@ -336,57 +334,13 @@ var IssuerSparkWallet = class _IssuerSparkWallet extends import_spark_sdk5.Spark
|
|
|
336
334
|
options
|
|
337
335
|
}) {
|
|
338
336
|
const wallet = new _IssuerSparkWallet(options, signer);
|
|
337
|
+
wallet.initializeTracer(wallet);
|
|
339
338
|
const initResponse = await wallet.initWallet(mnemonicOrSeed, accountNumber);
|
|
340
|
-
if (import_core.isNode) {
|
|
341
|
-
wallet.wrapIssuerSparkWalletWithTracing();
|
|
342
|
-
}
|
|
343
339
|
return {
|
|
344
340
|
wallet,
|
|
345
341
|
...initResponse
|
|
346
342
|
};
|
|
347
343
|
}
|
|
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
344
|
constructor(configOptions, signer) {
|
|
391
345
|
super(configOptions, signer);
|
|
392
346
|
this.issuerTokenTransactionService = new IssuerTokenTransactionService(
|
|
@@ -397,6 +351,7 @@ var IssuerSparkWallet = class _IssuerSparkWallet extends import_spark_sdk5.Spark
|
|
|
397
351
|
this.config,
|
|
398
352
|
this.connectionManager
|
|
399
353
|
);
|
|
354
|
+
this.wrapIssuerSparkWalletMethodsWithTracing();
|
|
400
355
|
}
|
|
401
356
|
/**
|
|
402
357
|
* Gets the token balance for the issuer's token.
|
|
@@ -451,7 +406,7 @@ var IssuerSparkWallet = class _IssuerSparkWallet extends import_spark_sdk5.Spark
|
|
|
451
406
|
});
|
|
452
407
|
if (response.tokenMetadata.length === 0) {
|
|
453
408
|
throw new import_spark_sdk5.ValidationError(
|
|
454
|
-
"Token metadata not found - If a token has not yet been
|
|
409
|
+
"Token metadata not found - If a token has not yet been created, please create it first. Try again in a few seconds.",
|
|
455
410
|
{
|
|
456
411
|
field: "tokenMetadata",
|
|
457
412
|
value: response.tokenMetadata,
|
|
@@ -570,9 +525,6 @@ var IssuerSparkWallet = class _IssuerSparkWallet extends import_spark_sdk5.Spark
|
|
|
570
525
|
network: this.config.getNetworkType()
|
|
571
526
|
});
|
|
572
527
|
const issuerTokenIdentifier = await this.getIssuerTokenIdentifier();
|
|
573
|
-
if (issuerTokenIdentifier === null) {
|
|
574
|
-
throw new import_spark_sdk5.ValidationError("Issuer token identifier not found");
|
|
575
|
-
}
|
|
576
528
|
return await this.transferTokens({
|
|
577
529
|
tokenIdentifier: issuerTokenIdentifier,
|
|
578
530
|
tokenAmount,
|
|
@@ -592,13 +544,6 @@ var IssuerSparkWallet = class _IssuerSparkWallet extends import_spark_sdk5.Spark
|
|
|
592
544
|
this.config.getNetworkType()
|
|
593
545
|
);
|
|
594
546
|
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
547
|
const rawTokenIdentifier = (0, import_spark_sdk7.decodeBech32mTokenIdentifier)(
|
|
603
548
|
issuerTokenIdentifier,
|
|
604
549
|
this.config.getNetworkType()
|
|
@@ -625,13 +570,6 @@ var IssuerSparkWallet = class _IssuerSparkWallet extends import_spark_sdk5.Spark
|
|
|
625
570
|
this.config.getNetworkType()
|
|
626
571
|
);
|
|
627
572
|
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
573
|
const rawTokenIdentifier = (0, import_spark_sdk7.decodeBech32mTokenIdentifier)(
|
|
636
574
|
issuerTokenIdentifier,
|
|
637
575
|
this.config.getNetworkType()
|
|
@@ -653,56 +591,62 @@ var IssuerSparkWallet = class _IssuerSparkWallet extends import_spark_sdk5.Spark
|
|
|
653
591
|
async getIssuerTokenDistribution() {
|
|
654
592
|
throw new import_spark_sdk8.NotImplementedError("Token distribution is not yet supported");
|
|
655
593
|
}
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
* @returns The transaction ID of the announcement
|
|
665
|
-
* @throws {ValidationError} If decimals is not a safe integer
|
|
666
|
-
* @throws {NetworkError} If the announcement transaction cannot be broadcast
|
|
667
|
-
*/
|
|
668
|
-
async announceTokenL1(tokenName, tokenTicker, decimals, maxSupply, isFreezable, feeRateSatsPerVb = 4) {
|
|
669
|
-
validateTokenParameters(tokenName, tokenTicker, decimals, maxSupply);
|
|
670
|
-
if (!Number.isSafeInteger(decimals)) {
|
|
671
|
-
throw new import_spark_sdk5.ValidationError("Decimals must be less than 2^53", {
|
|
672
|
-
field: "decimals",
|
|
673
|
-
value: decimals,
|
|
674
|
-
expected: "smaller or equal to " + Number.MAX_SAFE_INTEGER
|
|
675
|
-
});
|
|
676
|
-
}
|
|
677
|
-
await this.lrc20Wallet.syncWallet();
|
|
678
|
-
const tokenPublicKey = new import_lrc20_sdk.TokenPubkey(this.lrc20Wallet.pubkey);
|
|
679
|
-
const announcement = new import_lrc20_sdk.TokenPubkeyAnnouncement(
|
|
680
|
-
tokenPublicKey,
|
|
681
|
-
tokenName,
|
|
682
|
-
tokenTicker,
|
|
683
|
-
decimals,
|
|
684
|
-
maxSupply,
|
|
685
|
-
isFreezable
|
|
686
|
-
);
|
|
687
|
-
try {
|
|
688
|
-
const tx = await this.lrc20Wallet.prepareAnnouncement(
|
|
689
|
-
announcement,
|
|
690
|
-
feeRateSatsPerVb
|
|
691
|
-
);
|
|
692
|
-
const txId = await this.lrc20Wallet.broadcastRawBtcTransaction(
|
|
693
|
-
tx.bitcoin_tx.toHex()
|
|
694
|
-
);
|
|
695
|
-
return txId;
|
|
696
|
-
} catch (error) {
|
|
697
|
-
throw new import_spark_sdk5.NetworkError(
|
|
698
|
-
"Failed to broadcast announcement transaction on L1",
|
|
699
|
-
{
|
|
700
|
-
operation: "broadcastRawBtcTransaction",
|
|
701
|
-
errorCount: 1,
|
|
702
|
-
errors: error instanceof Error ? error.message : String(error)
|
|
703
|
-
}
|
|
594
|
+
getTraceName(methodName) {
|
|
595
|
+
return `IssuerSparkWallet.${methodName}`;
|
|
596
|
+
}
|
|
597
|
+
wrapPublicIssuerSparkWalletMethodWithOtelSpan(methodName) {
|
|
598
|
+
const original = this[methodName];
|
|
599
|
+
if (typeof original !== "function") {
|
|
600
|
+
throw new Error(
|
|
601
|
+
`Method ${methodName} is not a function on IssuerSparkWallet.`
|
|
704
602
|
);
|
|
705
603
|
}
|
|
604
|
+
const wrapped = this.wrapWithOtelSpan(
|
|
605
|
+
this.getTraceName(methodName),
|
|
606
|
+
original.bind(this)
|
|
607
|
+
);
|
|
608
|
+
this[methodName] = wrapped;
|
|
609
|
+
}
|
|
610
|
+
wrapIssuerSparkWalletMethodsWithTracing() {
|
|
611
|
+
const methods = [
|
|
612
|
+
"getIssuerTokenBalance",
|
|
613
|
+
"getIssuerTokenMetadata",
|
|
614
|
+
"getIssuerTokenIdentifier",
|
|
615
|
+
"createToken",
|
|
616
|
+
"mintTokens",
|
|
617
|
+
"burnTokens",
|
|
618
|
+
"freezeTokens",
|
|
619
|
+
"unfreezeTokens",
|
|
620
|
+
"getIssuerTokenDistribution"
|
|
621
|
+
];
|
|
622
|
+
methods.forEach(
|
|
623
|
+
(m) => this.wrapPublicIssuerSparkWalletMethodWithOtelSpan(m)
|
|
624
|
+
);
|
|
625
|
+
}
|
|
626
|
+
};
|
|
627
|
+
|
|
628
|
+
// src/issuer-wallet/issuer-spark-wallet.browser.ts
|
|
629
|
+
var import_spark_sdk10 = require("@buildonspark/spark-sdk");
|
|
630
|
+
var IssuerSparkWalletBrowser = class _IssuerSparkWalletBrowser extends IssuerSparkWallet {
|
|
631
|
+
static async initialize({
|
|
632
|
+
mnemonicOrSeed,
|
|
633
|
+
accountNumber,
|
|
634
|
+
signer,
|
|
635
|
+
options
|
|
636
|
+
}) {
|
|
637
|
+
const wallet = new _IssuerSparkWalletBrowser(options, signer);
|
|
638
|
+
wallet.initializeTracer(wallet);
|
|
639
|
+
const initResponse = await wallet.initWallet(mnemonicOrSeed, accountNumber);
|
|
640
|
+
return {
|
|
641
|
+
wallet,
|
|
642
|
+
...initResponse
|
|
643
|
+
};
|
|
644
|
+
}
|
|
645
|
+
initializeTracerEnv({
|
|
646
|
+
spanProcessors,
|
|
647
|
+
traceUrls
|
|
648
|
+
}) {
|
|
649
|
+
(0, import_spark_sdk10.initializeTracerEnv)({ spanProcessors, traceUrls });
|
|
706
650
|
}
|
|
707
651
|
};
|
|
708
652
|
// Annotate the CommonJS export names for ESM import in node:
|
package/dist/index.d.cts
CHANGED
|
@@ -1,162 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { I as IssuerSparkWallet } from './issuer-spark-wallet-Bho-WrkK.cjs';
|
|
2
|
+
export { a as IssuerTokenMetadata, T as TokenDistribution } from './issuer-spark-wallet-Bho-WrkK.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-Bho-WrkK.js';
|
|
2
|
+
export { a as IssuerTokenMetadata, T as TokenDistribution } from './issuer-spark-wallet-Bho-WrkK.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 };
|