Skip to content

Commit

Permalink
Merge branch 'main' into feat/pydantic-v2
Browse files Browse the repository at this point in the history
  • Loading branch information
antazoey authored Sep 28, 2023
2 parents c95e7c5 + 62687ab commit 3fee58f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/ape/types/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,15 @@ def validate_address(cls, value):
def block(self) -> "BlockAPI":
return self.chain_manager.blocks[self.block_number]

@property
def timestamp(self) -> int:
"""
The UNIX timestamp of when the event was emitted.
NOTE: This performs a block lookup.
"""
return self.block.timestamp

@property
def _event_args_str(self) -> str:
return " ".join(f"{key}={val}" for key, val in self.event_arguments.items())
Expand Down
1 change: 1 addition & 0 deletions tests/functional/test_receipt.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ def assert_receipt_logs(receipt: ReceiptAPI, num: int):
logs = receipt.decode_logs(event_type)
assert len(logs) == 1
assert_log_values(logs[0], num)
assert receipt.timestamp == logs[0].timestamp

assert_receipt_logs(receipt_0, 1)
assert_receipt_logs(receipt_1, 2)
Expand Down

0 comments on commit 3fee58f

Please sign in to comment.