Skip to content

Commit

Permalink
fix: missing sender and other tx fields
Browse files Browse the repository at this point in the history
  • Loading branch information
antazoey committed Dec 23, 2024
1 parent e6a60cb commit 81576f0
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 12 deletions.
12 changes: 6 additions & 6 deletions src/ape/managers/chain.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
from ape.managers.base import BaseManager
from ape.types.address import AddressType
from ape.utils.basemodel import BaseInterfaceModel
from ape.utils.misc import is_evm_precompile, is_zero_hex, log_instead_of_fail
from ape.utils.misc import ZERO_ADDRESS, is_evm_precompile, is_zero_hex, log_instead_of_fail

if TYPE_CHECKING:
from rich.console import Console as RichConsole
Expand Down Expand Up @@ -591,12 +591,12 @@ def append(self, txn_receipt: ReceiptAPI):
"""

self._hash_to_receipt_map[txn_receipt.txn_hash] = txn_receipt
if txn_receipt.sender:
address = self.conversion_manager.convert(txn_receipt.sender, AddressType)
if address not in self._account_history_cache:
self._account_history_cache[address] = AccountHistory(address=address)
key = txn_receipt.sender or ZERO_ADDRESS
address = self.conversion_manager.convert(key, AddressType)
if address not in self._account_history_cache:
self._account_history_cache[address] = AccountHistory(address=address)

self._account_history_cache[address].append(txn_receipt)
self._account_history_cache[address].append(txn_receipt)

def revert_to_block(self, block_number: int):
"""
Expand Down
13 changes: 7 additions & 6 deletions src/ape_test/provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -342,8 +342,15 @@ def send_transaction(self, txn: "TransactionAPI") -> "ReceiptAPI":
txn_hash = to_hex(txn.txn_hash)

required_confirmations = txn.required_confirmations or 0
txn_dict = txn_dict or txn.model_dump(mode="json")

# Signature is typically excluded from the model fields,
# so we have to include it manually.
txn_dict["signature"] = txn.signature

if vm_err or not self.auto_mine:
receipt_data = {
**txn_dict,
"block_number": -1, # Not yet confirmed,
"error": vm_err,
"provider": self,
Expand All @@ -353,12 +360,6 @@ def send_transaction(self, txn: "TransactionAPI") -> "ReceiptAPI":
}
receipt = self.network.ecosystem.decode_receipt(receipt_data)
else:
txn_dict = txn_dict or txn.model_dump(mode="json")

# Signature is typically excluded from the model fields,
# so we have to include it manually.
txn_dict["signature"] = txn.signature

receipt = self.get_receipt(
txn_hash, required_confirmations=required_confirmations, transaction=txn_dict
)
Expand Down

0 comments on commit 81576f0

Please sign in to comment.