-
Notifications
You must be signed in to change notification settings - Fork 165
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Co-authored-by: Leonardo Zizzamia <[email protected]>
- Loading branch information
1 parent
6b7885c
commit 4090f4f
Showing
20 changed files
with
313 additions
and
236 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,59 @@ | ||
--- | ||
'@coinbase/onchainkit': minor | ||
--- | ||
|
||
**feat**: Replace internal `useOnchainActionWithCache` with `tanstack/react-query`. This affects `useName` and `useAvatar` hooks. The return type and the input parameters also changed for these 2 hooks. | ||
|
||
BREAKING CHANGES | ||
|
||
The input parameters as well as return types of `useName` and `useAvatar` hooks have changed. The return type of `useName` and `useAvatar` hooks changed. | ||
|
||
### `useName` | ||
|
||
Before | ||
|
||
```tsx | ||
import { useName } from '@coinbase/onchainkit/identity'; | ||
|
||
const { ensName, isLoading } = useName('0x1234'); | ||
``` | ||
|
||
After | ||
|
||
```tsx | ||
import { useName } from '@coinbase/onchainkit/identity'; | ||
|
||
// Return type signature is following @tanstack/react-query useQuery hook signature | ||
const { | ||
data: name, | ||
isLoading, | ||
isError, | ||
error, | ||
status, | ||
} = useName({ address: '0x1234' }, { enabled: true, cacheTime: 1000 * 60 * 60 * 24 }); | ||
``` | ||
|
||
### `useAvatar` | ||
|
||
Before | ||
|
||
```tsx | ||
import { useAvatar } from '@coinbase/onchainkit/identity'; | ||
|
||
const { ensAvatar, isLoading } = useAvatar('vitalik.eth'); | ||
``` | ||
|
||
After | ||
|
||
```tsx | ||
import { useAvatar } from '@coinbase/onchainkit/identity'; | ||
|
||
// Return type signature is following @tanstack/react-query useQuery hook signature | ||
const { | ||
data: avatar, | ||
isLoading, | ||
isError, | ||
error, | ||
status, | ||
} = useAvatar({ ensName: 'vitalik.eth' }, { enabled: true, cacheTime: 1000 * 60 * 60 * 24 }); | ||
``` |
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,35 @@ | ||
# `useAvatar` | ||
|
||
The `useAvatar` hook is used to get avatar image url from an onchain identity provider for a given name. | ||
|
||
Supported providers: | ||
|
||
- ENS | ||
|
||
## Usage | ||
|
||
```tsx | ||
import { useAvatar } from '@coinbase/onchainkit/identity'; | ||
|
||
// Return type signature is following @tanstack/react-query useQuery hook signature | ||
const { | ||
data: avatar, | ||
isLoading, | ||
isError, | ||
error, | ||
status, | ||
} = useAvatar({ ensName: 'vitalik.eth' }, { enabled: true, cacheTime: 1000 * 60 * 60 * 24 }); | ||
``` | ||
|
||
## Props | ||
|
||
```ts | ||
type UseAvatarOptions = { | ||
ensName: string; | ||
}; | ||
|
||
type UseAvatarQueryOptions = { | ||
enabled?: boolean; | ||
cacheTime?: number; | ||
}; | ||
``` |
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,35 @@ | ||
# `useName` | ||
|
||
The `useName` hook is used to get name from an onchain identity provider for a given address. | ||
|
||
Supported providers: | ||
|
||
- ENS | ||
|
||
## Usage | ||
|
||
```tsx | ||
import { useName } from '@coinbase/onchainkit/identity'; | ||
|
||
// Return type signature is following @tanstack/react-query useQuery hook signature | ||
const { | ||
data: name, | ||
isLoading, | ||
isError, | ||
error, | ||
status, | ||
} = useName({ address: '0x1234' }, { enabled: true, cacheTime: 1000 * 60 * 60 * 24 }); | ||
``` | ||
|
||
## Props | ||
|
||
```ts | ||
type UseNameOptions = { | ||
address: `0x${string}`; | ||
}; | ||
|
||
type UseNameQueryOptions = { | ||
enabled?: boolean; | ||
cacheTime?: number; | ||
}; | ||
``` |
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
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
Oops, something went wrong.