-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added remaining public funcs + package.json updates
- Loading branch information
Showing
19 changed files
with
1,013 additions
and
29 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 |
---|---|---|
|
@@ -74,7 +74,11 @@ | |
"!src/**/*.test.ts", | ||
"!src/test" | ||
], | ||
"repository": "[email protected]:ensdomains/ensjs.git", | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/ensdomains/ensjs.git", | ||
"directory": "packages/ensjs" | ||
}, | ||
"author": "TateB <[email protected]>", | ||
"license": "MIT", | ||
"scripts": { | ||
|
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 |
---|---|---|
|
@@ -14,6 +14,11 @@ | |
"import": "./dist/esm/index.js", | ||
"default": "./dist/cjs/index.js" | ||
}, | ||
"./query": { | ||
"types": "./dist/types/query.d.ts", | ||
"import": "./dist/esm/query.js", | ||
"default": "./dist/cjs/query.js" | ||
}, | ||
"./package.json": "./package.json" | ||
}, | ||
"files": [ | ||
|
@@ -22,8 +27,15 @@ | |
"!src/**/*.test.ts", | ||
"!src/test" | ||
], | ||
"repository": "[email protected]:ensdomains/ensjs.git", | ||
"author": "Lucemans <[email protected]>", | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/ensdomains/ensjs.git", | ||
"directory": "packages/react" | ||
}, | ||
"contributors": [ | ||
"TateB <[email protected]>", | ||
"Lucemans <[email protected]>" | ||
], | ||
"license": "MIT", | ||
"scripts": { | ||
"clean": "rm -rf ./dist", | ||
|
@@ -49,7 +61,8 @@ | |
"peerDependencies": { | ||
"@tanstack/react-query": "^5.54", | ||
"viem": "^2.9.2", | ||
"wagmi": "^2" | ||
"wagmi": "^2", | ||
"@ensdomains/ensjs": "^4.0.1" | ||
}, | ||
"engines": { | ||
"node": ">=18" | ||
|
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,57 @@ | ||
import { useChainId, useConfig } from 'wagmi' | ||
import { useQuery, type UseQueryReturnType } from 'wagmi/query' | ||
import { | ||
getEnsAbiQueryOptions, | ||
type GetEnsAbiData, | ||
type GetEnsAbiErrorType, | ||
type GetEnsAbiOptions, | ||
type GetEnsAbiQueryFnData, | ||
type GetEnsAbiQueryKey, | ||
} from '../query/getEnsAbi.js' | ||
import type { ConfigWithEns } from '../types/config.js' | ||
import type { ConfigParameter, QueryParameter } from '../types/properties.js' | ||
import type { ResolvedRegister } from '../types/register.js' | ||
import type { Compute } from '../types/utils.js' | ||
|
||
export type UseEnsAbiParameters< | ||
config extends ConfigWithEns = ConfigWithEns, | ||
selectData = GetEnsAbiData, | ||
> = Compute< | ||
GetEnsAbiOptions<config> & | ||
ConfigParameter<config> & | ||
QueryParameter< | ||
GetEnsAbiQueryFnData, | ||
GetEnsAbiErrorType, | ||
selectData, | ||
GetEnsAbiQueryKey<config> | ||
> | ||
> | ||
|
||
export type UseEnsAbiReturnType<selectData = GetEnsAbiData> = | ||
UseQueryReturnType<selectData, GetEnsAbiErrorType> | ||
|
||
/** | ||
* Returns the ABI for a name | ||
* | ||
* @param parameters - {@link UseEnsAbiParameters} | ||
* @returns - {@link UseEnsAbiReturnType} | ||
*/ | ||
export const useEnsAbi = < | ||
config extends ConfigWithEns = ResolvedRegister['config'], | ||
selectData = GetEnsAbiData, | ||
>( | ||
parameters: UseEnsAbiParameters<config, selectData> = {}, | ||
): UseEnsAbiReturnType<selectData> => { | ||
const { name, query = {} } = parameters | ||
|
||
const config = useConfig<ConfigWithEns>() | ||
const chainId = useChainId({ config }) | ||
|
||
const options = getEnsAbiQueryOptions(config, { | ||
...parameters, | ||
chainId: parameters.chainId ?? chainId, | ||
}) | ||
const enabled = Boolean(name && (query.enabled ?? true)) | ||
|
||
return useQuery({ ...query, ...options, enabled }) | ||
} |
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,57 @@ | ||
import { useChainId, useConfig } from 'wagmi' | ||
import { useQuery, type UseQueryReturnType } from 'wagmi/query' | ||
import { | ||
getEnsAddressQueryOptions, | ||
type GetEnsAddressData, | ||
type GetEnsAddressErrorType, | ||
type GetEnsAddressOptions, | ||
type GetEnsAddressQueryFnData, | ||
type GetEnsAddressQueryKey, | ||
} from '../query/getEnsAddress.js' | ||
import type { ConfigWithEns } from '../types/config.js' | ||
import type { ConfigParameter, QueryParameter } from '../types/properties.js' | ||
import type { ResolvedRegister } from '../types/register.js' | ||
import type { Compute } from '../types/utils.js' | ||
|
||
export type UseEnsAddressParameters< | ||
config extends ConfigWithEns = ConfigWithEns, | ||
selectData = GetEnsAddressData, | ||
> = Compute< | ||
GetEnsAddressOptions<config> & | ||
ConfigParameter<config> & | ||
QueryParameter< | ||
GetEnsAddressQueryFnData, | ||
GetEnsAddressErrorType, | ||
selectData, | ||
GetEnsAddressQueryKey<config> | ||
> | ||
> | ||
|
||
export type UseEnsAddressReturnType<selectData = GetEnsAddressData> = | ||
UseQueryReturnType<selectData, GetEnsAddressErrorType> | ||
|
||
/** | ||
* Returns the address for a name | ||
* | ||
* @param parameters - {@link UseEnsAddressParameters} | ||
* @returns - {@link UseEnsAddressReturnType} | ||
*/ | ||
export const useEnsAddress = < | ||
config extends ConfigWithEns = ResolvedRegister['config'], | ||
selectData = GetEnsAddressData, | ||
>( | ||
parameters: UseEnsAddressParameters<config, selectData> = {}, | ||
): UseEnsAddressReturnType<selectData> => { | ||
const { name, query = {} } = parameters | ||
|
||
const config = useConfig<ConfigWithEns>() | ||
const chainId = useChainId({ config }) | ||
|
||
const options = getEnsAddressQueryOptions(config, { | ||
...parameters, | ||
chainId: parameters.chainId ?? chainId, | ||
}) | ||
const enabled = Boolean(name && (query.enabled ?? true)) | ||
|
||
return useQuery({ ...query, ...options, enabled }) | ||
} |
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,57 @@ | ||
import { useChainId, useConfig } from 'wagmi' | ||
import { useQuery, type UseQueryReturnType } from 'wagmi/query' | ||
import { | ||
getEnsContentHashQueryOptions, | ||
type GetEnsContentHashData, | ||
type GetEnsContentHashErrorType, | ||
type GetEnsContentHashOptions, | ||
type GetEnsContentHashQueryFnData, | ||
type GetEnsContentHashQueryKey, | ||
} from '../query/getEnsContentHash.js' | ||
import type { ConfigWithEns } from '../types/config.js' | ||
import type { ConfigParameter, QueryParameter } from '../types/properties.js' | ||
import type { ResolvedRegister } from '../types/register.js' | ||
import type { Compute } from '../types/utils.js' | ||
|
||
export type UseEnsContentHashParameters< | ||
config extends ConfigWithEns = ConfigWithEns, | ||
selectData = GetEnsContentHashData, | ||
> = Compute< | ||
GetEnsContentHashOptions<config> & | ||
ConfigParameter<config> & | ||
QueryParameter< | ||
GetEnsContentHashQueryFnData, | ||
GetEnsContentHashErrorType, | ||
selectData, | ||
GetEnsContentHashQueryKey<config> | ||
> | ||
> | ||
|
||
export type UseEnsContentHashReturnType<selectData = GetEnsContentHashData> = | ||
UseQueryReturnType<selectData, GetEnsContentHashErrorType> | ||
|
||
/** | ||
* Returns the content hash for a name | ||
* | ||
* @param parameters - {@link UseEnsContentHashParameters} | ||
* @returns - {@link UseEnsContentHashReturnType} | ||
*/ | ||
export const useEnsContentHash = < | ||
config extends ConfigWithEns = ResolvedRegister['config'], | ||
selectData = GetEnsContentHashData, | ||
>( | ||
parameters: UseEnsContentHashParameters<config, selectData> = {}, | ||
): UseEnsContentHashReturnType<selectData> => { | ||
const { name, query = {} } = parameters | ||
|
||
const config = useConfig<ConfigWithEns>() | ||
const chainId = useChainId({ config }) | ||
|
||
const options = getEnsContentHashQueryOptions(config, { | ||
...parameters, | ||
chainId: parameters.chainId ?? chainId, | ||
}) | ||
const enabled = Boolean(name && (query.enabled ?? true)) | ||
|
||
return useQuery({ ...query, ...options, enabled }) | ||
} |
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,57 @@ | ||
import { useChainId, useConfig } from 'wagmi' | ||
import { useQuery, type UseQueryReturnType } from 'wagmi/query' | ||
import { | ||
getEnsOwnerQueryOptions, | ||
type GetEnsOwnerData, | ||
type GetEnsOwnerErrorType, | ||
type GetEnsOwnerOptions, | ||
type GetEnsOwnerQueryFnData, | ||
type GetEnsOwnerQueryKey, | ||
} from '../query/getEnsOwner.js' | ||
import type { ConfigWithEns } from '../types/config.js' | ||
import type { ConfigParameter, QueryParameter } from '../types/properties.js' | ||
import type { ResolvedRegister } from '../types/register.js' | ||
import type { Compute } from '../types/utils.js' | ||
|
||
export type UseEnsOwnerParameters< | ||
config extends ConfigWithEns = ConfigWithEns, | ||
selectData = GetEnsOwnerData, | ||
> = Compute< | ||
GetEnsOwnerOptions<config> & | ||
ConfigParameter<config> & | ||
QueryParameter< | ||
GetEnsOwnerQueryFnData, | ||
GetEnsOwnerErrorType, | ||
selectData, | ||
GetEnsOwnerQueryKey<config> | ||
> | ||
> | ||
|
||
export type UseEnsOwnerReturnType<selectData = GetEnsOwnerData> = | ||
UseQueryReturnType<selectData, GetEnsOwnerErrorType> | ||
|
||
/** | ||
* Returns the owner of a name | ||
* | ||
* @param parameters - {@link UseEnsOwnerParameters} | ||
* @returns - {@link UseEnsOwnerReturnType} | ||
*/ | ||
export const useEnsOwner = < | ||
config extends ConfigWithEns = ResolvedRegister['config'], | ||
selectData = GetEnsOwnerData, | ||
>( | ||
parameters: UseEnsOwnerParameters<config, selectData> = {}, | ||
): UseEnsOwnerReturnType<selectData> => { | ||
const { name, query = {} } = parameters | ||
|
||
const config = useConfig<ConfigWithEns>() | ||
const chainId = useChainId({ config }) | ||
|
||
const options = getEnsOwnerQueryOptions(config, { | ||
...parameters, | ||
chainId: parameters.chainId ?? chainId, | ||
}) | ||
const enabled = Boolean(name && (query.enabled ?? true)) | ||
|
||
return useQuery({ ...query, ...options, enabled }) | ||
} |
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,57 @@ | ||
import { useChainId, useConfig } from 'wagmi' | ||
import { useQuery, type UseQueryReturnType } from 'wagmi/query' | ||
import { | ||
getEnsPriceQueryOptions, | ||
type GetEnsPriceData, | ||
type GetEnsPriceErrorType, | ||
type GetEnsPriceOptions, | ||
type GetEnsPriceQueryFnData, | ||
type GetEnsPriceQueryKey, | ||
} from '../query/getEnsPrice.js' | ||
import type { ConfigWithEns } from '../types/config.js' | ||
import type { ConfigParameter, QueryParameter } from '../types/properties.js' | ||
import type { ResolvedRegister } from '../types/register.js' | ||
import type { Compute } from '../types/utils.js' | ||
|
||
export type UseEnsPriceParameters< | ||
config extends ConfigWithEns = ConfigWithEns, | ||
selectData = GetEnsPriceData, | ||
> = Compute< | ||
GetEnsPriceOptions<config> & | ||
ConfigParameter<config> & | ||
QueryParameter< | ||
GetEnsPriceQueryFnData, | ||
GetEnsPriceErrorType, | ||
selectData, | ||
GetEnsPriceQueryKey<config> | ||
> | ||
> | ||
|
||
export type UseEnsPriceReturnType<selectData = GetEnsPriceData> = | ||
UseQueryReturnType<selectData, GetEnsPriceErrorType> | ||
|
||
/** | ||
* Returns the price for registering or renewing a name | ||
* | ||
* @param parameters - {@link UseEnsPriceParameters} | ||
* @returns - {@link UseEnsPriceReturnType} | ||
*/ | ||
export const useEnsPrice = < | ||
config extends ConfigWithEns = ResolvedRegister['config'], | ||
selectData = GetEnsPriceData, | ||
>( | ||
parameters: UseEnsPriceParameters<config, selectData> = {}, | ||
): UseEnsPriceReturnType<selectData> => { | ||
const { nameOrNames, duration, query = {} } = parameters | ||
|
||
const config = useConfig<ConfigWithEns>() | ||
const chainId = useChainId({ config }) | ||
|
||
const options = getEnsPriceQueryOptions(config, { | ||
...parameters, | ||
chainId: parameters.chainId ?? chainId, | ||
}) | ||
const enabled = Boolean(nameOrNames && duration && (query.enabled ?? true)) | ||
|
||
return useQuery({ ...query, ...options, enabled }) | ||
} |
Oops, something went wrong.