Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: include getTransactionCount in public client #141

Merged
merged 1 commit into from
Mar 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/small-years-live.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"viem": patch
---

Fixed `createPublicClient` to include `getTransactionCount`
4 changes: 4 additions & 0 deletions src/clients/createPublicClient.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ test('creates', () => {
"getStorageAt": [Function],
"getTransaction": [Function],
"getTransactionConfirmations": [Function],
"getTransactionCount": [Function],
"getTransactionReceipt": [Function],
"key": "public",
"multicall": [Function],
Expand Down Expand Up @@ -135,6 +136,7 @@ describe('transports', () => {
"getStorageAt": [Function],
"getTransaction": [Function],
"getTransactionConfirmations": [Function],
"getTransactionCount": [Function],
"getTransactionReceipt": [Function],
"key": "public",
"multicall": [Function],
Expand Down Expand Up @@ -219,6 +221,7 @@ describe('transports', () => {
"getStorageAt": [Function],
"getTransaction": [Function],
"getTransactionConfirmations": [Function],
"getTransactionCount": [Function],
"getTransactionReceipt": [Function],
"key": "public",
"multicall": [Function],
Expand Down Expand Up @@ -282,6 +285,7 @@ describe('transports', () => {
"getStorageAt": [Function],
"getTransaction": [Function],
"getTransactionConfirmations": [Function],
"getTransactionCount": [Function],
"getTransactionReceipt": [Function],
"key": "public",
"multicall": [Function],
Expand Down
9 changes: 9 additions & 0 deletions src/clients/decorators/public.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ test('default', async () => {
"getStorageAt": [Function],
"getTransaction": [Function],
"getTransactionConfirmations": [Function],
"getTransactionCount": [Function],
"getTransactionReceipt": [Function],
"multicall": [Function],
"readContract": [Function],
Expand Down Expand Up @@ -217,6 +218,14 @@ describe('smoke test', () => {
).toBe(1n)
})

test('getTransactionCount', async () => {
expect(
await publicClient.getTransactionCount({
address: accounts[0].address,
}),
).toBeDefined()
})

test('getTransactionReceipt', async () => {
expect(
await publicClient.getTransactionReceipt({
Expand Down
7 changes: 7 additions & 0 deletions src/clients/decorators/public.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ import type {
GetTransactionParameters,
GetTransactionConfirmationsParameters,
GetTransactionConfirmationsReturnType,
GetTransactionCountParameters,
GetTransactionCountReturnType,
GetTransactionReceiptParameters,
GetTransactionReceiptReturnType,
GetTransactionReturnType,
Expand Down Expand Up @@ -77,6 +79,7 @@ import {
getLogs,
getTransaction,
getTransactionConfirmations,
getTransactionCount,
getTransactionReceipt,
uninstallFilter,
waitForTransactionReceipt,
Expand Down Expand Up @@ -181,6 +184,9 @@ export type PublicActions<TChain extends Chain = Chain> = {
getTransactionConfirmations: (
args: GetTransactionConfirmationsParameters<TChain>,
) => Promise<GetTransactionConfirmationsReturnType>
getTransactionCount: (
args: GetTransactionCountParameters,
) => Promise<GetTransactionCountReturnType>
getTransactionReceipt: (
args: GetTransactionReceiptParameters,
) => Promise<GetTransactionReceiptReturnType<TChain>>
Expand Down Expand Up @@ -273,6 +279,7 @@ export const publicActions = <
getTransaction: (args) => getTransaction(client, args),
getTransactionConfirmations: (args) =>
getTransactionConfirmations(client, args),
getTransactionCount: (args) => getTransactionCount(client, args),
getTransactionReceipt: (args) => getTransactionReceipt(client, args),
multicall: (args) => multicall(client, args),
readContract: (args) => readContract(client, args),
Expand Down