@lucid-evolution/utils 0.1.40 → 0.1.41

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
@@ -1282,9 +1282,6 @@ function slotToUnixTime(network, slot) {
1282
1282
  return (0, import_plutus2.slotToBeginUnixTime)(slot, import_plutus2.SLOT_CONFIG_NETWORK[network]);
1283
1283
  }
1284
1284
 
1285
- // src/utxo.ts
1286
- var CSL = __toESM(require("@emurgo/cardano-serialization-lib-nodejs"), 1);
1287
-
1288
1285
  // src/value.ts
1289
1286
  var import_core_utils4 = require("@lucid-evolution/core-utils");
1290
1287
  function valueToAssets(value) {
@@ -1354,7 +1351,12 @@ function addAssets(...assets) {
1354
1351
  return assets.reduce((a, b) => {
1355
1352
  for (const k in b) {
1356
1353
  if (Object.hasOwn(b, k)) {
1357
- a[k] = (a[k] || 0n) + b[k];
1354
+ const sum = (a[k] || 0n) + b[k];
1355
+ if (sum === 0n) {
1356
+ delete a[k];
1357
+ } else {
1358
+ a[k] = sum;
1359
+ }
1358
1360
  }
1359
1361
  }
1360
1362
  return a;
@@ -1393,16 +1395,9 @@ function utxosToCores(utxos) {
1393
1395
  return result;
1394
1396
  }
1395
1397
  function coreToUtxo(coreUtxo) {
1396
- const utxoCore = CSL.TransactionUnspentOutput.from_bytes(
1397
- coreUtxo.to_cbor_bytes()
1398
- );
1399
1398
  const utxo = {
1400
- ...coreToOutRef(
1401
- CML.TransactionInput.from_cbor_bytes(utxoCore.input().to_bytes())
1402
- ),
1403
- ...coreToTxOutput(
1404
- CML.TransactionOutput.from_cbor_bytes(utxoCore.output().to_bytes())
1405
- )
1399
+ ...coreToOutRef(coreUtxo.input()),
1400
+ ...coreToTxOutput(coreUtxo.output())
1406
1401
  };
1407
1402
  return utxo;
1408
1403
  }
package/dist/index.js CHANGED
@@ -1203,9 +1203,6 @@ function slotToUnixTime(network, slot) {
1203
1203
  return slotToBeginUnixTime(slot, SLOT_CONFIG_NETWORK[network]);
1204
1204
  }
1205
1205
 
1206
- // src/utxo.ts
1207
- import * as CSL from "@emurgo/cardano-serialization-lib-nodejs";
1208
-
1209
1206
  // src/value.ts
1210
1207
  import { fromHex as fromHex4, toHex as toHex3 } from "@lucid-evolution/core-utils";
1211
1208
  function valueToAssets(value) {
@@ -1275,7 +1272,12 @@ function addAssets(...assets) {
1275
1272
  return assets.reduce((a, b) => {
1276
1273
  for (const k in b) {
1277
1274
  if (Object.hasOwn(b, k)) {
1278
- a[k] = (a[k] || 0n) + b[k];
1275
+ const sum = (a[k] || 0n) + b[k];
1276
+ if (sum === 0n) {
1277
+ delete a[k];
1278
+ } else {
1279
+ a[k] = sum;
1280
+ }
1279
1281
  }
1280
1282
  }
1281
1283
  return a;
@@ -1314,16 +1316,9 @@ function utxosToCores(utxos) {
1314
1316
  return result;
1315
1317
  }
1316
1318
  function coreToUtxo(coreUtxo) {
1317
- const utxoCore = CSL.TransactionUnspentOutput.from_bytes(
1318
- coreUtxo.to_cbor_bytes()
1319
- );
1320
1319
  const utxo = {
1321
- ...coreToOutRef(
1322
- CML.TransactionInput.from_cbor_bytes(utxoCore.input().to_bytes())
1323
- ),
1324
- ...coreToTxOutput(
1325
- CML.TransactionOutput.from_cbor_bytes(utxoCore.output().to_bytes())
1326
- )
1320
+ ...coreToOutRef(coreUtxo.input()),
1321
+ ...coreToTxOutput(coreUtxo.output())
1327
1322
  };
1328
1323
  return utxo;
1329
1324
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lucid-evolution/utils",
3
- "version": "0.1.40",
3
+ "version": "0.1.41",
4
4
  "description": "",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -29,8 +29,6 @@
29
29
  "@anastasia-labs/cardano-multiplatform-lib-browser": "6.0.2-1",
30
30
  "@anastasia-labs/cardano-multiplatform-lib-nodejs": "6.0.2-1",
31
31
  "@effect/schema": "^0.68.16",
32
- "@emurgo/cardano-serialization-lib-browser": "^11.5.0",
33
- "@emurgo/cardano-serialization-lib-nodejs": "^11.5.0",
34
32
  "@harmoniclabs/plutus-data": "^1.2.4",
35
33
  "@harmoniclabs/uplc": "^1.2.4",
36
34
  "bip39": "^3.1.0",