@meshsdk/core-csl 1.9.0-beta.99 → 1.9.1
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 +26 -9
- package/dist/index.d.cts +4 -3
- package/dist/index.d.ts +4 -3
- package/dist/index.js +29 -9
- package/package.json +4 -3
package/dist/index.cjs
CHANGED
|
@@ -567,6 +567,7 @@ var keyHashToRewardAddress = (keyHashHex, network = 1) => {
|
|
|
567
567
|
|
|
568
568
|
// src/utils/transaction.ts
|
|
569
569
|
var import_whisky_js_nodejs = require("@sidan-lab/whisky-js-nodejs");
|
|
570
|
+
var import_whisky_evaluator = require("whisky-evaluator");
|
|
570
571
|
|
|
571
572
|
// src/wasm.ts
|
|
572
573
|
var parseWasmResult = (result) => {
|
|
@@ -595,20 +596,30 @@ var signTransaction = (txHex, signingKeys) => {
|
|
|
595
596
|
const result = csl.js_sign_transaction(txHex, cslSigningKeys);
|
|
596
597
|
return parseWasmResult(result);
|
|
597
598
|
};
|
|
598
|
-
var evaluateTransaction = (txHex, resolvedUtxos, chainedTxs,
|
|
599
|
-
|
|
599
|
+
var evaluateTransaction = (txHex, resolvedUtxos, chainedTxs, costModels, slotConfig) => {
|
|
600
|
+
let additionalTxs = [];
|
|
600
601
|
for (const tx of chainedTxs) {
|
|
601
|
-
additionalTxs.
|
|
602
|
+
additionalTxs.push(tx);
|
|
602
603
|
}
|
|
603
|
-
|
|
604
|
+
let mappedUtxos = [];
|
|
604
605
|
for (const utxo of resolvedUtxos) {
|
|
605
|
-
mappedUtxos.
|
|
606
|
+
mappedUtxos.push(JSON.stringify(utxo));
|
|
606
607
|
}
|
|
607
|
-
|
|
608
|
+
if (!costModels || costModels.length !== 3) {
|
|
609
|
+
throw new Error(
|
|
610
|
+
"Cost models for all three Plutus versions must be provided"
|
|
611
|
+
);
|
|
612
|
+
}
|
|
613
|
+
let mappedCostModels = JSON.stringify({
|
|
614
|
+
plutus_v1: costModels[0],
|
|
615
|
+
plutus_v2: costModels[1],
|
|
616
|
+
plutus_v3: costModels[2]
|
|
617
|
+
});
|
|
618
|
+
const result = (0, import_whisky_evaluator.js_evaluate_tx_scripts)(
|
|
608
619
|
txHex,
|
|
609
620
|
mappedUtxos,
|
|
610
621
|
additionalTxs,
|
|
611
|
-
|
|
622
|
+
mappedCostModels,
|
|
612
623
|
JSON.stringify(slotConfig)
|
|
613
624
|
);
|
|
614
625
|
const unwrappedResult = parseWasmResult(result);
|
|
@@ -2405,13 +2416,14 @@ var OfflineEvaluator = class {
|
|
|
2405
2416
|
fetcher;
|
|
2406
2417
|
network;
|
|
2407
2418
|
slotConfig;
|
|
2419
|
+
costModels;
|
|
2408
2420
|
/**
|
|
2409
2421
|
* Creates a new instance of OfflineEvaluator.
|
|
2410
2422
|
* @param fetcher - An implementation of IFetcher to resolve transaction UTXOs
|
|
2411
2423
|
* @param network - The network to evaluate scripts for
|
|
2412
2424
|
* @param slotConfig - Slot configuration for the network (optional, defaults to network-specific values)
|
|
2413
2425
|
*/
|
|
2414
|
-
constructor(fetcher, network, slotConfig) {
|
|
2426
|
+
constructor(fetcher, network, slotConfig, customCostModels) {
|
|
2415
2427
|
this.fetcher = fetcher;
|
|
2416
2428
|
this.network = network;
|
|
2417
2429
|
this.slotConfig = slotConfig ?? {
|
|
@@ -2419,6 +2431,11 @@ var OfflineEvaluator = class {
|
|
|
2419
2431
|
zeroSlot: import_common7.SLOT_CONFIG_NETWORK[network].zeroSlot,
|
|
2420
2432
|
zeroTime: import_common7.SLOT_CONFIG_NETWORK[network].zeroTime
|
|
2421
2433
|
};
|
|
2434
|
+
this.costModels = customCostModels ?? [
|
|
2435
|
+
import_common7.DEFAULT_V1_COST_MODEL_LIST,
|
|
2436
|
+
import_common7.DEFAULT_V2_COST_MODEL_LIST,
|
|
2437
|
+
import_common7.DEFAULT_V3_COST_MODEL_LIST
|
|
2438
|
+
];
|
|
2422
2439
|
}
|
|
2423
2440
|
/**
|
|
2424
2441
|
* Evaluates Plutus scripts in a transaction by resolving its input UTXOs and calculating execution costs.
|
|
@@ -2477,7 +2494,7 @@ var OfflineEvaluator = class {
|
|
|
2477
2494
|
tx,
|
|
2478
2495
|
additionalUtxos,
|
|
2479
2496
|
additionalTxs,
|
|
2480
|
-
this.
|
|
2497
|
+
this.costModels,
|
|
2481
2498
|
this.slotConfig
|
|
2482
2499
|
);
|
|
2483
2500
|
}
|
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,
|
|
2
|
+
import { DeserializedAddress, PubKeyAddress, ScriptAddress, UTxO, SlotConfig, Action, Data, PlutusDataType, TxInput, IMeshTxSerializer, Protocol, MeshTxBuilderBody, BuilderData, IDeserializer, IResolver, Output, Asset, ITxParser, CertificateType, Certificate, PoolMetadata, PoolParams, Relay, TxMetadata, Metadata, Redeemer, Network, MintItem, ScriptSource, SimpleScriptSourceInfo, TxIn, ScriptTxInParameter, SimpleScriptTxInParameter, TxInParameter, Vote, Withdrawal, LanguageVersion, NativeScript, PlutusScript, IEvaluator, IFetcher } from '@meshsdk/common';
|
|
3
3
|
import * as csl from '@sidan-lab/whisky-js-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[], chainedTxs: string[],
|
|
33
|
+
declare const evaluateTransaction: (txHex: string, resolvedUtxos: UTxO[], chainedTxs: string[], costModels: number[][], slotConfig: Omit<Omit<SlotConfig, "startEpoch">, "epochLength">) => Omit<Action, "data">[];
|
|
34
34
|
declare const getTransactionInputs: (txHex: string) => {
|
|
35
35
|
txHash: string;
|
|
36
36
|
outputIndex: number;
|
|
@@ -359,13 +359,14 @@ declare class OfflineEvaluator implements IEvaluator {
|
|
|
359
359
|
private readonly fetcher;
|
|
360
360
|
private readonly network;
|
|
361
361
|
slotConfig: Omit<Omit<SlotConfig, "startEpoch">, "epochLength">;
|
|
362
|
+
costModels: number[][];
|
|
362
363
|
/**
|
|
363
364
|
* Creates a new instance of OfflineEvaluator.
|
|
364
365
|
* @param fetcher - An implementation of IFetcher to resolve transaction UTXOs
|
|
365
366
|
* @param network - The network to evaluate scripts for
|
|
366
367
|
* @param slotConfig - Slot configuration for the network (optional, defaults to network-specific values)
|
|
367
368
|
*/
|
|
368
|
-
constructor(fetcher: IFetcher, network: Network, slotConfig?: Omit<Omit<SlotConfig, "startEpoch">, "epochLength"
|
|
369
|
+
constructor(fetcher: IFetcher, network: Network, slotConfig?: Omit<Omit<SlotConfig, "startEpoch">, "epochLength">, customCostModels?: number[][]);
|
|
369
370
|
/**
|
|
370
371
|
* Evaluates Plutus scripts in a transaction by resolving its input UTXOs and calculating execution costs.
|
|
371
372
|
*
|
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,
|
|
2
|
+
import { DeserializedAddress, PubKeyAddress, ScriptAddress, UTxO, SlotConfig, Action, Data, PlutusDataType, TxInput, IMeshTxSerializer, Protocol, MeshTxBuilderBody, BuilderData, IDeserializer, IResolver, Output, Asset, ITxParser, CertificateType, Certificate, PoolMetadata, PoolParams, Relay, TxMetadata, Metadata, Redeemer, Network, MintItem, ScriptSource, SimpleScriptSourceInfo, TxIn, ScriptTxInParameter, SimpleScriptTxInParameter, TxInParameter, Vote, Withdrawal, LanguageVersion, NativeScript, PlutusScript, IEvaluator, IFetcher } from '@meshsdk/common';
|
|
3
3
|
import * as csl from '@sidan-lab/whisky-js-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[], chainedTxs: string[],
|
|
33
|
+
declare const evaluateTransaction: (txHex: string, resolvedUtxos: UTxO[], chainedTxs: string[], costModels: number[][], slotConfig: Omit<Omit<SlotConfig, "startEpoch">, "epochLength">) => Omit<Action, "data">[];
|
|
34
34
|
declare const getTransactionInputs: (txHex: string) => {
|
|
35
35
|
txHash: string;
|
|
36
36
|
outputIndex: number;
|
|
@@ -359,13 +359,14 @@ declare class OfflineEvaluator implements IEvaluator {
|
|
|
359
359
|
private readonly fetcher;
|
|
360
360
|
private readonly network;
|
|
361
361
|
slotConfig: Omit<Omit<SlotConfig, "startEpoch">, "epochLength">;
|
|
362
|
+
costModels: number[][];
|
|
362
363
|
/**
|
|
363
364
|
* Creates a new instance of OfflineEvaluator.
|
|
364
365
|
* @param fetcher - An implementation of IFetcher to resolve transaction UTXOs
|
|
365
366
|
* @param network - The network to evaluate scripts for
|
|
366
367
|
* @param slotConfig - Slot configuration for the network (optional, defaults to network-specific values)
|
|
367
368
|
*/
|
|
368
|
-
constructor(fetcher: IFetcher, network: Network, slotConfig?: Omit<Omit<SlotConfig, "startEpoch">, "epochLength"
|
|
369
|
+
constructor(fetcher: IFetcher, network: Network, slotConfig?: Omit<Omit<SlotConfig, "startEpoch">, "epochLength">, customCostModels?: number[][]);
|
|
369
370
|
/**
|
|
370
371
|
* Evaluates Plutus scripts in a transaction by resolving its input UTXOs and calculating execution costs.
|
|
371
372
|
*
|
package/dist/index.js
CHANGED
|
@@ -408,6 +408,7 @@ var keyHashToRewardAddress = (keyHashHex, network = 1) => {
|
|
|
408
408
|
|
|
409
409
|
// src/utils/transaction.ts
|
|
410
410
|
import { js_get_tx_outs_utxo } from "@sidan-lab/whisky-js-nodejs";
|
|
411
|
+
import { js_evaluate_tx_scripts } from "whisky-evaluator";
|
|
411
412
|
|
|
412
413
|
// src/wasm.ts
|
|
413
414
|
var parseWasmResult = (result) => {
|
|
@@ -436,20 +437,30 @@ var signTransaction = (txHex, signingKeys) => {
|
|
|
436
437
|
const result = csl.js_sign_transaction(txHex, cslSigningKeys);
|
|
437
438
|
return parseWasmResult(result);
|
|
438
439
|
};
|
|
439
|
-
var evaluateTransaction = (txHex, resolvedUtxos, chainedTxs,
|
|
440
|
-
|
|
440
|
+
var evaluateTransaction = (txHex, resolvedUtxos, chainedTxs, costModels, slotConfig) => {
|
|
441
|
+
let additionalTxs = [];
|
|
441
442
|
for (const tx of chainedTxs) {
|
|
442
|
-
additionalTxs.
|
|
443
|
+
additionalTxs.push(tx);
|
|
443
444
|
}
|
|
444
|
-
|
|
445
|
+
let mappedUtxos = [];
|
|
445
446
|
for (const utxo of resolvedUtxos) {
|
|
446
|
-
mappedUtxos.
|
|
447
|
+
mappedUtxos.push(JSON.stringify(utxo));
|
|
447
448
|
}
|
|
448
|
-
|
|
449
|
+
if (!costModels || costModels.length !== 3) {
|
|
450
|
+
throw new Error(
|
|
451
|
+
"Cost models for all three Plutus versions must be provided"
|
|
452
|
+
);
|
|
453
|
+
}
|
|
454
|
+
let mappedCostModels = JSON.stringify({
|
|
455
|
+
plutus_v1: costModels[0],
|
|
456
|
+
plutus_v2: costModels[1],
|
|
457
|
+
plutus_v3: costModels[2]
|
|
458
|
+
});
|
|
459
|
+
const result = js_evaluate_tx_scripts(
|
|
449
460
|
txHex,
|
|
450
461
|
mappedUtxos,
|
|
451
462
|
additionalTxs,
|
|
452
|
-
|
|
463
|
+
mappedCostModels,
|
|
453
464
|
JSON.stringify(slotConfig)
|
|
454
465
|
);
|
|
455
466
|
const unwrappedResult = parseWasmResult(result);
|
|
@@ -2251,19 +2262,23 @@ var CSLSerializer = class {
|
|
|
2251
2262
|
|
|
2252
2263
|
// src/offline-providers/offline-evaluator.ts
|
|
2253
2264
|
import {
|
|
2265
|
+
DEFAULT_V1_COST_MODEL_LIST,
|
|
2266
|
+
DEFAULT_V2_COST_MODEL_LIST,
|
|
2267
|
+
DEFAULT_V3_COST_MODEL_LIST,
|
|
2254
2268
|
SLOT_CONFIG_NETWORK
|
|
2255
2269
|
} from "@meshsdk/common";
|
|
2256
2270
|
var OfflineEvaluator = class {
|
|
2257
2271
|
fetcher;
|
|
2258
2272
|
network;
|
|
2259
2273
|
slotConfig;
|
|
2274
|
+
costModels;
|
|
2260
2275
|
/**
|
|
2261
2276
|
* Creates a new instance of OfflineEvaluator.
|
|
2262
2277
|
* @param fetcher - An implementation of IFetcher to resolve transaction UTXOs
|
|
2263
2278
|
* @param network - The network to evaluate scripts for
|
|
2264
2279
|
* @param slotConfig - Slot configuration for the network (optional, defaults to network-specific values)
|
|
2265
2280
|
*/
|
|
2266
|
-
constructor(fetcher, network, slotConfig) {
|
|
2281
|
+
constructor(fetcher, network, slotConfig, customCostModels) {
|
|
2267
2282
|
this.fetcher = fetcher;
|
|
2268
2283
|
this.network = network;
|
|
2269
2284
|
this.slotConfig = slotConfig ?? {
|
|
@@ -2271,6 +2286,11 @@ var OfflineEvaluator = class {
|
|
|
2271
2286
|
zeroSlot: SLOT_CONFIG_NETWORK[network].zeroSlot,
|
|
2272
2287
|
zeroTime: SLOT_CONFIG_NETWORK[network].zeroTime
|
|
2273
2288
|
};
|
|
2289
|
+
this.costModels = customCostModels ?? [
|
|
2290
|
+
DEFAULT_V1_COST_MODEL_LIST,
|
|
2291
|
+
DEFAULT_V2_COST_MODEL_LIST,
|
|
2292
|
+
DEFAULT_V3_COST_MODEL_LIST
|
|
2293
|
+
];
|
|
2274
2294
|
}
|
|
2275
2295
|
/**
|
|
2276
2296
|
* Evaluates Plutus scripts in a transaction by resolving its input UTXOs and calculating execution costs.
|
|
@@ -2329,7 +2349,7 @@ var OfflineEvaluator = class {
|
|
|
2329
2349
|
tx,
|
|
2330
2350
|
additionalUtxos,
|
|
2331
2351
|
additionalTxs,
|
|
2332
|
-
this.
|
|
2352
|
+
this.costModels,
|
|
2333
2353
|
this.slotConfig
|
|
2334
2354
|
);
|
|
2335
2355
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@meshsdk/core-csl",
|
|
3
|
-
"version": "1.9.
|
|
3
|
+
"version": "1.9.1",
|
|
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",
|
|
@@ -38,13 +38,14 @@
|
|
|
38
38
|
"typescript": "^5.3.3"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@meshsdk/common": "1.9.
|
|
41
|
+
"@meshsdk/common": "1.9.1",
|
|
42
42
|
"@sidan-lab/whisky-js-browser": "^1.0.11",
|
|
43
43
|
"@sidan-lab/whisky-js-nodejs": "^1.0.11",
|
|
44
44
|
"@types/base32-encoding": "^1.0.2",
|
|
45
45
|
"base32-encoding": "^1.0.0",
|
|
46
46
|
"bech32": "^2.0.0",
|
|
47
|
-
"json-bigint": "^1.0.0"
|
|
47
|
+
"json-bigint": "^1.0.0",
|
|
48
|
+
"whisky-evaluator": "0.1.1"
|
|
48
49
|
},
|
|
49
50
|
"prettier": "@meshsdk/configs/prettier",
|
|
50
51
|
"publishConfig": {
|