From 3d1a534b821bcdffc23395553e8c79101ccbce2a Mon Sep 17 00:00:00 2001 From: lisicky Date: Mon, 21 Oct 2024 23:08:33 +0800 Subject: [PATCH 01/16] add offline evaluator --- package-lock.json | 16 +-- packages/mesh-common/src/types/action.ts | 2 +- packages/mesh-core-csl/package.json | 6 +- .../mesh-core-csl/src/utils/transaction.ts | 103 +++++++++++++++++- packages/mesh-provider/src/index.ts | 2 +- packages/mesh-provider/src/offline/index.ts | 2 + .../src/offline/offline-evaluator.ts | 40 +++++++ .../test/offline/evaluator.test.ts | 45 ++++++++ 8 files changed, 202 insertions(+), 14 deletions(-) create mode 100644 packages/mesh-provider/src/offline/index.ts create mode 100644 packages/mesh-provider/src/offline/offline-evaluator.ts create mode 100644 packages/mesh-provider/test/offline/evaluator.test.ts diff --git a/package-lock.json b/package-lock.json index 7def41d62..1b979b8ad 100644 --- a/package-lock.json +++ b/package-lock.json @@ -13203,14 +13203,14 @@ "dev": true }, "node_modules/@sidan-lab/sidan-csl-rs-browser": { - "version": "0.8.7", - "resolved": "https://registry.npmjs.org/@sidan-lab/sidan-csl-rs-browser/-/sidan-csl-rs-browser-0.8.7.tgz", - "integrity": "sha512-8Psoxptlv9tyFRXj5YNR+74zeMoMdoLkGLf6jjzlxlD1MnQhw3qlJ3cPNsicDVfffcNRsPMAhicoH5qVWN8AgQ==" + "version": "0.9.4", + "resolved": "https://registry.npmjs.org/@sidan-lab/sidan-csl-rs-browser/-/sidan-csl-rs-browser-0.9.4.tgz", + "integrity": "sha512-+WUeS0aTkh+j/kSjY/qFcXdJQUfhKvZAAxXrjv+i2/EaIphcv1XDGb05CoPUaX+4nUh2lLssFAnc4tEhei3w/w==" }, "node_modules/@sidan-lab/sidan-csl-rs-nodejs": { - "version": "0.8.7", - "resolved": "https://registry.npmjs.org/@sidan-lab/sidan-csl-rs-nodejs/-/sidan-csl-rs-nodejs-0.8.7.tgz", - "integrity": "sha512-IAJyqDgKDesebJ/En4haphBO0zUEuz6mar3TDvtkqng/Kf6Pm7qBPp7vi5Yf2/A/S9Ik6gnIL8XflrGxNoqpVQ==" + "version": "0.9.4", + "resolved": "https://registry.npmjs.org/@sidan-lab/sidan-csl-rs-nodejs/-/sidan-csl-rs-nodejs-0.9.4.tgz", + "integrity": "sha512-dmuEkPiDWcdlkOiE72HS3EkY8/XwMxR/ottgrcNcUw6fw09CSL5lynqklQEkTgwV060btvhjZ87ELfEda3w/pA==" }, "node_modules/@sinclair/typebox": { "version": "0.27.8", @@ -29445,8 +29445,8 @@ "license": "Apache-2.0", "dependencies": { "@meshsdk/common": "1.7.9", - "@sidan-lab/sidan-csl-rs-browser": "0.8.7", - "@sidan-lab/sidan-csl-rs-nodejs": "0.8.7", + "@sidan-lab/sidan-csl-rs-browser": "0.9.4", + "@sidan-lab/sidan-csl-rs-nodejs": "0.9.4", "json-bigint": "^1.0.0" }, "devDependencies": { diff --git a/packages/mesh-common/src/types/action.ts b/packages/mesh-common/src/types/action.ts index fce94d795..1329d5244 100644 --- a/packages/mesh-common/src/types/action.ts +++ b/packages/mesh-common/src/types/action.ts @@ -1,6 +1,6 @@ import { Data } from "./data"; -export type RedeemerTagType = "CERT" | "MINT" | "REWARD" | "SPEND"; +export type RedeemerTagType = "CERT" | "MINT" | "REWARD" | "SPEND" | "VOTE" | "PROPOSE"; export type Action = { data: Data; diff --git a/packages/mesh-core-csl/package.json b/packages/mesh-core-csl/package.json index 50adeeb92..c2b8bb13e 100644 --- a/packages/mesh-core-csl/package.json +++ b/packages/mesh-core-csl/package.json @@ -39,8 +39,8 @@ }, "dependencies": { "@meshsdk/common": "1.7.9", - "@sidan-lab/sidan-csl-rs-browser": "0.8.7", - "@sidan-lab/sidan-csl-rs-nodejs": "0.8.7", + "@sidan-lab/sidan-csl-rs-browser": "0.9.4", + "@sidan-lab/sidan-csl-rs-nodejs": "0.9.4", "json-bigint": "^1.0.0" }, "prettier": "@meshsdk/configs/prettier", @@ -55,4 +55,4 @@ "blockchain", "sdk" ] -} \ No newline at end of file +} diff --git a/packages/mesh-core-csl/src/utils/transaction.ts b/packages/mesh-core-csl/src/utils/transaction.ts index 7a6b499b6..a7b68e9e0 100644 --- a/packages/mesh-core-csl/src/utils/transaction.ts +++ b/packages/mesh-core-csl/src/utils/transaction.ts @@ -1,5 +1,17 @@ -import { csl } from "../deser"; +import { csl, deserializeTx } from "../deser"; import { parseWasmResult } from "../wasm"; +import { UTxO, Network, Action, Budget, RedeemerTagType } from "@meshsdk/common"; + +type RedeemerTagWasm = "cert" | "mint" | "reward" | "spend" | "vote" | "propose"; +type ActionWasm = { + index: number; + budget: BudgetWasm; + tag: RedeemerTagWasm; +}; +type BudgetWasm = { + mem: number; + steps: number; +}; export const calculateTxHash = (txHex: string) => { const result = csl.js_calculate_tx_hash(txHex); @@ -14,3 +26,92 @@ export const signTransaction = (txHex: string, signingKeys: string[]) => { const result = csl.js_sign_transaction(txHex, cslSigningKeys); return parseWasmResult(result); }; + +export const evaluateTransaction = (txHex: string, resolvedUtxos: UTxO[], network: Network): Omit[] => { + const additionalTxs = csl.JsVecString.new(); + const mappedUtxos = csl.JsVecString.new(); + for (const utxo of resolvedUtxos) { + mappedUtxos.add(JSON.stringify(utxo)); + } + const result = csl.evaluate_tx_scripts_js(txHex, mappedUtxos, additionalTxs, network); + const unwrappedResult = parseWasmResult(result); + try { + const actions = JSON.parse(unwrappedResult) as ActionWasm[]; + return actions.map(mapAction); + } catch (e) { + throw new Error("Cannot parse result from evaluate_tx_scripts_js. Expected Action[] type"); + } +} + +const mapAction = (action: ActionWasm): Omit => { + return { + index: action.index, + budget: mapBudget(action.budget), + tag: mapRedeemerTag(action.tag), + }; +} + +const mapBudget = (budget: BudgetWasm): Budget => { + return { + mem: budget.mem, + steps: budget.steps, + }; +} + +const mapRedeemerTag = (tag: RedeemerTagWasm): RedeemerTagType => { + switch (tag) { + case "cert": + return "CERT" + case "mint": + return "MINT" + case "reward": + return "REWARD" + case "spend": + return "SPEND" + case "vote": + return "VOTE" + case "propose": + return "PROPOSE" + default: + throw new Error(`Unknown RedeemerTag: ${tag}`); + } +} + +export const getTransactionInputs = (txHex: string): { + txHash: string; + index: number; +}[] => { + const inputs = [] + const deserializedTx = deserializeTx(txHex); + const body = deserializedTx.body(); + const cslInputs = body.inputs(); + for (let i = 0; i < cslInputs.len(); i++) { + const input = cslInputs.get(i); + inputs.push({ + txHash: input.transaction_id().to_hex(), + index: input.index(), + }); + } + const cslCollaterals = body.collateral(); + if (cslCollaterals) { + for (let i = 0; i < cslCollaterals.len(); i++) { + const collateral = cslCollaterals.get(i); + inputs.push({ + txHash: collateral.transaction_id().to_hex(), + index: collateral.index(), + }); + } + } + const cslRefInputs = body.reference_inputs(); + if (cslRefInputs) { + for (let i = 0; i < cslRefInputs.len(); i++) { + const refInput = cslRefInputs.get(i); + inputs.push({ + txHash: refInput.transaction_id().to_hex(), + index: refInput.index(), + }); + } + } + + return inputs; +} diff --git a/packages/mesh-provider/src/index.ts b/packages/mesh-provider/src/index.ts index c8073036c..72189ad0d 100644 --- a/packages/mesh-provider/src/index.ts +++ b/packages/mesh-provider/src/index.ts @@ -6,4 +6,4 @@ export * from "./maestro"; export * from "./ogmios"; export * from "./utxo-rpc"; export * from "./yaci"; -export * from "./offline/offline-fetcher"; +export * from "./offline"; diff --git a/packages/mesh-provider/src/offline/index.ts b/packages/mesh-provider/src/offline/index.ts new file mode 100644 index 000000000..f38d58241 --- /dev/null +++ b/packages/mesh-provider/src/offline/index.ts @@ -0,0 +1,2 @@ +export * from "./offline-fetcher"; +export * from "./offline-evaluator"; diff --git a/packages/mesh-provider/src/offline/offline-evaluator.ts b/packages/mesh-provider/src/offline/offline-evaluator.ts new file mode 100644 index 000000000..18b8a4b62 --- /dev/null +++ b/packages/mesh-provider/src/offline/offline-evaluator.ts @@ -0,0 +1,40 @@ +import { + IEvaluator, + IFetcher, + UTxO, + Action, + Network +} from "@meshsdk/common"; +import { evaluateTransaction, getTransactionInputs } from "@meshsdk/core-csl"; + +export class OfflineEvaluator implements IEvaluator { + + private readonly fetcher: IFetcher; + private readonly network: Network; + + constructor(fetcher: IFetcher, network: Network) { + this.fetcher = fetcher; + this.network = network; + } + + async evaluateTx(tx: string): Promise[]> { + const inputsToResolve = getTransactionInputs(tx); + const txHashesSet = new Set(inputsToResolve.map(input => input.txHash)); + const resolvedUTXOs: UTxO[] = []; + for (const txHash of txHashesSet) { + const utxos = await this.fetcher.fetchUTxOs(txHash); + for (const utxo of utxos) { + if (utxo) + if (inputsToResolve.find(input => input.txHash === txHash && input.index === utxo.input.outputIndex)) { + resolvedUTXOs.push(utxo); + } + } + } + if (resolvedUTXOs.length !== inputsToResolve.length) { + const missing = inputsToResolve.filter(input => !resolvedUTXOs.find(utxo => utxo.input.txHash === input.txHash && utxo.input.outputIndex === input.index)); + const missingList = missing.map(m => `${m.txHash}:${m.index}`).join(", "); + throw new Error(`Can't resolve these UTXOs to execute plutus scripts: ${missingList}`); + } + return evaluateTransaction(tx, resolvedUTXOs, this.network); + } +} diff --git a/packages/mesh-provider/test/offline/evaluator.test.ts b/packages/mesh-provider/test/offline/evaluator.test.ts new file mode 100644 index 000000000..01ca93276 --- /dev/null +++ b/packages/mesh-provider/test/offline/evaluator.test.ts @@ -0,0 +1,45 @@ +import { + OfflineEvaluator, + OfflineFetcher +} from "../../src"; + +describe("Offline Evaluator", () => { + let evaluator: OfflineEvaluator; + let fetcher: OfflineFetcher; + + beforeEach(() => { + fetcher = new OfflineFetcher(); + evaluator = new OfflineEvaluator(fetcher, "preprod"); + }); + + it("should successfully evaluate correct tx", async () => { + const txHex = "84a900818258205de23a200f136e657307bc69173dddaf38b446bd7242a50f5bf255e329018b65030182a300581d70eafce55e4f0e057b495f77d8019577c56ae1fe188dc7e6d63f4f93b801821a001e8480a1581c32b7e3d552b2b18cb9bf1a39e6e1ce75f62c084f2b917a44c071a3bda14001028201d81858b4d8799f582461666461373264392d383039332d343330332d623030652d3233616362323934313432661a06acfc00d8799fd8799f581c5e0abc8c791c220b8c56e729cb77e95c03c7bd27971896dda0ac2368ffd8799fd8799fd8799f581cc8fdacb82c1cec476d444f559c28f4b75ddb6f483fe20427683a661affffffff1b0000019223dc5f75d8799fd8799f58205f759f3527a47632735470586a7ab2fbee4b4aa8b6504d52d52bc62fa8ec961aff00ff01ff825839005e0abc8c791c220b8c56e729cb77e95c03c7bd27971896dda0ac2368c8fdacb82c1cec476d444f559c28f4b75ddb6f483fe20427683a661a1a15a2ae54021a000d5ab0031a0442ee8109a1581c32b7e3d552b2b18cb9bf1a39e6e1ce75f62c084f2b917a44c071a3bda140010b5820c131e4b612c1a50ddcb739f58185148a26c6beaa198d036f5f9e4e8c7d458de20d8382582002345ff40e1b8730434571b8b4749ad084b2cd582aa8997fa7416be8b76c7da80082582002345ff40e1b8730434571b8b4749ad084b2cd582aa8997fa7416be8b76c7da8058258201c4ef054932bafcb4a59810f31fa0ed001d6611066938d1a1aef1d1237c0a441020e81581cc6aa7af71f8ba577246149edf075d2edd9daa63980b7ca176799af6c128382582066b7282bad1aef9ba0a99f06e618d651d232d4788f0d2ee2d22db22a62391033008258205f759f3527a47632735470586a7ab2fbee4b4aa8b6504d52d52bc62fa8ec961a008258201c4ef054932bafcb4a59810f31fa0ed001d6611066938d1a1aef1d1237c0a44100a10581840100d8799fd8799f58205f759f3527a47632735470586a7ab2fbee4b4aa8b6504d52d52bc62fa8ec961aff00ff821a006acfc01ab2d05e00f5f6"; + const utxo_1 = { input: { outputIndex: 3, txHash: "5de23a200f136e657307bc69173dddaf38b446bd7242a50f5bf255e329018b65" }, output: { address: "addr_test1qrsaqj54nyedfg74tye8743tkrclgnfztj6z937g50q0fwv6vwcuvc9guftgju6xav470f6da9guk8t3nn46wd34z43s99hwxv", amount: [{ unit: "lovelace", quantity: "365858180" }], scriptHash: undefined } }; + const utxo_2 = { input: { outputIndex: 0, txHash: "02345ff40e1b8730434571b8b4749ad084b2cd582aa8997fa7416be8b76c7da8" }, output: { address: "addr_test1qrsaqj54nyedfg74tye8743tkrclgnfztj6z937g50q0fwv6vwcuvc9guftgju6xav470f6da9guk8t3nn46wd34z43s99hwxv", amount: [{ unit: "lovelace", quantity: "5000000" }], scriptHash: undefined } }; + const utxo_3 = { input: { outputIndex: 5, txHash: "02345ff40e1b8730434571b8b4749ad084b2cd582aa8997fa7416be8b76c7da8" }, output: { address: "addr_test1qrsaqj54nyedfg74tye8743tkrclgnfztj6z937g50q0fwv6vwcuvc9guftgju6xav470f6da9guk8t3nn46wd34z43s99hwxv", amount: [{ unit: "lovelace", quantity: "5000000" }], scriptHash: undefined } }; + const utxo_4 = { input: { outputIndex: 0, txHash: "1c4ef054932bafcb4a59810f31fa0ed001d6611066938d1a1aef1d1237c0a441" }, output: { address: "addr_test1qrsaqj54nyedfg74tye8743tkrclgnfztj6z937g50q0fwv6vwcuvc9guftgju6xav470f6da9guk8t3nn46wd34z43s99hwxv", amount: [{ unit: "lovelace", quantity: "123000000" }], scriptHash: undefined } }; + const utxo_5 = { input: { outputIndex: 2, txHash: "1c4ef054932bafcb4a59810f31fa0ed001d6611066938d1a1aef1d1237c0a441" }, output: { address: "addr_test1qrsaqj54nyedfg74tye8743tkrclgnfztj6z937g50q0fwv6vwcuvc9guftgju6xav470f6da9guk8t3nn46wd34z43s99hwxv", amount: [{ unit: "lovelace", quantity: "5000000" }], scriptHash: undefined } }; + const utxo_6 = { input: { outputIndex: 0, txHash: "66b7282bad1aef9ba0a99f06e618d651d232d4788f0d2ee2d22db22a62391033" }, output: { address: "addr_test1qp0q40yv0ywzyzuv2mnjnjmha9wq83aay7t339ka5zkzx6xglkktstqua3rk63z02kwz3a9hthdk7jplugzzw6p6vcdqa39gds", amount: [{ unit: "lovelace", quantity: "26000000" }], scriptHash: "32b7e3d552b2b18cb9bf1a39e6e1ce75f62c084f2b917a44c071a3bd", scriptRef: "8202590eca590ec701000033232323232323223223232322533300832323232323232323232323232323232323232323232323232323232323232323232323232323232325333031302d30323754002264a66606460540022a666064666018910103313333000063758601660686ea8c080c0d0dd50158a9998191998050031bac301130343754604060686ea80acdd61810181a1baa30203034375405626666444464646464a666074606c60766ea80044c8c8c8c8c8c8c94ccc10402854ccc10402454ccc10401854ccc10400c54ccc10400840045280a5014a0294052819192999821181f0008b0a999821181d000899b89375a608e60886ea8008dd6982398241824182418221baa0061630423754002605c60846ea8c114c118c108dd50059980f99baf301a30413754006605a60826ea8059240132496e74656e7420646174756d2073686f756c6420636f6e7461696e20616c6c206d61746368696e6720726566732075736564003301e3375e605860806ea8010c084c100dd50092493f496e74656e7420746f6b656e2073686f756c64206f6e6c7920657665722062652073656e7420746f20696e74656e74207370656e64696e672073637269707400533303d3039303e37540022646464646464646464646464a666098609e0042646493182280218178038b18268009826801182580098258011bad3049001304900230470013047002375a608a002608a0046086002607e6ea800458cc0640092401264f7574707574206d75737420636f6e7461696e20736f6d6520696e6c696e656420646174756d003301b3024301c323300100137566036607c6ea8008894ccc10000452f5c0264666444646600200200644a66608c0022006264660906e9ccc120dd4803198241822800998241823000a5eb80cc00c00cc128008c120004dd7181f8009bab304000133003003304400230420014901224f6e6c792061646120616c6c6f776564207769746820696e74656e7420746f6b656e00303f303c37540022ca6660780062980103d87a80001302d3303d303e0034bd701980c1818181380124812e4f6e6c7920612073696e676c65206f7574707574207769746820696e74656e7420746f6b656e20616c6c6f77656400330173375e6e98c04c00cdd31991299981c9818a4000297adef6c6013232330010014bd6f7b63011299981f80089982019bb0375200a6e9800d2f5bded8c0264646464a66608066e400240084cc110cdd81ba9009374c00e00a2a66608066e3c0240084cc110cdd81ba9009374c00e00626608866ec0dd48011ba600133006006003375660820066eb8c0fc008c10c008c104004c8cc0040052f5bded8c044a66607c00226607e66ec0dd4801a610101004bd6f7b630099191919299981f99b90007002133043337606ea401d3010101000051533303f3371e00e00426608666ec0dd4803a61010100003133043337606ea4008dd4000998030030019bad3040003375c607c004608400460800026eb8c094c0e4dd50029bae30163039375400a9212b4f6e6c7920612073696e676c6520696e74656e7420746f6b656e2073686f756c64206265206d696e74656400330280032302f3330153756602c60726ea8004dd71812981c9baa005375c602c60726ea8014c098cc0d8dd48021981b2610140004bd701bac301530343754604060686ea80acdd59806981a1baa302030343754056606e607060706070607060706070607060686ea8c080c0d0dd50158a5014a02a66606466e2000520001533303233300c488103313838000063758601660686ea8c080c0d0dd501589998050031bac301130343754604060686ea80acdd61810181a1baa302030343754056294058dd6981b18199baa00116533303030283301501500113301b0014890014c103d87a8000325333030302830313754002297adef6c6013756606a60646ea8004cc064c02cdd5980518189baa301d3031375405000264a66605e605660606ea80044dd7181a18189baa00116300d3030375404ea66605a6052605c6ea80044c8c8c8c8c8c8c8c8c8c8c8c8c8c8c8c8c8c94ccc108c1140084c8c8c8c8c8c8c926302b00b302a00c302a00d302900e302700f303b010533303f303b3040375402226464a666088608e004264931981b000919181798228011bae3043001163756608a00260826ea80445858c10c004c10c008dd698208009820801181f800981f801181e800981e801181d800981d801181c800981c801181b800981b801181a800981a801181980098179baa00116300f302e3754004a666056604e60586ea80044c8c8c8c8c8c94ccc0d0c0dc0084c8c926301a00430190051630350013035002303300130330023031001302d37540022c6600e601260586ea800524011e436f6c642072656620646174756d206d75737420626520696e6c696e6564003232533302b323300100102a22533303000114a0264a66605c64604e66601a6eacc038c0c4dd5180718189baa005375c603a60626ea8004dd7180718189baa001303300214a2266006006002606600220022ca666054604c60566ea80044c0bcc0b0dd50008b198069bac3008302b3754602e60566ea8088098888c94ccc0b14ccc0b0c090c0b4dd519808001980598171baa0041614a2200229414ccc0acc09cc0b0dd519807800980518169baa0031614a24605a605c605c605c605c605c605c605c605c00244464660020026464a6660586050605a6ea80044c0c4c0b8dd50008992999816981498171baa00113032302f37540022c6603e00491010130003301e0010053756603060586ea8c060c0b0dd5001912999815981398161baa001132323300100100522533303100114a0264a66605e66e3cdd7181a0010020a511330030030013034001375c6060605a6ea80044c8cdc49bad30313032001301b3301e375860620024660080080026eb0c0c0c0b4dd5000918159816181618161816000919198008008011129998150008a5eb7bdb1804c8c8c8c94ccc0accdc8a45000021533302b3371e9101000021003100513302f337606ea4008dd3000998030030019bab302c003375c6054004605c00460580024464a66604c601e604e6ea80044c0acc0a0dd50008b180418139baa002222325333026301e302737540022900009bad302b3028375400264a66604c603c604e6ea8004530103d87a80001330113756605660506ea8004008cc03c00c0088c09cc0a0004894ccc0880085288b18008009129998118008a40002602266004004604c002460466048604800244646600200200644a666046002298103d87a80001323253330223375e602060486ea80080144c058cc0980092f5c0266008008002604e004604a00244a66604000229000098071980100118118009299980d980b980e1baa0011323232325333022302500213232498c94ccc084c0740044c8c94ccc098c0a40084c9263019001163027001302337540062a66604260320022a66604860466ea800c526161630213754004602c0062c604600260460046042002603a6ea80045894ccc068c058c06cdd5000899191919299981098120010a4c2c6eb8c088004c088008dd71810000980e1baa00116232533301a301600113232533301f3022002149858dd71810000980e1baa0021533301a301200113232533301f3022002132498c05c00458c080004c070dd50010a99980d180180089919299980f981100109924c60240022c604000260386ea800854ccc068cdc3a400c00226464a66603e60440042649319299980e980c800899192999811181280109924c602a0022c6046002603e6ea800854ccc074c0540044c8c94ccc088c0940084c9263015001163023001301f37540042a66603a600c002264646464a666048604e00426493180b8018b1bae302500130250023023001301f37540042a66603a66e1d200600113232323253330243027002149858dd7181280098128011bae3023001301f37540042a66603a66e1d200800113232323253330243027002149858dd6981280098128011bae3023001301f37540042a66603a66e1d200a00115333020301f37540042930b0a99980e99b874803000454ccc080c07cdd50010a4c2c2c603a6ea800458c080004c070dd50010b180d1baa001370e900211191980080080191299980e8008a60103d87a8000132323232533301e3372200e0042a66603c66e3c01c0084c048cc088dd3000a5eb80530103d87a80001330060060033756603e0066eb8c074008c084008c07c00488c8cc00400400c894ccc0700045300103d87a8000132323232533301d3372200e0042a66603a66e3c01c0084c044cc084dd4000a5eb80530103d87a8000133006006003375a603c0066eb8c070008c080008c078004c00400488c94ccc058c0480044c8c94ccc06cc07800852616375c603800260306ea800854ccc058c0380044c8c94ccc06cc0780084c926323232533301e3021002132498cc04000c8cc02402400458dd6980f800980f8011bac301d001163758603800260306ea800858c058dd50009180c000980080091299980a8008a4000260066600400460300026e01200222323300100100322533301500114bd7009919299980a180280109980c00119802002000899802002000980c801180b80091191980080080191299980a0008a6103d87a800013232323253330153372200e0042a66602a66e3c01c0084c024cc0640052f5c0298103d87a80001330060060033016003375c60280046030004602c0026e95200022323300100100322533301200114984c8cc00c00cc058008c00cc0500048c94ccc030c0200044c8c94ccc044c0500084c9263005001163012001300e37540042a66601860080022646464646464a66602a60300042930b1bad30160013016002375a602800260280046eb4c048004c038dd50010b18061baa001232533300b30070011323253330103013002149858dd7180880098069baa0021533300b30030011323253330103013002149858dd7180880098069baa00216300b37540026e1d200214984d958c00400c94ccc018c008c01cdd50008991919192999806980800109924ca666014600c60166ea800c4c8c94ccc03cc04800852616375c602000260186ea800c5858dd698070009807001180600098041baa00116370e90001bac0015734aae7555cf2ab9f5740ae855d12601259fd8799f581c55871db8a58f10fddf48b92029827d168271e785646af257de85486c40ffff0001" } }; + const utxo_7 = { input: { outputIndex: 0, txHash: "5f759f3527a47632735470586a7ab2fbee4b4aa8b6504d52d52bc62fa8ec961a" }, output: { address: "addr_test1qp0q40yv0ywzyzuv2mnjnjmha9wq83aay7t339ka5zkzx6xglkktstqua3rk63z02kwz3a9hthdk7jplugzzw6p6vcdqa39gds", amount: [{ unit: "lovelace", quantity: "4000000" }, { unit: "55871db8a58f10fddf48b92029827d168271e785646af257de85486c", quantity: "1" }], dataHash: "a5a21bf7d9119e01f8cf04316dba1d9cdcacd998430728fdb938de8dad4b6c1f", "plutusData": "d8799fd8799f581c0eb1e4ef980b3c308edd7b3ab64990d5240e5230286038cae5c634cdffd8799f581c1fdf3668220c08618b4f2e5e7cc54f70ca4b11fd2b6a3fbe678235f1ffd8799fd8799fa14130d8799f581cc6aa7af71f8ba577246149edf075d2edd9daa63980b7ca176799af6cffffd8799fd8799f58201c4ef054932bafcb4a59810f31fa0ed001d6611066938d1a1aef1d1237c0a441ff00ffd8799fd87a9f581ceafce55e4f0e057b495f77d8019577c56ae1fe188dc7e6d63f4f93b8ffd87a80ffd8799f581c32b7e3d552b2b18cb9bf1a39e6e1ce75f62c084f2b917a44c071a3bd40ffd8799f581cdbde35dec305604c1c8a596437802fd5e3468c8e92ce1781203e7bb74455534441ffd8799fd87a9f581c10fcea52f80dbc6e499106b02894173a2e60d21c6b3d1fe881d9495dffd87a80ffd8799fd8799f581cc6aa7af71f8ba577246149edf075d2edd9daa63980b7ca176799af6cffd87a80ff1903e801ffff", scriptHash: undefined } }; + fetcher.addUTxOs([utxo_1, utxo_2, utxo_3, utxo_4, utxo_5, utxo_6, utxo_7]); + + const res = await evaluator.evaluateTx(txHex); + expect(res).toStrictEqual( + [ + { + index: 0, + tag: "MINT", + budget: { + mem: 508703, + steps: 164980381, + } + } + ] + ) + }); + + it("should fail evaluating incorrect tx", async () => { + const res = await evaluator.evaluateTx("84a900818258205de23a200f136e657307bc69173dddaf38b446bd7242a50f5bf255").catch(() => "error"); + expect(res).toBe("error"); + }); +}); From 60de86a149c1bb0e15b2e2ea73ce5e43f71a56c0 Mon Sep 17 00:00:00 2001 From: lisicky Date: Mon, 28 Oct 2024 03:19:48 +0800 Subject: [PATCH 02/16] fix for tests --- packages/mesh-core-csl/test/core/builder.test.ts | 2 +- packages/mesh-provider/test/offline/evaluator.test.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/mesh-core-csl/test/core/builder.test.ts b/packages/mesh-core-csl/test/core/builder.test.ts index 726b23d6b..bc690b184 100644 --- a/packages/mesh-core-csl/test/core/builder.test.ts +++ b/packages/mesh-core-csl/test/core/builder.test.ts @@ -95,7 +95,7 @@ describe("Builder", () => { }; const txHex = serializer.serializeTxBody(body, DEFAULT_PROTOCOL_PARAMETERS); expect(txHex).toEqual( - "84a300818258201662c4b349907e4d92e0995fd9dcdc9a4489f7dff4f5cce6b4b3901de479308c0e0182825839001e4eb194e3335a0dcc4f5c5d009318167c583bb3b0879d9f718cd9e0d63a93470bd4d8bb986c02ff8a6043796b91cc397ceb29058f5c9ac01a0012c97f825839001e4eb194e3335a0dcc4f5c5d009318167c583bb3b0879d9f718cd9e0d63a93470bd4d8bb986c02ff8a6043796b91cc397ceb29058f5c9ac01a2e16c3f4021a00029075a0f5f6", + "84a300d90102818258201662c4b349907e4d92e0995fd9dcdc9a4489f7dff4f5cce6b4b3901de479308c0e0182825839001e4eb194e3335a0dcc4f5c5d009318167c583bb3b0879d9f718cd9e0d63a93470bd4d8bb986c02ff8a6043796b91cc397ceb29058f5c9ac01a0012c97f825839001e4eb194e3335a0dcc4f5c5d009318167c583bb3b0879d9f718cd9e0d63a93470bd4d8bb986c02ff8a6043796b91cc397ceb29058f5c9ac01a2e16c2ec021a0002917da0f5f6", ); }); }); diff --git a/packages/mesh-provider/test/offline/evaluator.test.ts b/packages/mesh-provider/test/offline/evaluator.test.ts index 01ca93276..ea6c52bcb 100644 --- a/packages/mesh-provider/test/offline/evaluator.test.ts +++ b/packages/mesh-provider/test/offline/evaluator.test.ts @@ -1,7 +1,7 @@ import { OfflineEvaluator, OfflineFetcher -} from "../../src"; +} from "@meshsdk/provider"; describe("Offline Evaluator", () => { let evaluator: OfflineEvaluator; From 5efcf9b5e86d7689ae6cd4e642cbedb3ebb3219e Mon Sep 17 00:00:00 2001 From: lisicky Date: Mon, 28 Oct 2024 15:10:44 +0800 Subject: [PATCH 03/16] try to fix playground --- apps/playground/next.config.js | 15 +++++++++++++++ apps/playground/package.json | 3 ++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/apps/playground/next.config.js b/apps/playground/next.config.js index d4cde4ff5..3d5bf5981 100644 --- a/apps/playground/next.config.js +++ b/apps/playground/next.config.js @@ -1,4 +1,5 @@ const withMDX = require("@next/mdx")(); +const CopyWebpackPlugin = require('copy-webpack-plugin'); /** @type {import('next').NextConfig} */ const nextConfig = { @@ -8,6 +9,20 @@ const nextConfig = { asyncWebAssembly: true, layers: true, }; + config.plugins.push( + new CopyWebpackPlugin({ + patterns: [ + { + from: '../../node_modules/@sidan-lab/sidan-csl-rs-browser/*.wasm', + to: 'static/chunks/[name][ext]', + }, + { + from: '../../node_modules/@sidan-lab/sidan-csl-rs-nodejs/*.wasm', + to: 'server/chunks/[name][ext]', + }, + ], + }) + ); return config; }, pageExtensions: ["js", "jsx", "mdx", "ts", "tsx"], diff --git a/apps/playground/package.json b/apps/playground/package.json index 937a59314..30c1e5980 100644 --- a/apps/playground/package.json +++ b/apps/playground/package.json @@ -49,7 +49,8 @@ "eslint": "^8.57.0", "postcss": "^8.4.38", "tailwindcss": "^3.4.3", - "typescript": "^5.3.3" + "typescript": "^5.3.3", + "copy-webpack-plugin": "^12.0.2" }, "prettier": "@meshsdk/configs/prettier" } From 150b8b01a6ca1a9c54024cf066b75e0399c1002c Mon Sep 17 00:00:00 2001 From: lisicky Date: Wed, 30 Oct 2024 02:37:58 +0800 Subject: [PATCH 04/16] revert: try to fix playground --- apps/playground/next.config.js | 15 --------------- apps/playground/package.json | 3 +-- 2 files changed, 1 insertion(+), 17 deletions(-) diff --git a/apps/playground/next.config.js b/apps/playground/next.config.js index 3d5bf5981..d4cde4ff5 100644 --- a/apps/playground/next.config.js +++ b/apps/playground/next.config.js @@ -1,5 +1,4 @@ const withMDX = require("@next/mdx")(); -const CopyWebpackPlugin = require('copy-webpack-plugin'); /** @type {import('next').NextConfig} */ const nextConfig = { @@ -9,20 +8,6 @@ const nextConfig = { asyncWebAssembly: true, layers: true, }; - config.plugins.push( - new CopyWebpackPlugin({ - patterns: [ - { - from: '../../node_modules/@sidan-lab/sidan-csl-rs-browser/*.wasm', - to: 'static/chunks/[name][ext]', - }, - { - from: '../../node_modules/@sidan-lab/sidan-csl-rs-nodejs/*.wasm', - to: 'server/chunks/[name][ext]', - }, - ], - }) - ); return config; }, pageExtensions: ["js", "jsx", "mdx", "ts", "tsx"], diff --git a/apps/playground/package.json b/apps/playground/package.json index 30c1e5980..937a59314 100644 --- a/apps/playground/package.json +++ b/apps/playground/package.json @@ -49,8 +49,7 @@ "eslint": "^8.57.0", "postcss": "^8.4.38", "tailwindcss": "^3.4.3", - "typescript": "^5.3.3", - "copy-webpack-plugin": "^12.0.2" + "typescript": "^5.3.3" }, "prettier": "@meshsdk/configs/prettier" } From f8e8d5e148913f3145f4c5c922ec13a158ff7b2a Mon Sep 17 00:00:00 2001 From: lisicky Date: Wed, 30 Oct 2024 02:59:28 +0800 Subject: [PATCH 05/16] move offline evaluator --- package-lock.json | 1 + packages/mesh-core-csl/package.json | 1 + packages/mesh-core-csl/src/index.ts | 1 + packages/mesh-core-csl/src/offline-providers/index.ts | 1 + .../src/offline-providers}/offline-evaluator.ts | 2 +- .../test/offline-providers}/evaluator.test.ts | 6 ++---- packages/mesh-provider/src/offline/index.ts | 1 - 7 files changed, 7 insertions(+), 6 deletions(-) create mode 100644 packages/mesh-core-csl/src/offline-providers/index.ts rename packages/{mesh-provider/src/offline => mesh-core-csl/src/offline-providers}/offline-evaluator.ts (94%) rename packages/{mesh-provider/test/offline => mesh-core-csl/test/offline-providers}/evaluator.test.ts (99%) diff --git a/package-lock.json b/package-lock.json index 1b979b8ad..e826fea6e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -29451,6 +29451,7 @@ }, "devDependencies": { "@meshsdk/configs": "*", + "@meshsdk/provider": "*", "@types/json-bigint": "^1.0.4", "eslint": "^8.57.0", "ts-jest": "^29.1.4", diff --git a/packages/mesh-core-csl/package.json b/packages/mesh-core-csl/package.json index c2b8bb13e..31d0b402c 100644 --- a/packages/mesh-core-csl/package.json +++ b/packages/mesh-core-csl/package.json @@ -31,6 +31,7 @@ }, "devDependencies": { "@meshsdk/configs": "*", + "@meshsdk/provider": "*", "@types/json-bigint": "^1.0.4", "eslint": "^8.57.0", "ts-jest": "^29.1.4", diff --git a/packages/mesh-core-csl/src/index.ts b/packages/mesh-core-csl/src/index.ts index 64a2e4bfa..1a5d82504 100644 --- a/packages/mesh-core-csl/src/index.ts +++ b/packages/mesh-core-csl/src/index.ts @@ -1,3 +1,4 @@ export * from "./utils"; export * from "./core"; export * from "./deser"; +export * from "./offline-providers"; diff --git a/packages/mesh-core-csl/src/offline-providers/index.ts b/packages/mesh-core-csl/src/offline-providers/index.ts new file mode 100644 index 000000000..75b1a0ded --- /dev/null +++ b/packages/mesh-core-csl/src/offline-providers/index.ts @@ -0,0 +1 @@ +export * from "./offline-evaluator" diff --git a/packages/mesh-provider/src/offline/offline-evaluator.ts b/packages/mesh-core-csl/src/offline-providers/offline-evaluator.ts similarity index 94% rename from packages/mesh-provider/src/offline/offline-evaluator.ts rename to packages/mesh-core-csl/src/offline-providers/offline-evaluator.ts index 18b8a4b62..9623d0a22 100644 --- a/packages/mesh-provider/src/offline/offline-evaluator.ts +++ b/packages/mesh-core-csl/src/offline-providers/offline-evaluator.ts @@ -5,7 +5,7 @@ import { Action, Network } from "@meshsdk/common"; -import { evaluateTransaction, getTransactionInputs } from "@meshsdk/core-csl"; +import { evaluateTransaction, getTransactionInputs } from "../utils"; export class OfflineEvaluator implements IEvaluator { diff --git a/packages/mesh-provider/test/offline/evaluator.test.ts b/packages/mesh-core-csl/test/offline-providers/evaluator.test.ts similarity index 99% rename from packages/mesh-provider/test/offline/evaluator.test.ts rename to packages/mesh-core-csl/test/offline-providers/evaluator.test.ts index ea6c52bcb..7c02f6fa5 100644 --- a/packages/mesh-provider/test/offline/evaluator.test.ts +++ b/packages/mesh-core-csl/test/offline-providers/evaluator.test.ts @@ -1,7 +1,5 @@ -import { - OfflineEvaluator, - OfflineFetcher -} from "@meshsdk/provider"; +import { OfflineFetcher } from "@meshsdk/provider"; +import { OfflineEvaluator } from "@meshsdk/core-csl"; describe("Offline Evaluator", () => { let evaluator: OfflineEvaluator; diff --git a/packages/mesh-provider/src/offline/index.ts b/packages/mesh-provider/src/offline/index.ts index f38d58241..08ef88907 100644 --- a/packages/mesh-provider/src/offline/index.ts +++ b/packages/mesh-provider/src/offline/index.ts @@ -1,2 +1 @@ export * from "./offline-fetcher"; -export * from "./offline-evaluator"; From 8d009df98e5de28a6b829ad8786a747919c15bd9 Mon Sep 17 00:00:00 2001 From: lisicky Date: Wed, 30 Oct 2024 03:02:37 +0800 Subject: [PATCH 06/16] merge fix --- package-lock.json | 69 +++++++++++++++-------------- packages/mesh-provider/package.json | 3 +- 2 files changed, 37 insertions(+), 35 deletions(-) diff --git a/package-lock.json b/package-lock.json index dd3325bd8..dac7f7c38 100644 --- a/package-lock.json +++ b/package-lock.json @@ -29377,7 +29377,7 @@ }, "packages/mesh-common": { "name": "@meshsdk/common", - "version": "1.7.9", + "version": "1.7.10", "license": "Apache-2.0", "dependencies": { "bech32": "^2.0.0", @@ -29394,12 +29394,12 @@ }, "packages/mesh-contract": { "name": "@meshsdk/contract", - "version": "1.7.9", + "version": "1.7.10", "license": "Apache-2.0", "dependencies": { - "@meshsdk/common": "1.7.9", - "@meshsdk/core": "1.7.9", - "@meshsdk/core-csl": "1.7.9" + "@meshsdk/common": "1.7.10", + "@meshsdk/core": "1.7.10", + "@meshsdk/core-csl": "1.7.10" }, "devDependencies": { "@meshsdk/configs": "*", @@ -29410,16 +29410,16 @@ }, "packages/mesh-core": { "name": "@meshsdk/core", - "version": "1.7.9", + "version": "1.7.10", "license": "Apache-2.0", "dependencies": { - "@meshsdk/common": "1.7.9", - "@meshsdk/core-csl": "1.7.9", - "@meshsdk/core-cst": "1.7.9", - "@meshsdk/provider": "1.7.9", - "@meshsdk/react": "1.7.9", - "@meshsdk/transaction": "1.7.9", - "@meshsdk/wallet": "1.7.9" + "@meshsdk/common": "1.7.10", + "@meshsdk/core-csl": "1.7.10", + "@meshsdk/core-cst": "1.7.10", + "@meshsdk/provider": "1.7.10", + "@meshsdk/react": "1.7.10", + "@meshsdk/transaction": "1.7.10", + "@meshsdk/wallet": "1.7.10" }, "devDependencies": { "@meshsdk/configs": "*", @@ -29430,10 +29430,10 @@ }, "packages/mesh-core-csl": { "name": "@meshsdk/core-csl", - "version": "1.7.9", + "version": "1.7.10", "license": "Apache-2.0", "dependencies": { - "@meshsdk/common": "1.7.9", + "@meshsdk/common": "1.7.10", "@sidan-lab/sidan-csl-rs-browser": "0.9.4", "@sidan-lab/sidan-csl-rs-nodejs": "0.9.4", "json-bigint": "^1.0.0" @@ -29449,7 +29449,7 @@ }, "packages/mesh-core-cst": { "name": "@meshsdk/core-cst", - "version": "1.7.9", + "version": "1.7.10", "license": "Apache-2.0", "dependencies": { "@cardano-sdk/core": "0.35.4", @@ -29458,7 +29458,7 @@ "@harmoniclabs/cbor": "1.3.0", "@harmoniclabs/plutus-data": "1.2.4", "@harmoniclabs/uplc": "1.2.4", - "@meshsdk/common": "1.7.9", + "@meshsdk/common": "1.7.10", "@stricahq/bip32ed25519": "^1.1.0", "@stricahq/cbors": "^1.0.0", "pbkdf2": "^3.1.2" @@ -29475,17 +29475,18 @@ }, "packages/mesh-provider": { "name": "@meshsdk/provider", - "version": "1.7.9", + "version": "1.7.10", "license": "Apache-2.0", "dependencies": { - "@meshsdk/common": "1.7.9", - "@meshsdk/core-cst": "1.7.9", + "@meshsdk/common": "1.7.10", + "@meshsdk/core-cst": "1.7.10", "@utxorpc/sdk": "0.6.2", "@utxorpc/spec": "0.10.1", "axios": "^1.7.2" }, "devDependencies": { "@meshsdk/configs": "*", + "@meshsdk/provider": "*", "eslint": "^8.57.0", "tsup": "^8.0.2", "typescript": "^5.3.3" @@ -29493,12 +29494,12 @@ }, "packages/mesh-react": { "name": "@meshsdk/react", - "version": "1.7.9", + "version": "1.7.10", "license": "Apache-2.0", "dependencies": { - "@meshsdk/common": "1.7.9", - "@meshsdk/transaction": "1.7.9", - "@meshsdk/wallet": "1.7.9", + "@meshsdk/common": "1.7.10", + "@meshsdk/transaction": "1.7.10", + "@meshsdk/wallet": "1.7.10", "react": "^18.2.0" }, "devDependencies": { @@ -29513,12 +29514,12 @@ }, "packages/mesh-transaction": { "name": "@meshsdk/transaction", - "version": "1.7.9", + "version": "1.7.10", "license": "Apache-2.0", "dependencies": { - "@meshsdk/common": "1.7.9", - "@meshsdk/core-csl": "1.7.9", - "@meshsdk/core-cst": "1.7.9", + "@meshsdk/common": "1.7.10", + "@meshsdk/core-csl": "1.7.10", + "@meshsdk/core-cst": "1.7.10", "json-bigint": "^1.0.0" }, "devDependencies": { @@ -29531,13 +29532,13 @@ }, "packages/mesh-wallet": { "name": "@meshsdk/wallet", - "version": "1.7.9", + "version": "1.7.10", "license": "Apache-2.0", "dependencies": { - "@meshsdk/common": "1.7.9", - "@meshsdk/core-csl": "1.7.9", - "@meshsdk/core-cst": "1.7.9", - "@meshsdk/transaction": "1.7.9", + "@meshsdk/common": "1.7.10", + "@meshsdk/core-csl": "1.7.10", + "@meshsdk/core-cst": "1.7.10", + "@meshsdk/transaction": "1.7.10", "@nufi/dapp-client-cardano": "0.3.5", "@nufi/dapp-client-core": "0.3.5" }, @@ -29551,7 +29552,7 @@ }, "scripts/mesh-cli": { "name": "meshjs", - "version": "1.7.9", + "version": "1.7.10", "license": "Apache-2.0", "dependencies": { "chalk": "5.3.0", diff --git a/packages/mesh-provider/package.json b/packages/mesh-provider/package.json index 8a9b11eae..dfb11ad22 100644 --- a/packages/mesh-provider/package.json +++ b/packages/mesh-provider/package.json @@ -29,6 +29,7 @@ }, "devDependencies": { "@meshsdk/configs": "*", + "@meshsdk/provider": "*", "eslint": "^8.57.0", "tsup": "^8.0.2", "typescript": "^5.3.3" @@ -52,4 +53,4 @@ "blockchain", "sdk" ] -} \ No newline at end of file +} From 47a628a73d9523fb9d918574705537d9f5284011 Mon Sep 17 00:00:00 2001 From: lisicky Date: Wed, 30 Oct 2024 03:05:12 +0800 Subject: [PATCH 07/16] merge fix --- package-lock.json | 3 +-- packages/mesh-core-cst/package.json | 3 ++- packages/mesh-provider/package.json | 2 -- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/package-lock.json b/package-lock.json index dac7f7c38..1ec19710e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -29465,6 +29465,7 @@ }, "devDependencies": { "@meshsdk/configs": "*", + "@meshsdk/provider": "*", "@types/pbkdf2": "^3.1.2", "eslint": "^8.57.0", "ts-jest": "^29.1.4", @@ -29479,14 +29480,12 @@ "license": "Apache-2.0", "dependencies": { "@meshsdk/common": "1.7.10", - "@meshsdk/core-cst": "1.7.10", "@utxorpc/sdk": "0.6.2", "@utxorpc/spec": "0.10.1", "axios": "^1.7.2" }, "devDependencies": { "@meshsdk/configs": "*", - "@meshsdk/provider": "*", "eslint": "^8.57.0", "tsup": "^8.0.2", "typescript": "^5.3.3" diff --git a/packages/mesh-core-cst/package.json b/packages/mesh-core-cst/package.json index fee8c6d0e..dfdf81c29 100644 --- a/packages/mesh-core-cst/package.json +++ b/packages/mesh-core-cst/package.json @@ -28,6 +28,7 @@ }, "devDependencies": { "@meshsdk/configs": "*", + "@meshsdk/provider": "*", "@types/pbkdf2": "^3.1.2", "eslint": "^8.57.0", "ts-jest": "^29.1.4", @@ -59,4 +60,4 @@ "blockchain", "sdk" ] -} \ No newline at end of file +} diff --git a/packages/mesh-provider/package.json b/packages/mesh-provider/package.json index dfb11ad22..209760d79 100644 --- a/packages/mesh-provider/package.json +++ b/packages/mesh-provider/package.json @@ -29,14 +29,12 @@ }, "devDependencies": { "@meshsdk/configs": "*", - "@meshsdk/provider": "*", "eslint": "^8.57.0", "tsup": "^8.0.2", "typescript": "^5.3.3" }, "dependencies": { "@meshsdk/common": "1.7.10", - "@meshsdk/core-cst": "1.7.10", "@utxorpc/sdk": "0.6.2", "@utxorpc/spec": "0.10.1", "axios": "^1.7.2" From 9168fcd44c6fe4c5f3e2c2cb52de6c0685102f4e Mon Sep 17 00:00:00 2001 From: lisicky Date: Wed, 30 Oct 2024 03:08:21 +0800 Subject: [PATCH 08/16] merge fix --- package-lock.json | 3 ++- packages/mesh-core-csl/package.json | 1 + packages/mesh-core-cst/package.json | 1 - packages/mesh-provider/package.json | 1 + 4 files changed, 4 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index 1ec19710e..4af7fef05 100644 --- a/package-lock.json +++ b/package-lock.json @@ -29440,6 +29440,7 @@ }, "devDependencies": { "@meshsdk/configs": "*", + "@meshsdk/provider": "*", "@types/json-bigint": "^1.0.4", "eslint": "^8.57.0", "ts-jest": "^29.1.4", @@ -29465,7 +29466,6 @@ }, "devDependencies": { "@meshsdk/configs": "*", - "@meshsdk/provider": "*", "@types/pbkdf2": "^3.1.2", "eslint": "^8.57.0", "ts-jest": "^29.1.4", @@ -29480,6 +29480,7 @@ "license": "Apache-2.0", "dependencies": { "@meshsdk/common": "1.7.10", + "@meshsdk/core-cst": "1.7.10", "@utxorpc/sdk": "0.6.2", "@utxorpc/spec": "0.10.1", "axios": "^1.7.2" diff --git a/packages/mesh-core-csl/package.json b/packages/mesh-core-csl/package.json index ecebbee08..a2fad0948 100644 --- a/packages/mesh-core-csl/package.json +++ b/packages/mesh-core-csl/package.json @@ -31,6 +31,7 @@ }, "devDependencies": { "@meshsdk/configs": "*", + "@meshsdk/provider": "*", "@types/json-bigint": "^1.0.4", "eslint": "^8.57.0", "ts-jest": "^29.1.4", diff --git a/packages/mesh-core-cst/package.json b/packages/mesh-core-cst/package.json index dfdf81c29..1f0f7aca5 100644 --- a/packages/mesh-core-cst/package.json +++ b/packages/mesh-core-cst/package.json @@ -28,7 +28,6 @@ }, "devDependencies": { "@meshsdk/configs": "*", - "@meshsdk/provider": "*", "@types/pbkdf2": "^3.1.2", "eslint": "^8.57.0", "ts-jest": "^29.1.4", diff --git a/packages/mesh-provider/package.json b/packages/mesh-provider/package.json index 209760d79..70dd68bf4 100644 --- a/packages/mesh-provider/package.json +++ b/packages/mesh-provider/package.json @@ -35,6 +35,7 @@ }, "dependencies": { "@meshsdk/common": "1.7.10", + "@meshsdk/core-cst": "1.7.10", "@utxorpc/sdk": "0.6.2", "@utxorpc/spec": "0.10.1", "axios": "^1.7.2" From f1b102e926ad1ce2a2c29d5078ef9620c51aa707 Mon Sep 17 00:00:00 2001 From: lisicky Date: Thu, 14 Nov 2024 15:20:20 +0800 Subject: [PATCH 09/16] add doc --- .../offline-providers/offline-evaluator.ts | 54 +++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/packages/mesh-core-csl/src/offline-providers/offline-evaluator.ts b/packages/mesh-core-csl/src/offline-providers/offline-evaluator.ts index 9623d0a22..0146b38b1 100644 --- a/packages/mesh-core-csl/src/offline-providers/offline-evaluator.ts +++ b/packages/mesh-core-csl/src/offline-providers/offline-evaluator.ts @@ -7,16 +7,70 @@ import { } from "@meshsdk/common"; import { evaluateTransaction, getTransactionInputs } from "../utils"; + +/** + * OfflineEvaluator implements the IEvaluator interface to provide offline evaluation of Plutus scripts. + * This class evaluates Plutus scripts contained in Cardano transactions without requiring network connectivity. + * It works in conjunction with an IFetcher implementation to resolve transaction UTXOs needed for script validation. + * + * The evaluator returns Action objects that contain: + * - tag: The type of script being executed (CERT, MINT, REWARD, SPEND, VOTE, PROPOSE) + * - index: Execution index of the script + * - budget: Memory and CPU step costs for script execution + * - data: The script's redeemer data (excluded from return type) + * + * Example usage: + * ```typescript + * import { OfflineEvaluator, OfflineFetcher } from '@meshsdk/core'; + * + * // Create fetcher and evaluator instances + * const fetcher = new OfflineFetcher(); + * const evaluator = new OfflineEvaluator(fetcher, 'mainnet'); + * + * // Evaluate Plutus scripts in a transaction + * try { + * const actions = await evaluator.evaluateTx(transactionCborHex); + * actions.forEach(action => { + * console.log(`Script type: ${action.tag}`); + * console.log(`Memory units: ${action.budget.mem}`); + * console.log(`CPU steps: ${action.budget.steps}`); + * }); + * } catch (error) { + * console.error('Plutus script evaluation failed:', error); + * } + * ``` + */ export class OfflineEvaluator implements IEvaluator { private readonly fetcher: IFetcher; private readonly network: Network; + /** + * Creates a new instance of OfflineEvaluator. + * @param fetcher - An implementation of IFetcher to resolve transaction UTXOs + * @param network - The network to evaluate scripts for + */ constructor(fetcher: IFetcher, network: Network) { this.fetcher = fetcher; this.network = network; } + /** + * Evaluates Plutus scripts in a transaction by resolving its input UTXOs and calculating execution costs. + * + * The method performs these steps: + * 1. Extracts input references from the transaction + * 2. Resolves the corresponding UTXOs using the fetcher + * 3. Verifies all required UTXOs are available + * 4. Evaluates each Plutus script to determine its memory and CPU costs + * + * @param tx - Transaction in CBOR hex format + * @returns Promise resolving to array of script evaluation results, each containing: + * - tag: Type of script (CERT | MINT | REWARD | SPEND | VOTE | PROPOSE) + * - index: Script execution index + * - budget: Memory units and CPU steps required + * @throws Error if any required UTXOs cannot be resolved or if script evaluation fails + */ async evaluateTx(tx: string): Promise[]> { const inputsToResolve = getTransactionInputs(tx); const txHashesSet = new Set(inputsToResolve.map(input => input.txHash)); From 426d4454cec57d3dc4a2f8c8c18b2a34650c7191 Mon Sep 17 00:00:00 2001 From: lisicky Date: Thu, 14 Nov 2024 15:37:56 +0800 Subject: [PATCH 10/16] update the doc --- .../offline-providers/offline-evaluator.ts | 48 +++++++++++++------ 1 file changed, 34 insertions(+), 14 deletions(-) diff --git a/packages/mesh-core-csl/src/offline-providers/offline-evaluator.ts b/packages/mesh-core-csl/src/offline-providers/offline-evaluator.ts index 0146b38b1..a27501091 100644 --- a/packages/mesh-core-csl/src/offline-providers/offline-evaluator.ts +++ b/packages/mesh-core-csl/src/offline-providers/offline-evaluator.ts @@ -10,14 +10,15 @@ import { evaluateTransaction, getTransactionInputs } from "../utils"; /** * OfflineEvaluator implements the IEvaluator interface to provide offline evaluation of Plutus scripts. - * This class evaluates Plutus scripts contained in Cardano transactions without requiring network connectivity. - * It works in conjunction with an IFetcher implementation to resolve transaction UTXOs needed for script validation. + * This class evaluates Plutus scripts contained in Cardano transactions without requiring network connectivity, + * determining their execution costs in terms of memory and CPU steps. * - * The evaluator returns Action objects that contain: - * - tag: The type of script being executed (CERT, MINT, REWARD, SPEND, VOTE, PROPOSE) - * - index: Execution index of the script - * - budget: Memory and CPU step costs for script execution - * - data: The script's redeemer data (excluded from return type) + * Each script evaluation returns an Action object (excluding the redeemer data) that contains: + * - tag: The type of script being executed (CERT | MINT | REWARD | SPEND | VOTE | PROPOSE) + * - index: Execution index of the script within the transaction + * - budget: Execution costs including: + * - mem: Memory units required + * - steps: CPU steps required * * Example usage: * ```typescript @@ -25,16 +26,35 @@ import { evaluateTransaction, getTransactionInputs } from "../utils"; * * // Create fetcher and evaluator instances * const fetcher = new OfflineFetcher(); - * const evaluator = new OfflineEvaluator(fetcher, 'mainnet'); + * const evaluator = new OfflineEvaluator(fetcher, 'preprod'); + * + * // Add required UTXOs that the transaction references + * fetcher.addUTxOs([ + * { + * input: { + * txHash: "1234...", + * outputIndex: 0 + * }, + * output: { + * address: "addr1...", + * amount: [{ unit: "lovelace", quantity: "1000000" }], + * scriptHash: "abcd..." // If this is a script UTXO + * } + * } + * ]); * * // Evaluate Plutus scripts in a transaction * try { - * const actions = await evaluator.evaluateTx(transactionCborHex); - * actions.forEach(action => { - * console.log(`Script type: ${action.tag}`); - * console.log(`Memory units: ${action.budget.mem}`); - * console.log(`CPU steps: ${action.budget.steps}`); - * }); + * const actions = await evaluator.evaluateTx(transactionCbor); + * // Example result for a minting script: + * // [{ + * // index: 0, + * // tag: "MINT", + * // budget: { + * // mem: 508703, // Memory units used + * // steps: 164980381 // CPU steps used + * // } + * // }] * } catch (error) { * console.error('Plutus script evaluation failed:', error); * } From 25aaeef1dd1e8909cdacba65e09a8332d2b9bfca Mon Sep 17 00:00:00 2001 From: lisicky Date: Thu, 14 Nov 2024 16:36:07 +0800 Subject: [PATCH 11/16] add playground doc --- apps/playground/src/data/links-providers.ts | 8 ++ .../src/pages/providers/evaluators/index.tsx | 4 +- .../src/pages/providers/offline-evaluator.tsx | 128 ++++++++++++++++++ 3 files changed, 139 insertions(+), 1 deletion(-) create mode 100644 apps/playground/src/pages/providers/offline-evaluator.tsx diff --git a/apps/playground/src/data/links-providers.ts b/apps/playground/src/data/links-providers.ts index 2609a2345..1888bfa89 100644 --- a/apps/playground/src/data/links-providers.ts +++ b/apps/playground/src/data/links-providers.ts @@ -51,6 +51,13 @@ export const metaHydra = { thumbnail: "/providers/hydra.svg", }; +export const metaOfflineEvaluator = { + title: "Offline Evaluator", + link: "/providers/offline-evaluator", + desc: "An offline Plutus script evaluator for testing and validation.", + thumbnail: "/providers/hydra.png", +}; + export const linksProviders: MenuItem[] = [ metaBlockfrost, metaKoios, @@ -59,6 +66,7 @@ export const linksProviders: MenuItem[] = [ metaOgmios, metaU5c, metaYaci, + metaOfflineEvaluator, ]; export const metaProviders = { diff --git a/apps/playground/src/pages/providers/evaluators/index.tsx b/apps/playground/src/pages/providers/evaluators/index.tsx index 101a4c9ea..1d7a3f865 100644 --- a/apps/playground/src/pages/providers/evaluators/index.tsx +++ b/apps/playground/src/pages/providers/evaluators/index.tsx @@ -7,6 +7,7 @@ import { } from "@meshsdk/core"; import EvaluatorEvaluateTransaction from "./evaluate-tx"; +import {OfflineEvaluator} from "@meshsdk/core-csl"; export default function ProviderEvaluators({ blockchainProvider, @@ -30,4 +31,5 @@ export type SupportedEvaluators = | YaciProvider | MaestroProvider | OgmiosProvider - | U5CProvider; + | U5CProvider + | OfflineEvaluator; diff --git a/apps/playground/src/pages/providers/offline-evaluator.tsx b/apps/playground/src/pages/providers/offline-evaluator.tsx new file mode 100644 index 000000000..d52094459 --- /dev/null +++ b/apps/playground/src/pages/providers/offline-evaluator.tsx @@ -0,0 +1,128 @@ +import type { NextPage } from "next"; +import { OfflineFetcher } from "@meshsdk/core"; +import { OfflineEvaluator } from "@meshsdk/core-csl"; +import ButtonFloatDocumentation from "~/components/button/button-float-documentation"; +import SidebarFullwidth from "~/components/layouts/sidebar-fullwidth"; +import Link from "~/components/link"; +import TitleIconDescriptionBody from "~/components/sections/title-icon-description-body"; +import Metatags from "~/components/site/metatags"; +import Codeblock from "~/components/text/codeblock"; +import { metaOfflineEvaluator } from "~/data/links-providers"; +import ProviderEvaluators from "./evaluators"; + +const ReactPage: NextPage = () => { + const sidebarItems = [ + { label: "Evaluate Transaction", to: "evaluateTx" }, + ]; + +let code1 = `import { OfflineEvaluator, OfflineFetcher } from "@meshsdk/core";\n\n`; +code1 += `// Create fetcher for resolving UTXOs\n`; +code1 += `const fetcher = new OfflineFetcher();\n\n`; +code1 += `// Add UTXOs required for script evaluation\n`; +code1 += `fetcher.addUTxOs([\n`; +code1 += ` {\n`; +code1 += ` input: { \n`; +code1 += ` txHash: "5de23a2...", \n`; +code1 += ` outputIndex: 0 \n`; +code1 += ` },\n`; +code1 += ` output: {\n`; +code1 += ` address: "addr1...",\n`; +code1 += ` amount: [{ unit: "lovelace", quantity: "1000000" }],\n`; +code1 += ` scriptHash: "32b7e3d..." // For script UTXOs\n`; +code1 += ` }\n`; +code1 += ` }\n`; +code1 += `]);\n\n`; +code1 += `// Create evaluator for the desired network\n`; +code1 += `const evaluator = new OfflineEvaluator(fetcher, "preprod");\n`; + +let code2 = `// Evaluate Plutus scripts in a transaction\n`; +code2 += `try {\n`; +code2 += ` const actions = await evaluator.evaluateTx(transactionCbor);\n`; +code2 += ` // Example result:\n`; +code2 += ` // [{\n`; +code2 += ` // index: 0,\n`; +code2 += ` // tag: "MINT",\n`; +code2 += ` // budget: {\n`; +code2 += ` // mem: 508703, // Memory units used\n`; +code2 += ` // steps: 164980381 // CPU steps used\n`; +code2 += ` // }\n`; +code2 += ` // }]\n`; +code2 += `} catch (error) {\n`; +code2 += ` console.error('Script evaluation failed:', error);\n`; +code2 += `}\n`; + +let code3 = `// In your test file\n`; +code3 += `describe("Plutus Script Tests", () => {\n`; +code3 += ` let evaluator: OfflineEvaluator;\n`; +code3 += ` let fetcher: OfflineFetcher;\n\n`; +code3 += ` beforeEach(() => {\n`; +code3 += ` fetcher = new OfflineFetcher();\n`; +code3 += ` evaluator = new OfflineEvaluator(fetcher, "preprod");\n\n`; +code3 += ` // Add test UTXOs\n`; +code3 += ` fetcher.addUTxOs([...]);\n`; +code3 += ` });\n\n`; +code3 += ` it("should evaluate minting policy", async () => {\n`; +code3 += ` const result = await evaluator.evaluateTx(txCbor);\n`; +code3 += ` expect(result[0].tag).toBe("MINT");\n`; +code3 += ` expect(result[0].budget.mem).toBeLessThan(600000);\n`; +code3 += ` });\n`; +code3 += `});\n`; + +const fetcher = new OfflineFetcher(); +const evaluator = new OfflineEvaluator(fetcher, "preprod"); + +return ( + <> + + + +

+ The OfflineEvaluator calculates execution costs (memory and CPU steps) for + Plutus scripts in transactions without requiring network connectivity. It works + with an {" "} + + OfflineFetcher + + {" "} to resolve the UTXOs needed for script validation. +

+ +

Get started:

+ + + +

+ Once initialized, you can evaluate Plutus scripts in transactions: +

+ + +

+ The evaluator is particularly useful for testing Plutus scripts, ensuring + they execute within memory and CPU limits: +

+ + +

+ The evaluation results include memory units and CPU steps required for each + script execution, helping you optimize your scripts and ensure they meet + protocol constraints. +

+
+ + + + +
+ +); +}; + +export default ReactPage; From 9dab2e83102bf64d789dafcc47cf27d7eb31fc6d Mon Sep 17 00:00:00 2001 From: lisicky Date: Thu, 14 Nov 2024 16:38:00 +0800 Subject: [PATCH 12/16] fix the doc --- apps/playground/src/pages/providers/offline-evaluator.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/apps/playground/src/pages/providers/offline-evaluator.tsx b/apps/playground/src/pages/providers/offline-evaluator.tsx index d52094459..c6358bc9f 100644 --- a/apps/playground/src/pages/providers/offline-evaluator.tsx +++ b/apps/playground/src/pages/providers/offline-evaluator.tsx @@ -15,7 +15,8 @@ const ReactPage: NextPage = () => { { label: "Evaluate Transaction", to: "evaluateTx" }, ]; -let code1 = `import { OfflineEvaluator, OfflineFetcher } from "@meshsdk/core";\n\n`; +let code1 = `import { OfflineEvaluator } from "@meshsdk/core-csl";\n\n`; +code1 += `import { OfflineFetcher } from "@meshsdk/core";\n\n`; code1 += `// Create fetcher for resolving UTXOs\n`; code1 += `const fetcher = new OfflineFetcher();\n\n`; code1 += `// Add UTXOs required for script evaluation\n`; From d3625c3cdec9c0703dcb470039a4ebd4cae2f938 Mon Sep 17 00:00:00 2001 From: "Hong Jing (Jingles)" Date: Thu, 14 Nov 2024 22:36:15 +0800 Subject: [PATCH 13/16] update docs --- .../src/components/site/metatags.tsx | 6 +- apps/playground/src/data/cardano.ts | 4 ++ .../providers/evaluators/evaluate-tx.tsx | 20 +++++- .../content-ownership/index.tsx | 1 - package-lock.json | 70 +++++++++---------- 5 files changed, 58 insertions(+), 43 deletions(-) diff --git a/apps/playground/src/components/site/metatags.tsx b/apps/playground/src/components/site/metatags.tsx index c5270fe8d..8e8bb2eb8 100644 --- a/apps/playground/src/components/site/metatags.tsx +++ b/apps/playground/src/components/site/metatags.tsx @@ -22,9 +22,7 @@ export default function Metatags({ } if (title === undefined) { - title = "Mesh JS - Cardano Web3 TypeScript SDK & Off-Chain Framework"; - } else { - title = title + " - Mesh JS"; + title = "Cardano Web3 TypeScript SDK & Off-Chain Framework"; } return ( @@ -32,7 +30,7 @@ export default function Metatags({ - {title && {title}} + {title && {`${title} - Mesh JS`}} diff --git a/apps/playground/src/data/cardano.ts b/apps/playground/src/data/cardano.ts index 50cfec1fc..e66103b87 100644 --- a/apps/playground/src/data/cardano.ts +++ b/apps/playground/src/data/cardano.ts @@ -53,6 +53,10 @@ export const oneTimeMintingPolicy = export const demoTransactionCbor = "84a70081825820859d3b4fd3a4c012b43ee1bbbc99240aec1827c3b8a74b867d10a7f4759149bc00018382583900e4cfbbc317c718f78d137b6535d8940618cc3d2ac04f1f35acf78e53a1521c2cea3cc79762d575581e47ea60b8eaa03430716cfd6140c796821a0011b0dea1581c67dd133868f14107b25772f3c5abaa1e0549f4b400b5e0e3a1136152a149000643b0546573743101a300581d7067dd133868f14107b25772f3c5abaa1e0549f4b400b5e0e3a113615201821a001ad510a1581c67dd133868f14107b25772f3c5abaa1e0549f4b400b5e0e3a1136152a149000de140546573743101028201d8185882d8799fa4446e616d6545546573743145696d6167655835697066733a2f2f516d527a6963705265757477436b4d36616f74754b6a4572464355443231334470775071364279757a4d4a617561496d656469615479706549696d6167652f6a70674b6465736372697074696f6e5348656c6c6f20776f726c64202d20434950363802ff825839003659ed2a30abb32e97589f2a01c8500ce8fc4897b868ebe42fbf4a8aa1521c2cea3cc79762d575581e47ea60b8eaa03430716cfd6140c7961a00134249021a000c830909a1581c67dd133868f14107b25772f3c5abaa1e0549f4b400b5e0e3a1136152a249000643b054657374310149000de1405465737431010b58207ae25a8a9286347cc1e0444a0de75e07432a6ed243591ef673fd837bb5235a670d82825820859d3b4fd3a4c012b43ee1bbbc99240aec1827c3b8a74b867d10a7f4759149bc00825820859d3b4fd3a4c012b43ee1bbbc99240aec1827c3b8a74b867d10a7f4759149bc050e81581ce4cfbbc317c718f78d137b6535d8940618cc3d2ac04f1f35acf78e53a206815883588101000032323232323232322232533300632323232533300a3370e9000000899b8f375c601c601000e911046d6573680014a0601000260180026018002600800429309b2b19299980319b87480000044c8c94ccc02cc03400852616375c601600260080062c60080044600a6ea80048c00cdd5000ab9a5573aaae7955cfaba157450581840100d8799f446d657368ff821a006acfc01ab2d05e00f5f6"; +// from content ownership mint policy +export const demoTransactionCborScript = + "84a600d901028182582056ae6e2d8c419ab279ecd308040b8f56025cd4a287c75c182f8ccc0fd4115b0700018182583900556f3a70b8a68081cf36c918dd9933abdca34f20fc534499c817182b8cfb40854d41392b624b678012443d61015f5575627a467c450396c9821a008c2c8fa1581c8251cfa433b84ed4357143657f1c33740caa9e953c5f266c86ecfaf5a14001021a000c69f109a1581c8251cfa433b84ed4357143657f1c33740caa9e953c5f266c86ecfaf5a140010b58204fb018afc3952620696789649a8447595f9895ec48bda9c2596f0507e9b43f360dd9010281825820e8b1c89936d747185cf77c3eb42a37749cb4bdfee36d8763cfffad264ecbe0b900a207d90102815901cc5901c901010033232323232323222533300332323232325332330093001300a37540042646464a66601860080022a66601e601c6ea8018540085854ccc030cdc3a40040022a66601e601c6ea8018540085858c030dd50028992999805980198061baa0051533300b3003300c375464660020026eb0c044c038dd50041129998080008a6103d87a800013232533300f3375e01c600a60226ea80084cdd2a40006602600497ae01330040040013014002301200114a229404c8cc004004c8cc004004dd59809180998099809980998079baa00922533301100114bd70099199911191980080080191299980b80088018991980c9ba733019375200c66032602c00266032602e00297ae033003003301b0023019001375c60200026eacc044004cc00c00cc054008c04c004894ccc040004528899299980719299980799b8f375c600a00200c266e20dd6980a180a980a800a40002944dd618098010998018018008a50301300123010001375c601c60166ea8008dc3a40002c6018601a004601600260160046012002600a6ea8004526136565734aae7555cf2ab9f5740ae855d1260127d8799f582056ae6e2d8c419ab279ecd308040b8f56025cd4a287c75c182f8ccc0fd4115b0700ff000105a182010082d87980821a006acfc01ab2d05e00f5f6"; + export const yaci = { mnemonic: [ "test", diff --git a/apps/playground/src/pages/providers/evaluators/evaluate-tx.tsx b/apps/playground/src/pages/providers/evaluators/evaluate-tx.tsx index bf2d8706a..48662f810 100644 --- a/apps/playground/src/pages/providers/evaluators/evaluate-tx.tsx +++ b/apps/playground/src/pages/providers/evaluators/evaluate-tx.tsx @@ -1,11 +1,14 @@ import { useState } from "react"; +import { OfflineEvaluator } from "@meshsdk/core-csl"; + +import { getProvider } from "~/components/cardano/mesh-wallet"; import Input from "~/components/form/input"; import InputTable from "~/components/sections/input-table"; import LiveCodeDemo from "~/components/sections/live-code-demo"; import TwoColumnsScroll from "~/components/sections/two-columns-scroll"; import Codeblock from "~/components/text/codeblock"; -import { demoTransactionCbor } from "~/data/cardano"; +import { demoTransactionCborScript } from "~/data/cardano"; import { SupportedEvaluators } from "."; export default function EvaluatorEvaluateTransaction({ @@ -15,7 +18,7 @@ export default function EvaluatorEvaluateTransaction({ blockchainProvider: SupportedEvaluators; provider: string; }) { - const [userInput, setUserInput] = useState(demoTransactionCbor); + const [userInput, setUserInput] = useState(demoTransactionCborScript); return ( ');\n`; + code += `const offlineeval = new OfflineEvaluator(blockchainProvider, "preprod");\n\n`; + code += `const evaluateTx = await offlineeval.evaluateTx('');\n`; + return ( { ]; let example = ``; - example += `import { MeshContentOwnershipContract } from "@meshsdk/contract";\n`; example += `import { MeshTxBuilder, BlockfrostProvider } from "@meshsdk/core";\n`; example += `\n`; diff --git a/package-lock.json b/package-lock.json index e073c8085..9b9db1e0a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -30873,7 +30873,7 @@ }, "packages/mesh-common": { "name": "@meshsdk/common", - "version": "1.7.13", + "version": "1.7.14", "license": "Apache-2.0", "dependencies": { "bech32": "^2.0.0", @@ -30890,12 +30890,12 @@ }, "packages/mesh-contract": { "name": "@meshsdk/contract", - "version": "1.7.13", + "version": "1.7.14", "license": "Apache-2.0", "dependencies": { - "@meshsdk/common": "1.7.13", - "@meshsdk/core": "1.7.13", - "@meshsdk/core-csl": "1.7.13" + "@meshsdk/common": "1.7.14", + "@meshsdk/core": "1.7.14", + "@meshsdk/core-csl": "1.7.14" }, "devDependencies": { "@meshsdk/configs": "*", @@ -30906,16 +30906,16 @@ }, "packages/mesh-core": { "name": "@meshsdk/core", - "version": "1.7.13", + "version": "1.7.14", "license": "Apache-2.0", "dependencies": { - "@meshsdk/common": "1.7.13", - "@meshsdk/core-csl": "1.7.13", - "@meshsdk/core-cst": "1.7.13", - "@meshsdk/provider": "1.7.13", - "@meshsdk/react": "1.7.13", - "@meshsdk/transaction": "1.7.13", - "@meshsdk/wallet": "1.7.13" + "@meshsdk/common": "1.7.14", + "@meshsdk/core-csl": "1.7.14", + "@meshsdk/core-cst": "1.7.14", + "@meshsdk/provider": "1.7.14", + "@meshsdk/react": "1.7.14", + "@meshsdk/transaction": "1.7.14", + "@meshsdk/wallet": "1.7.14" }, "devDependencies": { "@meshsdk/configs": "*", @@ -30926,10 +30926,10 @@ }, "packages/mesh-core-csl": { "name": "@meshsdk/core-csl", - "version": "1.7.13", + "version": "1.7.14", "license": "Apache-2.0", "dependencies": { - "@meshsdk/common": "1.7.13", + "@meshsdk/common": "1.7.14", "@sidan-lab/sidan-csl-rs-browser": "0.9.5", "@sidan-lab/sidan-csl-rs-nodejs": "0.9.5", "json-bigint": "^1.0.0" @@ -30946,7 +30946,7 @@ }, "packages/mesh-core-cst": { "name": "@meshsdk/core-cst", - "version": "1.7.13", + "version": "1.7.14", "license": "Apache-2.0", "dependencies": { "@cardano-sdk/core": "0.35.4", @@ -30955,9 +30955,9 @@ "@harmoniclabs/cbor": "1.3.0", "@harmoniclabs/plutus-data": "1.2.4", "@harmoniclabs/uplc": "1.2.4", - "@meshsdk/common": "1.7.13", + "@meshsdk/common": "1.7.14", "@stricahq/bip32ed25519": "^1.1.0", - "@stricahq/cbors": "^1.0.0", + "@stricahq/cbors": "^1.0.3", "pbkdf2": "^3.1.2" }, "devDependencies": { @@ -30972,11 +30972,11 @@ }, "packages/mesh-provider": { "name": "@meshsdk/provider", - "version": "1.7.13", + "version": "1.7.14", "license": "Apache-2.0", "dependencies": { - "@meshsdk/common": "1.7.13", - "@meshsdk/core-cst": "1.7.13", + "@meshsdk/common": "1.7.14", + "@meshsdk/core-cst": "1.7.14", "@utxorpc/sdk": "0.6.2", "@utxorpc/spec": "0.10.1", "axios": "^1.7.2" @@ -30990,12 +30990,12 @@ }, "packages/mesh-react": { "name": "@meshsdk/react", - "version": "1.7.13", + "version": "1.7.14", "license": "Apache-2.0", "dependencies": { - "@meshsdk/common": "1.7.13", - "@meshsdk/transaction": "1.7.13", - "@meshsdk/wallet": "1.7.13", + "@meshsdk/common": "1.7.14", + "@meshsdk/transaction": "1.7.14", + "@meshsdk/wallet": "1.7.14", "react": "^18.2.0" }, "devDependencies": { @@ -31010,12 +31010,12 @@ }, "packages/mesh-transaction": { "name": "@meshsdk/transaction", - "version": "1.7.13", + "version": "1.7.14", "license": "Apache-2.0", "dependencies": { - "@meshsdk/common": "1.7.13", - "@meshsdk/core-csl": "1.7.13", - "@meshsdk/core-cst": "1.7.13", + "@meshsdk/common": "1.7.14", + "@meshsdk/core-csl": "1.7.14", + "@meshsdk/core-cst": "1.7.14", "json-bigint": "^1.0.0" }, "devDependencies": { @@ -31028,13 +31028,13 @@ }, "packages/mesh-wallet": { "name": "@meshsdk/wallet", - "version": "1.7.13", + "version": "1.7.14", "license": "Apache-2.0", "dependencies": { - "@meshsdk/common": "1.7.13", - "@meshsdk/core-csl": "1.7.13", - "@meshsdk/core-cst": "1.7.13", - "@meshsdk/transaction": "1.7.13", + "@meshsdk/common": "1.7.14", + "@meshsdk/core-csl": "1.7.14", + "@meshsdk/core-cst": "1.7.14", + "@meshsdk/transaction": "1.7.14", "@nufi/dapp-client-cardano": "0.3.5", "@nufi/dapp-client-core": "0.3.5" }, @@ -31048,7 +31048,7 @@ }, "scripts/mesh-cli": { "name": "meshjs", - "version": "1.7.13", + "version": "1.7.14", "license": "Apache-2.0", "dependencies": { "chalk": "5.3.0", From 8c1af2019a7128296f23e88f9b85f19c6c185389 Mon Sep 17 00:00:00 2001 From: "Hong Jing (Jingles)" Date: Fri, 15 Nov 2024 17:31:21 +0800 Subject: [PATCH 14/16] bump version --- packages/mesh-common/package.json | 2 +- packages/mesh-contract/package.json | 8 ++++---- packages/mesh-core-csl/package.json | 6 +++--- packages/mesh-core-cst/package.json | 4 ++-- packages/mesh-core/package.json | 16 ++++++++-------- packages/mesh-provider/package.json | 6 +++--- packages/mesh-react/package.json | 8 ++++---- packages/mesh-transaction/package.json | 8 ++++---- packages/mesh-wallet/package.json | 10 +++++----- scripts/mesh-cli/package.json | 2 +- 10 files changed, 35 insertions(+), 35 deletions(-) diff --git a/packages/mesh-common/package.json b/packages/mesh-common/package.json index b7e93b6ca..73ab06409 100644 --- a/packages/mesh-common/package.json +++ b/packages/mesh-common/package.json @@ -1,6 +1,6 @@ { "name": "@meshsdk/common", - "version": "1.7.14", + "version": "1.7.15", "description": "", "main": "./dist/index.cjs", "browser": "./dist/index.js", diff --git a/packages/mesh-contract/package.json b/packages/mesh-contract/package.json index 096197fc0..3179c467f 100644 --- a/packages/mesh-contract/package.json +++ b/packages/mesh-contract/package.json @@ -1,6 +1,6 @@ { "name": "@meshsdk/contract", - "version": "1.7.14", + "version": "1.7.15", "description": "", "main": "./dist/index.cjs", "browser": "./dist/index.js", @@ -34,9 +34,9 @@ "typescript": "^5.3.3" }, "dependencies": { - "@meshsdk/common": "1.7.14", - "@meshsdk/core": "1.7.14", - "@meshsdk/core-csl": "1.7.14" + "@meshsdk/common": "1.7.15", + "@meshsdk/core": "1.7.15", + "@meshsdk/core-csl": "1.7.15" }, "prettier": "@meshsdk/configs/prettier", "publishConfig": { diff --git a/packages/mesh-core-csl/package.json b/packages/mesh-core-csl/package.json index 60ff828a4..03f50ba24 100644 --- a/packages/mesh-core-csl/package.json +++ b/packages/mesh-core-csl/package.json @@ -1,6 +1,6 @@ { "name": "@meshsdk/core-csl", - "version": "1.7.14", + "version": "1.7.15", "description": "", "main": "./dist/index.cjs", "module": "./dist/index.js", @@ -31,7 +31,7 @@ }, "devDependencies": { "@meshsdk/configs": "*", - "@meshsdk/provider": "*", + "@meshsdk/provider": "1.7.15", "@types/json-bigint": "^1.0.4", "eslint": "^8.57.0", "ts-jest": "^29.1.4", @@ -39,7 +39,7 @@ "typescript": "^5.3.3" }, "dependencies": { - "@meshsdk/common": "1.7.14", + "@meshsdk/common": "1.7.15", "@sidan-lab/sidan-csl-rs-browser": "0.9.5", "@sidan-lab/sidan-csl-rs-nodejs": "0.9.5", "json-bigint": "^1.0.0" diff --git a/packages/mesh-core-cst/package.json b/packages/mesh-core-cst/package.json index 99a0d0e1d..3c8c4f8b6 100644 --- a/packages/mesh-core-cst/package.json +++ b/packages/mesh-core-cst/package.json @@ -1,6 +1,6 @@ { "name": "@meshsdk/core-cst", - "version": "1.7.14", + "version": "1.7.15", "description": "", "main": "./dist/index.cjs", "browser": "./dist/index.js", @@ -42,7 +42,7 @@ "@harmoniclabs/cbor": "1.3.0", "@harmoniclabs/plutus-data": "1.2.4", "@harmoniclabs/uplc": "1.2.4", - "@meshsdk/common": "1.7.14", + "@meshsdk/common": "1.7.15", "@stricahq/bip32ed25519": "^1.1.0", "@stricahq/cbors": "^1.0.3", "pbkdf2": "^3.1.2" diff --git a/packages/mesh-core/package.json b/packages/mesh-core/package.json index ab423ee68..641c7d77e 100644 --- a/packages/mesh-core/package.json +++ b/packages/mesh-core/package.json @@ -1,6 +1,6 @@ { "name": "@meshsdk/core", - "version": "1.7.14", + "version": "1.7.15", "description": "", "main": "./dist/index.cjs", "browser": "./dist/index.js", @@ -33,13 +33,13 @@ "typescript": "^5.3.3" }, "dependencies": { - "@meshsdk/common": "1.7.14", - "@meshsdk/core-csl": "1.7.14", - "@meshsdk/core-cst": "1.7.14", - "@meshsdk/provider": "1.7.14", - "@meshsdk/react": "1.7.14", - "@meshsdk/transaction": "1.7.14", - "@meshsdk/wallet": "1.7.14" + "@meshsdk/common": "1.7.15", + "@meshsdk/core-csl": "1.7.15", + "@meshsdk/core-cst": "1.7.15", + "@meshsdk/provider": "1.7.15", + "@meshsdk/react": "1.7.15", + "@meshsdk/transaction": "1.7.15", + "@meshsdk/wallet": "1.7.15" }, "prettier": "@meshsdk/configs/prettier", "publishConfig": { diff --git a/packages/mesh-provider/package.json b/packages/mesh-provider/package.json index df5f59459..f2569b3d8 100644 --- a/packages/mesh-provider/package.json +++ b/packages/mesh-provider/package.json @@ -1,6 +1,6 @@ { "name": "@meshsdk/provider", - "version": "1.7.14", + "version": "1.7.15", "description": "", "main": "./dist/index.cjs", "browser": "./dist/index.js", @@ -34,8 +34,8 @@ "typescript": "^5.3.3" }, "dependencies": { - "@meshsdk/common": "1.7.14", - "@meshsdk/core-cst": "1.7.14", + "@meshsdk/common": "1.7.15", + "@meshsdk/core-cst": "1.7.15", "@utxorpc/sdk": "0.6.2", "@utxorpc/spec": "0.10.1", "axios": "^1.7.2" diff --git a/packages/mesh-react/package.json b/packages/mesh-react/package.json index 1e8d5e5be..9a222b959 100644 --- a/packages/mesh-react/package.json +++ b/packages/mesh-react/package.json @@ -1,6 +1,6 @@ { "name": "@meshsdk/react", - "version": "1.7.14", + "version": "1.7.15", "description": "", "main": "./dist/index.cjs", "browser": "./dist/index.js", @@ -30,9 +30,9 @@ }, "dependencies": { "react": "^18.2.0", - "@meshsdk/common": "1.7.14", - "@meshsdk/transaction": "1.7.14", - "@meshsdk/wallet": "1.7.14" + "@meshsdk/common": "1.7.15", + "@meshsdk/transaction": "1.7.15", + "@meshsdk/wallet": "1.7.15" }, "devDependencies": { "@meshsdk/configs": "*", diff --git a/packages/mesh-transaction/package.json b/packages/mesh-transaction/package.json index 77dfc0383..dd0482688 100644 --- a/packages/mesh-transaction/package.json +++ b/packages/mesh-transaction/package.json @@ -1,6 +1,6 @@ { "name": "@meshsdk/transaction", - "version": "1.7.14", + "version": "1.7.15", "description": "", "main": "./dist/index.cjs", "browser": "./dist/index.js", @@ -35,9 +35,9 @@ "typescript": "^5.3.3" }, "dependencies": { - "@meshsdk/common": "1.7.14", - "@meshsdk/core-csl": "1.7.14", - "@meshsdk/core-cst": "1.7.14", + "@meshsdk/common": "1.7.15", + "@meshsdk/core-csl": "1.7.15", + "@meshsdk/core-cst": "1.7.15", "json-bigint": "^1.0.0" }, "prettier": "@meshsdk/configs/prettier", diff --git a/packages/mesh-wallet/package.json b/packages/mesh-wallet/package.json index a2cf32bed..90ccbc6eb 100644 --- a/packages/mesh-wallet/package.json +++ b/packages/mesh-wallet/package.json @@ -1,6 +1,6 @@ { "name": "@meshsdk/wallet", - "version": "1.7.14", + "version": "1.7.15", "description": "", "main": "./dist/index.cjs", "browser": "./dist/index.js", @@ -35,10 +35,10 @@ "typescript": "^5.3.3" }, "dependencies": { - "@meshsdk/common": "1.7.14", - "@meshsdk/core-csl": "1.7.14", - "@meshsdk/core-cst": "1.7.14", - "@meshsdk/transaction": "1.7.14", + "@meshsdk/common": "1.7.15", + "@meshsdk/core-csl": "1.7.15", + "@meshsdk/core-cst": "1.7.15", + "@meshsdk/transaction": "1.7.15", "@nufi/dapp-client-cardano": "0.3.5", "@nufi/dapp-client-core": "0.3.5" }, diff --git a/scripts/mesh-cli/package.json b/scripts/mesh-cli/package.json index c454d83b6..b3a656495 100644 --- a/scripts/mesh-cli/package.json +++ b/scripts/mesh-cli/package.json @@ -3,7 +3,7 @@ "description": "A quick and easy way to bootstrap your dApps on Cardano using Mesh.", "homepage": "https://meshjs.dev", "author": "MeshJS", - "version": "1.7.14", + "version": "1.7.15", "license": "Apache-2.0", "type": "module", "main": "./dist/index.cjs", From 1ce3fee12f3c25325f59321ea08c3ca9a2b13c7e Mon Sep 17 00:00:00 2001 From: "Hong Jing (Jingles)" Date: Fri, 15 Nov 2024 17:33:08 +0800 Subject: [PATCH 15/16] bump version 1.7.16 --- packages/mesh-common/package.json | 2 +- packages/mesh-contract/package.json | 8 ++++---- packages/mesh-core-csl/package.json | 6 +++--- packages/mesh-core-cst/package.json | 4 ++-- packages/mesh-core/package.json | 16 ++++++++-------- packages/mesh-provider/package.json | 6 +++--- packages/mesh-react/package.json | 8 ++++---- packages/mesh-transaction/package.json | 8 ++++---- packages/mesh-wallet/package.json | 10 +++++----- scripts/mesh-cli/package.json | 2 +- 10 files changed, 35 insertions(+), 35 deletions(-) diff --git a/packages/mesh-common/package.json b/packages/mesh-common/package.json index 73ab06409..d0b7bb431 100644 --- a/packages/mesh-common/package.json +++ b/packages/mesh-common/package.json @@ -1,6 +1,6 @@ { "name": "@meshsdk/common", - "version": "1.7.15", + "version": "1.7.16", "description": "", "main": "./dist/index.cjs", "browser": "./dist/index.js", diff --git a/packages/mesh-contract/package.json b/packages/mesh-contract/package.json index 3179c467f..056b2b974 100644 --- a/packages/mesh-contract/package.json +++ b/packages/mesh-contract/package.json @@ -1,6 +1,6 @@ { "name": "@meshsdk/contract", - "version": "1.7.15", + "version": "1.7.16", "description": "", "main": "./dist/index.cjs", "browser": "./dist/index.js", @@ -34,9 +34,9 @@ "typescript": "^5.3.3" }, "dependencies": { - "@meshsdk/common": "1.7.15", - "@meshsdk/core": "1.7.15", - "@meshsdk/core-csl": "1.7.15" + "@meshsdk/common": "1.7.16", + "@meshsdk/core": "1.7.16", + "@meshsdk/core-csl": "1.7.16" }, "prettier": "@meshsdk/configs/prettier", "publishConfig": { diff --git a/packages/mesh-core-csl/package.json b/packages/mesh-core-csl/package.json index 03f50ba24..1099d2547 100644 --- a/packages/mesh-core-csl/package.json +++ b/packages/mesh-core-csl/package.json @@ -1,6 +1,6 @@ { "name": "@meshsdk/core-csl", - "version": "1.7.15", + "version": "1.7.16", "description": "", "main": "./dist/index.cjs", "module": "./dist/index.js", @@ -31,7 +31,7 @@ }, "devDependencies": { "@meshsdk/configs": "*", - "@meshsdk/provider": "1.7.15", + "@meshsdk/provider": "1.7.16", "@types/json-bigint": "^1.0.4", "eslint": "^8.57.0", "ts-jest": "^29.1.4", @@ -39,7 +39,7 @@ "typescript": "^5.3.3" }, "dependencies": { - "@meshsdk/common": "1.7.15", + "@meshsdk/common": "1.7.16", "@sidan-lab/sidan-csl-rs-browser": "0.9.5", "@sidan-lab/sidan-csl-rs-nodejs": "0.9.5", "json-bigint": "^1.0.0" diff --git a/packages/mesh-core-cst/package.json b/packages/mesh-core-cst/package.json index 3c8c4f8b6..4b1c8307d 100644 --- a/packages/mesh-core-cst/package.json +++ b/packages/mesh-core-cst/package.json @@ -1,6 +1,6 @@ { "name": "@meshsdk/core-cst", - "version": "1.7.15", + "version": "1.7.16", "description": "", "main": "./dist/index.cjs", "browser": "./dist/index.js", @@ -42,7 +42,7 @@ "@harmoniclabs/cbor": "1.3.0", "@harmoniclabs/plutus-data": "1.2.4", "@harmoniclabs/uplc": "1.2.4", - "@meshsdk/common": "1.7.15", + "@meshsdk/common": "1.7.16", "@stricahq/bip32ed25519": "^1.1.0", "@stricahq/cbors": "^1.0.3", "pbkdf2": "^3.1.2" diff --git a/packages/mesh-core/package.json b/packages/mesh-core/package.json index 641c7d77e..29d90ff5c 100644 --- a/packages/mesh-core/package.json +++ b/packages/mesh-core/package.json @@ -1,6 +1,6 @@ { "name": "@meshsdk/core", - "version": "1.7.15", + "version": "1.7.16", "description": "", "main": "./dist/index.cjs", "browser": "./dist/index.js", @@ -33,13 +33,13 @@ "typescript": "^5.3.3" }, "dependencies": { - "@meshsdk/common": "1.7.15", - "@meshsdk/core-csl": "1.7.15", - "@meshsdk/core-cst": "1.7.15", - "@meshsdk/provider": "1.7.15", - "@meshsdk/react": "1.7.15", - "@meshsdk/transaction": "1.7.15", - "@meshsdk/wallet": "1.7.15" + "@meshsdk/common": "1.7.16", + "@meshsdk/core-csl": "1.7.16", + "@meshsdk/core-cst": "1.7.16", + "@meshsdk/provider": "1.7.16", + "@meshsdk/react": "1.7.16", + "@meshsdk/transaction": "1.7.16", + "@meshsdk/wallet": "1.7.16" }, "prettier": "@meshsdk/configs/prettier", "publishConfig": { diff --git a/packages/mesh-provider/package.json b/packages/mesh-provider/package.json index f2569b3d8..4a785cebb 100644 --- a/packages/mesh-provider/package.json +++ b/packages/mesh-provider/package.json @@ -1,6 +1,6 @@ { "name": "@meshsdk/provider", - "version": "1.7.15", + "version": "1.7.16", "description": "", "main": "./dist/index.cjs", "browser": "./dist/index.js", @@ -34,8 +34,8 @@ "typescript": "^5.3.3" }, "dependencies": { - "@meshsdk/common": "1.7.15", - "@meshsdk/core-cst": "1.7.15", + "@meshsdk/common": "1.7.16", + "@meshsdk/core-cst": "1.7.16", "@utxorpc/sdk": "0.6.2", "@utxorpc/spec": "0.10.1", "axios": "^1.7.2" diff --git a/packages/mesh-react/package.json b/packages/mesh-react/package.json index 9a222b959..8115d954e 100644 --- a/packages/mesh-react/package.json +++ b/packages/mesh-react/package.json @@ -1,6 +1,6 @@ { "name": "@meshsdk/react", - "version": "1.7.15", + "version": "1.7.16", "description": "", "main": "./dist/index.cjs", "browser": "./dist/index.js", @@ -30,9 +30,9 @@ }, "dependencies": { "react": "^18.2.0", - "@meshsdk/common": "1.7.15", - "@meshsdk/transaction": "1.7.15", - "@meshsdk/wallet": "1.7.15" + "@meshsdk/common": "1.7.16", + "@meshsdk/transaction": "1.7.16", + "@meshsdk/wallet": "1.7.16" }, "devDependencies": { "@meshsdk/configs": "*", diff --git a/packages/mesh-transaction/package.json b/packages/mesh-transaction/package.json index dd0482688..514dc5947 100644 --- a/packages/mesh-transaction/package.json +++ b/packages/mesh-transaction/package.json @@ -1,6 +1,6 @@ { "name": "@meshsdk/transaction", - "version": "1.7.15", + "version": "1.7.16", "description": "", "main": "./dist/index.cjs", "browser": "./dist/index.js", @@ -35,9 +35,9 @@ "typescript": "^5.3.3" }, "dependencies": { - "@meshsdk/common": "1.7.15", - "@meshsdk/core-csl": "1.7.15", - "@meshsdk/core-cst": "1.7.15", + "@meshsdk/common": "1.7.16", + "@meshsdk/core-csl": "1.7.16", + "@meshsdk/core-cst": "1.7.16", "json-bigint": "^1.0.0" }, "prettier": "@meshsdk/configs/prettier", diff --git a/packages/mesh-wallet/package.json b/packages/mesh-wallet/package.json index 90ccbc6eb..9428b10c4 100644 --- a/packages/mesh-wallet/package.json +++ b/packages/mesh-wallet/package.json @@ -1,6 +1,6 @@ { "name": "@meshsdk/wallet", - "version": "1.7.15", + "version": "1.7.16", "description": "", "main": "./dist/index.cjs", "browser": "./dist/index.js", @@ -35,10 +35,10 @@ "typescript": "^5.3.3" }, "dependencies": { - "@meshsdk/common": "1.7.15", - "@meshsdk/core-csl": "1.7.15", - "@meshsdk/core-cst": "1.7.15", - "@meshsdk/transaction": "1.7.15", + "@meshsdk/common": "1.7.16", + "@meshsdk/core-csl": "1.7.16", + "@meshsdk/core-cst": "1.7.16", + "@meshsdk/transaction": "1.7.16", "@nufi/dapp-client-cardano": "0.3.5", "@nufi/dapp-client-core": "0.3.5" }, diff --git a/scripts/mesh-cli/package.json b/scripts/mesh-cli/package.json index b3a656495..46433e167 100644 --- a/scripts/mesh-cli/package.json +++ b/scripts/mesh-cli/package.json @@ -3,7 +3,7 @@ "description": "A quick and easy way to bootstrap your dApps on Cardano using Mesh.", "homepage": "https://meshjs.dev", "author": "MeshJS", - "version": "1.7.15", + "version": "1.7.16", "license": "Apache-2.0", "type": "module", "main": "./dist/index.cjs", From e667535c6ecc587827939c5df5cff8ccf1687a47 Mon Sep 17 00:00:00 2001 From: "Hong Jing (Jingles)" Date: Fri, 15 Nov 2024 18:02:46 +0800 Subject: [PATCH 16/16] update links --- apps/playground/src/data/links-providers.ts | 12 +- .../src/pages/providers/offline-evaluator.tsx | 216 +++++++++--------- 2 files changed, 116 insertions(+), 112 deletions(-) diff --git a/apps/playground/src/data/links-providers.ts b/apps/playground/src/data/links-providers.ts index 47e0d91c6..c94315309 100644 --- a/apps/playground/src/data/links-providers.ts +++ b/apps/playground/src/data/links-providers.ts @@ -55,7 +55,14 @@ export const metaOfflineFetcher = { title: "Offline Fetcher", link: "/providers/offline-fetcher", desc: "Provider for testing, development and offline scenarios", - thumbnail: "/providers/hydra.svg", + thumbnail: "/logo-mesh/mesh.png", +}; + +export const metaOfflineEvaluator = { + title: "Offline Evaluator", + link: "/providers/offline-evaluator", + desc: "An offline Plutus script evaluator for testing and validation.", + thumbnail: "/logo-mesh/mesh.png", }; export const linksProviders: MenuItem[] = [ @@ -66,7 +73,8 @@ export const linksProviders: MenuItem[] = [ metaOgmios, metaU5c, metaYaci, - metaOfflineFetcher + metaOfflineFetcher, + metaOfflineEvaluator, ]; export const metaProviders = { diff --git a/apps/playground/src/pages/providers/offline-evaluator.tsx b/apps/playground/src/pages/providers/offline-evaluator.tsx index c6358bc9f..c49aea128 100644 --- a/apps/playground/src/pages/providers/offline-evaluator.tsx +++ b/apps/playground/src/pages/providers/offline-evaluator.tsx @@ -1,6 +1,8 @@ import type { NextPage } from "next"; + import { OfflineFetcher } from "@meshsdk/core"; import { OfflineEvaluator } from "@meshsdk/core-csl"; + import ButtonFloatDocumentation from "~/components/button/button-float-documentation"; import SidebarFullwidth from "~/components/layouts/sidebar-fullwidth"; import Link from "~/components/link"; @@ -11,119 +13,113 @@ import { metaOfflineEvaluator } from "~/data/links-providers"; import ProviderEvaluators from "./evaluators"; const ReactPage: NextPage = () => { - const sidebarItems = [ - { label: "Evaluate Transaction", to: "evaluateTx" }, - ]; - -let code1 = `import { OfflineEvaluator } from "@meshsdk/core-csl";\n\n`; -code1 += `import { OfflineFetcher } from "@meshsdk/core";\n\n`; -code1 += `// Create fetcher for resolving UTXOs\n`; -code1 += `const fetcher = new OfflineFetcher();\n\n`; -code1 += `// Add UTXOs required for script evaluation\n`; -code1 += `fetcher.addUTxOs([\n`; -code1 += ` {\n`; -code1 += ` input: { \n`; -code1 += ` txHash: "5de23a2...", \n`; -code1 += ` outputIndex: 0 \n`; -code1 += ` },\n`; -code1 += ` output: {\n`; -code1 += ` address: "addr1...",\n`; -code1 += ` amount: [{ unit: "lovelace", quantity: "1000000" }],\n`; -code1 += ` scriptHash: "32b7e3d..." // For script UTXOs\n`; -code1 += ` }\n`; -code1 += ` }\n`; -code1 += `]);\n\n`; -code1 += `// Create evaluator for the desired network\n`; -code1 += `const evaluator = new OfflineEvaluator(fetcher, "preprod");\n`; - -let code2 = `// Evaluate Plutus scripts in a transaction\n`; -code2 += `try {\n`; -code2 += ` const actions = await evaluator.evaluateTx(transactionCbor);\n`; -code2 += ` // Example result:\n`; -code2 += ` // [{\n`; -code2 += ` // index: 0,\n`; -code2 += ` // tag: "MINT",\n`; -code2 += ` // budget: {\n`; -code2 += ` // mem: 508703, // Memory units used\n`; -code2 += ` // steps: 164980381 // CPU steps used\n`; -code2 += ` // }\n`; -code2 += ` // }]\n`; -code2 += `} catch (error) {\n`; -code2 += ` console.error('Script evaluation failed:', error);\n`; -code2 += `}\n`; - -let code3 = `// In your test file\n`; -code3 += `describe("Plutus Script Tests", () => {\n`; -code3 += ` let evaluator: OfflineEvaluator;\n`; -code3 += ` let fetcher: OfflineFetcher;\n\n`; -code3 += ` beforeEach(() => {\n`; -code3 += ` fetcher = new OfflineFetcher();\n`; -code3 += ` evaluator = new OfflineEvaluator(fetcher, "preprod");\n\n`; -code3 += ` // Add test UTXOs\n`; -code3 += ` fetcher.addUTxOs([...]);\n`; -code3 += ` });\n\n`; -code3 += ` it("should evaluate minting policy", async () => {\n`; -code3 += ` const result = await evaluator.evaluateTx(txCbor);\n`; -code3 += ` expect(result[0].tag).toBe("MINT");\n`; -code3 += ` expect(result[0].budget.mem).toBeLessThan(600000);\n`; -code3 += ` });\n`; -code3 += `});\n`; - -const fetcher = new OfflineFetcher(); -const evaluator = new OfflineEvaluator(fetcher, "preprod"); - -return ( - <> - - - {\n`; + code3 += ` let evaluator: OfflineEvaluator;\n`; + code3 += ` let fetcher: OfflineFetcher;\n\n`; + code3 += ` beforeEach(() => {\n`; + code3 += ` fetcher = new OfflineFetcher();\n`; + code3 += ` evaluator = new OfflineEvaluator(fetcher, "preprod");\n\n`; + code3 += ` // Add test UTXOs\n`; + code3 += ` fetcher.addUTxOs([...]);\n`; + code3 += ` });\n\n`; + code3 += ` it("should evaluate minting policy", async () => {\n`; + code3 += ` const result = await evaluator.evaluateTx(txCbor);\n`; + code3 += ` expect(result[0].tag).toBe("MINT");\n`; + code3 += ` expect(result[0].budget.mem).toBeLessThan(600000);\n`; + code3 += ` });\n`; + code3 += `});\n`; + + const fetcher = new OfflineFetcher(); + const evaluator = new OfflineEvaluator(fetcher, "preprod"); + + return ( + <> + -

- The OfflineEvaluator calculates execution costs (memory and CPU steps) for - Plutus scripts in transactions without requiring network connectivity. It works - with an {" "} - - OfflineFetcher - - {" "} to resolve the UTXOs needed for script validation. -

- -

Get started:

- - - -

- Once initialized, you can evaluate Plutus scripts in transactions: -

- - -

- The evaluator is particularly useful for testing Plutus scripts, ensuring - they execute within memory and CPU limits: -

- - -

- The evaluation results include memory units and CPU steps required for each - script execution, helping you optimize your scripts and ensure they meet - protocol constraints. -

-
- - - - -
- -); + + +

+ The OfflineEvaluator calculates execution costs (memory and CPU + steps) for Plutus scripts in transactions without requiring network + connectivity. It works with an{" "} + OfflineFetcher to + resolve the UTXOs needed for script validation. This is also + compatible with any other fetchers to provide online data fetching. +

+ +

Get started:

+ + + +

+ Once initialized, you can evaluate Plutus scripts in transactions: +

+ + +

+ The evaluator is particularly useful for testing Plutus scripts, + ensuring they execute within memory and CPU limits: +

+ + +

+ The evaluation results include memory units and CPU steps required + for each script execution, helping you optimize your scripts and + ensure they meet protocol constraints. +

+
+ + + + +
+ + ); }; export default ReactPage;