@buildonspark/issuer-sdk 0.0.2 → 0.0.3

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/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright 2023 Lightspark Group, Inc.
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
@@ -1,13 +1,15 @@
1
1
  import { Network } from "@buildonspark/spark-sdk/utils";
2
2
  import { IssuerSparkWallet } from "./services/spark/wallet.js";
3
+ import lrc20sdk from "@buildonspark/lrc20-sdk";
3
4
  export declare class IssuerWallet {
4
5
  private bitcoinWallet;
5
6
  private sparkWallet;
6
7
  private initialized;
8
+ private network;
7
9
  constructor(network: Network);
8
- initWalletFromMnemonic(mnemonic: string, enableL1Wallet?: boolean): Promise<void>;
10
+ initWallet(mnemonicOrSeed?: Uint8Array | string, enableL1Wallet?: boolean): Promise<void>;
9
11
  getSparkWallet(): IssuerSparkWallet;
10
- getBitcoinWallet(): any;
12
+ getBitcoinWallet(): lrc20sdk.LRCWallet;
11
13
  isSparkInitialized(): boolean;
12
14
  isL1Initialized(): boolean;
13
15
  getTokenPublicKey(): Promise<string>;
@@ -23,19 +25,15 @@ export declare class IssuerWallet {
23
25
  * Mints new tokens to the specified address
24
26
  * TODO: Add support for minting directly to recipient address.
25
27
  */
26
- mintTokens(amountToMint: bigint): Promise<void>;
28
+ mintTokens(amountToMint: bigint): Promise<string>;
27
29
  /**
28
30
  * Transfers tokens to the specified receipient.
29
31
  */
30
- transferTokens(amountToTransfer: bigint, recipientPublicKey: string): Promise<void>;
31
- /**
32
- * Consolidate all leaves into a single leaf.
33
- */
34
- consolidateTokens(): Promise<void>;
32
+ transferTokens(amountToTransfer: bigint, recipientPublicKey: string): Promise<string>;
35
33
  /**
36
34
  * Burns issuer tokens at the specified receipient.
37
35
  */
38
- burnTokens(amountToBurn: bigint): Promise<void>;
36
+ burnTokens(amountToBurn: bigint): Promise<string>;
39
37
  /**
40
38
  * Freezes tokens at the specified public key.
41
39
  */
@@ -50,4 +48,10 @@ export declare class IssuerWallet {
50
48
  impactedLeafIds: string[];
51
49
  impactedTokenAmount: bigint;
52
50
  }>;
51
+ /**
52
+ * Announces LRC20 token on L1
53
+ */
54
+ announceTokenL1(tokenName: string, tokenTicker: string, decimals: number, maxSupply: bigint, isFreezable: boolean): Promise<{
55
+ txid: string;
56
+ }>;
53
57
  }
@@ -1,27 +1,36 @@
1
+ import { bytesToHex } from "@noble/curves/abstract/utils";
1
2
  import { IssuerSparkWallet } from "./services/spark/wallet.js";
2
- // import * as bip39 from "@scure/bip39";
3
- // import { HDKey } from "@scure/bip32";
4
- // import { LRCWallet } from "lrc20-js-sdk";
5
- // import { networks } from "bitcoinjs-lib";
6
- // import { NetworkType } from "lrc20-js-sdk";
3
+ import * as bip39 from "@scure/bip39";
4
+ import { HDKey } from "@scure/bip32";
5
+ import lrc20sdk from "@buildonspark/lrc20-sdk";
6
+ import { announceTokenL1 } from "./services/lrc20/announce.js";
7
+ import { LRC_WALLET_NETWORK, LRC_WALLET_NETWORK_TYPE } from "./utils/constants.js";
7
8
  export class IssuerWallet {
8
9
  bitcoinWallet;
9
10
  sparkWallet;
10
11
  initialized = false;
12
+ network;
11
13
  constructor(network) {
12
14
  this.sparkWallet = new IssuerSparkWallet(network);
15
+ this.network = network;
13
16
  }
14
- async initWalletFromMnemonic(mnemonic,
17
+ async initWallet(mnemonicOrSeed,
15
18
  // Set to true to enable L1 Token Announcements.
16
19
  enableL1Wallet = true) {
17
- await this.sparkWallet.initWalletFromMnemonic(mnemonic);
20
+ let result = await this.sparkWallet.initWallet(mnemonicOrSeed);
18
21
  if (enableL1Wallet) {
19
- // const seed = await bip39.mnemonicToSeed(mnemonic);
20
- // const hdkey = HDKey.fromMasterSeed(seed).derive("m/0").privateKey;
21
- // this.bitcoinWallet = createLRCWallet(
22
- // bytesToHex.privateKey,
23
- // networks.regtest,
24
- // NetworkType.REGTEST);
22
+ if (!mnemonicOrSeed) {
23
+ mnemonicOrSeed = result.mnemonic;
24
+ }
25
+ let seed;
26
+ if (typeof mnemonicOrSeed === "string") {
27
+ seed = await bip39.mnemonicToSeed(mnemonicOrSeed);
28
+ }
29
+ else {
30
+ seed = mnemonicOrSeed;
31
+ }
32
+ const hdkey = HDKey.fromMasterSeed(seed).derive("m/0").privateKey;
33
+ this.bitcoinWallet = new lrc20sdk.LRCWallet(bytesToHex(hdkey), LRC_WALLET_NETWORK[this.network], LRC_WALLET_NETWORK_TYPE[this.network]);
25
34
  }
26
35
  this.initialized = true;
27
36
  }
@@ -35,7 +44,7 @@ export class IssuerWallet {
35
44
  if (!this.initialized || !this.bitcoinWallet) {
36
45
  throw new Error("Bitcoin wallet not initialized");
37
46
  }
38
- return this.sparkWallet !== undefined;
47
+ return this.bitcoinWallet;
39
48
  }
40
49
  isSparkInitialized() {
41
50
  return this.initialized;
@@ -67,7 +76,7 @@ export class IssuerWallet {
67
76
  if (!this.isSparkInitialized()) {
68
77
  throw new Error("Spark wallet not initialized");
69
78
  }
70
- await this.sparkWallet.mintIssuerTokens(amountToMint);
79
+ return await this.sparkWallet.mintIssuerTokens(amountToMint);
71
80
  }
72
81
  /**
73
82
  * Transfers tokens to the specified receipient.
@@ -76,16 +85,7 @@ export class IssuerWallet {
76
85
  if (!this.isSparkInitialized()) {
77
86
  throw new Error("Spark wallet not initialized");
78
87
  }
79
- await this.sparkWallet.transferIssuerTokens(amountToTransfer, recipientPublicKey);
80
- }
81
- /**
82
- * Consolidate all leaves into a single leaf.
83
- */
84
- async consolidateTokens() {
85
- if (!this.isSparkInitialized()) {
86
- throw new Error("Spark wallet not initialized");
87
- }
88
- await this.sparkWallet.consolidateIssuerTokenLeaves();
88
+ return await this.sparkWallet.transferIssuerTokens(amountToTransfer, recipientPublicKey);
89
89
  }
90
90
  /**
91
91
  * Burns issuer tokens at the specified receipient.
@@ -94,7 +94,7 @@ export class IssuerWallet {
94
94
  if (!this.isSparkInitialized()) {
95
95
  throw new Error("Spark wallet not initialized");
96
96
  }
97
- await this.sparkWallet.burnIssuerTokens(amountToBurn);
97
+ return await this.sparkWallet.burnIssuerTokens(amountToBurn);
98
98
  }
99
99
  /**
100
100
  * Freezes tokens at the specified public key.
@@ -114,5 +114,14 @@ export class IssuerWallet {
114
114
  }
115
115
  return await this.sparkWallet.unfreezeIssuerTokens(unfreezePublicKey);
116
116
  }
117
+ /**
118
+ * Announces LRC20 token on L1
119
+ */
120
+ async announceTokenL1(tokenName, tokenTicker, decimals, maxSupply, isFreezable) {
121
+ if (!this.isL1Initialized()) {
122
+ throw new Error("L1 wallet not initialized");
123
+ }
124
+ return await announceTokenL1(this.bitcoinWallet, tokenName, tokenTicker, decimals, maxSupply, isFreezable);
125
+ }
117
126
  }
118
127
  //# sourceMappingURL=issuer-sdk.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"issuer-sdk.js","sourceRoot":"","sources":["../src/issuer-sdk.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAC/D,yCAAyC;AACzC,wCAAwC;AACxC,4CAA4C;AAC5C,4CAA4C;AAC5C,8CAA8C;AAE9C,MAAM,OAAO,YAAY;IACf,aAAa,CAAkB;IAC/B,WAAW,CAAoB;IAC/B,WAAW,GAAY,KAAK,CAAC;IAErC,YAAY,OAAgB;QAC1B,IAAI,CAAC,WAAW,GAAG,IAAI,iBAAiB,CAAC,OAAO,CAAC,CAAC;IACpD,CAAC;IAED,KAAK,CAAC,sBAAsB,CAC1B,QAAgB;IAChB,gDAAgD;IAChD,iBAA0B,IAAI;QAE9B,MAAM,IAAI,CAAC,WAAW,CAAC,sBAAsB,CAAC,QAAQ,CAAC,CAAC;QAExD,IAAI,cAAc,EAAE,CAAC;YACnB,qDAAqD;YACrD,qEAAqE;YACrE,wCAAwC;YACxC,4BAA4B;YAC5B,uBAAuB;YACvB,2BAA2B;QAC7B,CAAC;QACD,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC;IAC1B,C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KAAK,CAAC,cAAc,CAAC,iBAAyB;QAI5C,IAAI,CAAC,IAAI,CAAC,kBAAkB,EAAE,EAAE,CAAC;YAC/B,MAAM,IAAI,KAAK,CAAC,8BAA8B,CAAC,CAAC;QAClD,CAAC;QACD,OAAO,MAAM,IAAI,CAAC,WAAW,CAAC,oBAAoB,CAAC,iBAAiB,CAAC,CAAC;IACxE,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,eAAe,CAAC,SAAiB,EAAE,WAAmB,EAAE,QAAgB,EAAE,SAAiB,EAAE,WAAoB;QACrH,IAAG,CAAC,IAAI,CAAC,eAAe,EAAE,EAAE,CAAC;YAC3B,MAAM,IAAI,KAAK,CAAC,2BAA2B,CAAC,CAAC;QAC/C,CAAC;QAED,OAAO,MAAM,eAAe,CAAC,IAAI,CAAC,aAAc,EAAE,SAAS,EAAE,WAAW,EAAE,QAAQ,EAAE,SAAS,EAAE,WAAW,CAAC,CAAA;IAC7G,CAAC;CACF"}
@@ -0,0 +1,4 @@
1
+ import lrc20sdk from "@buildonspark/lrc20-sdk";
2
+ export declare function announceTokenL1(lrcWallet: lrc20sdk.LRCWallet, tokenName: string, tokenTicker: string, decimals: number, maxSupply: bigint, isFreezable: boolean, feeRateSatsPerVb?: number): Promise<{
3
+ txid: string;
4
+ }>;
@@ -0,0 +1,10 @@
1
+ import lrc20sdk from "@buildonspark/lrc20-sdk";
2
+ export async function announceTokenL1(lrcWallet, tokenName, tokenTicker, decimals, maxSupply, isFreezable, feeRateSatsPerVb = 2.0) {
3
+ await lrcWallet.syncWallet();
4
+ const tokenPublicKey = new lrc20sdk.TokenPubkey(lrcWallet.pubkey);
5
+ const announcement = new lrc20sdk.TokenPubkeyAnnouncement(tokenPublicKey, tokenName, tokenTicker, decimals, maxSupply, isFreezable);
6
+ const tx = await lrcWallet.prepareAnnouncement(announcement, feeRateSatsPerVb);
7
+ let txid = await lrcWallet.broadcastRawBtcTransaction(tx.bitcoin_tx.toHex());
8
+ return { txid };
9
+ }
10
+ //# sourceMappingURL=announce.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"announce.js","sourceRoot":"","sources":["../../../src/services/lrc20/announce.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,MAAM,yBAAyB,CAAC;AAE/C,MAAM,CAAC,KAAK,UAAU,eAAe,CACnC,SAA6B,EAC7B,SAAiB,EACjB,WAAmB,EACnB,QAAgB,EAChB,SAAiB,EACjB,WAAoB,EACpB,mBAA2B,GAAG;IAE9B,MAAM,SAAS,CAAC,UAAU,EAAE,CAAC;IAE7B,MAAM,cAAc,GAAG,IAAI,QAAQ,CAAC,WAAW,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;IAElE,MAAM,YAAY,GAAG,IAAI,QAAQ,CAAC,uBAAuB,CACvD,cAAc,EACd,SAAS,EACT,WAAW,EACX,QAAQ,EACR,SAAS,EACT,WAAW,CACZ,CAAC;IAEF,MAAM,EAAE,GAAG,MAAM,SAAS,CAAC,mBAAmB,CAC5C,YAAY,EACZ,gBAAgB,CACjB,CAAC;IAEF,IAAI,IAAI,GAAG,MAAM,SAAS,CAAC,0BAA0B,CAAC,EAAE,CAAC,UAAU,CAAC,KAAK,EAAE,CAAC,CAAC;IAE7E,OAAO,EAAE,IAAI,EAAE,CAAA;AACjB,CAAC"}
@@ -12,8 +12,7 @@ export declare class IssuerSparkWallet extends SparkWallet {
12
12
  }>;
13
13
  mintIssuerTokens(tokenAmount: bigint): Promise<string>;
14
14
  transferIssuerTokens(tokenAmount: bigint, recipientPublicKey: string): Promise<string>;
15
- consolidateIssuerTokenLeaves(): Promise<string>;
16
- burnIssuerTokens(tokenAmount: bigint, selectedLeaves?: LeafWithPreviousTransactionData[]): Promise<void>;
15
+ burnIssuerTokens(tokenAmount: bigint, selectedLeaves?: LeafWithPreviousTransactionData[]): Promise<string>;
17
16
  freezeIssuerTokens(ownerPublicKey: string): Promise<{
18
17
  impactedLeafIds: string[];
19
18
  impactedTokenAmount: bigint;
@@ -12,12 +12,18 @@ export class IssuerSparkWallet extends SparkWallet {
12
12
  this.tokenFreezeService = new TokenFreezeService(this.config, this.connectionManager);
13
13
  }
14
14
  async getIssuerTokenBalance() {
15
- const publicKey = await this.getIdentityPublicKey();
16
- const balance = await this.getTokenBalance(publicKey);
17
- const allLeaves = await this.getAllTokenLeaves();
18
- // Get the leaves for the issuer token public key from the map
19
- const issuerTokenLeaves = allLeaves.get(publicKey) || [];
20
- return await this.getTokenBalance(publicKey);
15
+ const publicKey = await super.getIdentityPublicKey();
16
+ const balanceObj = await this.getBalance();
17
+ if (!balanceObj.tokenBalances || !balanceObj.tokenBalances.has(publicKey)) {
18
+ return {
19
+ balance: 0n,
20
+ leafCount: 0,
21
+ };
22
+ }
23
+ return {
24
+ balance: balanceObj.tokenBalances.get(publicKey).balance,
25
+ leafCount: balanceObj.tokenBalances.get(publicKey).leafCount,
26
+ };
21
27
  }
22
28
  async mintIssuerTokens(tokenAmount) {
23
29
  var tokenPublicKey = await super.getIdentityPublicKey();
@@ -28,12 +34,8 @@ export class IssuerSparkWallet extends SparkWallet {
28
34
  const tokenPublicKey = await super.getIdentityPublicKey();
29
35
  return await super.transferTokens(tokenPublicKey, tokenAmount, recipientPublicKey);
30
36
  }
31
- async consolidateIssuerTokenLeaves() {
32
- const tokenPublicKey = await super.getIdentityPublicKey();
33
- return await super.consolidateTokenLeaves(tokenPublicKey);
34
- }
35
37
  async burnIssuerTokens(tokenAmount, selectedLeaves) {
36
- await this.transferTokens(await this.getIdentityPublicKey(), tokenAmount, BURN_ADDRESS, selectedLeaves);
38
+ return await this.transferTokens(await super.getIdentityPublicKey(), tokenAmount, BURN_ADDRESS, selectedLeaves);
37
39
  }
38
40
  async freezeIssuerTokens(ownerPublicKey) {
39
41
  await this.syncTokenLeaves();
@@ -1 +1 @@
1
- {"version":3,"file":"wallet.js","sourceRoot":"","sources":["../../../src/services/spark/wallet.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,8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;QAE1D,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,kBAAmB,CAAC,YAAY,CAC1D,UAAU,CAAC,cAAc,CAAC,EAC1B,UAAU,CAAC,cAAc,CAAC,CAC3B,CAAC;QAEF,qCAAqC;QACrC,MAAM,WAAW,GAAG,eAAe,CAAC,QAAQ,CAAC,mBAAmB,CAAC,CAAC;QAElE,OAAO;YACL,eAAe,EAAE,QAAQ,CAAC,eAAe;YACzC,mBAAmB,EAAE,WAAW;SACjC,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,oBAAoB,CACxB,cAAsB;QAEtB,MAAM,IAAI,CAAC,eAAe,EAAE,CAAC;QAC7B,MAAM,cAAc,GAAG,MAAM,KAAK,CAAC,oBAAoB,EAAE,CAAC;QAE1D,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,kBAAmB,CAAC,cAAc,CAC5D,UAAU,CAAC,cAAc,CAAC,EAC1B,UAAU,CAAC,cAAc,CAAC,CAC3B,CAAC;QACF,MAAM,WAAW,GAAG,eAAe,CAAC,QAAQ,CAAC,mBAAmB,CAAC,CAAC;QAElE,OAAO;YACL,eAAe,EAAE,QAAQ,CAAC,eAAe;YACzC,mBAAmB,EAAE,WAAW;SACjC,CAAC;IACJ,CAAC;CACF"}
@@ -13,65 +13,47 @@ describe("token integration test", () => {
13
13
  const tokenAmount = 1000n;
14
14
  const wallet = new IssuerSparkWallet(Network.LOCAL);
15
15
  const mnemonic = generateMnemonic(wordlist);
16
- await wallet.initWalletFromMnemonic(mnemonic);
16
+ await wallet.initWallet(mnemonic);
17
17
  await wallet.mintIssuerTokens(tokenAmount);
18
- const tokenBalance = await wallet.getTokenBalance(await wallet.getIdentityPublicKey());
18
+ const tokenBalance = await wallet.getIssuerTokenBalance();
19
19
  expect(tokenBalance.balance).toEqual(tokenAmount);
20
20
  });
21
21
  it("should issue a single token and transfer it", async () => {
22
22
  const tokenAmount = 1000n;
23
23
  const issuerWallet = new IssuerSparkWallet(Network.LOCAL);
24
24
  const mnemonic = generateMnemonic(wordlist);
25
- await issuerWallet.initWalletFromMnemonic(mnemonic);
25
+ await issuerWallet.initWallet(mnemonic);
26
26
  const destinationWallet = new SparkWallet(Network.LOCAL);
27
27
  const destinationMnemonic = generateMnemonic(wordlist);
28
- await destinationWallet.initWalletFromMnemonic(destinationMnemonic);
28
+ await destinationWallet.initWallet(destinationMnemonic);
29
29
  await issuerWallet.mintIssuerTokens(tokenAmount);
30
30
  await issuerWallet.transferIssuerTokens(tokenAmount, await destinationWallet.getIdentityPublicKey());
31
31
  await new Promise((resolve) => setTimeout(resolve, 3000));
32
- const sourceBalance = await issuerWallet.getTokenBalance(await issuerWallet.getIdentityPublicKey());
32
+ const sourceBalance = await issuerWallet.getIssuerTokenBalance();
33
33
  expect(sourceBalance.balance).toEqual(0n);
34
34
  const tokenPublicKey = await issuerWallet.getIdentityPublicKey();
35
- const destinationBalance = await destinationWallet.getTokenBalance(tokenPublicKey);
35
+ const destinationBalance = await getSparkWalletTokenBalanceOrZero(destinationWallet, tokenPublicKey);
36
36
  expect(destinationBalance.balance).toEqual(tokenAmount);
37
37
  });
38
- it("should consolidate three token leaves", async () => {
39
- const tokenAmount = 1000n;
40
- const wallet = new IssuerSparkWallet(Network.LOCAL);
41
- const mnemonic = generateMnemonic(wordlist);
42
- await wallet.initWalletFromMnemonic(mnemonic);
43
- await wallet.mintIssuerTokens(tokenAmount);
44
- await wallet.mintIssuerTokens(tokenAmount);
45
- await wallet.mintIssuerTokens(tokenAmount);
46
- const identityPublicKey = await wallet.getIdentityPublicKey();
47
- const balanceBeforeConsolidation = await wallet.getTokenBalance(await wallet.getIdentityPublicKey());
48
- const leavesBeforeConsolidation = await wallet.getAllTokenLeaves();
49
- expect(balanceBeforeConsolidation.balance).toEqual(tokenAmount * 3n);
50
- expect(leavesBeforeConsolidation.get(identityPublicKey)?.length || 0).toEqual(3);
51
- await wallet.consolidateIssuerTokenLeaves();
52
- const balanceAfterConsolidation = await wallet.getTokenBalance(await wallet.getIdentityPublicKey());
53
- const leavesAfterConsolidation = await wallet.getAllTokenLeaves();
54
- expect(balanceAfterConsolidation.balance).toEqual(tokenAmount * 3n);
55
- expect(leavesAfterConsolidation.get(identityPublicKey)?.length || 0).toEqual(1);
56
- });
57
38
  it("should freeze tokens", async () => {
58
39
  const tokenAmount = 1000n;
59
40
  const issuerWallet = new IssuerSparkWallet(Network.LOCAL);
60
41
  const issuerMnemonic = generateMnemonic(wordlist);
61
- await issuerWallet.initWalletFromMnemonic(issuerMnemonic);
42
+ await issuerWallet.initWallet(issuerMnemonic);
62
43
  await issuerWallet.mintIssuerTokens(tokenAmount);
63
44
  // Check issuer balance after minting
64
- const issuerBalanceAfterMint = await issuerWallet.getTokenBalance(await issuerWallet.getIdentityPublicKey());
45
+ const issuerBalanceAfterMint = await issuerWallet.getIssuerTokenBalance();
65
46
  expect(issuerBalanceAfterMint.balance).toEqual(tokenAmount);
66
- const userWallet = new IssuerSparkWallet(Network.LOCAL);
47
+ const userWallet = new SparkWallet(Network.LOCAL);
67
48
  const userMnemonic = generateMnemonic(wordlist);
68
- await userWallet.initWalletFromMnemonic(userMnemonic);
49
+ await userWallet.initWallet(userMnemonic);
69
50
  const userWalletPublicKey = await userWallet.getIdentityPublicKey();
70
51
  await issuerWallet.transferIssuerTokens(tokenAmount, userWalletPublicKey);
71
- const issuerBalanceAfterTransfer = await issuerWallet.getTokenBalance(await issuerWallet.getIdentityPublicKey());
52
+ const issuerBalanceAfterTransfer = await issuerWallet.getIssuerTokenBalance();
72
53
  expect(issuerBalanceAfterTransfer.balance).toEqual(0n);
73
54
  const tokenPublicKey = await issuerWallet.getIdentityPublicKey();
74
- const userBalanceAfterTransfer = await userWallet.getTokenBalance(tokenPublicKey);
55
+ const userBalanceAfterTransfer = (await userWallet.getBalance())
56
+ .tokenBalances[tokenPublicKey];
75
57
  expect(userBalanceAfterTransfer.balance).toEqual(tokenAmount);
76
58
  const freezeResult = await issuerWallet.freezeIssuerTokens(userWalletPublicKey);
77
59
  expect(freezeResult.impactedLeafIds.length).toBe(1);
@@ -84,40 +66,53 @@ describe("token integration test", () => {
84
66
  const tokenAmount = 200n;
85
67
  const issuerWallet = new IssuerSparkWallet(Network.LOCAL);
86
68
  const issuerMnemonic = generateMnemonic(wordlist);
87
- await issuerWallet.initWalletFromMnemonic(issuerMnemonic);
69
+ await issuerWallet.initWallet(issuerMnemonic);
88
70
  await issuerWallet.mintIssuerTokens(tokenAmount);
89
- const issuerTokenBalance = await issuerWallet.getTokenBalance(await issuerWallet.getIdentityPublicKey());
71
+ const issuerTokenBalance = await issuerWallet.getIssuerTokenBalance();
90
72
  expect(issuerTokenBalance.balance).toEqual(tokenAmount);
91
73
  await issuerWallet.burnIssuerTokens(tokenAmount);
92
- const issuerTokenBalanceAfterBurn = await issuerWallet.getTokenBalance(await issuerWallet.getIdentityPublicKey());
74
+ const issuerTokenBalanceAfterBurn = await issuerWallet.getIssuerTokenBalance();
93
75
  expect(issuerTokenBalanceAfterBurn.balance).toEqual(0n);
94
76
  });
95
77
  it("mint, transfer to user, user transfer to issuer, burn", async () => {
96
78
  const tokenAmount = 1000n;
97
79
  const issuerWallet = new IssuerSparkWallet(Network.LOCAL);
98
80
  const issuerMnemonic = generateMnemonic(wordlist);
99
- await issuerWallet.initWalletFromMnemonic(issuerMnemonic);
81
+ await issuerWallet.initWallet(issuerMnemonic);
100
82
  const userWallet = new SparkWallet(Network.LOCAL);
101
83
  const userMnemonic = generateMnemonic(wordlist);
102
- await userWallet.initWalletFromMnemonic(userMnemonic);
84
+ await userWallet.initWallet(userMnemonic);
103
85
  await issuerWallet.mintIssuerTokens(tokenAmount);
104
- const issuerBalanceAfterMint = await issuerWallet.getTokenBalance(await issuerWallet.getIdentityPublicKey());
86
+ const issuerBalanceAfterMint = await issuerWallet.getIssuerTokenBalance();
105
87
  expect(issuerBalanceAfterMint.balance).toEqual(tokenAmount);
106
88
  const userWalletPublicKey = await userWallet.getIdentityPublicKey();
107
89
  await issuerWallet.transferIssuerTokens(tokenAmount, userWalletPublicKey);
108
- const issuerBalanceAfterTransfer = await issuerWallet.getTokenBalance(await issuerWallet.getIdentityPublicKey());
90
+ const issuerBalanceAfterTransfer = await issuerWallet.getIssuerTokenBalance();
109
91
  expect(issuerBalanceAfterTransfer.balance).toEqual(0n);
110
92
  const tokenPublicKeyHex = await issuerWallet.getIdentityPublicKey();
111
- const userBalanceAfterTransfer = await userWallet.getTokenBalance(tokenPublicKeyHex);
93
+ const userBalanceAfterTransfer = await getSparkWalletTokenBalanceOrZero(userWallet, tokenPublicKeyHex);
112
94
  expect(userBalanceAfterTransfer.balance).toEqual(tokenAmount);
113
95
  await userWallet.transferTokens(tokenPublicKeyHex, tokenAmount, tokenPublicKeyHex);
114
- const userBalanceAfterTransferBack = await userWallet.getTokenBalance(tokenPublicKeyHex);
96
+ const userBalanceAfterTransferBack = await getSparkWalletTokenBalanceOrZero(userWallet, tokenPublicKeyHex);
115
97
  expect(userBalanceAfterTransferBack.balance).toEqual(0n);
116
- const issuerTokenBalance = await issuerWallet.getTokenBalance(tokenPublicKeyHex);
98
+ const issuerTokenBalance = await issuerWallet.getIssuerTokenBalance();
117
99
  expect(issuerTokenBalance.balance).toEqual(tokenAmount);
118
100
  await issuerWallet.burnIssuerTokens(tokenAmount);
119
- const issuerTokenBalanceAfterBurn = await issuerWallet.getTokenBalance(tokenPublicKeyHex);
101
+ const issuerTokenBalanceAfterBurn = await issuerWallet.getIssuerTokenBalance();
120
102
  expect(issuerTokenBalanceAfterBurn.balance).toEqual(0n);
121
103
  });
122
104
  });
105
+ async function getSparkWalletTokenBalanceOrZero(sparkWallet, publicKey) {
106
+ const balanceObj = await sparkWallet.getBalance();
107
+ if (!balanceObj.tokenBalances || !balanceObj.tokenBalances.has(publicKey)) {
108
+ return {
109
+ balance: 0n,
110
+ leafCount: 0,
111
+ };
112
+ }
113
+ return {
114
+ balance: balanceObj.tokenBalance,
115
+ leafCount: balanceObj.leafCount,
116
+ };
117
+ }
123
118
  //# source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AC,UAAU,EAAE,CAAC;IAClD,IAAI,CAAC,UAAU,CAAC,aAAa,IAAI,CAAC,UAAU,CAAC,aAAa,CAAC,GAAG,CAAC,SAAS,CAAC,EAAE,CAAC;QAC1E,OAAO;YACL,OAAO,EAAE,EAAE;YACX,SAAS,EAAE,CAAC;SACb,CAAC;IACJ,CAAC;IACD,OAAO;QACL,OAAO,EAAE,UAAU,CAAC,YAAY;QAChC,SAAS,EAAE,UAAU,CAAC,SAAS;KAChC,CAAC;AACJ,CAAC"}
@@ -0,0 +1,16 @@
1
+ import { networks } from "bitcoinjs-lib";
2
+ import lrc20sdk from "@buildonspark/lrc20-sdk";
3
+ export declare const LRC_WALLET_NETWORK: Readonly<{
4
+ 0: networks.Network;
5
+ 1: networks.Network;
6
+ 2: networks.Network;
7
+ 3: networks.Network;
8
+ 4: networks.Network;
9
+ }>;
10
+ export declare const LRC_WALLET_NETWORK_TYPE: Readonly<{
11
+ 0: lrc20sdk.NetworkType.MAINNET;
12
+ 1: lrc20sdk.NetworkType.TESTNET;
13
+ 2: lrc20sdk.NetworkType.TESTNET;
14
+ 3: lrc20sdk.NetworkType.LS_REGTEST;
15
+ 4: lrc20sdk.NetworkType.REGTEST;
16
+ }>;
@@ -0,0 +1,18 @@
1
+ import { Network } from "@buildonspark/spark-sdk/utils";
2
+ import { networks } from "bitcoinjs-lib";
3
+ import lrc20sdk from "@buildonspark/lrc20-sdk";
4
+ export const LRC_WALLET_NETWORK = Object.freeze({
5
+ [Network.MAINNET]: networks.bitcoin,
6
+ [Network.TESTNET]: networks.testnet,
7
+ [Network.SIGNET]: networks.testnet,
8
+ [Network.REGTEST]: networks.regtest,
9
+ [Network.LOCAL]: networks.regtest,
10
+ });
11
+ export const LRC_WALLET_NETWORK_TYPE = Object.freeze({
12
+ [Network.MAINNET]: lrc20sdk.NetworkType.MAINNET,
13
+ [Network.TESTNET]: lrc20sdk.NetworkType.TESTNET,
14
+ [Network.SIGNET]: lrc20sdk.NetworkType.TESTNET,
15
+ [Network.REGTEST]: lrc20sdk.NetworkType.LS_REGTEST,
16
+ [Network.LOCAL]: lrc20sdk.NetworkType.REGTEST,
17
+ });
18
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/utils/constants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,EAAC,MAAM,+BAA+B,CAAC;AACtD,OAAO,EAAC,QAAQ,EAAC,MAAM,eAAe,CAAC;AACvC,OAAO,QAAQ,MAAM,yBAAyB,CAAC;AAE/C,MAAM,CAAC,MAAM,kBAAkB,GAAG,MAAM,CAAC,MAAM,CAAC;IAC9C,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,QAAQ,CAAC,OAAO;IACnC,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,QAAQ,CAAC,OAAO;IACnC,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,QAAQ,CAAC,OAAO;IAClC,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,QAAQ,CAAC,OAAO;IACnC,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,QAAQ,CAAC,OAAO;CAClC,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,uBAAuB,GAAG,MAAM,CAAC,MAAM,CAAC;IACnD,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,QAAQ,CAAC,WAAW,CAAC,OAAO;IAC/C,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,QAAQ,CAAC,WAAW,CAAC,OAAO;IAC/C,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,QAAQ,CAAC,WAAW,CAAC,OAAO;IAC9C,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,QAAQ,CAAC,WAAW,CAAC,UAAU;IAClD,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,QAAQ,CAAC,WAAW,CAAC,OAAO;CAC9C,CAAC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@buildonspark/issuer-sdk",
3
- "version": "0.0.2",
3
+ "version": "0.0.3",
4
4
  "description": "Spark Issuer SDK for token issuance",
5
5
  "module": "./dist/issuer-sdk.js",
6
6
  "types": "./dist/issuer-sdk.d.ts",
@@ -42,8 +42,8 @@
42
42
  },
43
43
  "dependencies": {
44
44
  "@bufbuild/protobuf": "^2.2.3",
45
- "@buildonspark/lrc20-sdk": "0.0.0",
46
- "@buildonspark/spark-sdk": "0.0.2",
45
+ "@buildonspark/lrc20-sdk": "0.0.1",
46
+ "@buildonspark/spark-sdk": "0.0.3",
47
47
  "@grpc/grpc-js": "^1.12.5",
48
48
  "@noble/curves": "^1.8.0",
49
49
  "@noble/secp256k1": "^2.2.3",