Skip to content

Commit

Permalink
fix: widen extend
Browse files Browse the repository at this point in the history
  • Loading branch information
jxom committed Jan 29, 2024
1 parent b61e31d commit f44b502
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions src/clients/createClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,8 @@ export type ClientConfig<
// They are allowed to be extended, but must conform to their parameter & return type interfaces.
// Example: an extended `call` action must accept `CallParameters` as parameters,
// and conform to the `CallReturnType` return type.
type ExtendableProtectedActions<
chain extends Chain | undefined = Chain | undefined,
account extends Account | undefined = Account | undefined,
> = Pick<
PublicActions<Transport, chain>,
type ExtendableProtectedActions = Pick<
PublicActions,
| 'call'
| 'createContractEventFilter'
| 'createEventFilter'
Expand All @@ -89,7 +86,7 @@ type ExtendableProtectedActions<
| 'watchBlockNumber'
| 'watchContractEvent'
> &
Pick<WalletActions<chain, account>, 'sendTransaction' | 'writeContract'>
Pick<WalletActions, 'sendTransaction' | 'writeContract'>

// TODO: Move `transport` to slot index 2 since `chain` and `account` used more frequently.
// Otherwise, we end up with a lot of `Client<Transport, chain, account>` in actions.
Expand All @@ -102,8 +99,7 @@ export type Client<
> = Client_Base<transport, chain, account, rpcSchema> &
(extended extends Extended ? extended : unknown) & {
extend: <
const client extends Extended &
Partial<ExtendableProtectedActions<chain, account>>,
const client extends Extended & Partial<ExtendableProtectedActions>,
>(
fn: (
client: Client<transport, chain, account, rpcSchema, extended>,
Expand Down

0 comments on commit f44b502

Please sign in to comment.