Closed fubuloubu closed 1 year ago
Talked to @fubuloubu, seems like it is bigger issue, calling function as get_values(3, gas_limit="max")
throws, too.
E ape.exceptions.ConversionError: Type 'typing.Union[typing.Literal['auto', 'max'], int, str, NoneType]' must be one of [ChecksumAddress, bytes, int, Decimal, list, tuple]
Environment information
ape
and plugin versions:What went wrong?
When making a call with `my_contract.myMethod(..., gas_limit=), it fails to process because it is asking the conversion plugin system to convert to a Union type, which is not possible:
This is because currently
TransactionAPI.gas_limit
is of typeape.types.GasLimit
, which is a Union:https://github.com/ApeWorX/ape/blob/b57d4a9b16b71903a8f76319e245e1f50a87dcd3/src/ape/api/transactions.py#L33
https://github.com/ApeWorX/ape/blob/b57d4a9b16b71903a8f76319e245e1f50a87dcd3/src/ape/types/__init__.py#L55
How can it be fixed?
Easy fix is that
gas_limit
should just be anint
type, and probably go through and ensure all types of anyBaseInterfaceModel
subclass are basic Python types (and not Unions) since the intent behind these models is they are supposed to be indexable for caching solutions(although strictly speaking,TransactionAPI
is not supposed to be cached,ReceiptAPI
is)Or alternatively, expand the conversion plugin system to work with Union types by adding something like the following psuedo code to here:
NOTE: the above code does not work, but to sketch an idea