@buildonspark/issuer-sdk 0.0.82 → 0.0.84
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 +14 -0
- package/dist/index.cjs +4 -0
- package/dist/index.js +4 -0
- package/package.json +2 -2
- package/src/issuer-wallet/issuer-spark-wallet.ts +4 -0
- package/src/tests/integration/spark.test.ts +42 -65
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# @buildonspark/issuer-sdk
|
|
2
2
|
|
|
3
|
+
## 0.0.84
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies
|
|
8
|
+
- @buildonspark/spark-sdk@0.2.5
|
|
9
|
+
|
|
10
|
+
## 0.0.83
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- Updated dependencies
|
|
15
|
+
- @buildonspark/spark-sdk@0.2.4
|
|
16
|
+
|
|
3
17
|
## 0.0.82
|
|
4
18
|
|
|
5
19
|
### Patch Changes
|
package/dist/index.cjs
CHANGED
|
@@ -358,6 +358,10 @@ var IssuerSparkWallet = class _IssuerSparkWallet extends import_spark_sdk5.Spark
|
|
|
358
358
|
"SparkIssuerWallet.getIssuerTokenIdentifier",
|
|
359
359
|
this.getIssuerTokenIdentifier.bind(this)
|
|
360
360
|
);
|
|
361
|
+
this.createToken = this.wrapWithOtelSpan(
|
|
362
|
+
"SparkIssuerWallet.createToken",
|
|
363
|
+
this.createToken.bind(this)
|
|
364
|
+
);
|
|
361
365
|
this.mintTokens = this.wrapWithOtelSpan(
|
|
362
366
|
"SparkIssuerWallet.mintTokens",
|
|
363
367
|
this.mintTokens.bind(this)
|
package/dist/index.js
CHANGED
|
@@ -338,6 +338,10 @@ var IssuerSparkWallet = class _IssuerSparkWallet extends SparkWallet {
|
|
|
338
338
|
"SparkIssuerWallet.getIssuerTokenIdentifier",
|
|
339
339
|
this.getIssuerTokenIdentifier.bind(this)
|
|
340
340
|
);
|
|
341
|
+
this.createToken = this.wrapWithOtelSpan(
|
|
342
|
+
"SparkIssuerWallet.createToken",
|
|
343
|
+
this.createToken.bind(this)
|
|
344
|
+
);
|
|
341
345
|
this.mintTokens = this.wrapWithOtelSpan(
|
|
342
346
|
"SparkIssuerWallet.mintTokens",
|
|
343
347
|
this.mintTokens.bind(this)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@buildonspark/issuer-sdk",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.84",
|
|
4
4
|
"description": "Spark Issuer SDK for token issuance",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"module": "./dist/index.js",
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
},
|
|
56
56
|
"dependencies": {
|
|
57
57
|
"@buildonspark/lrc20-sdk": "0.0.60",
|
|
58
|
-
"@buildonspark/spark-sdk": "0.2.
|
|
58
|
+
"@buildonspark/spark-sdk": "0.2.5",
|
|
59
59
|
"@lightsparkdev/core": "^1.4.2",
|
|
60
60
|
"@noble/curves": "^1.8.0",
|
|
61
61
|
"@scure/btc-signer": "^1.5.0",
|
|
@@ -83,6 +83,10 @@ export class IssuerSparkWallet extends SparkWallet {
|
|
|
83
83
|
"SparkIssuerWallet.getIssuerTokenIdentifier",
|
|
84
84
|
this.getIssuerTokenIdentifier.bind(this),
|
|
85
85
|
);
|
|
86
|
+
this.createToken = this.wrapWithOtelSpan(
|
|
87
|
+
"SparkIssuerWallet.createToken",
|
|
88
|
+
this.createToken.bind(this),
|
|
89
|
+
);
|
|
86
90
|
this.mintTokens = this.wrapWithOtelSpan(
|
|
87
91
|
"SparkIssuerWallet.mintTokens",
|
|
88
92
|
this.mintTokens.bind(this),
|
|
@@ -6,7 +6,6 @@ import {
|
|
|
6
6
|
import { jest } from "@jest/globals";
|
|
7
7
|
import { IssuerSparkWalletTesting } from "../utils/issuer-test-wallet.js";
|
|
8
8
|
import { SparkWalletTesting } from "../utils/spark-testing-wallet.js";
|
|
9
|
-
import { IssuerSparkWallet } from "../../index.js";
|
|
10
9
|
|
|
11
10
|
export const TOKENS_V0_SCHNORR_CONFIG: Required<ConfigOptions> = {
|
|
12
11
|
...WalletConfig.LOCAL,
|
|
@@ -46,14 +45,6 @@ describe.each(TEST_CONFIGS)(
|
|
|
46
45
|
({ name, config }) => {
|
|
47
46
|
jest.setTimeout(80000);
|
|
48
47
|
|
|
49
|
-
let sharedIssuerWallet: IssuerSparkWallet;
|
|
50
|
-
let sharedUserWallet: any;
|
|
51
|
-
let sharedTokenPublicKey: string;
|
|
52
|
-
|
|
53
|
-
afterEach(async () => {
|
|
54
|
-
await new Promise((resolve) => setTimeout(resolve, 1000));
|
|
55
|
-
});
|
|
56
|
-
|
|
57
48
|
it("should fail when minting tokens without creation", async () => {
|
|
58
49
|
const tokenAmount: bigint = 1000n;
|
|
59
50
|
const { wallet } = await IssuerSparkWalletTesting.initialize({
|
|
@@ -110,12 +101,10 @@ describe.each(TEST_CONFIGS)(
|
|
|
110
101
|
isFreezable: false,
|
|
111
102
|
maxSupply: 1_000_000n,
|
|
112
103
|
});
|
|
113
|
-
sharedIssuerWallet = issuerWallet;
|
|
114
|
-
sharedTokenPublicKey = await issuerWallet.getIdentityPublicKey();
|
|
115
104
|
|
|
116
|
-
const tokenMetadata = await
|
|
105
|
+
const tokenMetadata = await issuerWallet.getIssuerTokenMetadata();
|
|
117
106
|
|
|
118
|
-
const identityPublicKey = await
|
|
107
|
+
const identityPublicKey = await issuerWallet.getIdentityPublicKey();
|
|
119
108
|
expect(tokenMetadata?.tokenName).toEqual(`${name}M`);
|
|
120
109
|
expect(tokenMetadata?.tokenTicker).toEqual("MIN");
|
|
121
110
|
expect(tokenMetadata?.decimals).toEqual(0);
|
|
@@ -126,9 +115,9 @@ describe.each(TEST_CONFIGS)(
|
|
|
126
115
|
const metadataPubkey = tokenMetadata?.tokenPublicKey;
|
|
127
116
|
expect(metadataPubkey).toEqual(identityPublicKey);
|
|
128
117
|
|
|
129
|
-
await
|
|
118
|
+
await issuerWallet.mintTokens(tokenAmount);
|
|
130
119
|
|
|
131
|
-
const tokenBalance = await
|
|
120
|
+
const tokenBalance = await issuerWallet.getIssuerTokenBalance();
|
|
132
121
|
expect(tokenBalance.balance).toBeGreaterThanOrEqual(tokenAmount);
|
|
133
122
|
});
|
|
134
123
|
|
|
@@ -149,28 +138,23 @@ describe.each(TEST_CONFIGS)(
|
|
|
149
138
|
isFreezable: false,
|
|
150
139
|
maxSupply: 1_000_000n,
|
|
151
140
|
});
|
|
152
|
-
|
|
153
|
-
sharedUserWallet = userWallet;
|
|
154
|
-
sharedTokenPublicKey = await issuerWallet.getIdentityPublicKey();
|
|
141
|
+
const issuerPublicKey = await issuerWallet.getIdentityPublicKey();
|
|
155
142
|
|
|
156
|
-
await
|
|
143
|
+
await issuerWallet.mintTokens(tokenAmount);
|
|
157
144
|
|
|
158
|
-
const
|
|
159
|
-
|
|
160
|
-
expect(sharedIssuerBalance).toBeDefined();
|
|
161
|
-
expect(sharedIssuerBalance.tokenIdentifier).toBeDefined();
|
|
162
|
-
await sharedIssuerWallet.transferTokens({
|
|
145
|
+
const tokenIdentifier = await issuerWallet.getIssuerTokenIdentifier();
|
|
146
|
+
await issuerWallet.transferTokens({
|
|
163
147
|
tokenAmount,
|
|
164
|
-
tokenIdentifier:
|
|
165
|
-
receiverSparkAddress: await
|
|
148
|
+
tokenIdentifier: tokenIdentifier!,
|
|
149
|
+
receiverSparkAddress: await userWallet.getSparkAddress(),
|
|
166
150
|
});
|
|
167
151
|
|
|
168
|
-
const balanceObj = await
|
|
169
|
-
const
|
|
152
|
+
const balanceObj = await userWallet.getBalance();
|
|
153
|
+
const userBalance = filterTokenBalanceForTokenPublicKey(
|
|
170
154
|
balanceObj?.tokenBalances,
|
|
171
|
-
|
|
155
|
+
issuerPublicKey,
|
|
172
156
|
);
|
|
173
|
-
expect(
|
|
157
|
+
expect(userBalance.balance).toBeGreaterThanOrEqual(tokenAmount);
|
|
174
158
|
});
|
|
175
159
|
|
|
176
160
|
// it("should announce, mint, get list all transactions, and transfer tokens multiple times, get list all transactions again and check difference", async () => {
|
|
@@ -322,8 +306,8 @@ describe.each(TEST_CONFIGS)(
|
|
|
322
306
|
isFreezable: false,
|
|
323
307
|
maxSupply: 1_000_000n,
|
|
324
308
|
});
|
|
325
|
-
|
|
326
|
-
|
|
309
|
+
|
|
310
|
+
const issuerPublicKey = await issuerWallet.getIdentityPublicKey();
|
|
327
311
|
|
|
328
312
|
const { wallet: destinationWallet } = await SparkWalletTesting.initialize(
|
|
329
313
|
{
|
|
@@ -341,16 +325,15 @@ describe.each(TEST_CONFIGS)(
|
|
|
341
325
|
options: config,
|
|
342
326
|
});
|
|
343
327
|
|
|
344
|
-
await
|
|
345
|
-
const sharedIssuerBalance =
|
|
346
|
-
await sharedIssuerWallet.getIssuerTokenBalance();
|
|
328
|
+
await issuerWallet.mintTokens(tokenAmount);
|
|
329
|
+
const sharedIssuerBalance = await issuerWallet.getIssuerTokenBalance();
|
|
347
330
|
expect(sharedIssuerBalance).toBeDefined();
|
|
348
331
|
expect(sharedIssuerBalance.tokenIdentifier).toBeDefined();
|
|
349
332
|
|
|
350
333
|
const tokenIdentifier = sharedIssuerBalance.tokenIdentifier!;
|
|
351
334
|
const sourceBalanceBefore = sharedIssuerBalance.balance;
|
|
352
335
|
|
|
353
|
-
await
|
|
336
|
+
await issuerWallet.batchTransferTokens([
|
|
354
337
|
{
|
|
355
338
|
tokenAmount: tokenAmount / 3n,
|
|
356
339
|
tokenIdentifier,
|
|
@@ -368,27 +351,26 @@ describe.each(TEST_CONFIGS)(
|
|
|
368
351
|
},
|
|
369
352
|
]);
|
|
370
353
|
|
|
371
|
-
const sourceBalanceAfter = (
|
|
372
|
-
|
|
373
|
-
).balance;
|
|
354
|
+
const sourceBalanceAfter = (await issuerWallet.getIssuerTokenBalance())
|
|
355
|
+
.balance;
|
|
374
356
|
expect(sourceBalanceAfter).toEqual(sourceBalanceBefore - tokenAmount);
|
|
375
357
|
|
|
376
358
|
const balanceObj = await destinationWallet.getBalance();
|
|
377
359
|
const destinationBalance = filterTokenBalanceForTokenPublicKey(
|
|
378
360
|
balanceObj?.tokenBalances,
|
|
379
|
-
|
|
361
|
+
issuerPublicKey,
|
|
380
362
|
);
|
|
381
363
|
expect(destinationBalance.balance).toEqual(tokenAmount / 3n);
|
|
382
364
|
const balanceObj2 = await destinationWallet2.getBalance();
|
|
383
365
|
const destinationBalance2 = filterTokenBalanceForTokenPublicKey(
|
|
384
366
|
balanceObj2?.tokenBalances,
|
|
385
|
-
|
|
367
|
+
issuerPublicKey,
|
|
386
368
|
);
|
|
387
369
|
expect(destinationBalance2.balance).toEqual(tokenAmount / 3n);
|
|
388
370
|
const balanceObj3 = await destinationWallet3.getBalance();
|
|
389
371
|
const destinationBalance3 = filterTokenBalanceForTokenPublicKey(
|
|
390
372
|
balanceObj3?.tokenBalances,
|
|
391
|
-
|
|
373
|
+
issuerPublicKey,
|
|
392
374
|
);
|
|
393
375
|
expect(destinationBalance3.balance).toEqual(tokenAmount / 3n);
|
|
394
376
|
});
|
|
@@ -557,19 +539,16 @@ describe.each(TEST_CONFIGS)(
|
|
|
557
539
|
isFreezable: false,
|
|
558
540
|
maxSupply: 1_000_000n,
|
|
559
541
|
});
|
|
560
|
-
sharedIssuerWallet = issuerWallet;
|
|
561
|
-
sharedTokenPublicKey = await issuerWallet.getIdentityPublicKey();
|
|
562
542
|
|
|
563
|
-
await
|
|
564
|
-
const issuerTokenBalance = (
|
|
565
|
-
|
|
566
|
-
).balance;
|
|
543
|
+
await issuerWallet.mintTokens(tokenAmount);
|
|
544
|
+
const issuerTokenBalance = (await issuerWallet.getIssuerTokenBalance())
|
|
545
|
+
.balance;
|
|
567
546
|
expect(issuerTokenBalance).toBeGreaterThanOrEqual(tokenAmount);
|
|
568
547
|
|
|
569
|
-
await
|
|
548
|
+
await issuerWallet.burnTokens(tokenAmount);
|
|
570
549
|
|
|
571
550
|
const issuerTokenBalanceAfterBurn = (
|
|
572
|
-
await
|
|
551
|
+
await issuerWallet.getIssuerTokenBalance()
|
|
573
552
|
).balance;
|
|
574
553
|
expect(issuerTokenBalanceAfterBurn).toEqual(
|
|
575
554
|
issuerTokenBalance - tokenAmount,
|
|
@@ -590,19 +569,18 @@ describe.each(TEST_CONFIGS)(
|
|
|
590
569
|
isFreezable: false,
|
|
591
570
|
maxSupply: 1_000_000n,
|
|
592
571
|
});
|
|
593
|
-
|
|
594
|
-
sharedTokenPublicKey = await issuerWallet.getIdentityPublicKey();
|
|
572
|
+
const issuerPublicKey = await issuerWallet.getIdentityPublicKey();
|
|
595
573
|
|
|
596
574
|
const { wallet: userWallet } = await SparkWalletTesting.initialize({
|
|
597
575
|
options: config,
|
|
598
576
|
});
|
|
599
577
|
|
|
600
|
-
const initialBalance = (await
|
|
578
|
+
const initialBalance = (await issuerWallet.getIssuerTokenBalance())
|
|
601
579
|
.balance;
|
|
602
580
|
|
|
603
|
-
await
|
|
581
|
+
await issuerWallet.mintTokens(tokenAmount);
|
|
604
582
|
const issuerBalanceObjAfterMint =
|
|
605
|
-
await
|
|
583
|
+
await issuerWallet.getIssuerTokenBalance();
|
|
606
584
|
expect(issuerBalanceObjAfterMint).toBeDefined();
|
|
607
585
|
const issuerBalanceAfterMint = issuerBalanceObjAfterMint.balance;
|
|
608
586
|
expect(issuerBalanceAfterMint).toEqual(initialBalance + tokenAmount);
|
|
@@ -610,47 +588,46 @@ describe.each(TEST_CONFIGS)(
|
|
|
610
588
|
const tokenIdentifier = issuerBalanceObjAfterMint.tokenIdentifier!;
|
|
611
589
|
const userSparkAddress = await userWallet.getSparkAddress();
|
|
612
590
|
|
|
613
|
-
await
|
|
591
|
+
await issuerWallet.transferTokens({
|
|
614
592
|
tokenAmount,
|
|
615
593
|
tokenIdentifier,
|
|
616
594
|
receiverSparkAddress: userSparkAddress,
|
|
617
595
|
});
|
|
618
596
|
|
|
619
597
|
const issuerBalanceAfterTransfer = (
|
|
620
|
-
await
|
|
598
|
+
await issuerWallet.getIssuerTokenBalance()
|
|
621
599
|
).balance;
|
|
622
600
|
expect(issuerBalanceAfterTransfer).toEqual(initialBalance);
|
|
623
601
|
|
|
624
602
|
const userBalanceObj = await userWallet.getBalance();
|
|
625
603
|
const userBalanceAfterTransfer = filterTokenBalanceForTokenPublicKey(
|
|
626
604
|
userBalanceObj?.tokenBalances,
|
|
627
|
-
|
|
605
|
+
issuerPublicKey,
|
|
628
606
|
);
|
|
629
607
|
expect(userBalanceAfterTransfer.balance).toEqual(tokenAmount);
|
|
630
608
|
|
|
631
609
|
await userWallet.transferTokens({
|
|
632
610
|
tokenIdentifier,
|
|
633
611
|
tokenAmount,
|
|
634
|
-
receiverSparkAddress: await
|
|
612
|
+
receiverSparkAddress: await issuerWallet.getSparkAddress(),
|
|
635
613
|
});
|
|
636
614
|
|
|
637
615
|
const userBalanceObjAfterTransferBack = await userWallet.getBalance();
|
|
638
616
|
const userBalanceAfterTransferBack = filterTokenBalanceForTokenPublicKey(
|
|
639
617
|
userBalanceObjAfterTransferBack?.tokenBalances,
|
|
640
|
-
|
|
618
|
+
issuerPublicKey,
|
|
641
619
|
);
|
|
642
620
|
|
|
643
621
|
expect(userBalanceAfterTransferBack.balance).toEqual(0n);
|
|
644
622
|
|
|
645
|
-
const issuerTokenBalance = (
|
|
646
|
-
|
|
647
|
-
).balance;
|
|
623
|
+
const issuerTokenBalance = (await issuerWallet.getIssuerTokenBalance())
|
|
624
|
+
.balance;
|
|
648
625
|
expect(issuerTokenBalance).toEqual(initialBalance + tokenAmount);
|
|
649
626
|
|
|
650
|
-
await
|
|
627
|
+
await issuerWallet.burnTokens(tokenAmount);
|
|
651
628
|
|
|
652
629
|
const issuerTokenBalanceAfterBurn = (
|
|
653
|
-
await
|
|
630
|
+
await issuerWallet.getIssuerTokenBalance()
|
|
654
631
|
).balance;
|
|
655
632
|
expect(issuerTokenBalanceAfterBurn).toEqual(initialBalance);
|
|
656
633
|
});
|