Skip to content
Merged
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
2 changes: 1 addition & 1 deletion next-env.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
/// <reference types="next/image-types/global" />

// NOTE: This file should not be edited
// see https://nextjs.org/docs/app/building-your-application/configuring/typescript for more information.
// see https://nextjs.org/docs/app/api-reference/config/typescript for more information.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
"tailwindcss-animate": "^1.0.7",
"url-join": "^5.0.0",
"vaul": "^1.1.1",
"viem": "^2.21.51",
"viem": "^2.31.0",
"zod": "^3.23.8"
},
"devDependencies": {
Expand Down
128 changes: 63 additions & 65 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

44 changes: 27 additions & 17 deletions src/api/account.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,44 +2,54 @@

import { endpoint } from "@/api"
import { api } from "@/api/api-client"
import { isUndefined, omitBy } from "lodash-es"
import { omitBy } from "lodash-es"
import { type Address } from "viem"

import type {
FilteredAccountsResponse,
AccountStatsResponse,
PaginatedAccountsResponse,
} from "@/types/api/account"
import { type ClustersSearchSchema } from "@/lib/search-parsers/clusters-search-parsers"
import type { AccountsSearchSchema } from "@/lib/search-parsers/accounts-search-parsers"
import { stringifyBigints } from "@/lib/utils/bigint"
import { unstable_cache } from "@/lib/utils/unstable-cache"

export const getAccounts = async (
params: Partial<ClustersSearchSchema> & Pick<ClustersSearchSchema, "network">
params: Partial<AccountsSearchSchema> & Pick<AccountsSearchSchema, "network">
): Promise<PaginatedAccountsResponse> =>
await unstable_cache(
async () => {
const filtered = omitBy(params, isUndefined)
const filtered = omitBy(
params,
(value) => value === undefined || value === null
)

const searchParams = new URLSearchParams(
filtered as unknown as Record<string, string>
)
const data = await api.get<FilteredAccountsResponse>(

return api.get<PaginatedAccountsResponse>(
endpoint(params.network, "accounts", `?${searchParams}`)
)

return {
type: "accounts",
accounts: data.data,
pagination: {
page: data.filter.page,
per_page: data.filter.perPage,
total: 1000,
pages: 100,
},
} satisfies PaginatedAccountsResponse
},
[JSON.stringify(stringifyBigints(params))],
{
revalidate: 30,
tags: ["accounts"],
}
)()

export const getAccountStats = async (
params: { address: Address } & Pick<AccountsSearchSchema, "network">
) =>
await unstable_cache(
async () => {
return api.get<AccountStatsResponse>(
endpoint(params.network, "accounts/counts", params.address)
)
},
[JSON.stringify(stringifyBigints(params))],
{
revalidate: 30,
tags: ["account-stats"],
}
)()
6 changes: 3 additions & 3 deletions src/api/clusters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ export const searchClusters = async <
filtered as unknown as Record<string, string>
)

const e = endpoint(params.network, "clusters", `?${searchParams}`)
console.log("e:", e)
return await api.get<PaginatedClustersResponse<T>>(e)
return await api.get<PaginatedClustersResponse<T>>(
endpoint(params.network, "clusters", `?${searchParams}`)
)
},
[JSON.stringify(stringifyBigints(params))],
{
Expand Down
5 changes: 3 additions & 2 deletions src/api/validators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,9 @@ export const searchValidators = async (
const searchParams = new URLSearchParams(
filtered as unknown as Record<string, string>
)
const url = endpoint(params.network, "validators", `?${searchParams}`)
const response = await api.get<PaginatedValidatorsResponse>(url)
const response = await api.get<PaginatedValidatorsResponse>(
endpoint(params.network, "validators", `?${searchParams}`)
)
return response
},
[JSON.stringify(stringifyBigints(params))],
Expand Down
Loading