@buildonspark/issuer-sdk 0.0.85 → 0.0.86
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 +7 -0
- package/dist/{chunk-HOLMXKFE.js → chunk-NRKE2XKD.js} +2 -55
- package/dist/index.cjs +2 -55
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/dist/index.node.cjs +2 -55
- package/dist/index.node.d.cts +2 -2
- package/dist/index.node.d.ts +2 -2
- package/dist/index.node.js +1 -1
- package/dist/{issuer-spark-wallet-BFzkv4X5.d.cts → issuer-spark-wallet-Bho-WrkK.d.cts} +0 -13
- package/dist/{issuer-spark-wallet-BFzkv4X5.d.ts → issuer-spark-wallet-Bho-WrkK.d.ts} +0 -13
- package/package.json +3 -5
- package/src/issuer-wallet/issuer-spark-wallet.ts +1 -69
- package/src/tests/integration/spark.test.ts +0 -88
- package/src/utils/constants.ts +0 -19
package/CHANGELOG.md
CHANGED
|
@@ -3,7 +3,6 @@ import {
|
|
|
3
3
|
} from "./chunk-7B4B24XF.js";
|
|
4
4
|
|
|
5
5
|
// src/issuer-wallet/issuer-spark-wallet.ts
|
|
6
|
-
import { TokenPubkey, TokenPubkeyAnnouncement } from "@buildonspark/lrc20-sdk";
|
|
7
6
|
import {
|
|
8
7
|
NetworkError as NetworkError2,
|
|
9
8
|
SparkWallet,
|
|
@@ -387,7 +386,7 @@ var IssuerSparkWallet = class _IssuerSparkWallet extends SparkWallet {
|
|
|
387
386
|
});
|
|
388
387
|
if (response.tokenMetadata.length === 0) {
|
|
389
388
|
throw new ValidationError3(
|
|
390
|
-
"Token metadata not found - If a token has not yet been
|
|
389
|
+
"Token metadata not found - If a token has not yet been created, please create it first. Try again in a few seconds.",
|
|
391
390
|
{
|
|
392
391
|
field: "tokenMetadata",
|
|
393
392
|
value: response.tokenMetadata,
|
|
@@ -572,57 +571,6 @@ var IssuerSparkWallet = class _IssuerSparkWallet extends SparkWallet {
|
|
|
572
571
|
async getIssuerTokenDistribution() {
|
|
573
572
|
throw new NotImplementedError("Token distribution is not yet supported");
|
|
574
573
|
}
|
|
575
|
-
/**
|
|
576
|
-
* Announces a new token on the L1 (Bitcoin) network.
|
|
577
|
-
* @param tokenName - The name of the token
|
|
578
|
-
* @param tokenTicker - The ticker symbol for the token
|
|
579
|
-
* @param decimals - The number of decimal places for the token
|
|
580
|
-
* @param maxSupply - The maximum supply of the token
|
|
581
|
-
* @param isFreezable - Whether the token can be frozen
|
|
582
|
-
* @param feeRateSatsPerVb - The fee rate in satoshis per virtual byte (default: 4.0)
|
|
583
|
-
* @returns The transaction ID of the announcement
|
|
584
|
-
* @throws {ValidationError} If decimals is not a safe integer
|
|
585
|
-
* @throws {NetworkError} If the announcement transaction cannot be broadcast
|
|
586
|
-
*/
|
|
587
|
-
async announceTokenL1(tokenName, tokenTicker, decimals, maxSupply, isFreezable, feeRateSatsPerVb = 4) {
|
|
588
|
-
validateTokenParameters(tokenName, tokenTicker, decimals, maxSupply);
|
|
589
|
-
if (!Number.isSafeInteger(decimals)) {
|
|
590
|
-
throw new ValidationError3("Decimals must be less than 2^53", {
|
|
591
|
-
field: "decimals",
|
|
592
|
-
value: decimals,
|
|
593
|
-
expected: "smaller or equal to " + Number.MAX_SAFE_INTEGER
|
|
594
|
-
});
|
|
595
|
-
}
|
|
596
|
-
await this.lrc20Wallet.syncWallet();
|
|
597
|
-
const tokenPublicKey = new TokenPubkey(this.lrc20Wallet.pubkey);
|
|
598
|
-
const announcement = new TokenPubkeyAnnouncement(
|
|
599
|
-
tokenPublicKey,
|
|
600
|
-
tokenName,
|
|
601
|
-
tokenTicker,
|
|
602
|
-
decimals,
|
|
603
|
-
maxSupply,
|
|
604
|
-
isFreezable
|
|
605
|
-
);
|
|
606
|
-
try {
|
|
607
|
-
const tx = await this.lrc20Wallet.prepareAnnouncement(
|
|
608
|
-
announcement,
|
|
609
|
-
feeRateSatsPerVb
|
|
610
|
-
);
|
|
611
|
-
const txId = await this.lrc20Wallet.broadcastRawBtcTransaction(
|
|
612
|
-
tx.bitcoin_tx.toHex()
|
|
613
|
-
);
|
|
614
|
-
return txId;
|
|
615
|
-
} catch (error) {
|
|
616
|
-
throw new NetworkError2(
|
|
617
|
-
"Failed to broadcast announcement transaction on L1",
|
|
618
|
-
{
|
|
619
|
-
operation: "broadcastRawBtcTransaction",
|
|
620
|
-
errorCount: 1,
|
|
621
|
-
errors: error instanceof Error ? error.message : String(error)
|
|
622
|
-
}
|
|
623
|
-
);
|
|
624
|
-
}
|
|
625
|
-
}
|
|
626
574
|
getTraceName(methodName) {
|
|
627
575
|
return `IssuerSparkWallet.${methodName}`;
|
|
628
576
|
}
|
|
@@ -649,8 +597,7 @@ var IssuerSparkWallet = class _IssuerSparkWallet extends SparkWallet {
|
|
|
649
597
|
"burnTokens",
|
|
650
598
|
"freezeTokens",
|
|
651
599
|
"unfreezeTokens",
|
|
652
|
-
"getIssuerTokenDistribution"
|
|
653
|
-
"announceTokenL1"
|
|
600
|
+
"getIssuerTokenDistribution"
|
|
654
601
|
];
|
|
655
602
|
methods.forEach(
|
|
656
603
|
(m) => this.wrapPublicIssuerSparkWalletMethodWithOtelSpan(m)
|
package/dist/index.cjs
CHANGED
|
@@ -39,7 +39,6 @@ if (typeof window !== "undefined") {
|
|
|
39
39
|
}
|
|
40
40
|
|
|
41
41
|
// src/issuer-wallet/issuer-spark-wallet.ts
|
|
42
|
-
var import_lrc20_sdk = require("@buildonspark/lrc20-sdk");
|
|
43
42
|
var import_spark_sdk5 = require("@buildonspark/spark-sdk");
|
|
44
43
|
var import_spark_sdk6 = require("@buildonspark/spark-sdk");
|
|
45
44
|
var import_utils4 = require("@noble/curves/abstract/utils");
|
|
@@ -407,7 +406,7 @@ var IssuerSparkWallet = class _IssuerSparkWallet extends import_spark_sdk5.Spark
|
|
|
407
406
|
});
|
|
408
407
|
if (response.tokenMetadata.length === 0) {
|
|
409
408
|
throw new import_spark_sdk5.ValidationError(
|
|
410
|
-
"Token metadata not found - If a token has not yet been
|
|
409
|
+
"Token metadata not found - If a token has not yet been created, please create it first. Try again in a few seconds.",
|
|
411
410
|
{
|
|
412
411
|
field: "tokenMetadata",
|
|
413
412
|
value: response.tokenMetadata,
|
|
@@ -592,57 +591,6 @@ var IssuerSparkWallet = class _IssuerSparkWallet extends import_spark_sdk5.Spark
|
|
|
592
591
|
async getIssuerTokenDistribution() {
|
|
593
592
|
throw new import_spark_sdk8.NotImplementedError("Token distribution is not yet supported");
|
|
594
593
|
}
|
|
595
|
-
/**
|
|
596
|
-
* Announces a new token on the L1 (Bitcoin) network.
|
|
597
|
-
* @param tokenName - The name of the token
|
|
598
|
-
* @param tokenTicker - The ticker symbol for the token
|
|
599
|
-
* @param decimals - The number of decimal places for the token
|
|
600
|
-
* @param maxSupply - The maximum supply of the token
|
|
601
|
-
* @param isFreezable - Whether the token can be frozen
|
|
602
|
-
* @param feeRateSatsPerVb - The fee rate in satoshis per virtual byte (default: 4.0)
|
|
603
|
-
* @returns The transaction ID of the announcement
|
|
604
|
-
* @throws {ValidationError} If decimals is not a safe integer
|
|
605
|
-
* @throws {NetworkError} If the announcement transaction cannot be broadcast
|
|
606
|
-
*/
|
|
607
|
-
async announceTokenL1(tokenName, tokenTicker, decimals, maxSupply, isFreezable, feeRateSatsPerVb = 4) {
|
|
608
|
-
validateTokenParameters(tokenName, tokenTicker, decimals, maxSupply);
|
|
609
|
-
if (!Number.isSafeInteger(decimals)) {
|
|
610
|
-
throw new import_spark_sdk5.ValidationError("Decimals must be less than 2^53", {
|
|
611
|
-
field: "decimals",
|
|
612
|
-
value: decimals,
|
|
613
|
-
expected: "smaller or equal to " + Number.MAX_SAFE_INTEGER
|
|
614
|
-
});
|
|
615
|
-
}
|
|
616
|
-
await this.lrc20Wallet.syncWallet();
|
|
617
|
-
const tokenPublicKey = new import_lrc20_sdk.TokenPubkey(this.lrc20Wallet.pubkey);
|
|
618
|
-
const announcement = new import_lrc20_sdk.TokenPubkeyAnnouncement(
|
|
619
|
-
tokenPublicKey,
|
|
620
|
-
tokenName,
|
|
621
|
-
tokenTicker,
|
|
622
|
-
decimals,
|
|
623
|
-
maxSupply,
|
|
624
|
-
isFreezable
|
|
625
|
-
);
|
|
626
|
-
try {
|
|
627
|
-
const tx = await this.lrc20Wallet.prepareAnnouncement(
|
|
628
|
-
announcement,
|
|
629
|
-
feeRateSatsPerVb
|
|
630
|
-
);
|
|
631
|
-
const txId = await this.lrc20Wallet.broadcastRawBtcTransaction(
|
|
632
|
-
tx.bitcoin_tx.toHex()
|
|
633
|
-
);
|
|
634
|
-
return txId;
|
|
635
|
-
} catch (error) {
|
|
636
|
-
throw new import_spark_sdk5.NetworkError(
|
|
637
|
-
"Failed to broadcast announcement transaction on L1",
|
|
638
|
-
{
|
|
639
|
-
operation: "broadcastRawBtcTransaction",
|
|
640
|
-
errorCount: 1,
|
|
641
|
-
errors: error instanceof Error ? error.message : String(error)
|
|
642
|
-
}
|
|
643
|
-
);
|
|
644
|
-
}
|
|
645
|
-
}
|
|
646
594
|
getTraceName(methodName) {
|
|
647
595
|
return `IssuerSparkWallet.${methodName}`;
|
|
648
596
|
}
|
|
@@ -669,8 +617,7 @@ var IssuerSparkWallet = class _IssuerSparkWallet extends import_spark_sdk5.Spark
|
|
|
669
617
|
"burnTokens",
|
|
670
618
|
"freezeTokens",
|
|
671
619
|
"unfreezeTokens",
|
|
672
|
-
"getIssuerTokenDistribution"
|
|
673
|
-
"announceTokenL1"
|
|
620
|
+
"getIssuerTokenDistribution"
|
|
674
621
|
];
|
|
675
622
|
methods.forEach(
|
|
676
623
|
(m) => this.wrapPublicIssuerSparkWalletMethodWithOtelSpan(m)
|
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { I as IssuerSparkWallet } from './issuer-spark-wallet-
|
|
2
|
-
export { a as IssuerTokenMetadata, T as TokenDistribution } from './issuer-spark-wallet-
|
|
1
|
+
import { I as IssuerSparkWallet } from './issuer-spark-wallet-Bho-WrkK.cjs';
|
|
2
|
+
export { a as IssuerTokenMetadata, T as TokenDistribution } from './issuer-spark-wallet-Bho-WrkK.cjs';
|
|
3
3
|
import { SparkWalletProps } from '@buildonspark/spark-sdk';
|
|
4
4
|
import '@buildonspark/spark-sdk/proto/spark';
|
|
5
5
|
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { I as IssuerSparkWallet } from './issuer-spark-wallet-
|
|
2
|
-
export { a as IssuerTokenMetadata, T as TokenDistribution } from './issuer-spark-wallet-
|
|
1
|
+
import { I as IssuerSparkWallet } from './issuer-spark-wallet-Bho-WrkK.js';
|
|
2
|
+
export { a as IssuerTokenMetadata, T as TokenDistribution } from './issuer-spark-wallet-Bho-WrkK.js';
|
|
3
3
|
import { SparkWalletProps } from '@buildonspark/spark-sdk';
|
|
4
4
|
import '@buildonspark/spark-sdk/proto/spark';
|
|
5
5
|
|
package/dist/index.js
CHANGED
package/dist/index.node.cjs
CHANGED
|
@@ -39,7 +39,6 @@ if (typeof window !== "undefined") {
|
|
|
39
39
|
}
|
|
40
40
|
|
|
41
41
|
// src/issuer-wallet/issuer-spark-wallet.ts
|
|
42
|
-
var import_lrc20_sdk = require("@buildonspark/lrc20-sdk");
|
|
43
42
|
var import_spark_sdk5 = require("@buildonspark/spark-sdk");
|
|
44
43
|
var import_spark_sdk6 = require("@buildonspark/spark-sdk");
|
|
45
44
|
var import_utils4 = require("@noble/curves/abstract/utils");
|
|
@@ -407,7 +406,7 @@ var IssuerSparkWallet = class _IssuerSparkWallet extends import_spark_sdk5.Spark
|
|
|
407
406
|
});
|
|
408
407
|
if (response.tokenMetadata.length === 0) {
|
|
409
408
|
throw new import_spark_sdk5.ValidationError(
|
|
410
|
-
"Token metadata not found - If a token has not yet been
|
|
409
|
+
"Token metadata not found - If a token has not yet been created, please create it first. Try again in a few seconds.",
|
|
411
410
|
{
|
|
412
411
|
field: "tokenMetadata",
|
|
413
412
|
value: response.tokenMetadata,
|
|
@@ -592,57 +591,6 @@ var IssuerSparkWallet = class _IssuerSparkWallet extends import_spark_sdk5.Spark
|
|
|
592
591
|
async getIssuerTokenDistribution() {
|
|
593
592
|
throw new import_spark_sdk8.NotImplementedError("Token distribution is not yet supported");
|
|
594
593
|
}
|
|
595
|
-
/**
|
|
596
|
-
* Announces a new token on the L1 (Bitcoin) network.
|
|
597
|
-
* @param tokenName - The name of the token
|
|
598
|
-
* @param tokenTicker - The ticker symbol for the token
|
|
599
|
-
* @param decimals - The number of decimal places for the token
|
|
600
|
-
* @param maxSupply - The maximum supply of the token
|
|
601
|
-
* @param isFreezable - Whether the token can be frozen
|
|
602
|
-
* @param feeRateSatsPerVb - The fee rate in satoshis per virtual byte (default: 4.0)
|
|
603
|
-
* @returns The transaction ID of the announcement
|
|
604
|
-
* @throws {ValidationError} If decimals is not a safe integer
|
|
605
|
-
* @throws {NetworkError} If the announcement transaction cannot be broadcast
|
|
606
|
-
*/
|
|
607
|
-
async announceTokenL1(tokenName, tokenTicker, decimals, maxSupply, isFreezable, feeRateSatsPerVb = 4) {
|
|
608
|
-
validateTokenParameters(tokenName, tokenTicker, decimals, maxSupply);
|
|
609
|
-
if (!Number.isSafeInteger(decimals)) {
|
|
610
|
-
throw new import_spark_sdk5.ValidationError("Decimals must be less than 2^53", {
|
|
611
|
-
field: "decimals",
|
|
612
|
-
value: decimals,
|
|
613
|
-
expected: "smaller or equal to " + Number.MAX_SAFE_INTEGER
|
|
614
|
-
});
|
|
615
|
-
}
|
|
616
|
-
await this.lrc20Wallet.syncWallet();
|
|
617
|
-
const tokenPublicKey = new import_lrc20_sdk.TokenPubkey(this.lrc20Wallet.pubkey);
|
|
618
|
-
const announcement = new import_lrc20_sdk.TokenPubkeyAnnouncement(
|
|
619
|
-
tokenPublicKey,
|
|
620
|
-
tokenName,
|
|
621
|
-
tokenTicker,
|
|
622
|
-
decimals,
|
|
623
|
-
maxSupply,
|
|
624
|
-
isFreezable
|
|
625
|
-
);
|
|
626
|
-
try {
|
|
627
|
-
const tx = await this.lrc20Wallet.prepareAnnouncement(
|
|
628
|
-
announcement,
|
|
629
|
-
feeRateSatsPerVb
|
|
630
|
-
);
|
|
631
|
-
const txId = await this.lrc20Wallet.broadcastRawBtcTransaction(
|
|
632
|
-
tx.bitcoin_tx.toHex()
|
|
633
|
-
);
|
|
634
|
-
return txId;
|
|
635
|
-
} catch (error) {
|
|
636
|
-
throw new import_spark_sdk5.NetworkError(
|
|
637
|
-
"Failed to broadcast announcement transaction on L1",
|
|
638
|
-
{
|
|
639
|
-
operation: "broadcastRawBtcTransaction",
|
|
640
|
-
errorCount: 1,
|
|
641
|
-
errors: error instanceof Error ? error.message : String(error)
|
|
642
|
-
}
|
|
643
|
-
);
|
|
644
|
-
}
|
|
645
|
-
}
|
|
646
594
|
getTraceName(methodName) {
|
|
647
595
|
return `IssuerSparkWallet.${methodName}`;
|
|
648
596
|
}
|
|
@@ -669,8 +617,7 @@ var IssuerSparkWallet = class _IssuerSparkWallet extends import_spark_sdk5.Spark
|
|
|
669
617
|
"burnTokens",
|
|
670
618
|
"freezeTokens",
|
|
671
619
|
"unfreezeTokens",
|
|
672
|
-
"getIssuerTokenDistribution"
|
|
673
|
-
"announceTokenL1"
|
|
620
|
+
"getIssuerTokenDistribution"
|
|
674
621
|
];
|
|
675
622
|
methods.forEach(
|
|
676
623
|
(m) => this.wrapPublicIssuerSparkWalletMethodWithOtelSpan(m)
|
package/dist/index.node.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { I as IssuerSparkWallet } from './issuer-spark-wallet-
|
|
2
|
-
export { a as IssuerTokenMetadata, T as TokenDistribution } from './issuer-spark-wallet-
|
|
1
|
+
import { I as IssuerSparkWallet } from './issuer-spark-wallet-Bho-WrkK.cjs';
|
|
2
|
+
export { a as IssuerTokenMetadata, T as TokenDistribution } from './issuer-spark-wallet-Bho-WrkK.cjs';
|
|
3
3
|
import { SparkWalletProps } from '@buildonspark/spark-sdk';
|
|
4
4
|
import '@buildonspark/spark-sdk/proto/spark';
|
|
5
5
|
|
package/dist/index.node.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { I as IssuerSparkWallet } from './issuer-spark-wallet-
|
|
2
|
-
export { a as IssuerTokenMetadata, T as TokenDistribution } from './issuer-spark-wallet-
|
|
1
|
+
import { I as IssuerSparkWallet } from './issuer-spark-wallet-Bho-WrkK.js';
|
|
2
|
+
export { a as IssuerTokenMetadata, T as TokenDistribution } from './issuer-spark-wallet-Bho-WrkK.js';
|
|
3
3
|
import { SparkWalletProps } from '@buildonspark/spark-sdk';
|
|
4
4
|
import '@buildonspark/spark-sdk/proto/spark';
|
|
5
5
|
|
package/dist/index.node.js
CHANGED
|
@@ -143,19 +143,6 @@ declare class IssuerSparkWallet extends SparkWallet {
|
|
|
143
143
|
* @throws {NotImplementedError} This feature is not yet supported
|
|
144
144
|
*/
|
|
145
145
|
getIssuerTokenDistribution(): Promise<TokenDistribution>;
|
|
146
|
-
/**
|
|
147
|
-
* Announces a new token on the L1 (Bitcoin) network.
|
|
148
|
-
* @param tokenName - The name of the token
|
|
149
|
-
* @param tokenTicker - The ticker symbol for the token
|
|
150
|
-
* @param decimals - The number of decimal places for the token
|
|
151
|
-
* @param maxSupply - The maximum supply of the token
|
|
152
|
-
* @param isFreezable - Whether the token can be frozen
|
|
153
|
-
* @param feeRateSatsPerVb - The fee rate in satoshis per virtual byte (default: 4.0)
|
|
154
|
-
* @returns The transaction ID of the announcement
|
|
155
|
-
* @throws {ValidationError} If decimals is not a safe integer
|
|
156
|
-
* @throws {NetworkError} If the announcement transaction cannot be broadcast
|
|
157
|
-
*/
|
|
158
|
-
announceTokenL1(tokenName: string, tokenTicker: string, decimals: number, maxSupply: bigint, isFreezable: boolean, feeRateSatsPerVb?: number): Promise<string>;
|
|
159
146
|
protected getTraceName(methodName: string): string;
|
|
160
147
|
private wrapPublicIssuerSparkWalletMethodWithOtelSpan;
|
|
161
148
|
private wrapIssuerSparkWalletMethodsWithTracing;
|
|
@@ -143,19 +143,6 @@ declare class IssuerSparkWallet extends SparkWallet {
|
|
|
143
143
|
* @throws {NotImplementedError} This feature is not yet supported
|
|
144
144
|
*/
|
|
145
145
|
getIssuerTokenDistribution(): Promise<TokenDistribution>;
|
|
146
|
-
/**
|
|
147
|
-
* Announces a new token on the L1 (Bitcoin) network.
|
|
148
|
-
* @param tokenName - The name of the token
|
|
149
|
-
* @param tokenTicker - The ticker symbol for the token
|
|
150
|
-
* @param decimals - The number of decimal places for the token
|
|
151
|
-
* @param maxSupply - The maximum supply of the token
|
|
152
|
-
* @param isFreezable - Whether the token can be frozen
|
|
153
|
-
* @param feeRateSatsPerVb - The fee rate in satoshis per virtual byte (default: 4.0)
|
|
154
|
-
* @returns The transaction ID of the announcement
|
|
155
|
-
* @throws {ValidationError} If decimals is not a safe integer
|
|
156
|
-
* @throws {NetworkError} If the announcement transaction cannot be broadcast
|
|
157
|
-
*/
|
|
158
|
-
announceTokenL1(tokenName: string, tokenTicker: string, decimals: number, maxSupply: bigint, isFreezable: boolean, feeRateSatsPerVb?: number): Promise<string>;
|
|
159
146
|
protected getTraceName(methodName: string): string;
|
|
160
147
|
private wrapPublicIssuerSparkWalletMethodWithOtelSpan;
|
|
161
148
|
private wrapIssuerSparkWalletMethodsWithTracing;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@buildonspark/issuer-sdk",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.86",
|
|
4
4
|
"description": "Spark Issuer SDK for token issuance",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"module": "./dist/index.js",
|
|
@@ -72,12 +72,10 @@
|
|
|
72
72
|
"types": "tsc"
|
|
73
73
|
},
|
|
74
74
|
"dependencies": {
|
|
75
|
-
"@buildonspark/
|
|
76
|
-
"@
|
|
77
|
-
"@lightsparkdev/core": "^1.4.2",
|
|
75
|
+
"@buildonspark/spark-sdk": "0.2.7",
|
|
76
|
+
"@lightsparkdev/core": "^1.4.3",
|
|
78
77
|
"@noble/curves": "^1.8.0",
|
|
79
78
|
"@scure/btc-signer": "^1.5.0",
|
|
80
|
-
"bitcoinjs-lib": "^6.1.5",
|
|
81
79
|
"buffer": "^6.0.3",
|
|
82
80
|
"ts-proto": "^2.6.1"
|
|
83
81
|
},
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { TokenPubkey, TokenPubkeyAnnouncement } from "@buildonspark/lrc20-sdk";
|
|
2
1
|
import {
|
|
3
2
|
NetworkError,
|
|
4
3
|
SparkWallet,
|
|
@@ -142,7 +141,7 @@ export class IssuerSparkWallet extends SparkWallet {
|
|
|
142
141
|
});
|
|
143
142
|
if (response.tokenMetadata.length === 0) {
|
|
144
143
|
throw new ValidationError(
|
|
145
|
-
"Token metadata not found - If a token has not yet been
|
|
144
|
+
"Token metadata not found - If a token has not yet been created, please create it first. Try again in a few seconds.",
|
|
146
145
|
{
|
|
147
146
|
field: "tokenMetadata",
|
|
148
147
|
value: response.tokenMetadata,
|
|
@@ -371,72 +370,6 @@ export class IssuerSparkWallet extends SparkWallet {
|
|
|
371
370
|
throw new NotImplementedError("Token distribution is not yet supported");
|
|
372
371
|
}
|
|
373
372
|
|
|
374
|
-
/**
|
|
375
|
-
* Announces a new token on the L1 (Bitcoin) network.
|
|
376
|
-
* @param tokenName - The name of the token
|
|
377
|
-
* @param tokenTicker - The ticker symbol for the token
|
|
378
|
-
* @param decimals - The number of decimal places for the token
|
|
379
|
-
* @param maxSupply - The maximum supply of the token
|
|
380
|
-
* @param isFreezable - Whether the token can be frozen
|
|
381
|
-
* @param feeRateSatsPerVb - The fee rate in satoshis per virtual byte (default: 4.0)
|
|
382
|
-
* @returns The transaction ID of the announcement
|
|
383
|
-
* @throws {ValidationError} If decimals is not a safe integer
|
|
384
|
-
* @throws {NetworkError} If the announcement transaction cannot be broadcast
|
|
385
|
-
*/
|
|
386
|
-
public async announceTokenL1(
|
|
387
|
-
tokenName: string,
|
|
388
|
-
tokenTicker: string,
|
|
389
|
-
decimals: number,
|
|
390
|
-
maxSupply: bigint,
|
|
391
|
-
isFreezable: boolean,
|
|
392
|
-
feeRateSatsPerVb: number = 4.0,
|
|
393
|
-
): Promise<string> {
|
|
394
|
-
validateTokenParameters(tokenName, tokenTicker, decimals, maxSupply);
|
|
395
|
-
|
|
396
|
-
if (!Number.isSafeInteger(decimals)) {
|
|
397
|
-
throw new ValidationError("Decimals must be less than 2^53", {
|
|
398
|
-
field: "decimals",
|
|
399
|
-
value: decimals,
|
|
400
|
-
expected: "smaller or equal to " + Number.MAX_SAFE_INTEGER,
|
|
401
|
-
});
|
|
402
|
-
}
|
|
403
|
-
|
|
404
|
-
await this.lrc20Wallet!.syncWallet();
|
|
405
|
-
|
|
406
|
-
const tokenPublicKey = new TokenPubkey(this.lrc20Wallet!.pubkey);
|
|
407
|
-
|
|
408
|
-
const announcement = new TokenPubkeyAnnouncement(
|
|
409
|
-
tokenPublicKey,
|
|
410
|
-
tokenName,
|
|
411
|
-
tokenTicker,
|
|
412
|
-
decimals,
|
|
413
|
-
maxSupply,
|
|
414
|
-
isFreezable,
|
|
415
|
-
);
|
|
416
|
-
|
|
417
|
-
try {
|
|
418
|
-
const tx = await this.lrc20Wallet!.prepareAnnouncement(
|
|
419
|
-
announcement,
|
|
420
|
-
feeRateSatsPerVb,
|
|
421
|
-
);
|
|
422
|
-
|
|
423
|
-
const txId = await this.lrc20Wallet!.broadcastRawBtcTransaction(
|
|
424
|
-
tx.bitcoin_tx.toHex(),
|
|
425
|
-
);
|
|
426
|
-
|
|
427
|
-
return txId;
|
|
428
|
-
} catch (error) {
|
|
429
|
-
throw new NetworkError(
|
|
430
|
-
"Failed to broadcast announcement transaction on L1",
|
|
431
|
-
{
|
|
432
|
-
operation: "broadcastRawBtcTransaction",
|
|
433
|
-
errorCount: 1,
|
|
434
|
-
errors: error instanceof Error ? error.message : String(error),
|
|
435
|
-
},
|
|
436
|
-
);
|
|
437
|
-
}
|
|
438
|
-
}
|
|
439
|
-
|
|
440
373
|
protected getTraceName(methodName: string) {
|
|
441
374
|
return `IssuerSparkWallet.${methodName}`;
|
|
442
375
|
}
|
|
@@ -471,7 +404,6 @@ export class IssuerSparkWallet extends SparkWallet {
|
|
|
471
404
|
"freezeTokens",
|
|
472
405
|
"unfreezeTokens",
|
|
473
406
|
"getIssuerTokenDistribution",
|
|
474
|
-
"announceTokenL1",
|
|
475
407
|
] as const;
|
|
476
408
|
|
|
477
409
|
methods.forEach((m) =>
|
|
@@ -76,33 +76,6 @@ describe.each(TEST_CONFIGS)(
|
|
|
76
76
|
expect(metadata.decimals).toEqual(decimals);
|
|
77
77
|
});
|
|
78
78
|
|
|
79
|
-
it("should announce a token", async () => {
|
|
80
|
-
const { wallet: issuerWallet } =
|
|
81
|
-
await IssuerSparkWalletTesting.initialize({
|
|
82
|
-
options: config,
|
|
83
|
-
});
|
|
84
|
-
|
|
85
|
-
const tokenName = `${name}Announcable`;
|
|
86
|
-
const tokenTicker = "ANN";
|
|
87
|
-
const maxSupply = 5000n;
|
|
88
|
-
const decimals = 0;
|
|
89
|
-
|
|
90
|
-
await fundAndAnnounce(
|
|
91
|
-
issuerWallet,
|
|
92
|
-
5000n,
|
|
93
|
-
0,
|
|
94
|
-
tokenName,
|
|
95
|
-
tokenTicker,
|
|
96
|
-
false,
|
|
97
|
-
);
|
|
98
|
-
|
|
99
|
-
const metadata = await issuerWallet.getIssuerTokenMetadata();
|
|
100
|
-
expect(metadata.tokenName).toEqual(tokenName);
|
|
101
|
-
expect(metadata.tokenTicker).toEqual(tokenTicker);
|
|
102
|
-
expect(metadata.maxSupply).toEqual(maxSupply);
|
|
103
|
-
expect(metadata.decimals).toEqual(decimals);
|
|
104
|
-
});
|
|
105
|
-
|
|
106
79
|
it("should fail on duplicate token creation", async () => {
|
|
107
80
|
const { wallet: issuerWallet } =
|
|
108
81
|
await IssuerSparkWalletTesting.initialize({
|
|
@@ -577,15 +550,6 @@ describe.each(TEST_CONFIGS)(
|
|
|
577
550
|
});
|
|
578
551
|
});
|
|
579
552
|
|
|
580
|
-
it("should be able to anounce a token with name of size equal to MAX_SYMBOL_SIZE", async () => {
|
|
581
|
-
const { wallet: issuerWallet } =
|
|
582
|
-
await IssuerSparkWalletTesting.initialize({
|
|
583
|
-
options: config,
|
|
584
|
-
});
|
|
585
|
-
|
|
586
|
-
await fundAndAnnounce(issuerWallet, 100000n, 0, "MST", "TESTAA", false);
|
|
587
|
-
});
|
|
588
|
-
|
|
589
553
|
it("should be able to create a token with symbol of size equal to MAX_NAME_SIZE", async () => {
|
|
590
554
|
const { wallet: issuerWallet } =
|
|
591
555
|
await IssuerSparkWalletTesting.initialize({
|
|
@@ -601,22 +565,6 @@ describe.each(TEST_CONFIGS)(
|
|
|
601
565
|
});
|
|
602
566
|
});
|
|
603
567
|
|
|
604
|
-
it("should be able to announce a token with symbol of size equal to MAX_NAME_SIZE", async () => {
|
|
605
|
-
const { wallet: issuerWallet } =
|
|
606
|
-
await IssuerSparkWalletTesting.initialize({
|
|
607
|
-
options: config,
|
|
608
|
-
});
|
|
609
|
-
|
|
610
|
-
await fundAndAnnounce(
|
|
611
|
-
issuerWallet,
|
|
612
|
-
100000n,
|
|
613
|
-
0,
|
|
614
|
-
"ABCDEFGHIJKLMNOPQ",
|
|
615
|
-
"MQS",
|
|
616
|
-
false,
|
|
617
|
-
);
|
|
618
|
-
});
|
|
619
|
-
|
|
620
568
|
it("should create, mint, freeze, and unfreeze tokens", async () => {
|
|
621
569
|
const tokenAmount: bigint = 1000n;
|
|
622
570
|
const { wallet: issuerWallet } =
|
|
@@ -785,39 +733,3 @@ describe.each(TEST_CONFIGS)(
|
|
|
785
733
|
});
|
|
786
734
|
},
|
|
787
735
|
);
|
|
788
|
-
|
|
789
|
-
async function fundAndAnnounce(
|
|
790
|
-
wallet: IssuerSparkWallet,
|
|
791
|
-
maxSupply: bigint = 100000n,
|
|
792
|
-
decimals: number = 0,
|
|
793
|
-
tokenName: string = "TestToken1",
|
|
794
|
-
tokenSymbol: string = "TT1",
|
|
795
|
-
isFreezable: boolean = false,
|
|
796
|
-
) {
|
|
797
|
-
// Faucet funds to the Issuer wallet because announcing a token
|
|
798
|
-
// requires ownership of an L1 UTXO.
|
|
799
|
-
const faucet = BitcoinFaucet.getInstance();
|
|
800
|
-
const l1WalletPubKey = await wallet.getTokenL1Address();
|
|
801
|
-
await faucet.sendToAddress(l1WalletPubKey, 100_000n);
|
|
802
|
-
await faucet.mineBlocks(6);
|
|
803
|
-
|
|
804
|
-
await new Promise((resolve) => setTimeout(resolve, 3000));
|
|
805
|
-
|
|
806
|
-
try {
|
|
807
|
-
const response = await wallet.announceTokenL1(
|
|
808
|
-
tokenName,
|
|
809
|
-
tokenSymbol,
|
|
810
|
-
decimals,
|
|
811
|
-
maxSupply,
|
|
812
|
-
isFreezable,
|
|
813
|
-
);
|
|
814
|
-
console.log("Announce token response:", response);
|
|
815
|
-
} catch (error: any) {
|
|
816
|
-
console.error("Error when announcing token on L1:", error);
|
|
817
|
-
throw error;
|
|
818
|
-
}
|
|
819
|
-
await faucet.mineBlocks(2);
|
|
820
|
-
|
|
821
|
-
const SECONDS = 1000;
|
|
822
|
-
await new Promise((resolve) => setTimeout(resolve, 3 * SECONDS));
|
|
823
|
-
}
|
package/src/utils/constants.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { Network } from "@buildonspark/spark-sdk";
|
|
2
|
-
import { networks } from "bitcoinjs-lib";
|
|
3
|
-
import { NetworkType } from "@buildonspark/lrc20-sdk";
|
|
4
|
-
|
|
5
|
-
export const LRC_WALLET_NETWORK = Object.freeze({
|
|
6
|
-
[Network.MAINNET]: networks.bitcoin,
|
|
7
|
-
[Network.TESTNET]: networks.testnet,
|
|
8
|
-
[Network.SIGNET]: networks.testnet,
|
|
9
|
-
[Network.REGTEST]: networks.regtest,
|
|
10
|
-
[Network.LOCAL]: networks.regtest,
|
|
11
|
-
});
|
|
12
|
-
|
|
13
|
-
export const LRC_WALLET_NETWORK_TYPE = Object.freeze({
|
|
14
|
-
[Network.MAINNET]: NetworkType.MAINNET,
|
|
15
|
-
[Network.TESTNET]: NetworkType.TESTNET,
|
|
16
|
-
[Network.SIGNET]: NetworkType.TESTNET,
|
|
17
|
-
[Network.REGTEST]: NetworkType.REGTEST,
|
|
18
|
-
[Network.LOCAL]: NetworkType.REGTEST,
|
|
19
|
-
});
|