From a9c4e8d6b04dbb563c98c21a9da056f6f8f030a9 Mon Sep 17 00:00:00 2001 From: Tom Meagher Date: Thu, 2 Nov 2023 13:10:08 -0400 Subject: [PATCH 1/2] fix: protected action types --- src/actions/wallet/writeContract.ts | 10 +++------- src/clients/createClient.test-d.ts | 15 +++++++++++++++ 2 files changed, 18 insertions(+), 7 deletions(-) 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) + }) }) From 46b57a54f35dc5b2b0b6ccbabb7c917a7cb6b1d1 Mon Sep 17 00:00:00 2001 From: Tom Meagher Date: Thu, 2 Nov 2023 13:10:55 -0400 Subject: [PATCH 2/2] chore: changeset --- .changeset/pretty-carrots-grin.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/pretty-carrots-grin.md 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