@buildonspark/issuer-sdk 0.0.25 → 0.0.26
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 +9 -2
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +9 -2
- package/package.json +3 -3
- package/src/issuer-spark-wallet.ts +10 -5
- package/src/services/token-transactions.ts +6 -5
- package/src/tests/integration/spark.test.ts +12 -10
package/dist/index.cjs
CHANGED
|
@@ -36,6 +36,7 @@ if (typeof global === "undefined") {
|
|
|
36
36
|
// src/issuer-spark-wallet.ts
|
|
37
37
|
var import_lrc20_sdk2 = require("@buildonspark/lrc20-sdk");
|
|
38
38
|
var import_spark_sdk = require("@buildonspark/spark-sdk");
|
|
39
|
+
var import_address = require("@buildonspark/spark-sdk/address");
|
|
39
40
|
var import_utils5 = require("@buildonspark/spark-sdk/utils");
|
|
40
41
|
var import_utils6 = require("@noble/curves/abstract/utils");
|
|
41
42
|
var import_bip39 = require("@scure/bip39");
|
|
@@ -141,6 +142,7 @@ var IssuerTokenTransactionService = class extends import_token_transactions.Toke
|
|
|
141
142
|
}
|
|
142
143
|
async constructMintTokenTransaction(tokenPublicKey, tokenAmount) {
|
|
143
144
|
return {
|
|
145
|
+
network: this.config.getNetworkProto(),
|
|
144
146
|
tokenInput: {
|
|
145
147
|
$case: "mintInput",
|
|
146
148
|
mintInput: {
|
|
@@ -378,7 +380,8 @@ var IssuerSparkWallet = class _IssuerSparkWallet extends import_spark_sdk.SparkW
|
|
|
378
380
|
this.lrc20Wallet = new import_lrc20_sdk2.LRCWallet(
|
|
379
381
|
(0, import_utils6.bytesToHex)(identityKey.privateKey),
|
|
380
382
|
import_utils5.LRC_WALLET_NETWORK[network],
|
|
381
|
-
import_utils5.LRC_WALLET_NETWORK_TYPE[network]
|
|
383
|
+
import_utils5.LRC_WALLET_NETWORK_TYPE[network],
|
|
384
|
+
this.config.lrc20ApiConfig
|
|
382
385
|
);
|
|
383
386
|
}
|
|
384
387
|
return initResponse;
|
|
@@ -421,10 +424,14 @@ var IssuerSparkWallet = class _IssuerSparkWallet extends import_spark_sdk.SparkW
|
|
|
421
424
|
);
|
|
422
425
|
}
|
|
423
426
|
async burnTokens(tokenAmount, selectedLeaves) {
|
|
427
|
+
const burnAddress = (0, import_address.encodeSparkAddress)({
|
|
428
|
+
identityPublicKey: BURN_ADDRESS,
|
|
429
|
+
network: this.config.getNetworkType()
|
|
430
|
+
});
|
|
424
431
|
return await this.transferTokens({
|
|
425
432
|
tokenPublicKey: await super.getIdentityPublicKey(),
|
|
426
433
|
tokenAmount,
|
|
427
|
-
receiverSparkAddress:
|
|
434
|
+
receiverSparkAddress: burnAddress,
|
|
428
435
|
selectedLeaves
|
|
429
436
|
});
|
|
430
437
|
}
|
package/dist/index.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { ListAllTokenTransactionsCursor, OperationType } from '@buildonspark/lrc20-sdk/proto/rpc/v1/types';
|
|
1
2
|
import { CreateLightningInvoiceParams, PayLightningInvoiceParams, TokenInfo, SparkWallet, SparkWalletProps } from '@buildonspark/spark-sdk';
|
|
2
3
|
import { QueryAllTransfersResponse, Transfer, LeafWithPreviousTransactionData, TokenTransactionWithStatus } from '@buildonspark/spark-sdk/proto/spark';
|
|
3
|
-
import { ListAllTokenTransactionsCursor, OperationType } from '@buildonspark/lrc20-sdk/proto/rpc/v1/types';
|
|
4
4
|
import { LRCWallet } from '@buildonspark/lrc20-sdk';
|
|
5
5
|
import { LightningReceiveRequest } from '@buildonspark/spark-sdk/types';
|
|
6
6
|
import { GetTokenActivityResponse, TokenPubKeyInfoResponse } from './types.cjs';
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { ListAllTokenTransactionsCursor, OperationType } from '@buildonspark/lrc20-sdk/proto/rpc/v1/types';
|
|
1
2
|
import { CreateLightningInvoiceParams, PayLightningInvoiceParams, TokenInfo, SparkWallet, SparkWalletProps } from '@buildonspark/spark-sdk';
|
|
2
3
|
import { QueryAllTransfersResponse, Transfer, LeafWithPreviousTransactionData, TokenTransactionWithStatus } from '@buildonspark/spark-sdk/proto/spark';
|
|
3
|
-
import { ListAllTokenTransactionsCursor, OperationType } from '@buildonspark/lrc20-sdk/proto/rpc/v1/types';
|
|
4
4
|
import { LRCWallet } from '@buildonspark/lrc20-sdk';
|
|
5
5
|
import { LightningReceiveRequest } from '@buildonspark/spark-sdk/types';
|
|
6
6
|
import { GetTokenActivityResponse, TokenPubKeyInfoResponse } from './types.js';
|
package/dist/index.js
CHANGED
|
@@ -7,6 +7,7 @@ import {
|
|
|
7
7
|
TokenPubkeyAnnouncement
|
|
8
8
|
} from "@buildonspark/lrc20-sdk";
|
|
9
9
|
import { SparkWallet } from "@buildonspark/spark-sdk";
|
|
10
|
+
import { encodeSparkAddress } from "@buildonspark/spark-sdk/address";
|
|
10
11
|
import {
|
|
11
12
|
getMasterHDKeyFromSeed,
|
|
12
13
|
LRC_WALLET_NETWORK,
|
|
@@ -121,6 +122,7 @@ var IssuerTokenTransactionService = class extends TokenTransactionService {
|
|
|
121
122
|
}
|
|
122
123
|
async constructMintTokenTransaction(tokenPublicKey, tokenAmount) {
|
|
123
124
|
return {
|
|
125
|
+
network: this.config.getNetworkProto(),
|
|
124
126
|
tokenInput: {
|
|
125
127
|
$case: "mintInput",
|
|
126
128
|
mintInput: {
|
|
@@ -358,7 +360,8 @@ var IssuerSparkWallet = class _IssuerSparkWallet extends SparkWallet {
|
|
|
358
360
|
this.lrc20Wallet = new LRCWallet(
|
|
359
361
|
bytesToHex2(identityKey.privateKey),
|
|
360
362
|
LRC_WALLET_NETWORK[network],
|
|
361
|
-
LRC_WALLET_NETWORK_TYPE[network]
|
|
363
|
+
LRC_WALLET_NETWORK_TYPE[network],
|
|
364
|
+
this.config.lrc20ApiConfig
|
|
362
365
|
);
|
|
363
366
|
}
|
|
364
367
|
return initResponse;
|
|
@@ -401,10 +404,14 @@ var IssuerSparkWallet = class _IssuerSparkWallet extends SparkWallet {
|
|
|
401
404
|
);
|
|
402
405
|
}
|
|
403
406
|
async burnTokens(tokenAmount, selectedLeaves) {
|
|
407
|
+
const burnAddress = encodeSparkAddress({
|
|
408
|
+
identityPublicKey: BURN_ADDRESS,
|
|
409
|
+
network: this.config.getNetworkType()
|
|
410
|
+
});
|
|
404
411
|
return await this.transferTokens({
|
|
405
412
|
tokenPublicKey: await super.getIdentityPublicKey(),
|
|
406
413
|
tokenAmount,
|
|
407
|
-
receiverSparkAddress:
|
|
414
|
+
receiverSparkAddress: burnAddress,
|
|
408
415
|
selectedLeaves
|
|
409
416
|
});
|
|
410
417
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@buildonspark/issuer-sdk",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.26",
|
|
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.0.
|
|
57
|
+
"@buildonspark/lrc20-sdk": "0.0.24",
|
|
58
|
+
"@buildonspark/spark-sdk": "0.0.26",
|
|
59
59
|
"@noble/curves": "^1.8.0",
|
|
60
60
|
"@scure/bip39": "^1.5.4",
|
|
61
61
|
"@scure/btc-signer": "^1.5.0",
|
|
@@ -2,11 +2,12 @@ import {
|
|
|
2
2
|
LRCWallet,
|
|
3
3
|
TokenPubkey,
|
|
4
4
|
TokenPubkeyAnnouncement,
|
|
5
|
-
TokenPubkeyInfo
|
|
5
|
+
TokenPubkeyInfo
|
|
6
6
|
} from "@buildonspark/lrc20-sdk";
|
|
7
|
+
import { ListAllTokenTransactionsCursor, OperationType } from "@buildonspark/lrc20-sdk/proto/rpc/v1/types";
|
|
7
8
|
import { SparkWallet, SparkWalletProps } from "@buildonspark/spark-sdk";
|
|
9
|
+
import { encodeSparkAddress } from "@buildonspark/spark-sdk/address";
|
|
8
10
|
import { LeafWithPreviousTransactionData } from "@buildonspark/spark-sdk/proto/spark";
|
|
9
|
-
import { ListAllTokenTransactionsCursor, OperationType } from "@buildonspark/lrc20-sdk/proto/rpc/v1/types";
|
|
10
11
|
import { ConfigOptions } from "@buildonspark/spark-sdk/services/wallet-config";
|
|
11
12
|
import {
|
|
12
13
|
getMasterHDKeyFromSeed,
|
|
@@ -34,8 +35,7 @@ const BURN_ADDRESS = "02".repeat(33);
|
|
|
34
35
|
|
|
35
36
|
export class IssuerSparkWallet
|
|
36
37
|
extends SparkWallet
|
|
37
|
-
implements IssuerWalletInterface
|
|
38
|
-
{
|
|
38
|
+
implements IssuerWalletInterface {
|
|
39
39
|
private issuerTokenTransactionService: IssuerTokenTransactionService;
|
|
40
40
|
private tokenFreezeService: TokenFreezeService;
|
|
41
41
|
private tokenPublicKeyInfo?: TokenPubkeyInfo;
|
|
@@ -88,6 +88,7 @@ export class IssuerSparkWallet
|
|
|
88
88
|
bytesToHex(identityKey.privateKey!),
|
|
89
89
|
LRC_WALLET_NETWORK[network],
|
|
90
90
|
LRC_WALLET_NETWORK_TYPE[network],
|
|
91
|
+
this.config.lrc20ApiConfig
|
|
91
92
|
);
|
|
92
93
|
}
|
|
93
94
|
|
|
@@ -148,10 +149,14 @@ export class IssuerSparkWallet
|
|
|
148
149
|
tokenAmount: bigint,
|
|
149
150
|
selectedLeaves?: LeafWithPreviousTransactionData[],
|
|
150
151
|
): Promise<string> {
|
|
152
|
+
const burnAddress = encodeSparkAddress({
|
|
153
|
+
identityPublicKey: BURN_ADDRESS,
|
|
154
|
+
network: this.config.getNetworkType(),
|
|
155
|
+
});
|
|
151
156
|
return await this.transferTokens({
|
|
152
157
|
tokenPublicKey: await super.getIdentityPublicKey(),
|
|
153
158
|
tokenAmount,
|
|
154
|
-
receiverSparkAddress:
|
|
159
|
+
receiverSparkAddress: burnAddress,
|
|
155
160
|
selectedLeaves,
|
|
156
161
|
});
|
|
157
162
|
}
|
|
@@ -1,22 +1,23 @@
|
|
|
1
|
-
import { TokenTransactionService } from "@buildonspark/spark-sdk/token-transactions";
|
|
2
|
-
import { TokenTransaction } from "@buildonspark/spark-sdk/proto/spark";
|
|
3
|
-
import { ConnectionManager } from "@buildonspark/spark-sdk/connection";
|
|
4
1
|
import { WalletConfigService } from "@buildonspark/spark-sdk/config";
|
|
2
|
+
import { ConnectionManager } from "@buildonspark/spark-sdk/connection";
|
|
3
|
+
import { TokenTransaction } from "@buildonspark/spark-sdk/proto/spark";
|
|
4
|
+
import { TokenTransactionService } from "@buildonspark/spark-sdk/token-transactions";
|
|
5
5
|
import { numberToBytesBE } from "@noble/curves/abstract/utils";
|
|
6
6
|
|
|
7
7
|
export class IssuerTokenTransactionService extends TokenTransactionService {
|
|
8
8
|
constructor(
|
|
9
9
|
config: WalletConfigService,
|
|
10
|
-
connectionManager: ConnectionManager
|
|
10
|
+
connectionManager: ConnectionManager,
|
|
11
11
|
) {
|
|
12
12
|
super(config, connectionManager);
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
async constructMintTokenTransaction(
|
|
16
16
|
tokenPublicKey: Uint8Array,
|
|
17
|
-
tokenAmount: bigint
|
|
17
|
+
tokenAmount: bigint,
|
|
18
18
|
): Promise<TokenTransaction> {
|
|
19
19
|
return {
|
|
20
|
+
network: this.config.getNetworkProto(),
|
|
20
21
|
tokenInput: {
|
|
21
22
|
$case: "mintInput",
|
|
22
23
|
mintInput: {
|
|
@@ -185,7 +185,7 @@ describe("token integration test", () => {
|
|
|
185
185
|
await issuerWallet.transferTokens({
|
|
186
186
|
tokenAmount,
|
|
187
187
|
tokenPublicKey: await issuerWallet.getIdentityPublicKey(),
|
|
188
|
-
receiverSparkAddress: await destinationWallet.
|
|
188
|
+
receiverSparkAddress: await destinationWallet.getSparkAddress(),
|
|
189
189
|
});
|
|
190
190
|
const sourceBalance = await issuerWallet.getIssuerTokenBalance();
|
|
191
191
|
expect(sourceBalance.balance).toEqual(0n);
|
|
@@ -213,7 +213,7 @@ describe("token integration test", () => {
|
|
|
213
213
|
await issuerWallet.transferTokens({
|
|
214
214
|
tokenAmount,
|
|
215
215
|
tokenPublicKey: await issuerWallet.getIdentityPublicKey(),
|
|
216
|
-
receiverSparkAddress: await destinationWallet.
|
|
216
|
+
receiverSparkAddress: await destinationWallet.getSparkAddress(),
|
|
217
217
|
});
|
|
218
218
|
const sourceBalance = await issuerWallet.getIssuerTokenBalance();
|
|
219
219
|
expect(sourceBalance.balance).toEqual(0n);
|
|
@@ -249,7 +249,7 @@ describe("token integration test", () => {
|
|
|
249
249
|
await issuerWallet.transferTokens({
|
|
250
250
|
tokenPublicKey: await issuerWallet.getIdentityPublicKey(),
|
|
251
251
|
tokenAmount,
|
|
252
|
-
receiverSparkAddress: await destinationWallet.
|
|
252
|
+
receiverSparkAddress: await destinationWallet.getSparkAddress(),
|
|
253
253
|
});
|
|
254
254
|
const sourceBalance = await issuerWallet.getIssuerTokenBalance();
|
|
255
255
|
expect(sourceBalance.balance).toEqual(0n);
|
|
@@ -277,7 +277,7 @@ describe("token integration test", () => {
|
|
|
277
277
|
const { wallet: userWallet } = await SparkWallet.initialize({
|
|
278
278
|
options: LOCAL_WALLET_CONFIG_ECDSA,
|
|
279
279
|
});
|
|
280
|
-
const userWalletPublicKey = await userWallet.
|
|
280
|
+
const userWalletPublicKey = await userWallet.getSparkAddress();
|
|
281
281
|
|
|
282
282
|
await issuerWallet.transferTokens({
|
|
283
283
|
tokenAmount,
|
|
@@ -323,7 +323,7 @@ describe("token integration test", () => {
|
|
|
323
323
|
const { wallet: userWallet } = await SparkWallet.initialize({
|
|
324
324
|
options: LOCAL_WALLET_CONFIG_SCHNORR,
|
|
325
325
|
});
|
|
326
|
-
const userWalletPublicKey = await userWallet.
|
|
326
|
+
const userWalletPublicKey = await userWallet.getSparkAddress();
|
|
327
327
|
|
|
328
328
|
await issuerWallet.transferTokens({
|
|
329
329
|
tokenAmount,
|
|
@@ -402,7 +402,7 @@ describe("token integration test", () => {
|
|
|
402
402
|
const issuerBalanceAfterMint = await issuerWallet.getIssuerTokenBalance();
|
|
403
403
|
expect(issuerBalanceAfterMint.balance).toEqual(tokenAmount);
|
|
404
404
|
|
|
405
|
-
const userWalletPublicKey = await userWallet.
|
|
405
|
+
const userWalletPublicKey = await userWallet.getSparkAddress();
|
|
406
406
|
|
|
407
407
|
await issuerWallet.transferTokens({
|
|
408
408
|
tokenAmount,
|
|
@@ -415,6 +415,7 @@ describe("token integration test", () => {
|
|
|
415
415
|
expect(issuerBalanceAfterTransfer.balance).toEqual(0n);
|
|
416
416
|
|
|
417
417
|
const tokenPublicKeyHex = await issuerWallet.getIdentityPublicKey();
|
|
418
|
+
const userWalletPublicKeyHex = await userWallet.getSparkAddress();
|
|
418
419
|
const userBalanceAfterTransfer = await getSparkWalletTokenBalanceOrZero(
|
|
419
420
|
userWallet,
|
|
420
421
|
tokenPublicKeyHex,
|
|
@@ -424,7 +425,7 @@ describe("token integration test", () => {
|
|
|
424
425
|
await userWallet.transferTokens({
|
|
425
426
|
tokenPublicKey: tokenPublicKeyHex,
|
|
426
427
|
tokenAmount,
|
|
427
|
-
receiverSparkAddress:
|
|
428
|
+
receiverSparkAddress: userWalletPublicKeyHex,
|
|
428
429
|
});
|
|
429
430
|
|
|
430
431
|
const userBalanceAfterTransferBack = await getSparkWalletTokenBalanceOrZero(
|
|
@@ -460,7 +461,7 @@ describe("token integration test", () => {
|
|
|
460
461
|
const issuerBalanceAfterMint = await issuerWallet.getIssuerTokenBalance();
|
|
461
462
|
expect(issuerBalanceAfterMint.balance).toEqual(tokenAmount);
|
|
462
463
|
|
|
463
|
-
const userWalletPublicKey = await userWallet.
|
|
464
|
+
const userWalletPublicKey = await userWallet.getSparkAddress();
|
|
464
465
|
|
|
465
466
|
await issuerWallet.transferTokens({
|
|
466
467
|
tokenAmount,
|
|
@@ -473,6 +474,7 @@ describe("token integration test", () => {
|
|
|
473
474
|
expect(issuerBalanceAfterTransfer.balance).toEqual(0n);
|
|
474
475
|
|
|
475
476
|
const tokenPublicKeyHex = await issuerWallet.getIdentityPublicKey();
|
|
477
|
+
const userWalletPublicKeyHex = await userWallet.getSparkAddress();
|
|
476
478
|
const userBalanceAfterTransfer = await getSparkWalletTokenBalanceOrZero(
|
|
477
479
|
userWallet,
|
|
478
480
|
tokenPublicKeyHex,
|
|
@@ -482,7 +484,7 @@ describe("token integration test", () => {
|
|
|
482
484
|
await userWallet.transferTokens({
|
|
483
485
|
tokenPublicKey: tokenPublicKeyHex,
|
|
484
486
|
tokenAmount,
|
|
485
|
-
receiverSparkAddress:
|
|
487
|
+
receiverSparkAddress: userWalletPublicKeyHex,
|
|
486
488
|
});
|
|
487
489
|
|
|
488
490
|
const userBalanceAfterTransferBack = await getSparkWalletTokenBalanceOrZero(
|
|
@@ -515,4 +517,4 @@ async function getSparkWalletTokenBalanceOrZero(
|
|
|
515
517
|
return {
|
|
516
518
|
balance: balanceObj.tokenBalances.get(publicKey)!.balance,
|
|
517
519
|
};
|
|
518
|
-
}
|
|
520
|
+
}
|