From cbfa55fe7492781a2106a14cff296031e5c93066 Mon Sep 17 00:00:00 2001 From: ian Date: Wed, 10 Jan 2024 01:32:41 +0800 Subject: [PATCH] :sparkles: Show lock script name Also link to the explorer script page. --- .../u/[wallet]/[connection]/account-header.js | 9 ++- src/app/u/[wallet]/[connection]/sign-out.js | 65 +++++++++++++++++-- 2 files changed, 64 insertions(+), 10 deletions(-) diff --git a/src/app/u/[wallet]/[connection]/account-header.js b/src/app/u/[wallet]/[connection]/account-header.js index a2e08b1..70e359d 100644 --- a/src/app/u/[wallet]/[connection]/account-header.js +++ b/src/app/u/[wallet]/[connection]/account-header.js @@ -1,19 +1,18 @@ -import * as walletSelector from "@/lib/wallet/selector"; import SignOut from "./sign-out"; export default function AccountHeader({ address, wallet, connection, - config: { ckbChain }, + config: { ckbChain, ckbChainConfig }, }) { - const walletName = walletSelector.walletName(wallet); - return (

diff --git a/src/app/u/[wallet]/[connection]/sign-out.js b/src/app/u/[wallet]/[connection]/sign-out.js index fbec64c..2fba335 100644 --- a/src/app/u/[wallet]/[connection]/sign-out.js +++ b/src/app/u/[wallet]/[connection]/sign-out.js @@ -1,16 +1,71 @@ "use client"; -import { useRouter } from "next/navigation"; +import * as walletSelector from "@/lib/wallet/selector"; import { Dropdown } from "flowbite-react"; +import { useRouter } from "next/navigation"; +import * as lumosHelpers from "@ckb-lumos/helpers"; + +export function LockScriptName({ lockScriptName, address, ckbChainConfig }) { + if ( + ckbChainConfig.EXPLORER_URL !== null && + ckbChainConfig.EXPLORER_URL !== undefined + ) { + const script = lumosHelpers.addressToScript(address, { + config: ckbChainConfig, + }); + const href = `${ckbChainConfig.EXPLORER_URL}/script/${script.codeHash}/${script.hashType}`; + return ( + + {lockScriptName} + + + ); + } + return {lockScriptName}; +} + +export default function SignOut({ + wallet, + connection, + address, + ckbChainConfig, +}) { + const walletName = walletSelector.walletName(wallet); + const lockScriptNameProps = { + lockScriptName: walletSelector.lockScriptName(wallet), + address, + ckbChainConfig, + }; -export default function SignOut({ walletName, connection }) { const router = useRouter(); return (