This repository has been archived by the owner on May 16, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #140 from unicape/1.x
chore: Added useBytecode useProof useStorageAt useTransactionReceipt
- Loading branch information
Showing
12 changed files
with
389 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
"@use-wagmi/nuxt": minor | ||
"use-wagmi": minor | ||
--- | ||
|
||
Added useBytecode useProof useStorageAt useTransactionReceipt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
'use client' | ||
|
||
import { | ||
type Config, | ||
type GetBytecodeErrorType, | ||
type ResolvedRegister, | ||
} from '@wagmi/core' | ||
import type { Evaluate } from '@wagmi/core/internal' | ||
import { | ||
type GetBytecodeData, | ||
type GetBytecodeOptions, | ||
type GetBytecodeQueryKey, | ||
getBytecodeQueryOptions, | ||
} from '@wagmi/core/query' | ||
import { type GetBytecodeQueryFnData } from '@wagmi/core/query' | ||
import { computed } from 'vue-demi' | ||
import { | ||
type ConfigParameter, | ||
type DeepUnwrapRef, | ||
type MaybeRefDeep, | ||
type QueryParameter, | ||
} from '../types.js' | ||
import { cloneDeepUnref } from '../utils/cloneDeepUnref.js' | ||
import { type UseQueryReturnType, useQuery } from '../utils/query.js' | ||
import { useChainId } from './useChainId.js' | ||
import { useConfig } from './useConfig.js' | ||
|
||
export type UseBytecodeParameters< | ||
config extends Config = Config, | ||
selectData = GetBytecodeData, | ||
> = MaybeRefDeep< | ||
Evaluate< | ||
GetBytecodeOptions<config> & | ||
ConfigParameter<config> & | ||
QueryParameter< | ||
GetBytecodeQueryFnData, | ||
GetBytecodeErrorType, | ||
selectData, | ||
GetBytecodeQueryKey<config> | ||
> | ||
> | ||
> | ||
|
||
export type UseBytecodeReturnType<selectData = GetBytecodeData> = | ||
UseQueryReturnType<selectData, GetBytecodeErrorType> | ||
|
||
/** https://wagmi.sh/react/api/hooks/useBytecode */ | ||
export function useBytecode< | ||
config extends Config = ResolvedRegister['config'], | ||
selectData = GetBytecodeData, | ||
>( | ||
parameters: UseBytecodeParameters<config, selectData> = {}, | ||
): UseBytecodeReturnType<selectData> { | ||
const config = useConfig(parameters) | ||
const chainId = useChainId() | ||
|
||
const queryOptions = computed(() => { | ||
const _parameters = cloneDeepUnref< | ||
DeepUnwrapRef<UseBytecodeParameters<config, selectData>> | ||
>(parameters as any) | ||
|
||
const { address, query = {} } = _parameters | ||
const options = getBytecodeQueryOptions(config, { | ||
..._parameters, | ||
chainId: _parameters.chainId ?? chainId.value, | ||
}) | ||
const enabled = Boolean(address && (query.enabled ?? true)) | ||
|
||
return { | ||
...query, | ||
...options, | ||
enabled, | ||
} | ||
}) | ||
|
||
return useQuery(queryOptions as any) as UseBytecodeReturnType<selectData> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
'use client' | ||
|
||
import { | ||
type Config, | ||
type GetProofErrorType, | ||
type ResolvedRegister, | ||
} from '@wagmi/core' | ||
import type { Evaluate } from '@wagmi/core/internal' | ||
import { | ||
type GetProofData, | ||
type GetProofOptions, | ||
type GetProofQueryKey, | ||
getProofQueryOptions, | ||
} from '@wagmi/core/query' | ||
import { type GetProofQueryFnData } from '@wagmi/core/query' | ||
|
||
import { computed } from 'vue-demi' | ||
import { | ||
type ConfigParameter, | ||
type DeepUnwrapRef, | ||
type MaybeRefDeep, | ||
type QueryParameter, | ||
} from '../types.js' | ||
import { cloneDeepUnref } from '../utils/cloneDeepUnref.js' | ||
import { type UseQueryReturnType, useQuery } from '../utils/query.js' | ||
import { useChainId } from './useChainId.js' | ||
import { useConfig } from './useConfig.js' | ||
|
||
export type UseProofParameters< | ||
config extends Config = Config, | ||
selectData = GetProofData, | ||
> = MaybeRefDeep< | ||
Evaluate< | ||
GetProofOptions<config> & | ||
ConfigParameter<config> & | ||
QueryParameter< | ||
GetProofQueryFnData, | ||
GetProofErrorType, | ||
selectData, | ||
GetProofQueryKey<config> | ||
> | ||
> | ||
> | ||
|
||
export type UseProofReturnType<selectData = GetProofData> = UseQueryReturnType< | ||
selectData, | ||
GetProofErrorType | ||
> | ||
|
||
/** https://wagmi.sh/react/api/hooks/useProof */ | ||
export function useProof< | ||
config extends Config = ResolvedRegister['config'], | ||
selectData = GetProofData, | ||
>( | ||
parameters: UseProofParameters<config, selectData> = {}, | ||
): UseProofReturnType<selectData> { | ||
const config = useConfig(parameters) | ||
const chainId = useChainId() | ||
|
||
const queryOptions = computed(() => { | ||
const _parameters = | ||
cloneDeepUnref<DeepUnwrapRef<UseProofParameters<config, selectData>>>( | ||
parameters, | ||
) | ||
|
||
const { address, storageKeys, query = {} } = _parameters | ||
|
||
const options = getProofQueryOptions(config, { | ||
..._parameters, | ||
chainId: _parameters.chainId ?? chainId.value, | ||
}) | ||
const enabled = Boolean(address && storageKeys && (query.enabled ?? true)) | ||
|
||
return { | ||
...query, | ||
...options, | ||
enabled, | ||
} | ||
}) | ||
|
||
return useQuery(queryOptions as any) as UseProofReturnType<selectData> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
'use client' | ||
|
||
import { | ||
type Config, | ||
type GetStorageAtErrorType, | ||
type ResolvedRegister, | ||
} from '@wagmi/core' | ||
import type { Evaluate } from '@wagmi/core/internal' | ||
import { | ||
type GetStorageAtData, | ||
type GetStorageAtOptions, | ||
type GetStorageAtQueryKey, | ||
getStorageAtQueryOptions, | ||
} from '@wagmi/core/query' | ||
import { type GetStorageAtQueryFnData } from '@wagmi/core/query' | ||
import { computed } from 'vue-demi' | ||
import { | ||
type ConfigParameter, | ||
type DeepUnwrapRef, | ||
type MaybeRefDeep, | ||
type QueryParameter, | ||
} from '../types.js' | ||
import { cloneDeepUnref } from '../utils/cloneDeepUnref.js' | ||
import { type UseQueryReturnType, useQuery } from '../utils/query.js' | ||
import { useChainId } from './useChainId.js' | ||
import { useConfig } from './useConfig.js' | ||
|
||
export type UseStorageAtParameters< | ||
config extends Config = Config, | ||
selectData = GetStorageAtData, | ||
> = MaybeRefDeep< | ||
Evaluate< | ||
GetStorageAtOptions<config> & | ||
ConfigParameter<config> & | ||
QueryParameter< | ||
GetStorageAtQueryFnData, | ||
GetStorageAtErrorType, | ||
selectData, | ||
GetStorageAtQueryKey<config> | ||
> | ||
> | ||
> | ||
|
||
export type UseStorageAtReturnType<selectData = GetStorageAtData> = | ||
UseQueryReturnType<selectData, GetStorageAtErrorType> | ||
|
||
/** https://wagmi.sh/react/api/hooks/useStorageAt */ | ||
export function useStorageAt< | ||
config extends Config = ResolvedRegister['config'], | ||
selectData = GetStorageAtData, | ||
>( | ||
parameters: UseStorageAtParameters<config, selectData> = {}, | ||
): UseStorageAtReturnType<selectData> { | ||
const config = useConfig(parameters) | ||
const chainId = useChainId() | ||
|
||
const queryOptions = computed(() => { | ||
const _parameters = cloneDeepUnref< | ||
DeepUnwrapRef<UseStorageAtParameters<config, selectData>> | ||
>(parameters as any) | ||
|
||
const { address, slot, query = {} } = _parameters | ||
const options = getStorageAtQueryOptions(config, { | ||
..._parameters, | ||
chainId: _parameters.chainId ?? chainId.value, | ||
}) | ||
const enabled = Boolean(address && slot && (query.enabled ?? true)) | ||
|
||
return { | ||
...query, | ||
...options, | ||
enabled, | ||
} | ||
}) | ||
|
||
return useQuery(queryOptions as any) as UseStorageAtReturnType<selectData> | ||
} |
Oops, something went wrong.