@meshsdk/core-csl 1.7.22 → 1.7.23

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
@@ -516,6 +516,12 @@ var parseWasmResult = (result) => {
516
516
  };
517
517
 
518
518
  // src/utils/transaction.ts
519
+ function isSuccessAction(action) {
520
+ return action.success !== void 0;
521
+ }
522
+ function isErrorAction(action) {
523
+ return action.error !== void 0;
524
+ }
519
525
  var calculateTxHash = (txHex) => {
520
526
  const result = csl.js_calculate_tx_hash(txHex);
521
527
  return parseWasmResult(result);
@@ -534,14 +540,29 @@ var evaluateTransaction = (txHex, resolvedUtxos, network) => {
534
540
  for (const utxo of resolvedUtxos) {
535
541
  mappedUtxos.add(JSON.stringify(utxo));
536
542
  }
537
- const result = csl.evaluate_tx_scripts_js(txHex, mappedUtxos, additionalTxs, network);
543
+ const result = csl.evaluate_tx_scripts_js(
544
+ txHex,
545
+ mappedUtxos,
546
+ additionalTxs,
547
+ network
548
+ );
538
549
  const unwrappedResult = parseWasmResult(result);
539
- try {
540
- const actions = JSON.parse(unwrappedResult);
541
- return actions.map(mapAction);
542
- } catch (e) {
543
- throw new Error("Cannot parse result from evaluate_tx_scripts_js. Expected Action[] type");
550
+ const actions = JSON.parse(unwrappedResult);
551
+ let parsedSuccessActions = [];
552
+ let parsedErrorActions = [];
553
+ actions.map((action) => {
554
+ if (isSuccessAction(action)) {
555
+ parsedSuccessActions.push(action.success);
556
+ } else if (isErrorAction(action)) {
557
+ parsedErrorActions.push(action.error);
558
+ } else {
559
+ throw new Error("Invalid action type found");
560
+ }
561
+ });
562
+ if (parsedErrorActions.length > 0) {
563
+ throw new Error(JSON.stringify(parsedErrorActions));
544
564
  }
565
+ return parsedSuccessActions.map(mapAction);
545
566
  };
546
567
  var mapAction = (action) => {
547
568
  return {
@@ -1000,6 +1021,17 @@ var mintParametersObj = (mintItem) => {
1000
1021
  };
1001
1022
  };
1002
1023
 
1024
+ // src/core/adaptor/network.ts
1025
+ var networkToObj = (network) => {
1026
+ if (typeof network === "string") {
1027
+ return network;
1028
+ } else {
1029
+ return {
1030
+ custom: network
1031
+ };
1032
+ }
1033
+ };
1034
+
1003
1035
  // src/core/adaptor/output.ts
1004
1036
  var outputToObj = (output) => {
1005
1037
  let datum = null;
@@ -1275,17 +1307,6 @@ var withdrawalToObj = (withdrawal) => {
1275
1307
  }
1276
1308
  };
1277
1309
 
1278
- // src/core/adaptor/network.ts
1279
- var networkToObj = (network) => {
1280
- if (typeof network === "string") {
1281
- return network;
1282
- } else {
1283
- return {
1284
- custom: network
1285
- };
1286
- }
1287
- };
1288
-
1289
1310
  // src/core/adaptor/utxo.ts
1290
1311
  var utxoToObj = ({
1291
1312
  input: { outputIndex, txHash },
@@ -1322,6 +1343,7 @@ var meshTxBuilderBodyToObj = ({
1322
1343
  signingKey,
1323
1344
  withdrawals,
1324
1345
  votes,
1346
+ fee,
1325
1347
  network
1326
1348
  }) => {
1327
1349
  return {
@@ -1338,6 +1360,7 @@ var meshTxBuilderBodyToObj = ({
1338
1360
  signingKey,
1339
1361
  withdrawals: withdrawals.map(withdrawalToObj),
1340
1362
  votes: votes.map(voteToObj),
1363
+ fee,
1341
1364
  network: networkToObj(network)
1342
1365
  };
1343
1366
  };
package/dist/index.d.cts CHANGED
@@ -105,7 +105,7 @@ declare const utxoToObj: ({ input: { outputIndex, txHash }, output: { address, a
105
105
 
106
106
  declare const withdrawalToObj: (withdrawal: Withdrawal) => object;
107
107
 
108
- declare const meshTxBuilderBodyToObj: ({ inputs, outputs, collaterals, requiredSignatures, referenceInputs, mints, changeAddress, metadata, validityRange, certificates, signingKey, withdrawals, votes, network, }: MeshTxBuilderBody) => {
108
+ declare const meshTxBuilderBodyToObj: ({ inputs, outputs, collaterals, requiredSignatures, referenceInputs, mints, changeAddress, metadata, validityRange, certificates, signingKey, withdrawals, votes, fee, network, }: MeshTxBuilderBody) => {
109
109
  inputs: object[];
110
110
  outputs: object[];
111
111
  collaterals: object[];
@@ -119,6 +119,7 @@ declare const meshTxBuilderBodyToObj: ({ inputs, outputs, collaterals, requiredS
119
119
  signingKey: string[];
120
120
  withdrawals: object[];
121
121
  votes: object[];
122
+ fee: string | undefined;
122
123
  network: "testnet" | "preview" | "preprod" | "mainnet" | number[][] | {
123
124
  custom: "testnet" | "preview" | "preprod" | "mainnet" | number[][];
124
125
  };
package/dist/index.d.ts CHANGED
@@ -105,7 +105,7 @@ declare const utxoToObj: ({ input: { outputIndex, txHash }, output: { address, a
105
105
 
106
106
  declare const withdrawalToObj: (withdrawal: Withdrawal) => object;
107
107
 
108
- declare const meshTxBuilderBodyToObj: ({ inputs, outputs, collaterals, requiredSignatures, referenceInputs, mints, changeAddress, metadata, validityRange, certificates, signingKey, withdrawals, votes, network, }: MeshTxBuilderBody) => {
108
+ declare const meshTxBuilderBodyToObj: ({ inputs, outputs, collaterals, requiredSignatures, referenceInputs, mints, changeAddress, metadata, validityRange, certificates, signingKey, withdrawals, votes, fee, network, }: MeshTxBuilderBody) => {
109
109
  inputs: object[];
110
110
  outputs: object[];
111
111
  collaterals: object[];
@@ -119,6 +119,7 @@ declare const meshTxBuilderBodyToObj: ({ inputs, outputs, collaterals, requiredS
119
119
  signingKey: string[];
120
120
  withdrawals: object[];
121
121
  votes: object[];
122
+ fee: string | undefined;
122
123
  network: "testnet" | "preview" | "preprod" | "mainnet" | number[][] | {
123
124
  custom: "testnet" | "preview" | "preprod" | "mainnet" | number[][];
124
125
  };
package/dist/index.js CHANGED
@@ -389,6 +389,12 @@ var parseWasmResult = (result) => {
389
389
  };
390
390
 
391
391
  // src/utils/transaction.ts
392
+ function isSuccessAction(action) {
393
+ return action.success !== void 0;
394
+ }
395
+ function isErrorAction(action) {
396
+ return action.error !== void 0;
397
+ }
392
398
  var calculateTxHash = (txHex) => {
393
399
  const result = csl.js_calculate_tx_hash(txHex);
394
400
  return parseWasmResult(result);
@@ -407,14 +413,29 @@ var evaluateTransaction = (txHex, resolvedUtxos, network) => {
407
413
  for (const utxo of resolvedUtxos) {
408
414
  mappedUtxos.add(JSON.stringify(utxo));
409
415
  }
410
- const result = csl.evaluate_tx_scripts_js(txHex, mappedUtxos, additionalTxs, network);
416
+ const result = csl.evaluate_tx_scripts_js(
417
+ txHex,
418
+ mappedUtxos,
419
+ additionalTxs,
420
+ network
421
+ );
411
422
  const unwrappedResult = parseWasmResult(result);
412
- try {
413
- const actions = JSON.parse(unwrappedResult);
414
- return actions.map(mapAction);
415
- } catch (e) {
416
- throw new Error("Cannot parse result from evaluate_tx_scripts_js. Expected Action[] type");
423
+ const actions = JSON.parse(unwrappedResult);
424
+ let parsedSuccessActions = [];
425
+ let parsedErrorActions = [];
426
+ actions.map((action) => {
427
+ if (isSuccessAction(action)) {
428
+ parsedSuccessActions.push(action.success);
429
+ } else if (isErrorAction(action)) {
430
+ parsedErrorActions.push(action.error);
431
+ } else {
432
+ throw new Error("Invalid action type found");
433
+ }
434
+ });
435
+ if (parsedErrorActions.length > 0) {
436
+ throw new Error(JSON.stringify(parsedErrorActions));
417
437
  }
438
+ return parsedSuccessActions.map(mapAction);
418
439
  };
419
440
  var mapAction = (action) => {
420
441
  return {
@@ -876,6 +897,17 @@ var mintParametersObj = (mintItem) => {
876
897
  };
877
898
  };
878
899
 
900
+ // src/core/adaptor/network.ts
901
+ var networkToObj = (network) => {
902
+ if (typeof network === "string") {
903
+ return network;
904
+ } else {
905
+ return {
906
+ custom: network
907
+ };
908
+ }
909
+ };
910
+
879
911
  // src/core/adaptor/output.ts
880
912
  var outputToObj = (output) => {
881
913
  let datum = null;
@@ -1151,17 +1183,6 @@ var withdrawalToObj = (withdrawal) => {
1151
1183
  }
1152
1184
  };
1153
1185
 
1154
- // src/core/adaptor/network.ts
1155
- var networkToObj = (network) => {
1156
- if (typeof network === "string") {
1157
- return network;
1158
- } else {
1159
- return {
1160
- custom: network
1161
- };
1162
- }
1163
- };
1164
-
1165
1186
  // src/core/adaptor/utxo.ts
1166
1187
  var utxoToObj = ({
1167
1188
  input: { outputIndex, txHash },
@@ -1198,6 +1219,7 @@ var meshTxBuilderBodyToObj = ({
1198
1219
  signingKey,
1199
1220
  withdrawals,
1200
1221
  votes,
1222
+ fee,
1201
1223
  network
1202
1224
  }) => {
1203
1225
  return {
@@ -1214,6 +1236,7 @@ var meshTxBuilderBodyToObj = ({
1214
1236
  signingKey,
1215
1237
  withdrawals: withdrawals.map(withdrawalToObj),
1216
1238
  votes: votes.map(voteToObj),
1239
+ fee,
1217
1240
  network: networkToObj(network)
1218
1241
  };
1219
1242
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@meshsdk/core-csl",
3
- "version": "1.7.22",
3
+ "version": "1.7.23",
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.7.22",
34
+ "@meshsdk/provider": "1.7.23",
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.7.22",
43
- "@sidan-lab/sidan-csl-rs-browser": "0.9.6",
44
- "@sidan-lab/sidan-csl-rs-nodejs": "0.9.6",
42
+ "@meshsdk/common": "1.7.23",
43
+ "@sidan-lab/sidan-csl-rs-browser": "0.9.7",
44
+ "@sidan-lab/sidan-csl-rs-nodejs": "0.9.7",
45
45
  "@types/base32-encoding": "^1.0.2",
46
46
  "base32-encoding": "^1.0.0",
47
47
  "bech32": "^2.0.0",