mainnet-js 2.2.8 → 2.3.0
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.html +1 -1
- package/dist/{mainnet-2.2.8.js → mainnet-2.3.0.js} +7 -7
- package/dist/module/config.d.ts +2 -0
- package/dist/module/config.d.ts.map +1 -1
- package/dist/module/config.js +4 -0
- package/dist/module/config.js.map +1 -1
- package/dist/module/index.d.ts +1 -0
- package/dist/module/index.d.ts.map +1 -1
- package/dist/module/index.js +1 -0
- package/dist/module/index.js.map +1 -1
- package/dist/module/interface.d.ts +1 -1
- package/dist/module/network/ElectrumNetworkProvider.js +1 -1
- package/dist/module/transaction/Wif.d.ts +1 -1
- package/dist/module/util/sumUtxoValue.d.ts +1 -1
- package/dist/module/util/sumUtxoValue.js +3 -3
- package/dist/module/util/sumUtxoValue.js.map +1 -1
- package/dist/module/wallet/Bcmr.d.ts.map +1 -1
- package/dist/module/wallet/Bcmr.js +3 -2
- package/dist/module/wallet/Bcmr.js.map +1 -1
- package/dist/module/wallet/Wif.d.ts +6 -6
- package/dist/module/wallet/Wif.d.ts.map +1 -1
- package/dist/module/wallet/Wif.js +19 -18
- package/dist/module/wallet/Wif.js.map +1 -1
- package/dist/module/wallet/model.d.ts +6 -6
- package/dist/module/wallet/model.d.ts.map +1 -1
- package/dist/module/wallet/model.js +3 -3
- package/dist/module/wallet/model.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/polyfill/json.js +7 -0
- package/src/config.ts +5 -0
- package/src/index.ts +1 -0
- package/src/interface.ts +1 -1
- package/src/network/ElectrumNetworkProvider.ts +1 -1
- package/src/transaction/Wif.ts +1 -1
- package/src/util/sumUtxoValue.ts +5 -5
- package/src/wallet/Bcmr.test.ts +1 -1
- package/src/wallet/Bcmr.ts +3 -2
- package/src/wallet/Cashtokens.test.headless.js +44 -39
- package/src/wallet/Cashtokens.test.ts +117 -122
- package/src/wallet/Wif.test.ts +6 -9
- package/src/wallet/Wif.ts +28 -27
- package/src/wallet/model.ts +9 -9
|
@@ -16,6 +16,7 @@ import {
|
|
|
16
16
|
utf8ToBin,
|
|
17
17
|
} from "@bitauth/libauth";
|
|
18
18
|
import { delay } from "../util";
|
|
19
|
+
import json from "../../polyfill/json";
|
|
19
20
|
import { Config } from "../config";
|
|
20
21
|
|
|
21
22
|
beforeAll(async () => {
|
|
@@ -39,7 +40,7 @@ describe(`Test cashtokens`, () => {
|
|
|
39
40
|
const bob = await RegTestWallet.newRandom();
|
|
40
41
|
await alice.send([[bob.cashaddr!, 0.101, "bch"]]);
|
|
41
42
|
const genesisResponse = await bob.tokenGenesis({
|
|
42
|
-
amount:
|
|
43
|
+
amount: 100n,
|
|
43
44
|
});
|
|
44
45
|
|
|
45
46
|
const maxAmountToSend = await bob.getMaxAmountToSend();
|
|
@@ -51,12 +52,12 @@ describe(`Test cashtokens`, () => {
|
|
|
51
52
|
const alice = await RegTestWallet.fromId(process.env.ALICE_ID!);
|
|
52
53
|
const bob = await RegTestWallet.newRandom();
|
|
53
54
|
const genesisResponse = await alice.tokenGenesis({
|
|
54
|
-
amount:
|
|
55
|
+
amount: 100n,
|
|
55
56
|
});
|
|
56
57
|
|
|
57
58
|
const tokenId = genesisResponse.tokenIds![0];
|
|
58
59
|
const tokenBalance = await alice.getTokenBalance(tokenId);
|
|
59
|
-
expect(tokenBalance).toBe(
|
|
60
|
+
expect(tokenBalance).toBe(100n);
|
|
60
61
|
const tokenUtxos = await alice.getTokenUtxos(tokenId);
|
|
61
62
|
expect(tokenUtxos.length).toBe(1);
|
|
62
63
|
await alice.send([
|
|
@@ -67,11 +68,11 @@ describe(`Test cashtokens`, () => {
|
|
|
67
68
|
}),
|
|
68
69
|
new TokenSendRequest({
|
|
69
70
|
cashaddr: bob.cashaddr!,
|
|
70
|
-
amount:
|
|
71
|
+
amount: 25n,
|
|
71
72
|
tokenId: tokenId,
|
|
72
73
|
}),
|
|
73
74
|
]);
|
|
74
|
-
expect(await bob.getTokenBalance(tokenId)).toBe(
|
|
75
|
+
expect(await bob.getTokenBalance(tokenId)).toBe(25n);
|
|
75
76
|
expect(await bob.getBalance("sat")).toBe(5000);
|
|
76
77
|
|
|
77
78
|
await bob.send(
|
|
@@ -81,11 +82,11 @@ describe(`Test cashtokens`, () => {
|
|
|
81
82
|
unit: "sat",
|
|
82
83
|
})
|
|
83
84
|
);
|
|
84
|
-
expect(await bob.getTokenBalance(tokenId)).toBe(
|
|
85
|
+
expect(await bob.getTokenBalance(tokenId)).toBe(25n);
|
|
85
86
|
expect(await bob.getBalance("sat")).toBe(3780);
|
|
86
87
|
|
|
87
88
|
await bob.sendMax(alice.cashaddr!);
|
|
88
|
-
expect(await bob.getTokenBalance(tokenId)).toBe(
|
|
89
|
+
expect(await bob.getTokenBalance(tokenId)).toBe(25n);
|
|
89
90
|
expect(await bob.getBalance("sat")).toBe(0);
|
|
90
91
|
});
|
|
91
92
|
|
|
@@ -93,43 +94,43 @@ describe(`Test cashtokens`, () => {
|
|
|
93
94
|
const alice = await RegTestWallet.fromId(process.env.ALICE_ID!);
|
|
94
95
|
const bob = await RegTestWallet.newRandom();
|
|
95
96
|
const genesisResponse = await alice.tokenGenesis({
|
|
96
|
-
amount:
|
|
97
|
+
amount: 100n,
|
|
97
98
|
});
|
|
98
99
|
|
|
99
100
|
const tokenId = genesisResponse.tokenIds![0];
|
|
100
101
|
const tokenBalance = await alice.getTokenBalance(tokenId);
|
|
101
|
-
expect(tokenBalance).toBe(
|
|
102
|
+
expect(tokenBalance).toBe(100n);
|
|
102
103
|
const tokenUtxos = await alice.getTokenUtxos(tokenId);
|
|
103
104
|
expect(tokenUtxos.length).toBe(1);
|
|
104
105
|
const response = await alice.send([
|
|
105
106
|
new TokenSendRequest({
|
|
106
107
|
cashaddr: bob.cashaddr!,
|
|
107
|
-
amount:
|
|
108
|
+
amount: 25n,
|
|
108
109
|
tokenId: tokenId,
|
|
109
110
|
}),
|
|
110
111
|
new TokenSendRequest({
|
|
111
112
|
cashaddr: alice.cashaddr!,
|
|
112
|
-
amount:
|
|
113
|
+
amount: 25n,
|
|
113
114
|
tokenId: tokenId,
|
|
114
115
|
}),
|
|
115
116
|
]);
|
|
116
117
|
const newTokenUtxos = await alice.getTokenUtxos(tokenId);
|
|
117
118
|
expect(newTokenUtxos.length).toBe(2);
|
|
118
|
-
expect(await alice.getTokenBalance(tokenId)).toBe(
|
|
119
|
-
expect(await bob.getTokenBalance(tokenId)).toBe(
|
|
119
|
+
expect(await alice.getTokenBalance(tokenId)).toBe(75n);
|
|
120
|
+
expect(await bob.getTokenBalance(tokenId)).toBe(25n);
|
|
120
121
|
expect(await bob.getNftTokenBalance(tokenId)).toBe(0);
|
|
121
122
|
expect((await bob.getAllNftTokenBalances())[tokenId] || 0).toBe(0);
|
|
122
123
|
|
|
123
124
|
await alice.send([
|
|
124
125
|
new TokenSendRequest({
|
|
125
126
|
cashaddr: bob.cashaddr!,
|
|
126
|
-
amount:
|
|
127
|
+
amount: 75n,
|
|
127
128
|
tokenId: tokenId,
|
|
128
129
|
}),
|
|
129
130
|
]);
|
|
130
131
|
|
|
131
|
-
expect(await alice.getTokenBalance(tokenId)).toBe(
|
|
132
|
-
expect(await bob.getTokenBalance(tokenId)).toBe(
|
|
132
|
+
expect(await alice.getTokenBalance(tokenId)).toBe(0n);
|
|
133
|
+
expect(await bob.getTokenBalance(tokenId)).toBe(100n);
|
|
133
134
|
});
|
|
134
135
|
|
|
135
136
|
test("Test NFT cashtoken genesis and sending", async () => {
|
|
@@ -143,7 +144,7 @@ describe(`Test cashtokens`, () => {
|
|
|
143
144
|
|
|
144
145
|
const tokenId = genesisResponse.tokenIds![0];
|
|
145
146
|
const tokenBalance = await alice.getTokenBalance(tokenId);
|
|
146
|
-
expect(tokenBalance).toBe(
|
|
147
|
+
expect(tokenBalance).toBe(0n);
|
|
147
148
|
const nftTokenBalance = await alice.getNftTokenBalance(tokenId);
|
|
148
149
|
expect(nftTokenBalance).toBe(1);
|
|
149
150
|
const tokenUtxos = await alice.getTokenUtxos(tokenId);
|
|
@@ -156,12 +157,12 @@ describe(`Test cashtokens`, () => {
|
|
|
156
157
|
commitment: "abcd",
|
|
157
158
|
} as any,
|
|
158
159
|
]);
|
|
159
|
-
expect(await alice.getTokenBalance(tokenId)).toBe(
|
|
160
|
+
expect(await alice.getTokenBalance(tokenId)).toBe(0n);
|
|
160
161
|
expect(await alice.getNftTokenBalance(tokenId)).toBe(0);
|
|
161
162
|
const newTokenUtxos = await alice.getTokenUtxos(tokenId);
|
|
162
163
|
expect(newTokenUtxos.length).toBe(0);
|
|
163
164
|
|
|
164
|
-
expect(await bob.getTokenBalance(tokenId)).toBe(
|
|
165
|
+
expect(await bob.getTokenBalance(tokenId)).toBe(0n);
|
|
165
166
|
const bobTokenUtxos = await bob.getTokenUtxos(tokenId);
|
|
166
167
|
expect(bobTokenUtxos.length).toBe(1);
|
|
167
168
|
expect(tokenId).toEqual(response.tokenIds![0]);
|
|
@@ -178,7 +179,7 @@ describe(`Test cashtokens`, () => {
|
|
|
178
179
|
|
|
179
180
|
const tokenId = genesisResponse.tokenIds![0];
|
|
180
181
|
const tokenBalance = await alice.getTokenBalance(tokenId);
|
|
181
|
-
expect(tokenBalance).toBe(
|
|
182
|
+
expect(tokenBalance).toBe(0n);
|
|
182
183
|
const tokenUtxos = await alice.getTokenUtxos(tokenId);
|
|
183
184
|
expect(tokenUtxos.length).toBe(1);
|
|
184
185
|
await expect(
|
|
@@ -202,7 +203,7 @@ describe(`Test cashtokens`, () => {
|
|
|
202
203
|
|
|
203
204
|
const tokenId = genesisResponse.tokenIds![0];
|
|
204
205
|
const tokenBalance = await alice.getTokenBalance(tokenId);
|
|
205
|
-
expect(tokenBalance).toBe(
|
|
206
|
+
expect(tokenBalance).toBe(0n);
|
|
206
207
|
const tokenUtxos = await alice.getTokenUtxos(tokenId);
|
|
207
208
|
expect(tokenUtxos.length).toBe(1);
|
|
208
209
|
const response = await alice.send([
|
|
@@ -213,7 +214,7 @@ describe(`Test cashtokens`, () => {
|
|
|
213
214
|
commitment: "abcd02",
|
|
214
215
|
}),
|
|
215
216
|
]);
|
|
216
|
-
expect(await alice.getTokenBalance(tokenId)).toBe(
|
|
217
|
+
expect(await alice.getTokenBalance(tokenId)).toBe(0n);
|
|
217
218
|
const newTokenUtxos = await alice.getTokenUtxos(tokenId);
|
|
218
219
|
expect(newTokenUtxos.length).toBe(1);
|
|
219
220
|
expect(tokenId).toEqual(response.tokenIds![0]);
|
|
@@ -230,7 +231,7 @@ describe(`Test cashtokens`, () => {
|
|
|
230
231
|
|
|
231
232
|
const tokenId = genesisResponse.tokenIds![0];
|
|
232
233
|
const tokenBalance = await alice.getTokenBalance(tokenId);
|
|
233
|
-
expect(tokenBalance).toBe(
|
|
234
|
+
expect(tokenBalance).toBe(0n);
|
|
234
235
|
const tokenUtxos = await alice.getTokenUtxos(tokenId);
|
|
235
236
|
expect(tokenUtxos.length).toBe(1);
|
|
236
237
|
const response = await alice.tokenMint(tokenId, [
|
|
@@ -245,7 +246,7 @@ describe(`Test cashtokens`, () => {
|
|
|
245
246
|
capability: NFTCapability.none,
|
|
246
247
|
}),
|
|
247
248
|
]);
|
|
248
|
-
expect(await alice.getTokenBalance(tokenId)).toBe(
|
|
249
|
+
expect(await alice.getTokenBalance(tokenId)).toBe(0n);
|
|
249
250
|
const newTokenUtxos = await alice.getTokenUtxos(tokenId);
|
|
250
251
|
expect(newTokenUtxos.length).toBe(3);
|
|
251
252
|
expect(tokenId).toEqual(response.tokenIds![0]);
|
|
@@ -304,14 +305,14 @@ describe(`Test cashtokens`, () => {
|
|
|
304
305
|
const alice = await RegTestWallet.fromId(process.env.ALICE_ID!);
|
|
305
306
|
const genesisResponse = await alice.tokenGenesis({
|
|
306
307
|
cashaddr: alice.cashaddr!,
|
|
307
|
-
amount:
|
|
308
|
+
amount: 4n,
|
|
308
309
|
capability: NFTCapability.minting,
|
|
309
310
|
commitment: "abcd",
|
|
310
311
|
});
|
|
311
312
|
|
|
312
313
|
const tokenId = genesisResponse.tokenIds![0];
|
|
313
314
|
const tokenBalance = await alice.getTokenBalance(tokenId);
|
|
314
|
-
expect(tokenBalance).toBe(
|
|
315
|
+
expect(tokenBalance).toBe(4n);
|
|
315
316
|
const tokenUtxos = await alice.getTokenUtxos(tokenId);
|
|
316
317
|
expect(tokenUtxos.length).toBe(1);
|
|
317
318
|
|
|
@@ -332,7 +333,7 @@ describe(`Test cashtokens`, () => {
|
|
|
332
333
|
],
|
|
333
334
|
true
|
|
334
335
|
);
|
|
335
|
-
expect(await alice.getTokenBalance(tokenId)).toBe(
|
|
336
|
+
expect(await alice.getTokenBalance(tokenId)).toBe(2n);
|
|
336
337
|
const newTokenUtxos = await alice.getTokenUtxos(tokenId);
|
|
337
338
|
expect(newTokenUtxos.length).toBe(3);
|
|
338
339
|
expect(tokenId).toEqual(response.tokenIds![0]);
|
|
@@ -354,7 +355,7 @@ describe(`Test cashtokens`, () => {
|
|
|
354
355
|
],
|
|
355
356
|
false
|
|
356
357
|
);
|
|
357
|
-
expect(await alice.getTokenBalance(tokenId)).toBe(
|
|
358
|
+
expect(await alice.getTokenBalance(tokenId)).toBe(2n);
|
|
358
359
|
const ftTokenUtxos = await alice.getTokenUtxos(tokenId);
|
|
359
360
|
expect(ftTokenUtxos.length).toBe(5);
|
|
360
361
|
expect(tokenId).toEqual(ftResponse.tokenIds![0]);
|
|
@@ -382,7 +383,7 @@ describe(`Test cashtokens`, () => {
|
|
|
382
383
|
],
|
|
383
384
|
true
|
|
384
385
|
);
|
|
385
|
-
expect(await alice.getTokenBalance(tokenId)).toBe(
|
|
386
|
+
expect(await alice.getTokenBalance(tokenId)).toBe(0n);
|
|
386
387
|
const ft2TokenUtxos = await alice.getTokenUtxos(tokenId);
|
|
387
388
|
expect(ft2TokenUtxos.length).toBe(8);
|
|
388
389
|
expect(tokenId).toEqual(ft2Response.tokenIds![0]);
|
|
@@ -392,12 +393,12 @@ describe(`Test cashtokens`, () => {
|
|
|
392
393
|
const alice = await RegTestWallet.fromId(process.env.ALICE_ID!);
|
|
393
394
|
const genesisResponse = await alice.tokenGenesis({
|
|
394
395
|
cashaddr: alice.cashaddr!,
|
|
395
|
-
amount:
|
|
396
|
+
amount: 4n,
|
|
396
397
|
});
|
|
397
398
|
|
|
398
399
|
const tokenId = genesisResponse.tokenIds![0];
|
|
399
400
|
const tokenBalance = await alice.getTokenBalance(tokenId);
|
|
400
|
-
expect(tokenBalance).toBe(
|
|
401
|
+
expect(tokenBalance).toBe(4n);
|
|
401
402
|
const tokenUtxos = await alice.getTokenUtxos(tokenId);
|
|
402
403
|
expect(tokenUtxos.length).toBe(1);
|
|
403
404
|
|
|
@@ -405,7 +406,7 @@ describe(`Test cashtokens`, () => {
|
|
|
405
406
|
const response = await alice.tokenBurn(
|
|
406
407
|
{
|
|
407
408
|
tokenId: tokenId,
|
|
408
|
-
amount:
|
|
409
|
+
amount: 5n,
|
|
409
410
|
},
|
|
410
411
|
"burn"
|
|
411
412
|
);
|
|
@@ -416,7 +417,7 @@ describe(`Test cashtokens`, () => {
|
|
|
416
417
|
expect(rawTx!.vout[0].scriptPubKey.hex).toContain(
|
|
417
418
|
binToHex(utf8ToBin("burn"))
|
|
418
419
|
);
|
|
419
|
-
expect(await alice.getTokenBalance(tokenId)).toBe(
|
|
420
|
+
expect(await alice.getTokenBalance(tokenId)).toBe(0n);
|
|
420
421
|
const newTokenUtxos = await alice.getTokenUtxos(tokenId);
|
|
421
422
|
expect(newTokenUtxos.length).toBe(0);
|
|
422
423
|
expect(tokenId).toEqual(response.tokenIds![0]);
|
|
@@ -426,14 +427,14 @@ describe(`Test cashtokens`, () => {
|
|
|
426
427
|
const alice = await RegTestWallet.fromId(process.env.ALICE_ID!);
|
|
427
428
|
const genesisResponse = await alice.tokenGenesis({
|
|
428
429
|
cashaddr: alice.cashaddr!,
|
|
429
|
-
amount:
|
|
430
|
+
amount: 4n,
|
|
430
431
|
capability: NFTCapability.minting,
|
|
431
432
|
commitment: "abcd",
|
|
432
433
|
});
|
|
433
434
|
|
|
434
435
|
const tokenId = genesisResponse.tokenIds![0];
|
|
435
436
|
const tokenBalance = await alice.getTokenBalance(tokenId);
|
|
436
|
-
expect(tokenBalance).toBe(
|
|
437
|
+
expect(tokenBalance).toBe(4n);
|
|
437
438
|
const tokenUtxos = await alice.getTokenUtxos(tokenId);
|
|
438
439
|
expect(tokenUtxos.length).toBe(1);
|
|
439
440
|
|
|
@@ -441,7 +442,7 @@ describe(`Test cashtokens`, () => {
|
|
|
441
442
|
const response = await alice.tokenBurn(
|
|
442
443
|
{
|
|
443
444
|
tokenId: tokenId,
|
|
444
|
-
amount:
|
|
445
|
+
amount: 1n,
|
|
445
446
|
capability: NFTCapability.minting,
|
|
446
447
|
commitment: "abcd",
|
|
447
448
|
},
|
|
@@ -454,8 +455,8 @@ describe(`Test cashtokens`, () => {
|
|
|
454
455
|
expect(rawTx!.vout[0].scriptPubKey.hex).toContain(
|
|
455
456
|
binToHex(utf8ToBin("burn"))
|
|
456
457
|
);
|
|
457
|
-
expect(await alice.getTokenBalance(tokenId)).toBe(
|
|
458
|
-
expect((await alice.getAllTokenBalances())[tokenId]).toBe(
|
|
458
|
+
expect(await alice.getTokenBalance(tokenId)).toBe(3n);
|
|
459
|
+
expect((await alice.getAllTokenBalances())[tokenId]).toBe(3n);
|
|
459
460
|
const newTokenUtxos = await alice.getTokenUtxos(tokenId);
|
|
460
461
|
expect(newTokenUtxos.length).toBe(1);
|
|
461
462
|
expect(await alice.getNftTokenBalance(tokenId)).toBe(1);
|
|
@@ -466,13 +467,13 @@ describe(`Test cashtokens`, () => {
|
|
|
466
467
|
const ftResponse = await alice.tokenBurn(
|
|
467
468
|
{
|
|
468
469
|
tokenId: tokenId,
|
|
469
|
-
amount:
|
|
470
|
+
amount: 5n,
|
|
470
471
|
capability: NFTCapability.minting,
|
|
471
472
|
commitment: "abcd",
|
|
472
473
|
},
|
|
473
474
|
"burn"
|
|
474
475
|
);
|
|
475
|
-
expect(await alice.getTokenBalance(tokenId)).toBe(
|
|
476
|
+
expect(await alice.getTokenBalance(tokenId)).toBe(0n);
|
|
476
477
|
const ftTokenUtxos = await alice.getTokenUtxos(tokenId);
|
|
477
478
|
expect(ftTokenUtxos.length).toBe(1);
|
|
478
479
|
expect(tokenId).toEqual(ftResponse.tokenIds![0]);
|
|
@@ -486,8 +487,8 @@ describe(`Test cashtokens`, () => {
|
|
|
486
487
|
},
|
|
487
488
|
"burn"
|
|
488
489
|
);
|
|
489
|
-
expect(await alice.getTokenBalance(tokenId)).toBe(
|
|
490
|
-
expect((await alice.getAllTokenBalances())[tokenId] ||
|
|
490
|
+
expect(await alice.getTokenBalance(tokenId)).toBe(0n);
|
|
491
|
+
expect((await alice.getAllTokenBalances())[tokenId] || 0n).toBe(0n);
|
|
491
492
|
const nftTokenUtxos = await alice.getTokenUtxos(tokenId);
|
|
492
493
|
expect(nftTokenUtxos.length).toBe(0);
|
|
493
494
|
expect(tokenId).toEqual(nftResponse.tokenIds![0]);
|
|
@@ -499,14 +500,14 @@ describe(`Test cashtokens`, () => {
|
|
|
499
500
|
const alice = await RegTestWallet.fromId(process.env.ALICE_ID!);
|
|
500
501
|
const bob = await RegTestWallet.newRandom();
|
|
501
502
|
const genesisResponse = await alice.tokenGenesis({
|
|
502
|
-
amount:
|
|
503
|
+
amount: 100n,
|
|
503
504
|
value: 7000,
|
|
504
505
|
cashaddr: bob.cashaddr!,
|
|
505
506
|
});
|
|
506
507
|
|
|
507
508
|
const tokenId = genesisResponse.tokenIds![0];
|
|
508
509
|
const tokenBalance = await bob.getTokenBalance(tokenId);
|
|
509
|
-
expect(tokenBalance).toBe(
|
|
510
|
+
expect(tokenBalance).toBe(100n);
|
|
510
511
|
const tokenUtxos = await bob.getTokenUtxos(tokenId);
|
|
511
512
|
expect(tokenUtxos.length).toBe(1);
|
|
512
513
|
expect(tokenUtxos[0].satoshis).toBe(7000);
|
|
@@ -515,14 +516,14 @@ describe(`Test cashtokens`, () => {
|
|
|
515
516
|
const response = await bob.send([
|
|
516
517
|
new TokenSendRequest({
|
|
517
518
|
cashaddr: bob.cashaddr!,
|
|
518
|
-
amount:
|
|
519
|
+
amount: 100n,
|
|
519
520
|
tokenId: tokenId,
|
|
520
521
|
value: 1500,
|
|
521
522
|
}),
|
|
522
523
|
]);
|
|
523
524
|
let newTokenUtxos = await bob.getTokenUtxos(tokenId);
|
|
524
525
|
expect(newTokenUtxos.length).toBe(1);
|
|
525
|
-
expect(await bob.getTokenBalance(tokenId)).toBe(
|
|
526
|
+
expect(await bob.getTokenBalance(tokenId)).toBe(100n);
|
|
526
527
|
|
|
527
528
|
let bobUtxos = await bob.getAddressUtxos(bob.cashaddr!);
|
|
528
529
|
expect(bobUtxos.length).toBe(2);
|
|
@@ -533,14 +534,14 @@ describe(`Test cashtokens`, () => {
|
|
|
533
534
|
await bob.send([
|
|
534
535
|
new TokenSendRequest({
|
|
535
536
|
cashaddr: bob.cashaddr!,
|
|
536
|
-
amount:
|
|
537
|
+
amount: 100n,
|
|
537
538
|
tokenId: tokenId,
|
|
538
539
|
value: 3000,
|
|
539
540
|
}),
|
|
540
541
|
]);
|
|
541
542
|
newTokenUtxos = await bob.getTokenUtxos(tokenId);
|
|
542
543
|
expect(newTokenUtxos.length).toBe(1);
|
|
543
|
-
expect(await bob.getTokenBalance(tokenId)).toBe(
|
|
544
|
+
expect(await bob.getTokenBalance(tokenId)).toBe(100n);
|
|
544
545
|
|
|
545
546
|
bobUtxos = await bob.getAddressUtxos(bob.cashaddr!);
|
|
546
547
|
expect(bobUtxos.length).toBe(2);
|
|
@@ -553,7 +554,7 @@ describe(`Test cashtokens`, () => {
|
|
|
553
554
|
const bob = await RegTestWallet.newRandom();
|
|
554
555
|
|
|
555
556
|
const genesisResponse = await alice.tokenGenesis({
|
|
556
|
-
amount:
|
|
557
|
+
amount: 100n,
|
|
557
558
|
value: 5000,
|
|
558
559
|
capability: NFTCapability.minting,
|
|
559
560
|
commitment: "test",
|
|
@@ -562,19 +563,19 @@ describe(`Test cashtokens`, () => {
|
|
|
562
563
|
|
|
563
564
|
const tokenId = genesisResponse.tokenIds![0];
|
|
564
565
|
const tokenBalance = await alice.getTokenBalance(tokenId);
|
|
565
|
-
expect(tokenBalance).toBe(
|
|
566
|
+
expect(tokenBalance).toBe(100n);
|
|
566
567
|
const tokenUtxos = await alice.getTokenUtxos(tokenId);
|
|
567
568
|
expect(tokenUtxos.length).toBe(1);
|
|
568
569
|
expect(tokenUtxos[0].satoshis).toBe(5000);
|
|
569
570
|
|
|
570
|
-
let seenBalance =
|
|
571
|
+
let seenBalance = 0n;
|
|
571
572
|
let sendResponse: SendResponse = {};
|
|
572
573
|
setTimeout(
|
|
573
574
|
async () =>
|
|
574
575
|
(sendResponse = await alice.send([
|
|
575
576
|
new TokenSendRequest({
|
|
576
577
|
cashaddr: bob.cashaddr!,
|
|
577
|
-
amount:
|
|
578
|
+
amount: 100n,
|
|
578
579
|
tokenId: tokenId,
|
|
579
580
|
value: 1500,
|
|
580
581
|
capability: NFTCapability.minting,
|
|
@@ -593,10 +594,10 @@ describe(`Test cashtokens`, () => {
|
|
|
593
594
|
bobTxId = tx.txid;
|
|
594
595
|
});
|
|
595
596
|
|
|
596
|
-
const balance = await bob.waitForTokenBalance(tokenId,
|
|
597
|
+
const balance = await bob.waitForTokenBalance(tokenId, 100n);
|
|
597
598
|
await delay(500);
|
|
598
|
-
expect(balance).toBe(
|
|
599
|
-
expect(seenBalance).toBe(
|
|
599
|
+
expect(balance).toBe(100n);
|
|
600
|
+
expect(seenBalance).toBe(100n);
|
|
600
601
|
expect(sendResponse.txId).toBe(bobTxId);
|
|
601
602
|
await cancel();
|
|
602
603
|
await txCancel();
|
|
@@ -612,23 +613,23 @@ describe(`Test cashtokens`, () => {
|
|
|
612
613
|
await alice.send({ cashaddr: bob.cashaddr!, value: 10000, unit: "sat" });
|
|
613
614
|
|
|
614
615
|
const genesisResponse = await bob.tokenGenesis({
|
|
615
|
-
amount:
|
|
616
|
+
amount: 100n,
|
|
616
617
|
});
|
|
617
618
|
|
|
618
619
|
const tokenId = genesisResponse.tokenIds![0];
|
|
619
620
|
const tokenBalance = await bob.getTokenBalance(tokenId);
|
|
620
621
|
|
|
621
|
-
expect(tokenBalance).toBe(
|
|
622
|
+
expect(tokenBalance).toBe(100n);
|
|
622
623
|
const tokenUtxos = await bob.getTokenUtxos(tokenId);
|
|
623
624
|
expect(tokenUtxos.length).toBe(1);
|
|
624
625
|
|
|
625
626
|
const genesis2Response = await bob.tokenGenesis({
|
|
626
|
-
amount:
|
|
627
|
+
amount: 200n,
|
|
627
628
|
});
|
|
628
629
|
|
|
629
630
|
const tokenId2 = genesis2Response.tokenIds![0];
|
|
630
631
|
const tokenBalance2 = await bob.getTokenBalance(tokenId2);
|
|
631
|
-
expect(tokenBalance2).toBe(
|
|
632
|
+
expect(tokenBalance2).toBe(200n);
|
|
632
633
|
const tokenUtxos2 = await bob.getTokenUtxos(tokenId2);
|
|
633
634
|
expect(tokenUtxos2.length).toBe(1);
|
|
634
635
|
|
|
@@ -644,23 +645,23 @@ describe(`Test cashtokens`, () => {
|
|
|
644
645
|
await alice.send({ cashaddr: bob.cashaddr!, value: 10000, unit: "sat" });
|
|
645
646
|
|
|
646
647
|
const genesisResponse = await bob.tokenGenesis({
|
|
647
|
-
amount:
|
|
648
|
+
amount: 100n,
|
|
648
649
|
});
|
|
649
650
|
|
|
650
651
|
const tokenId = genesisResponse.tokenIds![0];
|
|
651
652
|
const tokenBalance = await bob.getTokenBalance(tokenId);
|
|
652
653
|
|
|
653
|
-
expect(tokenBalance).toBe(
|
|
654
|
+
expect(tokenBalance).toBe(100n);
|
|
654
655
|
const tokenUtxos = await bob.getTokenUtxos(tokenId);
|
|
655
656
|
expect(tokenUtxos.length).toBe(1);
|
|
656
657
|
|
|
657
658
|
const genesis2Response = await bob.tokenGenesis({
|
|
658
|
-
amount:
|
|
659
|
+
amount: 200n,
|
|
659
660
|
});
|
|
660
661
|
|
|
661
662
|
const tokenId2 = genesis2Response.tokenIds![0];
|
|
662
663
|
const tokenBalance2 = await bob.getTokenBalance(tokenId2);
|
|
663
|
-
expect(tokenBalance2).toBe(
|
|
664
|
+
expect(tokenBalance2).toBe(200n);
|
|
664
665
|
const tokenUtxos2 = await bob.getTokenUtxos(tokenId2);
|
|
665
666
|
expect(tokenUtxos2.length).toBe(1);
|
|
666
667
|
|
|
@@ -670,12 +671,12 @@ describe(`Test cashtokens`, () => {
|
|
|
670
671
|
await bob.send({
|
|
671
672
|
cashaddr: charlie.cashaddr!,
|
|
672
673
|
tokenId: tokenId,
|
|
673
|
-
amount:
|
|
674
|
+
amount: 50n,
|
|
674
675
|
});
|
|
675
676
|
expect((await bob.getTokenUtxos()).length).toBe(2);
|
|
676
677
|
expect((await charlie.getTokenUtxos()).length).toBe(1);
|
|
677
|
-
expect(await bob.getTokenBalance(tokenId)).toBe(
|
|
678
|
-
expect(await charlie.getTokenBalance(tokenId)).toBe(
|
|
678
|
+
expect(await bob.getTokenBalance(tokenId)).toBe(50n);
|
|
679
|
+
expect(await charlie.getTokenBalance(tokenId)).toBe(50n);
|
|
679
680
|
});
|
|
680
681
|
|
|
681
682
|
test("Test sending bch should not burn tokens", async () => {
|
|
@@ -686,20 +687,20 @@ describe(`Test cashtokens`, () => {
|
|
|
686
687
|
await alice.send({ cashaddr: bob.cashaddr!, value: 10000, unit: "sat" });
|
|
687
688
|
|
|
688
689
|
const genesisResponse = await bob.tokenGenesis({
|
|
689
|
-
amount:
|
|
690
|
+
amount: 100n,
|
|
690
691
|
});
|
|
691
692
|
|
|
692
693
|
const tokenId = genesisResponse.tokenIds![0];
|
|
693
694
|
const tokenBalance = await bob.getTokenBalance(tokenId);
|
|
694
695
|
|
|
695
|
-
expect(tokenBalance).toBe(
|
|
696
|
+
expect(tokenBalance).toBe(100n);
|
|
696
697
|
const tokenUtxos = await bob.getTokenUtxos(tokenId);
|
|
697
698
|
expect(tokenUtxos.length).toBe(1);
|
|
698
699
|
|
|
699
700
|
await bob.send({ cashaddr: alice.cashaddr!, value: 1000, unit: "sat" });
|
|
700
701
|
|
|
701
702
|
const tokenBalance2 = await bob.getTokenBalance(tokenId);
|
|
702
|
-
expect(tokenBalance2).toBe(
|
|
703
|
+
expect(tokenBalance2).toBe(100n);
|
|
703
704
|
const tokenUtxos2 = await bob.getTokenUtxos(tokenId);
|
|
704
705
|
expect(tokenUtxos2.length).toBe(1);
|
|
705
706
|
});
|
|
@@ -715,13 +716,13 @@ describe(`Test cashtokens`, () => {
|
|
|
715
716
|
]);
|
|
716
717
|
|
|
717
718
|
const genesisResponse = await bob.tokenGenesis({
|
|
718
|
-
amount:
|
|
719
|
+
amount: 1001n,
|
|
719
720
|
});
|
|
720
721
|
|
|
721
722
|
const tokenId = genesisResponse.tokenIds![0];
|
|
722
723
|
|
|
723
724
|
const tokenBalance = await bob.getTokenBalance(tokenId);
|
|
724
|
-
expect(tokenBalance).toBe(
|
|
725
|
+
expect(tokenBalance).toBe(1001n);
|
|
725
726
|
const tokenUtxos = await bob.getTokenUtxos(tokenId);
|
|
726
727
|
expect(tokenUtxos.length).toBe(1);
|
|
727
728
|
|
|
@@ -731,37 +732,37 @@ describe(`Test cashtokens`, () => {
|
|
|
731
732
|
{
|
|
732
733
|
cashaddr: charlie.cashaddr!,
|
|
733
734
|
tokenId: tokenId,
|
|
734
|
-
amount:
|
|
735
|
+
amount: 5n,
|
|
735
736
|
},
|
|
736
737
|
{
|
|
737
738
|
cashaddr: charlie.cashaddr!,
|
|
738
739
|
tokenId: tokenId,
|
|
739
|
-
amount:
|
|
740
|
+
amount: 501n,
|
|
740
741
|
},
|
|
741
742
|
{
|
|
742
743
|
cashaddr: charlie.cashaddr!,
|
|
743
744
|
tokenId: tokenId,
|
|
744
|
-
amount:
|
|
745
|
+
amount: 95n,
|
|
745
746
|
},
|
|
746
747
|
{
|
|
747
748
|
cashaddr: charlie.cashaddr!,
|
|
748
749
|
tokenId: tokenId,
|
|
749
|
-
amount:
|
|
750
|
+
amount: 100n,
|
|
750
751
|
},
|
|
751
752
|
{
|
|
752
753
|
cashaddr: charlie.cashaddr!,
|
|
753
754
|
tokenId: tokenId,
|
|
754
|
-
amount:
|
|
755
|
+
amount: 300n,
|
|
755
756
|
},
|
|
756
757
|
]);
|
|
757
758
|
|
|
758
759
|
const tokenBalance2 = await bob.getTokenBalance(tokenId);
|
|
759
|
-
expect(tokenBalance2).toBe(
|
|
760
|
+
expect(tokenBalance2).toBe(0n);
|
|
760
761
|
const tokenUtxos2 = await bob.getTokenUtxos(tokenId);
|
|
761
762
|
expect(tokenUtxos2.length).toBe(0);
|
|
762
763
|
|
|
763
764
|
const tokenBalance3 = await charlie.getTokenBalance(tokenId);
|
|
764
|
-
expect(tokenBalance3).toBe(
|
|
765
|
+
expect(tokenBalance3).toBe(1001n);
|
|
765
766
|
const tokenUtxos3 = await charlie.getTokenUtxos(tokenId);
|
|
766
767
|
expect(tokenUtxos3.length).toBe(5);
|
|
767
768
|
|
|
@@ -770,16 +771,16 @@ describe(`Test cashtokens`, () => {
|
|
|
770
771
|
{
|
|
771
772
|
cashaddr: bob.cashaddr!,
|
|
772
773
|
tokenId: tokenId,
|
|
773
|
-
amount:
|
|
774
|
+
amount: 50n,
|
|
774
775
|
},
|
|
775
776
|
]);
|
|
776
777
|
const tokenBalance4 = await charlie.getTokenBalance(tokenId);
|
|
777
|
-
expect(tokenBalance4).toBe(
|
|
778
|
+
expect(tokenBalance4).toBe(951n);
|
|
778
779
|
const tokenUtxos4 = await charlie.getTokenUtxos(tokenId);
|
|
779
780
|
expect(tokenUtxos4.length).toBe(1);
|
|
780
781
|
|
|
781
782
|
const tokenBalance5 = await bob.getTokenBalance(tokenId);
|
|
782
|
-
expect(tokenBalance5).toBe(
|
|
783
|
+
expect(tokenBalance5).toBe(50n);
|
|
783
784
|
const tokenUtxos5 = await bob.getTokenUtxos(tokenId);
|
|
784
785
|
expect(tokenUtxos5.length).toBe(1);
|
|
785
786
|
});
|
|
@@ -799,7 +800,7 @@ describe(`Test cashtokens`, () => {
|
|
|
799
800
|
|
|
800
801
|
const tokenId = genesisResponse.tokenIds![0];
|
|
801
802
|
|
|
802
|
-
expect(await bob.getTokenBalance(tokenId)).toBe(
|
|
803
|
+
expect(await bob.getTokenBalance(tokenId)).toBe(0n);
|
|
803
804
|
expect(await bob.getNftTokenBalance(tokenId)).toBe(1);
|
|
804
805
|
expect((await bob.getTokenUtxos(tokenId)).length).toBe(1);
|
|
805
806
|
|
|
@@ -808,7 +809,7 @@ describe(`Test cashtokens`, () => {
|
|
|
808
809
|
commitment: "0a",
|
|
809
810
|
});
|
|
810
811
|
|
|
811
|
-
expect(await bob.getTokenBalance(tokenId)).toBe(
|
|
812
|
+
expect(await bob.getTokenBalance(tokenId)).toBe(0n);
|
|
812
813
|
expect(await bob.getNftTokenBalance(tokenId)).toBe(2);
|
|
813
814
|
expect((await bob.getTokenUtxos(tokenId)).length).toBe(2);
|
|
814
815
|
|
|
@@ -820,11 +821,11 @@ describe(`Test cashtokens`, () => {
|
|
|
820
821
|
cashaddr: charlie.cashaddr!,
|
|
821
822
|
})
|
|
822
823
|
);
|
|
823
|
-
expect(await bob.getTokenBalance(tokenId)).toBe(
|
|
824
|
+
expect(await bob.getTokenBalance(tokenId)).toBe(0n);
|
|
824
825
|
expect(await bob.getNftTokenBalance(tokenId)).toBe(1);
|
|
825
826
|
expect((await bob.getTokenUtxos(tokenId)).length).toBe(1);
|
|
826
827
|
|
|
827
|
-
expect(await charlie.getTokenBalance(tokenId)).toBe(
|
|
828
|
+
expect(await charlie.getTokenBalance(tokenId)).toBe(0n);
|
|
828
829
|
expect(await charlie.getNftTokenBalance(tokenId)).toBe(1);
|
|
829
830
|
expect((await charlie.getTokenUtxos(tokenId)).length).toBe(1);
|
|
830
831
|
});
|
|
@@ -844,7 +845,7 @@ describe(`Test cashtokens`, () => {
|
|
|
844
845
|
|
|
845
846
|
const tokenId = genesisResponse.tokenIds![0];
|
|
846
847
|
|
|
847
|
-
expect(await bob.getTokenBalance(tokenId)).toBe(
|
|
848
|
+
expect(await bob.getTokenBalance(tokenId)).toBe(0n);
|
|
848
849
|
expect(await bob.getNftTokenBalance(tokenId)).toBe(1);
|
|
849
850
|
expect((await bob.getTokenUtxos(tokenId)).length).toBe(1);
|
|
850
851
|
|
|
@@ -853,7 +854,7 @@ describe(`Test cashtokens`, () => {
|
|
|
853
854
|
commitment: "0a",
|
|
854
855
|
});
|
|
855
856
|
|
|
856
|
-
expect(await bob.getTokenBalance(tokenId)).toBe(
|
|
857
|
+
expect(await bob.getTokenBalance(tokenId)).toBe(0n);
|
|
857
858
|
expect(await bob.getNftTokenBalance(tokenId)).toBe(2);
|
|
858
859
|
expect((await bob.getTokenUtxos(tokenId)).length).toBe(2);
|
|
859
860
|
|
|
@@ -862,7 +863,7 @@ describe(`Test cashtokens`, () => {
|
|
|
862
863
|
commitment: "0b",
|
|
863
864
|
});
|
|
864
865
|
|
|
865
|
-
expect(await bob.getTokenBalance(tokenId)).toBe(
|
|
866
|
+
expect(await bob.getTokenBalance(tokenId)).toBe(0n);
|
|
866
867
|
expect(await bob.getNftTokenBalance(tokenId)).toBe(3);
|
|
867
868
|
expect((await bob.getTokenUtxos(tokenId)).length).toBe(3);
|
|
868
869
|
|
|
@@ -872,7 +873,7 @@ describe(`Test cashtokens`, () => {
|
|
|
872
873
|
commitment: "",
|
|
873
874
|
});
|
|
874
875
|
|
|
875
|
-
expect(await bob.getTokenBalance(tokenId)).toBe(
|
|
876
|
+
expect(await bob.getTokenBalance(tokenId)).toBe(0n);
|
|
876
877
|
expect(await bob.getNftTokenBalance(tokenId)).toBe(2);
|
|
877
878
|
expect((await bob.getTokenUtxos(tokenId)).length).toBe(2);
|
|
878
879
|
|
|
@@ -884,11 +885,11 @@ describe(`Test cashtokens`, () => {
|
|
|
884
885
|
cashaddr: charlie.cashaddr!,
|
|
885
886
|
})
|
|
886
887
|
);
|
|
887
|
-
expect(await bob.getTokenBalance(tokenId)).toBe(
|
|
888
|
+
expect(await bob.getTokenBalance(tokenId)).toBe(0n);
|
|
888
889
|
expect(await bob.getNftTokenBalance(tokenId)).toBe(1);
|
|
889
890
|
expect((await bob.getTokenUtxos(tokenId)).length).toBe(1);
|
|
890
891
|
|
|
891
|
-
expect(await charlie.getTokenBalance(tokenId)).toBe(
|
|
892
|
+
expect(await charlie.getTokenBalance(tokenId)).toBe(0n);
|
|
892
893
|
expect(await charlie.getNftTokenBalance(tokenId)).toBe(1);
|
|
893
894
|
expect((await charlie.getTokenUtxos(tokenId)).length).toBe(1);
|
|
894
895
|
|
|
@@ -900,11 +901,11 @@ describe(`Test cashtokens`, () => {
|
|
|
900
901
|
cashaddr: charlie.cashaddr!,
|
|
901
902
|
})
|
|
902
903
|
);
|
|
903
|
-
expect(await bob.getTokenBalance(tokenId)).toBe(
|
|
904
|
+
expect(await bob.getTokenBalance(tokenId)).toBe(0n);
|
|
904
905
|
expect(await bob.getNftTokenBalance(tokenId)).toBe(0);
|
|
905
906
|
expect((await bob.getTokenUtxos(tokenId)).length).toBe(0);
|
|
906
907
|
|
|
907
|
-
expect(await charlie.getTokenBalance(tokenId)).toBe(
|
|
908
|
+
expect(await charlie.getTokenBalance(tokenId)).toBe(0n);
|
|
908
909
|
expect(await charlie.getNftTokenBalance(tokenId)).toBe(2);
|
|
909
910
|
expect((await charlie.getTokenUtxos(tokenId)).length).toBe(2);
|
|
910
911
|
});
|
|
@@ -924,7 +925,7 @@ describe(`Test cashtokens`, () => {
|
|
|
924
925
|
|
|
925
926
|
const tokenId = genesisResponse.tokenIds![0];
|
|
926
927
|
|
|
927
|
-
expect(await bob.getTokenBalance(tokenId)).toBe(
|
|
928
|
+
expect(await bob.getTokenBalance(tokenId)).toBe(0n);
|
|
928
929
|
expect(await bob.getNftTokenBalance(tokenId)).toBe(1);
|
|
929
930
|
expect((await bob.getTokenUtxos(tokenId)).length).toBe(1);
|
|
930
931
|
|
|
@@ -933,7 +934,7 @@ describe(`Test cashtokens`, () => {
|
|
|
933
934
|
commitment: "0a",
|
|
934
935
|
});
|
|
935
936
|
|
|
936
|
-
expect(await bob.getTokenBalance(tokenId)).toBe(
|
|
937
|
+
expect(await bob.getTokenBalance(tokenId)).toBe(0n);
|
|
937
938
|
expect(await bob.getNftTokenBalance(tokenId)).toBe(2);
|
|
938
939
|
expect((await bob.getTokenUtxos(tokenId)).length).toBe(2);
|
|
939
940
|
|
|
@@ -942,7 +943,7 @@ describe(`Test cashtokens`, () => {
|
|
|
942
943
|
commitment: "0b",
|
|
943
944
|
});
|
|
944
945
|
|
|
945
|
-
expect(await bob.getTokenBalance(tokenId)).toBe(
|
|
946
|
+
expect(await bob.getTokenBalance(tokenId)).toBe(0n);
|
|
946
947
|
expect(await bob.getNftTokenBalance(tokenId)).toBe(3);
|
|
947
948
|
expect((await bob.getTokenUtxos(tokenId)).length).toBe(3);
|
|
948
949
|
|
|
@@ -952,7 +953,7 @@ describe(`Test cashtokens`, () => {
|
|
|
952
953
|
commitment: "00",
|
|
953
954
|
});
|
|
954
955
|
|
|
955
|
-
expect(await bob.getTokenBalance(tokenId)).toBe(
|
|
956
|
+
expect(await bob.getTokenBalance(tokenId)).toBe(0n);
|
|
956
957
|
expect(await bob.getNftTokenBalance(tokenId)).toBe(2);
|
|
957
958
|
expect((await bob.getTokenUtxos(tokenId)).length).toBe(2);
|
|
958
959
|
|
|
@@ -983,12 +984,12 @@ describe(`Test cashtokens`, () => {
|
|
|
983
984
|
const genesisResponse = await bob.tokenGenesis({
|
|
984
985
|
capability: "none",
|
|
985
986
|
commitment: "0000000e",
|
|
986
|
-
amount:
|
|
987
|
+
amount: 10000n,
|
|
987
988
|
});
|
|
988
989
|
|
|
989
990
|
const tokenId = genesisResponse.tokenIds![0];
|
|
990
991
|
|
|
991
|
-
expect(await bob.getTokenBalance(tokenId)).toBe(
|
|
992
|
+
expect(await bob.getTokenBalance(tokenId)).toBe(10000n);
|
|
992
993
|
expect(await bob.getNftTokenBalance(tokenId)).toBe(1);
|
|
993
994
|
expect((await bob.getTokenUtxos(tokenId)).length).toBe(1);
|
|
994
995
|
|
|
@@ -1003,11 +1004,11 @@ describe(`Test cashtokens`, () => {
|
|
|
1003
1004
|
new TokenSendRequest({
|
|
1004
1005
|
cashaddr: bob.cashaddr!,
|
|
1005
1006
|
tokenId: tokenId,
|
|
1006
|
-
amount:
|
|
1007
|
+
amount: 10000n,
|
|
1007
1008
|
}),
|
|
1008
1009
|
]);
|
|
1009
1010
|
|
|
1010
|
-
expect(await bob.getTokenBalance(tokenId)).toBe(
|
|
1011
|
+
expect(await bob.getTokenBalance(tokenId)).toBe(10000n);
|
|
1011
1012
|
expect(await bob.getNftTokenBalance(tokenId)).toBe(1);
|
|
1012
1013
|
expect((await bob.getTokenUtxos(tokenId)).length).toBe(2);
|
|
1013
1014
|
|
|
@@ -1016,23 +1017,23 @@ describe(`Test cashtokens`, () => {
|
|
|
1016
1017
|
new TokenSendRequest({
|
|
1017
1018
|
cashaddr: bob.cashaddr!,
|
|
1018
1019
|
tokenId: tokenId,
|
|
1019
|
-
amount:
|
|
1020
|
+
amount: 9000n,
|
|
1020
1021
|
}),
|
|
1021
1022
|
new TokenSendRequest({
|
|
1022
1023
|
cashaddr: bob.cashaddr!,
|
|
1023
1024
|
tokenId: tokenId,
|
|
1024
1025
|
capability: "none",
|
|
1025
1026
|
commitment: "0000000e",
|
|
1026
|
-
amount:
|
|
1027
|
+
amount: 1000n,
|
|
1027
1028
|
}),
|
|
1028
1029
|
]);
|
|
1029
1030
|
|
|
1030
|
-
expect(await bob.getTokenBalance(tokenId)).toBe(
|
|
1031
|
+
expect(await bob.getTokenBalance(tokenId)).toBe(10000n);
|
|
1031
1032
|
expect(await bob.getNftTokenBalance(tokenId)).toBe(1);
|
|
1032
1033
|
expect((await bob.getTokenUtxos(tokenId)).length).toBe(2);
|
|
1033
1034
|
const tokenUtxos = await bob.getTokenUtxos(tokenId);
|
|
1034
|
-
expect(tokenUtxos[0].token?.amount).toBe(
|
|
1035
|
-
expect(tokenUtxos[1].token?.amount).toBe(
|
|
1035
|
+
expect(tokenUtxos[0].token?.amount).toBe(9000n);
|
|
1036
|
+
expect(tokenUtxos[1].token?.amount).toBe(1000n);
|
|
1036
1037
|
|
|
1037
1038
|
// merge FT and NFT into single utxo
|
|
1038
1039
|
await bob.send([
|
|
@@ -1041,11 +1042,11 @@ describe(`Test cashtokens`, () => {
|
|
|
1041
1042
|
tokenId: tokenId,
|
|
1042
1043
|
capability: "none",
|
|
1043
1044
|
commitment: "0000000e",
|
|
1044
|
-
amount:
|
|
1045
|
+
amount: 10000n,
|
|
1045
1046
|
}),
|
|
1046
1047
|
]);
|
|
1047
1048
|
|
|
1048
|
-
expect(await bob.getTokenBalance(tokenId)).toBe(
|
|
1049
|
+
expect(await bob.getTokenBalance(tokenId)).toBe(10000n);
|
|
1049
1050
|
expect(await bob.getNftTokenBalance(tokenId)).toBe(1);
|
|
1050
1051
|
expect((await bob.getTokenUtxos(tokenId)).length).toBe(1);
|
|
1051
1052
|
});
|
|
@@ -1074,9 +1075,7 @@ describe(`Test cashtokens`, () => {
|
|
|
1074
1075
|
expect(encodedTransaction.length).toBeGreaterThan(0);
|
|
1075
1076
|
|
|
1076
1077
|
// check transaction was not submitted
|
|
1077
|
-
expect(
|
|
1078
|
-
JSON.stringify(await aliceWallet.getAddressUtxos())
|
|
1079
|
-
);
|
|
1078
|
+
expect(json(aliceUtxos)).toBe(json(await aliceWallet.getAddressUtxos()));
|
|
1080
1079
|
|
|
1081
1080
|
const decoded = decodeTransaction(encodedTransaction);
|
|
1082
1081
|
if (typeof decoded === "string") {
|
|
@@ -1120,9 +1119,7 @@ describe(`Test cashtokens`, () => {
|
|
|
1120
1119
|
expect(encodedTransaction.length).toBeGreaterThan(0);
|
|
1121
1120
|
|
|
1122
1121
|
// check transaction was not submitted
|
|
1123
|
-
expect(
|
|
1124
|
-
JSON.stringify(await aliceWallet.getAddressUtxos())
|
|
1125
|
-
);
|
|
1122
|
+
expect(json(aliceUtxos)).toBe(json(await aliceWallet.getAddressUtxos()));
|
|
1126
1123
|
|
|
1127
1124
|
const decoded = decodeTransaction(encodedTransaction);
|
|
1128
1125
|
if (typeof decoded === "string") {
|
|
@@ -1176,9 +1173,7 @@ describe(`Test cashtokens`, () => {
|
|
|
1176
1173
|
expect(encodedTransaction.length).toBeGreaterThan(0);
|
|
1177
1174
|
|
|
1178
1175
|
// check transaction was not submitted
|
|
1179
|
-
expect(
|
|
1180
|
-
JSON.stringify(await aliceWallet.getAddressUtxos())
|
|
1181
|
-
);
|
|
1176
|
+
expect(json(aliceUtxos)).toBe(json(await aliceWallet.getAddressUtxos()));
|
|
1182
1177
|
|
|
1183
1178
|
const decoded = decodeTransaction(encodedTransaction);
|
|
1184
1179
|
if (typeof decoded === "string") {
|
|
@@ -1215,7 +1210,7 @@ describe(`Test cashtokens`, () => {
|
|
|
1215
1210
|
test("Test enforcing token addresses", async () => {
|
|
1216
1211
|
const alice = await RegTestWallet.fromId(process.env.ALICE_ID!);
|
|
1217
1212
|
const genesisResponse = await alice.tokenGenesis({
|
|
1218
|
-
amount:
|
|
1213
|
+
amount: 100n,
|
|
1219
1214
|
});
|
|
1220
1215
|
const tokenId = genesisResponse.tokenIds![0];
|
|
1221
1216
|
|
|
@@ -1236,7 +1231,7 @@ describe(`Test cashtokens`, () => {
|
|
|
1236
1231
|
new TokenSendRequest({
|
|
1237
1232
|
cashaddr: alice.cashaddr!,
|
|
1238
1233
|
tokenId: tokenId,
|
|
1239
|
-
amount:
|
|
1234
|
+
amount: 1n,
|
|
1240
1235
|
})
|
|
1241
1236
|
)
|
|
1242
1237
|
).resolves.not.toThrow();
|
|
@@ -1246,7 +1241,7 @@ describe(`Test cashtokens`, () => {
|
|
|
1246
1241
|
new TokenSendRequest({
|
|
1247
1242
|
cashaddr: alice.tokenaddr!,
|
|
1248
1243
|
tokenId: tokenId,
|
|
1249
|
-
amount:
|
|
1244
|
+
amount: 2n,
|
|
1250
1245
|
})
|
|
1251
1246
|
)
|
|
1252
1247
|
).resolves.not.toThrow();
|
|
@@ -1261,7 +1256,7 @@ describe(`Test cashtokens`, () => {
|
|
|
1261
1256
|
new TokenSendRequest({
|
|
1262
1257
|
cashaddr: alice.cashaddr!,
|
|
1263
1258
|
tokenId: tokenId,
|
|
1264
|
-
amount:
|
|
1259
|
+
amount: 1n,
|
|
1265
1260
|
})
|
|
1266
1261
|
))()
|
|
1267
1262
|
).rejects.toThrow();
|
|
@@ -1271,7 +1266,7 @@ describe(`Test cashtokens`, () => {
|
|
|
1271
1266
|
new TokenSendRequest({
|
|
1272
1267
|
cashaddr: alice.tokenaddr!,
|
|
1273
1268
|
tokenId: tokenId,
|
|
1274
|
-
amount:
|
|
1269
|
+
amount: 2n,
|
|
1275
1270
|
})
|
|
1276
1271
|
)
|
|
1277
1272
|
).resolves.not.toThrow();
|