diff --git a/apps/playground/src/pages/apis/transaction/basics/send-assets.tsx b/apps/playground/src/pages/apis/transaction/basics/send-assets.tsx index 00f00ace..9709df11 100644 --- a/apps/playground/src/pages/apis/transaction/basics/send-assets.tsx +++ b/apps/playground/src/pages/apis/transaction/basics/send-assets.tsx @@ -1,5 +1,6 @@ import { useState } from "react"; +import { Transaction } from "@meshsdk/core"; import { useWallet } from "@meshsdk/react"; import Input from "~/components/form/input"; @@ -8,7 +9,6 @@ import LiveCodeDemo from "~/components/sections/live-code-demo"; import TwoColumnsScroll from "~/components/sections/two-columns-scroll"; import Codeblock from "~/components/text/codeblock"; import { demoAddresses, demoAsset } from "~/data/cardano"; -import { Transaction } from "@meshsdk/core"; export default function TransactionSendAssets() { return ( @@ -59,13 +59,6 @@ function Right() { quantity: amount, }, ]); - tx.setMetadata(674, { - msg: [ - "Invoice-No: 1234567890", - "Customer-No: 555-1234", - "P.S.: i will shop again at your store :-)", - ], - }); const unsignedTx = await tx.build(); const signedTx = await wallet.signTx(unsignedTx); diff --git a/apps/playground/src/pages/apis/transaction/basics/send-lovelace.tsx b/apps/playground/src/pages/apis/transaction/basics/send-lovelace.tsx index 0fbca7bc..d778cef1 100644 --- a/apps/playground/src/pages/apis/transaction/basics/send-lovelace.tsx +++ b/apps/playground/src/pages/apis/transaction/basics/send-lovelace.tsx @@ -40,10 +40,10 @@ function Right() { const [amount, setAmount] = useState("1000000"); async function runDemo() { - const tx = new Transaction({ initiator: wallet }).sendLovelace( - address, - amount, - ); + const tx = new Transaction({ + initiator: wallet, + verbose: true, + }).sendLovelace(address, amount); const unsignedTx = await tx.build(); const signedTx = await wallet.signTx(unsignedTx); diff --git a/apps/playground/src/pages/apis/transaction/common.tsx b/apps/playground/src/pages/apis/transaction/common.tsx index 3e38d850..3fe12f28 100644 --- a/apps/playground/src/pages/apis/transaction/common.tsx +++ b/apps/playground/src/pages/apis/transaction/common.tsx @@ -3,7 +3,7 @@ import Codeblock from "~/components/text/codeblock"; export function Intro() { let example = ``; example += `import { Transaction } from '@meshsdk/core';\n\n`; - example += `const tx = new Transaction({ initiator: wallet });\n`; + example += `const tx = new Transaction({ initiator: wallet, verbose: false });\n`; example += `tx.foo(...); // add transaction methods\n`; example += `tx.bar(...); // add transaction methods\n\n`; example += `const unsignedTx = await tx.build();\n`; @@ -22,6 +22,11 @@ export function Intro() { and returns the remaining assets to the change address. Use{" "} wallet.signTx() to sign transaction CBOR.

+

+ The verbose is optional and set to false by + default, setting it to true will enable verbose logging for + the txBodyJson prior going into build. +

); diff --git a/package-lock.json b/package-lock.json index d8fd1b34..9cd0756e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -95,6 +95,15 @@ "undici-types": "~5.26.4" } }, + "apps/docs/node_modules/@types/react": { + "version": "18.3.3", + "devOptional": true, + "license": "MIT", + "dependencies": { + "@types/prop-types": "*", + "csstype": "^3.0.2" + } + }, "apps/docs/node_modules/autoprefixer": { "version": "10.4.19", "dev": true, @@ -217,9 +226,8 @@ }, "apps/docs/node_modules/undici-types": { "version": "5.26.5", - "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-5.26.5.tgz", - "integrity": "sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==", - "dev": true + "dev": true, + "license": "MIT" }, "apps/docs/node_modules/use-sync-external-store": { "version": "1.2.0", @@ -336,103 +344,103 @@ } }, "node_modules/@algolia/client-abtesting": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/@algolia/client-abtesting/-/client-abtesting-5.0.0.tgz", - "integrity": "sha512-pVSwJ2QZ9hNeINjSWRQGwN/zAk16E6fOM4VGayIULyiJnaIaRjGT/UfMRiGsIuBFib2zviq83uO8GOnCUBmXnA==", + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/@algolia/client-abtesting/-/client-abtesting-5.1.1.tgz", + "integrity": "sha512-Zz4c1VSwBKu1qD44/9zYd7OjcwsfiPJkqKArYcQuJJihHUwodfnmf4Agi29M07exa8dySo9SHYcWKRxrpkKRiA==", "peer": true, "dependencies": { - "@algolia/client-common": "5.0.0", - "@algolia/requester-browser-xhr": "5.0.0", - "@algolia/requester-node-http": "5.0.0" + "@algolia/client-common": "5.1.1", + "@algolia/requester-browser-xhr": "5.1.1", + "@algolia/requester-node-http": "5.1.1" }, "engines": { "node": ">= 14.0.0" } }, "node_modules/@algolia/client-analytics": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/@algolia/client-analytics/-/client-analytics-5.0.0.tgz", - "integrity": "sha512-3A4JyblLorrxkYn6uOWyo7drDi3z7+Yzm45YP1MgOvzOCt0qWlEb6neIFLDe4UrBy24JqmRx54uNMBuYMOscgw==", + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/@algolia/client-analytics/-/client-analytics-5.1.1.tgz", + "integrity": "sha512-0IjlWzzUtIHaoxqlHPUHCPzQQdzhUXThLHUlexeSMZSqqibmC5Ku6Hz3LFMBDGxoCC6L+qWgyd2x6aE9XupaNA==", "peer": true, "dependencies": { - "@algolia/client-common": "5.0.0", - "@algolia/requester-browser-xhr": "5.0.0", - "@algolia/requester-node-http": "5.0.0" + "@algolia/client-common": "5.1.1", + "@algolia/requester-browser-xhr": "5.1.1", + "@algolia/requester-node-http": "5.1.1" }, "engines": { "node": ">= 14.0.0" } }, "node_modules/@algolia/client-common": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/@algolia/client-common/-/client-common-5.0.0.tgz", - "integrity": "sha512-6N5Qygv/Z/B+rPufnPDLNWgsMf1uubMU7iS52xLcQSLiGlTS4f9eLUrmNXSzHccP33uoFi6xN9craN1sZi5MPQ==", + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/@algolia/client-common/-/client-common-5.1.1.tgz", + "integrity": "sha512-jkQNQbGY+XQB3Eln7wqqdUZKBzG8lETcsaUk5gcMc6iIwyN/qW0v0fhpKPH+Kli+BImLxo0CWk12CvVvx2exWA==", "peer": true, "engines": { "node": ">= 14.0.0" } }, "node_modules/@algolia/client-personalization": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/@algolia/client-personalization/-/client-personalization-5.0.0.tgz", - "integrity": "sha512-Ns9pl+YGl0qZTbMqEKIO54GJqzyrMUmLfPB3/iEEkezKMMHXAsINrOuKTfhA6vyI0vhUJL3imOPo6vmXZBDZsA==", + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/@algolia/client-personalization/-/client-personalization-5.1.1.tgz", + "integrity": "sha512-Cf20l5ZyHkm7I+DnQ3d1rbgUMkx4GcLhN4AGBfN/MDhSQNG7mORCc4RKRvg62vG95NAElbfx1JcnAuLLucQ3Rw==", "peer": true, "dependencies": { - "@algolia/client-common": "5.0.0", - "@algolia/requester-browser-xhr": "5.0.0", - "@algolia/requester-node-http": "5.0.0" + "@algolia/client-common": "5.1.1", + "@algolia/requester-browser-xhr": "5.1.1", + "@algolia/requester-node-http": "5.1.1" }, "engines": { "node": ">= 14.0.0" } }, "node_modules/@algolia/client-search": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/@algolia/client-search/-/client-search-5.0.0.tgz", - "integrity": "sha512-QdDYMzoxYZ3axzBy6CHe+M+NlOGvHEFTa2actchGnp25Uu0N6lyVNivT7nph+P1XoxgAD08cWbeJD3wWQXnpng==", + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/@algolia/client-search/-/client-search-5.1.1.tgz", + "integrity": "sha512-SFpb3FI/VouGou/vpuS7qeCA5Y/KpV42P6CEA/1MZQtl/xJkl6PVjikb+Q9YadeHi2jtDV/aQ6PyiVDnX4PQcw==", "peer": true, "dependencies": { - "@algolia/client-common": "5.0.0", - "@algolia/requester-browser-xhr": "5.0.0", - "@algolia/requester-node-http": "5.0.0" + "@algolia/client-common": "5.1.1", + "@algolia/requester-browser-xhr": "5.1.1", + "@algolia/requester-node-http": "5.1.1" }, "engines": { "node": ">= 14.0.0" } }, "node_modules/@algolia/recommend": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/@algolia/recommend/-/recommend-5.0.0.tgz", - "integrity": "sha512-aEXg4RPFIRrJjrtri782W7XFNkarxoN9X42FwYYP1bz15jKu2vrIqzGlQoNCNWuZP7WwYyUAoTtixwLRJq8grQ==", + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/@algolia/recommend/-/recommend-5.1.1.tgz", + "integrity": "sha512-ebtbWTXBSaeg7DarDU3IXjbJgcVM6mtoHeK/VvMka+KAaJXoVsMfD402qs4cN0gaw0bAy3dNUmXkV0nNi1kq4g==", "peer": true, "dependencies": { - "@algolia/client-common": "5.0.0", - "@algolia/requester-browser-xhr": "5.0.0", - "@algolia/requester-node-http": "5.0.0" + "@algolia/client-common": "5.1.1", + "@algolia/requester-browser-xhr": "5.1.1", + "@algolia/requester-node-http": "5.1.1" }, "engines": { "node": ">= 14.0.0" } }, "node_modules/@algolia/requester-browser-xhr": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/@algolia/requester-browser-xhr/-/requester-browser-xhr-5.0.0.tgz", - "integrity": "sha512-oOoQhSpg/RGiGHjn/cqtYpHBkkd+5M/DCi1jmfW+ZOvLVx21QVt6PbWIJoKJF85moNFo4UG9pMBU35R1MaxUKQ==", + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/@algolia/requester-browser-xhr/-/requester-browser-xhr-5.1.1.tgz", + "integrity": "sha512-NXmN1ujJCj5GlJQaMK6DbdiXdcf6nhRef/X40lu9TYi71q9xTo/5RPMI0K2iOp6g07S26BrXFOz6RSV3Ny4LLw==", "peer": true, "dependencies": { - "@algolia/client-common": "5.0.0" + "@algolia/client-common": "5.1.1" }, "engines": { "node": ">= 14.0.0" } }, "node_modules/@algolia/requester-node-http": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/@algolia/requester-node-http/-/requester-node-http-5.0.0.tgz", - "integrity": "sha512-FwCdugzpnW0wxbgWPauAz5vhmWGQnjZa5DCl9PBbIoDNEy/NIV8DmiL9CEA+LljQdDidG0l0ijojcTNaRRtPvQ==", + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/@algolia/requester-node-http/-/requester-node-http-5.1.1.tgz", + "integrity": "sha512-xwrgnNTIzgxDEx6zuCKSKTPzQLA8fL/WZiVB6fRpIu5agLMjoAi0cWA5YSDbo+2FFxqVgLqKY/Jz6mKmWtY15Q==", "peer": true, "dependencies": { - "@algolia/client-common": "5.0.0" + "@algolia/client-common": "5.1.1" }, "engines": { "node": ">= 14.0.0" @@ -476,9 +484,9 @@ } }, "node_modules/@babel/compat-data": { - "version": "7.25.2", - "resolved": "https://registry.npmjs.org/@babel/compat-data/-/compat-data-7.25.2.tgz", - "integrity": "sha512-bYcppcpKBvX4znYaPEeFau03bp89ShqNMLs+rmdptMw+heSZh9+z84d2YG+K7cYLbWwzdjtDoW/uqZmPjulClQ==", + "version": "7.25.4", + "resolved": "https://registry.npmjs.org/@babel/compat-data/-/compat-data-7.25.4.tgz", + "integrity": "sha512-+LGRog6RAsCJrrrg/IO6LGmpphNe5DiK30dGjCoxxeGv49B10/3XYGxPsAwrDlMFcFEvdAUavDT8r9k/hSyQqQ==", "dev": true, "engines": { "node": ">=6.9.0" @@ -542,12 +550,12 @@ } }, "node_modules/@babel/generator": { - "version": "7.25.0", - "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.25.0.tgz", - "integrity": "sha512-3LEEcj3PVW8pW2R1SR1M89g/qrYk/m/mB/tLqn7dn4sbBUQyTqnlod+II2U4dqiGtUmkcnAmkMDralTFZttRiw==", + "version": "7.25.5", + "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.25.5.tgz", + "integrity": "sha512-abd43wyLfbWoxC6ahM8xTkqLpGB2iWBVyuKC9/srhFunCd1SDNrV1s72bBpK4hLj8KLzHBBcOblvLQZBNw9r3w==", "dev": true, "dependencies": { - "@babel/types": "^7.25.0", + "@babel/types": "^7.25.4", "@jridgewell/gen-mapping": "^0.3.5", "@jridgewell/trace-mapping": "^0.3.25", "jsesc": "^2.5.1" @@ -752,12 +760,12 @@ } }, "node_modules/@babel/parser": { - "version": "7.25.3", - "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.25.3.tgz", - "integrity": "sha512-iLTJKDbJ4hMvFPgQwwsVoxtHyWpKKPBrxkANrSYewDPaPpT5py5yeVkgPIJ7XYXhndxJpaA3PyALSXQ7u8e/Dw==", + "version": "7.25.4", + "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.25.4.tgz", + "integrity": "sha512-nq+eWrOgdtu3jG5Os4TQP3x3cLA8hR8TvJNjD8vnPa20WGycimcparWnLK4jJhElTK6SDyuJo1weMKO/5LpmLA==", "dev": true, "dependencies": { - "@babel/types": "^7.25.2" + "@babel/types": "^7.25.4" }, "bin": { "parser": "bin/babel-parser.js" @@ -974,12 +982,12 @@ } }, "node_modules/@babel/plugin-syntax-typescript": { - "version": "7.24.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-typescript/-/plugin-syntax-typescript-7.24.7.tgz", - "integrity": "sha512-c/+fVeJBB0FeKsFvwytYiUD+LBvhHjGSI0g446PRGdSVGZLRNArBUno2PETbAly3tpiNAQR5XaZ+JslxkotsbA==", + "version": "7.25.4", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-typescript/-/plugin-syntax-typescript-7.25.4.tgz", + "integrity": "sha512-uMOCoHVU52BsSWxPOMVv5qKRdeSlPuImUCB2dlPuBSU+W2/ROE7/Zg8F2Kepbk+8yBa68LlRKxO+xgEVWorsDg==", "dev": true, "dependencies": { - "@babel/helper-plugin-utils": "^7.24.7" + "@babel/helper-plugin-utils": "^7.24.8" }, "engines": { "node": ">=6.9.0" @@ -989,9 +997,9 @@ } }, "node_modules/@babel/runtime": { - "version": "7.25.0", - "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.25.0.tgz", - "integrity": "sha512-7dRy4DwXwtzBrPbZflqxnvfxLF8kdZXPkhymtDeFoFqE6ldzjQFgYTtYIFARcLEYDrqfBfYcZt1WqFxRoyC9Rw==", + "version": "7.25.4", + "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.25.4.tgz", + "integrity": "sha512-DSgLeL/FNcpXuzav5wfYvHCGvynXkJbn3Zvc3823AEe9nPwW9IK4UoCSS5yGymmQzN0pCPvivtgS6/8U2kkm1w==", "dependencies": { "regenerator-runtime": "^0.14.0" }, @@ -1014,16 +1022,16 @@ } }, "node_modules/@babel/traverse": { - "version": "7.25.3", - "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.25.3.tgz", - "integrity": "sha512-HefgyP1x754oGCsKmV5reSmtV7IXj/kpaE1XYY+D9G5PvKKoFfSbiS4M77MdjuwlZKDIKFCffq9rPU+H/s3ZdQ==", + "version": "7.25.4", + "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.25.4.tgz", + "integrity": "sha512-VJ4XsrD+nOvlXyLzmLzUs/0qjFS4sK30te5yEFlvbbUNEgKaVb2BHZUpAL+ttLPQAHNrsI3zZisbfha5Cvr8vg==", "dev": true, "dependencies": { "@babel/code-frame": "^7.24.7", - "@babel/generator": "^7.25.0", - "@babel/parser": "^7.25.3", + "@babel/generator": "^7.25.4", + "@babel/parser": "^7.25.4", "@babel/template": "^7.25.0", - "@babel/types": "^7.25.2", + "@babel/types": "^7.25.4", "debug": "^4.3.1", "globals": "^11.1.0" }, @@ -1041,9 +1049,9 @@ } }, "node_modules/@babel/types": { - "version": "7.25.2", - "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.25.2.tgz", - "integrity": "sha512-YTnYtra7W9e6/oAZEHj0bJehPRUlLH9/fbpT5LfB0NhQXyALCRkRs3zH9v07IYhkgpqX6Z78FnuccZr/l4Fs4Q==", + "version": "7.25.4", + "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.25.4.tgz", + "integrity": "sha512-zQ1ijeeCXVEh+aNL0RlmkPkG8HUiDcU2pzQQFjtbntgAczRASFzj4H+6+bV+dy1ntKR14I/DypeuRG1uma98iQ==", "dev": true, "dependencies": { "@babel/helper-string-parser": "^7.24.8", @@ -1133,11 +1141,11 @@ } }, "node_modules/@cardano-sdk/crypto": { - "version": "0.1.29", - "resolved": "https://registry.npmjs.org/@cardano-sdk/crypto/-/crypto-0.1.29.tgz", - "integrity": "sha512-V7a6AA1GZzKYRqPe6vGj5hXbb16C4M/G3KEEvpQeREz2J83t6ty2gZCtx4VCUpRuKtEQUW/NHzeiEZnEbWQiQQ==", + "version": "0.1.30", + "resolved": "https://registry.npmjs.org/@cardano-sdk/crypto/-/crypto-0.1.30.tgz", + "integrity": "sha512-xUJSF+OWL8z1t/cnjRlYVMIC2zlk3cYazn6/+bEyvXHv9+XyPbgZK44iOiJryJcgsaG7ibzJXaOw/DWeS1dwSg==", "dependencies": { - "@cardano-sdk/util": "~0.15.4", + "@cardano-sdk/util": "~0.15.5", "blake2b": "^2.1.4", "i": "^0.3.7", "libsodium-wrappers-sumo": "^0.7.5", @@ -4196,13 +4204,13 @@ "license": "ISC" }, "node_modules/@cardano-sdk/dapp-connector": { - "version": "0.12.29", - "resolved": "https://registry.npmjs.org/@cardano-sdk/dapp-connector/-/dapp-connector-0.12.29.tgz", - "integrity": "sha512-lvBX1EREsZ9be6UxTlbKL/9fANefnpsnatjgA3tE9MinLd/CDXMmzvjt/PbRGagYWROWrr65v3jDzI3fao6ZRQ==", + "version": "0.12.33", + "resolved": "https://registry.npmjs.org/@cardano-sdk/dapp-connector/-/dapp-connector-0.12.33.tgz", + "integrity": "sha512-KMwh6LDcBdorA6X+HDtVOoyDcNSjxGebFxjXuSV3nDrRS5ueWCbZz2Txc0acT4ucXhCc3itl/5WdfNP11JJ3+Q==", "dependencies": { - "@cardano-sdk/core": "~0.38.0", - "@cardano-sdk/crypto": "~0.1.29", - "@cardano-sdk/util": "~0.15.4", + "@cardano-sdk/core": "~0.39.0", + "@cardano-sdk/crypto": "~0.1.30", + "@cardano-sdk/util": "~0.15.5", "ts-custom-error": "^3.2.0", "ts-log": "^2.2.4", "webextension-polyfill": "^0.8.0" @@ -4240,14 +4248,14 @@ } }, "node_modules/@cardano-sdk/dapp-connector/node_modules/@cardano-sdk/core": { - "version": "0.38.0", - "resolved": "https://registry.npmjs.org/@cardano-sdk/core/-/core-0.38.0.tgz", - "integrity": "sha512-BMvR7unraMYiveA0MYT7cAydK3FhQuAbUX4qKAxWnwPzYleG6l68mUhMxW22/8yfAij6ocYi5XMuGSw5srgtbg==", + "version": "0.39.0", + "resolved": "https://registry.npmjs.org/@cardano-sdk/core/-/core-0.39.0.tgz", + "integrity": "sha512-7nrRrFK8hM1XKzTsRjyGMZY46oK0KcQtIR0e44xqlxHo2sG4iy3abL60DhguDqcJkagmap8TPTT36QVtrgD4iQ==", "dependencies": { "@cardano-ogmios/client": "6.5.0", "@cardano-ogmios/schema": "6.5.0", - "@cardano-sdk/crypto": "~0.1.29", - "@cardano-sdk/util": "~0.15.4", + "@cardano-sdk/crypto": "~0.1.30", + "@cardano-sdk/util": "~0.15.5", "@foxglove/crc": "^0.0.3", "@scure/base": "^1.1.1", "fraction.js": "4.0.1", @@ -4360,14 +4368,14 @@ } }, "node_modules/@cardano-sdk/key-management/node_modules/@cardano-sdk/key-management": { - "version": "0.23.0", - "resolved": "https://registry.npmjs.org/@cardano-sdk/key-management/-/key-management-0.23.0.tgz", - "integrity": "sha512-vjf2CL8QY6FePo28gW2bujAtnEP+5Ie/Xbp0z+QcafYcJZW5AU4DPVRLXd1Df3V0roB/5BvAwW4ujN2uC+kLog==", - "dependencies": { - "@cardano-sdk/core": "~0.38.0", - "@cardano-sdk/crypto": "~0.1.29", - "@cardano-sdk/dapp-connector": "~0.12.29", - "@cardano-sdk/util": "~0.15.4", + "version": "0.23.4", + "resolved": "https://registry.npmjs.org/@cardano-sdk/key-management/-/key-management-0.23.4.tgz", + "integrity": "sha512-KvfiKoyo8Tq/PTgxfg7nwZnZSa4GB+i0JbLRa8EneMWxEuB726BOW2Ra8gvdsW8QAYxLw/uD9FDeF8iiM3jY2A==", + "dependencies": { + "@cardano-sdk/core": "~0.39.0", + "@cardano-sdk/crypto": "~0.1.30", + "@cardano-sdk/dapp-connector": "~0.12.33", + "@cardano-sdk/util": "~0.15.5", "@emurgo/cardano-message-signing-nodejs": "^1.0.1", "bip39": "^3.0.4", "chacha": "^2.1.0", @@ -4383,14 +4391,14 @@ } }, "node_modules/@cardano-sdk/key-management/node_modules/@cardano-sdk/key-management/node_modules/@cardano-sdk/core": { - "version": "0.38.0", - "resolved": "https://registry.npmjs.org/@cardano-sdk/core/-/core-0.38.0.tgz", - "integrity": "sha512-BMvR7unraMYiveA0MYT7cAydK3FhQuAbUX4qKAxWnwPzYleG6l68mUhMxW22/8yfAij6ocYi5XMuGSw5srgtbg==", + "version": "0.39.0", + "resolved": "https://registry.npmjs.org/@cardano-sdk/core/-/core-0.39.0.tgz", + "integrity": "sha512-7nrRrFK8hM1XKzTsRjyGMZY46oK0KcQtIR0e44xqlxHo2sG4iy3abL60DhguDqcJkagmap8TPTT36QVtrgD4iQ==", "dependencies": { "@cardano-ogmios/client": "6.5.0", "@cardano-ogmios/schema": "6.5.0", - "@cardano-sdk/crypto": "~0.1.29", - "@cardano-sdk/util": "~0.15.4", + "@cardano-sdk/crypto": "~0.1.30", + "@cardano-sdk/util": "~0.15.5", "@foxglove/crc": "^0.0.3", "@scure/base": "^1.1.1", "fraction.js": "4.0.1", @@ -4413,16 +4421,16 @@ } }, "node_modules/@cardano-sdk/key-management/node_modules/@cardano-sdk/util-dev": { - "version": "0.22.2", - "resolved": "https://registry.npmjs.org/@cardano-sdk/util-dev/-/util-dev-0.22.2.tgz", - "integrity": "sha512-GrQS5kZ50wrPymf2ImihdQDheWK+7ggOZXXSR2mXdOrsS6QlkFr6AznBsh+avNxihWhcFAJMzly00IQhazsEZQ==", - "dependencies": { - "@cardano-sdk/core": "~0.38.0", - "@cardano-sdk/crypto": "~0.1.29", - "@cardano-sdk/key-management": "~0.23.0", - "@cardano-sdk/util": "~0.15.4", + "version": "0.22.6", + "resolved": "https://registry.npmjs.org/@cardano-sdk/util-dev/-/util-dev-0.22.6.tgz", + "integrity": "sha512-qSMDcihdfXRneUKXTUozjgp18kt1y75PNwgy0PpAXaWBKFX/j/zoTI117F3XVKg6IgIiKFy60iuYbil/1Kl0qw==", + "dependencies": { + "@cardano-sdk/core": "~0.39.0", + "@cardano-sdk/crypto": "~0.1.30", + "@cardano-sdk/key-management": "~0.23.4", + "@cardano-sdk/util": "~0.15.5", "@types/dockerode": "^3.3.8", - "axios": "^0.28.0", + "axios": "^1.7.4", "delay": "^5.0.0", "dockerode": "^3.3.1", "dockerode-utils": "^0.0.7", @@ -4438,14 +4446,14 @@ } }, "node_modules/@cardano-sdk/key-management/node_modules/@cardano-sdk/util-dev/node_modules/@cardano-sdk/core": { - "version": "0.38.0", - "resolved": "https://registry.npmjs.org/@cardano-sdk/core/-/core-0.38.0.tgz", - "integrity": "sha512-BMvR7unraMYiveA0MYT7cAydK3FhQuAbUX4qKAxWnwPzYleG6l68mUhMxW22/8yfAij6ocYi5XMuGSw5srgtbg==", + "version": "0.39.0", + "resolved": "https://registry.npmjs.org/@cardano-sdk/core/-/core-0.39.0.tgz", + "integrity": "sha512-7nrRrFK8hM1XKzTsRjyGMZY46oK0KcQtIR0e44xqlxHo2sG4iy3abL60DhguDqcJkagmap8TPTT36QVtrgD4iQ==", "dependencies": { "@cardano-ogmios/client": "6.5.0", "@cardano-ogmios/schema": "6.5.0", - "@cardano-sdk/crypto": "~0.1.29", - "@cardano-sdk/util": "~0.15.4", + "@cardano-sdk/crypto": "~0.1.30", + "@cardano-sdk/util": "~0.15.5", "@foxglove/crc": "^0.0.3", "@scure/base": "^1.1.1", "fraction.js": "4.0.1", @@ -4467,16 +4475,6 @@ } } }, - "node_modules/@cardano-sdk/key-management/node_modules/axios": { - "version": "0.28.1", - "resolved": "https://registry.npmjs.org/axios/-/axios-0.28.1.tgz", - "integrity": "sha512-iUcGA5a7p0mVb4Gm/sy+FSECNkPFT4y7wt6OM/CDpO/OnNCvSs3PoMG8ibrC9jRoGYU0gUK5pXVC4NPXq6lHRQ==", - "dependencies": { - "follow-redirects": "^1.15.0", - "form-data": "^4.0.0", - "proxy-from-env": "^1.1.0" - } - }, "node_modules/@cardano-sdk/key-management/node_modules/fraction.js": { "version": "4.0.1", "resolved": "https://registry.npmjs.org/fraction.js/-/fraction.js-4.0.1.tgz", @@ -4486,9 +4484,9 @@ } }, "node_modules/@cardano-sdk/util": { - "version": "0.15.4", - "resolved": "https://registry.npmjs.org/@cardano-sdk/util/-/util-0.15.4.tgz", - "integrity": "sha512-lUPCCPADaORY0O5fFKYzGSQiQtCK6pkF7XKxDIwpWts9MvW6RKm8QtUiY0J0FpzcbTTIvcMWOfzkOivtTm3LvA==", + "version": "0.15.5", + "resolved": "https://registry.npmjs.org/@cardano-sdk/util/-/util-0.15.5.tgz", + "integrity": "sha512-TM80z29l6FMa878HBSHFETrRLA/jfh4X+CEF3RPw6Bf0a+BpXL9ve2qKjWMv5Gf4fvRIq1r+pFVKQGWKR9SzIA==", "dependencies": { "bech32": "^2.0.0", "lodash": "^4.17.21", @@ -5929,22 +5927,22 @@ } }, "node_modules/@next/env": { - "version": "14.2.5", - "resolved": "https://registry.npmjs.org/@next/env/-/env-14.2.5.tgz", - "integrity": "sha512-/zZGkrTOsraVfYjGP8uM0p6r0BDT6xWpkjdVbcz66PJVSpwXX3yNiRycxAuDfBKGWBrZBXRuK/YVlkNgxHGwmA==" + "version": "14.2.6", + "resolved": "https://registry.npmjs.org/@next/env/-/env-14.2.6.tgz", + "integrity": "sha512-bs5DFKV+08EjWrl8EB+KKqev1ZTNONH1vFCaHh911aaB362NnP32UDTbE9VQhyiAgbFqJsfDkSxFERNDDb3j0g==" }, "node_modules/@next/eslint-plugin-next": { - "version": "14.2.5", - "resolved": "https://registry.npmjs.org/@next/eslint-plugin-next/-/eslint-plugin-next-14.2.5.tgz", - "integrity": "sha512-LY3btOpPh+OTIpviNojDpUdIbHW9j0JBYBjsIp8IxtDFfYFyORvw3yNq6N231FVqQA7n7lwaf7xHbVJlA1ED7g==", + "version": "14.2.6", + "resolved": "https://registry.npmjs.org/@next/eslint-plugin-next/-/eslint-plugin-next-14.2.6.tgz", + "integrity": "sha512-d3+p4AjIYmhqzYHhhmkRYYN6ZU35TwZAKX08xKRfnHkz72KhWL2kxMFsDptpZs5e8bBGdepn7vn1+9DaF8iX+A==", "dependencies": { "glob": "10.3.10" } }, "node_modules/@next/mdx": { - "version": "14.2.5", - "resolved": "https://registry.npmjs.org/@next/mdx/-/mdx-14.2.5.tgz", - "integrity": "sha512-AROhSdXQg0/jt55iqxVSJqp9oaCyXwRe44/I17c77gDshZ6ex7VKBZDH0GljaxZ0Y4mScYUbFJJEh42Xw4X4Dg==", + "version": "14.2.6", + "resolved": "https://registry.npmjs.org/@next/mdx/-/mdx-14.2.6.tgz", + "integrity": "sha512-59jhA506DXouG5T1lUjG8TAYGIQNia6hDuDgRIJwWfOEzgDvIOZHL3/oUGFH9BS2/Y75a9y0l65Lz0aMvUEWeg==", "dependencies": { "source-map": "^0.7.0" }, @@ -5962,9 +5960,9 @@ } }, "node_modules/@next/swc-darwin-arm64": { - "version": "14.2.5", - "resolved": "https://registry.npmjs.org/@next/swc-darwin-arm64/-/swc-darwin-arm64-14.2.5.tgz", - "integrity": "sha512-/9zVxJ+K9lrzSGli1///ujyRfon/ZneeZ+v4ptpiPoOU+GKZnm8Wj8ELWU1Pm7GHltYRBklmXMTUqM/DqQ99FQ==", + "version": "14.2.6", + "resolved": "https://registry.npmjs.org/@next/swc-darwin-arm64/-/swc-darwin-arm64-14.2.6.tgz", + "integrity": "sha512-BtJZb+hYXGaVJJivpnDoi3JFVn80SHKCiiRUW3kk1SY6UCUy5dWFFSbh+tGi5lHAughzeduMyxbLt3pspvXNSg==", "cpu": [ "arm64" ], @@ -5977,9 +5975,9 @@ } }, "node_modules/@next/swc-darwin-x64": { - "version": "14.2.5", - "resolved": "https://registry.npmjs.org/@next/swc-darwin-x64/-/swc-darwin-x64-14.2.5.tgz", - "integrity": "sha512-vXHOPCwfDe9qLDuq7U1OYM2wUY+KQ4Ex6ozwsKxp26BlJ6XXbHleOUldenM67JRyBfVjv371oneEvYd3H2gNSA==", + "version": "14.2.6", + "resolved": "https://registry.npmjs.org/@next/swc-darwin-x64/-/swc-darwin-x64-14.2.6.tgz", + "integrity": "sha512-ZHRbGpH6KHarzm6qEeXKSElSXh8dS2DtDPjQt3IMwY8QVk7GbdDYjvV4NgSnDA9huGpGgnyy3tH8i5yHCqVkiQ==", "cpu": [ "x64" ], @@ -5992,9 +5990,9 @@ } }, "node_modules/@next/swc-linux-arm64-gnu": { - "version": "14.2.5", - "resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-gnu/-/swc-linux-arm64-gnu-14.2.5.tgz", - "integrity": "sha512-vlhB8wI+lj8q1ExFW8lbWutA4M2ZazQNvMWuEDqZcuJJc78iUnLdPPunBPX8rC4IgT6lIx/adB+Cwrl99MzNaA==", + "version": "14.2.6", + "resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-gnu/-/swc-linux-arm64-gnu-14.2.6.tgz", + "integrity": "sha512-O4HqUEe3ZvKshXHcDUXn1OybN4cSZg7ZdwHJMGCXSUEVUqGTJVsOh17smqilIjooP/sIJksgl+1kcf2IWMZWHg==", "cpu": [ "arm64" ], @@ -6007,9 +6005,9 @@ } }, "node_modules/@next/swc-linux-arm64-musl": { - "version": "14.2.5", - "resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-musl/-/swc-linux-arm64-musl-14.2.5.tgz", - "integrity": "sha512-NpDB9NUR2t0hXzJJwQSGu1IAOYybsfeB+LxpGsXrRIb7QOrYmidJz3shzY8cM6+rO4Aojuef0N/PEaX18pi9OA==", + "version": "14.2.6", + "resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-musl/-/swc-linux-arm64-musl-14.2.6.tgz", + "integrity": "sha512-xUcdhr2hfalG8RDDGSFxQ75yOG894UlmFS4K2M0jLrUhauRBGOtUOxoDVwiIIuZQwZ3Y5hDsazNjdYGB0cQ9yQ==", "cpu": [ "arm64" ], @@ -6022,9 +6020,9 @@ } }, "node_modules/@next/swc-linux-x64-gnu": { - "version": "14.2.5", - "resolved": "https://registry.npmjs.org/@next/swc-linux-x64-gnu/-/swc-linux-x64-gnu-14.2.5.tgz", - "integrity": "sha512-8XFikMSxWleYNryWIjiCX+gU201YS+erTUidKdyOVYi5qUQo/gRxv/3N1oZFCgqpesN6FPeqGM72Zve+nReVXQ==", + "version": "14.2.6", + "resolved": "https://registry.npmjs.org/@next/swc-linux-x64-gnu/-/swc-linux-x64-gnu-14.2.6.tgz", + "integrity": "sha512-InosKxw8UMcA/wEib5n2QttwHSKHZHNSbGcMepBM0CTcNwpxWzX32KETmwbhKod3zrS8n1vJ+DuJKbL9ZAB0Ag==", "cpu": [ "x64" ], @@ -6037,9 +6035,9 @@ } }, "node_modules/@next/swc-linux-x64-musl": { - "version": "14.2.5", - "resolved": "https://registry.npmjs.org/@next/swc-linux-x64-musl/-/swc-linux-x64-musl-14.2.5.tgz", - "integrity": "sha512-6QLwi7RaYiQDcRDSU/os40r5o06b5ue7Jsk5JgdRBGGp8l37RZEh9JsLSM8QF0YDsgcosSeHjglgqi25+m04IQ==", + "version": "14.2.6", + "resolved": "https://registry.npmjs.org/@next/swc-linux-x64-musl/-/swc-linux-x64-musl-14.2.6.tgz", + "integrity": "sha512-d4QXfJmt5pGJ7cG8qwxKSBnO5AXuKAFYxV7qyDRHnUNvY/dgDh+oX292gATpB2AAHgjdHd5ks1wXxIEj6muLUQ==", "cpu": [ "x64" ], @@ -6052,9 +6050,9 @@ } }, "node_modules/@next/swc-win32-arm64-msvc": { - "version": "14.2.5", - "resolved": "https://registry.npmjs.org/@next/swc-win32-arm64-msvc/-/swc-win32-arm64-msvc-14.2.5.tgz", - "integrity": "sha512-1GpG2VhbspO+aYoMOQPQiqc/tG3LzmsdBH0LhnDS3JrtDx2QmzXe0B6mSZZiN3Bq7IOMXxv1nlsjzoS1+9mzZw==", + "version": "14.2.6", + "resolved": "https://registry.npmjs.org/@next/swc-win32-arm64-msvc/-/swc-win32-arm64-msvc-14.2.6.tgz", + "integrity": "sha512-AlgIhk4/G+PzOG1qdF1b05uKTMsuRatFlFzAi5G8RZ9h67CVSSuZSbqGHbJDlcV1tZPxq/d4G0q6qcHDKWf4aQ==", "cpu": [ "arm64" ], @@ -6067,9 +6065,9 @@ } }, "node_modules/@next/swc-win32-ia32-msvc": { - "version": "14.2.5", - "resolved": "https://registry.npmjs.org/@next/swc-win32-ia32-msvc/-/swc-win32-ia32-msvc-14.2.5.tgz", - "integrity": "sha512-Igh9ZlxwvCDsu6438FXlQTHlRno4gFpJzqPjSIBZooD22tKeI4fE/YMRoHVJHmrQ2P5YL1DoZ0qaOKkbeFWeMg==", + "version": "14.2.6", + "resolved": "https://registry.npmjs.org/@next/swc-win32-ia32-msvc/-/swc-win32-ia32-msvc-14.2.6.tgz", + "integrity": "sha512-hNukAxq7hu4o5/UjPp5jqoBEtrpCbOmnUqZSKNJG8GrUVzfq0ucdhQFVrHcLRMvQcwqqDh1a5AJN9ORnNDpgBQ==", "cpu": [ "ia32" ], @@ -6082,9 +6080,9 @@ } }, "node_modules/@next/swc-win32-x64-msvc": { - "version": "14.2.5", - "resolved": "https://registry.npmjs.org/@next/swc-win32-x64-msvc/-/swc-win32-x64-msvc-14.2.5.tgz", - "integrity": "sha512-tEQ7oinq1/CjSG9uSTerca3v4AZ+dFa+4Yu6ihaG8Ud8ddqLQgFGcnwYls13H5X5CPDPZJdYxyeMui6muOLd4g==", + "version": "14.2.6", + "resolved": "https://registry.npmjs.org/@next/swc-win32-x64-msvc/-/swc-win32-x64-msvc-14.2.6.tgz", + "integrity": "sha512-NANtw+ead1rSDK1jxmzq3TYkl03UNK2KHqUYf1nIhNci6NkeqBD4s1njSzYGIlSHxCK+wSaL8RXZm4v+NF/pMw==", "cpu": [ "x64" ], @@ -6097,9 +6095,9 @@ } }, "node_modules/@next/third-parties": { - "version": "14.2.5", - "resolved": "https://registry.npmjs.org/@next/third-parties/-/third-parties-14.2.5.tgz", - "integrity": "sha512-PDRJm8RZ3rnGNporHKjcdCeZqoW8iJ5uP0clo1Z08TqJiQzuntJ66zrGYCJyqTakx62UJNOp73YsQCFo6kbYYg==", + "version": "14.2.6", + "resolved": "https://registry.npmjs.org/@next/third-parties/-/third-parties-14.2.6.tgz", + "integrity": "sha512-gIayZnFgiir4HlyrqI/KS+MB4y82oVfSYYH4QwHa2KNOtCjX6etF8/cX3pSeSGsQi2VFiI+a9LL+MDMRYgIIoQ==", "dependencies": { "third-party-capital": "1.0.20" }, @@ -6226,12 +6224,12 @@ } }, "node_modules/@react-aria/focus": { - "version": "3.18.1", - "resolved": "https://registry.npmjs.org/@react-aria/focus/-/focus-3.18.1.tgz", - "integrity": "sha512-N0Cy61WCIv+57mbqC7hiZAsB+3rF5n4JKabxUmg/2RTJL6lq7hJ5N4gx75ymKxkN8GnVDwt4pKZah48Wopa5jw==", + "version": "3.18.2", + "resolved": "https://registry.npmjs.org/@react-aria/focus/-/focus-3.18.2.tgz", + "integrity": "sha512-Jc/IY+StjA3uqN73o6txKQ527RFU7gnG5crEl5Xy3V+gbYp2O5L3ezAo/E0Ipi2cyMbG6T5Iit1IDs7hcGu8aw==", "dependencies": { - "@react-aria/interactions": "^3.22.1", - "@react-aria/utils": "^3.25.1", + "@react-aria/interactions": "^3.22.2", + "@react-aria/utils": "^3.25.2", "@react-types/shared": "^3.24.1", "@swc/helpers": "^0.5.0", "clsx": "^2.0.0" @@ -6241,12 +6239,12 @@ } }, "node_modules/@react-aria/interactions": { - "version": "3.22.1", - "resolved": "https://registry.npmjs.org/@react-aria/interactions/-/interactions-3.22.1.tgz", - "integrity": "sha512-5TLzQaDAQQ5C70yG8GInbO4wIylKY67RfTIIwQPGR/4n5OIjbUD8BOj3NuSsuZ/frUPaBXo1VEBBmSO23fxkjw==", + "version": "3.22.2", + "resolved": "https://registry.npmjs.org/@react-aria/interactions/-/interactions-3.22.2.tgz", + "integrity": "sha512-xE/77fRVSlqHp2sfkrMeNLrqf2amF/RyuAS6T5oDJemRSgYM3UoxTbWjucPhfnoW7r32pFPHHgz4lbdX8xqD/g==", "dependencies": { "@react-aria/ssr": "^3.9.5", - "@react-aria/utils": "^3.25.1", + "@react-aria/utils": "^3.25.2", "@react-types/shared": "^3.24.1", "@swc/helpers": "^0.5.0" }, @@ -6269,12 +6267,12 @@ } }, "node_modules/@react-aria/utils": { - "version": "3.25.1", - "resolved": "https://registry.npmjs.org/@react-aria/utils/-/utils-3.25.1.tgz", - "integrity": "sha512-5Uj864e7T5+yj78ZfLnfHqmypLiqW2mN+nsdslog2z5ssunTqjolVeM15ootXskjISlZ7MojLpq97kIC4nlnAw==", + "version": "3.25.2", + "resolved": "https://registry.npmjs.org/@react-aria/utils/-/utils-3.25.2.tgz", + "integrity": "sha512-GdIvG8GBJJZygB4L2QJP1Gabyn2mjFsha73I2wSe+o4DYeGWoJiMZRM06PyTIxLH4S7Sn7eVDtsSBfkc2VY/NA==", "dependencies": { "@react-aria/ssr": "^3.9.5", - "@react-stately/utils": "^3.10.2", + "@react-stately/utils": "^3.10.3", "@react-types/shared": "^3.24.1", "@swc/helpers": "^0.5.0", "clsx": "^2.0.0" @@ -6284,9 +6282,9 @@ } }, "node_modules/@react-stately/utils": { - "version": "3.10.2", - "resolved": "https://registry.npmjs.org/@react-stately/utils/-/utils-3.10.2.tgz", - "integrity": "sha512-fh6OTQtbeQC0ywp6LJuuKs6tKIgFvt/DlIZEcIpGho6/oZG229UnIk6TUekwxnDbumuYyan6D9EgUtEMmT8UIg==", + "version": "3.10.3", + "resolved": "https://registry.npmjs.org/@react-stately/utils/-/utils-3.10.3.tgz", + "integrity": "sha512-moClv7MlVSHpbYtQIkm0Cx+on8Pgt1XqtPx6fy9rQFb2DNc9u1G3AUVnqA17buOkH1vLxAtX4MedlxMWyRCYYA==", "dependencies": { "@swc/helpers": "^0.5.0" }, @@ -6854,21 +6852,12 @@ "version": "8.56.11", "resolved": "https://registry.npmjs.org/@types/eslint/-/eslint-8.56.11.tgz", "integrity": "sha512-sVBpJMf7UPo/wGecYOpk2aQya2VUGeHhe38WG7/mN5FufNSubf5VT9Uh9Uyp8/eLJpu1/tuhJ/qTo4mhSB4V4Q==", + "dev": true, "dependencies": { "@types/estree": "*", "@types/json-schema": "*" } }, - "node_modules/@types/eslint-scope": { - "version": "3.7.7", - "resolved": "https://registry.npmjs.org/@types/eslint-scope/-/eslint-scope-3.7.7.tgz", - "integrity": "sha512-MzMFlSLBqNF2gcHWO0G1vP/YQyfvrxZ0bF+u7mzUdZ1/xK4A4sru+nraZz5i3iEIk1l1uyicaDVTB4QbbEkAYg==", - "peer": true, - "dependencies": { - "@types/eslint": "*", - "@types/estree": "*" - } - }, "node_modules/@types/estree": { "version": "1.0.5", "resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.5.tgz", @@ -6967,9 +6956,9 @@ "integrity": "sha512-nG96G3Wp6acyAgJqGasjODb+acrI7KltPiRxzHPXnP3NgI28bpQDRv53olbqGXbfcgF5aiiHmO3xpwEpS5Ld9g==" }, "node_modules/@types/node": { - "version": "22.4.1", - "resolved": "https://registry.npmjs.org/@types/node/-/node-22.4.1.tgz", - "integrity": "sha512-1tbpb9325+gPnKK0dMm+/LMriX0vKxf6RnB0SZUqfyVkQ4fMgUSySqhxE/y8Jvs4NyF1yHzTfG9KlnkIODxPKg==", + "version": "22.5.0", + "resolved": "https://registry.npmjs.org/@types/node/-/node-22.5.0.tgz", + "integrity": "sha512-DkFrJOe+rfdHTqqMg0bSNlGlQ85hSoh2TPzZyhHsXnMtligRWpxUySiyw8FY14ITt24HVCiQPWxS3KO/QlGmWg==", "dependencies": { "undici-types": "~6.19.2" } @@ -6995,9 +6984,9 @@ "integrity": "sha512-5zvhXYtRNRluoE/jAp4GVsSduVUzNWKkOZrCDBWYtE7biZywwdC2AcEzg+cSMLFRfVgeAFqpfNabiPjxFddV1Q==" }, "node_modules/@types/react": { - "version": "18.3.3", - "resolved": "https://registry.npmjs.org/@types/react/-/react-18.3.3.tgz", - "integrity": "sha512-hti/R0pS0q1/xx+TsI73XIqk26eBsISZ2R0wUijXIngRK9R/e7Xw/cXVxQK7R5JjW+SV4zGcn5hXjudkN/pLIw==", + "version": "18.3.4", + "resolved": "https://registry.npmjs.org/@types/react/-/react-18.3.4.tgz", + "integrity": "sha512-J7W30FTdfCxDDjmfRM+/JqLHBIyl7xUIp9kwK637FGmY7+mkSFSe6L4jpZzhj5QMfLssSDP4/i75AKkrdC7/Jw==", "dependencies": { "@types/prop-types": "*", "csstype": "^3.0.2" @@ -7825,19 +7814,19 @@ } }, "node_modules/algoliasearch": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/algoliasearch/-/algoliasearch-5.0.0.tgz", - "integrity": "sha512-j/RYIyKy7D6Vu/o142+6Gka1lXtu0j/Hj/Mw5oaPpOscOcE4jn29k465pcWYNC34HMxA4W8chiDk9cqw8nszag==", + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/algoliasearch/-/algoliasearch-5.1.1.tgz", + "integrity": "sha512-Bmi456esf2+/nY1w3Xa2etGjQPOBw+RPtfdKRN33mWJ4hNs9cug/F4w9KAb0wiYqDjW1fduXYwu6+YKLHFMMew==", "peer": true, "dependencies": { - "@algolia/client-abtesting": "5.0.0", - "@algolia/client-analytics": "5.0.0", - "@algolia/client-common": "5.0.0", - "@algolia/client-personalization": "5.0.0", - "@algolia/client-search": "5.0.0", - "@algolia/recommend": "5.0.0", - "@algolia/requester-browser-xhr": "5.0.0", - "@algolia/requester-node-http": "5.0.0" + "@algolia/client-abtesting": "5.1.1", + "@algolia/client-analytics": "5.1.1", + "@algolia/client-common": "5.1.1", + "@algolia/client-personalization": "5.1.1", + "@algolia/client-search": "5.1.1", + "@algolia/recommend": "5.1.1", + "@algolia/requester-browser-xhr": "5.1.1", + "@algolia/requester-node-http": "5.1.1" }, "engines": { "node": ">= 14.0.0" @@ -8107,9 +8096,9 @@ } }, "node_modules/async": { - "version": "3.2.5", - "resolved": "https://registry.npmjs.org/async/-/async-3.2.5.tgz", - "integrity": "sha512-baNZyqaaLhyLVKm/DlvdW051MSgO6b8eVfIezl9E5PqWxFgzLm/wQntEW4zOytVburDEr0JlALEpdOFwvErLsg==", + "version": "3.2.6", + "resolved": "https://registry.npmjs.org/async/-/async-3.2.6.tgz", + "integrity": "sha512-htCUDlxyyCLMgaM3xXg0C0LW2xqfuQ6p05pCEIsXuyQ+a1koYKTuBMzRNwmybfLgvJDMd0r1LTn4+E0Ti6C2AA==", "dev": true }, "node_modules/asynckit": { @@ -8177,9 +8166,9 @@ } }, "node_modules/axios": { - "version": "1.7.4", - "resolved": "https://registry.npmjs.org/axios/-/axios-1.7.4.tgz", - "integrity": "sha512-DukmaFRnY6AzAALSH4J2M3k6PkaC+MfaAGdEERRWcC9q3/TWQwLpHR8ZRLKTdQ3aBDL64EdluRDjJqKw+BPZEw==", + "version": "1.7.5", + "resolved": "https://registry.npmjs.org/axios/-/axios-1.7.5.tgz", + "integrity": "sha512-fZu86yCo+svH3uqJ/yTdQ0QHpQu5oL+/QE+QPSv6BZSkDAoky9vytxp7u5qk83OJFS3kEBcesWni9WTZAv3tSw==", "dependencies": { "follow-redirects": "^1.15.6", "form-data": "^4.0.0", @@ -9607,9 +9596,9 @@ } }, "node_modules/electron-to-chromium": { - "version": "1.5.11", - "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.11.tgz", - "integrity": "sha512-R1CccCDYqndR25CaXFd6hp/u9RaaMcftMkphmvuepXr5b1vfLkRml6aWVeBhXJ7rbevHkKEMJtz8XqPf7ffmew==" + "version": "1.5.13", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.13.tgz", + "integrity": "sha512-lbBcvtIJ4J6sS4tb5TLp1b4LyfCdMkwStzXPyAgVgTRAsep4bvrAGaBOP7ZJtQMNJpSQ9SqG4brWOroNaQtm7Q==" }, "node_modules/elliptic": { "version": "6.5.4", @@ -10000,11 +9989,11 @@ } }, "node_modules/eslint-config-next": { - "version": "14.2.5", - "resolved": "https://registry.npmjs.org/eslint-config-next/-/eslint-config-next-14.2.5.tgz", - "integrity": "sha512-zogs9zlOiZ7ka+wgUnmcM0KBEDjo4Jis7kxN1jvC0N4wynQ2MIx/KBkg4mVF63J5EK4W0QMCn7xO3vNisjaAoA==", + "version": "14.2.6", + "resolved": "https://registry.npmjs.org/eslint-config-next/-/eslint-config-next-14.2.6.tgz", + "integrity": "sha512-z0URA5LO6y8lS/YLN0EDW/C4LEkDODjJzA37dvLVdzCPzuewjzTe1os5g3XclZAZrQ8X8hPaSMQ2JuVWwMmrTA==", "dependencies": { - "@next/eslint-plugin-next": "14.2.5", + "@next/eslint-plugin-next": "14.2.6", "@rushstack/eslint-patch": "^1.3.3", "@typescript-eslint/parser": "^5.4.2 || ^6.0.0 || 7.0.0 - 7.2.0", "eslint-import-resolver-node": "^0.3.6", @@ -12247,9 +12236,9 @@ } }, "node_modules/is-core-module": { - "version": "2.15.0", - "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.15.0.tgz", - "integrity": "sha512-Dd+Lb2/zvk9SKy1TGCt1wFJFo/MWBPMX5x7KcvLajWTGuomczdQX61PvY5yK6SVACwpoexWo81IfFyoKY2QnTA==", + "version": "2.15.1", + "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.15.1.tgz", + "integrity": "sha512-z0vtXSwucUJtANQWldhbtbt7BnL0vxiFjIdDLAatwhDYty2bad6s+rijD6Ri4YuYJubLzIJLUidCh09e1djEVQ==", "dependencies": { "hasown": "^2.0.2" }, @@ -14492,9 +14481,9 @@ ] }, "node_modules/micromatch": { - "version": "4.0.7", - "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.7.tgz", - "integrity": "sha512-LPP/3KorzCwBxfeUuZmaR6bG2kdeHSbe0P2tY3FLRU4vYrjYz5hI4QZwV0njUx3jeuKe67YukQ1LSPZBKDqO/Q==", + "version": "4.0.8", + "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.8.tgz", + "integrity": "sha512-PXwfBhYu0hBCPw8Dn0E+WDYb7af3dSLVWKi3HGv84IdF4TyFoC0ysxFd0Goxw7nSv4T/PzEJQxsYsEiFCKo2BA==", "dependencies": { "braces": "^3.0.3", "picomatch": "^2.3.1" @@ -14653,11 +14642,11 @@ "peer": true }, "node_modules/next": { - "version": "14.2.5", - "resolved": "https://registry.npmjs.org/next/-/next-14.2.5.tgz", - "integrity": "sha512-0f8aRfBVL+mpzfBjYfQuLWh2WyAwtJXCRfkPF4UJ5qd2YwrHczsrSzXU4tRMV0OAxR8ZJZWPFn6uhSC56UTsLA==", + "version": "14.2.6", + "resolved": "https://registry.npmjs.org/next/-/next-14.2.6.tgz", + "integrity": "sha512-57Su7RqXs5CBKKKOagt8gPhMM3CpjgbeQhrtei2KLAA1vTNm7jfKS+uDARkSW8ZETUflDCBIsUKGSyQdRs4U4g==", "dependencies": { - "@next/env": "14.2.5", + "@next/env": "14.2.6", "@swc/helpers": "0.5.5", "busboy": "1.6.0", "caniuse-lite": "^1.0.30001579", @@ -14672,15 +14661,15 @@ "node": ">=18.17.0" }, "optionalDependencies": { - "@next/swc-darwin-arm64": "14.2.5", - "@next/swc-darwin-x64": "14.2.5", - "@next/swc-linux-arm64-gnu": "14.2.5", - "@next/swc-linux-arm64-musl": "14.2.5", - "@next/swc-linux-x64-gnu": "14.2.5", - "@next/swc-linux-x64-musl": "14.2.5", - "@next/swc-win32-arm64-msvc": "14.2.5", - "@next/swc-win32-ia32-msvc": "14.2.5", - "@next/swc-win32-x64-msvc": "14.2.5" + "@next/swc-darwin-arm64": "14.2.6", + "@next/swc-darwin-x64": "14.2.6", + "@next/swc-linux-arm64-gnu": "14.2.6", + "@next/swc-linux-arm64-musl": "14.2.6", + "@next/swc-linux-x64-gnu": "14.2.6", + "@next/swc-linux-x64-musl": "14.2.6", + "@next/swc-win32-arm64-msvc": "14.2.6", + "@next/swc-win32-ia32-msvc": "14.2.6", + "@next/swc-win32-x64-msvc": "14.2.6" }, "peerDependencies": { "@opentelemetry/api": "^1.1.0", @@ -17830,12 +17819,12 @@ } }, "node_modules/prettier-plugin-packagejson": { - "version": "2.5.1", - "resolved": "https://registry.npmjs.org/prettier-plugin-packagejson/-/prettier-plugin-packagejson-2.5.1.tgz", - "integrity": "sha512-6i4PW1KxEA+VrokYNGeI/q8qQX3u5DNBc7eLr9GX4OrvWr9DMls1lhbuNopkKG7Li9rTNxerWnYQyjxoUO4ROA==", + "version": "2.5.2", + "resolved": "https://registry.npmjs.org/prettier-plugin-packagejson/-/prettier-plugin-packagejson-2.5.2.tgz", + "integrity": "sha512-w+TmoLv2pIa+siplW1cCj2ujEXQQS6z7wmWLOiLQK/2QVl7Wy6xh/ZUpqQw8tbKMXDodmSW4GONxlA33xpdNOg==", "dev": true, "dependencies": { - "sort-package-json": "2.10.0", + "sort-package-json": "2.10.1", "synckit": "0.9.1" }, "peerDependencies": { @@ -18718,9 +18707,9 @@ } }, "node_modules/search-insights": { - "version": "2.16.3", - "resolved": "https://registry.npmjs.org/search-insights/-/search-insights-2.16.3.tgz", - "integrity": "sha512-hSHy/s4Zk2xibhj9XTCACB+1PqS+CaJxepGNBhKc/OsHRpqvHAUAm5+uZ6kJJbGXn0pb3XqekHjg6JAqPExzqg==", + "version": "2.17.0", + "resolved": "https://registry.npmjs.org/search-insights/-/search-insights-2.17.0.tgz", + "integrity": "sha512-AskayU3QNsXQzSL6v4LTYST7NNfs2HWyHHB+sdORP9chsytAhro5XRfToAMI/LAVYgNbzowVZTMfBRodgbUHKg==", "peer": true }, "node_modules/semver": { @@ -18882,9 +18871,9 @@ "dev": true }, "node_modules/sort-package-json": { - "version": "2.10.0", - "resolved": "https://registry.npmjs.org/sort-package-json/-/sort-package-json-2.10.0.tgz", - "integrity": "sha512-MYecfvObMwJjjJskhxYfuOADkXp1ZMMnCFC8yhp+9HDsk7HhR336hd7eiBs96lTXfiqmUNI+WQCeCMRBhl251g==", + "version": "2.10.1", + "resolved": "https://registry.npmjs.org/sort-package-json/-/sort-package-json-2.10.1.tgz", + "integrity": "sha512-d76wfhgUuGypKqY72Unm5LFnMpACbdxXsLPcL27pOsSrmVqH3PztFp1uq+Z22suk15h7vXmTesuh2aEjdCqb5w==", "dev": true, "dependencies": { "detect-indent": "^7.0.1", @@ -19023,9 +19012,9 @@ } }, "node_modules/spdx-license-ids": { - "version": "3.0.18", - "resolved": "https://registry.npmjs.org/spdx-license-ids/-/spdx-license-ids-3.0.18.tgz", - "integrity": "sha512-xxRs31BqRYHwiMzudOrpSiHtZ8i/GeionCBDSilhYRj+9gIcI8wCZTlXZKu9vZIVqViP3dcp9qE5G6AlIaD+TQ==" + "version": "3.0.20", + "resolved": "https://registry.npmjs.org/spdx-license-ids/-/spdx-license-ids-3.0.20.tgz", + "integrity": "sha512-jg25NiDV/1fLtSgEgyvVyDunvaNHbuwF9lfNV17gSmPFAlYzdfNBlLtLzXTevwkPj7DhGbmN9VnmJIgLnhvaBw==" }, "node_modules/split-ca": { "version": "1.0.1", @@ -19806,20 +19795,20 @@ "integrity": "sha512-Y/arvbn+rrz3JCKl9C4kVNfTfSm2/mEp5FSz5EsZSANGPSlQrpRI5M4PKF+mJnE52jOO90PnPSc3Ur3bTQw0gA==" }, "node_modules/ts-jest": { - "version": "29.2.4", - "resolved": "https://registry.npmjs.org/ts-jest/-/ts-jest-29.2.4.tgz", - "integrity": "sha512-3d6tgDyhCI29HlpwIq87sNuI+3Q6GLTTCeYRHCs7vDz+/3GCMwEtV9jezLyl4ZtnBgx00I7hm8PCP8cTksMGrw==", + "version": "29.2.5", + "resolved": "https://registry.npmjs.org/ts-jest/-/ts-jest-29.2.5.tgz", + "integrity": "sha512-KD8zB2aAZrcKIdGk4OwpJggeLcH1FgrICqDSROWqlnJXGCXK4Mn6FcdK2B6670Xr73lHMG1kHw8R87A0ecZ+vA==", "dev": true, "dependencies": { - "bs-logger": "0.x", + "bs-logger": "^0.2.6", "ejs": "^3.1.10", - "fast-json-stable-stringify": "2.x", + "fast-json-stable-stringify": "^2.1.0", "jest-util": "^29.0.0", "json5": "^2.2.3", - "lodash.memoize": "4.x", - "make-error": "1.x", - "semver": "^7.5.3", - "yargs-parser": "^21.0.1" + "lodash.memoize": "^4.1.2", + "make-error": "^1.3.6", + "semver": "^7.6.3", + "yargs-parser": "^21.1.1" }, "bin": { "ts-jest": "cli.js" @@ -19950,9 +19939,9 @@ } }, "node_modules/tslib": { - "version": "2.6.3", - "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.6.3.tgz", - "integrity": "sha512-xNvxJEOUiWPGhUuUdQgAJPKOOJfGnIyKySOc09XkKsgdUV/3E2zvwZYdejjmRgPCgcym1juLH3226yA7sEFJKQ==" + "version": "2.7.0", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.7.0.tgz", + "integrity": "sha512-gLXCKdN1/j47AiHiOkJN69hJmcbGTHI0ImLmbYLHykhgeN0jVGola9yVjFgzCUklsZQMW55o+dW7IXv3RCXDzA==" }, "node_modules/tsup": { "version": "8.2.4", @@ -20405,9 +20394,9 @@ } }, "node_modules/undici-types": { - "version": "6.19.6", - "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.19.6.tgz", - "integrity": "sha512-e/vggGopEfTKSvj4ihnOLTsqhrKRN3LeO6qSN/GxohhuRv8qH9bNQ4B8W7e/vFL+0XTnmHPB4/kegunZGA4Org==" + "version": "6.19.8", + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.19.8.tgz", + "integrity": "sha512-ve2KP6f/JnbPBFyobGHuerC9g1FYGn/F8n1LWTwNxCEzd6IfqTwUQcNXgEtmmQ6DlRrC1hrSrBnCZPokRrDHjw==" }, "node_modules/unified": { "version": "11.0.5", @@ -20699,12 +20688,11 @@ "integrity": "sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ==" }, "node_modules/webpack": { - "version": "5.93.0", - "resolved": "https://registry.npmjs.org/webpack/-/webpack-5.93.0.tgz", - "integrity": "sha512-Y0m5oEY1LRuwly578VqluorkXbvXKh7U3rLoQCEO04M97ScRr44afGVkI0FQFsXzysk5OgFAxjZAb9rsGQVihA==", + "version": "5.94.0", + "resolved": "https://registry.npmjs.org/webpack/-/webpack-5.94.0.tgz", + "integrity": "sha512-KcsGn50VT+06JH/iunZJedYGUJS5FGjow8wb9c0v5n1Om8O1g4L6LjtfxwlXIATopoQu+vOXXa7gYisWxCoPyg==", "peer": true, "dependencies": { - "@types/eslint-scope": "^3.7.3", "@types/estree": "^1.0.5", "@webassemblyjs/ast": "^1.12.1", "@webassemblyjs/wasm-edit": "^1.12.1", @@ -20713,7 +20701,7 @@ "acorn-import-attributes": "^1.9.5", "browserslist": "^4.21.10", "chrome-trace-event": "^1.0.2", - "enhanced-resolve": "^5.17.0", + "enhanced-resolve": "^5.17.1", "es-module-lexer": "^1.2.1", "eslint-scope": "5.1.1", "events": "^3.2.0", @@ -21160,7 +21148,7 @@ }, "packages/mesh-common": { "name": "@meshsdk/common", - "version": "1.6.9", + "version": "1.6.10", "license": "Apache-2.0", "dependencies": { "bech32": "^2.0.0", @@ -21177,7 +21165,7 @@ }, "packages/mesh-contract": { "name": "@meshsdk/contract", - "version": "1.6.9", + "version": "1.6.10", "license": "Apache-2.0", "dependencies": { "@meshsdk/common": "*", @@ -21195,7 +21183,7 @@ }, "packages/mesh-core": { "name": "@meshsdk/core", - "version": "1.6.9", + "version": "1.6.10", "license": "Apache-2.0", "dependencies": { "@meshsdk/common": "*", @@ -21215,7 +21203,7 @@ }, "packages/mesh-core-csl": { "name": "@meshsdk/core-csl", - "version": "1.6.9", + "version": "1.6.10", "license": "Apache-2.0", "dependencies": { "@meshsdk/common": "*", @@ -21234,15 +21222,15 @@ }, "packages/mesh-core-cst": { "name": "@meshsdk/core-cst", - "version": "1.6.9", + "version": "1.6.10", "license": "Apache-2.0", "dependencies": { "@cardano-sdk/core": "^0.35.4", "@cardano-sdk/crypto": "^0.1.28", "@cardano-sdk/util": "^0.15.4", - "@harmoniclabs/cbor": "^1.3.0", - "@harmoniclabs/plutus-data": "^1.2.4", - "@harmoniclabs/uplc": "^1.2.4", + "@harmoniclabs/cbor": "1.3.0", + "@harmoniclabs/plutus-data": "1.2.4", + "@harmoniclabs/uplc": "1.2.4", "@meshsdk/common": "*", "@stricahq/bip32ed25519": "^1.1.0", "@stricahq/cbors": "^1.0.0", @@ -21260,7 +21248,7 @@ }, "packages/mesh-provider": { "name": "@meshsdk/provider", - "version": "1.6.9", + "version": "1.6.10", "license": "Apache-2.0", "dependencies": { "@meshsdk/common": "*", @@ -21276,7 +21264,7 @@ }, "packages/mesh-react": { "name": "@meshsdk/react", - "version": "1.6.9", + "version": "1.6.10", "license": "Apache-2.0", "dependencies": { "@meshsdk/common": "*", @@ -21296,7 +21284,7 @@ }, "packages/mesh-transaction": { "name": "@meshsdk/transaction", - "version": "1.6.9", + "version": "1.6.10", "license": "Apache-2.0", "dependencies": { "@meshsdk/common": "*", @@ -21314,7 +21302,7 @@ }, "packages/mesh-wallet": { "name": "@meshsdk/wallet", - "version": "1.6.9", + "version": "1.6.10", "license": "Apache-2.0", "dependencies": { "@meshsdk/common": "*", diff --git a/packages/mesh-common/package.json b/packages/mesh-common/package.json index 37cf7f85..3d2e1f2b 100644 --- a/packages/mesh-common/package.json +++ b/packages/mesh-common/package.json @@ -1,6 +1,6 @@ { "name": "@meshsdk/common", - "version": "1.6.9", + "version": "1.6.10", "description": "", "main": "./dist/index.cjs", "module": "./dist/index.js", diff --git a/packages/mesh-common/src/interfaces/serializer.ts b/packages/mesh-common/src/interfaces/serializer.ts index e6bf5c04..0864bd0d 100644 --- a/packages/mesh-common/src/interfaces/serializer.ts +++ b/packages/mesh-common/src/interfaces/serializer.ts @@ -10,6 +10,7 @@ import { } from "../types"; export interface IMeshTxSerializer { + verbose: boolean; serializeTxBody( txBuilderBody: MeshTxBuilderBody, protocolParams: Protocol, diff --git a/packages/mesh-common/test/data/time.test.ts b/packages/mesh-common/test/data/time.test.ts index ad6ea3e4..8c89a7a8 100644 --- a/packages/mesh-common/test/data/time.test.ts +++ b/packages/mesh-common/test/data/time.test.ts @@ -94,70 +94,76 @@ describe("Time", () => { }); describe("time tests using blockfrost", () => { - it("test preprod", async () => { - if (!process.env.BLOCKFROST_API_KEY_PREPROD) { - console.error("could not find blockfrost preprod api key in env"); - process.exit(1); - } - const preprodBlockfrost = new BlockfrostProvider( - process.env.BLOCKFROST_API_KEY_PREPROD!, - ); + if (process.env.BLOCKFROST_API_KEY_PREPROD) { + it("test preprod", async () => { + if (!process.env.BLOCKFROST_API_KEY_PREPROD) { + console.error("could not find blockfrost preprod api key in env"); + process.exit(1); + } + const preprodBlockfrost = new BlockfrostProvider( + process.env.BLOCKFROST_API_KEY_PREPROD!, + ); - const latestBlockInfo = await preprodBlockfrost.fetchLatestBlock(); - const calculatedSlot = Number(resolveSlotNo("preprod")); + const latestBlockInfo = await preprodBlockfrost.fetchLatestBlock(); + const calculatedSlot = Number(resolveSlotNo("preprod")); - const calculatedEpoch = Number(resolveEpochNo("preprod")); + const calculatedEpoch = Number(resolveEpochNo("preprod")); - // Allow calculated slot to be within 100 seconds of latest block - expect(calculatedSlot).toBeGreaterThan( - Number(latestBlockInfo.slot) - 100, - ); - expect(calculatedSlot).toBeLessThan(Number(latestBlockInfo.slot) + 100); - expect(calculatedEpoch).toBe(Number(latestBlockInfo.epoch)); - }); + // Allow calculated slot to be within 100 seconds of latest block + expect(calculatedSlot).toBeGreaterThan( + Number(latestBlockInfo.slot) - 100, + ); + expect(calculatedSlot).toBeLessThan(Number(latestBlockInfo.slot) + 100); + expect(calculatedEpoch).toBe(Number(latestBlockInfo.epoch)); + }); + } - it("test mainnet", async () => { - if (!process.env.BLOCKFROST_API_KEY_MAINNET) { - console.error("could not find blockfrost mainnet api key in env"); - process.exit(1); - } - const mainnetBlockfrost = new BlockfrostProvider( - process.env.BLOCKFROST_API_KEY_MAINNET!, - ); + if (process.env.BLOCKFROST_API_KEY_MAINNET) { + it("test mainnet", async () => { + if (!process.env.BLOCKFROST_API_KEY_MAINNET) { + console.error("could not find blockfrost mainnet api key in env"); + process.exit(1); + } + const mainnetBlockfrost = new BlockfrostProvider( + process.env.BLOCKFROST_API_KEY_MAINNET!, + ); - const latestBlockInfo = await mainnetBlockfrost.fetchLatestBlock(); - const calculatedSlot = Number(resolveSlotNo("mainnet")); + const latestBlockInfo = await mainnetBlockfrost.fetchLatestBlock(); + const calculatedSlot = Number(resolveSlotNo("mainnet")); - const calculatedEpoch = Number(resolveEpochNo("mainnet")); + const calculatedEpoch = Number(resolveEpochNo("mainnet")); - // Allow calculated slot to be within 100 seconds of latest block - expect(calculatedSlot).toBeGreaterThan( - Number(latestBlockInfo.slot) - 100, - ); - expect(calculatedSlot).toBeLessThan(Number(latestBlockInfo.slot) + 100); - expect(calculatedEpoch).toBe(Number(latestBlockInfo.epoch)); - }); + // Allow calculated slot to be within 100 seconds of latest block + expect(calculatedSlot).toBeGreaterThan( + Number(latestBlockInfo.slot) - 100, + ); + expect(calculatedSlot).toBeLessThan(Number(latestBlockInfo.slot) + 100); + expect(calculatedEpoch).toBe(Number(latestBlockInfo.epoch)); + }); + } - it("test preview", async () => { - if (!process.env.BLOCKFROST_API_KEY_PREVIEW) { - console.error("could not find blockfrost preview api key in env"); - process.exit(1); - } - const previewBlockfrost = new BlockfrostProvider( - process.env.BLOCKFROST_API_KEY_PREVIEW!, - ); + if (process.env.BLOCKFROST_API_KEY_PREVIEW) { + it("test preview", async () => { + if (!process.env.BLOCKFROST_API_KEY_PREVIEW) { + console.error("could not find blockfrost preview api key in env"); + process.exit(1); + } + const previewBlockfrost = new BlockfrostProvider( + process.env.BLOCKFROST_API_KEY_PREVIEW!, + ); - const latestBlockInfo = await previewBlockfrost.fetchLatestBlock(); - const calculatedSlot = Number(resolveSlotNo("preview")); + const latestBlockInfo = await previewBlockfrost.fetchLatestBlock(); + const calculatedSlot = Number(resolveSlotNo("preview")); - const calculatedEpoch = Number(resolveEpochNo("preview")); + const calculatedEpoch = Number(resolveEpochNo("preview")); - // Allow calculated slot to be within 100 seconds of latest block - expect(calculatedSlot).toBeGreaterThan( - Number(latestBlockInfo.slot) - 100, - ); - expect(calculatedSlot).toBeLessThan(Number(latestBlockInfo.slot) + 100); - expect(calculatedEpoch).toBe(Number(latestBlockInfo.epoch)); - }); + // Allow calculated slot to be within 100 seconds of latest block + expect(calculatedSlot).toBeGreaterThan( + Number(latestBlockInfo.slot) - 100, + ); + expect(calculatedSlot).toBeLessThan(Number(latestBlockInfo.slot) + 100); + expect(calculatedEpoch).toBe(Number(latestBlockInfo.epoch)); + }); + } }); }); diff --git a/packages/mesh-contract/package.json b/packages/mesh-contract/package.json index 86b476b7..8e2010fe 100644 --- a/packages/mesh-contract/package.json +++ b/packages/mesh-contract/package.json @@ -1,6 +1,6 @@ { "name": "@meshsdk/contract", - "version": "1.6.9", + "version": "1.6.10", "description": "", "main": "./dist/index.cjs", "module": "./dist/index.js", diff --git a/packages/mesh-core-csl/package.json b/packages/mesh-core-csl/package.json index 04d0183b..5f4110fd 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.6.9", + "version": "1.6.10", "description": "", "main": "./dist/index.cjs", "module": "./dist/index.js", diff --git a/packages/mesh-core-csl/src/core/serializer.ts b/packages/mesh-core-csl/src/core/serializer.ts index 5365db0d..1b7edfd3 100644 --- a/packages/mesh-core-csl/src/core/serializer.ts +++ b/packages/mesh-core-csl/src/core/serializer.ts @@ -71,7 +71,7 @@ export class CSLSerializer implements IMeshTxSerializer { } const txBuildResult = csl.js_serialize_tx_body(txBodyJson, params); if (txBuildResult.get_status() !== "success") { - throw new Error(txBuildResult.get_data()); + throw new Error(`txBuildResult error: ${txBuildResult.get_data()}`); } return txBuildResult.get_data(); } diff --git a/packages/mesh-core-cst/package.json b/packages/mesh-core-cst/package.json index ab4e49e1..dac9c5c3 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.6.9", + "version": "1.6.10", "description": "", "main": "./dist/index.cjs", "module": "./dist/index.js", @@ -38,9 +38,9 @@ "@cardano-sdk/core": "^0.35.4", "@cardano-sdk/crypto": "^0.1.28", "@cardano-sdk/util": "^0.15.4", - "@harmoniclabs/cbor": "^1.3.0", - "@harmoniclabs/plutus-data": "^1.2.4", - "@harmoniclabs/uplc": "^1.2.4", + "@harmoniclabs/cbor": "1.3.0", + "@harmoniclabs/plutus-data": "1.2.4", + "@harmoniclabs/uplc": "1.2.4", "@meshsdk/common": "*", "@stricahq/bip32ed25519": "^1.1.0", "@stricahq/cbors": "^1.0.0", diff --git a/packages/mesh-core-cst/src/serializer/index.ts b/packages/mesh-core-cst/src/serializer/index.ts index 530c8fa0..33ef9d1c 100644 --- a/packages/mesh-core-cst/src/serializer/index.ts +++ b/packages/mesh-core-cst/src/serializer/index.ts @@ -66,6 +66,7 @@ import { hashScriptData } from "../utils/script-data-hash"; import { empty, mergeValue, negatives, subValue } from "../utils/value"; export class CardanoSDKSerializer implements IMeshTxSerializer { + verbose: boolean; private txBody: TransactionBody; private txWitnessSet: TransactionWitnessSet; @@ -87,7 +88,8 @@ export class CardanoSDKSerializer implements IMeshTxSerializer { [2]: false, }; - constructor() { + constructor(verbose = false) { + this.verbose = verbose; this.txBody = new TransactionBody( Serialization.CborSet.fromCore([], TransactionInput.fromCore), [], diff --git a/packages/mesh-core-cst/src/stricahq/bip32ed25519/README.md b/packages/mesh-core-cst/src/stricahq/bip32ed25519/README.md new file mode 100644 index 00000000..46fbb727 --- /dev/null +++ b/packages/mesh-core-cst/src/stricahq/bip32ed25519/README.md @@ -0,0 +1,16 @@ +> This package is by [Strica](https://github.com/StricaHQ/bip32ed25519) + +

+ + + +

+ +# Bip32Ed25519 + +Pure javascript implementation of [Bip32Ed25519](https://ieeexplore.ieee.org/document/7966967), used for Cardano blockchain key pair. + +- Create extended keys with Bip39 mnemonic entropy +- Soft and hard derivation +- Derive keys with user friendly API +- Sign and verify data diff --git a/packages/mesh-core-cst/src/stricahq/bip32ed25519/bip32-private-key.ts b/packages/mesh-core-cst/src/stricahq/bip32ed25519/bip32-private-key.ts new file mode 100644 index 00000000..b6cccb88 --- /dev/null +++ b/packages/mesh-core-cst/src/stricahq/bip32ed25519/bip32-private-key.ts @@ -0,0 +1,129 @@ +/* eslint-disable no-bitwise */ + +import { Buffer } from "buffer"; +import BN from "bn.js"; +import { pbkdf2 } from "pbkdf2"; + +import { Bip32PublicKey } from "./bip32-public-key"; +import { EDDSA } from "./ed25519e/eddsa"; +import { PrivateKey } from "./private-key"; +import { HARDENED_OFFSET, hmac512 } from "./utils"; + +const eddsa = new EDDSA(); + +class Bip32PrivateKey { + protected xprv: Buffer; + + constructor(xprv: Buffer) { + this.xprv = xprv; + } + + static fromEntropy(entropy: Buffer): Promise { + return new Promise((resolve, reject) => { + pbkdf2("", entropy, 4096, 96, "sha512", (err, xprv) => { + if (err) { + reject(err); + } + // The lowest three bits of the first octet are cleared + // 248 or 0xf8 or 0b11111000 + xprv[0]! &= 0b11111000; + // the highest bit of the last octet is cleared + // 31 or 0x1f or 0b00011111 + // AND the third highest bit is cleared too + xprv[31]! &= 0b00011111; + // and the second highest bit of the last octet is set + // 64 or 0x40 or 0b01000000 + xprv[31]! |= 0b01000000; + resolve(new Bip32PrivateKey(xprv)); + }); + }); + } + + derive(index: number) { + const kl = this.xprv.subarray(0, 32); + const kr = this.xprv.subarray(32, 64); + const cc = this.xprv.subarray(64, 96); + + let z; + let i; + if (index < HARDENED_OFFSET) { + const data = Buffer.allocUnsafe(1 + 32 + 4); + data.writeUInt32LE(index, 1 + 32); + + const keyPair = eddsa.keyFromSecret(kl.toString("hex")); + const vk = Buffer.from(keyPair.pubBytes()); + vk.copy(data, 1); + + data[0] = 0x02; + z = hmac512(cc, data); + data[0] = 0x03; + i = hmac512(cc, data); + } else { + const data = Buffer.allocUnsafe(1 + 64 + 4); + data.writeUInt32LE(index, 1 + 64); + kl.copy(data, 1); + kr.copy(data, 1 + 32); + + data[0] = 0x00; + z = hmac512(cc, data); + data[0] = 0x01; + i = hmac512(cc, data); + } + + const chainCode = i.slice(32, 64); + const zl = z.slice(0, 32); + const zr = z.slice(32, 64); + + const left = new BN(kl, 16, "le") + .add(new BN(zl.slice(0, 28), 16, "le").mul(new BN(8))) + .toArrayLike(Buffer, "le", 32); + let right = new BN(kr, 16, "le") + .add(new BN(zr, 16, "le")) + .toArrayLike(Buffer, "le") + .slice(0, 32); + + if (right.length !== 32) { + right = Buffer.from(right.toString("hex").padEnd(32, "0"), "hex"); + } + + const xprv = Buffer.concat([left, right, chainCode]); + return new Bip32PrivateKey(xprv); + } + + deriveHardened(index: number) { + return this.derive(index + HARDENED_OFFSET); + } + + derivePath(path: string) { + const splitPath = path.split("/"); + // @ts-ignore + return splitPath.reduce((hdkey, indexStr, i) => { + if (i === 0 && indexStr === "m") { + return hdkey; + } + if (indexStr.slice(-1) === `'`) { + const index = parseInt(indexStr.slice(0, -1), 10); + return hdkey.deriveHardened(index); + } + const index = parseInt(indexStr, 10); + return hdkey.derive(index); + }, this); + } + + toBip32PublicKey() { + const keyPair = eddsa.keyFromSecret(this.xprv.slice(0, 32).toString("hex")); + const vk = Buffer.from(keyPair.pubBytes()); + return new Bip32PublicKey(Buffer.concat([vk, this.xprv.slice(64, 96)])); + } + + toBytes(): Buffer { + return this.xprv; + } + + toPrivateKey(): PrivateKey { + const keyPair = eddsa.keyFromSecret(this.xprv.slice(0, 64)); + return new PrivateKey(Buffer.from(keyPair.privBytes())); + } +} + +export { Bip32PrivateKey }; diff --git a/packages/mesh-core-cst/src/stricahq/bip32ed25519/ed25519e/eddsa.js b/packages/mesh-core-cst/src/stricahq/bip32ed25519/ed25519e/eddsa.js new file mode 100644 index 00000000..502ed0cd --- /dev/null +++ b/packages/mesh-core-cst/src/stricahq/bip32ed25519/ed25519e/eddsa.js @@ -0,0 +1,140 @@ +/** + * Copyright 2021 Ashish Prajapati + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * *** Includes code to override elliptic.js implementation for ed25519 *** + * + * LICENSE + * + * This software is licensed under the MIT License. + * + * Copyright Fedor Indutny, 2014. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software + * and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, + * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR + * PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR + * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + */ + +import { curves, utils } from "elliptic"; +import { sha512 } from "hash.js"; + +import { Signature } from "./signature"; +import { KeyPair } from "./key"; + +const parseBytes = utils.parseBytes; + +class EDDSA { + constructor() { + if (!(this instanceof EDDSA)) return new EDDSA(); + + const curve = curves.ed25519.curve; + this.curve = curve; + this.g = curve.g; + this.g.precompute(curve.n.bitLength() + 1); + + this.pointClass = curve.point().constructor; + this.encodingLength = Math.ceil(curve.n.bitLength() / 8); + this.hash = sha512; + } + /** + * @param {Array|String} message - message bytes + * @param {Array|String|KeyPair} secret - secret bytes or a keypair + * @returns {Signature} - signature + */ + signExtended(message, secret) { + message = parseBytes(message); + const key = this.keyFromSecret(secret); + const r = this.hashInt(key.messagePrefix(), message); + const R = this.g.mul(r); + const Rencoded = this.encodePoint(R); + const s_ = this.hashInt(Rencoded, key.pubBytes(), message).mul(key.kl()); + const S = r.add(s_).umod(this.curve.n); + return this.makeSignature({ R, S, Rencoded }); + } + /** + * @param {Array} message - message bytes + * @param {Array|String|Signature} sig - sig bytes + * @param {Array|String|Point|KeyPair} pub - public key + * @returns {Boolean} - true if public key matches sig of message + */ + verify(message, sig, pub) { + message = parseBytes(message); + sig = this.makeSignature(sig); + const key = this.keyFromPublic(pub); + const h = this.hashInt(sig.Rencoded(), key.pubBytes(), message); + const SG = this.g.mul(sig.S()); + const RplusAh = sig.R().add(key.pub().mul(h)); + return RplusAh.eq(SG); + } + hashInt() { + const hash = this.hash(); + for (let i = 0; i < arguments.length; i++) hash.update(arguments[i]); + return utils.intFromLE(hash.digest()).umod(this.curve.n); + } + keyFromPublic(pub) { + return KeyPair.fromPublic(this, utils.parseBytes(pub)); + } + keyFromSecret(secret) { + return KeyPair.fromSecret(this, utils.parseBytes(secret)); + } + makeSignature(sig) { + if (sig instanceof Signature) return sig; + return new Signature(this, sig); + } + /** + * * https://tools.ietf.org/html/draft-josefsson-eddsa-ed25519-03#section-5.2 + * + * EDDSA defines methods for encoding and decoding points and integers. These are + * helper convenience methods, that pass along to utility functions implied + * parameters. + * + */ + encodePoint(point) { + const enc = point.getY().toArray("le", this.encodingLength); + enc[this.encodingLength - 1] |= point.getX().isOdd() ? 0x80 : 0; + return enc; + } + decodePoint(bytes) { + bytes = utils.parseBytes(bytes); + + const lastIx = bytes.length - 1; + const normed = bytes.slice(0, lastIx).concat(bytes[lastIx] & ~0x80); + const xIsOdd = (bytes[lastIx] & 0x80) !== 0; + + const y = utils.intFromLE(normed); + return this.curve.pointFromY(y, xIsOdd); + } + encodeInt(num) { + return num.toArray("le", this.encodingLength); + } + decodeInt(bytes) { + return utils.intFromLE(bytes); + } + isPoint(val) { + return val instanceof this.pointClass; + } +} + +export { EDDSA }; diff --git a/packages/mesh-core-cst/src/stricahq/bip32ed25519/ed25519e/key.js b/packages/mesh-core-cst/src/stricahq/bip32ed25519/ed25519e/key.js new file mode 100644 index 00000000..2b923dea --- /dev/null +++ b/packages/mesh-core-cst/src/stricahq/bip32ed25519/ed25519e/key.js @@ -0,0 +1,100 @@ +/** + * Copyright 2021 Ashish Prajapati + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * *** Includes code to override elliptic.js implementation for ed25519 *** + * + * LICENSE + * + * This software is licensed under the MIT License. + * + * Copyright Fedor Indutny, 2014. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software + * and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, + * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR + * PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR + * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + */ + +import { utils } from "elliptic"; + +const assert = utils.assert; +const parseBytes = utils.parseBytes; +const cachedProperty = utils.cachedProperty; +class KeyPair { + constructor(eddsa, params) { + this.eddsa = eddsa; + this._secret = parseBytes(params.secret); + if (eddsa.isPoint(params.pub)) { + this._pub = params.pub; + } else { + this._pubBytes = parseBytes(params.pub); + } + } + static fromPublic(eddsa, pub) { + if (pub instanceof KeyPair) { + return pub; + } + return new KeyPair(eddsa, { pub }); + } + static fromSecret(eddsa, secret) { + if (secret instanceof KeyPair) { + return secret; + } + return new KeyPair(eddsa, { secret }); + } + secret() { + return this._secret.slice(0, 32); + } + sign(message) { + assert(this._secret, "KeyPair can only verify"); + return this.eddsa.signExtended(message, this); + } + verify(message, sig) { + return this.eddsa.verify(message, sig, this); + } + pub() { + if (this._pubBytes) { + return this.eddsa.decodePoint(this._pubBytes); + } + return this.eddsa.g.mul(this.kl()); + } + pubBytes() { + return this.eddsa.encodePoint(this.pub()); + } + privBytes() { + return this._secret; + } + priv() { + return this.eddsa.decodeInt(this.privBytes()); + } + kl() { + return this.eddsa.decodeInt(this.privBytes().slice(0, 32)); + } + messagePrefix() { + return this._secret.slice(32, 64); + } +} + +export { KeyPair }; diff --git a/packages/mesh-core-cst/src/stricahq/bip32ed25519/ed25519e/signature.js b/packages/mesh-core-cst/src/stricahq/bip32ed25519/ed25519e/signature.js new file mode 100644 index 00000000..8b8c5520 --- /dev/null +++ b/packages/mesh-core-cst/src/stricahq/bip32ed25519/ed25519e/signature.js @@ -0,0 +1,99 @@ +/** + * Copyright 2021 Ashish Prajapati + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * *** Includes code to override elliptic.js implementation for ed25519 *** + * + * LICENSE + * + * This software is licensed under the MIT License. + * + * Copyright Fedor Indutny, 2014. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software + * and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, + * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR + * PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR + * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + */ + +import { isBN } from "bn.js"; +import { utils } from "elliptic"; + +const assert = utils.assert; +const cachedProperty = utils.cachedProperty; +const parseBytes = utils.parseBytes; +/** + * @param {EDDSA} eddsa - eddsa instance + * @param {Array|Object} sig - + * @param {Array|Point} [sig.R] - R point as Point or bytes + * @param {Array|bn} [sig.S] - S scalar as bn or bytes + * @param {Array} [sig.Rencoded] - R point encoded + * @param {Array} [sig.Sencoded] - S scalar encoded + */ +function Signature(eddsa, sig) { + this.eddsa = eddsa; + + if (typeof sig !== "object") sig = parseBytes(sig); + + if (Array.isArray(sig)) { + sig = { + R: sig.slice(0, eddsa.encodingLength), + S: sig.slice(eddsa.encodingLength), + }; + } + + assert(sig.R && sig.S, "Signature without R or S"); + + if (eddsa.isPoint(sig.R)) this._R = sig.R; + if (isBN(sig.S)) this._S = sig.S; + + this._Rencoded = Array.isArray(sig.R) ? sig.R : sig.Rencoded; + this._Sencoded = Array.isArray(sig.S) ? sig.S : sig.Sencoded; +} + +cachedProperty(Signature, "S", function S() { + return this.eddsa.decodeInt(this.Sencoded()); +}); + +cachedProperty(Signature, "R", function R() { + return this.eddsa.decodePoint(this.Rencoded()); +}); + +cachedProperty(Signature, "Rencoded", function Rencoded() { + return this.eddsa.encodePoint(this.R()); +}); + +cachedProperty(Signature, "Sencoded", function Sencoded() { + return this.eddsa.encodeInt(this.S()); +}); + +Signature.prototype.toBytes = function toBytes() { + return this.Rencoded().concat(this.Sencoded()); +}; + +Signature.prototype.toHex = function toHex() { + return utils.encode(this.toBytes(), "hex").toUpperCase(); +}; + +export { Signature }; diff --git a/packages/mesh-core-cst/src/stricahq/bip32ed25519/wrapper.ts b/packages/mesh-core-cst/src/stricahq/bip32ed25519/wrapper.ts index bdbd5b1d..8ead99c7 100644 --- a/packages/mesh-core-cst/src/stricahq/bip32ed25519/wrapper.ts +++ b/packages/mesh-core-cst/src/stricahq/bip32ed25519/wrapper.ts @@ -1,12 +1,10 @@ import * as cjsBip32ed25519 from "@stricahq/bip32ed25519"; -// This ensures that TypeScript understands the types properly export const bip32ed25519: typeof cjsBip32ed25519 & { default?: typeof cjsBip32ed25519; } = cjsBip32ed25519; const exportedBip32ed25519 = bip32ed25519?.default || bip32ed25519; -// Export individual classes and types export type StricaPrivateKey = cjsBip32ed25519.PrivateKey; export type StricaPublicKey = cjsBip32ed25519.PublicKey; export type StricaBip32PrivateKey = cjsBip32ed25519.Bip32PrivateKey; diff --git a/packages/mesh-core-cst/src/stricahq/cbors/README.md b/packages/mesh-core-cst/src/stricahq/cbors/README.md new file mode 100644 index 00000000..be4f3b47 --- /dev/null +++ b/packages/mesh-core-cst/src/stricahq/cbors/README.md @@ -0,0 +1,10 @@ +> This package is by [Strica](https://github.com/StricaHQ/cbors) + +

+ + + +

+ +# @stricahq/cbors +CBOR ([RFC 7049](http://tools.ietf.org/html/rfc7049)) encoder and decoder for javascript data types with streaming support. cbors implements annotations for deriving sub-cbor buffer from original cbor buffer which is a requirement for working with Cardano data types. diff --git a/packages/mesh-core/package.json b/packages/mesh-core/package.json index 4f423ff0..ff28b413 100644 --- a/packages/mesh-core/package.json +++ b/packages/mesh-core/package.json @@ -1,6 +1,6 @@ { "name": "@meshsdk/core", - "version": "1.6.9", + "version": "1.6.10", "description": "", "main": "./dist/index.cjs", "module": "./dist/index.js", diff --git a/packages/mesh-provider/package.json b/packages/mesh-provider/package.json index 524c6936..c5f0c8ad 100644 --- a/packages/mesh-provider/package.json +++ b/packages/mesh-provider/package.json @@ -1,6 +1,6 @@ { "name": "@meshsdk/provider", - "version": "1.6.9", + "version": "1.6.10", "description": "", "main": "./dist/index.cjs", "module": "./dist/index.js", diff --git a/packages/mesh-provider/src/yaci.ts b/packages/mesh-provider/src/yaci.ts index b01f5054..d5bd5d24 100644 --- a/packages/mesh-provider/src/yaci.ts +++ b/packages/mesh-provider/src/yaci.ts @@ -401,7 +401,10 @@ export class YaciProvider }, ); - if (status === 200 && data.result.EvaluationResult) { + console.log("Yaci status", status); + console.log("Yaci data", data); + + if (status === 202 && data.result.EvaluationResult) { const tagMap: { [key: string]: RedeemerTagType } = { spend: "SPEND", mint: "MINT", diff --git a/packages/mesh-provider/test/blockfrost/evaluator.test.ts b/packages/mesh-provider/test/blockfrost/evaluator.test.ts index 3322eb8f..a7f31e31 100644 --- a/packages/mesh-provider/test/blockfrost/evaluator.test.ts +++ b/packages/mesh-provider/test/blockfrost/evaluator.test.ts @@ -3,8 +3,8 @@ import dotenv from "dotenv"; import { BlockfrostProvider } from "@meshsdk/provider"; dotenv.config(); -const apiKey = process.env.BLOCKFROST_API_KEY_PREPROD!; -const provider = new BlockfrostProvider(apiKey, 0); +const apiKey = process.env.BLOCKFROST_API_KEY_PREPROD; +const provider = new BlockfrostProvider(apiKey ?? "", 0); const successTx = "84a70081825820859d3b4fd3a4c012b43ee1bbbc99240aec1827c3b8a74b867d10a7f4759149bc00018382583900e4cfbbc317c718f78d137b6535d8940618cc3d2ac04f1f35acf78e53a1521c2cea3cc79762d575581e47ea60b8eaa03430716cfd6140c796821a0011b0dea1581c67dd133868f14107b25772f3c5abaa1e0549f4b400b5e0e3a1136152a149000643b0546573743101a300581d7067dd133868f14107b25772f3c5abaa1e0549f4b400b5e0e3a113615201821a001ad510a1581c67dd133868f14107b25772f3c5abaa1e0549f4b400b5e0e3a1136152a149000de140546573743101028201d8185882d8799fa4446e616d6545546573743145696d6167655835697066733a2f2f516d527a6963705265757477436b4d36616f74754b6a4572464355443231334470775071364279757a4d4a617561496d656469615479706549696d6167652f6a70674b6465736372697074696f6e5348656c6c6f20776f726c64202d20434950363802ff825839003659ed2a30abb32e97589f2a01c8500ce8fc4897b868ebe42fbf4a8aa1521c2cea3cc79762d575581e47ea60b8eaa03430716cfd6140c7961a00134249021a000c830909a1581c67dd133868f14107b25772f3c5abaa1e0549f4b400b5e0e3a1136152a249000643b054657374310149000de1405465737431010b58207ae25a8a9286347cc1e0444a0de75e07432a6ed243591ef673fd837bb5235a670d82825820859d3b4fd3a4c012b43ee1bbbc99240aec1827c3b8a74b867d10a7f4759149bc00825820859d3b4fd3a4c012b43ee1bbbc99240aec1827c3b8a74b867d10a7f4759149bc050e81581ce4cfbbc317c718f78d137b6535d8940618cc3d2ac04f1f35acf78e53a206815883588101000032323232323232322232533300632323232533300a3370e9000000899b8f375c601c601000e911046d6573680014a0601000260180026018002600800429309b2b19299980319b87480000044c8c94ccc02cc03400852616375c601600260080062c60080044600a6ea80048c00cdd5000ab9a5573aaae7955cfaba157450581840100d8799f446d657368ff821a006acfc01ab2d05e00f5f6"; diff --git a/packages/mesh-provider/test/yaci/evaluator.test.ts b/packages/mesh-provider/test/yaci/evaluator.test.ts new file mode 100644 index 00000000..2e0a90d5 --- /dev/null +++ b/packages/mesh-provider/test/yaci/evaluator.test.ts @@ -0,0 +1,20 @@ +import { YaciProvider } from "@meshsdk/provider"; + +const provider = new YaciProvider("http://localhost:8080/api/v1/"); + +const successTx = + "84a60081825820ab11b83c9d46edf3e4f0124eccaec9c3469c4aa8bba47885991ea33f76f92d32000182825839005867c3b8e27840f556ac268b781578b14c5661fc63ee720dbeab663f9d4dcd7e454d2434164f4efb8edeb358d86a1dad9ec6224cfcbce3e6821a00111958a1581c9026ea35a0b0ca28e304ef94cc5a31c9e850db14a32dc3c69969fe83a14001825839005867c3b8e27840f556ac268b781578b14c5661fc63ee720dbeab663f9d4dcd7e454d2434164f4efb8edeb358d86a1dad9ec6224cfcbce3e61a3b89b0a8020009a1581c9026ea35a0b0ca28e304ef94cc5a31c9e850db14a32dc3c69969fe83a140010b5820df2de8c102f948422412af199867e5d472b9ff700473b2841e63209041b0e7df0d81825820ab11b83c9d46edf3e4f0124eccaec9c3469c4aa8bba47885991ea33f76f92d3200a20681590288590285010000332323232323232323232223232322533300832323232533300c3007300e3754002264a66601a6010601e6ea802454ccc034c020c03cdd519198008009bac30143011375400844a666026002298103d87a80001323253330113375e01e601260286ea80084cdd2a40006602c00497ae01330040040013017002301500114a229404c8cc004004c8cc004004c8cc004004dd5980b180b980b980b980b98099baa00622533301500114bd6f7b630099191919299980a99b9148900002153330153371e9101000021003100513301a337606ea4008dd3000998030030019bab3017003375c602a0046032004602e00244a666028002297ae0132333222323300100100322533301a00110031323301c374e660386ea4018cc070c064004cc070c0680052f5c066006006603c00460380026eb8c04c004dd5980a00099801801980c001180b0009129998098008a5113253330103253330113371e6eb8c0240040144cdc41bad301730183018001480005289bac301600213300300300114a0602c0026eb8c048c03cdd50008a50301130120023010001300c37540044601e0022930a99804a491856616c696461746f722072657475726e65642066616c7365001365632533300730020011533300b300a37540062930a998040030b0a99980399b874800800454ccc02cc028dd50018a4c2a6601000c2c2a6601000c2c60106ea8008dc3a4000a66666601800220022a6600a0062c2a6600a0062c2a6600a0062c2a6600a0062c92011672656465656d65723a204d696e74506f6c6172697479005734ae7155ceaab9e5573eae815d0aba257489812bd8799fd8799f5820ab11b83c9d46edf3e4f0124eccaec9c3469c4aa8bba47885991ea33f76f92d32ff00ff00010581840100d87980821a006acfc01ab2d05e00f5f6"; +// const failTx = +// "84a700848258203483fb2ced4fe3a8365e6a759a39d649b6c059bd04e8db6525dceef1fe7b2f25182c8258207702194883a5e3313a20bc7f4c52c05bd3b0d77e195be58d3976b36572774292182c82582077b196828fa17091d0ec94850c98d03bda0e6cd9e4373cdcd60a6b192f73fee9182e825820aaf165950213d80294a5e8f88aa31f6358c5e7c661071620715f4c3ce187f51c07018ea300583910cb55816770a83383463164b8b28609cefb26e73b2a7d361c3194b5335ca749261aa3b17aa2cd4b026bc6566c4b14421d6083edce64ffe5cb01821a0016e360a1581c5066154a102ee037390c5236f78db23239b49c5748d3d349f3ccf04ba144555344581a02faf080028201d81843d87980a300583910cb55816770a83383463164b8b28609cefb26e73b2a7d361c3194b5335ca749261aa3b17aa2cd4b026bc6566c4b14421d6083edce64ffe5cb01821a0016e360a1581c5066154a102ee037390c5236f78db23239b49c5748d3d349f3ccf04ba144555344581a02faf080028201d81843d87980a300583910cb55816770a83383463164b8b28609cefb26e73b2a7d361c3194b5335ca749261aa3b17aa2cd4b026bc6566c4b14421d6083edce64ffe5cb011a004c4b40028201d81843d87980a300583910cb55816770a83383463164b8b28609cefb26e73b2a7d361c3194b5335ca749261aa3b17aa2cd4b026bc6566c4b14421d6083edce64ffe5cb011a004c4b40028201d81843d87980a300583910cb55816770a83383463164b8b28609cefb26e73b2a7d361c3194b5335ca749261aa3b17aa2cd4b026bc6566c4b14421d6083edce64ffe5cb011a004c4b40028201d81843d87980a300583910cb55816770a83383463164b8b28609cefb26e73b2a7d361c3194b5335ca749261aa3b17aa2cd4b026bc6566c4b14421d6083edce64ffe5cb011a004c4b40028201d81843d87980a300583910cb55816770a83383463164b8b28609cefb26e73b2a7d361c3194b5335ca749261aa3b17aa2cd4b026bc6566c4b14421d6083edce64ffe5cb011a004c4b40028201d81843d87980a300583910cb55816770a83383463164b8b28609cefb26e73b2a7d361c3194b5335ca749261aa3b17aa2cd4b026bc6566c4b14421d6083edce64ffe5cb011a004c4b40028201d81843d87980a300583910cb55816770a83383463164b8b28609cefb26e73b2a7d361c3194b5335ca749261aa3b17aa2cd4b026bc6566c4b14421d6083edce64ffe5cb011a004c4b40028201d81843d87980a300583910cb55816770a83383463164b8b28609cefb26e73b2a7d361c3194b5335ca749261aa3b17aa2cd4b026bc6566c4b14421d6083edce64ffe5cb011a004c4b40028201d81843d87980a300583910cb55816770a83383463164b8b28609cefb26e73b2a7d361c3194b5335ca749261aa3b17aa2cd4b026bc6566c4b14421d6083edce64ffe5cb011a004c4b40028201d81843d87980a300583910cb55816770a83383463164b8b28609cefb26e73b2a7d361c3194b5335ca749261aa3b17aa2cd4b026bc6566c4b14421d6083edce64ffe5cb011a004c4b40028201d81843d87980a3005839101e9d8eac318f4e362ce80b987e63b6e41740d08bb084f014ae6633a95ca749261aa3b17aa2cd4b026bc6566c4b14421d6083edce64ffe5cb01821a0053a7e2a1581c5066154a102ee037390c5236f78db23239b49c5748d3d349f3ccf04ba144555344581a004c4b40028201d81843d87980825839001e4eb194e3335a0dcc4f5c5d009318167c583bb3b0879d9f718cd9e0d63a93470bd4d8bb986c02ff8a6043796b91cc397ceb29058f5c9ac01a20c46d08021a0003e8780b58208847a14577b0531c2a8ae0f7c27f2c75cc076c0864b3a641f5302a654c03b4cc0d818258203fbdf2b0b4213855dd9b87f7c94a50cf352ba6edfdded85ecb22cf9ceb75f814070e82581c1e4eb194e3335a0dcc4f5c5d009318167c583bb3b0879d9f718cd9e0581c5ca51b304b1f79d92eada8c58c513e969458dcd27ce4f5bc47823ffa128682582077b196828fa17091d0ec94850c98d03bda0e6cd9e4373cdcd60a6b192f73fee9182e825820aaf165950213d80294a5e8f88aa31f6358c5e7c661071620715f4c3ce187f51c078258207702194883a5e3313a20bc7f4c52c05bd3b0d77e195be58d3976b36572774292182c825820efe6fbbdd6b993d96883b96c572bfcaa0a4a138c83bd948dec1751d1bfda09b3008258203483fb2ced4fe3a8365e6a759a39d649b6c059bd04e8db6525dceef1fe7b2f25182c825820afd210b69469ebbb2997fd9285c6ae50833d82bcd817c6126ec05126fcdb6cad01a10584840000d879808219a9391a00d6d123840001d879808219a9391a00d6d123840002d879808219a9391a00d6d123840003d879808219a9391a00d6d123f5f6"; + +describe("Yavi Evaluator", () => { + it("should successfully evaluate correct tx", async () => { + // const res = await provider.evaluateTx(successTx); + // expect(res.length).toBeGreaterThan(0); + expect(1).toBe(1); + }); + // it("should fail evaluating incorrect tx", async () => { + // const res = await provider.evaluateTx(failTx).catch(() => "error"); + // expect(res).toBe("error"); + // }); +}); diff --git a/packages/mesh-react/package.json b/packages/mesh-react/package.json index 8e121376..8959667a 100644 --- a/packages/mesh-react/package.json +++ b/packages/mesh-react/package.json @@ -1,6 +1,6 @@ { "name": "@meshsdk/react", - "version": "1.6.9", + "version": "1.6.10", "description": "", "main": "./dist/index.cjs", "module": "./dist/index.js", diff --git a/packages/mesh-transaction/package.json b/packages/mesh-transaction/package.json index 7b0d79aa..f4098097 100644 --- a/packages/mesh-transaction/package.json +++ b/packages/mesh-transaction/package.json @@ -1,6 +1,6 @@ { "name": "@meshsdk/transaction", - "version": "1.6.9", + "version": "1.6.10", "description": "", "main": "./dist/index.cjs", "module": "./dist/index.js", diff --git a/packages/mesh-transaction/src/mesh-tx-builder/index.ts b/packages/mesh-transaction/src/mesh-tx-builder/index.ts index f8100447..f9011421 100644 --- a/packages/mesh-transaction/src/mesh-tx-builder/index.ts +++ b/packages/mesh-transaction/src/mesh-tx-builder/index.ts @@ -4,8 +4,11 @@ import { IMeshTxSerializer, ISubmitter, MeshTxBuilderBody, + MintItem, Protocol, + ScriptSource, ScriptTxIn, + SimpleScriptSourceInfo, TxIn, UTxO, } from "@meshsdk/common"; @@ -22,6 +25,7 @@ export interface MeshTxBuilderOptions { serializer?: IMeshTxSerializer; isHydra?: boolean; params?: Partial; + verbose?: boolean; } export class MeshTxBuilder extends MeshTxBuilderCore { @@ -30,8 +34,8 @@ export class MeshTxBuilder extends MeshTxBuilderCore { submitter?: ISubmitter; evaluator?: IEvaluator; txHex: string = ""; - private queriedTxHashes: Set = new Set(); - private queriedUTxOs: { [x: string]: UTxO[] } = {}; + protected queriedTxHashes: Set = new Set(); + protected queriedUTxOs: { [x: string]: UTxO[] } = {}; constructor({ serializer, @@ -40,6 +44,7 @@ export class MeshTxBuilder extends MeshTxBuilderCore { evaluator, params, isHydra = false, + verbose = false, }: MeshTxBuilderOptions = {}) { super(); if (serializer) { @@ -48,6 +53,7 @@ export class MeshTxBuilder extends MeshTxBuilderCore { // this.serializer = new CardanoSDKSerializer(); this.serializer = new CSLSerializer(); } + this.serializer.verbose = verbose; if (fetcher) this.fetcher = fetcher; if (submitter) this.submitter = submitter; if (evaluator) this.evaluator = evaluator; @@ -77,16 +83,27 @@ export class MeshTxBuilder extends MeshTxBuilderCore { this.removeDuplicateInputs(); // Checking if all inputs are complete - const { inputs, collaterals } = this.meshTxBuilderBody; + const { inputs, collaterals, mints } = this.meshTxBuilderBody; const incompleteTxIns = [...inputs, ...collaterals].filter( (txIn) => !this.isInputComplete(txIn), ); + const incompleteMints = mints.filter((mint) => !this.isMintComplete(mint)); // Getting all missing utxo information - await this.queryAllTxInfo(incompleteTxIns); + await this.queryAllTxInfo(incompleteTxIns, incompleteMints); // Completing all inputs incompleteTxIns.forEach((txIn) => { this.completeTxInformation(txIn); }); + incompleteMints.forEach((mint) => { + if (mint.type === "Plutus") { + const scriptSource = mint.scriptSource as ScriptSource; + this.completeScriptInfo(scriptSource); + } + if (mint.type === "Native") { + const scriptSource = mint.scriptSource as SimpleScriptSourceInfo; + this.completeSimpleScriptInfo(scriptSource); + } + }); this.addUtxosFromSelection(); let txHex = this.serializer.serializeTxBody( @@ -155,9 +172,9 @@ export class MeshTxBuilder extends MeshTxBuilderCore { /** * Get the UTxO information from the blockchain - * @param TxHash The TxIn object that contains the txHash and txIndex, while missing amount and address information + * @param txHash The TxIn object that contains the txHash and txIndex, while missing amount and address information */ - private getUTxOInfo = async (txHash: string): Promise => { + protected getUTxOInfo = async (txHash: string): Promise => { let utxos: UTxO[] = []; if (!this.queriedTxHashes.has(txHash)) { this.queriedTxHashes.add(txHash); @@ -166,9 +183,15 @@ export class MeshTxBuilder extends MeshTxBuilderCore { } }; - private queryAllTxInfo = (incompleteTxIns: TxIn[]) => { + protected queryAllTxInfo = ( + incompleteTxIns: TxIn[], + incompleteMints: MintItem[], + ) => { const queryUTxOPromises: Promise[] = []; - if (incompleteTxIns.length > 0 && !this.fetcher) + if ( + (incompleteTxIns.length > 0 || incompleteMints.length > 0) && + !this.fetcher + ) throw Error( "Transaction information is incomplete while no fetcher instance is provided", ); @@ -180,83 +203,129 @@ export class MeshTxBuilder extends MeshTxBuilderCore { if ( currentTxIn.type === "Script" && currentTxIn.scriptTxIn.scriptSource?.type === "Inline" && - !this.isRefScriptInfoComplete(currentTxIn) + !this.isRefScriptInfoComplete(currentTxIn.scriptTxIn.scriptSource) ) { queryUTxOPromises.push( this.getUTxOInfo(currentTxIn.scriptTxIn.scriptSource.txHash), ); } } + for (let i = 0; i < incompleteMints.length; i++) { + const currentMint = incompleteMints[i]!; + if (currentMint.type === "Plutus") { + const scriptSource = currentMint.scriptSource as ScriptSource; + if (scriptSource.type === "Inline") { + if (!this.isRefScriptInfoComplete(scriptSource)) { + queryUTxOPromises.push(this.getUTxOInfo(scriptSource.txHash)); + } + } + } + } return Promise.all(queryUTxOPromises); }; - private completeTxInformation = (input: TxIn) => { + protected completeTxInformation = (input: TxIn) => { // Adding value and address information for inputs if missing if (!this.isInputInfoComplete(input)) { - const utxos: UTxO[] = this.queriedUTxOs[input.txIn.txHash]!; - const utxo = utxos?.find( - (utxo) => utxo.input.outputIndex === input.txIn.txIndex, - ); - const amount = utxo?.output.amount; - const address = utxo?.output.address; - if (!amount || amount.length === 0) - throw Error( - `Couldn't find value information for ${input.txIn.txHash}#${input.txIn.txIndex}`, - ); - input.txIn.amount = amount; - if (input.type === "PubKey") { - if (!address || address === "") - throw Error( - `Couldn't find address information for ${input.txIn.txHash}#${input.txIn.txIndex}`, - ); - input.txIn.address = address; - } + this.completeInputInfo(input); } // Adding spendingScriptHash for script inputs' scriptSource if missing if ( input.type === "Script" && - input.scriptTxIn.scriptSource?.type == "Inline" && - !this.isRefScriptInfoComplete(input) + !this.isRefScriptInfoComplete(input.scriptTxIn.scriptSource!) ) { const scriptSource = input.scriptTxIn.scriptSource; - const refUtxos = this.queriedUTxOs[scriptSource.txHash]!; - const scriptRefUtxo = refUtxos.find( - (utxo) => utxo.input.outputIndex === scriptSource.txIndex, + this.completeScriptInfo(scriptSource!); + } + }; + + protected completeInputInfo = (input: TxIn) => { + const utxos: UTxO[] = this.queriedUTxOs[input.txIn.txHash]!; + const utxo = utxos?.find( + (utxo) => utxo.input.outputIndex === input.txIn.txIndex, + ); + const amount = utxo?.output.amount; + const address = utxo?.output.address; + if (!amount || amount.length === 0) + throw Error( + `Couldn't find value information for ${input.txIn.txHash}#${input.txIn.txIndex}`, ); - if (!scriptRefUtxo) + input.txIn.amount = amount; + if (input.type === "PubKey") { + if (!address || address === "") throw Error( - `Couldn't find script reference utxo for ${scriptSource.txHash}#${scriptSource.txIndex}`, + `Couldn't find address information for ${input.txIn.txHash}#${input.txIn.txIndex}`, ); - scriptSource.scriptHash = scriptRefUtxo?.output.scriptHash!; - scriptSource.scriptSize = ( - scriptRefUtxo?.output.scriptRef!.length / 2 - ).toString(); + input.txIn.address = address; } }; - private isInputComplete = (txIn: TxIn): boolean => { + protected completeScriptInfo = (scriptSource: ScriptSource) => { + if (scriptSource?.type != "Inline") return; + const refUtxos = this.queriedUTxOs[scriptSource.txHash]!; + const scriptRefUtxo = refUtxos.find( + (utxo) => utxo.input.outputIndex === scriptSource.txIndex, + ); + if (!scriptRefUtxo) + throw Error( + `Couldn't find script reference utxo for ${scriptSource.txHash}#${scriptSource.txIndex}`, + ); + scriptSource.scriptHash = scriptRefUtxo?.output.scriptHash!; + scriptSource.scriptSize = ( + scriptRefUtxo?.output.scriptRef!.length / 2 + ).toString(); + }; + + protected completeSimpleScriptInfo = ( + simpleScript: SimpleScriptSourceInfo, + ) => { + if (simpleScript.type !== "Inline") return; + const refUtxos = this.queriedUTxOs[simpleScript.txHash]!; + const scriptRefUtxo = refUtxos.find( + (utxo) => utxo.input.outputIndex === simpleScript.txIndex, + ); + if (!scriptRefUtxo) + throw Error( + `Couldn't find script reference utxo for ${simpleScript.txHash}#${simpleScript.txIndex}`, + ); + simpleScript.simpleScriptHash = scriptRefUtxo?.output.scriptHash!; + }; + + protected isInputComplete = (txIn: TxIn): boolean => { if (txIn.type === "PubKey") return this.isInputInfoComplete(txIn); if (txIn.type === "Script") { + const { scriptSource } = txIn.scriptTxIn; return ( - this.isInputInfoComplete(txIn) && this.isRefScriptInfoComplete(txIn) + this.isInputInfoComplete(txIn) && + this.isRefScriptInfoComplete(scriptSource!) ); } return true; }; - private isInputInfoComplete = (txIn: TxIn): boolean => { + protected isInputInfoComplete = (txIn: TxIn): boolean => { const { amount, address } = txIn.txIn; - if (txIn.type === "PubKey" && (!amount || !address)) return false; - if (txIn.type === "Script") { - if (!amount) return false; + if (!amount || !address) return false; + return true; + }; + + protected isMintComplete = (mint: MintItem): boolean => { + if (mint.type === "Plutus") { + const scriptSource = mint.scriptSource as ScriptSource; + return this.isRefScriptInfoComplete(scriptSource); + } + if (mint.type === "Native") { + const scriptSource = mint.scriptSource as SimpleScriptSourceInfo; + if (scriptSource.type === "Inline") { + if (!scriptSource?.simpleScriptHash) return false; + } } return true; }; - private isRefScriptInfoComplete = (scriptTxIn: ScriptTxIn): boolean => { - const { scriptSource } = scriptTxIn.scriptTxIn; + protected isRefScriptInfoComplete = (scriptSource: ScriptSource): boolean => { if (scriptSource?.type === "Inline") { - if (scriptSource?.scriptHash || scriptSource?.scriptSize) return false; + if (!scriptSource?.scriptHash || !scriptSource?.scriptSize) return false; } return true; }; diff --git a/packages/mesh-transaction/test/mesh-tx-builder/complete-info.test.ts b/packages/mesh-transaction/test/mesh-tx-builder/complete-info.test.ts new file mode 100644 index 00000000..f6071a75 --- /dev/null +++ b/packages/mesh-transaction/test/mesh-tx-builder/complete-info.test.ts @@ -0,0 +1,167 @@ +import { ScriptSource, SimpleScriptSourceInfo, TxIn } from "@meshsdk/common"; +import { MeshTxBuilder } from "@meshsdk/transaction"; + +class MockTxBuilder extends MeshTxBuilder { + constructor() { + super(); + this.queriedUTxOs = { + txHash1: [ + { + input: { txHash: "txHash1", outputIndex: 0 }, + output: { + amount: [{ unit: "lovelace", quantity: "100" }], + address: "address1", + scriptHash: "scriptHash1", + scriptRef: "scriptRef1", + }, + }, + ], + txHash2: [ + { + input: { txHash: "txHash2", outputIndex: 1 }, + output: { + amount: [{ unit: "lovelace", quantity: "200" }], + address: "address2", + scriptHash: "scriptHash2", + scriptRef: "scriptRef222", + }, + }, + ], + }; + } + + completeTxInformationExtended = this.completeTxInformation; + completeInputInfoExtended = this.completeInputInfo; + completeScriptInfoExtended = this.completeScriptInfo; + completeSimpleScriptInfoExtended = this.completeSimpleScriptInfo; +} + +describe("MeshTxBuilder", () => { + let txBuilder: MockTxBuilder; + + beforeEach(() => { + txBuilder = new MockTxBuilder(); + }); + + describe("completeTxInformation", () => { + it("should complete input info if incomplete", () => { + const input: TxIn = { + type: "PubKey", + txIn: { txHash: "txHash1", txIndex: 0 }, + }; + txBuilder.completeTxInformationExtended(input); + expect(JSON.stringify(input.txIn.amount)).toEqual( + JSON.stringify([{ unit: "lovelace", quantity: "100" }]), + ); + expect(input.txIn.address).toEqual("address1"); + }); + + it("should complete script info if incomplete", () => { + const input: TxIn = { + type: "Script", + txIn: { + txHash: "txHash2", + txIndex: 1, + }, + scriptTxIn: { + scriptSource: { + type: "Inline", + txHash: "txHash2", + txIndex: 1, + }, + }, + }; + txBuilder.completeTxInformationExtended(input); + expect(JSON.stringify(input.txIn.amount)).toEqual( + JSON.stringify([{ unit: "lovelace", quantity: "200" }]), + ); + expect(JSON.stringify(input.scriptTxIn.scriptSource)).toEqual( + JSON.stringify({ + type: "Inline", + txHash: "txHash2", + txIndex: 1, + scriptHash: "scriptHash2", + scriptSize: "6", + }), + ); + }); + }); + + describe("completeInputInfo", () => { + it("should complete input info with amount and address", () => { + const input: TxIn = { + type: "PubKey", + txIn: { txHash: "txHash1", txIndex: 0 }, + }; + txBuilder.completeInputInfoExtended(input); + expect(JSON.stringify(input.txIn.amount)).toEqual( + JSON.stringify([{ unit: "lovelace", quantity: "100" }]), + ); + expect(input.txIn.address).toEqual("address1"); + }); + + it("should throw error if amount is missing", () => { + const input: TxIn = { + type: "PubKey", + txIn: { txHash: "txHash3", txIndex: 0 }, + }; + expect(() => txBuilder.completeInputInfoExtended(input)).toThrow( + `Couldn't find value information for txHash3#0`, + ); + }); + }); + + describe("completeScriptInfo", () => { + it("should complete script info with scriptHash and scriptSize", () => { + const scriptSource: ScriptSource = { + type: "Inline", + txHash: "txHash2", + txIndex: 1, + }; + txBuilder.completeScriptInfoExtended(scriptSource); + expect(JSON.stringify(scriptSource)).toEqual( + JSON.stringify({ + type: "Inline", + txHash: "txHash2", + txIndex: 1, + scriptHash: "scriptHash2", + scriptSize: "6", + }), + ); + }); + + it("should throw error if script reference utxo is missing", () => { + const scriptSource: ScriptSource = { + type: "Inline", + txHash: "txHash3", + txIndex: 0, + }; + expect(() => + txBuilder.completeScriptInfoExtended(scriptSource), + ).toThrow(); + }); + }); + + describe("completeSimpleScriptInfo", () => { + it("should complete simple script info with simpleScriptHash", () => { + const simpleScript: SimpleScriptSourceInfo = { + type: "Inline", + txHash: "txHash2", + txIndex: 1, + }; + txBuilder.completeSimpleScriptInfoExtended(simpleScript); + expect(simpleScript.simpleScriptHash).toEqual("scriptHash2"); + }); + + it("should throw error if script reference utxo is missing", () => { + const simpleScript: SimpleScriptSourceInfo = { + type: "Inline", + txHash: "txHash3", + txIndex: 0, + }; + expect(() => + txBuilder.completeSimpleScriptInfoExtended(simpleScript), + ).toThrow(); + }); + }); +}); diff --git a/packages/mesh-transaction/test/mesh-tx-builder/complete.test.ts b/packages/mesh-transaction/test/mesh-tx-builder/complete.test.ts new file mode 100644 index 00000000..64b2e05f --- /dev/null +++ b/packages/mesh-transaction/test/mesh-tx-builder/complete.test.ts @@ -0,0 +1,107 @@ +import { + AccountInfo, + emptyTxBuilderBody, + IFetcher, + MintItem, + ScriptSource, + TransactionInfo, + TxIn, +} from "@meshsdk/common"; +import { MeshTxBuilder } from "@meshsdk/transaction"; + +class MockTxBuilder extends MeshTxBuilder { + constructor() { + super(); + this.queriedTxHashes = new Set(); + this.queriedUTxOs = {}; + this.fetcher = { + fetchUTxOs: jest.fn().mockResolvedValue([]), + fetchAccountInfo: jest.fn().mockResolvedValue({} as AccountInfo), + fetchAddressUTxOs: jest.fn().mockResolvedValue([]), + fetchProtocolParameters: jest.fn().mockResolvedValue({}), + fetchTxInfo: jest.fn().mockResolvedValue({} as TransactionInfo), + fetchNetworkInfo: jest.fn().mockResolvedValue({}), + fetchAssetInfo: jest.fn().mockResolvedValue({}), + fetchStakePoolInfo: jest.fn().mockResolvedValue({}), + fetchDelegationInfo: jest.fn().mockResolvedValue({}), + } as unknown as IFetcher; + } + + getUTxOInfoExtended = this.getUTxOInfo; + queryAllTxInfoExtended = this.queryAllTxInfo; +} + +describe("MeshTxBuilder", () => { + let txBuilder: MockTxBuilder; + + beforeEach(() => { + txBuilder = new MockTxBuilder(); + }); + + it("should update incomplete txIns and mints", async () => { + // Mock methods + + jest + .spyOn(txBuilder.serializer as any, "serializeTxBody") + .mockImplementation(() => ""); + jest + .spyOn(txBuilder as any, "addUtxosFromSelection") + .mockImplementation(() => {}); + jest + .spyOn(txBuilder as any, "isInputComplete") + .mockImplementation((txIn) => false); + jest + .spyOn(txBuilder as any, "isMintComplete") + .mockImplementation((mint) => false); + jest.spyOn(txBuilder as any, "queryAllTxInfo").mockResolvedValue(undefined); + const completeTxInformationMock = jest + .spyOn(txBuilder as any, "completeTxInformation") + .mockImplementation(() => {}); + const completeScriptInfoMock = jest + .spyOn(txBuilder as any, "completeScriptInfo") + .mockImplementation(() => {}); + + // Define incomplete inputs and mints + const incompleteTxIns: TxIn[] = [ + { type: "PubKey", txIn: { txHash: "txHash1", txIndex: 0 } }, + { type: "PubKey", txIn: { txHash: "txHash2", txIndex: 1 } }, + ]; + const incompleteMints: MintItem[] = [ + { + type: "Plutus", + policyId: "policyId1", + assetName: "assetName1", + amount: "100", + scriptSource: { + type: "Inline", + txHash: "txHash3", + txIndex: 2, + } as ScriptSource, + }, + ]; + + // Set the meshTxBuilderBody + txBuilder.meshTxBuilderBody = { + ...emptyTxBuilderBody(), + inputs: incompleteTxIns, + collaterals: [], + mints: incompleteMints, + }; + + // Call the complete method + await txBuilder.complete(); + + // Assertions + expect(completeTxInformationMock).toHaveBeenCalledTimes( + incompleteTxIns.length, + ); + incompleteTxIns.forEach((txIn) => { + expect(completeTxInformationMock).toHaveBeenCalledWith(txIn); + }); + + expect(completeScriptInfoMock).toHaveBeenCalledTimes(1); + expect(completeScriptInfoMock).toHaveBeenCalledWith( + (incompleteMints[0] as any).scriptSource, + ); + }); +}); diff --git a/packages/mesh-transaction/test/mesh-tx-builder/info-completeness-checker.test.ts b/packages/mesh-transaction/test/mesh-tx-builder/info-completeness-checker.test.ts new file mode 100644 index 00000000..e34fabbd --- /dev/null +++ b/packages/mesh-transaction/test/mesh-tx-builder/info-completeness-checker.test.ts @@ -0,0 +1,309 @@ +import { MintItem, ScriptSource, TxIn } from "@meshsdk/common"; +import { MeshTxBuilder } from "@meshsdk/transaction"; + +class MockTxBuilder extends MeshTxBuilder { + isInputCompleteExtended = this.isInputComplete; + isInputInfoCompleteExtended = this.isInputInfoComplete; + isRefScriptInfoCompleteExtended = this.isRefScriptInfoComplete; + isMintCompleteExtended = this.isMintComplete; +} + +describe("MeshTxBuilder", () => { + let txBuilder: MockTxBuilder; + + beforeEach(() => { + txBuilder = new MockTxBuilder(); + }); + + describe("isInputComplete", () => { + it("should return false for incomplete PubKey input", () => { + const txIn: TxIn = { + type: "PubKey", + txIn: { txHash: "hash", txIndex: 0 }, + }; + expect(txBuilder.isInputCompleteExtended(txIn)).toBe(false); + }); + + it("should return false for incomplete PubKey input", () => { + const txIn: TxIn = { + type: "PubKey", + txIn: { txHash: "hash", txIndex: 0, address: "address" }, + }; + expect(txBuilder.isInputCompleteExtended(txIn)).toBe(false); + }); + it("should return false for incomplete PubKey input", () => { + const txIn: TxIn = { + type: "PubKey", + txIn: { txHash: "hash", txIndex: 0, amount: [] }, + }; + expect(txBuilder.isInputCompleteExtended(txIn)).toBe(false); + }); + it("should return true for complete PubKey input", () => { + const txIn: TxIn = { + type: "PubKey", + txIn: { txHash: "hash", txIndex: 0, amount: [], address: "address" }, + }; + expect(txBuilder.isInputCompleteExtended(txIn)).toBe(true); + }); + + it("should return false for incomplete Script input", () => { + const txIn: TxIn = { + type: "Script", + txIn: { txHash: "hash", txIndex: 0 }, + scriptTxIn: { + scriptSource: { + type: "Provided", + script: { code: "code", version: "V1" }, + }, + }, + }; + expect(txBuilder.isInputCompleteExtended(txIn)).toBe(false); + }); + + it("should return false for incomplete Script input", () => { + const txIn: TxIn = { + type: "Script", + txIn: { txHash: "hash", txIndex: 0, address: "address" }, + scriptTxIn: { + scriptSource: { + type: "Provided", + script: { code: "code", version: "V1" }, + }, + }, + }; + expect(txBuilder.isInputCompleteExtended(txIn)).toBe(false); + }); + it("should return false for incomplete Script input", () => { + const txIn: TxIn = { + type: "Script", + txIn: { txHash: "hash", txIndex: 0, amount: [] }, + scriptTxIn: { + scriptSource: { + type: "Provided", + script: { code: "code", version: "V1" }, + }, + }, + }; + expect(txBuilder.isInputCompleteExtended(txIn)).toBe(false); + }); + it("should return true for complete Script input", () => { + const txIn: TxIn = { + type: "Script", + txIn: { txHash: "hash", txIndex: 0, amount: [], address: "address" }, + scriptTxIn: { + scriptSource: { + type: "Provided", + script: { code: "code", version: "V1" }, + }, + }, + }; + expect(txBuilder.isInputCompleteExtended(txIn)).toBe(true); + }); + it("should return true for complete Script input, with complete script ref", () => { + const txIn: TxIn = { + type: "Script", + txIn: { txHash: "hash", txIndex: 0, amount: [], address: "address" }, + scriptTxIn: { + scriptSource: { + type: "Inline", + txHash: "hash", + txIndex: 0, + scriptSize: "100", + scriptHash: "hash", + version: "V1", + }, + }, + }; + expect(txBuilder.isInputCompleteExtended(txIn)).toBe(true); + }); + it("should return false for complete Script input, but incomplete script ref (no script hash)", () => { + const txIn: TxIn = { + type: "Script", + txIn: { txHash: "hash", txIndex: 0, amount: [], address: "address" }, + scriptTxIn: { + scriptSource: { + type: "Inline", + txHash: "hash", + txIndex: 0, + scriptSize: "100", + version: "V1", + }, + }, + }; + expect(txBuilder.isInputCompleteExtended(txIn)).toBe(false); + }); + it("should return false for complete Script input, but incomplete script ref (no script size)", () => { + const txIn: TxIn = { + type: "Script", + txIn: { txHash: "hash", txIndex: 0, amount: [], address: "address" }, + scriptTxIn: { + scriptSource: { + type: "Inline", + txHash: "hash", + txIndex: 0, + scriptHash: "hash", + version: "V1", + }, + }, + }; + expect(txBuilder.isInputCompleteExtended(txIn)).toBe(false); + }); + }); + + describe("isInputInfoComplete", () => { + it("should return false for incomplete PubKey input", () => { + const txIn: TxIn = { + type: "PubKey", + txIn: { txHash: "hash", txIndex: 0 }, + }; + expect(txBuilder.isInputInfoCompleteExtended(txIn)).toBe(false); + }); + + it("should return false for incomplete PubKey input", () => { + const txIn: TxIn = { + type: "PubKey", + txIn: { txHash: "hash", txIndex: 0, address: "address" }, + }; + expect(txBuilder.isInputInfoCompleteExtended(txIn)).toBe(false); + }); + it("should return false for incomplete PubKey input", () => { + const txIn: TxIn = { + type: "PubKey", + txIn: { txHash: "hash", txIndex: 0, amount: [] }, + }; + expect(txBuilder.isInputInfoCompleteExtended(txIn)).toBe(false); + }); + it("should return true for complete PubKey input", () => { + const txIn: TxIn = { + type: "PubKey", + txIn: { txHash: "hash", txIndex: 0, amount: [], address: "address" }, + }; + expect(txBuilder.isInputInfoCompleteExtended(txIn)).toBe(true); + }); + }); + + describe("isMintComplete", () => { + it("should return true for complete Plutus mint", () => { + const mint: MintItem = { + type: "Plutus", + policyId: "policyId", + assetName: "assetName", + amount: "1", + scriptSource: { + type: "Inline", + txHash: "hash", + txIndex: 0, + scriptSize: "100", + scriptHash: "hash", + version: "V1", + }, + }; + expect(txBuilder.isMintCompleteExtended(mint)).toBe(true); + }); + + it("should return false for complete Plutus mint (no script hash)", () => { + const mint: MintItem = { + type: "Plutus", + policyId: "policyId", + assetName: "assetName", + amount: "1", + scriptSource: { + type: "Inline", + txHash: "hash", + txIndex: 0, + scriptSize: "100", + version: "V1", + }, + }; + expect(txBuilder.isMintCompleteExtended(mint)).toBe(false); + }); + + it("should return false for incomplete Plutus mint (no script size)", () => { + const mint: MintItem = { + type: "Plutus", + policyId: "policyId", + assetName: "assetName", + amount: "1", + scriptSource: { + type: "Inline", + txHash: "hash", + txIndex: 0, + scriptHash: "hash", + version: "V1", + }, + }; + expect(txBuilder.isMintCompleteExtended(mint)).toBe(false); + }); + + it("should return true for complete Native mint", () => { + const mint: MintItem = { + type: "Native", + policyId: "policyId", + assetName: "assetName", + amount: "1", + scriptSource: { + type: "Inline", + txHash: "hash", + txIndex: 0, + simpleScriptHash: "hash", + }, + }; + expect(txBuilder.isMintCompleteExtended(mint)).toBe(true); + }); + + it("should return false for incomplete Native mint (no script hash)", () => { + const mint: MintItem = { + type: "Plutus", + policyId: "policyId", + assetName: "assetName", + amount: "1", + scriptSource: { + type: "Inline", + txHash: "hash", + txIndex: 0, + }, + }; + expect(txBuilder.isMintCompleteExtended(mint)).toBe(false); + }); + }); + + describe("isRefScriptInfoComplete", () => { + it("should return true with complete script ref", () => { + const scriptSource: ScriptSource = { + type: "Inline", + txHash: "hash", + txIndex: 0, + scriptSize: "100", + scriptHash: "hash", + version: "V1", + }; + expect(txBuilder.isRefScriptInfoCompleteExtended(scriptSource)).toBe( + true, + ); + }); + it("should return false for incomplete script ref (no script hash)", () => { + const scriptSource: ScriptSource = { + type: "Inline", + txHash: "hash", + txIndex: 0, + scriptSize: "100", + version: "V1", + }; + expect(txBuilder.isRefScriptInfoCompleteExtended(scriptSource)).toBe( + false, + ); + }); + it("should return false for incomplete script ref (no script size)", () => { + const scriptSource: ScriptSource = { + type: "Inline", + txHash: "hash", + txIndex: 0, + scriptHash: "hash", + version: "V1", + }; + expect(txBuilder.isRefScriptInfoCompleteExtended(scriptSource)).toBe( + false, + ); + }); + }); +}); diff --git a/packages/mesh-transaction/test/mesh-tx-builder/query.test.ts b/packages/mesh-transaction/test/mesh-tx-builder/query.test.ts new file mode 100644 index 00000000..0180d511 --- /dev/null +++ b/packages/mesh-transaction/test/mesh-tx-builder/query.test.ts @@ -0,0 +1,95 @@ +import { + AccountInfo, + IFetcher, + MintItem, + TransactionInfo, + TxIn, + UTxO, +} from "@meshsdk/common"; +import { MeshTxBuilder } from "@meshsdk/transaction"; + +class MockTxBuilder extends MeshTxBuilder { + constructor() { + super(); + this.queriedTxHashes = new Set(); + this.queriedUTxOs = {}; + this.fetcher = { + fetchUTxOs: jest.fn().mockResolvedValue([]), + fetchAccountInfo: jest.fn().mockResolvedValue({} as AccountInfo), + fetchAddressUTxOs: jest.fn().mockResolvedValue([]), + fetchProtocolParameters: jest.fn().mockResolvedValue({}), + fetchTxInfo: jest.fn().mockResolvedValue({} as TransactionInfo), + fetchNetworkInfo: jest.fn().mockResolvedValue({}), + fetchAssetInfo: jest.fn().mockResolvedValue({}), + fetchStakePoolInfo: jest.fn().mockResolvedValue({}), + fetchDelegationInfo: jest.fn().mockResolvedValue({}), + } as unknown as IFetcher; + } + + getUTxOInfoExtended = this.getUTxOInfo; + queryAllTxInfoExtended = this.queryAllTxInfo; +} + +describe("MeshTxBuilder", () => { + let txBuilder: MockTxBuilder; + + beforeEach(() => { + txBuilder = new MockTxBuilder(); + }); + + describe("queryAllTxInfo", () => { + it("should call getUTxOInfo for incomplete TxIns", async () => { + const incompleteTxIns: TxIn[] = [ + { + type: "PubKey", + txIn: { txHash: "txHash1", txIndex: 0 }, + }, + { + type: "Script", + txIn: { txHash: "txHash2", txIndex: 1 }, + scriptTxIn: { + scriptSource: { + type: "Inline", + txHash: "txHash3", + txIndex: 2, + }, + }, + }, + ]; + const incompleteMints: MintItem[] = []; + + const getUTxOInfoMock = jest + .spyOn(txBuilder as any, "getUTxOInfo") + .mockResolvedValue({} as UTxO); + + await txBuilder.queryAllTxInfoExtended(incompleteTxIns, incompleteMints); + expect(getUTxOInfoMock).toHaveBeenCalledWith("txHash1"); + expect(getUTxOInfoMock).toHaveBeenCalledWith("txHash3"); + }); + + it("should call getUTxOInfo for incomplete Mints", async () => { + const incompleteTxIns: TxIn[] = []; + const incompleteMints: MintItem[] = [ + { + type: "Plutus", + policyId: "policyId1", + assetName: "assetName1", + amount: "100", + scriptSource: { + type: "Inline", + txHash: "txHash4", + txIndex: 3, + }, + }, + ]; + + const getUTxOInfoMock = jest + .spyOn(txBuilder as any, "getUTxOInfo") + .mockResolvedValue({} as UTxO); + + await txBuilder.queryAllTxInfoExtended(incompleteTxIns, incompleteMints); + + expect(getUTxOInfoMock).toHaveBeenCalledWith("txHash4"); + }); + }); +}); diff --git a/packages/mesh-wallet/package.json b/packages/mesh-wallet/package.json index 39f2d393..041ca35a 100644 --- a/packages/mesh-wallet/package.json +++ b/packages/mesh-wallet/package.json @@ -1,6 +1,6 @@ { "name": "@meshsdk/wallet", - "version": "1.6.9", + "version": "1.6.10", "description": "", "main": "./dist/index.cjs", "module": "./dist/index.js",