Skip to content

Commit 08e6a68

Browse files
authored
fix: protected action types (#1435)
* fix: protected action types * chore: changeset
1 parent 067776d commit 08e6a68

File tree

3 files changed

+23
-7
lines changed

3 files changed

+23
-7
lines changed

.changeset/pretty-carrots-grin.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"viem": patch
3+
---
4+
5+
Fixed protected action types

src/actions/wallet/writeContract.ts

+3-7
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,9 @@ export type WriteContractParameters<
4242
GetValue<
4343
TAbi,
4444
TFunctionName,
45-
SendTransactionParameters<
46-
TChain,
47-
TAccount,
48-
TChainOverride
49-
> extends SendTransactionParameters
50-
? SendTransactionParameters<TChain, TAccount, TChainOverride>['value']
51-
: SendTransactionParameters['value']
45+
FormattedTransactionRequest<
46+
TChainOverride extends Chain ? TChainOverride : TChain
47+
>['value']
5248
> & {
5349
/** Data to append to the end of the calldata. Useful for adding a ["domain" tag](https://opensea.notion.site/opensea/Seaport-Order-Attributions-ec2d69bf455041a5baa490941aad307f). */
5450
dataSuffix?: Hex

src/clients/createClient.test-d.ts

+15
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@ import { describe, expectTypeOf, test } from 'vitest'
33

44
import type { Account, JsonRpcAccount } from '../accounts/types.js'
55
import { localhost } from '../chains/index.js'
6+
import { type Chain } from '../types/chain.js'
67
import { type Client, createClient } from './createClient.js'
8+
import { walletActions } from './decorators/wallet.js'
79
import { http } from './transports/http.js'
810

911
test('with chain', () => {
@@ -100,4 +102,17 @@ describe('extend', () => {
100102
},
101103
}))
102104
})
105+
106+
test('protected action pass through generic', () => {
107+
function getClient<chain extends Chain | undefined>(
108+
chain?: chain | undefined,
109+
) {
110+
const client = createClient({
111+
chain,
112+
transport: http(),
113+
})
114+
return client.extend(walletActions)
115+
}
116+
getClient(localhost)
117+
})
103118
})

0 commit comments

Comments
 (0)