Closed fubuloubu closed 2 years ago
Debugging this further, seems like there is another issue where src/ape/contract/base.py:ContractTransaction.serialize_transaction
will convert AddressType
variables to HexBytes
(presumably via HexEncoder
), which fails to serialize properly for the Provider downstream
Thinking that conversion step needs more context into whatever variable types should be for the conversion, at least for kwargs
quick fix to ContractTransaction
:
def _get_type(self, kwarg_name: str) -> Any:
return TransactionAPI.__fields__[kwarg_name].type_
def serialize_transaction(self, *args, **kwargs) -> TransactionAPI:
kwargs = {
k: self.conversion_manager.convert(
v,
# TODO: Upstream, `TransactionAPI.sender` should be `AddressType` (not `str`)
AddressType if k == "sender" else self._get_type(k),
)
for k, v in kwargs.items()
}
...
Even with above fix, the workaround is to do:
one_contract.mutableCall(..., sender=accounts[another_contract.address])
This will load the contract as an ImpersonatedAccount
@fubuloubu can you give #619 a shot and see if it resolves the issue?
Environment information
ape
and plugin versions:What went wrong?
When using a network provider that supports transactions without signatures (such as forked mode networks or local test networks), ape doesn't support calling via a
ContractInstance
object assender
e.g.:How can it be fixed?
The signature check in certain providers checks to see if
sender
is not of typeAddressType
before switching to using the signature check, which is missingContractInstance
(this is done because of a circular dependency). Just add the extra support forContractInstace
as well. Could even have it always convert thesender
argument toAddressType
, if signing is not required on that network.