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

optimize TOR fetch for council-only display #2367

Merged
merged 1 commit into from
Jun 19, 2024
Merged
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
11 changes: 10 additions & 1 deletion hooks/queries/tokenOwnerRecord.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import useLegacyConnectionContext from '@hooks/useLegacyConnectionContext'
import useWalletOnePointOh from '@hooks/useWalletOnePointOh'
import queryClient from './queryClient'
import mainnetBetaRealms from 'public/realms/mainnet-beta.json'
import { determineVotingPowerType } from './governancePower'

export const tokenOwnerRecordQueryKeys = {
all: (endpoint: string) => [endpoint, 'TokenOwnerRecord'],
Expand Down Expand Up @@ -107,11 +108,19 @@ export const useTokenOwnerRecordsForRealmQuery = () => {
const filter = pubkeyFilter(1, realm.pubkey)
if (!filter) throw new Error() // unclear why this would ever happen, probably it just cannot

const votingType = await determineVotingPowerType(connection.current, realm.pubkey, "community")
const councilOnly = !(votingType === 'vanilla' || votingType === 'NFT')
const councilMint = realm.account.config.councilMint

const mintFilter = councilOnly && councilMint ?
pubkeyFilter(33, councilMint) :
null

const results = await getGovernanceAccounts(
connection.current,
realm.owner,
TokenOwnerRecord,
[filter]
mintFilter ? [filter, mintFilter] : [filter]
)

// This may or may not be resource intensive for big DAOs, and is not too useful
Expand Down
Loading