diff --git a/ape_titanoboa/provider.py b/ape_titanoboa/provider.py index 829c467..d53ed8d 100644 --- a/ape_titanoboa/provider.py +++ b/ape_titanoboa/provider.py @@ -329,6 +329,7 @@ def send_transaction(self, txn: "TransactionAPI") -> "ReceiptAPI": is_modifying=True, sender=txn.sender, receiver=txn.receiver, + value=txn.value, ) else: @@ -576,6 +577,7 @@ def _execute_code( sender: Optional[Union[str, bytes]] = None, receiver: Optional[Union[str, bytes]] = None, is_modifying: bool = False, + value: int = 0, ): return self.env.execute_code( data=data, @@ -583,6 +585,7 @@ def _execute_code( is_modifying=is_modifying, sender=sender, to_address=receiver, + value=value, ) diff --git a/tests/contracts/VyperContract.vy b/tests/contracts/VyperContract.vy index 7109740..59c50fe 100644 --- a/tests/contracts/VyperContract.vy +++ b/tests/contracts/VyperContract.vy @@ -102,6 +102,11 @@ def setNumber(num: uint256) -> uint256: log NumberChange(block.prevhash, self.prevNumber, "Dynamic", num, "Dynamic") return num + 5 +@payable +@external +def gimmeMoney(): + assert msg.value > 0, "Value must be greater than zero" + @external def setAddress(_address: address): self.theAddress = _address diff --git a/tests/test_provider.py b/tests/test_provider.py index dae3846..724ba0d 100644 --- a/tests/test_provider.py +++ b/tests/test_provider.py @@ -2,11 +2,7 @@ import pytest from ape import Contract, reverts -from ape.exceptions import ( - BlockNotFoundError, - ContractLogicError, - TransactionNotFoundError, -) +from ape.exceptions import BlockNotFoundError, ContractLogicError, TransactionNotFoundError from eth.exceptions import Revert from eth_utils import to_hex from hexbytes import HexBytes @@ -72,6 +68,12 @@ def test_send_transaction(chain, contract_instance, contract, owner, networks, n assert tx.failed +def test_send_transaction_payable(contract_instance, owner): + contract_instance.gimmeMoney(value=1, sender=owner) + with reverts(): + contract_instance.gimmeMoney(sender=owner) + + def test_send_call(contract_instance, owner, contract, networks): result = contract_instance.myNumber() assert result == 123