(
config: config,
options: GetBytecodeOptions<config> = {},
)
| 16 | > |
| 17 | |
| 18 | export function getBytecodeQueryOptions<config extends Config>( |
| 19 | config: config, |
| 20 | options: GetBytecodeOptions<config> = {}, |
| 21 | ) { |
| 22 | return { |
| 23 | async queryFn({ queryKey }) { |
| 24 | const { address, scopeKey: _, ...parameters } = queryKey[1] |
| 25 | if (!address) throw new Error('address is required') |
| 26 | const bytecode = await getBytecode(config, { ...parameters, address }) |
| 27 | return (bytecode ?? null) as any |
| 28 | }, |
| 29 | queryKey: getBytecodeQueryKey(options), |
| 30 | } as const satisfies QueryOptions< |
| 31 | GetBytecodeQueryFnData, |
| 32 | GetBytecodeErrorType, |
| 33 | GetBytecodeData, |
| 34 | GetBytecodeQueryKey<config> |
| 35 | > |
| 36 | } |
| 37 | export type GetBytecodeQueryFnData = GetBytecodeReturnType |
| 38 | |
| 39 | export type GetBytecodeData = GetBytecodeQueryFnData |
no test coverage detected