diff --git a/.changeset/friendly-donuts-whisper.md b/.changeset/friendly-donuts-whisper.md new file mode 100644 index 00000000..5905f60f --- /dev/null +++ b/.changeset/friendly-donuts-whisper.md @@ -0,0 +1,6 @@ +--- +"@reactive-dot/react": patch +"@reactive-dot/vue": patch +--- + +Refactored generic type parameters for chain IDs & descriptors. diff --git a/packages/react/src/hooks/use-query-loader.ts b/packages/react/src/hooks/use-query-loader.ts index 8ec7214b..5bb80696 100644 --- a/packages/react/src/hooks/use-query-loader.ts +++ b/packages/react/src/hooks/use-query-loader.ts @@ -23,11 +23,13 @@ export function useQueryLoader() { const _loadQuery = useCallback( (get: Getter) => < - TQuery extends ( - builder: Query<[], TDescriptor>, - ) => Query[], TDescriptor>, - TDescriptor extends ChainDescriptorOf, TChainId extends ChainId | undefined, + TQuery extends ( + builder: Query<[], ChainDescriptorOf>, + ) => Query< + QueryInstruction>[], + ChainDescriptorOf + >, >( builder: TQuery, options?: ChainHookOptions, diff --git a/packages/react/src/hooks/use-query-refresher.ts b/packages/react/src/hooks/use-query-refresher.ts index 0689fab4..2f919512 100644 --- a/packages/react/src/hooks/use-query-refresher.ts +++ b/packages/react/src/hooks/use-query-refresher.ts @@ -19,13 +19,17 @@ import { useCallback } from "react"; * @returns The function to refresh the query */ export function useQueryRefresher< + TChainId extends ChainId | undefined, TQuery extends | (( - builder: Query<[], TDescriptor>, - ) => Query[], TDescriptor> | Falsy) + builder: Query<[], ChainDescriptorOf>, + ) => + | Query< + QueryInstruction>[], + ChainDescriptorOf + > + | Falsy) | Falsy, - TDescriptor extends ChainDescriptorOf, - TChainId extends ChainId | undefined, >(builder: TQuery, options?: ChainHookOptions) { const config = useConfig(); const chainId = internal_useChainId(options); diff --git a/packages/react/src/hooks/use-query.ts b/packages/react/src/hooks/use-query.ts index 126c529d..7c03986f 100644 --- a/packages/react/src/hooks/use-query.ts +++ b/packages/react/src/hooks/use-query.ts @@ -25,13 +25,17 @@ import { useMemo } from "react"; * @returns The data response */ export function useLazyLoadQuery< + TChainId extends ChainId | undefined, TQuery extends | (( - builder: Query<[], TDescriptor>, - ) => Query[], TDescriptor> | Falsy) + builder: Query<[], ChainDescriptorOf>, + ) => + | Query< + QueryInstruction>[], + ChainDescriptorOf + > + | Falsy) | Falsy, - TDescriptor extends ChainDescriptorOf, - TChainId extends ChainId | undefined, >(builder: TQuery, options?: ChainHookOptions) { const config = useConfig(); const chainId = internal_useChainId(options); @@ -86,10 +90,14 @@ export function useLazyLoadQuery< export function useLazyLoadQueryWithRefresh< TQuery extends | (( - builder: Query<[], TDescriptor>, - ) => Query[], TDescriptor> | Falsy) + builder: Query<[], ChainDescriptorOf>, + ) => + | Query< + QueryInstruction>[], + ChainDescriptorOf + > + | Falsy) | Falsy, - TDescriptor extends ChainDescriptorOf, TChainId extends ChainId | undefined, >(builder: TQuery, options?: ChainHookOptions) { const data = useLazyLoadQuery(builder, options); diff --git a/packages/vue/src/composables/use-query.ts b/packages/vue/src/composables/use-query.ts index 001e7137..b5d46a83 100644 --- a/packages/vue/src/composables/use-query.ts +++ b/packages/vue/src/composables/use-query.ts @@ -40,11 +40,15 @@ import { * @returns The data response */ export function useQuery< - TQuery extends ( - builder: Query<[], TDescriptor>, - ) => Query[], TDescriptor> | Falsy, - TDescriptor extends ChainDescriptorOf, TChainId extends ChainId | undefined, + TQuery extends ( + builder: Query<[], ChainDescriptorOf>, + ) => + | Query< + QueryInstruction>[], + ChainDescriptorOf + > + | Falsy, >(builder: TQuery, options?: ChainComposableOptions) { const chainId = internal_useChainId(options); const typedApiPromise = useTypedApiPromise(options);