@buildonspark/issuer-sdk 0.0.30 → 0.0.32
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 +31 -39
- package/dist/index.d.cts +17 -9
- package/dist/index.d.ts +17 -9
- package/dist/index.js +31 -39
- package/package.json +4 -3
- package/src/index.ts +1 -1
- package/src/issuer-spark-wallet.ts +39 -28
- package/src/proto/common.ts +91 -38
- package/src/proto/google/protobuf/descriptor.ts +2308 -1439
- package/src/proto/google/protobuf/duration.ts +28 -10
- package/src/proto/google/protobuf/empty.ts +24 -10
- package/src/proto/google/protobuf/timestamp.ts +28 -10
- package/src/proto/mock.ts +84 -54
- package/src/proto/spark.ts +9718 -7485
- package/src/proto/spark_authn.ts +165 -60
- package/src/proto/validate/validate.ts +1157 -661
- package/src/services/token-transactions.ts +2 -2
- package/src/tests/integration/spark.test.ts +11 -82
- package/src/tests/stress/transfers.test.ts +101 -10
- package/src/types.ts +73 -70
- package/src/utils/enum-mappers.ts +16 -5
- package/src/utils/token-hashing.ts +2 -2
- package/src/utils/type-mappers.ts +136 -103
package/dist/index.cjs
CHANGED
|
@@ -140,14 +140,14 @@ var IssuerTokenTransactionService = class extends import_token_transactions.Toke
|
|
|
140
140
|
async constructMintTokenTransaction(tokenPublicKey, tokenAmount) {
|
|
141
141
|
return {
|
|
142
142
|
network: this.config.getNetworkProto(),
|
|
143
|
-
|
|
143
|
+
tokenInputs: {
|
|
144
144
|
$case: "mintInput",
|
|
145
145
|
mintInput: {
|
|
146
146
|
issuerPublicKey: tokenPublicKey,
|
|
147
147
|
issuerProvidedTimestamp: Date.now()
|
|
148
148
|
}
|
|
149
149
|
},
|
|
150
|
-
|
|
150
|
+
tokenOutputs: [
|
|
151
151
|
{
|
|
152
152
|
ownerPublicKey: tokenPublicKey,
|
|
153
153
|
tokenPublicKey,
|
|
@@ -228,21 +228,6 @@ function mapLayer(layer) {
|
|
|
228
228
|
}
|
|
229
229
|
|
|
230
230
|
// src/utils/type-mappers.ts
|
|
231
|
-
function convertToTokenPubKeyInfoResponse(tokenPubkeyInfo) {
|
|
232
|
-
return {
|
|
233
|
-
announcement: tokenPubkeyInfo?.announcement ? {
|
|
234
|
-
tokenPubkey: {
|
|
235
|
-
pubkey: (0, import_utils4.bytesToHex)(tokenPubkeyInfo.announcement.tokenPubkey.pubkey)
|
|
236
|
-
},
|
|
237
|
-
name: tokenPubkeyInfo.announcement.name,
|
|
238
|
-
symbol: tokenPubkeyInfo.announcement.symbol,
|
|
239
|
-
decimal: tokenPubkeyInfo.announcement.decimal,
|
|
240
|
-
maxSupply: tokenPubkeyInfo.announcement.maxSupply,
|
|
241
|
-
isFreezable: tokenPubkeyInfo.announcement.isFreezable
|
|
242
|
-
} : null,
|
|
243
|
-
totalSupply: tokenPubkeyInfo?.totalSupply ?? "0"
|
|
244
|
-
};
|
|
245
|
-
}
|
|
246
231
|
function convertTokenActivityToHexEncoded(rawTransactions) {
|
|
247
232
|
const response = {
|
|
248
233
|
transactions: rawTransactions.transactions.map((transaction) => {
|
|
@@ -316,7 +301,9 @@ function convertTokenActivityToHexEncoded(rawTransactions) {
|
|
|
316
301
|
spendTxVoutIndex: leaf.spendTxVoutIndex,
|
|
317
302
|
isFrozen: leaf.isFrozen
|
|
318
303
|
})),
|
|
319
|
-
sparkOperatorIdentityPublicKeys: spark.sparkOperatorIdentityPublicKeys.map(
|
|
304
|
+
sparkOperatorIdentityPublicKeys: spark.sparkOperatorIdentityPublicKeys.map(
|
|
305
|
+
(key) => (0, import_utils4.bytesToHex)(key)
|
|
306
|
+
)
|
|
320
307
|
}
|
|
321
308
|
}
|
|
322
309
|
};
|
|
@@ -324,7 +311,9 @@ function convertTokenActivityToHexEncoded(rawTransactions) {
|
|
|
324
311
|
return { transaction: void 0 };
|
|
325
312
|
}),
|
|
326
313
|
nextCursor: rawTransactions.nextCursor ? {
|
|
327
|
-
lastTransactionHash: (0, import_utils4.bytesToHex)(
|
|
314
|
+
lastTransactionHash: (0, import_utils4.bytesToHex)(
|
|
315
|
+
rawTransactions.nextCursor.lastTransactionHash
|
|
316
|
+
),
|
|
328
317
|
layer: mapLayer(rawTransactions.nextCursor.layer)
|
|
329
318
|
} : void 0
|
|
330
319
|
};
|
|
@@ -370,16 +359,19 @@ var IssuerSparkWallet = class _IssuerSparkWallet extends import_spark_sdk.SparkW
|
|
|
370
359
|
};
|
|
371
360
|
}
|
|
372
361
|
async getIssuerTokenInfo() {
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
const
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
362
|
+
const lrc20Client = await this.lrc20ConnectionManager.createLrc20Client();
|
|
363
|
+
const tokenInfo = await lrc20Client.getTokenPubkeyInfo({
|
|
364
|
+
publicKeys: [(0, import_utils5.hexToBytes)(await super.getIdentityPublicKey())]
|
|
365
|
+
});
|
|
366
|
+
const info = tokenInfo.tokenPubkeyInfos[0];
|
|
367
|
+
return {
|
|
368
|
+
tokenPublicKey: (0, import_utils5.bytesToHex)(info.announcement.publicKey.publicKey),
|
|
369
|
+
tokenName: info.announcement.name,
|
|
370
|
+
tokenSymbol: info.announcement.symbol,
|
|
371
|
+
tokenDecimals: Number((0, import_utils5.bytesToNumberBE)(info.announcement.decimal)),
|
|
372
|
+
isFreezable: info.announcement.isFreezable,
|
|
373
|
+
maxSupply: (0, import_utils5.bytesToNumberBE)(info.totalSupply)
|
|
374
|
+
};
|
|
383
375
|
}
|
|
384
376
|
async getIssuerTokenPublicKey() {
|
|
385
377
|
return await super.getIdentityPublicKey();
|
|
@@ -394,7 +386,7 @@ var IssuerSparkWallet = class _IssuerSparkWallet extends import_spark_sdk.SparkW
|
|
|
394
386
|
tokenTransaction
|
|
395
387
|
);
|
|
396
388
|
}
|
|
397
|
-
async burnTokens(tokenAmount,
|
|
389
|
+
async burnTokens(tokenAmount, selectedOutputs) {
|
|
398
390
|
const burnAddress = (0, import_address.encodeSparkAddress)({
|
|
399
391
|
identityPublicKey: BURN_ADDRESS,
|
|
400
392
|
network: this.config.getNetworkType()
|
|
@@ -403,14 +395,14 @@ var IssuerSparkWallet = class _IssuerSparkWallet extends import_spark_sdk.SparkW
|
|
|
403
395
|
tokenPublicKey: await super.getIdentityPublicKey(),
|
|
404
396
|
tokenAmount,
|
|
405
397
|
receiverSparkAddress: burnAddress,
|
|
406
|
-
|
|
398
|
+
selectedOutputs
|
|
407
399
|
});
|
|
408
400
|
}
|
|
409
|
-
async freezeTokens(
|
|
410
|
-
await this.
|
|
401
|
+
async freezeTokens(sparkAddress) {
|
|
402
|
+
await this.syncTokenOutputs();
|
|
411
403
|
const tokenPublicKey = await super.getIdentityPublicKey();
|
|
412
404
|
const decodedOwnerPubkey = (0, import_address2.decodeSparkAddress)(
|
|
413
|
-
|
|
405
|
+
sparkAddress,
|
|
414
406
|
this.config.getNetworkType()
|
|
415
407
|
);
|
|
416
408
|
const response = await this.tokenFreezeService.freezeTokens(
|
|
@@ -419,15 +411,15 @@ var IssuerSparkWallet = class _IssuerSparkWallet extends import_spark_sdk.SparkW
|
|
|
419
411
|
);
|
|
420
412
|
const tokenAmount = (0, import_utils5.bytesToNumberBE)(response.impactedTokenAmount);
|
|
421
413
|
return {
|
|
422
|
-
|
|
414
|
+
impactedOutputIds: response.impactedOutputIds,
|
|
423
415
|
impactedTokenAmount: tokenAmount
|
|
424
416
|
};
|
|
425
417
|
}
|
|
426
|
-
async unfreezeTokens(
|
|
427
|
-
await this.
|
|
418
|
+
async unfreezeTokens(sparkAddress) {
|
|
419
|
+
await this.syncTokenOutputs();
|
|
428
420
|
const tokenPublicKey = await super.getIdentityPublicKey();
|
|
429
421
|
const decodedOwnerPubkey = (0, import_address2.decodeSparkAddress)(
|
|
430
|
-
|
|
422
|
+
sparkAddress,
|
|
431
423
|
this.config.getNetworkType()
|
|
432
424
|
);
|
|
433
425
|
const response = await this.tokenFreezeService.unfreezeTokens(
|
|
@@ -436,7 +428,7 @@ var IssuerSparkWallet = class _IssuerSparkWallet extends import_spark_sdk.SparkW
|
|
|
436
428
|
);
|
|
437
429
|
const tokenAmount = (0, import_utils5.bytesToNumberBE)(response.impactedTokenAmount);
|
|
438
430
|
return {
|
|
439
|
-
|
|
431
|
+
impactedOutputIds: response.impactedOutputIds,
|
|
440
432
|
impactedTokenAmount: tokenAmount
|
|
441
433
|
};
|
|
442
434
|
}
|
package/dist/index.d.cts
CHANGED
|
@@ -1,8 +1,16 @@
|
|
|
1
1
|
import { ListAllTokenTransactionsCursor, OperationType } from '@buildonspark/lrc20-sdk/proto/rpc/v1/types';
|
|
2
2
|
import { SparkWallet, SparkWalletProps } from '@buildonspark/spark-sdk';
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
3
|
+
import { OutputWithPreviousTransactionData } from '@buildonspark/spark-sdk/proto/spark';
|
|
4
|
+
import { GetTokenActivityResponse } from './types.cjs';
|
|
5
5
|
|
|
6
|
+
type IssuerTokenInfo = {
|
|
7
|
+
tokenPublicKey: string;
|
|
8
|
+
tokenName: string;
|
|
9
|
+
tokenSymbol: string;
|
|
10
|
+
tokenDecimals: number;
|
|
11
|
+
maxSupply: bigint;
|
|
12
|
+
isFreezable: boolean;
|
|
13
|
+
};
|
|
6
14
|
declare class IssuerSparkWallet extends SparkWallet {
|
|
7
15
|
private issuerTokenTransactionService;
|
|
8
16
|
private tokenFreezeService;
|
|
@@ -15,16 +23,16 @@ declare class IssuerSparkWallet extends SparkWallet {
|
|
|
15
23
|
getIssuerTokenBalance(): Promise<{
|
|
16
24
|
balance: bigint;
|
|
17
25
|
}>;
|
|
18
|
-
getIssuerTokenInfo(): Promise<
|
|
26
|
+
getIssuerTokenInfo(): Promise<IssuerTokenInfo | null>;
|
|
19
27
|
getIssuerTokenPublicKey(): Promise<string>;
|
|
20
28
|
mintTokens(tokenAmount: bigint): Promise<string>;
|
|
21
|
-
burnTokens(tokenAmount: bigint,
|
|
22
|
-
freezeTokens(
|
|
23
|
-
|
|
29
|
+
burnTokens(tokenAmount: bigint, selectedOutputs?: OutputWithPreviousTransactionData[]): Promise<string>;
|
|
30
|
+
freezeTokens(sparkAddress: string): Promise<{
|
|
31
|
+
impactedOutputIds: string[];
|
|
24
32
|
impactedTokenAmount: bigint;
|
|
25
33
|
}>;
|
|
26
|
-
unfreezeTokens(
|
|
27
|
-
|
|
34
|
+
unfreezeTokens(sparkAddress: string): Promise<{
|
|
35
|
+
impactedOutputIds: string[];
|
|
28
36
|
impactedTokenAmount: bigint;
|
|
29
37
|
}>;
|
|
30
38
|
getTokenActivity(pageSize?: number, cursor?: ListAllTokenTransactionsCursor, operationTypes?: OperationType[], beforeTimestamp?: Date, afterTimestamp?: Date): Promise<GetTokenActivityResponse>;
|
|
@@ -41,4 +49,4 @@ declare class IssuerSparkWallet extends SparkWallet {
|
|
|
41
49
|
transferTokensL1(tokenAmount: bigint, p2trAddress: string): Promise<string>;
|
|
42
50
|
}
|
|
43
51
|
|
|
44
|
-
export { IssuerSparkWallet };
|
|
52
|
+
export { IssuerSparkWallet, type IssuerTokenInfo };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,16 @@
|
|
|
1
1
|
import { ListAllTokenTransactionsCursor, OperationType } from '@buildonspark/lrc20-sdk/proto/rpc/v1/types';
|
|
2
2
|
import { SparkWallet, SparkWalletProps } from '@buildonspark/spark-sdk';
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
3
|
+
import { OutputWithPreviousTransactionData } from '@buildonspark/spark-sdk/proto/spark';
|
|
4
|
+
import { GetTokenActivityResponse } from './types.js';
|
|
5
5
|
|
|
6
|
+
type IssuerTokenInfo = {
|
|
7
|
+
tokenPublicKey: string;
|
|
8
|
+
tokenName: string;
|
|
9
|
+
tokenSymbol: string;
|
|
10
|
+
tokenDecimals: number;
|
|
11
|
+
maxSupply: bigint;
|
|
12
|
+
isFreezable: boolean;
|
|
13
|
+
};
|
|
6
14
|
declare class IssuerSparkWallet extends SparkWallet {
|
|
7
15
|
private issuerTokenTransactionService;
|
|
8
16
|
private tokenFreezeService;
|
|
@@ -15,16 +23,16 @@ declare class IssuerSparkWallet extends SparkWallet {
|
|
|
15
23
|
getIssuerTokenBalance(): Promise<{
|
|
16
24
|
balance: bigint;
|
|
17
25
|
}>;
|
|
18
|
-
getIssuerTokenInfo(): Promise<
|
|
26
|
+
getIssuerTokenInfo(): Promise<IssuerTokenInfo | null>;
|
|
19
27
|
getIssuerTokenPublicKey(): Promise<string>;
|
|
20
28
|
mintTokens(tokenAmount: bigint): Promise<string>;
|
|
21
|
-
burnTokens(tokenAmount: bigint,
|
|
22
|
-
freezeTokens(
|
|
23
|
-
|
|
29
|
+
burnTokens(tokenAmount: bigint, selectedOutputs?: OutputWithPreviousTransactionData[]): Promise<string>;
|
|
30
|
+
freezeTokens(sparkAddress: string): Promise<{
|
|
31
|
+
impactedOutputIds: string[];
|
|
24
32
|
impactedTokenAmount: bigint;
|
|
25
33
|
}>;
|
|
26
|
-
unfreezeTokens(
|
|
27
|
-
|
|
34
|
+
unfreezeTokens(sparkAddress: string): Promise<{
|
|
35
|
+
impactedOutputIds: string[];
|
|
28
36
|
impactedTokenAmount: bigint;
|
|
29
37
|
}>;
|
|
30
38
|
getTokenActivity(pageSize?: number, cursor?: ListAllTokenTransactionsCursor, operationTypes?: OperationType[], beforeTimestamp?: Date, afterTimestamp?: Date): Promise<GetTokenActivityResponse>;
|
|
@@ -41,4 +49,4 @@ declare class IssuerSparkWallet extends SparkWallet {
|
|
|
41
49
|
transferTokensL1(tokenAmount: bigint, p2trAddress: string): Promise<string>;
|
|
42
50
|
}
|
|
43
51
|
|
|
44
|
-
export { IssuerSparkWallet };
|
|
52
|
+
export { IssuerSparkWallet, type IssuerTokenInfo };
|
package/dist/index.js
CHANGED
|
@@ -114,14 +114,14 @@ var IssuerTokenTransactionService = class extends TokenTransactionService {
|
|
|
114
114
|
async constructMintTokenTransaction(tokenPublicKey, tokenAmount) {
|
|
115
115
|
return {
|
|
116
116
|
network: this.config.getNetworkProto(),
|
|
117
|
-
|
|
117
|
+
tokenInputs: {
|
|
118
118
|
$case: "mintInput",
|
|
119
119
|
mintInput: {
|
|
120
120
|
issuerPublicKey: tokenPublicKey,
|
|
121
121
|
issuerProvidedTimestamp: Date.now()
|
|
122
122
|
}
|
|
123
123
|
},
|
|
124
|
-
|
|
124
|
+
tokenOutputs: [
|
|
125
125
|
{
|
|
126
126
|
ownerPublicKey: tokenPublicKey,
|
|
127
127
|
tokenPublicKey,
|
|
@@ -202,21 +202,6 @@ function mapLayer(layer) {
|
|
|
202
202
|
}
|
|
203
203
|
|
|
204
204
|
// src/utils/type-mappers.ts
|
|
205
|
-
function convertToTokenPubKeyInfoResponse(tokenPubkeyInfo) {
|
|
206
|
-
return {
|
|
207
|
-
announcement: tokenPubkeyInfo?.announcement ? {
|
|
208
|
-
tokenPubkey: {
|
|
209
|
-
pubkey: bytesToHex(tokenPubkeyInfo.announcement.tokenPubkey.pubkey)
|
|
210
|
-
},
|
|
211
|
-
name: tokenPubkeyInfo.announcement.name,
|
|
212
|
-
symbol: tokenPubkeyInfo.announcement.symbol,
|
|
213
|
-
decimal: tokenPubkeyInfo.announcement.decimal,
|
|
214
|
-
maxSupply: tokenPubkeyInfo.announcement.maxSupply,
|
|
215
|
-
isFreezable: tokenPubkeyInfo.announcement.isFreezable
|
|
216
|
-
} : null,
|
|
217
|
-
totalSupply: tokenPubkeyInfo?.totalSupply ?? "0"
|
|
218
|
-
};
|
|
219
|
-
}
|
|
220
205
|
function convertTokenActivityToHexEncoded(rawTransactions) {
|
|
221
206
|
const response = {
|
|
222
207
|
transactions: rawTransactions.transactions.map((transaction) => {
|
|
@@ -290,7 +275,9 @@ function convertTokenActivityToHexEncoded(rawTransactions) {
|
|
|
290
275
|
spendTxVoutIndex: leaf.spendTxVoutIndex,
|
|
291
276
|
isFrozen: leaf.isFrozen
|
|
292
277
|
})),
|
|
293
|
-
sparkOperatorIdentityPublicKeys: spark.sparkOperatorIdentityPublicKeys.map(
|
|
278
|
+
sparkOperatorIdentityPublicKeys: spark.sparkOperatorIdentityPublicKeys.map(
|
|
279
|
+
(key) => bytesToHex(key)
|
|
280
|
+
)
|
|
294
281
|
}
|
|
295
282
|
}
|
|
296
283
|
};
|
|
@@ -298,7 +285,9 @@ function convertTokenActivityToHexEncoded(rawTransactions) {
|
|
|
298
285
|
return { transaction: void 0 };
|
|
299
286
|
}),
|
|
300
287
|
nextCursor: rawTransactions.nextCursor ? {
|
|
301
|
-
lastTransactionHash: bytesToHex(
|
|
288
|
+
lastTransactionHash: bytesToHex(
|
|
289
|
+
rawTransactions.nextCursor.lastTransactionHash
|
|
290
|
+
),
|
|
302
291
|
layer: mapLayer(rawTransactions.nextCursor.layer)
|
|
303
292
|
} : void 0
|
|
304
293
|
};
|
|
@@ -344,16 +333,19 @@ var IssuerSparkWallet = class _IssuerSparkWallet extends SparkWallet {
|
|
|
344
333
|
};
|
|
345
334
|
}
|
|
346
335
|
async getIssuerTokenInfo() {
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
const
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
336
|
+
const lrc20Client = await this.lrc20ConnectionManager.createLrc20Client();
|
|
337
|
+
const tokenInfo = await lrc20Client.getTokenPubkeyInfo({
|
|
338
|
+
publicKeys: [hexToBytes(await super.getIdentityPublicKey())]
|
|
339
|
+
});
|
|
340
|
+
const info = tokenInfo.tokenPubkeyInfos[0];
|
|
341
|
+
return {
|
|
342
|
+
tokenPublicKey: bytesToHex2(info.announcement.publicKey.publicKey),
|
|
343
|
+
tokenName: info.announcement.name,
|
|
344
|
+
tokenSymbol: info.announcement.symbol,
|
|
345
|
+
tokenDecimals: Number(bytesToNumberBE2(info.announcement.decimal)),
|
|
346
|
+
isFreezable: info.announcement.isFreezable,
|
|
347
|
+
maxSupply: bytesToNumberBE2(info.totalSupply)
|
|
348
|
+
};
|
|
357
349
|
}
|
|
358
350
|
async getIssuerTokenPublicKey() {
|
|
359
351
|
return await super.getIdentityPublicKey();
|
|
@@ -368,7 +360,7 @@ var IssuerSparkWallet = class _IssuerSparkWallet extends SparkWallet {
|
|
|
368
360
|
tokenTransaction
|
|
369
361
|
);
|
|
370
362
|
}
|
|
371
|
-
async burnTokens(tokenAmount,
|
|
363
|
+
async burnTokens(tokenAmount, selectedOutputs) {
|
|
372
364
|
const burnAddress = encodeSparkAddress({
|
|
373
365
|
identityPublicKey: BURN_ADDRESS,
|
|
374
366
|
network: this.config.getNetworkType()
|
|
@@ -377,14 +369,14 @@ var IssuerSparkWallet = class _IssuerSparkWallet extends SparkWallet {
|
|
|
377
369
|
tokenPublicKey: await super.getIdentityPublicKey(),
|
|
378
370
|
tokenAmount,
|
|
379
371
|
receiverSparkAddress: burnAddress,
|
|
380
|
-
|
|
372
|
+
selectedOutputs
|
|
381
373
|
});
|
|
382
374
|
}
|
|
383
|
-
async freezeTokens(
|
|
384
|
-
await this.
|
|
375
|
+
async freezeTokens(sparkAddress) {
|
|
376
|
+
await this.syncTokenOutputs();
|
|
385
377
|
const tokenPublicKey = await super.getIdentityPublicKey();
|
|
386
378
|
const decodedOwnerPubkey = decodeSparkAddress(
|
|
387
|
-
|
|
379
|
+
sparkAddress,
|
|
388
380
|
this.config.getNetworkType()
|
|
389
381
|
);
|
|
390
382
|
const response = await this.tokenFreezeService.freezeTokens(
|
|
@@ -393,15 +385,15 @@ var IssuerSparkWallet = class _IssuerSparkWallet extends SparkWallet {
|
|
|
393
385
|
);
|
|
394
386
|
const tokenAmount = bytesToNumberBE2(response.impactedTokenAmount);
|
|
395
387
|
return {
|
|
396
|
-
|
|
388
|
+
impactedOutputIds: response.impactedOutputIds,
|
|
397
389
|
impactedTokenAmount: tokenAmount
|
|
398
390
|
};
|
|
399
391
|
}
|
|
400
|
-
async unfreezeTokens(
|
|
401
|
-
await this.
|
|
392
|
+
async unfreezeTokens(sparkAddress) {
|
|
393
|
+
await this.syncTokenOutputs();
|
|
402
394
|
const tokenPublicKey = await super.getIdentityPublicKey();
|
|
403
395
|
const decodedOwnerPubkey = decodeSparkAddress(
|
|
404
|
-
|
|
396
|
+
sparkAddress,
|
|
405
397
|
this.config.getNetworkType()
|
|
406
398
|
);
|
|
407
399
|
const response = await this.tokenFreezeService.unfreezeTokens(
|
|
@@ -410,7 +402,7 @@ var IssuerSparkWallet = class _IssuerSparkWallet extends SparkWallet {
|
|
|
410
402
|
);
|
|
411
403
|
const tokenAmount = bytesToNumberBE2(response.impactedTokenAmount);
|
|
412
404
|
return {
|
|
413
|
-
|
|
405
|
+
impactedOutputIds: response.impactedOutputIds,
|
|
414
406
|
impactedTokenAmount: tokenAmount
|
|
415
407
|
};
|
|
416
408
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@buildonspark/issuer-sdk",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.32",
|
|
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.
|
|
57
|
+
"@buildonspark/lrc20-sdk": "0.0.29",
|
|
58
|
+
"@buildonspark/spark-sdk": "0.1.1",
|
|
59
59
|
"@noble/curves": "^1.8.0",
|
|
60
60
|
"@scure/bip39": "^1.5.4",
|
|
61
61
|
"@scure/btc-signer": "^1.5.0",
|
|
@@ -73,6 +73,7 @@
|
|
|
73
73
|
"jest": "^29.7.0",
|
|
74
74
|
"madge": "^8.0.0",
|
|
75
75
|
"node-fetch": "^3.3.2",
|
|
76
|
+
"prettier": "^3.5.1",
|
|
76
77
|
"publint": "^0.3.9",
|
|
77
78
|
"ts-jest": "^29.2.5",
|
|
78
79
|
"tsup": "^8.4.0",
|
package/src/index.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from "./issuer-spark-wallet.js";
|
|
1
|
+
export * from "./issuer-spark-wallet.js";
|
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
} from "@buildonspark/lrc20-sdk/proto/rpc/v1/types";
|
|
11
11
|
import { SparkWallet, SparkWalletProps } from "@buildonspark/spark-sdk";
|
|
12
12
|
import { encodeSparkAddress } from "@buildonspark/spark-sdk/address";
|
|
13
|
-
import {
|
|
13
|
+
import { OutputWithPreviousTransactionData } from "@buildonspark/spark-sdk/proto/spark";
|
|
14
14
|
import { ConfigOptions } from "@buildonspark/spark-sdk/services/wallet-config";
|
|
15
15
|
import {
|
|
16
16
|
getMasterHDKeyFromSeed,
|
|
@@ -36,9 +36,16 @@ import { decodeSparkAddress } from "@buildonspark/spark-sdk/address";
|
|
|
36
36
|
|
|
37
37
|
const BURN_ADDRESS = "02".repeat(33);
|
|
38
38
|
|
|
39
|
-
export
|
|
40
|
-
|
|
41
|
-
|
|
39
|
+
export type IssuerTokenInfo = {
|
|
40
|
+
tokenPublicKey: string;
|
|
41
|
+
tokenName: string;
|
|
42
|
+
tokenSymbol: string;
|
|
43
|
+
tokenDecimals: number;
|
|
44
|
+
maxSupply: bigint;
|
|
45
|
+
isFreezable: boolean;
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
export class IssuerSparkWallet extends SparkWallet {
|
|
42
49
|
private issuerTokenTransactionService: IssuerTokenTransactionService;
|
|
43
50
|
private tokenFreezeService: TokenFreezeService;
|
|
44
51
|
private tokenPublicKeyInfo?: TokenPubkeyInfo;
|
|
@@ -81,18 +88,22 @@ export class IssuerSparkWallet
|
|
|
81
88
|
};
|
|
82
89
|
}
|
|
83
90
|
|
|
84
|
-
public async getIssuerTokenInfo(): Promise<
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
91
|
+
public async getIssuerTokenInfo(): Promise<IssuerTokenInfo | null> {
|
|
92
|
+
const lrc20Client = await this.lrc20ConnectionManager.createLrc20Client();
|
|
93
|
+
|
|
94
|
+
const tokenInfo = await lrc20Client.getTokenPubkeyInfo({
|
|
95
|
+
publicKeys: [hexToBytes(await super.getIdentityPublicKey())],
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
const info = tokenInfo.tokenPubkeyInfos[0];
|
|
99
|
+
return {
|
|
100
|
+
tokenPublicKey: bytesToHex(info.announcement!.publicKey!.publicKey),
|
|
101
|
+
tokenName: info.announcement!.name,
|
|
102
|
+
tokenSymbol: info.announcement!.symbol,
|
|
103
|
+
tokenDecimals: Number(bytesToNumberBE(info.announcement!.decimal)),
|
|
104
|
+
isFreezable: info.announcement!.isFreezable,
|
|
105
|
+
maxSupply: bytesToNumberBE(info.totalSupply),
|
|
106
|
+
};
|
|
96
107
|
}
|
|
97
108
|
|
|
98
109
|
public async getIssuerTokenPublicKey() {
|
|
@@ -115,7 +126,7 @@ export class IssuerSparkWallet
|
|
|
115
126
|
|
|
116
127
|
public async burnTokens(
|
|
117
128
|
tokenAmount: bigint,
|
|
118
|
-
|
|
129
|
+
selectedOutputs?: OutputWithPreviousTransactionData[],
|
|
119
130
|
): Promise<string> {
|
|
120
131
|
const burnAddress = encodeSparkAddress({
|
|
121
132
|
identityPublicKey: BURN_ADDRESS,
|
|
@@ -125,17 +136,17 @@ export class IssuerSparkWallet
|
|
|
125
136
|
tokenPublicKey: await super.getIdentityPublicKey(),
|
|
126
137
|
tokenAmount,
|
|
127
138
|
receiverSparkAddress: burnAddress,
|
|
128
|
-
|
|
139
|
+
selectedOutputs,
|
|
129
140
|
});
|
|
130
141
|
}
|
|
131
142
|
|
|
132
143
|
public async freezeTokens(
|
|
133
|
-
|
|
134
|
-
): Promise<{
|
|
135
|
-
await this.
|
|
144
|
+
sparkAddress: string,
|
|
145
|
+
): Promise<{ impactedOutputIds: string[]; impactedTokenAmount: bigint }> {
|
|
146
|
+
await this.syncTokenOutputs();
|
|
136
147
|
const tokenPublicKey = await super.getIdentityPublicKey();
|
|
137
148
|
const decodedOwnerPubkey = decodeSparkAddress(
|
|
138
|
-
|
|
149
|
+
sparkAddress,
|
|
139
150
|
this.config.getNetworkType(),
|
|
140
151
|
);
|
|
141
152
|
const response = await this.tokenFreezeService!.freezeTokens(
|
|
@@ -147,18 +158,18 @@ export class IssuerSparkWallet
|
|
|
147
158
|
const tokenAmount = bytesToNumberBE(response.impactedTokenAmount);
|
|
148
159
|
|
|
149
160
|
return {
|
|
150
|
-
|
|
161
|
+
impactedOutputIds: response.impactedOutputIds,
|
|
151
162
|
impactedTokenAmount: tokenAmount,
|
|
152
163
|
};
|
|
153
164
|
}
|
|
154
165
|
|
|
155
166
|
public async unfreezeTokens(
|
|
156
|
-
|
|
157
|
-
): Promise<{
|
|
158
|
-
await this.
|
|
167
|
+
sparkAddress: string,
|
|
168
|
+
): Promise<{ impactedOutputIds: string[]; impactedTokenAmount: bigint }> {
|
|
169
|
+
await this.syncTokenOutputs();
|
|
159
170
|
const tokenPublicKey = await super.getIdentityPublicKey();
|
|
160
171
|
const decodedOwnerPubkey = decodeSparkAddress(
|
|
161
|
-
|
|
172
|
+
sparkAddress,
|
|
162
173
|
this.config.getNetworkType(),
|
|
163
174
|
);
|
|
164
175
|
const response = await this.tokenFreezeService!.unfreezeTokens(
|
|
@@ -168,7 +179,7 @@ export class IssuerSparkWallet
|
|
|
168
179
|
const tokenAmount = bytesToNumberBE(response.impactedTokenAmount);
|
|
169
180
|
|
|
170
181
|
return {
|
|
171
|
-
|
|
182
|
+
impactedOutputIds: response.impactedOutputIds,
|
|
172
183
|
impactedTokenAmount: tokenAmount,
|
|
173
184
|
};
|
|
174
185
|
}
|