@buildonspark/issuer-sdk 0.0.53 → 0.0.55
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +43 -0
- package/dist/index.d.cts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +43 -0
- package/package.json +6 -5
- package/src/issuer-spark-wallet.ts +46 -0
- package/src/tests/integration/spark.test.ts +126 -0
package/dist/index.cjs
CHANGED
|
@@ -36,6 +36,7 @@ if (typeof global === "undefined") {
|
|
|
36
36
|
// src/issuer-spark-wallet.ts
|
|
37
37
|
var import_lrc20_sdk2 = require("@buildonspark/lrc20-sdk");
|
|
38
38
|
var import_spark_sdk3 = require("@buildonspark/spark-sdk");
|
|
39
|
+
var import_core = require("@lightsparkdev/core");
|
|
39
40
|
var import_address = require("@buildonspark/spark-sdk/address");
|
|
40
41
|
var import_utils6 = require("@noble/curves/abstract/utils");
|
|
41
42
|
|
|
@@ -356,11 +357,53 @@ var IssuerSparkWallet = class _IssuerSparkWallet extends import_spark_sdk3.Spark
|
|
|
356
357
|
options.mnemonicOrSeed,
|
|
357
358
|
options.accountNumber
|
|
358
359
|
);
|
|
360
|
+
if (import_core.isNode) {
|
|
361
|
+
await wallet.initializeTracer("issuer-sdk");
|
|
362
|
+
wallet.wrapIssuerSparkWalletWithTracing();
|
|
363
|
+
}
|
|
359
364
|
return {
|
|
360
365
|
wallet,
|
|
361
366
|
...initResponse
|
|
362
367
|
};
|
|
363
368
|
}
|
|
369
|
+
wrapIssuerSparkWalletWithTracing() {
|
|
370
|
+
this.getIssuerTokenBalance = this.wrapWithOtelSpan(
|
|
371
|
+
"SparkIssuerWallet.getIssuerTokenBalance",
|
|
372
|
+
this.getIssuerTokenBalance.bind(this)
|
|
373
|
+
);
|
|
374
|
+
this.getIssuerTokenInfo = this.wrapWithOtelSpan(
|
|
375
|
+
"SparkIssuerWallet.getIssuerTokenInfo",
|
|
376
|
+
this.getIssuerTokenInfo.bind(this)
|
|
377
|
+
);
|
|
378
|
+
this.mintTokens = this.wrapWithOtelSpan(
|
|
379
|
+
"SparkIssuerWallet.mintTokens",
|
|
380
|
+
this.mintTokens.bind(this)
|
|
381
|
+
);
|
|
382
|
+
this.burnTokens = this.wrapWithOtelSpan(
|
|
383
|
+
"SparkIssuerWallet.burnTokens",
|
|
384
|
+
this.burnTokens.bind(this)
|
|
385
|
+
);
|
|
386
|
+
this.freezeTokens = this.wrapWithOtelSpan(
|
|
387
|
+
"SparkIssuerWallet.freezeTokens",
|
|
388
|
+
this.freezeTokens.bind(this)
|
|
389
|
+
);
|
|
390
|
+
this.unfreezeTokens = this.wrapWithOtelSpan(
|
|
391
|
+
"SparkIssuerWallet.unfreezeTokens",
|
|
392
|
+
this.unfreezeTokens.bind(this)
|
|
393
|
+
);
|
|
394
|
+
this.getIssuerTokenActivity = this.wrapWithOtelSpan(
|
|
395
|
+
"SparkIssuerWallet.getIssuerTokenActivity",
|
|
396
|
+
this.getIssuerTokenActivity.bind(this)
|
|
397
|
+
);
|
|
398
|
+
this.getIssuerTokenDistribution = this.wrapWithOtelSpan(
|
|
399
|
+
"SparkIssuerWallet.getIssuerTokenDistribution",
|
|
400
|
+
this.getIssuerTokenDistribution.bind(this)
|
|
401
|
+
);
|
|
402
|
+
this.announceTokenL1 = this.wrapWithOtelSpan(
|
|
403
|
+
"SparkIssuerWallet.announceTokenL1",
|
|
404
|
+
this.announceTokenL1.bind(this)
|
|
405
|
+
);
|
|
406
|
+
}
|
|
364
407
|
constructor(configOptions) {
|
|
365
408
|
super(configOptions);
|
|
366
409
|
this.issuerTokenTransactionService = new IssuerTokenTransactionService(
|
package/dist/index.d.cts
CHANGED
|
@@ -29,6 +29,7 @@ declare class IssuerSparkWallet extends SparkWallet {
|
|
|
29
29
|
mnemonic?: string | undefined;
|
|
30
30
|
wallet: IssuerSparkWallet;
|
|
31
31
|
}>;
|
|
32
|
+
private wrapIssuerSparkWalletWithTracing;
|
|
32
33
|
protected constructor(configOptions?: ConfigOptions);
|
|
33
34
|
/**
|
|
34
35
|
* Gets the token balance for the issuer's token.
|
package/dist/index.d.ts
CHANGED
|
@@ -29,6 +29,7 @@ declare class IssuerSparkWallet extends SparkWallet {
|
|
|
29
29
|
mnemonic?: string | undefined;
|
|
30
30
|
wallet: IssuerSparkWallet;
|
|
31
31
|
}>;
|
|
32
|
+
private wrapIssuerSparkWalletWithTracing;
|
|
32
33
|
protected constructor(configOptions?: ConfigOptions);
|
|
33
34
|
/**
|
|
34
35
|
* Gets the token balance for the issuer's token.
|
package/dist/index.js
CHANGED
|
@@ -7,6 +7,7 @@ import {
|
|
|
7
7
|
SparkWallet,
|
|
8
8
|
ValidationError as ValidationError2
|
|
9
9
|
} from "@buildonspark/spark-sdk";
|
|
10
|
+
import { isNode } from "@lightsparkdev/core";
|
|
10
11
|
import {
|
|
11
12
|
decodeSparkAddress,
|
|
12
13
|
encodeSparkAddress
|
|
@@ -334,11 +335,53 @@ var IssuerSparkWallet = class _IssuerSparkWallet extends SparkWallet {
|
|
|
334
335
|
options.mnemonicOrSeed,
|
|
335
336
|
options.accountNumber
|
|
336
337
|
);
|
|
338
|
+
if (isNode) {
|
|
339
|
+
await wallet.initializeTracer("issuer-sdk");
|
|
340
|
+
wallet.wrapIssuerSparkWalletWithTracing();
|
|
341
|
+
}
|
|
337
342
|
return {
|
|
338
343
|
wallet,
|
|
339
344
|
...initResponse
|
|
340
345
|
};
|
|
341
346
|
}
|
|
347
|
+
wrapIssuerSparkWalletWithTracing() {
|
|
348
|
+
this.getIssuerTokenBalance = this.wrapWithOtelSpan(
|
|
349
|
+
"SparkIssuerWallet.getIssuerTokenBalance",
|
|
350
|
+
this.getIssuerTokenBalance.bind(this)
|
|
351
|
+
);
|
|
352
|
+
this.getIssuerTokenInfo = this.wrapWithOtelSpan(
|
|
353
|
+
"SparkIssuerWallet.getIssuerTokenInfo",
|
|
354
|
+
this.getIssuerTokenInfo.bind(this)
|
|
355
|
+
);
|
|
356
|
+
this.mintTokens = this.wrapWithOtelSpan(
|
|
357
|
+
"SparkIssuerWallet.mintTokens",
|
|
358
|
+
this.mintTokens.bind(this)
|
|
359
|
+
);
|
|
360
|
+
this.burnTokens = this.wrapWithOtelSpan(
|
|
361
|
+
"SparkIssuerWallet.burnTokens",
|
|
362
|
+
this.burnTokens.bind(this)
|
|
363
|
+
);
|
|
364
|
+
this.freezeTokens = this.wrapWithOtelSpan(
|
|
365
|
+
"SparkIssuerWallet.freezeTokens",
|
|
366
|
+
this.freezeTokens.bind(this)
|
|
367
|
+
);
|
|
368
|
+
this.unfreezeTokens = this.wrapWithOtelSpan(
|
|
369
|
+
"SparkIssuerWallet.unfreezeTokens",
|
|
370
|
+
this.unfreezeTokens.bind(this)
|
|
371
|
+
);
|
|
372
|
+
this.getIssuerTokenActivity = this.wrapWithOtelSpan(
|
|
373
|
+
"SparkIssuerWallet.getIssuerTokenActivity",
|
|
374
|
+
this.getIssuerTokenActivity.bind(this)
|
|
375
|
+
);
|
|
376
|
+
this.getIssuerTokenDistribution = this.wrapWithOtelSpan(
|
|
377
|
+
"SparkIssuerWallet.getIssuerTokenDistribution",
|
|
378
|
+
this.getIssuerTokenDistribution.bind(this)
|
|
379
|
+
);
|
|
380
|
+
this.announceTokenL1 = this.wrapWithOtelSpan(
|
|
381
|
+
"SparkIssuerWallet.announceTokenL1",
|
|
382
|
+
this.announceTokenL1.bind(this)
|
|
383
|
+
);
|
|
384
|
+
}
|
|
342
385
|
constructor(configOptions) {
|
|
343
386
|
super(configOptions);
|
|
344
387
|
this.issuerTokenTransactionService = new IssuerTokenTransactionService(
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@buildonspark/issuer-sdk",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.55",
|
|
4
4
|
"description": "Spark Issuer SDK for token issuance",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"module": "./dist/index.js",
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"build:watch": "yarn build --watch --clean=false",
|
|
35
35
|
"clean": "rm -rf dist",
|
|
36
36
|
"circular-deps": "madge --circular --extensions ts,tsx src",
|
|
37
|
-
"depcheck": "depcheck --ignores=buffer,ts-proto,jest,ts-jest",
|
|
37
|
+
"depcheck": "depcheck --ignores=buffer,ts-proto,jest,ts-jest,publint",
|
|
38
38
|
"dev": "yarn build -- --watch",
|
|
39
39
|
"docs": "typedoc src",
|
|
40
40
|
"format:fix": "prettier src --write",
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
"lint:fix:continue": "eslint --fix . || exit 0",
|
|
44
44
|
"lint:watch": "esw ./src -w --ext .ts,.tsx,.js --color",
|
|
45
45
|
"lint": "eslint .",
|
|
46
|
-
"package:checks": "yarn depcheck && yarn
|
|
46
|
+
"package:checks": "yarn depcheck && yarn attw --pack . && echo \"\nPackage checks passed successfully!\"",
|
|
47
47
|
"postversion": "yarn build",
|
|
48
48
|
"test-cmd": "node --experimental-vm-modules $(yarn bin jest) --no-cache --runInBand",
|
|
49
49
|
"test": "echo \"Error: no tests yet\"",
|
|
@@ -55,8 +55,9 @@
|
|
|
55
55
|
},
|
|
56
56
|
"dependencies": {
|
|
57
57
|
"@bufbuild/protobuf": "^2.2.5",
|
|
58
|
-
"@buildonspark/lrc20-sdk": "0.0.
|
|
59
|
-
"@buildonspark/spark-sdk": "0.1.
|
|
58
|
+
"@buildonspark/lrc20-sdk": "0.0.49",
|
|
59
|
+
"@buildonspark/spark-sdk": "0.1.24",
|
|
60
|
+
"@lightsparkdev/core": "^1.4.0",
|
|
60
61
|
"@noble/curves": "^1.8.0",
|
|
61
62
|
"@scure/btc-signer": "^1.5.0",
|
|
62
63
|
"bitcoinjs-lib": "^6.1.5",
|
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
SparkWalletProps,
|
|
10
10
|
ValidationError,
|
|
11
11
|
} from "@buildonspark/spark-sdk";
|
|
12
|
+
import { isNode } from "@lightsparkdev/core";
|
|
12
13
|
import {
|
|
13
14
|
decodeSparkAddress,
|
|
14
15
|
encodeSparkAddress,
|
|
@@ -58,12 +59,57 @@ export class IssuerSparkWallet extends SparkWallet {
|
|
|
58
59
|
options.mnemonicOrSeed,
|
|
59
60
|
options.accountNumber,
|
|
60
61
|
);
|
|
62
|
+
|
|
63
|
+
if (isNode) {
|
|
64
|
+
await wallet.initializeTracer("issuer-sdk");
|
|
65
|
+
wallet.wrapIssuerSparkWalletWithTracing();
|
|
66
|
+
}
|
|
67
|
+
|
|
61
68
|
return {
|
|
62
69
|
wallet,
|
|
63
70
|
...initResponse,
|
|
64
71
|
};
|
|
65
72
|
}
|
|
66
73
|
|
|
74
|
+
private wrapIssuerSparkWalletWithTracing() {
|
|
75
|
+
this.getIssuerTokenBalance = this.wrapWithOtelSpan(
|
|
76
|
+
"SparkIssuerWallet.getIssuerTokenBalance",
|
|
77
|
+
this.getIssuerTokenBalance.bind(this),
|
|
78
|
+
);
|
|
79
|
+
this.getIssuerTokenInfo = this.wrapWithOtelSpan(
|
|
80
|
+
"SparkIssuerWallet.getIssuerTokenInfo",
|
|
81
|
+
this.getIssuerTokenInfo.bind(this),
|
|
82
|
+
);
|
|
83
|
+
this.mintTokens = this.wrapWithOtelSpan(
|
|
84
|
+
"SparkIssuerWallet.mintTokens",
|
|
85
|
+
this.mintTokens.bind(this),
|
|
86
|
+
);
|
|
87
|
+
this.burnTokens = this.wrapWithOtelSpan(
|
|
88
|
+
"SparkIssuerWallet.burnTokens",
|
|
89
|
+
this.burnTokens.bind(this),
|
|
90
|
+
);
|
|
91
|
+
this.freezeTokens = this.wrapWithOtelSpan(
|
|
92
|
+
"SparkIssuerWallet.freezeTokens",
|
|
93
|
+
this.freezeTokens.bind(this),
|
|
94
|
+
);
|
|
95
|
+
this.unfreezeTokens = this.wrapWithOtelSpan(
|
|
96
|
+
"SparkIssuerWallet.unfreezeTokens",
|
|
97
|
+
this.unfreezeTokens.bind(this),
|
|
98
|
+
);
|
|
99
|
+
this.getIssuerTokenActivity = this.wrapWithOtelSpan(
|
|
100
|
+
"SparkIssuerWallet.getIssuerTokenActivity",
|
|
101
|
+
this.getIssuerTokenActivity.bind(this),
|
|
102
|
+
);
|
|
103
|
+
this.getIssuerTokenDistribution = this.wrapWithOtelSpan(
|
|
104
|
+
"SparkIssuerWallet.getIssuerTokenDistribution",
|
|
105
|
+
this.getIssuerTokenDistribution.bind(this),
|
|
106
|
+
);
|
|
107
|
+
this.announceTokenL1 = this.wrapWithOtelSpan(
|
|
108
|
+
"SparkIssuerWallet.announceTokenL1",
|
|
109
|
+
this.announceTokenL1.bind(this),
|
|
110
|
+
);
|
|
111
|
+
}
|
|
112
|
+
|
|
67
113
|
protected constructor(configOptions?: ConfigOptions) {
|
|
68
114
|
super(configOptions);
|
|
69
115
|
this.issuerTokenTransactionService = new IssuerTokenTransactionService(
|
|
@@ -113,6 +113,132 @@ describe("token integration tests", () => {
|
|
|
113
113
|
expect(destinationBalance.balance).toEqual(tokenAmount);
|
|
114
114
|
});
|
|
115
115
|
|
|
116
|
+
it("should announce, mint, and batchtransfer tokens with ECDSA", async () => {
|
|
117
|
+
const tokenAmount: bigint = 999n;
|
|
118
|
+
|
|
119
|
+
const { wallet: issuerWallet } = await IssuerSparkWalletTesting.initialize({
|
|
120
|
+
options: LOCAL_WALLET_CONFIG_ECDSA,
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
const { wallet: destinationWallet } = await SparkWalletTesting.initialize({
|
|
124
|
+
options: LOCAL_WALLET_CONFIG_ECDSA,
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
const { wallet: destinationWallet2 } = await SparkWalletTesting.initialize({
|
|
128
|
+
options: LOCAL_WALLET_CONFIG_ECDSA,
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
const { wallet: destinationWallet3 } = await SparkWalletTesting.initialize({
|
|
132
|
+
options: LOCAL_WALLET_CONFIG_ECDSA,
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
await fundAndAnnounce(issuerWallet, 100000n, 0, "ECDSATransfer", "ETT");
|
|
136
|
+
|
|
137
|
+
await issuerWallet.mintTokens(tokenAmount);
|
|
138
|
+
await issuerWallet.batchTransferTokens([
|
|
139
|
+
{
|
|
140
|
+
tokenAmount: tokenAmount / 3n,
|
|
141
|
+
tokenPublicKey: await issuerWallet.getIdentityPublicKey(),
|
|
142
|
+
receiverSparkAddress: await destinationWallet.getSparkAddress(),
|
|
143
|
+
},
|
|
144
|
+
{
|
|
145
|
+
tokenAmount: tokenAmount / 3n,
|
|
146
|
+
tokenPublicKey: await issuerWallet.getIdentityPublicKey(),
|
|
147
|
+
receiverSparkAddress: await destinationWallet2.getSparkAddress(),
|
|
148
|
+
},
|
|
149
|
+
{
|
|
150
|
+
tokenAmount: tokenAmount / 3n,
|
|
151
|
+
tokenPublicKey: await issuerWallet.getIdentityPublicKey(),
|
|
152
|
+
receiverSparkAddress: await destinationWallet3.getSparkAddress(),
|
|
153
|
+
},
|
|
154
|
+
]);
|
|
155
|
+
const sourceBalance = (await issuerWallet.getIssuerTokenBalance()).balance;
|
|
156
|
+
expect(sourceBalance).toEqual(0n);
|
|
157
|
+
|
|
158
|
+
const tokenPublicKey = await issuerWallet.getIdentityPublicKey();
|
|
159
|
+
const balanceObj = await destinationWallet.getBalance();
|
|
160
|
+
const destinationBalance = filterTokenBalanceForTokenPublicKey(
|
|
161
|
+
balanceObj?.tokenBalances,
|
|
162
|
+
tokenPublicKey,
|
|
163
|
+
);
|
|
164
|
+
expect(destinationBalance.balance).toEqual(tokenAmount / 3n);
|
|
165
|
+
const balanceObj2 = await destinationWallet2.getBalance();
|
|
166
|
+
const destinationBalance2 = filterTokenBalanceForTokenPublicKey(
|
|
167
|
+
balanceObj2?.tokenBalances,
|
|
168
|
+
tokenPublicKey,
|
|
169
|
+
);
|
|
170
|
+
expect(destinationBalance2.balance).toEqual(tokenAmount / 3n);
|
|
171
|
+
const balanceObj3 = await destinationWallet3.getBalance();
|
|
172
|
+
const destinationBalance3 = filterTokenBalanceForTokenPublicKey(
|
|
173
|
+
balanceObj3?.tokenBalances,
|
|
174
|
+
tokenPublicKey,
|
|
175
|
+
);
|
|
176
|
+
expect(destinationBalance3.balance).toEqual(tokenAmount / 3n);
|
|
177
|
+
});
|
|
178
|
+
|
|
179
|
+
it("should announce, mint, and batchtransfer tokens with Schnorr", async () => {
|
|
180
|
+
const tokenAmount: bigint = 999n;
|
|
181
|
+
|
|
182
|
+
const { wallet: issuerWallet } = await IssuerSparkWalletTesting.initialize({
|
|
183
|
+
options: LOCAL_WALLET_CONFIG_SCHNORR,
|
|
184
|
+
});
|
|
185
|
+
|
|
186
|
+
const { wallet: destinationWallet } = await SparkWalletTesting.initialize({
|
|
187
|
+
options: LOCAL_WALLET_CONFIG_SCHNORR,
|
|
188
|
+
});
|
|
189
|
+
|
|
190
|
+
const { wallet: destinationWallet2 } = await SparkWalletTesting.initialize({
|
|
191
|
+
options: LOCAL_WALLET_CONFIG_SCHNORR,
|
|
192
|
+
});
|
|
193
|
+
|
|
194
|
+
const { wallet: destinationWallet3 } = await SparkWalletTesting.initialize({
|
|
195
|
+
options: LOCAL_WALLET_CONFIG_SCHNORR,
|
|
196
|
+
});
|
|
197
|
+
|
|
198
|
+
await fundAndAnnounce(issuerWallet, 100000n, 0, "SchnorrTransfer", "STT");
|
|
199
|
+
|
|
200
|
+
await issuerWallet.mintTokens(tokenAmount);
|
|
201
|
+
await issuerWallet.batchTransferTokens([
|
|
202
|
+
{
|
|
203
|
+
tokenAmount: tokenAmount / 3n,
|
|
204
|
+
tokenPublicKey: await issuerWallet.getIdentityPublicKey(),
|
|
205
|
+
receiverSparkAddress: await destinationWallet.getSparkAddress(),
|
|
206
|
+
},
|
|
207
|
+
{
|
|
208
|
+
tokenAmount: tokenAmount / 3n,
|
|
209
|
+
tokenPublicKey: await issuerWallet.getIdentityPublicKey(),
|
|
210
|
+
receiverSparkAddress: await destinationWallet2.getSparkAddress(),
|
|
211
|
+
},
|
|
212
|
+
{
|
|
213
|
+
tokenAmount: tokenAmount / 3n,
|
|
214
|
+
tokenPublicKey: await issuerWallet.getIdentityPublicKey(),
|
|
215
|
+
receiverSparkAddress: await destinationWallet3.getSparkAddress(),
|
|
216
|
+
},
|
|
217
|
+
]);
|
|
218
|
+
const sourceBalance = (await issuerWallet.getIssuerTokenBalance()).balance;
|
|
219
|
+
expect(sourceBalance).toEqual(0n);
|
|
220
|
+
|
|
221
|
+
const tokenPublicKey = await issuerWallet.getIdentityPublicKey();
|
|
222
|
+
const balanceObj = await destinationWallet.getBalance();
|
|
223
|
+
const destinationBalance = filterTokenBalanceForTokenPublicKey(
|
|
224
|
+
balanceObj?.tokenBalances,
|
|
225
|
+
tokenPublicKey,
|
|
226
|
+
);
|
|
227
|
+
expect(destinationBalance.balance).toEqual(tokenAmount / 3n);
|
|
228
|
+
const balanceObj2 = await destinationWallet2.getBalance();
|
|
229
|
+
const destinationBalance2 = filterTokenBalanceForTokenPublicKey(
|
|
230
|
+
balanceObj2?.tokenBalances,
|
|
231
|
+
tokenPublicKey,
|
|
232
|
+
);
|
|
233
|
+
expect(destinationBalance2.balance).toEqual(tokenAmount / 3n);
|
|
234
|
+
const balanceObj3 = await destinationWallet3.getBalance();
|
|
235
|
+
const destinationBalance3 = filterTokenBalanceForTokenPublicKey(
|
|
236
|
+
balanceObj3?.tokenBalances,
|
|
237
|
+
tokenPublicKey,
|
|
238
|
+
);
|
|
239
|
+
expect(destinationBalance3.balance).toEqual(tokenAmount / 3n);
|
|
240
|
+
});
|
|
241
|
+
|
|
116
242
|
it("should track token operations in monitoring", async () => {
|
|
117
243
|
const tokenAmount: bigint = 1000n;
|
|
118
244
|
|