@buildonspark/issuer-sdk 0.0.99 → 0.0.100
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 +9 -0
- package/dist/native/index.react-native.cjs +588 -0
- package/dist/native/index.react-native.d.cts +149 -0
- package/dist/native/index.react-native.d.ts +149 -0
- package/dist/native/index.react-native.js +576 -0
- package/package.json +43 -4
- package/src/index.react-native.ts +4 -0
- package/src/issuer-wallet/issuer-spark-wallet.react-native.ts +8 -0
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import { SparkWallet, 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 abstract class IssuerSparkWallet extends SparkWallet {
|
|
55
|
+
private issuerTokenTransactionService;
|
|
56
|
+
private tokenFreezeService;
|
|
57
|
+
protected tracerId: string;
|
|
58
|
+
/**
|
|
59
|
+
* Initializes a new IssuerSparkWallet instance.
|
|
60
|
+
* Inherits the generic static initialize from the base class.
|
|
61
|
+
*/
|
|
62
|
+
constructor(configOptions?: ConfigOptions, signer?: SparkSigner);
|
|
63
|
+
/**
|
|
64
|
+
* Gets the token balance for the issuer's token.
|
|
65
|
+
* @returns An object containing the token balance as a bigint
|
|
66
|
+
*/
|
|
67
|
+
getIssuerTokenBalance(): Promise<{
|
|
68
|
+
tokenIdentifier: Bech32mTokenIdentifier | undefined;
|
|
69
|
+
balance: bigint;
|
|
70
|
+
}>;
|
|
71
|
+
/**
|
|
72
|
+
* Retrieves information about the issuer's token.
|
|
73
|
+
* @returns An object containing token information including public key, name, symbol, decimals, max supply, and freeze status
|
|
74
|
+
* @throws {NetworkError} If the token metadata cannot be retrieved
|
|
75
|
+
*/
|
|
76
|
+
getIssuerTokenMetadata(): Promise<IssuerTokenMetadata>;
|
|
77
|
+
/**
|
|
78
|
+
* Retrieves the bech32m encoded token identifier for the issuer's token.
|
|
79
|
+
* @returns The bech32m encoded token identifier for the issuer's token
|
|
80
|
+
* @throws {NetworkError} If the token identifier cannot be retrieved
|
|
81
|
+
*/
|
|
82
|
+
getIssuerTokenIdentifier(): Promise<Bech32mTokenIdentifier>;
|
|
83
|
+
/**
|
|
84
|
+
* Create a new token on Spark.
|
|
85
|
+
*
|
|
86
|
+
* @param params - Object containing token creation parameters.
|
|
87
|
+
* @param params.tokenName - The name of the token.
|
|
88
|
+
* @param params.tokenTicker - The ticker symbol for the token.
|
|
89
|
+
* @param params.decimals - The number of decimal places for the token.
|
|
90
|
+
* @param params.isFreezable - Whether the token can be frozen.
|
|
91
|
+
* @param [params.maxSupply=0n] - (Optional) The maximum supply of the token. Defaults to <code>0n</code>.
|
|
92
|
+
*
|
|
93
|
+
* @returns The transaction ID of the announcement.
|
|
94
|
+
*
|
|
95
|
+
* @throws {ValidationError} If `decimals` is not a safe integer or other validation fails.
|
|
96
|
+
* @throws {NetworkError} If the announcement transaction cannot be broadcast.
|
|
97
|
+
*/
|
|
98
|
+
createToken({ tokenName, tokenTicker, decimals, isFreezable, maxSupply, }: {
|
|
99
|
+
tokenName: string;
|
|
100
|
+
tokenTicker: string;
|
|
101
|
+
decimals: number;
|
|
102
|
+
isFreezable: boolean;
|
|
103
|
+
maxSupply?: bigint;
|
|
104
|
+
}): Promise<string>;
|
|
105
|
+
/**
|
|
106
|
+
* Mints new tokens
|
|
107
|
+
* @param tokenAmount - The amount of tokens to mint
|
|
108
|
+
* @returns The transaction ID of the mint operation
|
|
109
|
+
*/
|
|
110
|
+
mintTokens(tokenAmount: bigint): Promise<string>;
|
|
111
|
+
/**
|
|
112
|
+
* Burns issuer's tokens
|
|
113
|
+
* @param tokenAmount - The amount of tokens to burn
|
|
114
|
+
* @param selectedOutputs - Optional array of outputs to use for the burn operation
|
|
115
|
+
* @returns The transaction ID of the burn operation
|
|
116
|
+
*/
|
|
117
|
+
burnTokens(tokenAmount: bigint, selectedOutputs?: OutputWithPreviousTransactionData[]): Promise<string>;
|
|
118
|
+
/**
|
|
119
|
+
* Freezes tokens associated with a specific Spark address.
|
|
120
|
+
* @param sparkAddress - The Spark address whose tokens should be frozen
|
|
121
|
+
* @returns An object containing the IDs of impacted outputs and the total amount of frozen tokens
|
|
122
|
+
*/
|
|
123
|
+
freezeTokens(sparkAddress: string): Promise<{
|
|
124
|
+
impactedOutputIds: string[];
|
|
125
|
+
impactedTokenAmount: bigint;
|
|
126
|
+
}>;
|
|
127
|
+
/**
|
|
128
|
+
* Unfreezes previously frozen tokens associated with a specific Spark address.
|
|
129
|
+
* @param sparkAddress - The Spark address whose tokens should be unfrozen
|
|
130
|
+
* @returns An object containing the IDs of impacted outputs and the total amount of unfrozen tokens
|
|
131
|
+
*/
|
|
132
|
+
unfreezeTokens(sparkAddress: string): Promise<{
|
|
133
|
+
impactedOutputIds: string[];
|
|
134
|
+
impactedTokenAmount: bigint;
|
|
135
|
+
}>;
|
|
136
|
+
/**
|
|
137
|
+
* Retrieves the distribution information for the issuer's token.
|
|
138
|
+
* @throws {NotImplementedError} This feature is not yet supported
|
|
139
|
+
*/
|
|
140
|
+
getIssuerTokenDistribution(): Promise<TokenDistribution>;
|
|
141
|
+
protected getTraceName(methodName: string): string;
|
|
142
|
+
private wrapPublicIssuerSparkWalletMethodWithOtelSpan;
|
|
143
|
+
private wrapIssuerSparkWalletMethodsWithTracing;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
declare class IssuerSparkWalletReactNative extends IssuerSparkWallet {
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
export { IssuerSparkWalletReactNative as IssuerSparkWallet, type IssuerTokenMetadata, type TokenDistribution };
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import { SparkWallet, 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 abstract class IssuerSparkWallet extends SparkWallet {
|
|
55
|
+
private issuerTokenTransactionService;
|
|
56
|
+
private tokenFreezeService;
|
|
57
|
+
protected tracerId: string;
|
|
58
|
+
/**
|
|
59
|
+
* Initializes a new IssuerSparkWallet instance.
|
|
60
|
+
* Inherits the generic static initialize from the base class.
|
|
61
|
+
*/
|
|
62
|
+
constructor(configOptions?: ConfigOptions, signer?: SparkSigner);
|
|
63
|
+
/**
|
|
64
|
+
* Gets the token balance for the issuer's token.
|
|
65
|
+
* @returns An object containing the token balance as a bigint
|
|
66
|
+
*/
|
|
67
|
+
getIssuerTokenBalance(): Promise<{
|
|
68
|
+
tokenIdentifier: Bech32mTokenIdentifier | undefined;
|
|
69
|
+
balance: bigint;
|
|
70
|
+
}>;
|
|
71
|
+
/**
|
|
72
|
+
* Retrieves information about the issuer's token.
|
|
73
|
+
* @returns An object containing token information including public key, name, symbol, decimals, max supply, and freeze status
|
|
74
|
+
* @throws {NetworkError} If the token metadata cannot be retrieved
|
|
75
|
+
*/
|
|
76
|
+
getIssuerTokenMetadata(): Promise<IssuerTokenMetadata>;
|
|
77
|
+
/**
|
|
78
|
+
* Retrieves the bech32m encoded token identifier for the issuer's token.
|
|
79
|
+
* @returns The bech32m encoded token identifier for the issuer's token
|
|
80
|
+
* @throws {NetworkError} If the token identifier cannot be retrieved
|
|
81
|
+
*/
|
|
82
|
+
getIssuerTokenIdentifier(): Promise<Bech32mTokenIdentifier>;
|
|
83
|
+
/**
|
|
84
|
+
* Create a new token on Spark.
|
|
85
|
+
*
|
|
86
|
+
* @param params - Object containing token creation parameters.
|
|
87
|
+
* @param params.tokenName - The name of the token.
|
|
88
|
+
* @param params.tokenTicker - The ticker symbol for the token.
|
|
89
|
+
* @param params.decimals - The number of decimal places for the token.
|
|
90
|
+
* @param params.isFreezable - Whether the token can be frozen.
|
|
91
|
+
* @param [params.maxSupply=0n] - (Optional) The maximum supply of the token. Defaults to <code>0n</code>.
|
|
92
|
+
*
|
|
93
|
+
* @returns The transaction ID of the announcement.
|
|
94
|
+
*
|
|
95
|
+
* @throws {ValidationError} If `decimals` is not a safe integer or other validation fails.
|
|
96
|
+
* @throws {NetworkError} If the announcement transaction cannot be broadcast.
|
|
97
|
+
*/
|
|
98
|
+
createToken({ tokenName, tokenTicker, decimals, isFreezable, maxSupply, }: {
|
|
99
|
+
tokenName: string;
|
|
100
|
+
tokenTicker: string;
|
|
101
|
+
decimals: number;
|
|
102
|
+
isFreezable: boolean;
|
|
103
|
+
maxSupply?: bigint;
|
|
104
|
+
}): Promise<string>;
|
|
105
|
+
/**
|
|
106
|
+
* Mints new tokens
|
|
107
|
+
* @param tokenAmount - The amount of tokens to mint
|
|
108
|
+
* @returns The transaction ID of the mint operation
|
|
109
|
+
*/
|
|
110
|
+
mintTokens(tokenAmount: bigint): Promise<string>;
|
|
111
|
+
/**
|
|
112
|
+
* Burns issuer's tokens
|
|
113
|
+
* @param tokenAmount - The amount of tokens to burn
|
|
114
|
+
* @param selectedOutputs - Optional array of outputs to use for the burn operation
|
|
115
|
+
* @returns The transaction ID of the burn operation
|
|
116
|
+
*/
|
|
117
|
+
burnTokens(tokenAmount: bigint, selectedOutputs?: OutputWithPreviousTransactionData[]): Promise<string>;
|
|
118
|
+
/**
|
|
119
|
+
* Freezes tokens associated with a specific Spark address.
|
|
120
|
+
* @param sparkAddress - The Spark address whose tokens should be frozen
|
|
121
|
+
* @returns An object containing the IDs of impacted outputs and the total amount of frozen tokens
|
|
122
|
+
*/
|
|
123
|
+
freezeTokens(sparkAddress: string): Promise<{
|
|
124
|
+
impactedOutputIds: string[];
|
|
125
|
+
impactedTokenAmount: bigint;
|
|
126
|
+
}>;
|
|
127
|
+
/**
|
|
128
|
+
* Unfreezes previously frozen tokens associated with a specific Spark address.
|
|
129
|
+
* @param sparkAddress - The Spark address whose tokens should be unfrozen
|
|
130
|
+
* @returns An object containing the IDs of impacted outputs and the total amount of unfrozen tokens
|
|
131
|
+
*/
|
|
132
|
+
unfreezeTokens(sparkAddress: string): Promise<{
|
|
133
|
+
impactedOutputIds: string[];
|
|
134
|
+
impactedTokenAmount: bigint;
|
|
135
|
+
}>;
|
|
136
|
+
/**
|
|
137
|
+
* Retrieves the distribution information for the issuer's token.
|
|
138
|
+
* @throws {NotImplementedError} This feature is not yet supported
|
|
139
|
+
*/
|
|
140
|
+
getIssuerTokenDistribution(): Promise<TokenDistribution>;
|
|
141
|
+
protected getTraceName(methodName: string): string;
|
|
142
|
+
private wrapPublicIssuerSparkWalletMethodWithOtelSpan;
|
|
143
|
+
private wrapIssuerSparkWalletMethodsWithTracing;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
declare class IssuerSparkWalletReactNative extends IssuerSparkWallet {
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
export { IssuerSparkWalletReactNative as IssuerSparkWallet, type IssuerTokenMetadata, type TokenDistribution };
|