-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: add getTransactionCount to core * feat: add getTransactionCount to core * feat: add useTransactionCount to react hooks * docs: add useTransactionCount * fix: useTransactionCount formatting * fix: add getTransactionCount to exports tests * chore: add changeset * chore: remove changeset * chore: remove wrapping describe * chore: fix spacing
- Loading branch information
1 parent
0777d0b
commit e8ba4f5
Showing
19 changed files
with
904 additions
and
0 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
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,139 @@ | ||
<script setup> | ||
const packageName = '@wagmi/core' | ||
const actionName = 'getTransactionCount' | ||
const typeName = 'GetTransactionCount' | ||
</script> | ||
|
||
# getTransactionCount | ||
|
||
Action for fetching the number of transactions an Account has broadcast / sent. | ||
|
||
## Import | ||
|
||
```ts | ||
import { getTransactionCount } from '@wagmi/core' | ||
``` | ||
|
||
## Usage | ||
|
||
::: code-group | ||
```ts [index.ts] | ||
import { getTransactionCount } from '@wagmi/core' | ||
import { config } from './config' | ||
|
||
const transactionCount = getTransactionCount(config, { | ||
address: '0x4557B18E779944BFE9d78A672452331C186a9f48', | ||
}) | ||
``` | ||
<<< @/snippets/core/config.ts[config.ts] | ||
::: | ||
|
||
## Parameters | ||
|
||
```ts | ||
import { type GetTransactionCountParameters } from '@wagmi/core' | ||
``` | ||
|
||
--- | ||
|
||
### address | ||
|
||
`Address` | ||
|
||
The address of the account. | ||
|
||
::: code-group | ||
```ts [index.ts] | ||
import { getTransactionCount } from '@wagmi/core' | ||
import { config } from './config' | ||
|
||
const transactionCount = getTransactionCount(config, { | ||
address: '0x4557B18E779944BFE9d78A672452331C186a9f48', // [!code focus] | ||
}) | ||
``` | ||
<<< @/snippets/core/config.ts[config.ts] | ||
::: | ||
|
||
--- | ||
|
||
### blockNumber | ||
|
||
`bigint | undefined` | ||
|
||
Get the count at a block number. | ||
|
||
::: code-group | ||
```ts [index.ts] | ||
import { getTransactionCount } from '@wagmi/core' | ||
import { config } from './config' | ||
|
||
const transactionCount = getTransactionCount(config, { | ||
address: '0x4557B18E779944BFE9d78A672452331C186a9f48', | ||
blockNumber: 17829139n, // [!code focus] | ||
}) | ||
``` | ||
<<< @/snippets/core/config.ts[config.ts] | ||
::: | ||
|
||
### blockTag | ||
|
||
`'latest' | 'earliest' | 'pending' | 'safe' | 'finalized' | undefined` | ||
|
||
Get the count at a block tag. | ||
|
||
::: code-group | ||
```ts [index.ts] | ||
import { getTransactionCount } from '@wagmi/core' | ||
import { config } from './config' | ||
|
||
const transactionCount = getTransactionCount(config, { | ||
address: '0x4557B18E779944BFE9d78A672452331C186a9f48', | ||
blockTag: 'latest', // [!code focus] | ||
}) | ||
``` | ||
<<< @/snippets/core/config.ts[config.ts] | ||
::: | ||
|
||
--- | ||
|
||
### chainId | ||
|
||
`config['chains'][number]['id'] | undefined` | ||
|
||
ID of chain to use when fetching data. | ||
|
||
::: code-group | ||
```ts [index.ts] | ||
import { getTransactionCount } from '@wagmi/core' | ||
import { config } from './config' | ||
|
||
const transactionCount = getTransactionCount(config, { | ||
address: '0x4557B18E779944BFE9d78A672452331C186a9f48', | ||
chainId: mainnet.id, // [!code focus] | ||
}) | ||
``` | ||
<<< @/snippets/core/config.ts[config.ts] | ||
::: | ||
|
||
|
||
## Return Type | ||
|
||
```ts | ||
import { type GetTransactionCountReturnType } from '@wagmi/core' | ||
``` | ||
|
||
`number` | ||
|
||
The number of transactions an account has sent. | ||
|
||
## Error | ||
|
||
```ts | ||
import { type GetTransactionCountErrorType } from '@wagmi/core' | ||
``` | ||
|
||
<!--@include: @shared/query-imports.md--> | ||
|
||
## Viem | ||
|
||
- [`getTransactionCount`](https://viem.sh/docs/actions/public/getTransactionCount.html) |
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,185 @@ | ||
--- | ||
title: useTransactionCount | ||
description: Hook for fetching the number of transactions an Account has broadcast / sent. | ||
--- | ||
|
||
<script setup> | ||
const packageName = 'wagmi' | ||
const actionName = 'getTransactionCount' | ||
const typeName = 'GetTransactionCount' | ||
const TData = 'number' | ||
const TError = 'GetTransactionCountErrorType' | ||
</script> | ||
|
||
# useTransactionCount | ||
|
||
Hook for fetching the number of transactions an Account has broadcast / sent. | ||
|
||
## Import | ||
|
||
```ts | ||
import { useTransactionCount } from 'wagmi' | ||
``` | ||
|
||
## Usage | ||
|
||
::: code-group | ||
```tsx [index.tsx] | ||
import { useTransactionCount } from 'wagmi' | ||
|
||
function App() { | ||
const result = useTransactionCount({ | ||
address: '0x4557B18E779944BFE9d78A672452331C186a9f48', | ||
}) | ||
} | ||
``` | ||
<<< @/snippets/react/config.ts[config.ts] | ||
::: | ||
|
||
## Parameters | ||
|
||
```ts | ||
import { type UseTransactionCountParameters } from 'wagmi' | ||
``` | ||
|
||
### address | ||
|
||
`Address | undefined` | ||
|
||
Address to get the transaction count for. [`enabled`](#enabled) set to `false` if `address` is `undefined`. | ||
|
||
::: code-group | ||
```tsx [index.tsx] | ||
import { useTransactionCount } from 'wagmi' | ||
import { mainnet } from 'wagmi/chains' | ||
|
||
function App() { | ||
const result = useTransactionCount({ | ||
address: '0x4557B18E779944BFE9d78A672452331C186a9f48', // [!code focus] | ||
}) | ||
} | ||
``` | ||
<<< @/snippets/react/config.ts[config.ts] | ||
::: | ||
|
||
--- | ||
|
||
### blockNumber | ||
|
||
`bigint | undefined` | ||
|
||
Block number to get the transaction count at. | ||
|
||
::: code-group | ||
```ts [index.ts] | ||
import { useTransactionCount } from 'wagmi' | ||
|
||
function App() { | ||
const result = useTransactionCount({ | ||
address: '0x4557B18E779944BFE9d78A672452331C186a9f48', | ||
blockNumber: 17829139n, // [!code focus] | ||
}) | ||
} | ||
``` | ||
<<< @/snippets/react/config.ts[config.ts] | ||
::: | ||
|
||
### blockTag | ||
|
||
`'latest' | 'earliest' | 'pending' | 'safe' | 'finalized' | undefined` | ||
|
||
Block tag to get the transaction count at. | ||
|
||
::: code-group | ||
```ts [index.ts] | ||
import { useTransactionCount } from 'wagmi' | ||
|
||
function App() { | ||
const result = useTransactionCount({ | ||
address: '0x4557B18E779944BFE9d78A672452331C186a9f48', | ||
blockTag: 'latest', // [!code focus] | ||
}) | ||
} | ||
``` | ||
<<< @/snippets/react/config.ts[config.ts] | ||
::: | ||
|
||
--- | ||
|
||
### chainId | ||
|
||
`config['chains'][number]['id'] | undefined` | ||
|
||
ID of chain to use when fetching data. | ||
|
||
::: code-group | ||
```tsx [index.tsx] | ||
import { useTransactionCount } from 'wagmi' | ||
import { mainnet } from 'wagmi/chains' // [!code focus] | ||
function App() { | ||
const result = useTransactionCount({ | ||
address: '0x4557B18E779944BFE9d78A672452331C186a9f48', | ||
chainId: mainnet.id, // [!code focus] | ||
}) | ||
} | ||
``` | ||
<<< @/snippets/react/config.ts[config.ts] | ||
::: | ||
|
||
### config | ||
|
||
`Config | undefined` | ||
|
||
[`Config`](/react/api/createConfig#config) to use instead of retrieving from the from nearest [`WagmiProvider`](/react/WagmiProvider). | ||
|
||
::: code-group | ||
```tsx [index.tsx] | ||
import { useTransactionCount } from 'wagmi' | ||
import { config } from './config' // [!code focus] | ||
function App() { | ||
const result = useTransactionCount({ | ||
address: '0x4557B18E779944BFE9d78A672452331C186a9f48', | ||
config, // [!code focus] | ||
}) | ||
} | ||
``` | ||
<<< @/snippets/react/config.ts[config.ts] | ||
::: | ||
|
||
### scopeKey | ||
|
||
`string | undefined` | ||
|
||
Scopes the cache to a given context. Hooks that have identical context will share the same cache. | ||
|
||
::: code-group | ||
```tsx [index.tsx] | ||
import { useTransactionCount } from 'wagmi' | ||
|
||
function App() { | ||
const result = useTransactionCount({ | ||
address: '0x4557B18E779944BFE9d78A672452331C186a9f48', | ||
scopeKey: 'foo', // [!code focus] | ||
}) | ||
} | ||
``` | ||
<<< @/snippets/react/config.ts[config.ts] | ||
::: | ||
|
||
<!--@include: @shared/query-options.md--> | ||
|
||
## Return Type | ||
|
||
```ts | ||
import { type UseTransactionCountReturnType } from 'wagmi' | ||
``` | ||
|
||
<!--@include: @shared/query-result.md--> | ||
|
||
<!--@include: @shared/query-imports.md--> | ||
|
||
## Action | ||
|
||
- [`getTransactionCount`](/core/api/actions/getTransactionCount) |
Oops, something went wrong.