Skip to content

Commit

Permalink
fix: getCapabilities parameter type
Browse files Browse the repository at this point in the history
  • Loading branch information
jxom committed May 2, 2024
1 parent c8e1375 commit 8a2fb73
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
5 changes: 5 additions & 0 deletions .changeset/shaggy-impalas-cover.md
@@ -0,0 +1,5 @@
---
"viem": patch
---

**Experimental:** Fixed `getCapabilities` parameter type.
11 changes: 4 additions & 7 deletions src/experimental/eip5792/actions/getCapabilities.ts
Expand Up @@ -2,10 +2,7 @@ import type { Client } from '../../../clients/createClient.js'
import type { Transport } from '../../../clients/transports/createTransport.js'
import { AccountNotFoundError } from '../../../errors/account.js'
import type { ErrorType } from '../../../errors/utils.js'
import type {
GetAccountParameter,
JsonRpcAccount,
} from '../../../types/account.js'
import type { Account, GetAccountParameter } from '../../../types/account.js'
import type { Chain } from '../../../types/chain.js'
import type {
WalletCapabilities,
Expand All @@ -16,7 +13,7 @@ import { parseAccount } from '../../../utils/accounts.js'
import type { RequestErrorType } from '../../../utils/buildRequest.js'

export type GetCapabilitiesParameters<
account extends JsonRpcAccount | undefined = JsonRpcAccount | undefined,
account extends Account | undefined = Account | undefined,
> = GetAccountParameter<account>

export type GetCapabilitiesReturnType = Prettify<
Expand Down Expand Up @@ -47,9 +44,9 @@ export type GetCapabilitiesErrorType = RequestErrorType | ErrorType
*/
export async function getCapabilities<
chain extends Chain | undefined,
account extends JsonRpcAccount | undefined = undefined,
account extends Account | undefined = undefined,
>(
...parameters: account extends JsonRpcAccount
...parameters: account extends Account
?
| [client: Client<Transport, chain, account>]
| [
Expand Down
4 changes: 2 additions & 2 deletions src/experimental/eip5792/decorators/eip5792.ts
@@ -1,6 +1,6 @@
import type { Client } from '../../../clients/createClient.js'
import type { Transport } from '../../../clients/transports/createTransport.js'
import type { Account, JsonRpcAccount } from '../../../types/account.js'
import type { Account } from '../../../types/account.js'
import type { Chain } from '../../../types/chain.js'
import {
type GetCallsStatusParameters,
Expand Down Expand Up @@ -80,7 +80,7 @@ export type WalletActionsEip5792<
* })
*/
getCapabilities: (
...parameters: account extends JsonRpcAccount
...parameters: account extends Account
? [] | [parameters: GetCapabilitiesParameters<account>]
: [parameters: GetCapabilitiesParameters<undefined>]
) => Promise<GetCapabilitiesReturnType>
Expand Down

0 comments on commit 8a2fb73

Please sign in to comment.