Skip to content
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Refine ActionParameters type
  • Loading branch information
chrstph-dvx committed Jul 15, 2024
commit c9627be92f617ff1956dfb7f7f0c9678a139f7d0
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