diff --git a/gno/p/dao_roles_voting_group/roles_voting_group.gno b/gno/p/dao_roles_voting_group/roles_voting_group.gno index 07c8d293ef..09c125b46c 100644 --- a/gno/p/dao_roles_voting_group/roles_voting_group.gno +++ b/gno/p/dao_roles_voting_group/roles_voting_group.gno @@ -50,7 +50,7 @@ func NewRolesVotingGroup(rm *dao_roles_group.RolesGroup) *RolesVotingGroup { func (v *RolesVotingGroup) Info() dao_interfaces.ModuleInfo { return dao_interfaces.ModuleInfo{ - Kind: "gno.land/p/teritori/dao_voting_group", + Kind: "gno.land/p/teritori/dao_roles_voting_group", Version: "0.1.0", } } diff --git a/packages/hooks/dao/useDAOKind.ts b/packages/hooks/dao/useDAOKind.ts new file mode 100644 index 0000000000..18919ef761 --- /dev/null +++ b/packages/hooks/dao/useDAOKind.ts @@ -0,0 +1,38 @@ +import { GnoJSONRPCProvider } from "@gnolang/gno-js-client"; +import { useQuery } from "@tanstack/react-query"; + +import { NetworkKind, parseUserId } from "@/networks"; +import { extractGnoString } from "@/utils/gno"; +import { extractDaoKind } from "@/utils/gnodao/helpers"; + +export const useDAOKind = (daoId: string | undefined) => { + const { data, ...other } = useQuery( + ["daoKind", daoId], + async () => { + if (!daoId) { + return null; + } + const [network, packagePath] = parseUserId(daoId); + if (network?.kind !== NetworkKind.Gno) { + return null; + } + // Ensure is a DAO by checking the addr is a realm addr and not an EOA + if (!packagePath?.startsWith("gno.land/")) { + return null; + } + + const provider = new GnoJSONRPCProvider(network.endpoint); + const info = extractGnoString( + await provider.evaluateExpression( + packagePath, + `daoCore.VotingModule().Info().String()`, + 0, + ), + ); + + return extractDaoKind(info); + }, + { staleTime: Infinity, enabled: !!daoId }, + ); + return { daoKind: data, ...other }; +}; diff --git a/packages/screens/UserPublicProfile/components/UPPIntro.tsx b/packages/screens/UserPublicProfile/components/UPPIntro.tsx index 308bd30dba..53275911f2 100644 --- a/packages/screens/UserPublicProfile/components/UPPIntro.tsx +++ b/packages/screens/UserPublicProfile/components/UPPIntro.tsx @@ -21,6 +21,8 @@ import { SocialButton } from "@/components/buttons/SocialButton"; import { SocialButtonSecondary } from "@/components/buttons/SocialButtonSecondary"; import { ProfileButton } from "@/components/hub/ProfileButton"; import { UserAvatarWithFrame } from "@/components/images/AvatarWithFrame"; +import { useIsDAO } from "@/hooks/cosmwasm/useCosmWasmContractInfo"; +import { useDAOKind } from "@/hooks/dao/useDAOKind"; import { usePremiumChannel } from "@/hooks/feed/usePremiumChannel"; import { usePremiumIsSubscribed } from "@/hooks/feed/usePremiumIsSubscribed"; import { useMaxResolution } from "@/hooks/useMaxResolution"; @@ -36,10 +38,11 @@ import { DEFAULT_NAME } from "@/utils/social-feed"; import { neutral00, neutral55, + neutralA3, secondaryColor, yellowPremium, } from "@/utils/style/colors"; -import { fontBold16, fontMedium14 } from "@/utils/style/fonts"; +import { fontBold16, fontMedium14, fontSemibold12 } from "@/utils/style/fonts"; import { layout, RESPONSIVE_BREAKPOINT_S } from "@/utils/style/layout"; import { tinyAddress } from "@/utils/text"; import { normalizeTwitterId } from "@/utils/twitter"; @@ -51,6 +54,8 @@ export const UPPIntro: React.FC<{ }> = ({ userId, isUserOwner, setIsEditProfileModal = (val) => {} }) => { const selectedWallet = useSelectedWallet(); const { metadata } = useNSUserInfo(userId); + const { isDAO } = useIsDAO(userId); + const { daoKind } = useDAOKind(userId); const { copyToClipboard } = useCopyToClipboard(); const socialButtonStyle = { margin: layout.spacing_x0_75 }; const [network, userAddress] = parseUserId(userId); @@ -285,7 +290,32 @@ export const UPPIntro: React.FC<{ @{metadata.tokenId || userAddress} - + {isDAO && daoKind && ( + + + {daoKind} + + + )} { ret_num = ret_num > 100 ? 100 : ret_num; return (ret_num / 100).toFixed(2); }; + +export const extractDaoKind = ( + votingModuleInfo: string, +): string | undefined => { + const rawDaoKind = votingModuleInfo.split("@v")[0]; + switch (rawDaoKind) { + case "gno.land/p/teritori/dao_roles_voting_group": + return "roles based organization"; + case "gno.land/p/teritori/dao_voting_group": + return "memberships based organization"; + default: + return undefined; + } +};