Skip to content

Commit

Permalink
feat: improved structure to allow for a timeout to be set on private …
Browse files Browse the repository at this point in the history
…transactions, but an early partial receipt to be returned if they time out
  • Loading branch information
bitwise-constructs committed Sep 18, 2024
1 parent ede3af1 commit b3ac7f1
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions src/ape_ethereum/provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -633,21 +633,25 @@ def get_receipt(
else transaction.model_dump(by_alias=True, mode="json")
)

if kwargs.get("private"):
# Bail before confirmation because it won't be on chain yet.
data = {
"required_confirmations": 0,
"block_number": -1,
**txn,
}
receipt = self._create_receipt(**data)
return receipt.await_confirmations() # But do need to await nonce increment.
private = kwargs.get("private")

try:
receipt_data = dict(
self.web3.eth.wait_for_transaction_receipt(hex_hash, timeout=timeout)
)
except TimeExhausted as err:
# We don't auto-wait for acceptance or confirmations for private transactions.
# TODO: Update comment with instructions for how to manually wait
# once the feature is ready in core Ape.
if private:
# Return with a partial receipt
data = {
"block_number": -1,
"required_confirmations": required_confirmations,
**txn,
}
receipt = self._create_receipt(**data)
return receipt
msg_str = str(err)
if f"HexBytes('{txn_hash}')" in msg_str:
msg_str = msg_str.replace(f"HexBytes('{txn_hash}')", f"'{txn_hash}'")
Expand Down

0 comments on commit b3ac7f1

Please sign in to comment.