@lucid-evolution/utils 0.1.60 → 0.1.62

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.cjs CHANGED
@@ -435,31 +435,20 @@ function validatorToRewardAddress(network, validator) {
435
435
  function getAddressDetails(address) {
436
436
  try {
437
437
  const parsedAddress = CML.BaseAddress.from_address(
438
- CML.Address.from_bech32(address)
438
+ addressFromHexOrBech32(address)
439
439
  );
440
440
  const paymentCredential = parsedAddress.payment().kind() === 0 ? {
441
441
  type: "Key",
442
- // hash: toHex(
443
- // parsedAddress.payment_cred().to_keyhash()!.to_bytes(),
444
- // ),
445
442
  hash: parsedAddress.payment().as_pub_key().to_hex()
446
443
  } : {
447
444
  type: "Script",
448
- // hash: toHex(
449
- // parsedAddress.payment_cred().to_scripthash()!.to_bytes(),
450
- // ),
451
445
  hash: parsedAddress.payment().as_script().to_hex()
452
446
  };
453
- const stakeCredential = parsedAddress.stake().kind() === 0 ? (
454
- // parsedAddress.stake_cred().kind() === 0
455
- {
456
- type: "Key",
457
- hash: parsedAddress.stake().as_pub_key().to_hex()
458
- // hash: toHex(parsedAddress.stake_cred().to_keyhash()!.to_bytes()),
459
- }
460
- ) : {
447
+ const stakeCredential = parsedAddress.stake().kind() === 0 ? {
448
+ type: "Key",
449
+ hash: parsedAddress.stake().as_pub_key().to_hex()
450
+ } : {
461
451
  type: "Script",
462
- // hash: toHex(parsedAddress.stake_cred().to_scripthash()!.to_bytes()),
463
452
  hash: parsedAddress.stake().as_script().to_hex()
464
453
  };
465
454
  return {
@@ -467,7 +456,6 @@ function getAddressDetails(address) {
467
456
  networkId: parsedAddress.to_address().network_id(),
468
457
  address: {
469
458
  bech32: parsedAddress.to_address().to_bech32(void 0),
470
- // hex: toHex(parsedAddress.to_address().to_bytes()),
471
459
  hex: parsedAddress.to_address().to_hex()
472
460
  },
473
461
  paymentCredential,
@@ -477,18 +465,14 @@ function getAddressDetails(address) {
477
465
  }
478
466
  try {
479
467
  const parsedAddress = CML.EnterpriseAddress.from_address(
480
- CML.Address.from_bech32(address)
468
+ addressFromHexOrBech32(address)
481
469
  );
482
470
  const paymentCredential = parsedAddress.payment().kind() === 0 ? {
483
471
  type: "Key",
484
- // hash: toHex(parsedAddress.payment_cred().to_keyhash()!.to_bytes()),
485
472
  hash: parsedAddress.payment().as_pub_key().to_hex()
486
473
  } : {
487
474
  type: "Script",
488
- hash: (
489
- // parsedAddress.payment_cred().to_scripthash()!.to_bytes()
490
- parsedAddress.payment().as_script().to_hex()
491
- )
475
+ hash: parsedAddress.payment().as_script().to_hex()
492
476
  };
493
477
  return {
494
478
  type: "Enterprise",
@@ -503,15 +487,13 @@ function getAddressDetails(address) {
503
487
  }
504
488
  try {
505
489
  const parsedAddress = CML.PointerAddress.from_address(
506
- CML.Address.from_bech32(address)
490
+ addressFromHexOrBech32(address)
507
491
  );
508
492
  const paymentCredential = parsedAddress?.payment().kind() === 0 ? {
509
493
  type: "Key",
510
- // hash: toHex(parsedAddress.payment_cred().to_keyhash()!.to_bytes()),
511
494
  hash: parsedAddress.payment().as_pub_key().to_hex()
512
495
  } : {
513
496
  type: "Script",
514
- // hash: toHex( parsedAddress.payment_cred().to_scripthash()!.to_bytes()),
515
497
  hash: parsedAddress.payment().as_script().to_hex()
516
498
  };
517
499
  return {
@@ -519,7 +501,6 @@ function getAddressDetails(address) {
519
501
  networkId: parsedAddress.to_address().network_id(),
520
502
  address: {
521
503
  bech32: parsedAddress.to_address().to_bech32(void 0),
522
- // hex: toHex(parsedAddress.to_address().to_bytes()),
523
504
  hex: parsedAddress.to_address().to_hex()
524
505
  },
525
506
  paymentCredential
@@ -528,7 +509,7 @@ function getAddressDetails(address) {
528
509
  }
529
510
  try {
530
511
  const parsedAddress = CML.RewardAddress.from_address(
531
- CML.Address.from_bech32(address)
512
+ addressFromHexOrBech32(address)
532
513
  );
533
514
  const stakeCredential = parsedAddress.payment().kind() === 0 ? {
534
515
  type: "Key",
@@ -542,7 +523,6 @@ function getAddressDetails(address) {
542
523
  networkId: parsedAddress.to_address().network_id(),
543
524
  address: {
544
525
  bech32: parsedAddress.to_address().to_bech32(void 0),
545
- // hex: toHex(parsedAddress.to_address().to_bytes()),
546
526
  hex: parsedAddress.to_address().to_hex()
547
527
  },
548
528
  stakeCredential
@@ -566,7 +546,6 @@ function getAddressDetails(address) {
566
546
  networkId: parsedAddress.content().network_id(),
567
547
  address: {
568
548
  bech32: "",
569
- // hex: toHex(parsedAddress.to_address().to_bytes()),
570
549
  hex: parsedAddress.to_address().to_hex()
571
550
  }
572
551
  };
@@ -1627,9 +1606,9 @@ var buildOutput = (utxo) => {
1627
1606
  return utxo.scriptRef ? buildDatum(utxo, builder).with_reference_script(toScriptRef(utxo.scriptRef)).next() : buildDatum(utxo, builder).next();
1628
1607
  };
1629
1608
  var buildDatum = (utxo, builder) => {
1630
- if (utxo.datumHash)
1631
- return builder.with_data(
1632
- CML.DatumOption.new_hash(CML.DatumHash.from_hex(utxo.datumHash))
1609
+ if (utxo.datumHash && utxo.datum)
1610
+ return builder.with_communication_data(
1611
+ CML.PlutusData.from_cbor_hex(utxo.datum)
1633
1612
  );
1634
1613
  if (utxo.datum)
1635
1614
  return builder.with_data(
package/dist/index.js CHANGED
@@ -347,31 +347,20 @@ function validatorToRewardAddress(network, validator) {
347
347
  function getAddressDetails(address) {
348
348
  try {
349
349
  const parsedAddress = CML.BaseAddress.from_address(
350
- CML.Address.from_bech32(address)
350
+ addressFromHexOrBech32(address)
351
351
  );
352
352
  const paymentCredential = parsedAddress.payment().kind() === 0 ? {
353
353
  type: "Key",
354
- // hash: toHex(
355
- // parsedAddress.payment_cred().to_keyhash()!.to_bytes(),
356
- // ),
357
354
  hash: parsedAddress.payment().as_pub_key().to_hex()
358
355
  } : {
359
356
  type: "Script",
360
- // hash: toHex(
361
- // parsedAddress.payment_cred().to_scripthash()!.to_bytes(),
362
- // ),
363
357
  hash: parsedAddress.payment().as_script().to_hex()
364
358
  };
365
- const stakeCredential = parsedAddress.stake().kind() === 0 ? (
366
- // parsedAddress.stake_cred().kind() === 0
367
- {
368
- type: "Key",
369
- hash: parsedAddress.stake().as_pub_key().to_hex()
370
- // hash: toHex(parsedAddress.stake_cred().to_keyhash()!.to_bytes()),
371
- }
372
- ) : {
359
+ const stakeCredential = parsedAddress.stake().kind() === 0 ? {
360
+ type: "Key",
361
+ hash: parsedAddress.stake().as_pub_key().to_hex()
362
+ } : {
373
363
  type: "Script",
374
- // hash: toHex(parsedAddress.stake_cred().to_scripthash()!.to_bytes()),
375
364
  hash: parsedAddress.stake().as_script().to_hex()
376
365
  };
377
366
  return {
@@ -379,7 +368,6 @@ function getAddressDetails(address) {
379
368
  networkId: parsedAddress.to_address().network_id(),
380
369
  address: {
381
370
  bech32: parsedAddress.to_address().to_bech32(void 0),
382
- // hex: toHex(parsedAddress.to_address().to_bytes()),
383
371
  hex: parsedAddress.to_address().to_hex()
384
372
  },
385
373
  paymentCredential,
@@ -389,18 +377,14 @@ function getAddressDetails(address) {
389
377
  }
390
378
  try {
391
379
  const parsedAddress = CML.EnterpriseAddress.from_address(
392
- CML.Address.from_bech32(address)
380
+ addressFromHexOrBech32(address)
393
381
  );
394
382
  const paymentCredential = parsedAddress.payment().kind() === 0 ? {
395
383
  type: "Key",
396
- // hash: toHex(parsedAddress.payment_cred().to_keyhash()!.to_bytes()),
397
384
  hash: parsedAddress.payment().as_pub_key().to_hex()
398
385
  } : {
399
386
  type: "Script",
400
- hash: (
401
- // parsedAddress.payment_cred().to_scripthash()!.to_bytes()
402
- parsedAddress.payment().as_script().to_hex()
403
- )
387
+ hash: parsedAddress.payment().as_script().to_hex()
404
388
  };
405
389
  return {
406
390
  type: "Enterprise",
@@ -415,15 +399,13 @@ function getAddressDetails(address) {
415
399
  }
416
400
  try {
417
401
  const parsedAddress = CML.PointerAddress.from_address(
418
- CML.Address.from_bech32(address)
402
+ addressFromHexOrBech32(address)
419
403
  );
420
404
  const paymentCredential = parsedAddress?.payment().kind() === 0 ? {
421
405
  type: "Key",
422
- // hash: toHex(parsedAddress.payment_cred().to_keyhash()!.to_bytes()),
423
406
  hash: parsedAddress.payment().as_pub_key().to_hex()
424
407
  } : {
425
408
  type: "Script",
426
- // hash: toHex( parsedAddress.payment_cred().to_scripthash()!.to_bytes()),
427
409
  hash: parsedAddress.payment().as_script().to_hex()
428
410
  };
429
411
  return {
@@ -431,7 +413,6 @@ function getAddressDetails(address) {
431
413
  networkId: parsedAddress.to_address().network_id(),
432
414
  address: {
433
415
  bech32: parsedAddress.to_address().to_bech32(void 0),
434
- // hex: toHex(parsedAddress.to_address().to_bytes()),
435
416
  hex: parsedAddress.to_address().to_hex()
436
417
  },
437
418
  paymentCredential
@@ -440,7 +421,7 @@ function getAddressDetails(address) {
440
421
  }
441
422
  try {
442
423
  const parsedAddress = CML.RewardAddress.from_address(
443
- CML.Address.from_bech32(address)
424
+ addressFromHexOrBech32(address)
444
425
  );
445
426
  const stakeCredential = parsedAddress.payment().kind() === 0 ? {
446
427
  type: "Key",
@@ -454,7 +435,6 @@ function getAddressDetails(address) {
454
435
  networkId: parsedAddress.to_address().network_id(),
455
436
  address: {
456
437
  bech32: parsedAddress.to_address().to_bech32(void 0),
457
- // hex: toHex(parsedAddress.to_address().to_bytes()),
458
438
  hex: parsedAddress.to_address().to_hex()
459
439
  },
460
440
  stakeCredential
@@ -478,7 +458,6 @@ function getAddressDetails(address) {
478
458
  networkId: parsedAddress.content().network_id(),
479
459
  address: {
480
460
  bech32: "",
481
- // hex: toHex(parsedAddress.to_address().to_bytes()),
482
461
  hex: parsedAddress.to_address().to_hex()
483
462
  }
484
463
  };
@@ -1543,9 +1522,9 @@ var buildOutput = (utxo) => {
1543
1522
  return utxo.scriptRef ? buildDatum(utxo, builder).with_reference_script(toScriptRef(utxo.scriptRef)).next() : buildDatum(utxo, builder).next();
1544
1523
  };
1545
1524
  var buildDatum = (utxo, builder) => {
1546
- if (utxo.datumHash)
1547
- return builder.with_data(
1548
- CML.DatumOption.new_hash(CML.DatumHash.from_hex(utxo.datumHash))
1525
+ if (utxo.datumHash && utxo.datum)
1526
+ return builder.with_communication_data(
1527
+ CML.PlutusData.from_cbor_hex(utxo.datum)
1549
1528
  );
1550
1529
  if (utxo.datum)
1551
1530
  return builder.with_data(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lucid-evolution/utils",
3
- "version": "0.1.60",
3
+ "version": "0.1.62",
4
4
  "description": "",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -36,9 +36,9 @@
36
36
  "effect": "^3.10.4",
37
37
  "@lucid-evolution/core-types": "0.1.21",
38
38
  "@lucid-evolution/core-utils": "0.1.16",
39
+ "@lucid-evolution/crc8": "0.1.8",
39
40
  "@lucid-evolution/plutus": "0.1.28",
40
- "@lucid-evolution/uplc": "0.2.18",
41
- "@lucid-evolution/crc8": "0.1.8"
41
+ "@lucid-evolution/uplc": "0.2.18"
42
42
  },
43
43
  "devDependencies": {
44
44
  "@types/node": "^20.12.8",