diff --git a/.changeset/pretty-carrots-grin.md b/.changeset/pretty-carrots-grin.md new file mode 100644 index 0000000000..046a76003f --- /dev/null +++ b/.changeset/pretty-carrots-grin.md @@ -0,0 +1,5 @@ +--- +"viem": patch +--- + +Fixed protected action types diff --git a/src/actions/wallet/writeContract.ts b/src/actions/wallet/writeContract.ts index ff45027fbd..66fe7dcaaf 100644 --- a/src/actions/wallet/writeContract.ts +++ b/src/actions/wallet/writeContract.ts @@ -42,13 +42,9 @@ export type WriteContractParameters< GetValue< TAbi, TFunctionName, - SendTransactionParameters< - TChain, - TAccount, - TChainOverride - > extends SendTransactionParameters - ? SendTransactionParameters['value'] - : SendTransactionParameters['value'] + FormattedTransactionRequest< + TChainOverride extends Chain ? TChainOverride : TChain + >['value'] > & { /** Data to append to the end of the calldata. Useful for adding a ["domain" tag](https://opensea.notion.site/opensea/Seaport-Order-Attributions-ec2d69bf455041a5baa490941aad307f). */ dataSuffix?: Hex diff --git a/src/clients/createClient.test-d.ts b/src/clients/createClient.test-d.ts index d033bc6567..9674e90e42 100644 --- a/src/clients/createClient.test-d.ts +++ b/src/clients/createClient.test-d.ts @@ -3,7 +3,9 @@ import { describe, expectTypeOf, test } from 'vitest' import type { Account, JsonRpcAccount } from '../accounts/types.js' import { localhost } from '../chains/index.js' +import { type Chain } from '../types/chain.js' import { type Client, createClient } from './createClient.js' +import { walletActions } from './decorators/wallet.js' import { http } from './transports/http.js' test('with chain', () => { @@ -100,4 +102,17 @@ describe('extend', () => { }, })) }) + + test('protected action pass through generic', () => { + function getClient( + chain?: chain | undefined, + ) { + const client = createClient({ + chain, + transport: http(), + }) + return client.extend(walletActions) + } + getClient(localhost) + }) })