Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: protected action types #1435

Merged
merged 2 commits into from
Nov 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/pretty-carrots-grin.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"viem": patch
---

Fixed protected action types
10 changes: 3 additions & 7 deletions src/actions/wallet/writeContract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,9 @@ export type WriteContractParameters<
GetValue<
TAbi,
TFunctionName,
SendTransactionParameters<
TChain,
TAccount,
TChainOverride
> extends SendTransactionParameters
? SendTransactionParameters<TChain, TAccount, TChainOverride>['value']
: SendTransactionParameters['value']
FormattedTransactionRequest<
TChainOverride extends Chain ? TChainOverride : TChain
>['value']
Comment on lines +45 to +47
Copy link
Member Author

Choose a reason for hiding this comment

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

More direct way to get 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
Expand Down
15 changes: 15 additions & 0 deletions src/clients/createClient.test-d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down Expand Up @@ -100,4 +102,17 @@ describe('extend', () => {
},
}))
})

test('protected action pass through generic', () => {
function getClient<chain extends Chain | undefined>(
chain?: chain | undefined,
) {
const client = createClient({
chain,
transport: http(),
})
return client.extend(walletActions)
}
getClient(localhost)
})
})
Loading