Skip to content

Commit

Permalink
docs: add vesting tutorial and init serializer
Browse files Browse the repository at this point in the history
  • Loading branch information
jinglescode committed Aug 20, 2024
1 parent 116d279 commit 61edb5d
Show file tree
Hide file tree
Showing 7 changed files with 528 additions and 73 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import SidebarFullwidth from "~/components/layouts/sidebar-fullwidth";
import TitleIconDescriptionBody from "~/components/sections/title-icon-description-body";
import Metatags from "~/components/site/metatags";
import { metaSerializers } from "~/data/links-utilities";
import SerializeNativeScript from "./serialize-native-script";

const ReactPage: NextPage = () => {
const sidebarItems = [{ label: "Coming soon", to: "resolveDataHash" }];
Expand All @@ -22,6 +23,8 @@ const ReactPage: NextPage = () => {
>
<></>
</TitleIconDescriptionBody>

<SerializeNativeScript />
</SidebarFullwidth>
</>
);
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
import {
deserializeAddress,
NativeScript,
serializeNativeScript,
} from "@meshsdk/core";

import LiveCodeDemo from "~/components/sections/live-code-demo";
import TwoColumnsScroll from "~/components/sections/two-columns-scroll";
import { demoAddresses } from "~/data/cardano";

export default function SerializeNativeScript() {
return (
<TwoColumnsScroll
sidebarTo="serializeNativeScript"
title="Serialize Native Script"
leftSection={Left()}
rightSection={Right()}
/>
);
}

function Left() {
return (
<>
<p>Serialize Native script into bech32 address.</p>
</>
);
}

function Right() {
async function runDemo() {
const { pubKeyHash: keyHash } = deserializeAddress(
demoAddresses.testnetPayment,
);

const nativeScript: NativeScript = {
type: "all",
scripts: [
{
type: "before",
slot: "99999999",
},
{
type: "sig",
keyHash: keyHash,
},
],
};

const address = serializeNativeScript(nativeScript);

return address;
}

let codeSnippet = ``;

return (
<LiveCodeDemo
title="Serialize Native Script"
subtitle="Serialize Native script into bech32 address"
code={codeSnippet}
runCodeFunction={runDemo}
></LiveCodeDemo>
);
}
Loading

0 comments on commit 61edb5d

Please sign in to comment.