Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
240 changes: 120 additions & 120 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion packages/mesh-common/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@meshsdk/common",
"version": "1.9.0-beta.104",
"version": "1.9.0",
"description": "Contains constants, types and interfaces used across the SDK and different serialization libraries",
"main": "./dist/index.cjs",
"browser": "./dist/index.js",
Expand Down
6 changes: 3 additions & 3 deletions packages/mesh-contract/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@meshsdk/contract",
"version": "1.9.0-beta.104",
"version": "1.9.0",
"description": "List of open-source smart contracts, complete with documentation, live demos, and end-to-end source code. https://meshjs.dev/smart-contracts",
"main": "./dist/index.cjs",
"browser": "./dist/index.js",
Expand Down Expand Up @@ -34,8 +34,8 @@
"typescript": "^5.3.3"
},
"dependencies": {
"@meshsdk/common": "1.9.0-beta.104",
"@meshsdk/core": "1.9.0-beta.104"
"@meshsdk/common": "1.9.0",
"@meshsdk/core": "1.9.0"
},
"prettier": "@meshsdk/configs/prettier",
"publishConfig": {
Expand Down
7 changes: 4 additions & 3 deletions packages/mesh-core-csl/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@meshsdk/core-csl",
"version": "1.9.0-beta.104",
"version": "1.9.0",
"description": "Types and utilities functions between Mesh and cardano-serialization-lib",
"main": "./dist/index.cjs",
"module": "./dist/index.js",
Expand Down Expand Up @@ -38,13 +38,14 @@
"typescript": "^5.3.3"
},
"dependencies": {
"@meshsdk/common": "1.9.0-beta.104",
"@meshsdk/common": "1.9.0",
"@sidan-lab/whisky-js-browser": "^1.0.11",
"@sidan-lab/whisky-js-nodejs": "^1.0.11",
"@types/base32-encoding": "^1.0.2",
"base32-encoding": "^1.0.0",
"bech32": "^2.0.0",
"json-bigint": "^1.0.0"
"json-bigint": "^1.0.0",
"whisky-evaluator": "0.1.1"
},
"prettier": "@meshsdk/configs/prettier",
"publishConfig": {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import {
Action,
DEFAULT_V1_COST_MODEL_LIST,
DEFAULT_V2_COST_MODEL_LIST,
DEFAULT_V3_COST_MODEL_LIST,
IEvaluator,
IFetcher,
Network,
Expand Down Expand Up @@ -70,6 +73,7 @@ export class OfflineEvaluator implements IEvaluator {
private readonly fetcher: IFetcher;
private readonly network: Network;
public slotConfig: Omit<Omit<SlotConfig, "startEpoch">, "epochLength">;
public costModels: number[][];

/**
* Creates a new instance of OfflineEvaluator.
Expand All @@ -81,6 +85,7 @@ export class OfflineEvaluator implements IEvaluator {
fetcher: IFetcher,
network: Network,
slotConfig?: Omit<Omit<SlotConfig, "startEpoch">, "epochLength">,
customCostModels?: number[][],
) {
this.fetcher = fetcher;
this.network = network;
Expand All @@ -89,6 +94,11 @@ export class OfflineEvaluator implements IEvaluator {
zeroSlot: SLOT_CONFIG_NETWORK[network].zeroSlot,
zeroTime: SLOT_CONFIG_NETWORK[network].zeroTime,
};
this.costModels = customCostModels ?? [
DEFAULT_V1_COST_MODEL_LIST,
DEFAULT_V2_COST_MODEL_LIST,
DEFAULT_V3_COST_MODEL_LIST,
];
}

/**
Expand Down Expand Up @@ -159,7 +169,7 @@ export class OfflineEvaluator implements IEvaluator {
tx,
additionalUtxos,
additionalTxs,
this.network,
this.costModels,
this.slotConfig,
);
}
Expand Down
25 changes: 18 additions & 7 deletions packages/mesh-core-csl/src/utils/transaction.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { js_get_tx_outs_utxo } from "@sidan-lab/whisky-js-nodejs";
import { js_evaluate_tx_scripts } from "whisky-evaluator";

import {
Action,
Expand Down Expand Up @@ -71,22 +72,32 @@ export const evaluateTransaction = (
txHex: string,
resolvedUtxos: UTxO[],
chainedTxs: string[],
network: Network,
costModels: number[][],
slotConfig: Omit<Omit<SlotConfig, "startEpoch">, "epochLength">,
): Omit<Action, "data">[] => {
const additionalTxs = csl.JsVecString.new();
let additionalTxs: string[] = [];
for (const tx of chainedTxs) {
additionalTxs.add(tx);
additionalTxs.push(tx);
}
const mappedUtxos = csl.JsVecString.new();
let mappedUtxos: string[] = [];
for (const utxo of resolvedUtxos) {
mappedUtxos.add(JSON.stringify(utxo));
mappedUtxos.push(JSON.stringify(utxo));
}
const result = csl.js_evaluate_tx_scripts(
if (!costModels || costModels.length !== 3) {
throw new Error(
"Cost models for all three Plutus versions must be provided",
);
}
let mappedCostModels: string = JSON.stringify({
plutus_v1: costModels[0],
plutus_v2: costModels[1],
plutus_v3: costModels[2],
});
const result = js_evaluate_tx_scripts(
txHex,
mappedUtxos,
additionalTxs,
network,
mappedCostModels,
JSON.stringify(slotConfig),
);
const unwrappedResult = parseWasmResult(result);
Expand Down
4 changes: 2 additions & 2 deletions packages/mesh-core-csl/src/wasm.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { csl } from "./deser/csl";
import { EvalWasmResult } from "whisky-evaluator";

export const parseWasmResult = (result: csl.WasmResult): string => {
export const parseWasmResult = (result: EvalWasmResult): string => {
if (result.get_status() !== "success") {
throw new Error(result.get_error());
}
Expand Down
140 changes: 65 additions & 75 deletions packages/mesh-core-csl/test/offline-providers/evaluator.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -338,17 +338,15 @@ describe("Offline Evaluator", () => {
return e;
});
expect(res).toBeInstanceOf(Error);
expect(res.message).toBe(
JSON.stringify([
{
index: 0,
budget: { mem: 550, steps: 1203691 },
tag: "mint",
errorMessage: "the validator crashed / exited prematurely",
logs: ["This is a trace"],
},
]),
);
expect(JSON.parse(res.message)).toEqual([
{
index: 0,
budget: { mem: 550, steps: 1203691 },
tag: "mint",
errorMessage: "the validator crashed / exited prematurely",
logs: ['Log("This is a trace")'],
},
]);
});

it("should log slot based on network defaults", async () => {
Expand Down Expand Up @@ -402,22 +400,20 @@ describe("Offline Evaluator", () => {
return e;
});
expect(res).toBeInstanceOf(Error);
expect(res.message).toBe(
JSON.stringify([
{
index: 0,
budget: { mem: 122164, steps: 41878310 },
tag: "spend",
errorMessage: "the validator crashed / exited prematurely",
logs: [
"time_now: 1734809125000",
"loan_term: 1734809132108",
"time_now > loan_term ? False",
"Validator returned false",
],
},
]),
);
expect(JSON.parse(res.message)).toEqual([
{
index: 0,
budget: { mem: 122164, steps: 41878310 },
tag: "spend",
errorMessage: "the validator crashed / exited prematurely",
logs: [
'Log("time_now: 1734809125000")',
'Log("loan_term: 1734809132108")',
'Log("time_now > loan_term ? False")',
'Log("Validator returned false")',
],
},
]);

const mainnetEvaluator = new OfflineEvaluator(fetcher, "mainnet");

Expand All @@ -432,22 +428,20 @@ describe("Offline Evaluator", () => {
});

expect(res2).toBeInstanceOf(Error);
expect(res2.message).toBe(
JSON.stringify([
{
index: 0,
budget: { mem: 122164, steps: 41878310 },
tag: "spend",
errorMessage: "the validator crashed / exited prematurely",
logs: [
"time_now: 1670692216000",
"loan_term: 1734809132108",
"time_now > loan_term ? False",
"Validator returned false",
],
},
]),
);
expect(JSON.parse(res2.message)).toEqual([
{
index: 0,
budget: { mem: 122164, steps: 41878310 },
tag: "spend",
errorMessage: "the validator crashed / exited prematurely",
logs: [
'Log("time_now: 1670692216000")',
'Log("loan_term: 1734809132108")',
'Log("time_now > loan_term ? False")',
'Log("Validator returned false")',
],
},
]);
});

it("should log slot based on config", async () => {
Expand Down Expand Up @@ -505,22 +499,20 @@ describe("Offline Evaluator", () => {
return e;
});
expect(res).toBeInstanceOf(Error);
expect(res.message).toBe(
JSON.stringify([
{
index: 0,
budget: { mem: 122164, steps: 41878310 },
tag: "spend",
errorMessage: "the validator crashed / exited prematurely",
logs: [
"time_now: 1670692216000",
"loan_term: 1734809132108",
"time_now > loan_term ? False",
"Validator returned false",
],
},
]),
);
expect(JSON.parse(res.message)).toEqual([
{
index: 0,
budget: { mem: 122164, steps: 41878310 },
tag: "spend",
errorMessage: "the validator crashed / exited prematurely",
logs: [
'Log("time_now: 1670692216000")',
'Log("loan_term: 1734809132108")',
'Log("time_now > loan_term ? False")',
'Log("Validator returned false")',
],
},
]);

const mainnetEvaluator = new OfflineEvaluator(fetcher, "mainnet", {
slotLength: SLOT_CONFIG_NETWORK.preprod.slotLength,
Expand All @@ -539,21 +531,19 @@ describe("Offline Evaluator", () => {
});

expect(res2).toBeInstanceOf(Error);
expect(res2.message).toBe(
JSON.stringify([
{
index: 0,
budget: { mem: 122164, steps: 41878310 },
tag: "spend",
errorMessage: "the validator crashed / exited prematurely",
logs: [
"time_now: 1734809125000",
"loan_term: 1734809132108",
"time_now > loan_term ? False",
"Validator returned false",
],
},
]),
);
expect(JSON.parse(res2.message)).toEqual([
{
index: 0,
budget: { mem: 122164, steps: 41878310 },
tag: "spend",
errorMessage: "the validator crashed / exited prematurely",
logs: [
'Log("time_now: 1734809125000")',
'Log("loan_term: 1734809132108")',
'Log("time_now > loan_term ? False")',
'Log("Validator returned false")',
],
},
]);
});
});
4 changes: 2 additions & 2 deletions packages/mesh-core-cst/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@meshsdk/core-cst",
"version": "1.9.0-beta.104",
"version": "1.9.0",
"description": "Types and utilities functions between Mesh and cardano-js-sdk",
"main": "./dist/index.cjs",
"browser": "./dist/index.js",
Expand Down Expand Up @@ -44,7 +44,7 @@
"@harmoniclabs/pair": "^1.0.0",
"@harmoniclabs/plutus-data": "1.2.6",
"@harmoniclabs/uplc": "1.4.1",
"@meshsdk/common": "1.9.0-beta.104",
"@meshsdk/common": "1.9.0",
"@types/base32-encoding": "^1.0.2",
"base32-encoding": "^1.0.0",
"bech32": "^2.0.0",
Expand Down
10 changes: 5 additions & 5 deletions packages/mesh-core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@meshsdk/core",
"version": "1.9.0-beta.104",
"version": "1.9.0",
"description": "Mesh SDK Core - https://meshjs.dev/",
"main": "./dist/index.cjs",
"browser": "./dist/index.js",
Expand Down Expand Up @@ -33,11 +33,11 @@
"typescript": "^5.3.3"
},
"dependencies": {
"@meshsdk/common": "1.9.0-beta.104",
"@meshsdk/core-cst": "1.9.0-beta.104",
"@meshsdk/common": "1.9.0",
"@meshsdk/core-cst": "1.9.0",
"@meshsdk/provider": "1.9.0-beta.101",
"@meshsdk/transaction": "1.9.0-beta.104",
"@meshsdk/wallet": "1.9.0-beta.104",
"@meshsdk/transaction": "1.9.0",
"@meshsdk/wallet": "1.9.0",
"scalus": "^0.17.0"
},
"prettier": "@meshsdk/configs/prettier",
Expand Down
6 changes: 3 additions & 3 deletions packages/mesh-transaction/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@meshsdk/transaction",
"version": "1.9.0-beta.104",
"version": "1.9.0",
"description": "Transactions - https://meshjs.dev/apis/transaction",
"main": "./dist/index.cjs",
"browser": "./dist/index.js",
Expand Down Expand Up @@ -35,8 +35,8 @@
"typescript": "^5.3.3"
},
"dependencies": {
"@meshsdk/common": "1.9.0-beta.104",
"@meshsdk/core-cst": "1.9.0-beta.104",
"@meshsdk/common": "1.9.0",
"@meshsdk/core-cst": "1.9.0",
"@cardano-sdk/core": "0.46.12",
"@cardano-sdk/util": "0.17.1",
"@cardano-sdk/input-selection": "0.14.28",
Expand Down
1 change: 0 additions & 1 deletion packages/mesh-transaction/src/mesh-tx-builder/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,6 @@ export class MeshTxBuilder extends MeshTxBuilderCore {
};

completeCostModels = async () => {
console.log("completing cost models...");
if (Array.isArray(this.meshTxBuilderBody.network)) {
return;
}
Expand Down
Loading
Loading