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 onchain metadata #77

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
35 changes: 28 additions & 7 deletions components/AboutRealm.tsx
Original file line number Diff line number Diff line change
@@ -1,45 +1,66 @@
import useRealm from 'hooks/useRealm'
import useProgramVersion from '@hooks/useProgramVersion'
import { useGetOnchainMetadata } from '@hooks/useOnchainMetadata'

const AboutRealm = () => {
const { realmInfo, symbol } = useRealm()
const programVersion = useProgramVersion()
const realmData = useGetOnchainMetadata(realmInfo?.realmId).data

return (
<div className="pb-4 space-y-3">
<div>
<p className="text-xs text-fgd-3">Name</p>
<p className="text-fgd-1">{realmInfo?.displayName || symbol}</p>
<p className="text-fgd-1">{realmData?.displayName || symbol}</p>
</div>
{realmInfo?.isCertified ? (
<div>
<p className="text-xs text-fgd-3">Token</p>
<p className="text-fgd-1">{symbol}</p>
</div>
) : null}
{realmInfo?.website ? (
{realmData?.shortDescription ? (
<div>
<p className="text-xs text-fgd-3">Description</p>
<p className="text-fgd-1">{realmData.shortDescription}</p>
</div>
) : null}
{realmData?.website ? (
<div>
<p className="text-xs text-fgd-3">Website</p>
<a
className="default-transition flex items-center text-primary-light hover:text-primary-dark text-sm"
href={realmInfo?.website}
href={realmData.website}
target="_blank"
rel="noopener noreferrer"
>
{realmData.website}
</a>
</div>
) : null}
{realmData?.twitter ? (
<div>
<p className="text-xs text-fgd-3">Twitter</p>
<a
className="default-transition flex items-center text-primary-light hover:text-primary-dark text-sm"
href={`https://twitter.com/${realmData.twitter}`}
target="_blank"
rel="noopener noreferrer"
>
{realmInfo?.website}
{realmData.twitter}
</a>
</div>
) : null}
{realmInfo?.twitter ? (
{realmData?.discord ? (
<div>
<p className="text-xs text-fgd-3">Twitter</p>
<a
className="default-transition flex items-center text-primary-light hover:text-primary-dark text-sm"
href={`https://twitter.com/${realmInfo?.twitter}`}
href={`https://${realmData.discord}`}
target="_blank"
rel="noopener noreferrer"
>
{realmInfo?.twitter}
{realmData.discord}
</a>
</div>
) : null}
Expand Down
12 changes: 7 additions & 5 deletions components/RealmHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { getRealmExplorerHost } from 'tools/routing'
import { tryParsePublicKey } from '@tools/core/pubkey'
import { useRealmQuery } from '@hooks/queries/realm'
import { useConnection } from '@solana/wallet-adapter-react'
import { useGetOnchainMetadata } from '@hooks/useOnchainMetadata'

const RealmHeader = () => {
const { fmtUrlWithCluster } = useQueryContext()
Expand All @@ -22,6 +23,7 @@ const RealmHeader = () => {
const realmUrl = `https://${explorerHost}/account/${realmInfo?.realmId.toBase58()}${connection.rpcEndpoint.includes("devnet") ? "?cluster=devnet" : ""}`

const [isBackNavVisible, setIsBackNavVisible] = useState(true)
const realmData = useGetOnchainMetadata(realmInfo?.realmId).data

useEffect(() => {
setIsBackNavVisible(realmInfo?.symbol !== REALM)
Expand All @@ -44,21 +46,21 @@ const RealmHeader = () => {
) : null}
</div>
<div className="flex flex-col items-center md:flex-row md:justify-between">
{realmInfo?.displayName ? (
{realmData?.displayName ? (
<div className="flex items-center">
<div className="flex flex-col items-center pb-3 md:flex-row md:pb-0">
{realmInfo?.ogImage ? (
{realmData?.daoImage ? (
<img
className="flex-shrink-0 w-8 mb-2 md:mb-0"
src={realmInfo?.ogImage}
src={realmData.daoImage}
></img>
) : (
<div className="bg-[rgba(255,255,255,0.1)] h-14 w-14 flex font-bold items-center justify-center rounded-full text-fgd-3">
{realmInfo.displayName.charAt(0)}
{realmData.displayName.charAt(0)}
</div>
)}
<div className="flex items-center">
<h1 className="ml-3">{realmInfo.displayName}</h1>
<h1 className="ml-3">{realmData.displayName}</h1>
</div>
</div>
</div>
Expand Down
Loading
Loading