@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.
@@ -0,0 +1,34 @@
1
+ import {
2
+ IssuerSparkWallet
3
+ } from "./chunk-NRKE2XKD.js";
4
+ import "./chunk-7B4B24XF.js";
5
+
6
+ // src/issuer-wallet/issuer-spark-wallet.node.ts
7
+ import {
8
+ initializeTracerEnv as initializeTracerEnvNodeJS
9
+ } from "@buildonspark/spark-sdk";
10
+ var IssuerSparkWalletNodeJS = class _IssuerSparkWalletNodeJS extends IssuerSparkWallet {
11
+ static async initialize({
12
+ mnemonicOrSeed,
13
+ accountNumber,
14
+ signer,
15
+ options
16
+ }) {
17
+ const wallet = new _IssuerSparkWalletNodeJS(options, signer);
18
+ wallet.initializeTracer(wallet);
19
+ const initResponse = await wallet.initWallet(mnemonicOrSeed, accountNumber);
20
+ return {
21
+ wallet,
22
+ ...initResponse
23
+ };
24
+ }
25
+ initializeTracerEnv({
26
+ spanProcessors,
27
+ traceUrls
28
+ }) {
29
+ initializeTracerEnvNodeJS({ spanProcessors, traceUrls });
30
+ }
31
+ };
32
+ export {
33
+ IssuerSparkWalletNodeJS as IssuerSparkWallet
34
+ };
@@ -0,0 +1,151 @@
1
+ import { SparkWallet, SparkWalletProps, ConfigOptions, SparkSigner, Bech32mTokenIdentifier } from '@buildonspark/spark-sdk';
2
+ import { OutputWithPreviousTransactionData } from '@buildonspark/spark-sdk/proto/spark';
3
+
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
+ */
63
+ static initialize({ mnemonicOrSeed, accountNumber, signer, options, }: SparkWalletProps): Promise<{
64
+ mnemonic?: string | undefined;
65
+ wallet: IssuerSparkWallet;
66
+ }>;
67
+ protected constructor(configOptions?: ConfigOptions, signer?: SparkSigner);
68
+ /**
69
+ * Gets the token balance for the issuer's token.
70
+ * @returns An object containing the token balance as a bigint
71
+ */
72
+ getIssuerTokenBalance(): Promise<{
73
+ tokenIdentifier: Bech32mTokenIdentifier | undefined;
74
+ balance: bigint;
75
+ }>;
76
+ /**
77
+ * Retrieves information about the issuer's token.
78
+ * @returns An object containing token information including public key, name, symbol, decimals, max supply, and freeze status
79
+ * @throws {NetworkError} If the token metadata cannot be retrieved
80
+ */
81
+ getIssuerTokenMetadata(): Promise<IssuerTokenMetadata>;
82
+ /**
83
+ * Retrieves the bech32m encoded token identifier for the issuer's token.
84
+ * @returns The bech32m encoded token identifier for the issuer's token
85
+ * @throws {NetworkError} If the token identifier cannot be retrieved
86
+ */
87
+ getIssuerTokenIdentifier(): Promise<Bech32mTokenIdentifier>;
88
+ /**
89
+ * Create a new token on Spark.
90
+ *
91
+ * @param params - Object containing token creation parameters.
92
+ * @param params.tokenName - The name of the token.
93
+ * @param params.tokenTicker - The ticker symbol for the token.
94
+ * @param params.decimals - The number of decimal places for the token.
95
+ * @param params.isFreezable - Whether the token can be frozen.
96
+ * @param [params.maxSupply=0n] - (Optional) The maximum supply of the token. Defaults to <code>0n</code>.
97
+ *
98
+ * @returns The transaction ID of the announcement.
99
+ *
100
+ * @throws {ValidationError} If `decimals` is not a safe integer or other validation fails.
101
+ * @throws {NetworkError} If the announcement transaction cannot be broadcast.
102
+ */
103
+ createToken({ tokenName, tokenTicker, decimals, isFreezable, maxSupply, }: {
104
+ tokenName: string;
105
+ tokenTicker: string;
106
+ decimals: number;
107
+ isFreezable: boolean;
108
+ maxSupply?: bigint;
109
+ }): Promise<string>;
110
+ /**
111
+ * Mints new tokens
112
+ * @param tokenAmount - The amount of tokens to mint
113
+ * @returns The transaction ID of the mint operation
114
+ */
115
+ mintTokens(tokenAmount: bigint): Promise<string>;
116
+ /**
117
+ * Burns issuer's tokens
118
+ * @param tokenAmount - The amount of tokens to burn
119
+ * @param selectedOutputs - Optional array of outputs to use for the burn operation
120
+ * @returns The transaction ID of the burn operation
121
+ */
122
+ burnTokens(tokenAmount: bigint, selectedOutputs?: OutputWithPreviousTransactionData[]): Promise<string>;
123
+ /**
124
+ * Freezes tokens associated with a specific Spark address.
125
+ * @param sparkAddress - The Spark address whose tokens should be frozen
126
+ * @returns An object containing the IDs of impacted outputs and the total amount of frozen tokens
127
+ */
128
+ freezeTokens(sparkAddress: string): Promise<{
129
+ impactedOutputIds: string[];
130
+ impactedTokenAmount: bigint;
131
+ }>;
132
+ /**
133
+ * Unfreezes previously frozen tokens associated with a specific Spark address.
134
+ * @param sparkAddress - The Spark address whose tokens should be unfrozen
135
+ * @returns An object containing the IDs of impacted outputs and the total amount of unfrozen tokens
136
+ */
137
+ unfreezeTokens(sparkAddress: string): Promise<{
138
+ impactedOutputIds: string[];
139
+ impactedTokenAmount: bigint;
140
+ }>;
141
+ /**
142
+ * Retrieves the distribution information for the issuer's token.
143
+ * @throws {NotImplementedError} This feature is not yet supported
144
+ */
145
+ getIssuerTokenDistribution(): Promise<TokenDistribution>;
146
+ protected getTraceName(methodName: string): string;
147
+ private wrapPublicIssuerSparkWalletMethodWithOtelSpan;
148
+ private wrapIssuerSparkWalletMethodsWithTracing;
149
+ }
150
+
151
+ export { IssuerSparkWallet as I, type TokenDistribution as T, type IssuerTokenMetadata as a };
@@ -0,0 +1,151 @@
1
+ import { SparkWallet, SparkWalletProps, ConfigOptions, SparkSigner, Bech32mTokenIdentifier } from '@buildonspark/spark-sdk';
2
+ import { OutputWithPreviousTransactionData } from '@buildonspark/spark-sdk/proto/spark';
3
+
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
+ */
63
+ static initialize({ mnemonicOrSeed, accountNumber, signer, options, }: SparkWalletProps): Promise<{
64
+ mnemonic?: string | undefined;
65
+ wallet: IssuerSparkWallet;
66
+ }>;
67
+ protected constructor(configOptions?: ConfigOptions, signer?: SparkSigner);
68
+ /**
69
+ * Gets the token balance for the issuer's token.
70
+ * @returns An object containing the token balance as a bigint
71
+ */
72
+ getIssuerTokenBalance(): Promise<{
73
+ tokenIdentifier: Bech32mTokenIdentifier | undefined;
74
+ balance: bigint;
75
+ }>;
76
+ /**
77
+ * Retrieves information about the issuer's token.
78
+ * @returns An object containing token information including public key, name, symbol, decimals, max supply, and freeze status
79
+ * @throws {NetworkError} If the token metadata cannot be retrieved
80
+ */
81
+ getIssuerTokenMetadata(): Promise<IssuerTokenMetadata>;
82
+ /**
83
+ * Retrieves the bech32m encoded token identifier for the issuer's token.
84
+ * @returns The bech32m encoded token identifier for the issuer's token
85
+ * @throws {NetworkError} If the token identifier cannot be retrieved
86
+ */
87
+ getIssuerTokenIdentifier(): Promise<Bech32mTokenIdentifier>;
88
+ /**
89
+ * Create a new token on Spark.
90
+ *
91
+ * @param params - Object containing token creation parameters.
92
+ * @param params.tokenName - The name of the token.
93
+ * @param params.tokenTicker - The ticker symbol for the token.
94
+ * @param params.decimals - The number of decimal places for the token.
95
+ * @param params.isFreezable - Whether the token can be frozen.
96
+ * @param [params.maxSupply=0n] - (Optional) The maximum supply of the token. Defaults to <code>0n</code>.
97
+ *
98
+ * @returns The transaction ID of the announcement.
99
+ *
100
+ * @throws {ValidationError} If `decimals` is not a safe integer or other validation fails.
101
+ * @throws {NetworkError} If the announcement transaction cannot be broadcast.
102
+ */
103
+ createToken({ tokenName, tokenTicker, decimals, isFreezable, maxSupply, }: {
104
+ tokenName: string;
105
+ tokenTicker: string;
106
+ decimals: number;
107
+ isFreezable: boolean;
108
+ maxSupply?: bigint;
109
+ }): Promise<string>;
110
+ /**
111
+ * Mints new tokens
112
+ * @param tokenAmount - The amount of tokens to mint
113
+ * @returns The transaction ID of the mint operation
114
+ */
115
+ mintTokens(tokenAmount: bigint): Promise<string>;
116
+ /**
117
+ * Burns issuer's tokens
118
+ * @param tokenAmount - The amount of tokens to burn
119
+ * @param selectedOutputs - Optional array of outputs to use for the burn operation
120
+ * @returns The transaction ID of the burn operation
121
+ */
122
+ burnTokens(tokenAmount: bigint, selectedOutputs?: OutputWithPreviousTransactionData[]): Promise<string>;
123
+ /**
124
+ * Freezes tokens associated with a specific Spark address.
125
+ * @param sparkAddress - The Spark address whose tokens should be frozen
126
+ * @returns An object containing the IDs of impacted outputs and the total amount of frozen tokens
127
+ */
128
+ freezeTokens(sparkAddress: string): Promise<{
129
+ impactedOutputIds: string[];
130
+ impactedTokenAmount: bigint;
131
+ }>;
132
+ /**
133
+ * Unfreezes previously frozen tokens associated with a specific Spark address.
134
+ * @param sparkAddress - The Spark address whose tokens should be unfrozen
135
+ * @returns An object containing the IDs of impacted outputs and the total amount of unfrozen tokens
136
+ */
137
+ unfreezeTokens(sparkAddress: string): Promise<{
138
+ impactedOutputIds: string[];
139
+ impactedTokenAmount: bigint;
140
+ }>;
141
+ /**
142
+ * Retrieves the distribution information for the issuer's token.
143
+ * @throws {NotImplementedError} This feature is not yet supported
144
+ */
145
+ getIssuerTokenDistribution(): Promise<TokenDistribution>;
146
+ protected getTraceName(methodName: string): string;
147
+ private wrapPublicIssuerSparkWalletMethodWithOtelSpan;
148
+ private wrapIssuerSparkWalletMethodsWithTracing;
149
+ }
150
+
151
+ export { IssuerSparkWallet as I, type TokenDistribution as T, type IssuerTokenMetadata as a };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@buildonspark/issuer-sdk",
3
- "version": "0.0.84",
3
+ "version": "0.0.86",
4
4
  "description": "Spark Issuer SDK for token issuance",
5
5
  "license": "Apache-2.0",
6
6
  "module": "./dist/index.js",
@@ -9,8 +9,26 @@
9
9
  "homepage": "https://github.com/buildonspark/spark",
10
10
  "exports": {
11
11
  ".": {
12
- "import": "./dist/index.js",
13
- "require": "./dist/index.cjs"
12
+ "import": {
13
+ "node": {
14
+ "types": "./dist/index.node.d.ts",
15
+ "default": "./dist/index.node.js"
16
+ },
17
+ "default": {
18
+ "types": "./dist/index.d.ts",
19
+ "default": "./dist/index.js"
20
+ }
21
+ },
22
+ "require": {
23
+ "node": {
24
+ "types": "./dist/index.node.d.cts",
25
+ "default": "./dist/index.node.cjs"
26
+ },
27
+ "default": {
28
+ "types": "./dist/index.d.cts",
29
+ "default": "./dist/index.cjs"
30
+ }
31
+ }
14
32
  },
15
33
  "./proto/spark": {
16
34
  "import": "./dist/proto/spark.js",
@@ -54,12 +72,10 @@
54
72
  "types": "tsc"
55
73
  },
56
74
  "dependencies": {
57
- "@buildonspark/lrc20-sdk": "0.0.60",
58
- "@buildonspark/spark-sdk": "0.2.5",
59
- "@lightsparkdev/core": "^1.4.2",
75
+ "@buildonspark/spark-sdk": "0.2.7",
76
+ "@lightsparkdev/core": "^1.4.3",
60
77
  "@noble/curves": "^1.8.0",
61
78
  "@scure/btc-signer": "^1.5.0",
62
- "bitcoinjs-lib": "^6.1.5",
63
79
  "buffer": "^6.0.3",
64
80
  "ts-proto": "^2.6.1"
65
81
  },
@@ -0,0 +1,2 @@
1
+ export { IssuerSparkWalletNodeJS as IssuerSparkWallet } from "./issuer-wallet/issuer-spark-wallet.node.js";
2
+ export * from "./issuer-wallet/types.js";
package/src/index.ts CHANGED
@@ -1,2 +1,2 @@
1
- export * from "./issuer-wallet/issuer-spark-wallet.js";
1
+ export { IssuerSparkWalletBrowser as IssuerSparkWallet } from "./issuer-wallet/issuer-spark-wallet.browser.js";
2
2
  export * from "./issuer-wallet/types.js";
@@ -0,0 +1,33 @@
1
+ import { IssuerSparkWallet as BaseIssuerSparkWallet } from "./issuer-spark-wallet.js";
2
+ import {
3
+ initializeTracerEnv as initializeTracerEnvBrowser,
4
+ type SparkWalletProps,
5
+ } from "@buildonspark/spark-sdk";
6
+
7
+ export class IssuerSparkWalletBrowser extends BaseIssuerSparkWallet {
8
+ public static async initialize({
9
+ mnemonicOrSeed,
10
+ accountNumber,
11
+ signer,
12
+ options,
13
+ }: SparkWalletProps) {
14
+ const wallet = new IssuerSparkWalletBrowser(options, signer);
15
+ wallet.initializeTracer(wallet);
16
+
17
+ const initResponse = await wallet.initWallet(mnemonicOrSeed, accountNumber);
18
+
19
+ return {
20
+ wallet,
21
+ ...initResponse,
22
+ };
23
+ }
24
+
25
+ protected initializeTracerEnv({
26
+ spanProcessors,
27
+ traceUrls,
28
+ }: Parameters<BaseIssuerSparkWallet["initializeTracerEnv"]>[0]) {
29
+ initializeTracerEnvBrowser({ spanProcessors, traceUrls });
30
+ }
31
+ }
32
+
33
+ export { IssuerSparkWalletBrowser as IssuerSparkWallet };
@@ -0,0 +1,33 @@
1
+ import { IssuerSparkWallet as BaseIssuerSparkWallet } from "./issuer-spark-wallet.js";
2
+ import {
3
+ initializeTracerEnv as initializeTracerEnvNodeJS,
4
+ type SparkWalletProps,
5
+ } from "@buildonspark/spark-sdk";
6
+
7
+ export class IssuerSparkWalletNodeJS extends BaseIssuerSparkWallet {
8
+ public static async initialize({
9
+ mnemonicOrSeed,
10
+ accountNumber,
11
+ signer,
12
+ options,
13
+ }: SparkWalletProps) {
14
+ const wallet = new IssuerSparkWalletNodeJS(options, signer);
15
+ wallet.initializeTracer(wallet);
16
+
17
+ const initResponse = await wallet.initWallet(mnemonicOrSeed, accountNumber);
18
+
19
+ return {
20
+ wallet,
21
+ ...initResponse,
22
+ };
23
+ }
24
+
25
+ protected initializeTracerEnv({
26
+ spanProcessors,
27
+ traceUrls,
28
+ }: Parameters<BaseIssuerSparkWallet["initializeTracerEnv"]>[0]) {
29
+ initializeTracerEnvNodeJS({ spanProcessors, traceUrls });
30
+ }
31
+ }
32
+
33
+ export { IssuerSparkWalletNodeJS as IssuerSparkWallet };