@meshsdk/core-csl 1.8.3 → 1.8.4

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
@@ -28,8 +28,8 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
28
28
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
29
 
30
30
  // src/index.ts
31
- var src_exports = {};
32
- __export(src_exports, {
31
+ var index_exports = {};
32
+ __export(index_exports, {
33
33
  CSLSerializer: () => CSLSerializer,
34
34
  LANGUAGE_VERSIONS: () => LANGUAGE_VERSIONS,
35
35
  OfflineEvaluator: () => OfflineEvaluator,
@@ -128,7 +128,7 @@ __export(src_exports, {
128
128
  v2ScriptToBech32: () => v2ScriptToBech32,
129
129
  withdrawalToObj: () => withdrawalToObj
130
130
  });
131
- module.exports = __toCommonJS(src_exports);
131
+ module.exports = __toCommonJS(index_exports);
132
132
 
133
133
  // src/utils/address.ts
134
134
  var import_common2 = require("@meshsdk/common");
@@ -534,7 +534,7 @@ var signTransaction = (txHex, signingKeys) => {
534
534
  const result = csl.js_sign_transaction(txHex, cslSigningKeys);
535
535
  return parseWasmResult(result);
536
536
  };
537
- var evaluateTransaction = (txHex, resolvedUtxos, network) => {
537
+ var evaluateTransaction = (txHex, resolvedUtxos, network, slotConfig) => {
538
538
  const additionalTxs = csl.JsVecString.new();
539
539
  const mappedUtxos = csl.JsVecString.new();
540
540
  for (const utxo of resolvedUtxos) {
@@ -544,7 +544,8 @@ var evaluateTransaction = (txHex, resolvedUtxos, network) => {
544
544
  txHex,
545
545
  mappedUtxos,
546
546
  additionalTxs,
547
- network
547
+ network,
548
+ JSON.stringify(slotConfig)
548
549
  );
549
550
  const unwrappedResult = parseWasmResult(result);
550
551
  const actions = JSON.parse(unwrappedResult);
@@ -1503,17 +1504,25 @@ var CSLSerializer = class {
1503
1504
  };
1504
1505
 
1505
1506
  // src/offline-providers/offline-evaluator.ts
1507
+ var import_common5 = require("@meshsdk/common");
1506
1508
  var OfflineEvaluator = class {
1507
1509
  fetcher;
1508
1510
  network;
1511
+ slotConfig;
1509
1512
  /**
1510
1513
  * Creates a new instance of OfflineEvaluator.
1511
1514
  * @param fetcher - An implementation of IFetcher to resolve transaction UTXOs
1512
1515
  * @param network - The network to evaluate scripts for
1516
+ * @param slotConfig - Slot configuration for the network (optional, defaults to network-specific values)
1513
1517
  */
1514
- constructor(fetcher, network) {
1518
+ constructor(fetcher, network, slotConfig) {
1515
1519
  this.fetcher = fetcher;
1516
1520
  this.network = network;
1521
+ this.slotConfig = slotConfig ?? {
1522
+ slotLength: import_common5.SLOT_CONFIG_NETWORK[network].slotLength,
1523
+ zeroSlot: import_common5.SLOT_CONFIG_NETWORK[network].zeroSlot,
1524
+ zeroTime: import_common5.SLOT_CONFIG_NETWORK[network].zeroTime
1525
+ };
1517
1526
  }
1518
1527
  /**
1519
1528
  * Evaluates Plutus scripts in a transaction by resolving its input UTXOs and calculating execution costs.
@@ -1539,18 +1548,31 @@ var OfflineEvaluator = class {
1539
1548
  const utxos = await this.fetcher.fetchUTxOs(txHash);
1540
1549
  for (const utxo of utxos) {
1541
1550
  if (utxo) {
1542
- if (inputsToResolve.find((input) => input.txHash === txHash && input.index === utxo.input.outputIndex)) {
1551
+ if (inputsToResolve.find(
1552
+ (input) => input.txHash === txHash && input.index === utxo.input.outputIndex
1553
+ )) {
1543
1554
  resolvedUTXOs.push(utxo);
1544
1555
  }
1545
1556
  }
1546
1557
  }
1547
1558
  }
1548
1559
  if (resolvedUTXOs.length !== inputsToResolve.length) {
1549
- const missing = inputsToResolve.filter((input) => !resolvedUTXOs.find((utxo) => utxo.input.txHash === input.txHash && utxo.input.outputIndex === input.index));
1560
+ const missing = inputsToResolve.filter(
1561
+ (input) => !resolvedUTXOs.find(
1562
+ (utxo) => utxo.input.txHash === input.txHash && utxo.input.outputIndex === input.index
1563
+ )
1564
+ );
1550
1565
  const missingList = missing.map((m) => `${m.txHash}:${m.index}`).join(", ");
1551
- throw new Error(`Can't resolve these UTXOs to execute plutus scripts: ${missingList}`);
1566
+ throw new Error(
1567
+ `Can't resolve these UTXOs to execute plutus scripts: ${missingList}`
1568
+ );
1552
1569
  }
1553
- return evaluateTransaction(tx, resolvedUTXOs, this.network);
1570
+ return evaluateTransaction(
1571
+ tx,
1572
+ resolvedUTXOs,
1573
+ this.network,
1574
+ this.slotConfig
1575
+ );
1554
1576
  }
1555
1577
  };
1556
1578
  // Annotate the CommonJS export names for ESM import in node:
package/dist/index.d.cts CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as _meshsdk_common from '@meshsdk/common';
2
- import { DeserializedAddress, PubKeyAddress, ScriptAddress, UTxO, Network, Action, Data, PlutusDataType, IMeshTxSerializer, Protocol, MeshTxBuilderBody, BuilderData, IDeserializer, IResolver, Certificate, CertificateType, PoolParams, PoolMetadata, Relay, Redeemer, MintItem, Output, ScriptSource, SimpleScriptSourceInfo, TxIn, TxInParameter, ScriptTxInParameter, SimpleScriptTxInParameter, Withdrawal, LanguageVersion, PlutusScript, NativeScript, IEvaluator, IFetcher } from '@meshsdk/common';
2
+ import { DeserializedAddress, PubKeyAddress, ScriptAddress, UTxO, Network, SlotConfig, Action, Data, PlutusDataType, IMeshTxSerializer, Protocol, MeshTxBuilderBody, BuilderData, IDeserializer, IResolver, Certificate, CertificateType, PoolParams, PoolMetadata, Relay, Redeemer, MintItem, Output, ScriptSource, SimpleScriptSourceInfo, TxIn, TxInParameter, ScriptTxInParameter, SimpleScriptTxInParameter, Withdrawal, LanguageVersion, PlutusScript, NativeScript, IEvaluator, IFetcher } from '@meshsdk/common';
3
3
  import * as csl from '@sidan-lab/sidan-csl-rs-nodejs';
4
4
  export { csl };
5
5
 
@@ -30,7 +30,7 @@ declare const keyHashToRewardAddress: (keyHashHex: string, network?: number) =>
30
30
 
31
31
  declare const calculateTxHash: (txHex: string) => string;
32
32
  declare const signTransaction: (txHex: string, signingKeys: string[]) => string;
33
- declare const evaluateTransaction: (txHex: string, resolvedUtxos: UTxO[], network: Network) => Omit<Action, "data">[];
33
+ declare const evaluateTransaction: (txHex: string, resolvedUtxos: UTxO[], network: Network, slotConfig: Omit<Omit<SlotConfig, "startEpoch">, "epochLength">) => Omit<Action, "data">[];
34
34
  declare const getTransactionInputs: (txHex: string) => {
35
35
  txHash: string;
36
36
  index: number;
@@ -240,12 +240,14 @@ declare const resolveEd25519KeyHash: (bech32: string) => string;
240
240
  declare class OfflineEvaluator implements IEvaluator {
241
241
  private readonly fetcher;
242
242
  private readonly network;
243
+ slotConfig: Omit<Omit<SlotConfig, "startEpoch">, "epochLength">;
243
244
  /**
244
245
  * Creates a new instance of OfflineEvaluator.
245
246
  * @param fetcher - An implementation of IFetcher to resolve transaction UTXOs
246
247
  * @param network - The network to evaluate scripts for
248
+ * @param slotConfig - Slot configuration for the network (optional, defaults to network-specific values)
247
249
  */
248
- constructor(fetcher: IFetcher, network: Network);
250
+ constructor(fetcher: IFetcher, network: Network, slotConfig?: Omit<Omit<SlotConfig, "startEpoch">, "epochLength">);
249
251
  /**
250
252
  * Evaluates Plutus scripts in a transaction by resolving its input UTXOs and calculating execution costs.
251
253
  *
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as _meshsdk_common from '@meshsdk/common';
2
- import { DeserializedAddress, PubKeyAddress, ScriptAddress, UTxO, Network, Action, Data, PlutusDataType, IMeshTxSerializer, Protocol, MeshTxBuilderBody, BuilderData, IDeserializer, IResolver, Certificate, CertificateType, PoolParams, PoolMetadata, Relay, Redeemer, MintItem, Output, ScriptSource, SimpleScriptSourceInfo, TxIn, TxInParameter, ScriptTxInParameter, SimpleScriptTxInParameter, Withdrawal, LanguageVersion, PlutusScript, NativeScript, IEvaluator, IFetcher } from '@meshsdk/common';
2
+ import { DeserializedAddress, PubKeyAddress, ScriptAddress, UTxO, Network, SlotConfig, Action, Data, PlutusDataType, IMeshTxSerializer, Protocol, MeshTxBuilderBody, BuilderData, IDeserializer, IResolver, Certificate, CertificateType, PoolParams, PoolMetadata, Relay, Redeemer, MintItem, Output, ScriptSource, SimpleScriptSourceInfo, TxIn, TxInParameter, ScriptTxInParameter, SimpleScriptTxInParameter, Withdrawal, LanguageVersion, PlutusScript, NativeScript, IEvaluator, IFetcher } from '@meshsdk/common';
3
3
  import * as csl from '@sidan-lab/sidan-csl-rs-nodejs';
4
4
  export { csl };
5
5
 
@@ -30,7 +30,7 @@ declare const keyHashToRewardAddress: (keyHashHex: string, network?: number) =>
30
30
 
31
31
  declare const calculateTxHash: (txHex: string) => string;
32
32
  declare const signTransaction: (txHex: string, signingKeys: string[]) => string;
33
- declare const evaluateTransaction: (txHex: string, resolvedUtxos: UTxO[], network: Network) => Omit<Action, "data">[];
33
+ declare const evaluateTransaction: (txHex: string, resolvedUtxos: UTxO[], network: Network, slotConfig: Omit<Omit<SlotConfig, "startEpoch">, "epochLength">) => Omit<Action, "data">[];
34
34
  declare const getTransactionInputs: (txHex: string) => {
35
35
  txHash: string;
36
36
  index: number;
@@ -240,12 +240,14 @@ declare const resolveEd25519KeyHash: (bech32: string) => string;
240
240
  declare class OfflineEvaluator implements IEvaluator {
241
241
  private readonly fetcher;
242
242
  private readonly network;
243
+ slotConfig: Omit<Omit<SlotConfig, "startEpoch">, "epochLength">;
243
244
  /**
244
245
  * Creates a new instance of OfflineEvaluator.
245
246
  * @param fetcher - An implementation of IFetcher to resolve transaction UTXOs
246
247
  * @param network - The network to evaluate scripts for
248
+ * @param slotConfig - Slot configuration for the network (optional, defaults to network-specific values)
247
249
  */
248
- constructor(fetcher: IFetcher, network: Network);
250
+ constructor(fetcher: IFetcher, network: Network, slotConfig?: Omit<Omit<SlotConfig, "startEpoch">, "epochLength">);
249
251
  /**
250
252
  * Evaluates Plutus scripts in a transaction by resolving its input UTXOs and calculating execution costs.
251
253
  *
package/dist/index.js CHANGED
@@ -407,7 +407,7 @@ var signTransaction = (txHex, signingKeys) => {
407
407
  const result = csl.js_sign_transaction(txHex, cslSigningKeys);
408
408
  return parseWasmResult(result);
409
409
  };
410
- var evaluateTransaction = (txHex, resolvedUtxos, network) => {
410
+ var evaluateTransaction = (txHex, resolvedUtxos, network, slotConfig) => {
411
411
  const additionalTxs = csl.JsVecString.new();
412
412
  const mappedUtxos = csl.JsVecString.new();
413
413
  for (const utxo of resolvedUtxos) {
@@ -417,7 +417,8 @@ var evaluateTransaction = (txHex, resolvedUtxos, network) => {
417
417
  txHex,
418
418
  mappedUtxos,
419
419
  additionalTxs,
420
- network
420
+ network,
421
+ JSON.stringify(slotConfig)
421
422
  );
422
423
  const unwrappedResult = parseWasmResult(result);
423
424
  const actions = JSON.parse(unwrappedResult);
@@ -1379,17 +1380,27 @@ var CSLSerializer = class {
1379
1380
  };
1380
1381
 
1381
1382
  // src/offline-providers/offline-evaluator.ts
1383
+ import {
1384
+ SLOT_CONFIG_NETWORK
1385
+ } from "@meshsdk/common";
1382
1386
  var OfflineEvaluator = class {
1383
1387
  fetcher;
1384
1388
  network;
1389
+ slotConfig;
1385
1390
  /**
1386
1391
  * Creates a new instance of OfflineEvaluator.
1387
1392
  * @param fetcher - An implementation of IFetcher to resolve transaction UTXOs
1388
1393
  * @param network - The network to evaluate scripts for
1394
+ * @param slotConfig - Slot configuration for the network (optional, defaults to network-specific values)
1389
1395
  */
1390
- constructor(fetcher, network) {
1396
+ constructor(fetcher, network, slotConfig) {
1391
1397
  this.fetcher = fetcher;
1392
1398
  this.network = network;
1399
+ this.slotConfig = slotConfig ?? {
1400
+ slotLength: SLOT_CONFIG_NETWORK[network].slotLength,
1401
+ zeroSlot: SLOT_CONFIG_NETWORK[network].zeroSlot,
1402
+ zeroTime: SLOT_CONFIG_NETWORK[network].zeroTime
1403
+ };
1393
1404
  }
1394
1405
  /**
1395
1406
  * Evaluates Plutus scripts in a transaction by resolving its input UTXOs and calculating execution costs.
@@ -1415,18 +1426,31 @@ var OfflineEvaluator = class {
1415
1426
  const utxos = await this.fetcher.fetchUTxOs(txHash);
1416
1427
  for (const utxo of utxos) {
1417
1428
  if (utxo) {
1418
- if (inputsToResolve.find((input) => input.txHash === txHash && input.index === utxo.input.outputIndex)) {
1429
+ if (inputsToResolve.find(
1430
+ (input) => input.txHash === txHash && input.index === utxo.input.outputIndex
1431
+ )) {
1419
1432
  resolvedUTXOs.push(utxo);
1420
1433
  }
1421
1434
  }
1422
1435
  }
1423
1436
  }
1424
1437
  if (resolvedUTXOs.length !== inputsToResolve.length) {
1425
- const missing = inputsToResolve.filter((input) => !resolvedUTXOs.find((utxo) => utxo.input.txHash === input.txHash && utxo.input.outputIndex === input.index));
1438
+ const missing = inputsToResolve.filter(
1439
+ (input) => !resolvedUTXOs.find(
1440
+ (utxo) => utxo.input.txHash === input.txHash && utxo.input.outputIndex === input.index
1441
+ )
1442
+ );
1426
1443
  const missingList = missing.map((m) => `${m.txHash}:${m.index}`).join(", ");
1427
- throw new Error(`Can't resolve these UTXOs to execute plutus scripts: ${missingList}`);
1444
+ throw new Error(
1445
+ `Can't resolve these UTXOs to execute plutus scripts: ${missingList}`
1446
+ );
1428
1447
  }
1429
- return evaluateTransaction(tx, resolvedUTXOs, this.network);
1448
+ return evaluateTransaction(
1449
+ tx,
1450
+ resolvedUTXOs,
1451
+ this.network,
1452
+ this.slotConfig
1453
+ );
1430
1454
  }
1431
1455
  };
1432
1456
  export {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@meshsdk/core-csl",
3
- "version": "1.8.3",
3
+ "version": "1.8.4",
4
4
  "description": "Types and utilities functions between Mesh and cardano-serialization-lib",
5
5
  "main": "./dist/index.cjs",
6
6
  "module": "./dist/index.js",
@@ -31,7 +31,7 @@
31
31
  },
32
32
  "devDependencies": {
33
33
  "@meshsdk/configs": "*",
34
- "@meshsdk/provider": "1.8.3",
34
+ "@meshsdk/provider": "1.8.4",
35
35
  "@types/json-bigint": "^1.0.4",
36
36
  "eslint": "^8.57.0",
37
37
  "ts-jest": "^29.1.4",
@@ -39,9 +39,9 @@
39
39
  "typescript": "^5.3.3"
40
40
  },
41
41
  "dependencies": {
42
- "@meshsdk/common": "1.8.3",
43
- "@sidan-lab/sidan-csl-rs-browser": "0.9.12",
44
- "@sidan-lab/sidan-csl-rs-nodejs": "0.9.12",
42
+ "@meshsdk/common": "1.8.4",
43
+ "@sidan-lab/sidan-csl-rs-browser": "0.9.13",
44
+ "@sidan-lab/sidan-csl-rs-nodejs": "0.9.13",
45
45
  "@types/base32-encoding": "^1.0.2",
46
46
  "base32-encoding": "^1.0.0",
47
47
  "bech32": "^2.0.0",