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.
Files changed (46) hide show
  1. package/dist/index.html +1 -1
  2. package/dist/{mainnet-3.0.0-next.1.js → mainnet-3.0.0-next.2.js} +7 -7
  3. package/dist/module/history/getHistory.js +17 -17
  4. package/dist/module/history/getHistory.js.map +1 -1
  5. package/dist/module/history/interface.d.ts +1 -1
  6. package/dist/module/history/interface.d.ts.map +1 -1
  7. package/dist/module/interface.d.ts +5 -3
  8. package/dist/module/interface.d.ts.map +1 -1
  9. package/dist/module/interface.js.map +1 -1
  10. package/dist/module/network/ElectrumNetworkProvider.d.ts.map +1 -1
  11. package/dist/module/network/ElectrumNetworkProvider.js +1 -3
  12. package/dist/module/network/ElectrumNetworkProvider.js.map +1 -1
  13. package/dist/module/network/interface.d.ts +2 -2
  14. package/dist/module/network/interface.d.ts.map +1 -1
  15. package/dist/module/transaction/Wif.d.ts.map +1 -1
  16. package/dist/module/transaction/Wif.js +25 -23
  17. package/dist/module/transaction/Wif.js.map +1 -1
  18. package/dist/module/util/asSendRequestObject.js +2 -2
  19. package/dist/module/util/asSendRequestObject.js.map +1 -1
  20. package/dist/module/util/sumUtxoValue.js +1 -1
  21. package/dist/module/util/sumUtxoValue.js.map +1 -1
  22. package/dist/module/wallet/Base.d.ts +18 -18
  23. package/dist/module/wallet/Base.d.ts.map +1 -1
  24. package/dist/module/wallet/Base.js +64 -69
  25. package/dist/module/wallet/Base.js.map +1 -1
  26. package/dist/module/wallet/HDWallet.d.ts +1 -1
  27. package/dist/module/wallet/Wif.d.ts +1 -1
  28. package/dist/module/wallet/model.d.ts +41 -25
  29. package/dist/module/wallet/model.d.ts.map +1 -1
  30. package/dist/module/wallet/model.js +10 -14
  31. package/dist/module/wallet/model.js.map +1 -1
  32. package/dist/tsconfig.tsbuildinfo +1 -1
  33. package/package.json +1 -1
  34. package/src/history/getHistory.ts +17 -17
  35. package/src/history/interface.ts +1 -1
  36. package/src/interface.ts +5 -3
  37. package/src/network/ElectrumNetworkProvider.ts +1 -3
  38. package/src/network/interface.ts +2 -2
  39. package/src/transaction/Wif.ts +27 -23
  40. package/src/util/asSendRequestObject.ts +2 -2
  41. package/src/util/sumUtxoValue.ts +1 -1
  42. package/src/wallet/Base.ts +67 -72
  43. package/src/wallet/Cashtokens.test.headless.js +217 -162
  44. package/src/wallet/Cashtokens.test.ts +470 -369
  45. package/src/wallet/HDWallet.test.ts +36 -24
  46. 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
- capability: NFTCapability.minting,
372
- commitment: "abcd",
371
+ nft: {
372
+ capability: NFTCapability.minting,
373
+ commitment: "abcd",
374
+ },
373
375
  amount: 1000n,
374
376
  });
375
377
 
376
- const tokenId = genesisResponse.tokenIds![0];
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
- capability: NFTCapability.none,
385
- commitment: "",
386
+ nft: {
387
+ capability: NFTCapability.none,
388
+ commitment: "",
389
+ },
386
390
  }),
387
391
  new TokenMintRequest({
388
392
  cashaddr: alice.getDepositAddress(3),
389
- capability: NFTCapability.mutable,
390
- commitment: "00",
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.tokenIds![0]);
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
- tokenId: tokenId,
405
- capability: NFTCapability.minting,
406
- commitment: "abcd",
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
- tokenId: tokenId,
412
- capability: NFTCapability.none,
413
- commitment: "",
419
+ category: tokenId,
420
+ nft: {
421
+ capability: NFTCapability.none,
422
+ commitment: "",
423
+ },
414
424
  }),
415
425
  new TokenSendRequest({
416
426
  cashaddr: bob.cashaddr!,
417
- tokenId: tokenId,
418
- capability: NFTCapability.mutable,
419
- commitment: "00",
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.tokenIds![0]);
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 tokenId = genesisResponse.tokenIds![0];
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, tokenId: "" }));
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
- tokenId: tokenId,
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
- tokenId: tokenId,
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
- tokenId: tokenId,
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
- tokenId: tokenId,
517
+ category: category,
506
518
  amount: 2n,
507
519
  })
508
520
  )
@@ -35,56 +35,60 @@ export class SendRequest {
35
35
 
36
36
  export class TokenGenesisRequest {
37
37
  amount?: bigint; // fungible token amount
38
- capability?: NFTCapability;
39
- commitment?: string;
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
- capability,
46
- commitment,
47
+ nft,
47
48
  cashaddr,
48
49
  value,
49
50
  }: {
50
51
  amount?: bigint;
51
- capability?: NFTCapability;
52
- commitment?: string;
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.capability = capability;
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
- tokenId: string;
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
- tokenId,
73
- capability,
74
- commitment,
76
+ category,
75
77
  amount,
78
+ nft,
76
79
  cashaddr,
77
80
  }: {
78
- tokenId: string;
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.tokenId = tokenId;
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
- tokenId: string;
97
- capability?: NFTCapability;
98
- commitment?: string;
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
- tokenId,
105
- capability,
106
- commitment,
110
+ category,
111
+ nft,
107
112
  }: {
108
113
  cashaddr: string;
109
114
  value?: bigint;
110
115
  amount?: bigint;
111
- tokenId: string;
112
- capability?: NFTCapability;
113
- commitment?: string;
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.tokenId = tokenId;
121
- this.capability = capability;
122
- this.commitment = commitment;
127
+ this.category = category;
128
+ this.nft = nft;
123
129
  }
124
130
  }
125
131
 
126
132
  export class TokenMintRequest {
127
- capability?: NFTCapability;
128
- commitment?: string;
133
+ nft?: {
134
+ capability: NFTCapability;
135
+ commitment: string;
136
+ };
129
137
  cashaddr?: string;
130
138
  value?: bigint;
131
139
 
132
140
  constructor({
133
- capability,
134
- commitment,
141
+ nft,
135
142
  cashaddr,
136
143
  value,
137
144
  }: {
138
- capability?: NFTCapability;
139
- commitment?: string;
145
+ nft?: {
146
+ capability: NFTCapability;
147
+ commitment: string;
148
+ };
140
149
  cashaddr?: string;
141
150
  value?: bigint;
142
151
  }) {
143
- this.capability = capability;
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
- tokenIds?: string[];
300
+ categories?: string[];
293
301
  unsignedTransaction?: string; // unsigned transaction hex
294
302
  sourceOutputs?: SourceOutput[]; // source outputs for signing unsigned transactions
295
303