Skip to content

Commit

Permalink
fix: include getTransactionCount in public client (#141)
Browse files Browse the repository at this point in the history
  • Loading branch information
unholypanda authored Mar 7, 2023
1 parent eccbc90 commit 450b612
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 0 deletions.
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

2 comments on commit 450b612

@vercel
Copy link

@vercel vercel bot commented on 450b612 Mar 7, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vercel
Copy link

@vercel vercel bot commented on 450b612 Mar 7, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

viem-playground – ./playgrounds/browser

viem-playground.vercel.app
viem-playground-git-main-wagmi-dev.vercel.app
viem-playground-wagmi-dev.vercel.app

Please sign in to comment.