From e30008b36765f1dc86c6fe7d7b70b14bd773efb2 Mon Sep 17 00:00:00 2001 From: "Hong Jing (Jingles)" Date: Fri, 15 Nov 2024 18:29:21 +0800 Subject: [PATCH] update guide --- .../apis/wallets/browserwallet/sign-data.tsx | 1 - apps/playground/src/pages/governance/index.mdx | 4 ---- .../guides/prove-wallet-ownership/demo.tsx | 17 +++++++++++++++-- .../guides/prove-wallet-ownership/index.mdx | 18 +++++++----------- 4 files changed, 22 insertions(+), 18 deletions(-) diff --git a/apps/playground/src/pages/apis/wallets/browserwallet/sign-data.tsx b/apps/playground/src/pages/apis/wallets/browserwallet/sign-data.tsx index 52fd07428..0372b1c07 100644 --- a/apps/playground/src/pages/apis/wallets/browserwallet/sign-data.tsx +++ b/apps/playground/src/pages/apis/wallets/browserwallet/sign-data.tsx @@ -1,6 +1,5 @@ import { useState } from "react"; -import { checkSignature } from "@meshsdk/core"; import { useWallet } from "@meshsdk/react"; import Input from "~/components/form/input"; diff --git a/apps/playground/src/pages/governance/index.mdx b/apps/playground/src/pages/governance/index.mdx index cb10eaafd..755461ad5 100644 --- a/apps/playground/src/pages/governance/index.mdx +++ b/apps/playground/src/pages/governance/index.mdx @@ -1,8 +1,4 @@ import { useState } from "react"; - -import { checkSignature, generateNonce } from "@meshsdk/core"; -import { CardanoWallet, useWallet } from "@meshsdk/react"; - import Button from "~/components/button/button"; import LayoutImageHeaderAndBody from "~/components/layouts/image-header-and-body"; diff --git a/apps/playground/src/pages/guides/prove-wallet-ownership/demo.tsx b/apps/playground/src/pages/guides/prove-wallet-ownership/demo.tsx index 43da0d2aa..7b0a32fdb 100644 --- a/apps/playground/src/pages/guides/prove-wallet-ownership/demo.tsx +++ b/apps/playground/src/pages/guides/prove-wallet-ownership/demo.tsx @@ -5,6 +5,7 @@ import { CardanoWallet, useWallet } from "@meshsdk/react"; import Button from "~/components/button/button"; import DemoResult from "~/components/sections/demo-result"; +import Codeblock from "~/components/text/codeblock"; export default function Demo() { const { wallet, connected } = useWallet(); @@ -16,15 +17,27 @@ export default function Demo() { setLoading(true); const nonce = generateNonce("Sign to login in to Mesh: "); - const signature = await wallet.signData(nonce); + const address = (await wallet.getUsedAddresses())[0]; + const signature = await wallet.signData(nonce, address); - const result = checkSignature(nonce, signature); + const result = checkSignature(nonce, signature, address); setResponse(result.toString()); setLoading(false); } + let code = ``; + code += `import { checkSignature, generateNonce } from "@meshsdk/core";\n`; + code += `\n`; + code += `const nonce = generateNonce("Sign to login in to Mesh: ");\n`; + code += `\n`; + code += `const address = (await wallet.getUsedAddresses())[0];\n`; + code += `const signature = await wallet.signData(nonce, address);\n`; + code += `\n`; + code += `const result = checkSignature(nonce, signature, address);\n`; + return ( <> +

Connect your wallet and click on the button to sign a message.