Skip to content

Commit

Permalink
fix: issue where arrays were missing in logs [APE-1501] (ApeWorX#1722)
Browse files Browse the repository at this point in the history
Co-authored-by: Juliya Smith <[email protected]>
  • Loading branch information
z80dev and antazoey authored Nov 3, 2023
1 parent 88f9236 commit bea735d
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 3 deletions.
4 changes: 3 additions & 1 deletion src/ape/types/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,9 @@ def __str__(self) -> str:
return f"{self.event_name}({self._event_args_str})"

def __repr__(self) -> str:
return f"<{self.event_name} {self._event_args_str}>"
event_arg_str = self._event_args_str
suffix = f" {event_arg_str}" if event_arg_str else ""
return f"<{self.event_name}{suffix}>"

def __ape_extra_attributes__(self) -> Iterator[ExtraModelAttributes]:
yield ExtraModelAttributes(
Expand Down
2 changes: 2 additions & 0 deletions src/ape_ethereum/ecosystem.py
Original file line number Diff line number Diff line change
Expand Up @@ -720,6 +720,8 @@ def get_abi(_topic: HexStr) -> Optional[LogInputABICollection]:
sub_type = "[".join(_type.split("[")[:-1])
if sub_type == "address":
converted_arguments[key] = [self.decode_address(v) for v in value]
else:
converted_arguments[key] = value

else:
# No change.
Expand Down

Large diffs are not rendered by default.

Large diffs are not rendered by default.

9 changes: 9 additions & 0 deletions tests/functional/data/sources/TestContractSol.sol
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ contract TestContractSol {
address[1] agents
);

event EventWithUintArray(
uint256[1] agents
);

struct MyStruct {
address a;
bytes32 b;
Expand Down Expand Up @@ -302,4 +306,9 @@ contract TestContractSol {
address[1] memory agts = [msg.sender];
emit EventWithAddressArray(1001, msg.sender, ppl, agts);
}

function logUintArray() public {
uint256[1] memory agts = [uint256(1)];
emit EventWithUintArray(agts);
}
}
8 changes: 8 additions & 0 deletions tests/functional/data/sources/TestContractVy.vy
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ event EventWithAddressArray:
participants: DynArray[address, 1024]
agents: address[1]

event EventWithUintArray:
agents: uint256[1]

struct MyStruct:
a: address
b: bytes32
Expand Down Expand Up @@ -295,3 +298,8 @@ def logAddressArray():
ppl.append(msg.sender)
agts: address[1] = [msg.sender]
log EventWithAddressArray(1001, msg.sender, ppl, agts)

@external
def logUintArray():
agts: uint256[1] = [1]
log EventWithUintArray(agts)
6 changes: 6 additions & 0 deletions tests/functional/test_contract_event.py
Original file line number Diff line number Diff line change
Expand Up @@ -334,3 +334,9 @@ def test_address_arrays_in_events(contract_instance, owner):
some_id=1001, some_address=owner, participants=[owner], agents=[owner]
)
assert tx.events == [expected]


def test_uint_arrays_in_events(contract_instance, owner):
tx = contract_instance.logUintArray(sender=owner)
expected = contract_instance.EventWithUintArray(agents=[1])
assert tx.events == [expected]

0 comments on commit bea735d

Please sign in to comment.