diff --git a/apps/playground/public/drep/meshjs.jsonld b/apps/playground/public/drep/meshjs.jsonld
new file mode 100644
index 00000000..cdafb5f7
--- /dev/null
+++ b/apps/playground/public/drep/meshjs.jsonld
@@ -0,0 +1,69 @@
+{
+ "@context": {
+ "CIP100": "https://github.com/cardano-foundation/CIPs/blob/master/CIP-0100/README.md#",
+ "CIP119": "https://github.com/cardano-foundation/CIPs/blob/master/CIP-0119/README.md#",
+ "hashAlgorithm": "CIP100:hashAlgorithm",
+ "body": {
+ "@id": "CIP119:body",
+ "@context": {
+ "references": {
+ "@id": "CIP119:references",
+ "@container": "@set",
+ "@context": {
+ "GovernanceMetadata": "CIP100:GovernanceMetadataReference",
+ "Identity": "CIP100:IdentityReference",
+ "Link": "CIP100:LinkReference",
+ "Other": "CIP100:OtherReference",
+ "label": "CIP100:reference-label",
+ "uri": "CIP100:reference-uri",
+ "referenceHash": {
+ "@id": "CIP119:referenceHash",
+ "@context": {
+ "hashDigest": "CIP119:hashDigest",
+ "hashAlgorithm": "CIP100:hashAlgorithm"
+ }
+ }
+ }
+ },
+ "paymentAddress": "CIP119:paymentAddress",
+ "givenName": "CIP119:givenName",
+ "image": "CIP119:image",
+ "objectives": "CIP119:objectives",
+ "motivations": "CIP119:motivations",
+ "qualifications": "CIP119:qualifications",
+ "doNotList": "CIP119:doNotList"
+ }
+ },
+ "authors": {
+ "@id": "CIP100:authors",
+ "@container": "@set",
+ "@context": {
+ "name": "http://xmlns.com/foaf/0.1/name",
+ "witness": {
+ "@id": "CIP100:witness",
+ "@context": {
+ "witnessAlgorithm": "CIP100:witnessAlgorithm",
+ "publicKey": "CIP100:publicKey",
+ "signature": "CIP100:signature"
+ }
+ }
+ }
+ }
+ },
+ "authors": [],
+ "hashAlgorithm": "blake2b-256",
+ "body": {
+ "givenName": "MeshJS",
+ "motivations": "We're motivated by our deep belief in decentralized governance and our hands-on experience with MeshJS. We've seen firsthand how accessible tools can drive innovation, and we want to make sure developers' needs and voices are at the forefront of Cardano's evolution.",
+ "objectives": "We champion governance decisions that support open-source development and empower Cardano's developer community. We aim to make it easier for developers to innovate and contribute to the ecosystem.",
+ "paymentAddress": "addr1qyjtjxjkhskglfefwe9kanvk7wczft0q6ngyhyh9es0km27q3upff6k44dawpnj5w8w5suq8jxff0w54yv90yte9u46st87vk3",
+ "qualifications": "Our experience in blockchain tooling and commitment to open-source principles make us well-equipped to represent developers in Cardano's decision-making processes.",
+ "references": [
+ {
+ "@type": "Other",
+ "label": "Label",
+ "uri": "https://meshjs.dev/"
+ }
+ ]
+ }
+}
\ No newline at end of file
diff --git a/apps/playground/src/data/links-data.ts b/apps/playground/src/data/links-data.ts
index 62097829..4cdb826d 100644
--- a/apps/playground/src/data/links-data.ts
+++ b/apps/playground/src/data/links-data.ts
@@ -27,7 +27,6 @@ export const metaDataJson = {
link: "/apis/data/json",
icon: Bars3Icon,
};
-// todoß
export const metaDataValue = {
title: "Value",
desc: "Manipulate Cardano Value Easily",
@@ -52,8 +51,8 @@ export const linksData: MenuItem[] = [
metaDataMesh,
metaDataJson,
metaDataValue,
- // metaDataCbor,
- // metaDataUtils,
+ // metaDataCbor, // todo
+ // metaDataUtils, // todo
];
export const metaData = {
diff --git a/apps/playground/src/pages/apis/transaction/minting/burning-one-signature.tsx b/apps/playground/src/pages/apis/transaction/minting/burning-one-signature.tsx
index 17d17b76..41b41f1d 100644
--- a/apps/playground/src/pages/apis/transaction/minting/burning-one-signature.tsx
+++ b/apps/playground/src/pages/apis/transaction/minting/burning-one-signature.tsx
@@ -50,7 +50,7 @@ function Left(userInput: string) {
codeSnippet1 += `const forgingScript = ForgeScript.withOneSignature(address);`;
let codeSnippet2 = `const asset: Asset = {\n`;
- codeSnippet2 += ` unit: assetAsset,\n`;
+ codeSnippet2 += ` unit: '${userInput}',\n`;
codeSnippet2 += ` quantity: '1',\n`;
codeSnippet2 += `};\n`;
codeSnippet2 += `tx.burnAsset(forgingScript, asset);`;
diff --git a/apps/playground/src/pages/apis/txbuilder/basics/index.tsx b/apps/playground/src/pages/apis/txbuilder/basics/index.tsx
index 735bc0a6..1db052e1 100644
--- a/apps/playground/src/pages/apis/txbuilder/basics/index.tsx
+++ b/apps/playground/src/pages/apis/txbuilder/basics/index.tsx
@@ -15,12 +15,14 @@ import TxbuilderSendValues from "./send-values";
import TxbuilderSetNetwork from "./set-network";
import TxbuilderSetRequiredSigners from "./set-required-signers";
import TxbuilderSetTime from "./set-time";
+import TxbuilderMultisigNativeScript from "./multisig-native-script";
const ReactPage: NextPage = () => {
const sidebarItems = [
{ label: "Initialize Tx Builder", to: "initializeTxbuilder" },
{ label: "Send value", to: "sendValue" },
{ label: "Multi-signature", to: "multisig" },
+ { label: "Multisig native script", to: "multisigNativeScript" },
{ label: "Build with object", to: "buildWithObject" },
{ label: "Coin selection", to: "coinSelection" },
{ label: "Set metadata", to: "cip20" },
@@ -68,6 +70,7 @@ const ReactPage: NextPage = () => {
{/* */}
+
{/* */}
diff --git a/apps/playground/src/pages/apis/txbuilder/basics/multisig-native-script.tsx b/apps/playground/src/pages/apis/txbuilder/basics/multisig-native-script.tsx
new file mode 100644
index 00000000..ff227ef7
--- /dev/null
+++ b/apps/playground/src/pages/apis/txbuilder/basics/multisig-native-script.tsx
@@ -0,0 +1,238 @@
+import {
+ AppWallet,
+ deserializeAddress,
+ ForgeScript,
+ MeshTxBuilder,
+ MeshWallet,
+ NativeScript,
+ resolveNativeScriptAddress,
+ resolveNativeScriptHash,
+ resolveScriptHash,
+ serializeNativeScript,
+ stringToHex,
+} from "@meshsdk/core";
+import { useWallet } from "@meshsdk/react";
+
+import { getProvider } from "~/components/cardano/mesh-wallet";
+import LiveCodeDemo from "~/components/sections/live-code-demo";
+import TwoColumnsScroll from "~/components/sections/two-columns-scroll";
+import Codeblock from "~/components/text/codeblock";
+import { demoAssetMetadata, demoMnemonic } from "~/data/cardano";
+import { getTxBuilder } from "../common";
+
+// const scriptAddress =
+// "addr_test1vpd5480qj5jj4pnjwq9yxnac8l9dw2k3y6gz2cpp6jawzwq838jl8";
+// const scriptCbor =
+// "8201828200581c556f3a70b8a68081cf36c918dd9933abdca34f20fc534499c817182b8200581c5867c3b8e27840f556ac268b781578b14c5661fc63ee720dbeab663f";
+
+export default function TxbuilderMultisigNativeScript() {
+ return (
+
+ );
+}
+
+function Left() {
+ let codeKeyHash = ``;
+ codeKeyHash += `const { pubKeyHash: keyHash1 } = deserializeAddress(walletAddress1);\n`;
+ codeKeyHash += `const { pubKeyHash: keyHash2 } = deserializeAddress(walletAddress2);\n`;
+
+ let codeNativeScript = ``;
+ codeNativeScript += `const nativeScript: NativeScript = {\n`;
+ codeNativeScript += ` type: "all",\n`;
+ codeNativeScript += ` scripts: [\n`;
+ codeNativeScript += ` {\n`;
+ codeNativeScript += ` type: "sig",\n`;
+ codeNativeScript += ` keyHash: keyHash1,\n`;
+ codeNativeScript += ` },\n`;
+ codeNativeScript += ` {\n`;
+ codeNativeScript += ` type: "sig",\n`;
+ codeNativeScript += ` keyHash: keyHash2,\n`;
+ codeNativeScript += ` },\n`;
+ codeNativeScript += ` ],\n`;
+ codeNativeScript += `};\n`;
+
+ let codeSerializeNativeScript = ``;
+ codeSerializeNativeScript += `const { address: scriptAddress, scriptCbor } =\n`;
+ codeSerializeNativeScript += ` serializeNativeScript(nativeScript);\n`;
+
+ let codeTx = ``;
+ codeTx += `// get utxo from script\n`;
+ codeTx += `const utxos = await blockchainProvider.fetchAddressUTxOs(scriptAddress);\n`;
+ codeTx += `const utxo = utxos[0];\n`;
+ codeTx += `\n`;
+ codeTx += `// create tx\n`;
+ codeTx += `const unsignedTx = await txBuilder\n`;
+ codeTx += ` .txIn(\n`;
+ codeTx += ` utxo.input.txHash,\n`;
+ codeTx += ` utxo.input.outputIndex,\n`;
+ codeTx += ` utxo.output.amount,\n`;
+ codeTx += ` utxo.output.address,\n`;
+ codeTx += ` )\n`;
+ codeTx += ` .txInScript(scriptCbor)\n`;
+ codeTx += ` .txOut(\n`;
+ codeTx += ` "addr_test1vpvx0sacufuypa2k4sngk7q40zc5c4npl337uusdh64kv0c7e4cxr",\n`;
+ codeTx += ` [{ unit: "lovelace", quantity: "2000000" }],\n`;
+ codeTx += ` )\n`;
+ codeTx += ` .changeAddress(scriptAddress)\n`;
+ codeTx += ` .selectUtxosFrom(utxos)\n`;
+ codeTx += ` .complete();\n`;
+
+ let codeSign = ``;
+ codeSign += `const signedTx1 = await wallet1.signTx(unsignedTx, true);\n`;
+ codeSign += `const signedTx2 = await wallet2.signTx(signedTx1, true);\n`;
+ codeSign += `\n`;
+ codeSign += `const txHash = await wallet.submitTx(signedTx2);\n`;
+
+ return (
+ <>
+
Create native script
+
+ First, we need to create a native script. In this example, we will
+ create a native script with two signatures. That means we need to get
+ the key hashes of the two wallets.
+
+
+
+ Next, we will create a native script object with the two key hashes. The
+ native script object will be used to create a multi-signature
+ transaction.
+
+
+
+ The native script object is then serialized into a CBOR object and an
+ address.
+
+
+ Create transaction
+
+ Now that we have the native script, we can create a transaction with the
+ script. We first need to get the UTXO from the script address.
+
+
+
+ Finally, we sign the transaction with the two wallets and submit the
+ transaction.
+
+
+ >
+ );
+}
+
+function Right() {
+ const { wallet, connected } = useWallet();
+
+ function getMeshWallet() {
+ const blockchainProvider = getProvider();
+
+ const wallet = new MeshWallet({
+ networkId: 0,
+ fetcher: blockchainProvider,
+ submitter: blockchainProvider,
+ key: {
+ type: "mnemonic",
+ words: "solution,".repeat(24).split(",").slice(0, 24),
+ },
+ });
+
+ const walletAddress = wallet.getChangeAddress();
+
+ const { pubKeyHash: keyHash } = deserializeAddress(walletAddress);
+ return { wallet, keyHash, walletAddress };
+ }
+
+ async function getScript() {
+ if (!connected) return;
+
+ // first wallet
+ const walletAddress = (await wallet.getUsedAddresses())[0];
+ if (!walletAddress) return;
+ const { pubKeyHash: keyHash1 } = deserializeAddress(walletAddress);
+
+ // second wallet
+ const { keyHash: keyHash2 } = getMeshWallet();
+
+ const nativeScript: NativeScript = {
+ type: "all",
+ scripts: [
+ {
+ type: "sig",
+ keyHash: keyHash1,
+ },
+ {
+ type: "sig",
+ keyHash: keyHash2,
+ },
+ ],
+ };
+
+ const { address: scriptAddress, scriptCbor } =
+ serializeNativeScript(nativeScript);
+
+ return { scriptAddress, scriptCbor: scriptCbor! };
+ }
+
+ async function runDemo() {
+ if (!connected) return;
+
+ const script = await getScript();
+ if (!script) {
+ throw new Error("Failed to get script");
+ }
+ const { scriptAddress, scriptCbor } = script;
+
+ const blockchainProvider = getProvider();
+ const utxos = await blockchainProvider.fetchAddressUTxOs(scriptAddress);
+
+ if (utxos.length === 0) {
+ throw new Error(`No utxos, fund address ${scriptAddress}`);
+ }
+ const utxo = utxos[0]!;
+
+ const { wallet: walletB } = getMeshWallet();
+
+ const txBuilder = getTxBuilder();
+
+ const unsignedTx = await txBuilder
+ .txIn(
+ utxo.input.txHash,
+ utxo.input.outputIndex,
+ utxo.output.amount,
+ utxo.output.address,
+ )
+ .txInScript(scriptCbor)
+ .txOut(
+ "addr_test1vpvx0sacufuypa2k4sngk7q40zc5c4npl337uusdh64kv0c7e4cxr",
+ [{ unit: "lovelace", quantity: "2000000" }],
+ )
+ .changeAddress(scriptAddress)
+ .selectUtxosFrom(utxos)
+ .complete();
+
+ const signedTx1 = await wallet.signTx(unsignedTx, true);
+ const signedTx2 = await walletB.signTx(signedTx1, true);
+
+ const txHash = await wallet.submitTx(signedTx2);
+ return txHash;
+ }
+
+ let codeSnippet = ``;
+
+ return (
+
+ );
+}
diff --git a/apps/playground/src/pages/apis/txbuilder/basics/multisig.tsx b/apps/playground/src/pages/apis/txbuilder/basics/multisig.tsx
index bb0d9f46..f8297619 100644
--- a/apps/playground/src/pages/apis/txbuilder/basics/multisig.tsx
+++ b/apps/playground/src/pages/apis/txbuilder/basics/multisig.tsx
@@ -1,5 +1,5 @@
import {
- AppWallet,
+ MeshWallet,
ForgeScript,
resolveScriptHash,
stringToHex,
@@ -26,12 +26,17 @@ export default function TxbuilderMultisig() {
function Left() {
let codeTx = ``;
- codeTx += `const tx = new Transaction({ initiator: wallet });\n`;
- codeTx += `tx.mintAsset(forgingScript, asset);\n`;
+ codeTx += `const unsignedTx = await txBuilder\n`;
+ codeTx += ` .mint("1", policyId, stringToHex("MeshToken"))\n`;
+ codeTx += ` .mintingScript(forgingScript)\n`;
+ codeTx += ` .metadataValue("721", { [policyId]: { [assetName]: demoAssetMetadata } })\n`;
+ codeTx += ` .changeAddress(address)\n`;
+ codeTx += ` .selectUtxosFrom(utxos)\n`;
+ codeTx += ` .complete();\n`;
codeTx += `\n`;
- codeTx += `const unsignedTx = await tx.build();\n`;
codeTx += `const signedTx = await wallet.signTx(unsignedTx, true);\n`;
- codeTx += `const signedTx2 = await mintingWallet.signTx(signedTx, true);\n`;
+ codeTx += `const signedTx2 = mintingWallet.signTx(signedTx, true);\n`;
+ codeTx += `const txHash = await wallet.submitTx(signedTx2);\n`;
let codeSign = `await wallet.signTx(unsignedTx, true);`;
@@ -59,7 +64,7 @@ function Right() {
async function runDemo() {
const blockchainProvider = getProvider();
- const mintingWallet = new AppWallet({
+ const mintingWallet = new MeshWallet({
networkId: 0,
fetcher: blockchainProvider,
submitter: blockchainProvider,
@@ -69,7 +74,7 @@ function Right() {
},
});
const forgingScript = ForgeScript.withOneSignature(
- mintingWallet.getPaymentAddress(),
+ mintingWallet.getChangeAddress(),
);
const assetName = "MeshToken";
const policyId = resolveScriptHash(forgingScript);
@@ -94,8 +99,8 @@ function Right() {
return txHash;
}
- let codeSnippet = `import { AppWallet, ForgeScript, Mint, Transaction } from '@meshsdk/core';\n\n`;
- codeSnippet += `const mintingWallet = new AppWallet({\n`;
+ let codeSnippet = `import { MeshWallet, ForgeScript, Mint, Transaction } from '@meshsdk/core';\n\n`;
+ codeSnippet += `const mintingWallet = new MeshWallet({\n`;
codeSnippet += ` networkId: 0,\n`;
codeSnippet += ` fetcher: blockchainProvider,\n`;
codeSnippet += ` submitter: blockchainProvider,\n`;
@@ -106,7 +111,7 @@ function Right() {
codeSnippet += `});\n`;
codeSnippet += `\n`;
codeSnippet += `const forgingScript = ForgeScript.withOneSignature(\n`;
- codeSnippet += ` mintingWallet.getPaymentAddress(),\n`;
+ codeSnippet += ` mintingWallet.getChangeAddress(),\n`;
codeSnippet += `);\n`;
codeSnippet += `\n`;
codeSnippet += `const assetName = "MeshToken";\n`;
@@ -116,8 +121,6 @@ function Right() {
codeSnippet += `const utxos = await wallet.getUtxos();\n`;
codeSnippet += `const address = usedAddress[0]!;\n`;
codeSnippet += `\n`;
- codeSnippet += `const txBuilder = getTxBuilder();\n`;
- codeSnippet += `\n`;
codeSnippet += `const unsignedTx = await txBuilder\n`;
codeSnippet += ` .mint("1", policyId, stringToHex("MeshToken"))\n`;
codeSnippet += ` .mintingScript(forgingScript)\n`;
diff --git a/apps/playground/src/pages/apis/txbuilder/common.tsx b/apps/playground/src/pages/apis/txbuilder/common.tsx
index 5d3d8830..b949cbf9 100644
--- a/apps/playground/src/pages/apis/txbuilder/common.tsx
+++ b/apps/playground/src/pages/apis/txbuilder/common.tsx
@@ -7,6 +7,7 @@ export function getTxBuilder() {
const txBuilder = new MeshTxBuilder({
fetcher: blockchainProvider,
evaluator: blockchainProvider,
+ verbose: true,
});
txBuilder.setNetwork("preprod");
return txBuilder;
diff --git a/package-lock.json b/package-lock.json
index c277b7ce..984b0b97 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -22364,7 +22364,7 @@
},
"packages/mesh-common": {
"name": "@meshsdk/common",
- "version": "1.6.14",
+ "version": "1.7.0",
"license": "Apache-2.0",
"dependencies": {
"bech32": "^2.0.0",
@@ -22381,14 +22381,14 @@
},
"packages/mesh-contract": {
"name": "@meshsdk/contract",
- "version": "1.6.14",
+ "version": "1.7.0",
"license": "Apache-2.0",
"dependencies": {
- "@meshsdk/common": "1.6.14",
- "@meshsdk/core": "1.6.14",
- "@meshsdk/core-csl": "1.6.14",
- "@meshsdk/core-cst": "1.6.14",
- "@meshsdk/transaction": "1.6.14"
+ "@meshsdk/common": "1.7.0",
+ "@meshsdk/core": "1.7.0",
+ "@meshsdk/core-csl": "1.7.0",
+ "@meshsdk/core-cst": "1.7.0",
+ "@meshsdk/transaction": "1.7.0"
},
"devDependencies": {
"@meshsdk/configs": "*",
@@ -22399,16 +22399,16 @@
},
"packages/mesh-core": {
"name": "@meshsdk/core",
- "version": "1.6.14",
+ "version": "1.7.0",
"license": "Apache-2.0",
"dependencies": {
- "@meshsdk/common": "1.6.14",
- "@meshsdk/core-csl": "1.6.14",
- "@meshsdk/core-cst": "1.6.14",
- "@meshsdk/provider": "1.6.14",
- "@meshsdk/react": "1.6.14",
- "@meshsdk/transaction": "1.6.14",
- "@meshsdk/wallet": "1.6.14"
+ "@meshsdk/common": "1.7.0",
+ "@meshsdk/core-csl": "1.7.0",
+ "@meshsdk/core-cst": "1.7.0",
+ "@meshsdk/provider": "1.7.0",
+ "@meshsdk/react": "1.7.0",
+ "@meshsdk/transaction": "1.7.0",
+ "@meshsdk/wallet": "1.7.0"
},
"devDependencies": {
"@meshsdk/configs": "*",
@@ -22419,10 +22419,10 @@
},
"packages/mesh-core-csl": {
"name": "@meshsdk/core-csl",
- "version": "1.6.14",
+ "version": "1.7.0",
"license": "Apache-2.0",
"dependencies": {
- "@meshsdk/common": "1.6.14",
+ "@meshsdk/common": "1.7.0",
"@sidan-lab/sidan-csl-rs-browser": "0.8.0",
"@sidan-lab/sidan-csl-rs-nodejs": "0.8.0",
"json-bigint": "^1.0.0"
@@ -22438,7 +22438,7 @@
},
"packages/mesh-core-cst": {
"name": "@meshsdk/core-cst",
- "version": "1.6.14",
+ "version": "1.7.0",
"license": "Apache-2.0",
"dependencies": {
"@cardano-sdk/core": "^0.35.4",
@@ -22447,7 +22447,7 @@
"@harmoniclabs/cbor": "1.3.0",
"@harmoniclabs/plutus-data": "1.2.4",
"@harmoniclabs/uplc": "1.2.4",
- "@meshsdk/common": "1.6.14",
+ "@meshsdk/common": "1.7.0",
"@stricahq/bip32ed25519": "^1.1.0",
"@stricahq/cbors": "^1.0.0",
"pbkdf2": "^3.1.2"
@@ -22464,11 +22464,11 @@
},
"packages/mesh-provider": {
"name": "@meshsdk/provider",
- "version": "1.6.14",
+ "version": "1.7.0",
"license": "Apache-2.0",
"dependencies": {
- "@meshsdk/common": "1.6.14",
- "@meshsdk/core-cst": "1.6.14",
+ "@meshsdk/common": "1.7.0",
+ "@meshsdk/core-cst": "1.7.0",
"axios": "^1.7.2"
},
"devDependencies": {
@@ -22480,12 +22480,12 @@
},
"packages/mesh-react": {
"name": "@meshsdk/react",
- "version": "1.6.14",
+ "version": "1.7.0",
"license": "Apache-2.0",
"dependencies": {
- "@meshsdk/common": "1.6.14",
- "@meshsdk/transaction": "1.6.14",
- "@meshsdk/wallet": "1.6.14",
+ "@meshsdk/common": "1.7.0",
+ "@meshsdk/transaction": "1.7.0",
+ "@meshsdk/wallet": "1.7.0",
"react": "^18.2.0"
},
"devDependencies": {
@@ -22500,12 +22500,12 @@
},
"packages/mesh-transaction": {
"name": "@meshsdk/transaction",
- "version": "1.6.14",
+ "version": "1.7.0",
"license": "Apache-2.0",
"dependencies": {
- "@meshsdk/common": "1.6.14",
- "@meshsdk/core-csl": "1.6.14",
- "@meshsdk/core-cst": "1.6.14",
+ "@meshsdk/common": "1.7.0",
+ "@meshsdk/core-csl": "1.7.0",
+ "@meshsdk/core-cst": "1.7.0",
"json-bigint": "^1.0.0"
},
"devDependencies": {
@@ -22518,13 +22518,13 @@
},
"packages/mesh-wallet": {
"name": "@meshsdk/wallet",
- "version": "1.6.14",
+ "version": "1.7.0",
"license": "Apache-2.0",
"dependencies": {
- "@meshsdk/common": "1.6.14",
- "@meshsdk/core-csl": "1.6.14",
- "@meshsdk/core-cst": "1.6.14",
- "@meshsdk/transaction": "1.6.14",
+ "@meshsdk/common": "1.7.0",
+ "@meshsdk/core-csl": "1.7.0",
+ "@meshsdk/core-cst": "1.7.0",
+ "@meshsdk/transaction": "1.7.0",
"@nufi/dapp-client-cardano": "^0.3.1",
"@nufi/dapp-client-core": "^0.3.1"
},
@@ -22538,7 +22538,7 @@
},
"scripts/mesh-cli": {
"name": "meshjs",
- "version": "1.6.14",
+ "version": "1.7.0",
"license": "Apache-2.0",
"dependencies": {
"chalk": "5.3.0",
diff --git a/packages/mesh-common/package.json b/packages/mesh-common/package.json
index 92ed88a4..f29dc276 100644
--- a/packages/mesh-common/package.json
+++ b/packages/mesh-common/package.json
@@ -1,6 +1,6 @@
{
"name": "@meshsdk/common",
- "version": "1.7.0",
+ "version": "1.7.1",
"description": "",
"main": "./dist/index.cjs",
"module": "./dist/index.js",
diff --git a/packages/mesh-common/src/types/transaction-builder/script.ts b/packages/mesh-common/src/types/transaction-builder/script.ts
index 97ac77a5..42dd80ef 100644
--- a/packages/mesh-common/src/types/transaction-builder/script.ts
+++ b/packages/mesh-common/src/types/transaction-builder/script.ts
@@ -24,4 +24,5 @@ export type SimpleScriptSourceInfo =
txHash: string;
txIndex: number;
simpleScriptHash?: string;
+ scriptSize?: string;
};
diff --git a/packages/mesh-common/src/types/transaction-builder/txin.ts b/packages/mesh-common/src/types/transaction-builder/txin.ts
index 81db7d33..ca0b170e 100644
--- a/packages/mesh-common/src/types/transaction-builder/txin.ts
+++ b/packages/mesh-common/src/types/transaction-builder/txin.ts
@@ -22,15 +22,7 @@ export type SimpleScriptTxIn = {
};
export type SimpleScriptTxInParameter = {
- scriptSource?:
- | {
- type: "Provided";
- script: string;
- }
- | {
- type: "Inline";
- txInInfo: SimpleScriptSourceInfo;
- };
+ scriptSource?: SimpleScriptSourceInfo;
};
export type ScriptTxInParameter = {
diff --git a/packages/mesh-contract/package.json b/packages/mesh-contract/package.json
index fb6d0586..8971ef90 100644
--- a/packages/mesh-contract/package.json
+++ b/packages/mesh-contract/package.json
@@ -1,6 +1,6 @@
{
"name": "@meshsdk/contract",
- "version": "1.7.0",
+ "version": "1.7.1",
"description": "",
"main": "./dist/index.cjs",
"module": "./dist/index.js",
@@ -33,11 +33,11 @@
"typescript": "^5.3.3"
},
"dependencies": {
- "@meshsdk/common": "1.7.0",
- "@meshsdk/core": "1.7.0",
- "@meshsdk/core-csl": "1.7.0",
- "@meshsdk/core-cst": "1.7.0",
- "@meshsdk/transaction": "1.7.0"
+ "@meshsdk/common": "1.7.1",
+ "@meshsdk/core": "1.7.1",
+ "@meshsdk/core-csl": "1.7.1",
+ "@meshsdk/core-cst": "1.7.1",
+ "@meshsdk/transaction": "1.7.1"
},
"prettier": "@meshsdk/configs/prettier",
"publishConfig": {
diff --git a/packages/mesh-core-csl/package.json b/packages/mesh-core-csl/package.json
index 5f6f49a6..11e47014 100644
--- a/packages/mesh-core-csl/package.json
+++ b/packages/mesh-core-csl/package.json
@@ -1,6 +1,6 @@
{
"name": "@meshsdk/core-csl",
- "version": "1.7.0",
+ "version": "1.7.1",
"description": "",
"main": "./dist/index.cjs",
"module": "./dist/index.js",
@@ -38,7 +38,7 @@
"typescript": "^5.3.3"
},
"dependencies": {
- "@meshsdk/common": "1.7.0",
+ "@meshsdk/common": "1.7.1",
"@sidan-lab/sidan-csl-rs-browser": "0.8.0",
"@sidan-lab/sidan-csl-rs-nodejs": "0.8.0",
"json-bigint": "^1.0.0"
diff --git a/packages/mesh-core-csl/src/core/adaptor/txIn.ts b/packages/mesh-core-csl/src/core/adaptor/txIn.ts
index a9d28ce5..57b0a202 100644
--- a/packages/mesh-core-csl/src/core/adaptor/txIn.ts
+++ b/packages/mesh-core-csl/src/core/adaptor/txIn.ts
@@ -1,4 +1,9 @@
-import { ScriptTxInParameter, TxIn, TxInParameter } from "@meshsdk/common";
+import {
+ ScriptTxInParameter,
+ SimpleScriptTxInParameter,
+ TxIn,
+ TxInParameter,
+} from "@meshsdk/common";
import { builderDataToCbor, redeemerToObj } from "./data";
import { scriptSourceToObj } from "./script";
@@ -21,8 +26,14 @@ export const txInToObj = (txIn: TxIn): object => {
};
case "SimpleScript":
- // Not implemented
- return {};
+ return {
+ simpleScriptTxIn: {
+ txIn: txInParameterToObj(txIn.txIn),
+ simpleScriptTxIn: simpleScriptTxInParameterToObj(
+ txIn.simpleScriptTxIn,
+ ),
+ },
+ };
}
};
@@ -79,3 +90,37 @@ export const scriptTxInParameterToObj = (
: null,
};
};
+
+export const simpleScriptTxInParameterToObj = (
+ simpleScriptTxInParameter: SimpleScriptTxInParameter,
+) => {
+ if (simpleScriptTxInParameter.scriptSource) {
+ let scriptSource: object | null = null;
+
+ switch (simpleScriptTxInParameter.scriptSource.type) {
+ case "Inline":
+ scriptSource = {
+ inlineSimpleScriptSource: {
+ refTxIn: {
+ txHash: simpleScriptTxInParameter.scriptSource.txHash,
+ txIndex: simpleScriptTxInParameter.scriptSource.txIndex,
+ },
+ simpleScriptHash:
+ simpleScriptTxInParameter.scriptSource.simpleScriptHash ?? "",
+ scriptSize: BigInt(
+ simpleScriptTxInParameter.scriptSource.scriptSize ?? "0",
+ ),
+ },
+ };
+ break;
+ case "Provided":
+ scriptSource = {
+ providedSimpleScriptSource: {
+ scriptCbor: simpleScriptTxInParameter.scriptSource.scriptCode,
+ },
+ };
+ break;
+ }
+ return scriptSource;
+ }
+};
diff --git a/packages/mesh-core-csl/src/utils/address.ts b/packages/mesh-core-csl/src/utils/address.ts
index c9c23bbc..f9c6cde1 100644
--- a/packages/mesh-core-csl/src/utils/address.ts
+++ b/packages/mesh-core-csl/src/utils/address.ts
@@ -35,8 +35,8 @@ export const serialzeAddress = (
);
const addressObj = isPaymentScript
- ? pubKeyAddress(paymentHash, stakeHash, isStakeScript)
- : scriptAddress(paymentHash, stakeHash, isStakeScript);
+ ? scriptAddress(paymentHash, stakeHash, isStakeScript)
+ : pubKeyAddress(paymentHash, stakeHash, isStakeScript);
return serializeAddressObj(addressObj, networkId);
};
diff --git a/packages/mesh-core-cst/package.json b/packages/mesh-core-cst/package.json
index c25426ad..d9a3aee8 100644
--- a/packages/mesh-core-cst/package.json
+++ b/packages/mesh-core-cst/package.json
@@ -1,6 +1,6 @@
{
"name": "@meshsdk/core-cst",
- "version": "1.7.0",
+ "version": "1.7.1",
"description": "",
"main": "./dist/index.cjs",
"module": "./dist/index.js",
@@ -41,7 +41,7 @@
"@harmoniclabs/cbor": "1.3.0",
"@harmoniclabs/plutus-data": "1.2.4",
"@harmoniclabs/uplc": "1.2.4",
- "@meshsdk/common": "1.7.0",
+ "@meshsdk/common": "1.7.1",
"@stricahq/bip32ed25519": "^1.1.0",
"@stricahq/cbors": "^1.0.0",
"pbkdf2": "^3.1.2"
diff --git a/packages/mesh-core-cst/src/serializer/index.ts b/packages/mesh-core-cst/src/serializer/index.ts
index 33ef9d1c..9a95f334 100644
--- a/packages/mesh-core-cst/src/serializer/index.ts
+++ b/packages/mesh-core-cst/src/serializer/index.ts
@@ -479,14 +479,11 @@ export class CardanoSDKSerializer implements IMeshTxSerializer {
this.scriptsProvided.add(
Script.newNativeScript(
NativeScript.fromCbor(
- HexBlob(currentTxIn.simpleScriptTxIn.scriptSource.script),
+ HexBlob(currentTxIn.simpleScriptTxIn.scriptSource.scriptCode),
),
),
);
- } else if (
- currentTxIn.simpleScriptTxIn.scriptSource.type === "Inline" &&
- currentTxIn.simpleScriptTxIn.scriptSource.txInInfo.type === "Inline" // This is weird, TODO: refactor types
- ) {
+ } else if (currentTxIn.simpleScriptTxIn.scriptSource.type === "Inline") {
let referenceInputs =
this.txBody.referenceInputs() ??
Serialization.CborSet.fromCore([], TransactionInput.fromCore);
@@ -495,10 +492,8 @@ export class CardanoSDKSerializer implements IMeshTxSerializer {
referenceInputsList.push(
new TransactionInput(
- TransactionId(
- currentTxIn.simpleScriptTxIn.scriptSource.txInInfo.txHash,
- ),
- BigInt(currentTxIn.simpleScriptTxIn.scriptSource.txInInfo.txIndex),
+ TransactionId(currentTxIn.simpleScriptTxIn.scriptSource.txHash),
+ BigInt(currentTxIn.simpleScriptTxIn.scriptSource.txIndex),
),
);
diff --git a/packages/mesh-core/package.json b/packages/mesh-core/package.json
index 3d1b4642..d1230947 100644
--- a/packages/mesh-core/package.json
+++ b/packages/mesh-core/package.json
@@ -1,6 +1,6 @@
{
"name": "@meshsdk/core",
- "version": "1.7.0",
+ "version": "1.7.1",
"description": "",
"main": "./dist/index.cjs",
"module": "./dist/index.js",
@@ -32,13 +32,13 @@
"typescript": "^5.3.3"
},
"dependencies": {
- "@meshsdk/common": "1.7.0",
- "@meshsdk/core-csl": "1.7.0",
- "@meshsdk/core-cst": "1.7.0",
- "@meshsdk/provider": "1.7.0",
- "@meshsdk/react": "1.7.0",
- "@meshsdk/transaction": "1.7.0",
- "@meshsdk/wallet": "1.7.0"
+ "@meshsdk/common": "1.7.1",
+ "@meshsdk/core-csl": "1.7.1",
+ "@meshsdk/core-cst": "1.7.1",
+ "@meshsdk/provider": "1.7.1",
+ "@meshsdk/react": "1.7.1",
+ "@meshsdk/transaction": "1.7.1",
+ "@meshsdk/wallet": "1.7.1"
},
"prettier": "@meshsdk/configs/prettier",
"publishConfig": {
diff --git a/packages/mesh-provider/package.json b/packages/mesh-provider/package.json
index 31ff9999..18b2d0e0 100644
--- a/packages/mesh-provider/package.json
+++ b/packages/mesh-provider/package.json
@@ -1,6 +1,6 @@
{
"name": "@meshsdk/provider",
- "version": "1.7.0",
+ "version": "1.7.1",
"description": "",
"main": "./dist/index.cjs",
"module": "./dist/index.js",
@@ -33,8 +33,8 @@
"typescript": "^5.3.3"
},
"dependencies": {
- "@meshsdk/common": "1.7.0",
- "@meshsdk/core-cst": "1.7.0",
+ "@meshsdk/common": "1.7.1",
+ "@meshsdk/core-cst": "1.7.1",
"axios": "^1.7.2"
},
"prettier": "@meshsdk/configs/prettier",
diff --git a/packages/mesh-react/package.json b/packages/mesh-react/package.json
index 5cd6c872..c9cfea36 100644
--- a/packages/mesh-react/package.json
+++ b/packages/mesh-react/package.json
@@ -1,6 +1,6 @@
{
"name": "@meshsdk/react",
- "version": "1.7.0",
+ "version": "1.7.1",
"description": "",
"main": "./dist/index.cjs",
"module": "./dist/index.js",
@@ -29,9 +29,9 @@
},
"dependencies": {
"react": "^18.2.0",
- "@meshsdk/common": "1.7.0",
- "@meshsdk/transaction": "1.7.0",
- "@meshsdk/wallet": "1.7.0"
+ "@meshsdk/common": "1.7.1",
+ "@meshsdk/transaction": "1.7.1",
+ "@meshsdk/wallet": "1.7.1"
},
"devDependencies": {
"@meshsdk/configs": "*",
diff --git a/packages/mesh-transaction/package.json b/packages/mesh-transaction/package.json
index 94e33376..2a29a40d 100644
--- a/packages/mesh-transaction/package.json
+++ b/packages/mesh-transaction/package.json
@@ -1,6 +1,6 @@
{
"name": "@meshsdk/transaction",
- "version": "1.7.0",
+ "version": "1.7.1",
"description": "",
"main": "./dist/index.cjs",
"module": "./dist/index.js",
@@ -34,9 +34,9 @@
"typescript": "^5.3.3"
},
"dependencies": {
- "@meshsdk/common": "1.7.0",
- "@meshsdk/core-csl": "1.7.0",
- "@meshsdk/core-cst": "1.7.0",
+ "@meshsdk/common": "1.7.1",
+ "@meshsdk/core-csl": "1.7.1",
+ "@meshsdk/core-cst": "1.7.1",
"json-bigint": "^1.0.0"
},
"prettier": "@meshsdk/configs/prettier",
diff --git a/packages/mesh-transaction/src/mesh-tx-builder/index.ts b/packages/mesh-transaction/src/mesh-tx-builder/index.ts
index f9011421..e02aea58 100644
--- a/packages/mesh-transaction/src/mesh-tx-builder/index.ts
+++ b/packages/mesh-transaction/src/mesh-tx-builder/index.ts
@@ -7,7 +7,6 @@ import {
MintItem,
Protocol,
ScriptSource,
- ScriptTxIn,
SimpleScriptSourceInfo,
TxIn,
UTxO,
diff --git a/packages/mesh-transaction/src/mesh-tx-builder/tx-builder-core.ts b/packages/mesh-transaction/src/mesh-tx-builder/tx-builder-core.ts
index ccd9032f..a2b2c766 100644
--- a/packages/mesh-transaction/src/mesh-tx-builder/tx-builder-core.ts
+++ b/packages/mesh-transaction/src/mesh-tx-builder/tx-builder-core.ts
@@ -115,7 +115,7 @@ export class MeshTxBuilderCore {
simpleScriptTxIn: {
scriptSource: {
type: "Provided",
- script: scriptCbor,
+ scriptCode: scriptCbor,
},
},
};
@@ -199,33 +199,47 @@ export class MeshTxBuilderCore {
return this;
};
- // /**
- // * Native script - Set the reference input where it would also be spent in the transaction
- // * @param txHash The transaction hash of the reference UTxO
- // * @param txIndex The transaction index of the reference UTxO
- // * @param spendingScriptHash The script hash of the spending script
- // * @returns The MeshTxBuilder instance
- // */
- // simpleScriptTxInReference = (
- // txHash: string,
- // txIndex: number,
- // spendingScriptHash?: string
- // ) => {
- // if (!this.txInQueueItem) throw Error('Undefined input');
- // if (this.txInQueueItem.type === 'PubKey')
- // throw Error(
- // 'Spending tx in reference attempted to be called a non script input'
- // );
- // this.txInQueueItem.scriptTxIn.scriptSource = {
- // type: 'Inline',
- // txInInfo: {
- // txHash,
- // txIndex,
- // spendingScriptHash,
- // },
- // };
- // return this;
- // };
+ /**
+ * Native script - Set the reference input where it would also be spent in the transaction
+ * @param txHash The transaction hash of the reference UTxO
+ * @param txIndex The transaction index of the reference UTxO
+ * @param spendingScriptHash The script hash of the spending script
+ * @returns The MeshTxBuilder instance
+ */
+ simpleScriptTxInReference = (
+ txHash: string,
+ txIndex: number,
+ spendingScriptHash?: string,
+ scriptSize?: string,
+ ) => {
+ if (!this.txInQueueItem) throw Error("Undefined input");
+ if (this.txInQueueItem.type === "Script") {
+ throw Error(
+ "simpleScriptTxInReference called on a plutus script, use spendingTxInReference instead",
+ );
+ }
+ if (this.txInQueueItem.type === "SimpleScript") {
+ throw Error(
+ "simpleScriptTxInReference called on a native script input that already has a script defined",
+ );
+ }
+ if (this.txInQueueItem.type === "PubKey") {
+ this.txInQueueItem = {
+ type: "SimpleScript",
+ txIn: this.txInQueueItem.txIn,
+ simpleScriptTxIn: {
+ scriptSource: {
+ type: "Inline",
+ txHash,
+ txIndex,
+ simpleScriptHash: spendingScriptHash,
+ scriptSize,
+ },
+ },
+ };
+ }
+ return this;
+ };
/**
* Set the redeemer for the reference input to be spent in same transaction
diff --git a/packages/mesh-transaction/test/mesh-tx-builder/tx.test.ts b/packages/mesh-transaction/test/mesh-tx-builder/tx.test.ts
index 8361843b..6917eb1c 100644
--- a/packages/mesh-transaction/test/mesh-tx-builder/tx.test.ts
+++ b/packages/mesh-transaction/test/mesh-tx-builder/tx.test.ts
@@ -1,8 +1,9 @@
+import { resolveNativeScriptHash, resolveNativeScriptHex } from "@meshsdk/core";
import { MeshTxBuilder } from "@meshsdk/transaction";
describe("MeshTxBuilder transactions", () => {
it("Adding embedded datum should produce correct tx cbor", () => {
- let mesh = new MeshTxBuilder({ verbose: true });
+ let mesh = new MeshTxBuilder();
let txHex = mesh
.txIn(
@@ -27,6 +28,77 @@ describe("MeshTxBuilder transactions", () => {
)
.completeSync();
- expect(txHex).toBe("84a400818258202cb57168ee66b68bd04a0d595060b546edf30c04ae1031b883c9ac797967dd8503018283581d60f95cab9352c14782a366802b7967746a89356e8915c17006149ff68c1a001e84805820923918e403bf43c34b4ef6b48eb2ee04babed17320d8d1b9ff9ad086e86f44ec82581d60f95cab9352c14782a366802b7967746a89356e8915c17006149ff68c1b000000024d74dc6e021a000294690b582015dd0a3ac1244430aacc7e95c2734b51f1a8cf2aaf05e5d6e8124cb78ab54cc9a1049fd87980fff5f6");
+ expect(txHex !== "").toBeTruthy();
+ });
+
+ it("Build tx of spending native script should succeed", () => {
+ let mesh = new MeshTxBuilder();
+
+ let txHex = mesh
+ .txIn(
+ "2cb57168ee66b68bd04a0d595060b546edf30c04ae1031b883c9ac797967dd85",
+ 3,
+ [{ unit: "lovelace", quantity: "9891607895" }],
+ "addr_test1vru4e2un2tq50q4rv6qzk7t8w34gjdtw3y2uzuqxzj0ldrqqactxh",
+ )
+ .txInScript(
+ resolveNativeScriptHex({
+ type: "all",
+ scripts: [
+ {
+ type: "after",
+ slot: "1",
+ },
+ ],
+ }),
+ )
+ .txOut(
+ "addr_test1vru4e2un2tq50q4rv6qzk7t8w34gjdtw3y2uzuqxzj0ldrqqactxh",
+ [{ unit: "lovelace", quantity: "2000000" }],
+ )
+ .changeAddress(
+ "addr_test1vru4e2un2tq50q4rv6qzk7t8w34gjdtw3y2uzuqxzj0ldrqqactxh",
+ )
+ .setNetwork("preprod")
+ .completeSync();
+
+ expect(txHex !== "").toBeTruthy();
+ });
+
+ it("Build tx of spending native script with ref should succeed", () => {
+ let mesh = new MeshTxBuilder();
+
+ let txHex = mesh
+ .txIn(
+ "2cb57168ee66b68bd04a0d595060b546edf30c04ae1031b883c9ac797967dd85",
+ 3,
+ [{ unit: "lovelace", quantity: "9891607895" }],
+ "addr_test1vru4e2un2tq50q4rv6qzk7t8w34gjdtw3y2uzuqxzj0ldrqqactxh",
+ )
+ .simpleScriptTxInReference(
+ "2cb57168ee66b68bd04a0d595060b546edf30c04ae1031b883c9ac797967dd85",
+ 1,
+ resolveNativeScriptHash({
+ type: "all",
+ scripts: [
+ {
+ type: "after",
+ slot: "1",
+ },
+ ],
+ }),
+ "1000",
+ )
+ .txOut(
+ "addr_test1vru4e2un2tq50q4rv6qzk7t8w34gjdtw3y2uzuqxzj0ldrqqactxh",
+ [{ unit: "lovelace", quantity: "2000000" }],
+ )
+ .changeAddress(
+ "addr_test1vru4e2un2tq50q4rv6qzk7t8w34gjdtw3y2uzuqxzj0ldrqqactxh",
+ )
+ .setNetwork("preprod")
+ .completeSync();
+
+ expect(txHex !== "").toBeTruthy();
});
});
diff --git a/packages/mesh-wallet/package.json b/packages/mesh-wallet/package.json
index 61cc80a0..fb7b478e 100644
--- a/packages/mesh-wallet/package.json
+++ b/packages/mesh-wallet/package.json
@@ -1,6 +1,6 @@
{
"name": "@meshsdk/wallet",
- "version": "1.7.0",
+ "version": "1.7.1",
"description": "",
"main": "./dist/index.cjs",
"module": "./dist/index.js",
@@ -34,10 +34,10 @@
"typescript": "^5.3.3"
},
"dependencies": {
- "@meshsdk/common": "1.7.0",
- "@meshsdk/core-csl": "1.7.0",
- "@meshsdk/core-cst": "1.7.0",
- "@meshsdk/transaction": "1.7.0",
+ "@meshsdk/common": "1.7.1",
+ "@meshsdk/core-csl": "1.7.1",
+ "@meshsdk/core-cst": "1.7.1",
+ "@meshsdk/transaction": "1.7.1",
"@nufi/dapp-client-cardano": "^0.3.1",
"@nufi/dapp-client-core": "^0.3.1"
},
diff --git a/packages/mesh-wallet/src/browser/index.ts b/packages/mesh-wallet/src/browser/index.ts
index e618b2e7..b3f74359 100644
--- a/packages/mesh-wallet/src/browser/index.ts
+++ b/packages/mesh-wallet/src/browser/index.ts
@@ -12,6 +12,7 @@ import {
UTxO,
Wallet,
} from "@meshsdk/common";
+import { csl } from "@meshsdk/core-csl";
import {
Address,
addressToBech32,
@@ -473,16 +474,18 @@ export class BrowserWallet implements IInitiator, ISigner, ISubmitter {
if (this._walletInstance.cip95 === undefined) return undefined;
const dRepKey = await this._walletInstance.cip95.getPubDRepKey();
- const { dRepKeyHex, dRepIDHash } =
- await BrowserWallet.dRepKeyToDRepID(dRepKey);
+ const { dRepIDHash } = await BrowserWallet.dRepKeyToDRepID(dRepKey);
- const networkId = await this.getNetworkId();
- const dRepId = buildDRepID(dRepKeyHex, networkId);
+ // const networkId = await this.getNetworkId();
+ // const dRepId = buildDRepID(dRepKey, networkId); // todo: this is not correct
+
+ const csldRepIdKeyHash = csl.PublicKey.from_hex(dRepKey).hash();
+ const dRepId = csldRepIdKeyHash.to_bech32("drep");
return {
pubDRepKey: dRepKey,
dRepIDHash: dRepIDHash,
- dRepIDBech32: dRepId, // todo to check
+ dRepIDBech32: dRepId,
};
} catch (e) {
console.error(e);
diff --git a/scripts/mesh-cli/package.json b/scripts/mesh-cli/package.json
index f8c2225d..f9dbbce0 100644
--- a/scripts/mesh-cli/package.json
+++ b/scripts/mesh-cli/package.json
@@ -3,7 +3,7 @@
"description": "A quick and easy way to bootstrap your dApps on Cardano using Mesh.",
"homepage": "https://meshjs.dev",
"author": "MeshJS",
- "version": "1.7.0",
+ "version": "1.7.1",
"license": "Apache-2.0",
"type": "module",
"main": "./dist/index.cjs",