diff --git a/src/pages/dao/links.jsx b/src/atoms/link/index.jsx similarity index 51% rename from src/pages/dao/links.jsx rename to src/atoms/link/index.jsx index eecd383ec..76de64c87 100644 --- a/src/pages/dao/links.jsx +++ b/src/atoms/link/index.jsx @@ -1,25 +1,21 @@ import React from 'react' +import { CIDToURL } from '@utils/index' import { walletPreview } from '@utils/string' import { TOKENS } from '@constants' import styles from '@style' export function TeiaUserLink({ address, alias, shorten, className, children }) { return ( - + {children} - {alias ? alias : shorten ? walletPreview(address) : address} + {alias ?? (shorten ? walletPreview(address) : address)} ) } export function DefaultLink({ href, className, children }) { return ( - + {children} ) @@ -27,10 +23,7 @@ export function DefaultLink({ href, className, children }) { export function TzktLink({ link, className, children }) { return ( - + {children} ) @@ -44,9 +37,9 @@ export function TezosAddressLink({ children, }) { return ( - + {children} - {alias ? alias : shorten ? walletPreview(address) : address} + {alias ?? (shorten ? walletPreview(address) : address)} ) } @@ -56,32 +49,26 @@ export function TokenLink({ fa2, id, className, children }) { if (token?.website) { return ( - + {children} ) } else { return ( - + {children} ) } } -export function IpfsLink({ cid, className, children }) { +export function IpfsLink({ cid, type, className, children }) { return ( - {children ? children : cid} + {children ?? cid} ) } diff --git a/src/atoms/link/index.module.scss b/src/atoms/link/index.module.scss new file mode 100644 index 000000000..b011f70a8 --- /dev/null +++ b/src/atoms/link/index.module.scss @@ -0,0 +1,3 @@ +.ipfs_link { + word-break: break-word; +} diff --git a/src/context/daoStore.ts b/src/context/daoStore.ts index d60b76daa..9cf8f099b 100644 --- a/src/context/daoStore.ts +++ b/src/context/daoStore.ts @@ -24,27 +24,27 @@ type OperationReturn = Promise interface DaoState { /** Uploads a file to ipfs */ - uploadFileToIpfs: (file: any, displayUploadInformation: boolean) => OperationReturn + uploadFileToIpfs: (file: any, displayUploadInformation?: boolean) => OperationReturn /** Votes a DAO proposal using the user TEIA tokens */ - voteProposal: (proposalId: string, vote: string, maxCheckpoints: number | null, callback: any) => OperationReturn + voteProposal: (proposalId: string, vote: string, maxCheckpoints: number | null, callback?: any) => OperationReturn /** Votes a DAO proposal as community representaive */ - voteProposalAsRepresentative: (proposalId: string, vote: string, callback: any) => OperationReturn + voteProposalAsRepresentative: (proposalId: string, vote: string, callback?: any) => OperationReturn /** Cancels a DAO proposal */ - cancelProposal: (proposalId: string, returnEscrow: boolean, callback: any) => OperationReturn + cancelProposal: (proposalId: string, returnEscrow: boolean, callback?: any) => OperationReturn /** Evaluates a DAO proposal voting result */ - evaluateVotingResult: (proposalId: string, callback: any) => OperationReturn + evaluateVotingResult: (proposalId: string, callback?: any) => OperationReturn /** Executes a DAO proposal */ - executeProposal: (proposalId: string, callback: any) => OperationReturn + executeProposal: (proposalId: string, callback?: any) => OperationReturn /** Creates a DAO proposal */ - createProposal: (title: string, descriptionIpfsPath: string, kind: any, callback: any) => OperationReturn + createProposal: (title: string, descriptionIpfsPath: string, kind: any, callback?: any) => OperationReturn /** Creates a DAO text proposal */ - createTextProposal: (title: string, descriptionIpfsPath: string, callback: any) => OperationReturn + createTextProposal: (title: string, descriptionIpfsPath: string, callback?: any) => OperationReturn /** Creates a DAO transfer mutez proposal */ - createTransferMutezProposal: (title: string, descriptionIpfsPath: string, transfers: any, callback: any) => OperationReturn + createTransferMutezProposal: (title: string, descriptionIpfsPath: string, transfers: any, callback?: any) => OperationReturn /** Creates a DAO transfer token proposal */ - createTransferTokenProposal: (title: string, descriptionIpfsPath: string, tokenAddress: string, tokenId: string, transfers: any, callback: any) => OperationReturn + createTransferTokenProposal: (title: string, descriptionIpfsPath: string, tokenAddress: string, tokenId: string, transfers: any, callback?: any) => OperationReturn /** Creates a DAO lambda function proposal */ - createLambdaFunctionProposal: (title: string, descriptionIpfsPath: string, michelineCode: string, callback: any) => OperationReturn + createLambdaFunctionProposal: (title: string, descriptionIpfsPath: string, michelineCode: string, callback?: any) => OperationReturn /** Claim DAO tokens */ claimTokens: () => OperationReturn } @@ -73,14 +73,15 @@ export const useDaoStore = create()( } const added = await uploadFileToIPFSProxy(file) + const cid = added?.data.cid if (displayUploadInformation) { close() } - console.log(`File IPFS cid: ${added?.data.cid}`) + console.log(`File IPFS cid: ${cid}`) - return added?.data.cid + return cid }, voteProposal: async (proposalId, vote, maxCheckpoints, callback) => { const handleOp = useUserStore.getState().handleOp @@ -263,9 +264,7 @@ export const useDaoStore = create()( createTransferMutezProposal: async (title, descriptionIpfsPath, transfers, callback) => { const show = useModalStore.getState().show - for (const transfer of transfers) { - const destination = transfer.destination - + for (const { destination } of transfers) { if (!(destination && validateAddress(destination) === 3)) { show( 'Submit DAO proposal', @@ -289,9 +288,7 @@ export const useDaoStore = create()( return } - for (const transfer of transfers) { - const destination = transfer.destination - + for (const { destination } of transfers) { if (!(destination && validateAddress(destination) === 3)) { show( 'Submit DAO proposal', @@ -381,7 +378,7 @@ export const useDaoStore = create()( // Calculate the tokens that the user still can claim const userMerkleData = merkleData[userAddress] const totalTokensToClaim = parseInt(userMerkleData.tokens) / DAO_TOKEN_DECIMALS - const alreadyClaimedTokens = (await getClaimedDaoTokens(userAddress)) / DAO_TOKEN_DECIMALS + const alreadyClaimedTokens = await getClaimedDaoTokens(userAddress) const unclaimedTokens = totalTokensToClaim - (alreadyClaimedTokens ? alreadyClaimedTokens : 0) if (unclaimedTokens === 0) { diff --git a/src/data/api.ts b/src/data/api.ts index 761a54550..d8db24762 100644 --- a/src/data/api.ts +++ b/src/data/api.ts @@ -1,6 +1,6 @@ import { HEN_CONTRACT_FA2, - DAO_TOKEN_CONTRACT, + DAO_TOKEN_DECIMALS, CLAIMED_DAO_TOKENS_BIGMAP_ID, } from '@constants' import axios from 'axios' @@ -327,34 +327,28 @@ export const GetUserMetadata = async (walletAddr: string) => { } /** - * Get user DAO token balance + * Get some data from the TzKT API */ -export async function getDaoTokenBalance(walletAddr: string) { - const parameters = { - 'token.contract': DAO_TOKEN_CONTRACT, - 'token.tokenId': '0', - account: walletAddr, - select: 'balance', - } +export async function getTzktData(query: string, parameters = {}, debug = true) { + const url = import.meta.env.VITE_TZKT_API + query const response = await axios - .get(import.meta.env.VITE_TZKT_API + '/v1/tokens/balances', { - params: parameters, - }) + .get(url, { params: parameters }) .catch((error) => - console.log('Error while querying the account token balance:', error) + console.log(`The following TzKT query returned an error: ${url}`, error) ) - return response?.data[0] ? parseInt(response.data[0]) / 1e6 : 0 + if (debug) console.log(`Executed TzKT query: ${url}`) + + return response?.data } /** * Get user claimed tokens */ export async function getClaimedDaoTokens(walletAddr: string) { - const response = await axios.get( - import.meta.env.VITE_TZKT_API + - `/v1/bigmaps/${CLAIMED_DAO_TOKENS_BIGMAP_ID}/keys/${walletAddr}` + const data = await getTzktData( + `/v1/bigmaps/${CLAIMED_DAO_TOKENS_BIGMAP_ID}/keys/${walletAddr}` ) - return response ? parseInt(response.data.value) : 0 + return data?.value ? parseInt(data.value) / DAO_TOKEN_DECIMALS : 0 } diff --git a/src/pages/dao/hooks.js b/src/data/swr.js similarity index 76% rename from src/pages/dao/hooks.js rename to src/data/swr.js index 91ac76698..da0dfc56d 100644 --- a/src/pages/dao/hooks.js +++ b/src/data/swr.js @@ -1,22 +1,9 @@ import useSWR from 'swr' -import axios from 'axios' import { DAO_TOKEN_CONTRACT, DAO_TOKEN_DECIMALS } from '@constants' +import { getTzktData } from '@data/api' import { hexToString } from '@utils/string' -async function getTzktData(query, parameters = {}, debug = true) { - const url = import.meta.env.VITE_TZKT_API + query - const response = await axios - .get(url, { params: parameters }) - .catch((error) => - console.log(`The following TzKT query returned an error: ${url}`, error) - ) - - if (debug) console.log(`Executed TzKT query: ${url}`) - - return response?.data -} - -function reorderBigmapData(data, subKey = undefined, decode = false) { +function reorderBigmapData(data, subKey, decode = false) { const bigmapData = data ? {} : undefined data?.forEach( (item) => @@ -37,7 +24,7 @@ export function useBalance(address) { return [data ? data / 1000000 : 0, mutate] } -export function useTokenBalance(address) { +export function useDaoTokenBalance(address) { const parameters = { 'token.contract': DAO_TOKEN_CONTRACT, 'token.tokenId': '0', @@ -61,7 +48,7 @@ export function useStorage(contractAddress) { return [data, mutate] } -export function useGovernanceParameters(daoStorage) { +export function useDaoGovernanceParameters(daoStorage) { const parameters = { limit: 10000, active: true, @@ -77,7 +64,7 @@ export function useGovernanceParameters(daoStorage) { return [reorderBigmapData(data), mutate] } -export function useProposals(daoStorage) { +export function useDaoProposals(daoStorage) { const parameters = { limit: 10000, active: true, @@ -93,7 +80,7 @@ export function useProposals(daoStorage) { return [reorderBigmapData(data), mutate] } -export function useRepresentatives(daoStorage) { +export function useDaoRepresentatives(daoStorage) { const { data, mutate } = useSWR( daoStorage?.representatives ? `/v1/contracts/${daoStorage.representatives}/storage` @@ -104,7 +91,7 @@ export function useRepresentatives(daoStorage) { return [data?.representatives, mutate] } -export function useUserVotes(address, daoStorage) { +export function useDaoUserVotes(address, daoStorage) { const parameters = { 'key.address': address, limit: 10000, @@ -121,7 +108,7 @@ export function useUserVotes(address, daoStorage) { return [reorderBigmapData(data, 'nat'), mutate] } -export function useCommunityVotes(community, daoStorage) { +export function useDaoCommunityVotes(community, daoStorage) { const parameters = { 'key.string': community, limit: 10000, @@ -138,35 +125,41 @@ export function useCommunityVotes(community, daoStorage) { return [reorderBigmapData(data, 'nat'), mutate] } -export function useUsersAliases(userAddress, representatives, proposals) { - const addresses = [] - if (userAddress) addresses.push(userAddress) - if (representatives) - Object.keys(representatives).forEach((address) => addresses.push(address)) - if (proposals) - Object.values(proposals).forEach((proposal) => - addresses.push(proposal.issuer) - ) +export function useAliases(addresses) { + if (addresses?.length === 1) addresses.push(addresses[0]) const parameters = { - 'key.in': addresses.join(','), + 'key.in': addresses?.join(','), limit: 10000, active: true, select: 'key,value', } const { data, mutate } = useSWR( - representatives && proposals ? [`/v1/bigmaps/3919/keys`, parameters] : null, + addresses?.length > 0 ? [`/v1/bigmaps/3919/keys`, parameters] : null, getTzktData ) return [reorderBigmapData(data, undefined, true), mutate] } -export function useDaoMemberCount() { +export function useDaoUsersAliases(userAddress, representatives, proposals) { + const addresses = [] + if (userAddress) addresses.push(userAddress) + if (representatives) + Object.keys(representatives).forEach((address) => addresses.push(address)) + if (proposals) + Object.values(proposals).forEach((proposal) => + addresses.push(proposal.issuer) + ) + + return useAliases(addresses) +} + +export function useDaoMemberCount(minTokens) { const parameters = { 'token.contract': DAO_TOKEN_CONTRACT, 'token.tokenId': '0', - 'balance.gt': 0 * DAO_TOKEN_DECIMALS, + 'balance.gt': minTokens * DAO_TOKEN_DECIMALS, } const { data, mutate } = useSWR( ['/v1/tokens/balances/count', parameters], diff --git a/src/pages/dao/claim.jsx b/src/pages/dao/claim.jsx index 2e0aa7bf4..8d3fe7cc7 100644 --- a/src/pages/dao/claim.jsx +++ b/src/pages/dao/claim.jsx @@ -4,9 +4,9 @@ import { Page } from '@atoms/layout' import { Button } from '@atoms/button' import { Checkbox } from '@atoms/input' import { Line } from '@atoms/line' +import { DefaultLink } from '@atoms/link' import { DAOIcon } from '@icons' import styles from '@style' -import { DefaultLink } from './links' export const Claim = () => { const claimTokens = useDaoStore((st) => st.claimTokens) diff --git a/src/pages/dao/index.jsx b/src/pages/dao/index.jsx index 76679a8d7..e8b3fd16d 100644 --- a/src/pages/dao/index.jsx +++ b/src/pages/dao/index.jsx @@ -4,8 +4,12 @@ import { useUserStore } from '@context/userStore' import { Page } from '@atoms/layout' import { Loading } from '@atoms/loading' import { Tabs } from '@atoms/tab/Tabs' +import { + useDaoTokenBalance, + useStorage, + useDaoRepresentatives, +} from '@data/swr' import styles from '@style' -import { useTokenBalance, useStorage, useRepresentatives } from './hooks' const TABS = [ { @@ -26,12 +30,12 @@ const TABS = [ export const DAO = () => { // Get all the required DAO information const daoStorage = useStorage(DAO_GOVERNANCE_CONTRACT) - const representatives = useRepresentatives(daoStorage) + const representatives = useDaoRepresentatives(daoStorage) // Get all the required user information const userAddress = useUserStore((st) => st.address) const userCommunity = representatives?.[userAddress] - const userTokenBalance = useTokenBalance(userAddress) + const userTokenBalance = useDaoTokenBalance(userAddress) return ( diff --git a/src/pages/dao/index.module.scss b/src/pages/dao/index.module.scss index 166f8bffd..2bde7b637 100644 --- a/src/pages/dao/index.module.scss +++ b/src/pages/dao/index.module.scss @@ -57,7 +57,3 @@ margin-bottom: 30px; } } - -.ipfs_link { - word-break: break-word; -} diff --git a/src/pages/dao/tabs/Parameters.jsx b/src/pages/dao/tabs/Parameters.jsx index c765b2fe4..bb36dee1a 100644 --- a/src/pages/dao/tabs/Parameters.jsx +++ b/src/pages/dao/tabs/Parameters.jsx @@ -2,40 +2,40 @@ import { DAO_GOVERNANCE_CONTRACT, DAO_TOKEN_DECIMALS } from '@constants' import { useUserStore } from '@context/userStore' import { Loading } from '@atoms/loading' import { Line } from '@atoms/line' -import styles from '@style' -import { TeiaUserLink, TezosAddressLink } from '../links' +import { TeiaUserLink, TezosAddressLink } from '@atoms/link' import { useBalance, - useTokenBalance, + useDaoTokenBalance, useStorage, - useGovernanceParameters, - useProposals, - useRepresentatives, - useUserVotes, - useCommunityVotes, - useUsersAliases, + useDaoGovernanceParameters, + useDaoProposals, + useDaoRepresentatives, + useDaoUserVotes, + useDaoCommunityVotes, + useDaoUsersAliases, useDaoMemberCount, -} from '../hooks' +} from '@data/swr' +import styles from '@style' export const DaoParameters = () => { // Get all the required DAO information const [daoStorage] = useStorage(DAO_GOVERNANCE_CONTRACT) - const [governanceParameters] = useGovernanceParameters(daoStorage) - const [proposals] = useProposals(daoStorage) - const [representatives] = useRepresentatives(daoStorage) - const [daoMemberCount] = useDaoMemberCount() + const [governanceParameters] = useDaoGovernanceParameters(daoStorage) + const [proposals] = useDaoProposals(daoStorage) + const [representatives] = useDaoRepresentatives(daoStorage) + const [daoMemberCount] = useDaoMemberCount(0) const [daoBalance] = useBalance(DAO_GOVERNANCE_CONTRACT) - const [daoTokenBalance] = useTokenBalance(DAO_GOVERNANCE_CONTRACT) + const [daoTokenBalance] = useDaoTokenBalance(DAO_GOVERNANCE_CONTRACT) // Get all the required user information const userAddress = useUserStore((st) => st.address) const userCommunity = representatives?.[userAddress] - const [userTokenBalance] = useTokenBalance(userAddress) - const [userVotes] = useUserVotes(userAddress, daoStorage) - const [userCommunityVotes] = useCommunityVotes(userCommunity, daoStorage) + const [userTokenBalance] = useDaoTokenBalance(userAddress) + const [userVotes] = useDaoUserVotes(userAddress, daoStorage) + const [userCommunityVotes] = useDaoCommunityVotes(userCommunity, daoStorage) // Get all the relevant users aliases - const [usersAliases] = useUsersAliases( + const [usersAliases] = useDaoUsersAliases( userAddress, representatives, proposals diff --git a/src/pages/dao/tabs/Proposals.jsx b/src/pages/dao/tabs/Proposals.jsx index d3bb9dcc6..6f4bf2bf8 100644 --- a/src/pages/dao/tabs/Proposals.jsx +++ b/src/pages/dao/tabs/Proposals.jsx @@ -7,20 +7,25 @@ import { useDaoStore } from '@context/daoStore' import { Button } from '@atoms/button' import { Line } from '@atoms/line' import { Select } from '@atoms/select' +import { + TeiaUserLink, + TezosAddressLink, + TokenLink, + IpfsLink, +} from '@atoms/link' +import { + useDaoTokenBalance, + useStorage, + useDaoGovernanceParameters, + useDaoProposals, + useDaoRepresentatives, + useDaoUserVotes, + useDaoCommunityVotes, + useDaoUsersAliases, +} from '@data/swr' import { hexToString } from '@utils/string' import { getWordDate } from '@utils/time' import styles from '@style' -import { TeiaUserLink, TezosAddressLink, TokenLink, IpfsLink } from '../links' -import { - useTokenBalance, - useStorage, - useGovernanceParameters, - useProposals, - useRepresentatives, - useUserVotes, - useCommunityVotes, - useUsersAliases, -} from '../hooks' const PROPOSAL_STATUS_OPTIONS = { toVote: 'Proposals to vote', @@ -39,18 +44,18 @@ export function DaoProposals() { // Get all the required DAO information const [daoStorage] = useStorage(DAO_GOVERNANCE_CONTRACT) - const [governanceParameters] = useGovernanceParameters(daoStorage) - const [proposals] = useProposals(daoStorage) - const [representatives] = useRepresentatives(daoStorage) + const [governanceParameters] = useDaoGovernanceParameters(daoStorage) + const [proposals] = useDaoProposals(daoStorage) + const [representatives] = useDaoRepresentatives(daoStorage) // Get all the required user information const userAddress = useUserStore((st) => st.address) const userCommunity = representatives?.[userAddress] - const [userVotes] = useUserVotes(userAddress, daoStorage) - const [userCommunityVotes] = useCommunityVotes(userCommunity, daoStorage) + const [userVotes] = useDaoUserVotes(userAddress, daoStorage) + const [userCommunityVotes] = useDaoCommunityVotes(userCommunity, daoStorage) // Get all the relevant users aliases - const [usersAliases] = useUsersAliases( + const [usersAliases] = useDaoUsersAliases( userAddress, representatives, proposals @@ -477,15 +482,15 @@ function ProposalContent({ content }) { function ProposalVotesSummary({ proposal }) { // Get all the required DAO information const [daoStorage] = useStorage(DAO_GOVERNANCE_CONTRACT) - const [governanceParameters] = useGovernanceParameters(daoStorage) - const [representatives] = useRepresentatives(daoStorage) + const [governanceParameters] = useDaoGovernanceParameters(daoStorage) + const [representatives] = useDaoRepresentatives(daoStorage) // Get all the required user information const userAddress = useUserStore((st) => st.address) const userCommunity = representatives?.[userAddress] - const [userTokenBalance] = useTokenBalance(userAddress) - const [userVotes] = useUserVotes(userAddress, daoStorage) - const [userCommunityVotes] = useCommunityVotes(userCommunity, daoStorage) + const [userTokenBalance] = useDaoTokenBalance(userAddress) + const [userVotes] = useDaoUserVotes(userAddress, daoStorage) + const [userCommunityVotes] = useDaoCommunityVotes(userCommunity, daoStorage) // Get the proposal quorum and governance parameters const quorum = proposal.quorum @@ -671,17 +676,17 @@ function VotesDisplay({ title, yes, no, abstain }) { function ProposalActions(props) { // Get all the required DAO information const [daoStorage] = useStorage(DAO_GOVERNANCE_CONTRACT) - const [governanceParameters] = useGovernanceParameters(daoStorage) - const [representatives] = useRepresentatives(daoStorage) - const [, updateProposals] = useProposals(daoStorage) + const [governanceParameters] = useDaoGovernanceParameters(daoStorage) + const [representatives] = useDaoRepresentatives(daoStorage) + const [, updateProposals] = useDaoProposals(daoStorage) // Get all the required user information const userAddress = useUserStore((st) => st.address) const userCommunity = representatives?.[userAddress] const [userTokenBalance, updateUserTokenBalance] = - useTokenBalance(userAddress) - const [userVotes, updateUserVotes] = useUserVotes(userAddress, daoStorage) - const [communityVotes, updateCommunityVotes] = useCommunityVotes( + useDaoTokenBalance(userAddress) + const [userVotes, updateUserVotes] = useDaoUserVotes(userAddress, daoStorage) + const [communityVotes, updateCommunityVotes] = useDaoCommunityVotes( userCommunity, daoStorage ) diff --git a/src/pages/dao/tabs/Submit.jsx b/src/pages/dao/tabs/Submit.jsx index 2493df568..cf9028e08 100644 --- a/src/pages/dao/tabs/Submit.jsx +++ b/src/pages/dao/tabs/Submit.jsx @@ -7,13 +7,13 @@ import { Button } from '@atoms/button' import { Line } from '@atoms/line' import { Select } from '@atoms/select' import { DaoInput, Textarea } from '@atoms/input' -import styles from '@style' import { - useTokenBalance, + useDaoTokenBalance, useStorage, - useGovernanceParameters, - useProposals, -} from '../hooks' + useDaoGovernanceParameters, + useDaoProposals, +} from '@data/swr' +import styles from '@style' const PROPOSAL_KINDS = { text: 'Text proposal', @@ -28,13 +28,13 @@ export function SubmitDaoProposals() { // Get all the required DAO information const [daoStorage] = useStorage(DAO_GOVERNANCE_CONTRACT) - const [governanceParameters] = useGovernanceParameters(daoStorage) - const [, updateProposals] = useProposals(daoStorage) + const [governanceParameters] = useDaoGovernanceParameters(daoStorage) + const [, updateProposals] = useDaoProposals(daoStorage) // Get all the required user information const userAddress = useUserStore((st) => st.address) const [userTokenBalance, updateUserTokenBalance] = - useTokenBalance(userAddress) + useDaoTokenBalance(userAddress) // Define the callback function to be triggered when a proposal is submitted const callback = () => { diff --git a/src/pages/profile/index.jsx b/src/pages/profile/index.jsx index 4ba468327..0203ee077 100644 --- a/src/pages/profile/index.jsx +++ b/src/pages/profile/index.jsx @@ -5,7 +5,7 @@ import { Page } from '@atoms/layout' import { useParams, useSearchParams, Outlet } from 'react-router-dom' import useSWR from 'swr' import { getUser } from '@data/api' -import { GetUserMetadata, getDaoTokenBalance } from '@data/api' +import { GetUserMetadata } from '@data/api' import useSettings from '@hooks/use-settings' import { validateAddress, ValidationResult } from '@taquito/utils' import Profile from './profile' @@ -55,9 +55,6 @@ async function fetchUserInfo(addressOrSubjkt, type = 'user_address') { user.subjkt = holder.name } - const daoTokenBalance = await getDaoTokenBalance(user.address) - user.daoTokenBalance = daoTokenBalance - return user } export const useDisplayStore = create( diff --git a/src/pages/profile/profile.jsx b/src/pages/profile/profile.jsx index 2c714c440..0e2604c4f 100644 --- a/src/pages/profile/profile.jsx +++ b/src/pages/profile/profile.jsx @@ -2,6 +2,7 @@ import useClipboard from 'react-use-clipboard' import { Button } from '@atoms/button' import { walletPreview } from '@utils/string' import Identicon from '@atoms/identicons' +import { useDaoTokenBalance } from '@data/swr' import styles from '@style' import { useDisplayStore } from '.' import ParticipantList from '@components/collab/manage/ParticipantList' @@ -11,6 +12,7 @@ export default function Profile({ user }) { const [isAddressCopied, setAddressCopied] = useClipboard(user.address, { successDuration: 2500, }) + const [daoTokenBalance] = useDaoTokenBalance(user.address) const coreParticipants = useDisplayStore((st) => st.coreParticipants) @@ -40,10 +42,9 @@ export default function Profile({ user }) { {isAddressCopied && 'Copied!'} - {user.daoTokenBalance >= 0 && ( + {daoTokenBalance >= 0 && (

- {Math.round(user.daoTokenBalance * 10) / 10}{' '} - TEIA + {Math.round(daoTokenBalance * 10) / 10} TEIA

)}