diff --git a/src/ape/api/transactions.py b/src/ape/api/transactions.py index 4edc4efde9..e6e12c1214 100644 --- a/src/ape/api/transactions.py +++ b/src/ape/api/transactions.py @@ -95,8 +95,19 @@ def validate_gas_limit(cls, value): return value + @property + def gas(self) -> Optional[int]: + """ + Alias for ``.gas_limit``. + """ + return self.gas_limit + @property def raise_on_revert(self) -> bool: + """ + ``True`` means VM-reverts should raise exceptions. + ``False`` allows getting failed receipts. + """ return self._raise_on_revert @raise_on_revert.setter @@ -122,6 +133,14 @@ def txn_hash(self) -> HexBytes: The calculated hash of the transaction. """ + # TODO: In 0.9, simply rename txn_hash to hash. + @property + def hash(self) -> HexBytes: + """ + Alias for ``self.txn_hash``. + """ + return self.txn_hash + @property def receipt(self) -> Optional["ReceiptAPI"]: """ diff --git a/tests/functional/test_transaction.py b/tests/functional/test_transaction.py index b255ff0a5f..e9606789d1 100644 --- a/tests/functional/test_transaction.py +++ b/tests/functional/test_transaction.py @@ -225,6 +225,10 @@ def test_txn_hash_and_receipt(owner, eth_tester_provider, ethereum, kwargs): txn = owner.prepare_transaction(txn) txn = owner.sign_transaction(txn) assert txn + + # Show the .hash alias works. + assert txn.hash == txn.txn_hash + actual = to_hex(txn.txn_hash) receipt = eth_tester_provider.send_transaction(txn) @@ -406,3 +410,10 @@ def serialize_transaction(self) -> bytes: my_tx = MyTransaction.model_validate({"chain_id": chain_id, "type": tx_type}) assert my_tx.chain_id == chain_id assert my_tx.type == tx_type + + +def test_gas(ethereum): + tx = ethereum.create_transaction(gas_limit=123) + assert tx.gas_limit == 123 + # Show the `gas` alias works. + assert tx.gas == 123