@buildonspark/issuer-sdk 0.0.89 → 0.0.91
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/{chunk-ZMLVOUPB.js → chunk-HQI3Y4QH.js} +11 -19
- package/dist/index.cjs +13 -19
- package/dist/index.js +1 -1
- package/dist/index.node.cjs +13 -19
- package/dist/index.node.js +1 -1
- package/package.json +2 -2
- package/src/issuer-wallet/issuer-spark-wallet.ts +10 -18
- package/src/services/freeze.ts +6 -6
- package/src/services/token-transactions.ts +6 -4
- package/src/tests/integration/spark.test.ts +2 -4
- package/src/tests/stress/transfers.test.ts +14 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# @buildonspark/issuer-sdk
|
|
2
2
|
|
|
3
|
+
## 0.0.91
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies
|
|
8
|
+
- @buildonspark/spark-sdk@0.2.12
|
|
9
|
+
|
|
10
|
+
## 0.0.90
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- Updated dependencies
|
|
15
|
+
- @buildonspark/spark-sdk@0.2.11
|
|
16
|
+
|
|
3
17
|
## 0.0.89
|
|
4
18
|
|
|
5
19
|
### Patch Changes
|
|
@@ -4,26 +4,23 @@ import {
|
|
|
4
4
|
|
|
5
5
|
// src/issuer-wallet/issuer-spark-wallet.ts
|
|
6
6
|
import {
|
|
7
|
+
decodeBech32mTokenIdentifier,
|
|
8
|
+
decodeSparkAddress,
|
|
9
|
+
encodeBech32mTokenIdentifier,
|
|
10
|
+
encodeSparkAddress,
|
|
7
11
|
NetworkError as NetworkError2,
|
|
12
|
+
NotImplementedError,
|
|
8
13
|
SparkWallet,
|
|
9
14
|
ValidationError as ValidationError3
|
|
10
15
|
} from "@buildonspark/spark-sdk";
|
|
11
|
-
import {
|
|
12
|
-
decodeSparkAddress,
|
|
13
|
-
encodeSparkAddress
|
|
14
|
-
} from "@buildonspark/spark-sdk";
|
|
15
|
-
import {
|
|
16
|
-
bytesToHex,
|
|
17
|
-
bytesToNumberBE,
|
|
18
|
-
hexToBytes as hexToBytes2
|
|
19
|
-
} from "@noble/curves/abstract/utils";
|
|
20
|
-
import { decodeBech32mTokenIdentifier } from "@buildonspark/spark-sdk";
|
|
16
|
+
import { bytesToHex, bytesToNumberBE, hexToBytes as hexToBytes2 } from "@noble/curves/utils";
|
|
21
17
|
|
|
22
18
|
// src/services/freeze.ts
|
|
23
19
|
import {
|
|
24
20
|
NetworkError,
|
|
25
21
|
collectResponses
|
|
26
22
|
} from "@buildonspark/spark-sdk";
|
|
23
|
+
import { hexToBytes } from "@noble/curves/utils";
|
|
27
24
|
|
|
28
25
|
// src/utils/token-hashing.ts
|
|
29
26
|
import { sha256 } from "@scure/btc-signer/utils";
|
|
@@ -85,7 +82,6 @@ function hashFreezeTokensPayload(payload) {
|
|
|
85
82
|
}
|
|
86
83
|
|
|
87
84
|
// src/services/freeze.ts
|
|
88
|
-
import { hexToBytes } from "@noble/curves/abstract/utils";
|
|
89
85
|
var TokenFreezeService = class {
|
|
90
86
|
config;
|
|
91
87
|
connectionManager;
|
|
@@ -149,8 +145,10 @@ var TokenFreezeService = class {
|
|
|
149
145
|
};
|
|
150
146
|
|
|
151
147
|
// src/services/token-transactions.ts
|
|
152
|
-
import {
|
|
153
|
-
|
|
148
|
+
import {
|
|
149
|
+
TokenTransactionService
|
|
150
|
+
} from "@buildonspark/spark-sdk";
|
|
151
|
+
import { numberToBytesBE } from "@noble/curves/utils";
|
|
154
152
|
var IssuerTokenTransactionService = class extends TokenTransactionService {
|
|
155
153
|
constructor(config, connectionManager) {
|
|
156
154
|
super(config, connectionManager);
|
|
@@ -223,9 +221,6 @@ var IssuerTokenTransactionService = class extends TokenTransactionService {
|
|
|
223
221
|
}
|
|
224
222
|
};
|
|
225
223
|
|
|
226
|
-
// src/issuer-wallet/issuer-spark-wallet.ts
|
|
227
|
-
import { NotImplementedError } from "@buildonspark/spark-sdk";
|
|
228
|
-
|
|
229
224
|
// src/utils/create-validation.ts
|
|
230
225
|
import { ValidationError as ValidationError2 } from "@buildonspark/spark-sdk";
|
|
231
226
|
function isNfcNormalized(value) {
|
|
@@ -296,9 +291,6 @@ function validateTokenParameters(tokenName, tokenTicker, decimals, maxSupply) {
|
|
|
296
291
|
}
|
|
297
292
|
|
|
298
293
|
// src/issuer-wallet/issuer-spark-wallet.ts
|
|
299
|
-
import {
|
|
300
|
-
encodeBech32mTokenIdentifier
|
|
301
|
-
} from "@buildonspark/spark-sdk";
|
|
302
294
|
var BURN_ADDRESS = "02".repeat(33);
|
|
303
295
|
var IssuerSparkWallet = class _IssuerSparkWallet extends SparkWallet {
|
|
304
296
|
issuerTokenTransactionService;
|
package/dist/index.cjs
CHANGED
|
@@ -40,12 +40,11 @@ if (typeof window !== "undefined") {
|
|
|
40
40
|
|
|
41
41
|
// src/issuer-wallet/issuer-spark-wallet.ts
|
|
42
42
|
var import_spark_sdk5 = require("@buildonspark/spark-sdk");
|
|
43
|
-
var
|
|
44
|
-
var import_utils4 = require("@noble/curves/abstract/utils");
|
|
45
|
-
var import_spark_sdk7 = require("@buildonspark/spark-sdk");
|
|
43
|
+
var import_utils4 = require("@noble/curves/utils");
|
|
46
44
|
|
|
47
45
|
// src/services/freeze.ts
|
|
48
46
|
var import_spark_sdk2 = require("@buildonspark/spark-sdk");
|
|
47
|
+
var import_utils2 = require("@noble/curves/utils");
|
|
49
48
|
|
|
50
49
|
// src/utils/token-hashing.ts
|
|
51
50
|
var import_utils = require("@scure/btc-signer/utils");
|
|
@@ -107,7 +106,6 @@ function hashFreezeTokensPayload(payload) {
|
|
|
107
106
|
}
|
|
108
107
|
|
|
109
108
|
// src/services/freeze.ts
|
|
110
|
-
var import_utils2 = require("@noble/curves/abstract/utils");
|
|
111
109
|
var TokenFreezeService = class {
|
|
112
110
|
config;
|
|
113
111
|
connectionManager;
|
|
@@ -172,7 +170,7 @@ var TokenFreezeService = class {
|
|
|
172
170
|
|
|
173
171
|
// src/services/token-transactions.ts
|
|
174
172
|
var import_spark_sdk3 = require("@buildonspark/spark-sdk");
|
|
175
|
-
var import_utils3 = require("@noble/curves/
|
|
173
|
+
var import_utils3 = require("@noble/curves/utils");
|
|
176
174
|
var IssuerTokenTransactionService = class extends import_spark_sdk3.TokenTransactionService {
|
|
177
175
|
constructor(config, connectionManager) {
|
|
178
176
|
super(config, connectionManager);
|
|
@@ -245,9 +243,6 @@ var IssuerTokenTransactionService = class extends import_spark_sdk3.TokenTransac
|
|
|
245
243
|
}
|
|
246
244
|
};
|
|
247
245
|
|
|
248
|
-
// src/issuer-wallet/issuer-spark-wallet.ts
|
|
249
|
-
var import_spark_sdk8 = require("@buildonspark/spark-sdk");
|
|
250
|
-
|
|
251
246
|
// src/utils/create-validation.ts
|
|
252
247
|
var import_spark_sdk4 = require("@buildonspark/spark-sdk");
|
|
253
248
|
function isNfcNormalized(value) {
|
|
@@ -318,7 +313,6 @@ function validateTokenParameters(tokenName, tokenTicker, decimals, maxSupply) {
|
|
|
318
313
|
}
|
|
319
314
|
|
|
320
315
|
// src/issuer-wallet/issuer-spark-wallet.ts
|
|
321
|
-
var import_spark_sdk9 = require("@buildonspark/spark-sdk");
|
|
322
316
|
var BURN_ADDRESS = "02".repeat(33);
|
|
323
317
|
var IssuerSparkWallet = class _IssuerSparkWallet extends import_spark_sdk5.SparkWallet {
|
|
324
318
|
issuerTokenTransactionService;
|
|
@@ -425,7 +419,7 @@ var IssuerSparkWallet = class _IssuerSparkWallet extends import_spark_sdk5.Spark
|
|
|
425
419
|
);
|
|
426
420
|
}
|
|
427
421
|
const metadata = response.tokenMetadata[0];
|
|
428
|
-
const tokenIdentifier = (0,
|
|
422
|
+
const tokenIdentifier = (0, import_spark_sdk5.encodeBech32mTokenIdentifier)({
|
|
429
423
|
tokenIdentifier: metadata.tokenIdentifier,
|
|
430
424
|
network: this.config.getNetworkType()
|
|
431
425
|
});
|
|
@@ -453,7 +447,7 @@ var IssuerSparkWallet = class _IssuerSparkWallet extends import_spark_sdk5.Spark
|
|
|
453
447
|
*/
|
|
454
448
|
async getIssuerTokenIdentifier() {
|
|
455
449
|
const tokenMetadata = await this.getIssuerTokenMetadata();
|
|
456
|
-
return (0,
|
|
450
|
+
return (0, import_spark_sdk5.encodeBech32mTokenIdentifier)({
|
|
457
451
|
tokenIdentifier: tokenMetadata.rawTokenIdentifier,
|
|
458
452
|
network: this.config.getNetworkType()
|
|
459
453
|
});
|
|
@@ -528,7 +522,7 @@ var IssuerSparkWallet = class _IssuerSparkWallet extends import_spark_sdk5.Spark
|
|
|
528
522
|
* @returns The transaction ID of the burn operation
|
|
529
523
|
*/
|
|
530
524
|
async burnTokens(tokenAmount, selectedOutputs) {
|
|
531
|
-
const burnAddress = (0,
|
|
525
|
+
const burnAddress = (0, import_spark_sdk5.encodeSparkAddress)({
|
|
532
526
|
identityPublicKey: BURN_ADDRESS,
|
|
533
527
|
network: this.config.getNetworkType()
|
|
534
528
|
});
|
|
@@ -547,12 +541,12 @@ var IssuerSparkWallet = class _IssuerSparkWallet extends import_spark_sdk5.Spark
|
|
|
547
541
|
*/
|
|
548
542
|
async freezeTokens(sparkAddress) {
|
|
549
543
|
await this.syncTokenOutputs();
|
|
550
|
-
const decodedOwnerPubkey = (0,
|
|
544
|
+
const decodedOwnerPubkey = (0, import_spark_sdk5.decodeSparkAddress)(
|
|
551
545
|
sparkAddress,
|
|
552
546
|
this.config.getNetworkType()
|
|
553
547
|
);
|
|
554
548
|
const issuerTokenIdentifier = await this.getIssuerTokenIdentifier();
|
|
555
|
-
const rawTokenIdentifier = (0,
|
|
549
|
+
const rawTokenIdentifier = (0, import_spark_sdk5.decodeBech32mTokenIdentifier)(
|
|
556
550
|
issuerTokenIdentifier,
|
|
557
551
|
this.config.getNetworkType()
|
|
558
552
|
).tokenIdentifier;
|
|
@@ -573,12 +567,12 @@ var IssuerSparkWallet = class _IssuerSparkWallet extends import_spark_sdk5.Spark
|
|
|
573
567
|
*/
|
|
574
568
|
async unfreezeTokens(sparkAddress) {
|
|
575
569
|
await this.syncTokenOutputs();
|
|
576
|
-
const decodedOwnerPubkey = (0,
|
|
570
|
+
const decodedOwnerPubkey = (0, import_spark_sdk5.decodeSparkAddress)(
|
|
577
571
|
sparkAddress,
|
|
578
572
|
this.config.getNetworkType()
|
|
579
573
|
);
|
|
580
574
|
const issuerTokenIdentifier = await this.getIssuerTokenIdentifier();
|
|
581
|
-
const rawTokenIdentifier = (0,
|
|
575
|
+
const rawTokenIdentifier = (0, import_spark_sdk5.decodeBech32mTokenIdentifier)(
|
|
582
576
|
issuerTokenIdentifier,
|
|
583
577
|
this.config.getNetworkType()
|
|
584
578
|
).tokenIdentifier;
|
|
@@ -597,7 +591,7 @@ var IssuerSparkWallet = class _IssuerSparkWallet extends import_spark_sdk5.Spark
|
|
|
597
591
|
* @throws {NotImplementedError} This feature is not yet supported
|
|
598
592
|
*/
|
|
599
593
|
async getIssuerTokenDistribution() {
|
|
600
|
-
throw new
|
|
594
|
+
throw new import_spark_sdk5.NotImplementedError("Token distribution is not yet supported");
|
|
601
595
|
}
|
|
602
596
|
getTraceName(methodName) {
|
|
603
597
|
return `IssuerSparkWallet.${methodName}`;
|
|
@@ -634,7 +628,7 @@ var IssuerSparkWallet = class _IssuerSparkWallet extends import_spark_sdk5.Spark
|
|
|
634
628
|
};
|
|
635
629
|
|
|
636
630
|
// src/issuer-wallet/issuer-spark-wallet.browser.ts
|
|
637
|
-
var
|
|
631
|
+
var import_spark_sdk6 = require("@buildonspark/spark-sdk");
|
|
638
632
|
var IssuerSparkWalletBrowser = class _IssuerSparkWalletBrowser extends IssuerSparkWallet {
|
|
639
633
|
static async initialize({
|
|
640
634
|
mnemonicOrSeed,
|
|
@@ -660,7 +654,7 @@ var IssuerSparkWalletBrowser = class _IssuerSparkWalletBrowser extends IssuerSpa
|
|
|
660
654
|
spanProcessors,
|
|
661
655
|
traceUrls
|
|
662
656
|
}) {
|
|
663
|
-
(0,
|
|
657
|
+
(0, import_spark_sdk6.initializeTracerEnv)({ spanProcessors, traceUrls });
|
|
664
658
|
}
|
|
665
659
|
};
|
|
666
660
|
// Annotate the CommonJS export names for ESM import in node:
|
package/dist/index.js
CHANGED
package/dist/index.node.cjs
CHANGED
|
@@ -40,12 +40,11 @@ if (typeof window !== "undefined") {
|
|
|
40
40
|
|
|
41
41
|
// src/issuer-wallet/issuer-spark-wallet.ts
|
|
42
42
|
var import_spark_sdk5 = require("@buildonspark/spark-sdk");
|
|
43
|
-
var
|
|
44
|
-
var import_utils4 = require("@noble/curves/abstract/utils");
|
|
45
|
-
var import_spark_sdk7 = require("@buildonspark/spark-sdk");
|
|
43
|
+
var import_utils4 = require("@noble/curves/utils");
|
|
46
44
|
|
|
47
45
|
// src/services/freeze.ts
|
|
48
46
|
var import_spark_sdk2 = require("@buildonspark/spark-sdk");
|
|
47
|
+
var import_utils2 = require("@noble/curves/utils");
|
|
49
48
|
|
|
50
49
|
// src/utils/token-hashing.ts
|
|
51
50
|
var import_utils = require("@scure/btc-signer/utils");
|
|
@@ -107,7 +106,6 @@ function hashFreezeTokensPayload(payload) {
|
|
|
107
106
|
}
|
|
108
107
|
|
|
109
108
|
// src/services/freeze.ts
|
|
110
|
-
var import_utils2 = require("@noble/curves/abstract/utils");
|
|
111
109
|
var TokenFreezeService = class {
|
|
112
110
|
config;
|
|
113
111
|
connectionManager;
|
|
@@ -172,7 +170,7 @@ var TokenFreezeService = class {
|
|
|
172
170
|
|
|
173
171
|
// src/services/token-transactions.ts
|
|
174
172
|
var import_spark_sdk3 = require("@buildonspark/spark-sdk");
|
|
175
|
-
var import_utils3 = require("@noble/curves/
|
|
173
|
+
var import_utils3 = require("@noble/curves/utils");
|
|
176
174
|
var IssuerTokenTransactionService = class extends import_spark_sdk3.TokenTransactionService {
|
|
177
175
|
constructor(config, connectionManager) {
|
|
178
176
|
super(config, connectionManager);
|
|
@@ -245,9 +243,6 @@ var IssuerTokenTransactionService = class extends import_spark_sdk3.TokenTransac
|
|
|
245
243
|
}
|
|
246
244
|
};
|
|
247
245
|
|
|
248
|
-
// src/issuer-wallet/issuer-spark-wallet.ts
|
|
249
|
-
var import_spark_sdk8 = require("@buildonspark/spark-sdk");
|
|
250
|
-
|
|
251
246
|
// src/utils/create-validation.ts
|
|
252
247
|
var import_spark_sdk4 = require("@buildonspark/spark-sdk");
|
|
253
248
|
function isNfcNormalized(value) {
|
|
@@ -318,7 +313,6 @@ function validateTokenParameters(tokenName, tokenTicker, decimals, maxSupply) {
|
|
|
318
313
|
}
|
|
319
314
|
|
|
320
315
|
// src/issuer-wallet/issuer-spark-wallet.ts
|
|
321
|
-
var import_spark_sdk9 = require("@buildonspark/spark-sdk");
|
|
322
316
|
var BURN_ADDRESS = "02".repeat(33);
|
|
323
317
|
var IssuerSparkWallet = class _IssuerSparkWallet extends import_spark_sdk5.SparkWallet {
|
|
324
318
|
issuerTokenTransactionService;
|
|
@@ -425,7 +419,7 @@ var IssuerSparkWallet = class _IssuerSparkWallet extends import_spark_sdk5.Spark
|
|
|
425
419
|
);
|
|
426
420
|
}
|
|
427
421
|
const metadata = response.tokenMetadata[0];
|
|
428
|
-
const tokenIdentifier = (0,
|
|
422
|
+
const tokenIdentifier = (0, import_spark_sdk5.encodeBech32mTokenIdentifier)({
|
|
429
423
|
tokenIdentifier: metadata.tokenIdentifier,
|
|
430
424
|
network: this.config.getNetworkType()
|
|
431
425
|
});
|
|
@@ -453,7 +447,7 @@ var IssuerSparkWallet = class _IssuerSparkWallet extends import_spark_sdk5.Spark
|
|
|
453
447
|
*/
|
|
454
448
|
async getIssuerTokenIdentifier() {
|
|
455
449
|
const tokenMetadata = await this.getIssuerTokenMetadata();
|
|
456
|
-
return (0,
|
|
450
|
+
return (0, import_spark_sdk5.encodeBech32mTokenIdentifier)({
|
|
457
451
|
tokenIdentifier: tokenMetadata.rawTokenIdentifier,
|
|
458
452
|
network: this.config.getNetworkType()
|
|
459
453
|
});
|
|
@@ -528,7 +522,7 @@ var IssuerSparkWallet = class _IssuerSparkWallet extends import_spark_sdk5.Spark
|
|
|
528
522
|
* @returns The transaction ID of the burn operation
|
|
529
523
|
*/
|
|
530
524
|
async burnTokens(tokenAmount, selectedOutputs) {
|
|
531
|
-
const burnAddress = (0,
|
|
525
|
+
const burnAddress = (0, import_spark_sdk5.encodeSparkAddress)({
|
|
532
526
|
identityPublicKey: BURN_ADDRESS,
|
|
533
527
|
network: this.config.getNetworkType()
|
|
534
528
|
});
|
|
@@ -547,12 +541,12 @@ var IssuerSparkWallet = class _IssuerSparkWallet extends import_spark_sdk5.Spark
|
|
|
547
541
|
*/
|
|
548
542
|
async freezeTokens(sparkAddress) {
|
|
549
543
|
await this.syncTokenOutputs();
|
|
550
|
-
const decodedOwnerPubkey = (0,
|
|
544
|
+
const decodedOwnerPubkey = (0, import_spark_sdk5.decodeSparkAddress)(
|
|
551
545
|
sparkAddress,
|
|
552
546
|
this.config.getNetworkType()
|
|
553
547
|
);
|
|
554
548
|
const issuerTokenIdentifier = await this.getIssuerTokenIdentifier();
|
|
555
|
-
const rawTokenIdentifier = (0,
|
|
549
|
+
const rawTokenIdentifier = (0, import_spark_sdk5.decodeBech32mTokenIdentifier)(
|
|
556
550
|
issuerTokenIdentifier,
|
|
557
551
|
this.config.getNetworkType()
|
|
558
552
|
).tokenIdentifier;
|
|
@@ -573,12 +567,12 @@ var IssuerSparkWallet = class _IssuerSparkWallet extends import_spark_sdk5.Spark
|
|
|
573
567
|
*/
|
|
574
568
|
async unfreezeTokens(sparkAddress) {
|
|
575
569
|
await this.syncTokenOutputs();
|
|
576
|
-
const decodedOwnerPubkey = (0,
|
|
570
|
+
const decodedOwnerPubkey = (0, import_spark_sdk5.decodeSparkAddress)(
|
|
577
571
|
sparkAddress,
|
|
578
572
|
this.config.getNetworkType()
|
|
579
573
|
);
|
|
580
574
|
const issuerTokenIdentifier = await this.getIssuerTokenIdentifier();
|
|
581
|
-
const rawTokenIdentifier = (0,
|
|
575
|
+
const rawTokenIdentifier = (0, import_spark_sdk5.decodeBech32mTokenIdentifier)(
|
|
582
576
|
issuerTokenIdentifier,
|
|
583
577
|
this.config.getNetworkType()
|
|
584
578
|
).tokenIdentifier;
|
|
@@ -597,7 +591,7 @@ var IssuerSparkWallet = class _IssuerSparkWallet extends import_spark_sdk5.Spark
|
|
|
597
591
|
* @throws {NotImplementedError} This feature is not yet supported
|
|
598
592
|
*/
|
|
599
593
|
async getIssuerTokenDistribution() {
|
|
600
|
-
throw new
|
|
594
|
+
throw new import_spark_sdk5.NotImplementedError("Token distribution is not yet supported");
|
|
601
595
|
}
|
|
602
596
|
getTraceName(methodName) {
|
|
603
597
|
return `IssuerSparkWallet.${methodName}`;
|
|
@@ -634,7 +628,7 @@ var IssuerSparkWallet = class _IssuerSparkWallet extends import_spark_sdk5.Spark
|
|
|
634
628
|
};
|
|
635
629
|
|
|
636
630
|
// src/issuer-wallet/issuer-spark-wallet.node.ts
|
|
637
|
-
var
|
|
631
|
+
var import_spark_sdk6 = require("@buildonspark/spark-sdk");
|
|
638
632
|
var IssuerSparkWalletNodeJS = class _IssuerSparkWalletNodeJS extends IssuerSparkWallet {
|
|
639
633
|
static async initialize({
|
|
640
634
|
mnemonicOrSeed,
|
|
@@ -660,7 +654,7 @@ var IssuerSparkWalletNodeJS = class _IssuerSparkWalletNodeJS extends IssuerSpark
|
|
|
660
654
|
spanProcessors,
|
|
661
655
|
traceUrls
|
|
662
656
|
}) {
|
|
663
|
-
(0,
|
|
657
|
+
(0, import_spark_sdk6.initializeTracerEnv)({ spanProcessors, traceUrls });
|
|
664
658
|
}
|
|
665
659
|
};
|
|
666
660
|
// Annotate the CommonJS export names for ESM import in node:
|
package/dist/index.node.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@buildonspark/issuer-sdk",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.91",
|
|
4
4
|
"description": "Spark Issuer SDK for token issuance",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"module": "./dist/index.js",
|
|
@@ -72,7 +72,7 @@
|
|
|
72
72
|
"types": "tsc"
|
|
73
73
|
},
|
|
74
74
|
"dependencies": {
|
|
75
|
-
"@buildonspark/spark-sdk": "0.2.
|
|
75
|
+
"@buildonspark/spark-sdk": "0.2.12",
|
|
76
76
|
"@noble/curves": "^1.8.0",
|
|
77
77
|
"@scure/btc-signer": "^1.5.0",
|
|
78
78
|
"buffer": "^6.0.3"
|
|
@@ -1,35 +1,27 @@
|
|
|
1
1
|
import {
|
|
2
|
+
Bech32mTokenIdentifier,
|
|
3
|
+
decodeBech32mTokenIdentifier,
|
|
4
|
+
decodeSparkAddress,
|
|
5
|
+
encodeBech32mTokenIdentifier,
|
|
6
|
+
encodeSparkAddress,
|
|
2
7
|
NetworkError,
|
|
8
|
+
NotImplementedError,
|
|
9
|
+
SparkSigner,
|
|
3
10
|
SparkWallet,
|
|
4
11
|
SparkWalletProps,
|
|
5
12
|
ValidationError,
|
|
6
|
-
|
|
7
|
-
import {
|
|
8
|
-
decodeSparkAddress,
|
|
9
|
-
encodeSparkAddress,
|
|
13
|
+
type ConfigOptions,
|
|
10
14
|
} from "@buildonspark/spark-sdk";
|
|
11
15
|
import {
|
|
12
16
|
OutputWithPreviousTransactionData,
|
|
13
17
|
TokenTransaction as TokenTransactionV0,
|
|
14
18
|
} from "@buildonspark/spark-sdk/proto/spark";
|
|
15
19
|
import { TokenTransaction } from "@buildonspark/spark-sdk/proto/spark_token";
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
bytesToHex,
|
|
19
|
-
bytesToNumberBE,
|
|
20
|
-
hexToBytes,
|
|
21
|
-
} from "@noble/curves/abstract/utils";
|
|
22
|
-
import { decodeBech32mTokenIdentifier } from "@buildonspark/spark-sdk";
|
|
20
|
+
import { bytesToHex, bytesToNumberBE, hexToBytes } from "@noble/curves/utils";
|
|
23
21
|
import { TokenFreezeService } from "../services/freeze.js";
|
|
24
22
|
import { IssuerTokenTransactionService } from "../services/token-transactions.js";
|
|
25
|
-
import { TokenDistribution, IssuerTokenMetadata } from "./types.js";
|
|
26
|
-
import { NotImplementedError } from "@buildonspark/spark-sdk";
|
|
27
|
-
import { SparkSigner } from "@buildonspark/spark-sdk";
|
|
28
23
|
import { validateTokenParameters } from "../utils/create-validation.js";
|
|
29
|
-
import {
|
|
30
|
-
encodeBech32mTokenIdentifier,
|
|
31
|
-
Bech32mTokenIdentifier,
|
|
32
|
-
} from "@buildonspark/spark-sdk";
|
|
24
|
+
import { IssuerTokenMetadata, TokenDistribution } from "./types.js";
|
|
33
25
|
|
|
34
26
|
const BURN_ADDRESS = "02".repeat(33);
|
|
35
27
|
|
package/src/services/freeze.ts
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import {
|
|
2
|
-
FreezeTokensResponse,
|
|
3
|
-
FreezeTokensPayload,
|
|
4
|
-
} from "@buildonspark/spark-sdk/proto/spark_token";
|
|
5
1
|
import {
|
|
6
2
|
type ConnectionManager,
|
|
7
|
-
WalletConfigService,
|
|
8
3
|
NetworkError,
|
|
4
|
+
WalletConfigService,
|
|
9
5
|
collectResponses,
|
|
10
6
|
} from "@buildonspark/spark-sdk";
|
|
7
|
+
import {
|
|
8
|
+
FreezeTokensPayload,
|
|
9
|
+
FreezeTokensResponse,
|
|
10
|
+
} from "@buildonspark/spark-sdk/proto/spark_token";
|
|
11
|
+
import { hexToBytes } from "@noble/curves/utils";
|
|
11
12
|
import { hashFreezeTokensPayload } from "../utils/token-hashing.js";
|
|
12
|
-
import { hexToBytes } from "@noble/curves/abstract/utils";
|
|
13
13
|
|
|
14
14
|
export class TokenFreezeService {
|
|
15
15
|
private readonly config: WalletConfigService;
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import {
|
|
2
|
+
TokenTransactionService,
|
|
3
|
+
WalletConfigService,
|
|
4
|
+
type ConnectionManager,
|
|
5
|
+
} from "@buildonspark/spark-sdk";
|
|
3
6
|
import { TokenTransaction as TokenTransactionV0 } from "@buildonspark/spark-sdk/proto/spark";
|
|
4
7
|
import { TokenTransaction } from "@buildonspark/spark-sdk/proto/spark_token";
|
|
5
|
-
import {
|
|
6
|
-
import { numberToBytesBE } from "@noble/curves/abstract/utils";
|
|
8
|
+
import { numberToBytesBE } from "@noble/curves/utils";
|
|
7
9
|
|
|
8
10
|
export class IssuerTokenTransactionService extends TokenTransactionService {
|
|
9
11
|
constructor(
|
|
@@ -1,14 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
|
-
WalletConfig,
|
|
3
2
|
ConfigOptions,
|
|
4
3
|
filterTokenBalanceForTokenIdentifier,
|
|
4
|
+
WalletConfig,
|
|
5
5
|
} from "@buildonspark/spark-sdk";
|
|
6
6
|
import { jest } from "@jest/globals";
|
|
7
|
+
import { bytesToHex } from "@noble/curves/utils";
|
|
7
8
|
import { IssuerSparkWalletTesting } from "../utils/issuer-test-wallet.js";
|
|
8
9
|
import { SparkWalletTesting } from "../utils/spark-testing-wallet.js";
|
|
9
|
-
import { BitcoinFaucet } from "@buildonspark/spark-sdk/test-utils";
|
|
10
|
-
import { bytesToHex } from "@noble/curves/abstract/utils";
|
|
11
|
-
import { IssuerSparkWallet } from "../../issuer-wallet/issuer-spark-wallet.node.js";
|
|
12
10
|
|
|
13
11
|
export const TOKENS_V0_SCHNORR_CONFIG: Required<ConfigOptions> = {
|
|
14
12
|
...WalletConfig.LOCAL,
|
|
@@ -39,6 +39,13 @@ describe("Stress test for token transfers", () => {
|
|
|
39
39
|
options: WalletConfig.LOCAL,
|
|
40
40
|
});
|
|
41
41
|
|
|
42
|
+
await issuerWallet.createToken({
|
|
43
|
+
tokenName: "TestToken",
|
|
44
|
+
tokenTicker: "TEST",
|
|
45
|
+
decimals: 0,
|
|
46
|
+
isFreezable: false,
|
|
47
|
+
maxSupply: 1_000_000n,
|
|
48
|
+
});
|
|
42
49
|
await issuerWallet.mintTokens(TOKEN_AMOUNT);
|
|
43
50
|
await sleep(1000);
|
|
44
51
|
const tokenIdentifier = await issuerWallet.getIssuerTokenIdentifier();
|
|
@@ -124,6 +131,13 @@ describe("Stress test for token transfers", () => {
|
|
|
124
131
|
options: WalletConfig.LOCAL,
|
|
125
132
|
});
|
|
126
133
|
|
|
134
|
+
await issuer.wallet.createToken({
|
|
135
|
+
tokenName: "TestToken",
|
|
136
|
+
tokenTicker: "TEST",
|
|
137
|
+
decimals: 0,
|
|
138
|
+
isFreezable: false,
|
|
139
|
+
maxSupply: 1_000_000n,
|
|
140
|
+
});
|
|
127
141
|
await issuer.wallet.mintTokens(TOKEN_AMOUNT);
|
|
128
142
|
const userAddress = await user.wallet.getSparkAddress();
|
|
129
143
|
const tokenIdentifier =
|