Skip to content

Commit

Permalink
refactor: change useBlockNumber to use the same custom `createQuery…
Browse files Browse the repository at this point in the history
…` as `useBalance`
  • Loading branch information
ByteAtATime committed Oct 26, 2024
1 parent 663e516 commit 5af6c65
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions packages/svelte/src/lib/hooks/useBlockNumber.svelte.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
import {
type CreateQueryResult,
createQuery,
useQueryClient,
} from '@tanstack/svelte-query'
import { useQueryClient } from '@tanstack/svelte-query'
import type {
Config,
GetBlockNumberErrorType,
Expand All @@ -27,6 +23,7 @@ import {
type UseWatchBlockNumberParameters,
useWatchBlockNumber,
} from '$lib/hooks/useWatchBlockNumber.svelte.js'
import { type CreateQueryReturnType, createQuery } from '$lib/query.svelte.js'
import type {
ConfigParameter,
QueryParameter,
Expand Down Expand Up @@ -63,7 +60,7 @@ export type UseBlockNumberParameters<
>

export type UseBlockNumberReturnType<selectData = GetBlockNumberData> =
RuneReturnType<CreateQueryResult<selectData, GetBlockNumberErrorType>>
RuneReturnType<CreateQueryReturnType<selectData, GetBlockNumberErrorType>>

/** https://wagmi.sh/react/api/hooks/useBlockNumber */
export function useBlockNumber<
Expand Down Expand Up @@ -107,7 +104,5 @@ export function useBlockNumber<
},
}))

const queryFn = createQuery(() => ({ ...query, ...options }))

return () => queryFn
return createQuery(() => ({ ...query, ...options }))
}

0 comments on commit 5af6c65

Please sign in to comment.