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
|
@@ -368,12 +368,14 @@ describe("HDWallet", () => {
|
|
|
368
368
|
|
|
369
369
|
const genesisResponse = await alice.tokenGenesis({
|
|
370
370
|
cashaddr: alice.getDepositAddress(1),
|
|
371
|
-
|
|
372
|
-
|
|
371
|
+
nft: {
|
|
372
|
+
capability: NFTCapability.minting,
|
|
373
|
+
commitment: "abcd",
|
|
374
|
+
},
|
|
373
375
|
amount: 1000n,
|
|
374
376
|
});
|
|
375
377
|
|
|
376
|
-
const tokenId = genesisResponse.
|
|
378
|
+
const tokenId = genesisResponse.categories![0];
|
|
377
379
|
|
|
378
380
|
await new Promise((resolve) => setTimeout(resolve, 500));
|
|
379
381
|
|
|
@@ -381,13 +383,17 @@ describe("HDWallet", () => {
|
|
|
381
383
|
const response = await alice.tokenMint(tokenId, [
|
|
382
384
|
new TokenMintRequest({
|
|
383
385
|
cashaddr: alice.getDepositAddress(2),
|
|
384
|
-
|
|
385
|
-
|
|
386
|
+
nft: {
|
|
387
|
+
capability: NFTCapability.none,
|
|
388
|
+
commitment: "",
|
|
389
|
+
},
|
|
386
390
|
}),
|
|
387
391
|
new TokenMintRequest({
|
|
388
392
|
cashaddr: alice.getDepositAddress(3),
|
|
389
|
-
|
|
390
|
-
|
|
393
|
+
nft: {
|
|
394
|
+
capability: NFTCapability.mutable,
|
|
395
|
+
commitment: "00",
|
|
396
|
+
},
|
|
391
397
|
}),
|
|
392
398
|
]);
|
|
393
399
|
|
|
@@ -395,28 +401,34 @@ describe("HDWallet", () => {
|
|
|
395
401
|
|
|
396
402
|
const newTokenUtxos = await alice.getTokenUtxos(tokenId);
|
|
397
403
|
expect(newTokenUtxos.length).toBe(3);
|
|
398
|
-
expect(tokenId).toEqual(response.
|
|
404
|
+
expect(tokenId).toEqual(response.categories![0]);
|
|
399
405
|
|
|
400
406
|
const bob = await RegTestWallet.newRandom();
|
|
401
407
|
await alice.send([
|
|
402
408
|
new TokenSendRequest({
|
|
403
409
|
cashaddr: bob.cashaddr!,
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
410
|
+
category: tokenId,
|
|
411
|
+
nft: {
|
|
412
|
+
capability: NFTCapability.minting,
|
|
413
|
+
commitment: "abcd",
|
|
414
|
+
},
|
|
407
415
|
amount: 1000n,
|
|
408
416
|
}),
|
|
409
417
|
new TokenSendRequest({
|
|
410
418
|
cashaddr: bob.cashaddr!,
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
419
|
+
category: tokenId,
|
|
420
|
+
nft: {
|
|
421
|
+
capability: NFTCapability.none,
|
|
422
|
+
commitment: "",
|
|
423
|
+
},
|
|
414
424
|
}),
|
|
415
425
|
new TokenSendRequest({
|
|
416
426
|
cashaddr: bob.cashaddr!,
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
427
|
+
category: tokenId,
|
|
428
|
+
nft: {
|
|
429
|
+
capability: NFTCapability.mutable,
|
|
430
|
+
commitment: "00",
|
|
431
|
+
},
|
|
420
432
|
}),
|
|
421
433
|
]);
|
|
422
434
|
|
|
@@ -425,7 +437,7 @@ describe("HDWallet", () => {
|
|
|
425
437
|
expect((await alice.getTokenUtxos(tokenId)).length).toBe(0);
|
|
426
438
|
const bobTokenUtxos = await bob.getTokenUtxos(tokenId);
|
|
427
439
|
expect(bobTokenUtxos.length).toBe(3);
|
|
428
|
-
expect(tokenId).toEqual(response.
|
|
440
|
+
expect(tokenId).toEqual(response.categories![0]);
|
|
429
441
|
});
|
|
430
442
|
|
|
431
443
|
test("Test enforcing token addresses", async () => {
|
|
@@ -441,7 +453,7 @@ describe("HDWallet", () => {
|
|
|
441
453
|
const genesisResponse = await alice.tokenGenesis({
|
|
442
454
|
amount: 100n,
|
|
443
455
|
});
|
|
444
|
-
const
|
|
456
|
+
const category = genesisResponse.categories![0];
|
|
445
457
|
|
|
446
458
|
await new Promise((resolve) => setTimeout(resolve, 500));
|
|
447
459
|
|
|
@@ -449,7 +461,7 @@ describe("HDWallet", () => {
|
|
|
449
461
|
|
|
450
462
|
const wrap = (addr) => {
|
|
451
463
|
return new Promise((resolve) => {
|
|
452
|
-
resolve(new TokenSendRequest({ cashaddr: addr,
|
|
464
|
+
resolve(new TokenSendRequest({ cashaddr: addr, category: "" }));
|
|
453
465
|
});
|
|
454
466
|
};
|
|
455
467
|
|
|
@@ -461,7 +473,7 @@ describe("HDWallet", () => {
|
|
|
461
473
|
alice.send(
|
|
462
474
|
new TokenSendRequest({
|
|
463
475
|
cashaddr: alice.getDepositAddress(),
|
|
464
|
-
|
|
476
|
+
category: category,
|
|
465
477
|
amount: 1n,
|
|
466
478
|
})
|
|
467
479
|
)
|
|
@@ -473,7 +485,7 @@ describe("HDWallet", () => {
|
|
|
473
485
|
alice.send(
|
|
474
486
|
new TokenSendRequest({
|
|
475
487
|
cashaddr: alice.getTokenDepositAddress(),
|
|
476
|
-
|
|
488
|
+
category: category,
|
|
477
489
|
amount: 2n,
|
|
478
490
|
})
|
|
479
491
|
)
|
|
@@ -490,7 +502,7 @@ describe("HDWallet", () => {
|
|
|
490
502
|
await alice.send(
|
|
491
503
|
new TokenSendRequest({
|
|
492
504
|
cashaddr: alice.getDepositAddress(),
|
|
493
|
-
|
|
505
|
+
category: category,
|
|
494
506
|
amount: 1n,
|
|
495
507
|
})
|
|
496
508
|
))()
|
|
@@ -502,7 +514,7 @@ describe("HDWallet", () => {
|
|
|
502
514
|
alice.send(
|
|
503
515
|
new TokenSendRequest({
|
|
504
516
|
cashaddr: alice.getTokenDepositAddress(),
|
|
505
|
-
|
|
517
|
+
category: category,
|
|
506
518
|
amount: 2n,
|
|
507
519
|
})
|
|
508
520
|
)
|
package/src/wallet/model.ts
CHANGED
|
@@ -35,56 +35,60 @@ export class SendRequest {
|
|
|
35
35
|
|
|
36
36
|
export class TokenGenesisRequest {
|
|
37
37
|
amount?: bigint; // fungible token amount
|
|
38
|
-
|
|
39
|
-
|
|
38
|
+
nft?: {
|
|
39
|
+
capability: NFTCapability;
|
|
40
|
+
commitment: string;
|
|
41
|
+
};
|
|
40
42
|
cashaddr?: string;
|
|
41
43
|
value?: bigint; // satoshi value
|
|
42
44
|
|
|
43
45
|
constructor({
|
|
44
46
|
amount,
|
|
45
|
-
|
|
46
|
-
commitment,
|
|
47
|
+
nft,
|
|
47
48
|
cashaddr,
|
|
48
49
|
value,
|
|
49
50
|
}: {
|
|
50
51
|
amount?: bigint;
|
|
51
|
-
|
|
52
|
-
|
|
52
|
+
nft?: {
|
|
53
|
+
capability: NFTCapability;
|
|
54
|
+
commitment: string;
|
|
55
|
+
};
|
|
53
56
|
cashaddr?: string;
|
|
54
57
|
value?: bigint;
|
|
55
58
|
}) {
|
|
56
59
|
this.amount = amount;
|
|
57
|
-
this.
|
|
58
|
-
this.commitment = commitment;
|
|
60
|
+
this.nft = nft;
|
|
59
61
|
this.cashaddr = cashaddr;
|
|
60
62
|
this.value = value;
|
|
61
63
|
}
|
|
62
64
|
}
|
|
63
65
|
|
|
64
66
|
export class TokenBurnRequest {
|
|
65
|
-
|
|
66
|
-
capability?: NFTCapability;
|
|
67
|
-
commitment?: string;
|
|
67
|
+
category: string;
|
|
68
68
|
amount?: bigint; // fungible token amount
|
|
69
|
+
nft?: {
|
|
70
|
+
capability: NFTCapability;
|
|
71
|
+
commitment: string;
|
|
72
|
+
};
|
|
69
73
|
cashaddr?: string;
|
|
70
74
|
|
|
71
75
|
constructor({
|
|
72
|
-
|
|
73
|
-
capability,
|
|
74
|
-
commitment,
|
|
76
|
+
category,
|
|
75
77
|
amount,
|
|
78
|
+
nft,
|
|
76
79
|
cashaddr,
|
|
77
80
|
}: {
|
|
78
|
-
|
|
79
|
-
capability?: NFTCapability;
|
|
80
|
-
commitment?: string;
|
|
81
|
+
category: string;
|
|
81
82
|
amount?: number | bigint;
|
|
82
83
|
cashaddr?: string;
|
|
84
|
+
nft?: {
|
|
85
|
+
capability: NFTCapability;
|
|
86
|
+
commitment: string;
|
|
87
|
+
};
|
|
83
88
|
}) {
|
|
84
|
-
this.
|
|
85
|
-
this.capability = capability;
|
|
86
|
-
this.commitment = commitment;
|
|
89
|
+
this.category = category;
|
|
87
90
|
this.amount = amount ? BigInt(amount) : 0n;
|
|
91
|
+
this.nft = nft;
|
|
88
92
|
this.cashaddr = cashaddr;
|
|
89
93
|
}
|
|
90
94
|
}
|
|
@@ -93,55 +97,59 @@ export class TokenSendRequest {
|
|
|
93
97
|
cashaddr: string; // cashaddr or tokenaddr to send tokens to
|
|
94
98
|
value?: bigint; // satoshi value
|
|
95
99
|
amount: bigint; // fungible token amount
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
100
|
+
category: string;
|
|
101
|
+
nft?: {
|
|
102
|
+
capability: NFTCapability;
|
|
103
|
+
commitment: string;
|
|
104
|
+
};
|
|
99
105
|
|
|
100
106
|
constructor({
|
|
101
107
|
cashaddr,
|
|
102
108
|
value,
|
|
103
109
|
amount,
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
commitment,
|
|
110
|
+
category,
|
|
111
|
+
nft,
|
|
107
112
|
}: {
|
|
108
113
|
cashaddr: string;
|
|
109
114
|
value?: bigint;
|
|
110
115
|
amount?: bigint;
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
116
|
+
category: string;
|
|
117
|
+
nft?: {
|
|
118
|
+
capability: NFTCapability;
|
|
119
|
+
commitment: string;
|
|
120
|
+
};
|
|
114
121
|
}) {
|
|
115
122
|
checkTokenaddr(cashaddr, Config.EnforceCashTokenReceiptAddresses);
|
|
116
123
|
|
|
117
124
|
this.cashaddr = cashaddr;
|
|
118
125
|
this.value = value;
|
|
119
126
|
this.amount = amount ? BigInt(amount) : 0n;
|
|
120
|
-
this.
|
|
121
|
-
this.
|
|
122
|
-
this.commitment = commitment;
|
|
127
|
+
this.category = category;
|
|
128
|
+
this.nft = nft;
|
|
123
129
|
}
|
|
124
130
|
}
|
|
125
131
|
|
|
126
132
|
export class TokenMintRequest {
|
|
127
|
-
|
|
128
|
-
|
|
133
|
+
nft?: {
|
|
134
|
+
capability: NFTCapability;
|
|
135
|
+
commitment: string;
|
|
136
|
+
};
|
|
129
137
|
cashaddr?: string;
|
|
130
138
|
value?: bigint;
|
|
131
139
|
|
|
132
140
|
constructor({
|
|
133
|
-
|
|
134
|
-
commitment,
|
|
141
|
+
nft,
|
|
135
142
|
cashaddr,
|
|
136
143
|
value,
|
|
137
144
|
}: {
|
|
138
|
-
|
|
139
|
-
|
|
145
|
+
nft?: {
|
|
146
|
+
capability: NFTCapability;
|
|
147
|
+
commitment: string;
|
|
148
|
+
};
|
|
140
149
|
cashaddr?: string;
|
|
141
150
|
value?: bigint;
|
|
142
151
|
}) {
|
|
143
|
-
this.
|
|
144
|
-
this.commitment = commitment;
|
|
152
|
+
this.nft = nft;
|
|
145
153
|
this.cashaddr = cashaddr;
|
|
146
154
|
this.value = value;
|
|
147
155
|
}
|
|
@@ -289,7 +297,7 @@ export class SendResponse {
|
|
|
289
297
|
txId?: string;
|
|
290
298
|
balance?: bigint;
|
|
291
299
|
explorerUrl?: string;
|
|
292
|
-
|
|
300
|
+
categories?: string[];
|
|
293
301
|
unsignedTransaction?: string; // unsigned transaction hex
|
|
294
302
|
sourceOutputs?: SourceOutput[]; // source outputs for signing unsigned transactions
|
|
295
303
|
|