Skip to content

Commit

Permalink
use new account indexer queries instead of wallet type
Browse files Browse the repository at this point in the history
  • Loading branch information
NoahSaso committed Sep 20, 2024
1 parent b10decc commit bfdd60a
Show file tree
Hide file tree
Showing 10 changed files with 56 additions and 56 deletions.
4 changes: 2 additions & 2 deletions packages/state/query/queries/account.ts
Original file line number Diff line number Diff line change
Expand Up @@ -525,9 +525,9 @@ export const fetchValenceAccounts = async (
}
): Promise<ValenceAccount[]> => {
const addresses = await queryClient.fetchQuery(
indexerQueries.queryWallet(queryClient, {
indexerQueries.queryAccount(queryClient, {
chainId,
walletAddress: address,
address,
formula: 'valence/accounts',
})
)
Expand Down
4 changes: 2 additions & 2 deletions packages/state/query/queries/contracts/CwVesting.extra.ts
Original file line number Diff line number Diff line change
Expand Up @@ -324,9 +324,9 @@ export const fetchVestingPaymentsOwnedBy = async (
}
): Promise<string[]> => {
const vestingPayments: string[] = await queryClient.fetchQuery(
indexerQueries.queryWallet(queryClient, {
indexerQueries.queryAccount(queryClient, {
chainId,
walletAddress: address,
address,
formula: 'vesting/ownerOf',
noFallback: true,
})
Expand Down
4 changes: 2 additions & 2 deletions packages/state/query/queries/dao.ts
Original file line number Diff line number Diff line change
Expand Up @@ -265,9 +265,9 @@ export const listWalletAdminOfDaos = async (
}
): Promise<string[]> => {
const walletAdminOfDaos = await queryClient.fetchQuery(
indexerQueries.queryWallet(queryClient, {
indexerQueries.queryAccount(queryClient, {
chainId,
walletAddress: address,
address,
formula: 'daos/adminOf',
noFallback: true,
})
Expand Down
34 changes: 17 additions & 17 deletions packages/state/query/queries/indexer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,23 @@ export const indexerQueries = {
/**
* Fetch indexer query, unless the indexer is behind and there is a fallback.
*/
queryAccount: <T = any>(
queryClient: QueryClient,
{
address,
...options
}: Omit<FetchIndexerQueryOptions, 'type' | 'address'> & {
address: string
}
) =>
indexerQueries.query<T>(queryClient, {
...options,
type: IndexerFormulaType.Account,
address,
}),
/**
* Fetch indexer query, unless the indexer is behind and there is a fallback.
*/
queryContract: <T = any>(
queryClient: QueryClient,
{
Expand Down Expand Up @@ -119,23 +136,6 @@ export const indexerQueries = {
type: IndexerFormulaType.Validator,
address,
}),
/**
* Fetch indexer query, unless the indexer is behind and there is a fallback.
*/
queryWallet: <T = any>(
queryClient: QueryClient,
{
walletAddress: address,
...options
}: Omit<FetchIndexerQueryOptions, 'type' | 'address'> & {
walletAddress: string
}
) =>
indexerQueries.query<T>(queryClient, {
...options,
type: IndexerFormulaType.Wallet,
address,
}),
/**
* Fetch query from Snapper.
*/
Expand Down
4 changes: 2 additions & 2 deletions packages/state/query/queries/polytone.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ export const fetchPolytoneProxies = async (
return polytoneNoteProxyMapToChainIdMap(
chainId,
await queryClient.fetchQuery(
indexerQueries.queryWallet(queryClient, {
indexerQueries.queryAccount(queryClient, {
chainId,
walletAddress: address,
address,
formula: 'polytone/proxies',
})
)
Expand Down
40 changes: 20 additions & 20 deletions packages/state/recoil/selectors/indexer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,25 @@ export const indexerUpStatusSelector = selectorFamily<
},
})

export const queryAccountIndexerSelector = selectorFamily<
any,
Omit<QueryIndexerParams, 'type' | 'address'> & {
walletAddress: string
}
>({
key: 'queryAccountIndexer',
get:
({ walletAddress: address, ...params }) =>
({ get }) =>
get(
queryIndexerSelector({
type: IndexerFormulaType.Account,
address,
...params,
})
),
})

export const queryContractIndexerSelector = selectorFamily<
any,
Omit<QueryIndexerParams, 'type' | 'address'> & {
Expand Down Expand Up @@ -182,25 +201,6 @@ export const queryValidatorIndexerSelector = selectorFamily<
),
})

export const queryWalletIndexerSelector = selectorFamily<
any,
Omit<QueryIndexerParams, 'type' | 'address'> & {
walletAddress: string
}
>({
key: 'queryWalletIndexer',
get:
({ walletAddress: address, ...params }) =>
({ get }) =>
get(
queryIndexerSelector({
type: IndexerFormulaType.Wallet,
address,
...params,
})
),
})

export type QuerySnapperParams = QuerySnapperOptions & {
// Refresh by changing this value.
id?: number
Expand Down Expand Up @@ -312,7 +312,7 @@ export const walletProposalStatsSelector = selectorFamily<
({ get }) => {
const id = get(refreshWalletProposalStatsAtom)
const stats = get(
queryWalletIndexerSelector({
queryAccountIndexerSelector({
walletAddress: address,
formula: 'proposals/stats',
chainId,
Expand Down
6 changes: 3 additions & 3 deletions packages/state/recoil/selectors/nft.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import {
} from '../atoms'
import { accountsSelector } from './account'
import { CommonNftSelectors, DaoDaoCoreSelectors } from './contracts'
import { queryWalletIndexerSelector } from './indexer'
import { queryAccountIndexerSelector } from './indexer'
import { stargazeWalletUsdValueSelector } from './stargaze'
import { genericTokenSelector } from './token'

Expand Down Expand Up @@ -520,7 +520,7 @@ export const walletLazyNftCardInfosSelector = selectorFamily<
}

const collections: CollectionWithTokens[] = get(
queryWalletIndexerSelector({
queryAccountIndexerSelector({
chainId,
walletAddress,
formula: 'nft/collections',
Expand Down Expand Up @@ -577,7 +577,7 @@ export const walletStakedLazyNftCardInfosSelector = selectorFamily<
const id = get(refreshWalletBalancesIdAtom(walletAddress))

const collections: CollectionWithTokens[] = get(
queryWalletIndexerSelector({
queryAccountIndexerSelector({
chainId,
walletAddress,
formula: 'nft/stakedWithDaos',
Expand Down
10 changes: 5 additions & 5 deletions packages/state/recoil/selectors/wallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ import { votingModuleSelector } from './contracts/DaoDaoCore'
import * as DaoVotingTokenStaked from './contracts/DaoVotingTokenStaked'
import { lazyDaoCardPropsSelector } from './dao'
import { followingDaosSelector } from './following'
import { queryWalletIndexerSelector } from './indexer'
import { queryAccountIndexerSelector } from './indexer'
import {
walletLazyNftCardInfosSelector,
walletStakedLazyNftCardInfosSelector,
Expand All @@ -67,7 +67,7 @@ export const walletCw20BalancesSelector = selectorFamily<
balance: string
}[] =
get(
queryWalletIndexerSelector({
queryAccountIndexerSelector({
chainId,
walletAddress,
formula: 'tokens/list',
Expand Down Expand Up @@ -105,7 +105,7 @@ export const walletTokenDaoStakedDenomsSelector = selectorFamily<
({ get }) => {
// Get the DAOs that the wallet is a member of
const daos = get(
queryWalletIndexerSelector({
queryAccountIndexerSelector({
chainId,
walletAddress,
formula: 'daos/memberOf',
Expand Down Expand Up @@ -327,7 +327,7 @@ export const walletTokenCardInfosSelector = selectorFamily<
| undefined
> = get(
noWait(
queryWalletIndexerSelector({
queryAccountIndexerSelector({
chainId,
walletAddress,
formula: 'tokens/list',
Expand Down Expand Up @@ -512,7 +512,7 @@ export const lazyWalletDaosSelector = selectorFamily<
config: DaoDaoCoreConfig
proposalCount: number
}[] = get(
queryWalletIndexerSelector({
queryAccountIndexerSelector({
chainId,
walletAddress: address,
formula: 'daos/memberOf',
Expand Down
4 changes: 2 additions & 2 deletions packages/stateful/recoil/selectors/dao.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ import {
daoVetoableDaosSelector,
followingDaosSelector,
isDaoSelector,
queryAccountIndexerSelector,
queryClientAtom,
queryWalletIndexerSelector,
refreshProposalsIdAtom,
} from '@dao-dao/state'
import {
Expand Down Expand Up @@ -202,7 +202,7 @@ export const daosWithVetoableProposalsSelector = selectorFamily<
get(
waitForAll(
accounts.map(({ chainId, address }) =>
queryWalletIndexerSelector({
queryAccountIndexerSelector({
chainId,
walletAddress: address,
formula: 'veto/vetoableProposals',
Expand Down
2 changes: 1 addition & 1 deletion packages/types/indexer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ import {
} from './contracts/DaoDaoCore'

export enum IndexerFormulaType {
Account = 'account',
Contract = 'contract',
Generic = 'generic',
Validator = 'validator',
Wallet = 'wallet',
}

export interface IndexerDumpState
Expand Down

0 comments on commit bfdd60a

Please sign in to comment.