mainnet-js 3.0.0-next.1 → 3.0.0-next.2
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-3.0.0-next.1.js → mainnet-3.0.0-next.2.js} +7 -7
- package/dist/module/history/getHistory.js +17 -17
- package/dist/module/history/getHistory.js.map +1 -1
- package/dist/module/history/interface.d.ts +1 -1
- package/dist/module/history/interface.d.ts.map +1 -1
- package/dist/module/interface.d.ts +5 -3
- package/dist/module/interface.d.ts.map +1 -1
- package/dist/module/interface.js.map +1 -1
- package/dist/module/network/ElectrumNetworkProvider.d.ts.map +1 -1
- package/dist/module/network/ElectrumNetworkProvider.js +1 -3
- package/dist/module/network/ElectrumNetworkProvider.js.map +1 -1
- package/dist/module/network/interface.d.ts +2 -2
- package/dist/module/network/interface.d.ts.map +1 -1
- package/dist/module/transaction/Wif.d.ts.map +1 -1
- package/dist/module/transaction/Wif.js +25 -23
- package/dist/module/transaction/Wif.js.map +1 -1
- package/dist/module/util/asSendRequestObject.js +2 -2
- package/dist/module/util/asSendRequestObject.js.map +1 -1
- package/dist/module/util/sumUtxoValue.js +1 -1
- package/dist/module/util/sumUtxoValue.js.map +1 -1
- package/dist/module/wallet/Base.d.ts +18 -18
- package/dist/module/wallet/Base.d.ts.map +1 -1
- package/dist/module/wallet/Base.js +64 -69
- package/dist/module/wallet/Base.js.map +1 -1
- package/dist/module/wallet/HDWallet.d.ts +1 -1
- package/dist/module/wallet/Wif.d.ts +1 -1
- package/dist/module/wallet/model.d.ts +41 -25
- package/dist/module/wallet/model.d.ts.map +1 -1
- package/dist/module/wallet/model.js +10 -14
- package/dist/module/wallet/model.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/history/getHistory.ts +17 -17
- package/src/history/interface.ts +1 -1
- package/src/interface.ts +5 -3
- package/src/network/ElectrumNetworkProvider.ts +1 -3
- package/src/network/interface.ts +2 -2
- package/src/transaction/Wif.ts +27 -23
- package/src/util/asSendRequestObject.ts +2 -2
- package/src/util/sumUtxoValue.ts +1 -1
- package/src/wallet/Base.ts +67 -72
- package/src/wallet/Cashtokens.test.headless.js +217 -162
- package/src/wallet/Cashtokens.test.ts +470 -369
- package/src/wallet/HDWallet.test.ts +36 -24
- package/src/wallet/model.ts +49 -41
|
@@ -34,27 +34,27 @@ describe(`Wallet should function in the browser`, () => {
|
|
|
34
34
|
amount: 100n,
|
|
35
35
|
});
|
|
36
36
|
|
|
37
|
-
const
|
|
38
|
-
const tokenBalance = await alice.getTokenBalance(
|
|
37
|
+
const category = genesisResponse.categories[0];
|
|
38
|
+
const tokenBalance = await alice.getTokenBalance(category);
|
|
39
39
|
expect(tokenBalance).toBe(100n);
|
|
40
|
-
const tokenUtxos = await alice.getTokenUtxos(
|
|
40
|
+
const tokenUtxos = await alice.getTokenUtxos(category);
|
|
41
41
|
expect(tokenUtxos.length).toBe(1);
|
|
42
42
|
const response = await alice.send([
|
|
43
43
|
new TokenSendRequest({
|
|
44
44
|
cashaddr: bob.cashaddr,
|
|
45
45
|
amount: 25n,
|
|
46
|
-
|
|
46
|
+
category: category,
|
|
47
47
|
}),
|
|
48
48
|
new TokenSendRequest({
|
|
49
49
|
cashaddr: alice.cashaddr,
|
|
50
50
|
amount: 25n,
|
|
51
|
-
|
|
51
|
+
category: category,
|
|
52
52
|
}),
|
|
53
53
|
]);
|
|
54
|
-
const newTokenUtxos = await alice.getTokenUtxos(
|
|
54
|
+
const newTokenUtxos = await alice.getTokenUtxos(category);
|
|
55
55
|
expect(newTokenUtxos.length).toBe(2);
|
|
56
|
-
expect(await alice.getTokenBalance(
|
|
57
|
-
expect(await bob.getTokenBalance(
|
|
56
|
+
expect(await alice.getTokenBalance(category)).toBe(75n);
|
|
57
|
+
expect(await bob.getTokenBalance(category)).toBe(25n);
|
|
58
58
|
}, process.env.ALICE_ID);
|
|
59
59
|
});
|
|
60
60
|
|
|
@@ -64,32 +64,36 @@ describe(`Wallet should function in the browser`, () => {
|
|
|
64
64
|
const bob = await RegTestWallet.newRandom();
|
|
65
65
|
const genesisResponse = await alice.tokenGenesis({
|
|
66
66
|
cashaddr: alice.cashaddr,
|
|
67
|
-
|
|
68
|
-
|
|
67
|
+
nft: {
|
|
68
|
+
capability: NFTCapability.mutable,
|
|
69
|
+
commitment: "abcd",
|
|
70
|
+
},
|
|
69
71
|
});
|
|
70
72
|
|
|
71
|
-
const
|
|
72
|
-
const tokenBalance = await alice.getTokenBalance(
|
|
73
|
+
const category = genesisResponse.categories[0];
|
|
74
|
+
const tokenBalance = await alice.getTokenBalance(category);
|
|
73
75
|
expect(tokenBalance).toBe(0n);
|
|
74
|
-
const tokenUtxos = await alice.getTokenUtxos(
|
|
76
|
+
const tokenUtxos = await alice.getTokenUtxos(category);
|
|
75
77
|
expect(tokenUtxos.length).toBe(1);
|
|
76
78
|
const response = await alice.send([
|
|
77
79
|
new TokenSendRequest({
|
|
78
80
|
cashaddr: bob.cashaddr,
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
81
|
+
category: category,
|
|
82
|
+
nft: {
|
|
83
|
+
capability: NFTCapability.mutable,
|
|
84
|
+
commitment: "abcd",
|
|
85
|
+
},
|
|
82
86
|
}),
|
|
83
87
|
]);
|
|
84
|
-
expect(await alice.getTokenBalance(
|
|
85
|
-
const newTokenUtxos = await alice.getTokenUtxos(
|
|
88
|
+
expect(await alice.getTokenBalance(category)).toBe(0n);
|
|
89
|
+
const newTokenUtxos = await alice.getTokenUtxos(category);
|
|
86
90
|
expect(newTokenUtxos.length).toBe(0);
|
|
87
91
|
|
|
88
|
-
expect(await bob.getTokenBalance(
|
|
89
|
-
const bobTokenUtxos = await bob.getTokenUtxos(
|
|
92
|
+
expect(await bob.getTokenBalance(category)).toBe(0n);
|
|
93
|
+
const bobTokenUtxos = await bob.getTokenUtxos(category);
|
|
90
94
|
expect(bobTokenUtxos.length).toBe(1);
|
|
91
|
-
expect(
|
|
92
|
-
expect(bobTokenUtxos[0].token?.commitment).toEqual("abcd");
|
|
95
|
+
expect(category).toEqual(response.categories[0]);
|
|
96
|
+
expect(bobTokenUtxos[0].token?.nft?.commitment).toEqual("abcd");
|
|
93
97
|
}, process.env.ALICE_ID);
|
|
94
98
|
});
|
|
95
99
|
|
|
@@ -98,21 +102,26 @@ describe(`Wallet should function in the browser`, () => {
|
|
|
98
102
|
const alice = await RegTestWallet.fromId(id);
|
|
99
103
|
const genesisResponse = await alice.tokenGenesis({
|
|
100
104
|
cashaddr: alice.cashaddr,
|
|
101
|
-
|
|
102
|
-
|
|
105
|
+
nft: {
|
|
106
|
+
capability: NFTCapability.none,
|
|
107
|
+
commitment: "abcd",
|
|
108
|
+
},
|
|
103
109
|
});
|
|
104
110
|
|
|
105
|
-
const
|
|
106
|
-
const tokenBalance = await alice.getTokenBalance(
|
|
111
|
+
const category = genesisResponse.categories[0];
|
|
112
|
+
const tokenBalance = await alice.getTokenBalance(category);
|
|
107
113
|
expect(tokenBalance).toBe(0n);
|
|
108
|
-
const tokenUtxos = await alice.getTokenUtxos(
|
|
114
|
+
const tokenUtxos = await alice.getTokenUtxos(category);
|
|
109
115
|
expect(tokenUtxos.length).toBe(1);
|
|
110
116
|
await expect(
|
|
111
117
|
alice.send([
|
|
112
118
|
new TokenSendRequest({
|
|
113
119
|
cashaddr: alice.cashaddr,
|
|
114
|
-
|
|
115
|
-
|
|
120
|
+
category: category,
|
|
121
|
+
nft: {
|
|
122
|
+
capability: NFTCapability.none,
|
|
123
|
+
commitment: "abcd02",
|
|
124
|
+
},
|
|
116
125
|
}),
|
|
117
126
|
])
|
|
118
127
|
).rejects.toThrow("No suitable token utxos available to send token");
|
|
@@ -124,28 +133,32 @@ describe(`Wallet should function in the browser`, () => {
|
|
|
124
133
|
const alice = await RegTestWallet.fromId(id);
|
|
125
134
|
const genesisResponse = await alice.tokenGenesis({
|
|
126
135
|
cashaddr: alice.cashaddr,
|
|
127
|
-
|
|
128
|
-
|
|
136
|
+
nft: {
|
|
137
|
+
capability: NFTCapability.mutable,
|
|
138
|
+
commitment: "abcd",
|
|
139
|
+
},
|
|
129
140
|
});
|
|
130
141
|
|
|
131
|
-
const
|
|
132
|
-
const tokenBalance = await alice.getTokenBalance(
|
|
142
|
+
const category = genesisResponse.categories[0];
|
|
143
|
+
const tokenBalance = await alice.getTokenBalance(category);
|
|
133
144
|
expect(tokenBalance).toBe(0n);
|
|
134
|
-
const tokenUtxos = await alice.getTokenUtxos(
|
|
145
|
+
const tokenUtxos = await alice.getTokenUtxos(category);
|
|
135
146
|
expect(tokenUtxos.length).toBe(1);
|
|
136
147
|
const response = await alice.send([
|
|
137
148
|
new TokenSendRequest({
|
|
138
149
|
cashaddr: alice.cashaddr,
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
150
|
+
category: category,
|
|
151
|
+
nft: {
|
|
152
|
+
capability: NFTCapability.mutable,
|
|
153
|
+
commitment: "abcd02",
|
|
154
|
+
},
|
|
142
155
|
}),
|
|
143
156
|
]);
|
|
144
|
-
expect(await alice.getTokenBalance(
|
|
145
|
-
const newTokenUtxos = await alice.getTokenUtxos(
|
|
157
|
+
expect(await alice.getTokenBalance(category)).toBe(0n);
|
|
158
|
+
const newTokenUtxos = await alice.getTokenUtxos(category);
|
|
146
159
|
expect(newTokenUtxos.length).toBe(1);
|
|
147
|
-
expect(
|
|
148
|
-
expect(newTokenUtxos[0].token?.commitment).toEqual("abcd02");
|
|
160
|
+
expect(category).toEqual(response.categories[0]);
|
|
161
|
+
expect(newTokenUtxos[0].token?.nft?.commitment).toEqual("abcd02");
|
|
149
162
|
}, process.env.ALICE_ID);
|
|
150
163
|
});
|
|
151
164
|
|
|
@@ -154,31 +167,37 @@ describe(`Wallet should function in the browser`, () => {
|
|
|
154
167
|
const alice = await RegTestWallet.fromId(id);
|
|
155
168
|
const genesisResponse = await alice.tokenGenesis({
|
|
156
169
|
cashaddr: alice.cashaddr,
|
|
157
|
-
|
|
158
|
-
|
|
170
|
+
nft: {
|
|
171
|
+
capability: NFTCapability.minting,
|
|
172
|
+
commitment: "abcd",
|
|
173
|
+
},
|
|
159
174
|
});
|
|
160
175
|
|
|
161
|
-
const
|
|
162
|
-
const tokenBalance = await alice.getTokenBalance(
|
|
176
|
+
const category = genesisResponse.categories[0];
|
|
177
|
+
const tokenBalance = await alice.getTokenBalance(category);
|
|
163
178
|
expect(tokenBalance).toBe(0n);
|
|
164
|
-
const tokenUtxos = await alice.getTokenUtxos(
|
|
179
|
+
const tokenUtxos = await alice.getTokenUtxos(category);
|
|
165
180
|
expect(tokenUtxos.length).toBe(1);
|
|
166
|
-
const response = await alice.tokenMint(
|
|
181
|
+
const response = await alice.tokenMint(category, [
|
|
167
182
|
new TokenMintRequest({
|
|
168
183
|
cashaddr: alice.cashaddr,
|
|
169
|
-
|
|
170
|
-
|
|
184
|
+
nft: {
|
|
185
|
+
capability: NFTCapability.none,
|
|
186
|
+
commitment: "test",
|
|
187
|
+
},
|
|
171
188
|
}),
|
|
172
189
|
new TokenMintRequest({
|
|
173
190
|
cashaddr: alice.cashaddr,
|
|
174
|
-
|
|
175
|
-
|
|
191
|
+
nft: {
|
|
192
|
+
capability: NFTCapability.none,
|
|
193
|
+
commitment: "test2",
|
|
194
|
+
},
|
|
176
195
|
}),
|
|
177
196
|
]);
|
|
178
|
-
expect(await alice.getTokenBalance(
|
|
179
|
-
const newTokenUtxos = await alice.getTokenUtxos(
|
|
197
|
+
expect(await alice.getTokenBalance(category)).toBe(0n);
|
|
198
|
+
const newTokenUtxos = await alice.getTokenUtxos(category);
|
|
180
199
|
expect(newTokenUtxos.length).toBe(3);
|
|
181
|
-
expect(
|
|
200
|
+
expect(category).toEqual(response.categories[0]);
|
|
182
201
|
}, process.env.ALICE_ID);
|
|
183
202
|
});
|
|
184
203
|
|
|
@@ -188,87 +207,103 @@ describe(`Wallet should function in the browser`, () => {
|
|
|
188
207
|
const genesisResponse = await alice.tokenGenesis({
|
|
189
208
|
cashaddr: alice.cashaddr,
|
|
190
209
|
amount: 4n,
|
|
191
|
-
|
|
192
|
-
|
|
210
|
+
nft: {
|
|
211
|
+
capability: NFTCapability.minting,
|
|
212
|
+
commitment: "abcd",
|
|
213
|
+
},
|
|
193
214
|
});
|
|
194
215
|
|
|
195
|
-
const
|
|
196
|
-
const tokenBalance = await alice.getTokenBalance(
|
|
216
|
+
const category = genesisResponse.categories[0];
|
|
217
|
+
const tokenBalance = await alice.getTokenBalance(category);
|
|
197
218
|
expect(tokenBalance).toBe(4n);
|
|
198
|
-
const tokenUtxos = await alice.getTokenUtxos(
|
|
219
|
+
const tokenUtxos = await alice.getTokenUtxos(category);
|
|
199
220
|
expect(tokenUtxos.length).toBe(1);
|
|
200
221
|
|
|
201
222
|
// mint 2 NFTs, defaults to amount reducing
|
|
202
223
|
const response = await alice.tokenMint(
|
|
203
|
-
|
|
224
|
+
category,
|
|
204
225
|
[
|
|
205
226
|
new TokenMintRequest({
|
|
206
227
|
cashaddr: alice.cashaddr,
|
|
207
|
-
|
|
208
|
-
|
|
228
|
+
nft: {
|
|
229
|
+
capability: NFTCapability.none,
|
|
230
|
+
commitment: "0a",
|
|
231
|
+
},
|
|
209
232
|
}),
|
|
210
233
|
new TokenMintRequest({
|
|
211
234
|
cashaddr: alice.cashaddr,
|
|
212
|
-
|
|
213
|
-
|
|
235
|
+
nft: {
|
|
236
|
+
capability: NFTCapability.none,
|
|
237
|
+
commitment: "0b",
|
|
238
|
+
},
|
|
214
239
|
}),
|
|
215
240
|
],
|
|
216
241
|
true
|
|
217
242
|
);
|
|
218
|
-
expect(await alice.getTokenBalance(
|
|
219
|
-
const newTokenUtxos = await alice.getTokenUtxos(
|
|
243
|
+
expect(await alice.getTokenBalance(category)).toBe(2n);
|
|
244
|
+
const newTokenUtxos = await alice.getTokenUtxos(category);
|
|
220
245
|
expect(newTokenUtxos.length).toBe(3);
|
|
221
|
-
expect(
|
|
246
|
+
expect(category).toEqual(response.categories[0]);
|
|
222
247
|
|
|
223
248
|
// mint 2 more NFTs without amount reducing
|
|
224
249
|
const ftResponse = await alice.tokenMint(
|
|
225
|
-
|
|
250
|
+
category,
|
|
226
251
|
[
|
|
227
252
|
new TokenMintRequest({
|
|
228
253
|
cashaddr: alice.cashaddr,
|
|
229
|
-
|
|
230
|
-
|
|
254
|
+
nft: {
|
|
255
|
+
capability: NFTCapability.none,
|
|
256
|
+
commitment: "0c",
|
|
257
|
+
},
|
|
231
258
|
}),
|
|
232
259
|
new TokenMintRequest({
|
|
233
260
|
cashaddr: alice.cashaddr,
|
|
234
|
-
|
|
235
|
-
|
|
261
|
+
nft: {
|
|
262
|
+
capability: NFTCapability.none,
|
|
263
|
+
commitment: "0d",
|
|
264
|
+
},
|
|
236
265
|
}),
|
|
237
266
|
],
|
|
238
267
|
false
|
|
239
268
|
);
|
|
240
|
-
expect(await alice.getTokenBalance(
|
|
241
|
-
const ftTokenUtxos = await alice.getTokenUtxos(
|
|
269
|
+
expect(await alice.getTokenBalance(category)).toBe(2n);
|
|
270
|
+
const ftTokenUtxos = await alice.getTokenUtxos(category);
|
|
242
271
|
expect(ftTokenUtxos.length).toBe(5);
|
|
243
|
-
expect(
|
|
272
|
+
expect(category).toEqual(ftResponse.categories[0]);
|
|
244
273
|
|
|
245
274
|
// we are going to hit amount -1, when minting 3 more NFTs
|
|
246
275
|
// check that it will stop at 0
|
|
247
276
|
const ft2Response = await alice.tokenMint(
|
|
248
|
-
|
|
277
|
+
category,
|
|
249
278
|
[
|
|
250
279
|
new TokenMintRequest({
|
|
251
280
|
cashaddr: alice.cashaddr,
|
|
252
|
-
|
|
253
|
-
|
|
281
|
+
nft: {
|
|
282
|
+
capability: NFTCapability.none,
|
|
283
|
+
commitment: "0a",
|
|
284
|
+
},
|
|
254
285
|
}),
|
|
255
286
|
new TokenMintRequest({
|
|
256
287
|
cashaddr: alice.cashaddr,
|
|
257
|
-
|
|
258
|
-
|
|
288
|
+
nft: {
|
|
289
|
+
capability: NFTCapability.none,
|
|
290
|
+
commitment: "0a",
|
|
291
|
+
},
|
|
259
292
|
}),
|
|
260
293
|
new TokenMintRequest({
|
|
261
294
|
cashaddr: alice.cashaddr,
|
|
262
|
-
|
|
263
|
-
|
|
295
|
+
nft: {
|
|
296
|
+
capability: NFTCapability.none,
|
|
297
|
+
commitment: "0a",
|
|
298
|
+
},
|
|
264
299
|
}),
|
|
265
300
|
],
|
|
266
301
|
true
|
|
267
302
|
);
|
|
268
|
-
expect(await alice.getTokenBalance(
|
|
269
|
-
const ft2TokenUtxos = await alice.getTokenUtxos(
|
|
303
|
+
expect(await alice.getTokenBalance(category)).toBe(0n);
|
|
304
|
+
const ft2TokenUtxos = await alice.getTokenUtxos(category);
|
|
270
305
|
expect(ft2TokenUtxos.length).toBe(8);
|
|
271
|
-
expect(
|
|
306
|
+
expect(category).toEqual(ft2Response.categories[0]);
|
|
272
307
|
}, process.env.ALICE_ID);
|
|
273
308
|
});
|
|
274
309
|
|
|
@@ -280,16 +315,16 @@ describe(`Wallet should function in the browser`, () => {
|
|
|
280
315
|
amount: 4n,
|
|
281
316
|
});
|
|
282
317
|
|
|
283
|
-
const
|
|
284
|
-
const tokenBalance = await alice.getTokenBalance(
|
|
318
|
+
const category = genesisResponse.categories[0];
|
|
319
|
+
const tokenBalance = await alice.getTokenBalance(category);
|
|
285
320
|
expect(tokenBalance).toBe(4n);
|
|
286
|
-
const tokenUtxos = await alice.getTokenUtxos(
|
|
321
|
+
const tokenUtxos = await alice.getTokenUtxos(category);
|
|
287
322
|
expect(tokenUtxos.length).toBe(1);
|
|
288
323
|
|
|
289
324
|
// burn 5 FT
|
|
290
325
|
const response = await alice.tokenBurn(
|
|
291
326
|
{
|
|
292
|
-
|
|
327
|
+
category: category,
|
|
293
328
|
amount: 5n,
|
|
294
329
|
},
|
|
295
330
|
"burn"
|
|
@@ -301,10 +336,10 @@ describe(`Wallet should function in the browser`, () => {
|
|
|
301
336
|
expect(rawTx.vout[0].scriptPubKey.hex).toContain(
|
|
302
337
|
binToHex(utf8ToBin("burn"))
|
|
303
338
|
);
|
|
304
|
-
expect(await alice.getTokenBalance(
|
|
305
|
-
const newTokenUtxos = await alice.getTokenUtxos(
|
|
339
|
+
expect(await alice.getTokenBalance(category)).toBe(0n);
|
|
340
|
+
const newTokenUtxos = await alice.getTokenUtxos(category);
|
|
306
341
|
expect(newTokenUtxos.length).toBe(0);
|
|
307
|
-
expect(
|
|
342
|
+
expect(category).toEqual(response.categories[0]);
|
|
308
343
|
}, process.env.ALICE_ID);
|
|
309
344
|
});
|
|
310
345
|
|
|
@@ -314,23 +349,27 @@ describe(`Wallet should function in the browser`, () => {
|
|
|
314
349
|
const genesisResponse = await alice.tokenGenesis({
|
|
315
350
|
cashaddr: alice.cashaddr,
|
|
316
351
|
amount: 4n,
|
|
317
|
-
|
|
318
|
-
|
|
352
|
+
nft: {
|
|
353
|
+
capability: NFTCapability.minting,
|
|
354
|
+
commitment: "abcd",
|
|
355
|
+
},
|
|
319
356
|
});
|
|
320
357
|
|
|
321
|
-
const
|
|
322
|
-
const tokenBalance = await alice.getTokenBalance(
|
|
358
|
+
const category = genesisResponse.categories[0];
|
|
359
|
+
const tokenBalance = await alice.getTokenBalance(category);
|
|
323
360
|
expect(tokenBalance).toBe(4n);
|
|
324
|
-
const tokenUtxos = await alice.getTokenUtxos(
|
|
361
|
+
const tokenUtxos = await alice.getTokenUtxos(category);
|
|
325
362
|
expect(tokenUtxos.length).toBe(1);
|
|
326
363
|
|
|
327
364
|
// burn 1 FT
|
|
328
365
|
const response = await alice.tokenBurn(
|
|
329
366
|
{
|
|
330
|
-
|
|
367
|
+
category: category,
|
|
331
368
|
amount: 1n,
|
|
332
|
-
|
|
333
|
-
|
|
369
|
+
nft: {
|
|
370
|
+
capability: NFTCapability.minting,
|
|
371
|
+
commitment: "abcd",
|
|
372
|
+
},
|
|
334
373
|
},
|
|
335
374
|
"burn"
|
|
336
375
|
);
|
|
@@ -341,45 +380,49 @@ describe(`Wallet should function in the browser`, () => {
|
|
|
341
380
|
expect(rawTx.vout[0].scriptPubKey.hex).toContain(
|
|
342
381
|
binToHex(utf8ToBin("burn"))
|
|
343
382
|
);
|
|
344
|
-
expect(await alice.getTokenBalance(
|
|
345
|
-
expect((await alice.getAllTokenBalances())[
|
|
346
|
-
const newTokenUtxos = await alice.getTokenUtxos(
|
|
383
|
+
expect(await alice.getTokenBalance(category)).toBe(3n);
|
|
384
|
+
expect((await alice.getAllTokenBalances())[category]).toBe(3n);
|
|
385
|
+
const newTokenUtxos = await alice.getTokenUtxos(category);
|
|
347
386
|
expect(newTokenUtxos.length).toBe(1);
|
|
348
|
-
expect(await alice.getNftTokenBalance(
|
|
349
|
-
expect((await alice.getAllNftTokenBalances())[
|
|
350
|
-
expect(
|
|
387
|
+
expect(await alice.getNftTokenBalance(category)).toBe(1);
|
|
388
|
+
expect((await alice.getAllNftTokenBalances())[category || 0]).toBe(1);
|
|
389
|
+
expect(category).toEqual(response.categories[0]);
|
|
351
390
|
|
|
352
391
|
// burn the rest FTs
|
|
353
392
|
const ftResponse = await alice.tokenBurn(
|
|
354
393
|
{
|
|
355
|
-
|
|
394
|
+
category: category,
|
|
356
395
|
amount: 5n,
|
|
357
|
-
|
|
358
|
-
|
|
396
|
+
nft: {
|
|
397
|
+
capability: NFTCapability.minting,
|
|
398
|
+
commitment: "abcd",
|
|
399
|
+
},
|
|
359
400
|
},
|
|
360
401
|
"burn"
|
|
361
402
|
);
|
|
362
|
-
expect(await alice.getTokenBalance(
|
|
363
|
-
const ftTokenUtxos = await alice.getTokenUtxos(
|
|
403
|
+
expect(await alice.getTokenBalance(category)).toBe(0n);
|
|
404
|
+
const ftTokenUtxos = await alice.getTokenUtxos(category);
|
|
364
405
|
expect(ftTokenUtxos.length).toBe(1);
|
|
365
|
-
expect(
|
|
406
|
+
expect(category).toEqual(ftResponse.categories[0]);
|
|
366
407
|
|
|
367
408
|
// burn the NFT too
|
|
368
409
|
const nftResponse = await alice.tokenBurn(
|
|
369
410
|
{
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
411
|
+
category: category,
|
|
412
|
+
nft: {
|
|
413
|
+
capability: NFTCapability.minting,
|
|
414
|
+
commitment: "abcd",
|
|
415
|
+
},
|
|
373
416
|
},
|
|
374
417
|
"burn"
|
|
375
418
|
);
|
|
376
|
-
expect(await alice.getTokenBalance(
|
|
377
|
-
expect((await alice.getAllTokenBalances())[
|
|
378
|
-
const nftTokenUtxos = await alice.getTokenUtxos(
|
|
419
|
+
expect(await alice.getTokenBalance(category)).toBe(0n);
|
|
420
|
+
expect((await alice.getAllTokenBalances())[category] || 0n).toBe(0n);
|
|
421
|
+
const nftTokenUtxos = await alice.getTokenUtxos(category);
|
|
379
422
|
expect(nftTokenUtxos.length).toBe(0);
|
|
380
|
-
expect(
|
|
381
|
-
expect(await alice.getNftTokenBalance(
|
|
382
|
-
expect((await alice.getAllNftTokenBalances())[
|
|
423
|
+
expect(category).toEqual(nftResponse.categories[0]);
|
|
424
|
+
expect(await alice.getNftTokenBalance(category)).toBe(0);
|
|
425
|
+
expect((await alice.getAllNftTokenBalances())[category] || 0n).toBe(0n);
|
|
383
426
|
}, process.env.ALICE_ID);
|
|
384
427
|
});
|
|
385
428
|
|
|
@@ -393,10 +436,10 @@ describe(`Wallet should function in the browser`, () => {
|
|
|
393
436
|
cashaddr: bob.cashaddr,
|
|
394
437
|
});
|
|
395
438
|
|
|
396
|
-
const
|
|
397
|
-
const tokenBalance = await bob.getTokenBalance(
|
|
439
|
+
const category = genesisResponse.categories[0];
|
|
440
|
+
const tokenBalance = await bob.getTokenBalance(category);
|
|
398
441
|
expect(tokenBalance).toBe(100n);
|
|
399
|
-
const tokenUtxos = await bob.getTokenUtxos(
|
|
442
|
+
const tokenUtxos = await bob.getTokenUtxos(category);
|
|
400
443
|
expect(tokenUtxos.length).toBe(1);
|
|
401
444
|
expect(tokenUtxos[0].satoshis).toBe(7000n);
|
|
402
445
|
|
|
@@ -405,13 +448,13 @@ describe(`Wallet should function in the browser`, () => {
|
|
|
405
448
|
new TokenSendRequest({
|
|
406
449
|
cashaddr: bob.cashaddr,
|
|
407
450
|
amount: 100,
|
|
408
|
-
|
|
451
|
+
category: category,
|
|
409
452
|
value: 1500n,
|
|
410
453
|
}),
|
|
411
454
|
]);
|
|
412
|
-
let newTokenUtxos = await bob.getTokenUtxos(
|
|
455
|
+
let newTokenUtxos = await bob.getTokenUtxos(category);
|
|
413
456
|
expect(newTokenUtxos.length).toBe(1);
|
|
414
|
-
expect(await bob.getTokenBalance(
|
|
457
|
+
expect(await bob.getTokenBalance(category)).toBe(100n);
|
|
415
458
|
|
|
416
459
|
let bobUtxos = await bob.getAddressUtxos(bob.cashaddr);
|
|
417
460
|
expect(bobUtxos.length).toBe(2);
|
|
@@ -423,13 +466,13 @@ describe(`Wallet should function in the browser`, () => {
|
|
|
423
466
|
new TokenSendRequest({
|
|
424
467
|
cashaddr: bob.cashaddr,
|
|
425
468
|
amount: 100,
|
|
426
|
-
|
|
469
|
+
category: category,
|
|
427
470
|
value: 3000n,
|
|
428
471
|
}),
|
|
429
472
|
]);
|
|
430
|
-
newTokenUtxos = await bob.getTokenUtxos(
|
|
473
|
+
newTokenUtxos = await bob.getTokenUtxos(category);
|
|
431
474
|
expect(newTokenUtxos.length).toBe(1);
|
|
432
|
-
expect(await bob.getTokenBalance(
|
|
475
|
+
expect(await bob.getTokenBalance(category)).toBe(100n);
|
|
433
476
|
|
|
434
477
|
bobUtxos = await bob.getAddressUtxos(bob.cashaddr);
|
|
435
478
|
expect(bobUtxos.length).toBe(2);
|
|
@@ -446,15 +489,17 @@ describe(`Wallet should function in the browser`, () => {
|
|
|
446
489
|
const genesisResponse = await alice.tokenGenesis({
|
|
447
490
|
amount: 100,
|
|
448
491
|
value: 5000n,
|
|
449
|
-
|
|
450
|
-
|
|
492
|
+
nft: {
|
|
493
|
+
capability: NFTCapability.minting,
|
|
494
|
+
commitment: "test",
|
|
495
|
+
},
|
|
451
496
|
cashaddr: alice.cashaddr,
|
|
452
497
|
});
|
|
453
498
|
|
|
454
|
-
const
|
|
455
|
-
const tokenBalance = await alice.getTokenBalance(
|
|
499
|
+
const category = genesisResponse.categories[0];
|
|
500
|
+
const tokenBalance = await alice.getTokenBalance(category);
|
|
456
501
|
expect(tokenBalance).toBe(100n);
|
|
457
|
-
const tokenUtxos = await alice.getTokenUtxos(
|
|
502
|
+
const tokenUtxos = await alice.getTokenUtxos(category);
|
|
458
503
|
expect(tokenUtxos.length).toBe(1);
|
|
459
504
|
expect(tokenUtxos[0].satoshis).toBe(5000n);
|
|
460
505
|
|
|
@@ -465,21 +510,23 @@ describe(`Wallet should function in the browser`, () => {
|
|
|
465
510
|
new TokenSendRequest({
|
|
466
511
|
cashaddr: bob.cashaddr,
|
|
467
512
|
amount: 100,
|
|
468
|
-
|
|
513
|
+
category: category,
|
|
469
514
|
value: 1500n,
|
|
470
|
-
|
|
471
|
-
|
|
515
|
+
nft: {
|
|
516
|
+
capability: NFTCapability.minting,
|
|
517
|
+
commitment: "test",
|
|
518
|
+
},
|
|
472
519
|
}),
|
|
473
520
|
]),
|
|
474
521
|
0
|
|
475
522
|
);
|
|
476
523
|
|
|
477
|
-
const cancel = await bob.watchTokenBalance(
|
|
524
|
+
const cancel = await bob.watchTokenBalance(category, (balance) => {
|
|
478
525
|
seenBalance = balance;
|
|
479
526
|
});
|
|
480
527
|
|
|
481
528
|
const [balance, _] = await Promise.all([
|
|
482
|
-
bob.waitForTokenBalance(
|
|
529
|
+
bob.waitForTokenBalance(category, 100),
|
|
483
530
|
delay(1000),
|
|
484
531
|
]);
|
|
485
532
|
|
|
@@ -515,15 +562,17 @@ describe(`Wallet should function in the browser`, () => {
|
|
|
515
562
|
aliceWallet.cashaddr
|
|
516
563
|
);
|
|
517
564
|
|
|
518
|
-
let
|
|
565
|
+
let category;
|
|
519
566
|
{
|
|
520
567
|
const aliceUtxos = await aliceWallet.getAddressUtxos();
|
|
521
568
|
|
|
522
|
-
const { unsignedTransaction, sourceOutputs,
|
|
569
|
+
const { unsignedTransaction, sourceOutputs, categories } =
|
|
523
570
|
await aliceWatchWallet.tokenGenesis(
|
|
524
571
|
{
|
|
525
|
-
|
|
526
|
-
|
|
572
|
+
nft: {
|
|
573
|
+
capability: "minting",
|
|
574
|
+
commitment: "00",
|
|
575
|
+
},
|
|
527
576
|
},
|
|
528
577
|
undefined,
|
|
529
578
|
{ buildUnsigned: true }
|
|
@@ -553,12 +602,14 @@ describe(`Wallet should function in the browser`, () => {
|
|
|
553
602
|
);
|
|
554
603
|
await aliceWallet.submitTransaction(signed);
|
|
555
604
|
|
|
556
|
-
|
|
605
|
+
category = categories[0];
|
|
557
606
|
|
|
558
|
-
expect(await aliceWallet.getNftTokenBalance(
|
|
559
|
-
const tokenUtxos = await aliceWallet.getTokenUtxos(
|
|
607
|
+
expect(await aliceWallet.getNftTokenBalance(category)).toBe(1);
|
|
608
|
+
const tokenUtxos = await aliceWallet.getTokenUtxos(category);
|
|
560
609
|
expect(tokenUtxos.length).toBe(1);
|
|
561
|
-
expect(tokenUtxos[0].token?.capability).toBe(
|
|
610
|
+
expect(tokenUtxos[0].token?.nft?.capability).toBe(
|
|
611
|
+
NFTCapability.minting
|
|
612
|
+
);
|
|
562
613
|
}
|
|
563
614
|
|
|
564
615
|
{
|
|
@@ -566,10 +617,12 @@ describe(`Wallet should function in the browser`, () => {
|
|
|
566
617
|
|
|
567
618
|
const { unsignedTransaction, sourceOutputs } =
|
|
568
619
|
await aliceWatchWallet.tokenMint(
|
|
569
|
-
|
|
620
|
+
category,
|
|
570
621
|
{
|
|
571
|
-
|
|
572
|
-
|
|
622
|
+
nft: {
|
|
623
|
+
capability: "none",
|
|
624
|
+
commitment: "0a",
|
|
625
|
+
},
|
|
573
626
|
},
|
|
574
627
|
undefined,
|
|
575
628
|
{ buildUnsigned: true }
|
|
@@ -601,17 +654,17 @@ describe(`Wallet should function in the browser`, () => {
|
|
|
601
654
|
);
|
|
602
655
|
await aliceWallet.submitTransaction(signed);
|
|
603
656
|
|
|
604
|
-
expect(await aliceWallet.getNftTokenBalance(
|
|
605
|
-
const tokenUtxos = await aliceWallet.getTokenUtxos(
|
|
657
|
+
expect(await aliceWallet.getNftTokenBalance(category)).toBe(2);
|
|
658
|
+
const tokenUtxos = await aliceWallet.getTokenUtxos(category);
|
|
606
659
|
expect(tokenUtxos.length).toBe(2);
|
|
607
660
|
expect(
|
|
608
661
|
tokenUtxos.filter(
|
|
609
|
-
(val) => val.token?.capability === NFTCapability.minting
|
|
662
|
+
(val) => val.token?.nft?.capability === NFTCapability.minting
|
|
610
663
|
).length
|
|
611
664
|
).toBe(1);
|
|
612
665
|
expect(
|
|
613
666
|
tokenUtxos.filter(
|
|
614
|
-
(val) => val.token?.capability === NFTCapability.none
|
|
667
|
+
(val) => val.token?.nft?.capability === NFTCapability.none
|
|
615
668
|
).length
|
|
616
669
|
).toBe(1);
|
|
617
670
|
}
|
|
@@ -623,9 +676,11 @@ describe(`Wallet should function in the browser`, () => {
|
|
|
623
676
|
await aliceWatchWallet.send(
|
|
624
677
|
[
|
|
625
678
|
new TokenSendRequest({
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
679
|
+
category: category,
|
|
680
|
+
nft: {
|
|
681
|
+
capability: "none",
|
|
682
|
+
commitment: "0a",
|
|
683
|
+
},
|
|
629
684
|
cashaddr: aliceWallet.cashaddr,
|
|
630
685
|
}),
|
|
631
686
|
],
|
|
@@ -656,17 +711,17 @@ describe(`Wallet should function in the browser`, () => {
|
|
|
656
711
|
sourceOutputs
|
|
657
712
|
);
|
|
658
713
|
await aliceWallet.submitTransaction(signed);
|
|
659
|
-
expect(await aliceWallet.getNftTokenBalance(
|
|
660
|
-
const tokenUtxos = await aliceWallet.getTokenUtxos(
|
|
714
|
+
expect(await aliceWallet.getNftTokenBalance(category)).toBe(2);
|
|
715
|
+
const tokenUtxos = await aliceWallet.getTokenUtxos(category);
|
|
661
716
|
expect(tokenUtxos.length).toBe(2);
|
|
662
717
|
expect(
|
|
663
718
|
tokenUtxos.filter(
|
|
664
|
-
(val) => val.token?.capability === NFTCapability.minting
|
|
719
|
+
(val) => val.token?.nft?.capability === NFTCapability.minting
|
|
665
720
|
).length
|
|
666
721
|
).toBe(1);
|
|
667
722
|
expect(
|
|
668
723
|
tokenUtxos.filter(
|
|
669
|
-
(val) => val.token?.capability === NFTCapability.none
|
|
724
|
+
(val) => val.token?.nft?.capability === NFTCapability.none
|
|
670
725
|
).length
|
|
671
726
|
).toBe(1);
|
|
672
727
|
}
|