Skip to content
This repository was archived by the owner on Mar 5, 2025. It is now read-only.
Merged
Changes from all commits
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
17 changes: 12 additions & 5 deletions packages/web3-eth-abi/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -186,14 +186,21 @@ export type MatchPrimitiveType<
| never;

export type ContractMethodOutputParameters<Params extends ReadonlyArray<unknown> | undefined> =
// check if params are empty array
Params extends readonly []
? []
: Params extends readonly [infer H, ...infer R]
? void // if yes outputs is void
: Params extends readonly [infer H, ...infer R] // check if Params is array
? H extends AbiParameter
? // TODO: Find a way to set name for tuple item
[MatchPrimitiveType<H['type'], H['components']>, ...ContractMethodOutputParameters<R>]
? [
MatchPrimitiveType<H['type'], H['components']>,
...ContractMethodOutputParameters<R>,
] &
H['name'] extends '' // check if output param name is empty string
? []
: Record<H['name'], MatchPrimitiveType<H['type'], H['components']>> & // sets key-value pair of output param name and type
ContractMethodOutputParameters<R>
: ContractMethodOutputParameters<R>
: Params extends undefined | unknown
: Params extends undefined | unknown // param is not array, check if undefined
? []
: Params;

Expand Down