@onekeyfe/cardano-coin-selection-asmjs 1.1.10-alpha.8 → 1.1.10

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.
@@ -91,7 +91,6 @@ const convertCborTxToEncodeTx = async ({ txHex, utxos, addresses, changeAddress,
91
91
  var _a, _b, _c, _d;
92
92
  let body;
93
93
  let rawTxHex;
94
- // console.log('CARDANO LOCAL_VERSION : 333====>>>');
95
94
  try {
96
95
  const tx = CardanoWasm.Transaction.from_bytes(Buffer.from(txHex, 'hex'));
97
96
  body = tx.body();
@@ -432,17 +432,23 @@ const txToOneKey = async (rawTx, network, initKeys, xpub, changeAddress) => {
432
432
  mintBundle = [];
433
433
  for (let j = 0; j < mint.keys().len(); j++) {
434
434
  const policy = mint.keys().get(j);
435
- const assets = mint.get(policy);
435
+ // CSL 13: Mint.get(policy) returns MintsAssets — a list, one entry per
436
+ // occurrence of that policy in the original CBOR — to preserve byte-
437
+ // level round-trip (tx hash stability). Iterate the list, then each map.
438
+ const mintsAssets = mint.get(policy);
436
439
  const tokens = [];
437
- for (let k = 0; k < assets.keys().len(); k++) {
438
- const assetName = assets.keys().get(k);
439
- const amount = assets.get(assetName);
440
- tokens.push({
441
- assetNameBytes: Buffer.from(assetName.name()).toString('hex'),
442
- mintAmount: amount.is_positive()
443
- ? amount.as_positive().to_str()
444
- : '-' + amount.as_negative().to_str(),
445
- });
440
+ for (let mai = 0; mai < mintsAssets.len(); mai++) {
441
+ const assets = mintsAssets.get(mai);
442
+ for (let k = 0; k < assets.keys().len(); k++) {
443
+ const assetName = assets.keys().get(k);
444
+ const amount = assets.get(assetName);
445
+ tokens.push({
446
+ assetNameBytes: Buffer.from(assetName.name()).toString('hex'),
447
+ mintAmount: amount.is_positive()
448
+ ? amount.as_positive().to_str()
449
+ : '-' + amount.as_negative().to_str(),
450
+ });
451
+ }
446
452
  }
447
453
  // sort canonical
448
454
  sortCanonicallyInPlace(tokens, item => item.assetNameBytes);
@@ -515,7 +521,7 @@ const txToOneKey = async (rawTx, network, initKeys, xpub, changeAddress) => {
515
521
  for (let i = 0; i < ri.len(); i++) {
516
522
  referenceInputs.push({
517
523
  prev_hash: ri.get(i).transaction_id().to_hex(),
518
- prev_index: parseInt(ri.get(i).index().to_str()),
524
+ prev_index: parseInt(String(ri.get(i).index())),
519
525
  });
520
526
  }
521
527
  signingMode = CardanoTxSigningMode.PLUTUS_TRANSACTION;
@@ -61,7 +61,6 @@ const convertCborTxToEncodeTx = async ({ txHex, utxos, addresses, changeAddress,
61
61
  var _a, _b, _c, _d;
62
62
  let body;
63
63
  let rawTxHex;
64
- // console.log('CARDANO LOCAL_VERSION : 333====>>>');
65
64
  try {
66
65
  const tx = CardanoWasm.Transaction.from_bytes(Buffer.from(txHex, 'hex'));
67
66
  body = tx.body();
@@ -406,17 +406,23 @@ export const txToOneKey = async (rawTx, network, initKeys, xpub, changeAddress)
406
406
  mintBundle = [];
407
407
  for (let j = 0; j < mint.keys().len(); j++) {
408
408
  const policy = mint.keys().get(j);
409
- const assets = mint.get(policy);
409
+ // CSL 13: Mint.get(policy) returns MintsAssets — a list, one entry per
410
+ // occurrence of that policy in the original CBOR — to preserve byte-
411
+ // level round-trip (tx hash stability). Iterate the list, then each map.
412
+ const mintsAssets = mint.get(policy);
410
413
  const tokens = [];
411
- for (let k = 0; k < assets.keys().len(); k++) {
412
- const assetName = assets.keys().get(k);
413
- const amount = assets.get(assetName);
414
- tokens.push({
415
- assetNameBytes: Buffer.from(assetName.name()).toString('hex'),
416
- mintAmount: amount.is_positive()
417
- ? amount.as_positive().to_str()
418
- : '-' + amount.as_negative().to_str(),
419
- });
414
+ for (let mai = 0; mai < mintsAssets.len(); mai++) {
415
+ const assets = mintsAssets.get(mai);
416
+ for (let k = 0; k < assets.keys().len(); k++) {
417
+ const assetName = assets.keys().get(k);
418
+ const amount = assets.get(assetName);
419
+ tokens.push({
420
+ assetNameBytes: Buffer.from(assetName.name()).toString('hex'),
421
+ mintAmount: amount.is_positive()
422
+ ? amount.as_positive().to_str()
423
+ : '-' + amount.as_negative().to_str(),
424
+ });
425
+ }
420
426
  }
421
427
  // sort canonical
422
428
  sortCanonicallyInPlace(tokens, item => item.assetNameBytes);
@@ -489,7 +495,7 @@ export const txToOneKey = async (rawTx, network, initKeys, xpub, changeAddress)
489
495
  for (let i = 0; i < ri.len(); i++) {
490
496
  referenceInputs.push({
491
497
  prev_hash: ri.get(i).transaction_id().to_hex(),
492
- prev_index: parseInt(ri.get(i).index().to_str()),
498
+ prev_index: parseInt(String(ri.get(i).index())),
493
499
  });
494
500
  }
495
501
  signingMode = CardanoTxSigningMode.PLUTUS_TRANSACTION;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onekeyfe/cardano-coin-selection-asmjs",
3
- "version": "1.1.10-alpha.8",
3
+ "version": "1.1.10",
4
4
  "description": "",
5
5
  "keywords": [
6
6
  "coin selection"