Skip to content

Commit

Permalink
Refine ActionParameters type
Browse files Browse the repository at this point in the history
  • Loading branch information
chrstph-dvx committed Jul 2, 2024
1 parent 6bbb0dd commit bb72cad
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions src/types/Actions.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import { Address } from 'viem';
import { Prettify } from './utils';

type RemoveUndefinedArgs<T> = T extends { args?: undefined } ? Omit<T, 'args'> : T;

/**
* Actions require contract address, but as part of decorators, the address might have been passed already to the decorator.
*
Expand All @@ -11,8 +9,8 @@ type RemoveUndefinedArgs<T> = T extends { args?: undefined } ? Omit<T, 'args'> :
*/
export type ActionParameters<Args, ContractName extends string, Curried extends boolean> = Prettify<
Curried extends false
? RemoveUndefinedArgs<Args & { [key in ContractName]: Address }>
: Args extends { args?: undefined }
? Args & { [key in ContractName]: Address }
: Args extends Record<string, never>
?
| {
[key in ContractName]: Address;
Expand Down

0 comments on commit bb72cad

Please sign in to comment.