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 10, 2024
1 parent 910cae3 commit 6501586
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 6501586

Please sign in to comment.