diff --git a/.changeset/small-years-live.md b/.changeset/small-years-live.md new file mode 100644 index 0000000000..2fe73735dd --- /dev/null +++ b/.changeset/small-years-live.md @@ -0,0 +1,5 @@ +--- +"viem": patch +--- + +Fixed `createPublicClient` to include `getTransactionCount` diff --git a/src/clients/createPublicClient.test.ts b/src/clients/createPublicClient.test.ts index 5d4c54a58b..08af5e6dbe 100644 --- a/src/clients/createPublicClient.test.ts +++ b/src/clients/createPublicClient.test.ts @@ -51,6 +51,7 @@ test('creates', () => { "getStorageAt": [Function], "getTransaction": [Function], "getTransactionConfirmations": [Function], + "getTransactionCount": [Function], "getTransactionReceipt": [Function], "key": "public", "multicall": [Function], @@ -135,6 +136,7 @@ describe('transports', () => { "getStorageAt": [Function], "getTransaction": [Function], "getTransactionConfirmations": [Function], + "getTransactionCount": [Function], "getTransactionReceipt": [Function], "key": "public", "multicall": [Function], @@ -219,6 +221,7 @@ describe('transports', () => { "getStorageAt": [Function], "getTransaction": [Function], "getTransactionConfirmations": [Function], + "getTransactionCount": [Function], "getTransactionReceipt": [Function], "key": "public", "multicall": [Function], @@ -282,6 +285,7 @@ describe('transports', () => { "getStorageAt": [Function], "getTransaction": [Function], "getTransactionConfirmations": [Function], + "getTransactionCount": [Function], "getTransactionReceipt": [Function], "key": "public", "multicall": [Function], diff --git a/src/clients/decorators/public.test.ts b/src/clients/decorators/public.test.ts index 33d0b73f24..510ceec37c 100644 --- a/src/clients/decorators/public.test.ts +++ b/src/clients/decorators/public.test.ts @@ -38,6 +38,7 @@ test('default', async () => { "getStorageAt": [Function], "getTransaction": [Function], "getTransactionConfirmations": [Function], + "getTransactionCount": [Function], "getTransactionReceipt": [Function], "multicall": [Function], "readContract": [Function], @@ -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({ diff --git a/src/clients/decorators/public.ts b/src/clients/decorators/public.ts index 8fea8c7cbf..3a5fa7cabb 100644 --- a/src/clients/decorators/public.ts +++ b/src/clients/decorators/public.ts @@ -33,6 +33,8 @@ import type { GetTransactionParameters, GetTransactionConfirmationsParameters, GetTransactionConfirmationsReturnType, + GetTransactionCountParameters, + GetTransactionCountReturnType, GetTransactionReceiptParameters, GetTransactionReceiptReturnType, GetTransactionReturnType, @@ -77,6 +79,7 @@ import { getLogs, getTransaction, getTransactionConfirmations, + getTransactionCount, getTransactionReceipt, uninstallFilter, waitForTransactionReceipt, @@ -181,6 +184,9 @@ export type PublicActions = { getTransactionConfirmations: ( args: GetTransactionConfirmationsParameters, ) => Promise + getTransactionCount: ( + args: GetTransactionCountParameters, + ) => Promise getTransactionReceipt: ( args: GetTransactionReceiptParameters, ) => Promise> @@ -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),