Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add multi asset docs and fund13 #332

Merged
merged 1 commit into from
Oct 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
88 changes: 83 additions & 5 deletions apps/playground/src/data/catalyst.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,85 @@ export const metaCatalyst = {
icon: LightBulbIcon,
};

export const fund13 = [
{
title: "Hydra Tools for administrating & interacting with Hydra Heads",
desc: "Provide all the tools needed to integration Hydra on apps, to enable end-user operations like interacting with wallet, query UTXOs/balance and submit transactions.",
url: "https://cardano.ideascale.com/c/idea/130856",
completed: [],
tobecompleted: [
`Hydra Provider`,
`Wallets integration`,
`Transaction building`,
`End-to-end working example`,
],
status: "Voting",
},
{
title: "Cardano Devkit - 'Ganache' for better devxp",
desc: "An app to launch local blockchain to test and deploy transactions and smart contracts, to run tests and experiments to develop Cardano applications.",
url: "https://cardano.ideascale.com/c/idea/130825",
completed: [],
tobecompleted: [
`Improve devnet deployment`,
`Desktop app to launch local blockchain`,
`Show UTXOs and balances`,
],
status: "Voting",
},
{
title: "Cquisitor - Transaction Investigation Tool",
desc: "Enhancing Devtools with hosted Rust-based validation modules, and improving error handling to provide clearer feedback, helping developers debug and validate efficiently.",
url: "https://cardano.ideascale.com/c/idea/131631",
completed: [],
tobecompleted: [
`Update Cquisitor`,
`Phase-1 validation`,
`Phase-2 validation`,
`Integration with Whisky and Mesh`,
],
status: "Voting",
},
{
title: "Multisig Platform",
desc: "Open source multisig platform for teams and organizations to manage their treasury and participate in governance.",
url: "https://cardano.ideascale.com/c/idea/131036",
completed: [],
tobecompleted: [
`Full governance features`,
`Native tokens support`,
`Discord integrations`,
`Fluidtokens and Minswap integrations`,
`Plutus script multisig wallet`,
],
status: "Voting",
},
{
title: "Builder Fest #2 in Asia",
desc: "Hosting Buidler Fest #2, a 2-day event for tech-savvy Cardano builders to connect, showcase and share.",
url: "https://cardano.ideascale.com/c/idea/131981",
completed: [],
tobecompleted: [
`Gathering of developers in Vietnam`,
`Increase collaboration between projects for Cardano ecosystem open-source`,
],
status: "Voting",
},
{
title: "Maintain Mesh and Build Developer Community",
desc: "Maintenance and operations of the Mesh open source libraries and tool suits. Growing Cardano developer community.",
url: "https://cardano.ideascale.com/c/idea/131363",
completed: [],
tobecompleted: [
`Provide community support`,
`Resolve GitHub issues`,
`Create tutorials and documentation`,
`Create workshops and live coding sessions`,
],
status: "Voting",
},
];

export const fund12 = [
{
title: "Cardano Service Layer Framework for DApps",
Expand All @@ -24,8 +103,7 @@ export const fund12 = [
status: "In Progress",
},
{
title:
"Mesh New Features to Improve Developer experience and Cardano Adoption",
title: "New Features to Improve Developer experience and Adoption",
desc: "We will upgrade Mesh by implementing CIP 45, WebRTC wallet connect, handle multiple serialization libs, revamp to support backend transactions building, and improve error messages to improve DevXP.",
url: "https://cardano.ideascale.com/c/idea/122160",
completed: [
Expand Down Expand Up @@ -60,7 +138,7 @@ export const fund12 = [
`Create workshops and live coding sessions`,
],
tobecompleted: [],
status: "In Progress",
status: "Closing",
},
];

Expand Down Expand Up @@ -100,7 +178,7 @@ export const fund11 = [
"Conway features",
],
tobecompleted: [],
status: "In Progress",
status: "Closing",
},
];

Expand All @@ -119,6 +197,6 @@ export const fund10 = [
"Mesh PBL Season #1",
],
tobecompleted: ["Student projects"],
status: "In Progress",
status: "Closing",
},
];
5 changes: 3 additions & 2 deletions apps/playground/src/pages/about/catalyst/index.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import type { NextPage } from "next";
import Link from "~/components/link";

import HeaderAndCards from "~/components/layouts/header-and-cards";
import Link from "~/components/link";
import Metatags from "~/components/site/metatags";
import Header3 from "~/components/text/header3";
import { fund10, fund11, fund12, metaCatalyst } from "~/data/catalyst";
import { fund10, fund11, fund12, fund13, metaCatalyst } from "~/data/catalyst";

const ReactPage: NextPage = () => {
return (
Expand All @@ -14,6 +14,7 @@ const ReactPage: NextPage = () => {
headerTitle={metaCatalyst.title}
headerParagraph={metaCatalyst.desc}
/>
<Section title="Fund 13" items={fund13} />
<Section title="Fund 12" items={fund12} />
<Section title="Fund 11" items={fund11} />
<Section title="Fund 10" items={fund10} />
Expand Down
3 changes: 3 additions & 0 deletions apps/playground/src/pages/apis/txbuilder/minting/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,12 @@ import TxbuilderMintingNativeScript from "./minting-native-script";
import TxbuilderMintAsset from "./minting-one-signature";
import TxbuilderMintingPlutusScript from "./minting-plutus-script";
import TxbuilderMintingRoyaltyToken from "./minting-royalty-token";
import TxbuilderMintMultipleAssets from "./multiple-assets";

const ReactPage: NextPage = () => {
const sidebarItems = [
{ label: "Mint with One Signature", to: "mintingOneSignature" },
{ label: "Mint Multiple Assets", to: "mintingMultipleAssets" },
{ label: "Burn asset", to: "burningOneSignature" },
{ label: "Mint with Native Script", to: "mintingNativeScript" },
{ label: "Mint with Plutus Script", to: "mintingPlutusScript" },
Expand Down Expand Up @@ -51,6 +53,7 @@ const ReactPage: NextPage = () => {
<ButtonFloatDocumentation href="https://docs.meshjs.dev/transactions/classes/MeshTxBuilder" />

<TxbuilderMintAsset />
<TxbuilderMintMultipleAssets />
<TxbuilderBurningOneSignature />
<TxbuilderMintingNativeScript />
<TxbuilderMintingPlutusScript />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import Link from "~/components/link";

import {
AssetMetadata,
cst,
Expand All @@ -12,6 +10,7 @@ import {
} from "@meshsdk/core";
import { useWallet } from "@meshsdk/react";

import Link from "~/components/link";
import LiveCodeDemo from "~/components/sections/live-code-demo";
import TwoColumnsScroll from "~/components/sections/two-columns-scroll";
import Codeblock from "~/components/text/codeblock";
Expand Down Expand Up @@ -97,7 +96,6 @@ function Right() {

const signedTx = await wallet.signTx(unsignedTx);
const txHash = await wallet.submitTx(signedTx);

return txHash;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,7 @@
import Link from "~/components/link";

import {
cst,
ForgeScript,
resolveScriptHash,
stringToHex,
} from "@meshsdk/core";
import { ForgeScript, resolveScriptHash, stringToHex } from "@meshsdk/core";
import { useWallet } from "@meshsdk/react";

import Link from "~/components/link";
import LiveCodeDemo from "~/components/sections/live-code-demo";
import TwoColumnsScroll from "~/components/sections/two-columns-scroll";
import Codeblock from "~/components/text/codeblock";
Expand Down Expand Up @@ -128,10 +122,11 @@ function Right() {
codeSnippet += `const metadata = { [policyId]: { [tokenName]: { ...demoAssetMetadata } } };\n`;
codeSnippet += `\n`;
codeSnippet += `const unsignedTx = await txBuilder\n`;
codeSnippet += ` .txIn(utxo.input.txHash, utxo.input.outputIndex)\n`;
codeSnippet += ` .mint("1", policyId, tokenName)\n`;
codeSnippet += ` .mint("1", policyId, tokenNameHex)\n`;
codeSnippet += ` .mintingScript(forgingScript)\n`;
codeSnippet += ` .metadataValue("721", metadata)\n`;
codeSnippet += ` .changeAddress(changeAddress)\n`;
codeSnippet += ` .selectUtxosFrom(utxos)\n`;
codeSnippet += ` .complete();\n`;
codeSnippet += `\n`;
codeSnippet += `const signedTx = await wallet.signTx(unsignedTx);\n`;
Expand Down
149 changes: 149 additions & 0 deletions apps/playground/src/pages/apis/txbuilder/minting/multiple-assets.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
import { ForgeScript, resolveScriptHash, stringToHex } from "@meshsdk/core";
import { useWallet } from "@meshsdk/react";

import LiveCodeDemo from "~/components/sections/live-code-demo";
import TwoColumnsScroll from "~/components/sections/two-columns-scroll";
import Codeblock from "~/components/text/codeblock";
import { demoAssetMetadata } from "~/data/cardano";
import { getTxBuilder } from "../common";

export default function TxbuilderMintMultipleAssets() {
return (
<TwoColumnsScroll
sidebarTo="mintingMultipleAssets"
title="Minting Multiple Assets"
leftSection={Left()}
rightSection={Right()}
/>
);
}

function Left() {
let codeSnippet1 = ``;
codeSnippet1 += `const metadata = {};\n`;
codeSnippet1 += `metadata[policyId] = {};\n`;
codeSnippet1 += `for (let i = 1; i < 3; i++) {\n`;
codeSnippet1 += " const tokenName = `MeshToken${i}`;\n";
codeSnippet1 += ` const tokenNameHex = stringToHex(tokenName);\n`;
codeSnippet1 += ` metadata[policyId][tokenName] = {\n`;
codeSnippet1 += ` ...demoAssetMetadata,\n`;
codeSnippet1 += ` name: tokenName,\n`;
codeSnippet1 += ` };\n`;
codeSnippet1 += ` txBuilder.mint("1", policyId, tokenNameHex);\n`;
codeSnippet1 += ` txBuilder.mintingScript(forgingScript);\n`;
codeSnippet1 += `}\n`;

let codeSnippet2 = ``;
codeSnippet2 += `txBuilder\n`;
codeSnippet2 += ` .metadataValue("721", metadata)\n`;
codeSnippet2 += ` .changeAddress(changeAddress)\n`;
codeSnippet2 += ` .selectUtxosFrom(utxos);\n`;
codeSnippet2 += `\n`;
codeSnippet2 += `const unsignedTx = await txBuilder.complete();\n`;
codeSnippet2 += `const signedTx = await wallet.signTx(unsignedTx);\n`;
codeSnippet2 += `const txHash = await wallet.submitTx(signedTx);\n`;

return (
<>
<p>
Minting multiple assets with a single transaction is a common operation
in blockchain applications. Like minting single assets, you can mint
multiple assets by calling <code>mint()</code> and{" "}
<code>mintingScript</code> multiple times.
</p>
<Codeblock data={codeSnippet1} />
<p>
You appending the metadata into one object and pass it to{" "}
<code>metadataValue()</code> method.
</p>
<Codeblock data={codeSnippet2} />
</>
);
}

function Right() {
const { wallet, connected } = useWallet();

async function runDemo() {
const utxos = await wallet.getUtxos();

const changeAddress = await wallet.getChangeAddress();
const forgingScript = ForgeScript.withOneSignature(changeAddress);

const policyId = resolveScriptHash(forgingScript);

const txBuilder = getTxBuilder();

const metadata = {};
metadata[policyId] = {};
for (let i = 1; i < 3; i++) {
const tokenName = `MeshToken${i}`;
const tokenNameHex = stringToHex(tokenName);
metadata[policyId][tokenName] = {
...demoAssetMetadata,
name: tokenName,
};
txBuilder.mint("1", policyId, tokenNameHex);
txBuilder.mintingScript(forgingScript);
}

txBuilder
.metadataValue("721", metadata)
.changeAddress(changeAddress)
.selectUtxosFrom(utxos);

const unsignedTx = await txBuilder.complete();
const signedTx = await wallet.signTx(unsignedTx);
const txHash = await wallet.submitTx(signedTx);
return txHash;
}

let codeSnippet = `import { MeshTxBuilder, ForgeScript, resolveScriptHash, stringToHex } from '@meshsdk/core';\n`;
codeSnippet += `import type { Asset } from '@meshsdk/core';\n`;
codeSnippet += `\n`;
codeSnippet += `const { wallet, connected } = useWallet();\n`;
codeSnippet += `\n`;
codeSnippet += `const utxos = await wallet.getUtxos();\n`;
codeSnippet += `const changeAddress = await wallet.getChangeAddress();\n`;
codeSnippet += `const forgingScript = ForgeScript.withOneSignature(changeAddress);\n`;
codeSnippet += `\n`;
codeSnippet += `const policyId = resolveScriptHash(forgingScript);\n`;
codeSnippet += `\n`;
codeSnippet += `const txBuilder = getTxBuilder();\n`;
codeSnippet += `\n`;
codeSnippet += `const metadata = {};\n`;
codeSnippet += `metadata[policyId] = {};\n`;
codeSnippet += `for (let i = 1; i < 3; i++) {\n`;
codeSnippet += " const tokenName = `MeshToken${i}`;\n";
codeSnippet += ` const tokenNameHex = stringToHex(tokenName);\n`;
codeSnippet += ` metadata[policyId][tokenName] = {\n`;
codeSnippet += ` ...demoAssetMetadata,\n`;
codeSnippet += ` name: tokenName,\n`;
codeSnippet += ` };\n`;
codeSnippet += ` txBuilder.mint("1", policyId, tokenNameHex);\n`;
codeSnippet += ` txBuilder.mintingScript(forgingScript);\n`;
codeSnippet += `}\n`;
codeSnippet += `\n`;
codeSnippet += `txBuilder\n`;
codeSnippet += ` .metadataValue("721", metadata)\n`;
codeSnippet += ` .changeAddress(changeAddress)\n`;
codeSnippet += ` .selectUtxosFrom(utxos);\n`;
codeSnippet += `\n`;
codeSnippet += `const unsignedTx = await txBuilder.complete();\n`;
codeSnippet += `const signedTx = await wallet.signTx(unsignedTx);\n`;
codeSnippet += `const txHash = await wallet.submitTx(signedTx);\n`;

return (
<LiveCodeDemo
title="Mint Multiple Assets"
subtitle="Mint multiple assets with a single transaction"
code={codeSnippet}
runCodeFunction={runDemo}
disabled={!connected}
runDemoButtonTooltip={
!connected ? "Connect wallet to run this demo" : undefined
}
runDemoShowBrowseWalletConnect={true}
></LiveCodeDemo>
);
}