Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

expose silent parameter to transfer #472

Merged
merged 1 commit into from
May 2, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ This changelog format is based on [Keep a Changelog](https://keepachangelog.com/
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased](https://github.com/iamdefinitelyahuman/brownie)
### Changed
- Exposed `silent` parameter to `Account.transfer()` ([#472](https://github.com/iamdefinitelyahuman/brownie/pull/472))

## [1.8.0](https://github.com/iamdefinitelyahuman/brownie/tree/v1.8.0) - 2020-04-30
### Added
Expand Down
4 changes: 3 additions & 1 deletion brownie/network/account.py
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,7 @@ def transfer(
gas_limit: Optional[int] = None,
gas_price: Optional[int] = None,
data: str = None,
silent: bool = False,
) -> "TransactionReceipt":
"""
Broadcast a transaction from this account.
Expand All @@ -327,6 +328,7 @@ def transfer(
gas_limit: Gas limit of the transaction.
gas_price: Gas price of the transaction.
data: Hexstring of data to include in transaction.
silent: Toggles console verbosity.

Returns:
TransactionReceipt object
Expand All @@ -351,7 +353,7 @@ def transfer(
if rpc.is_active():
rpc._add_to_undo_buffer(self.transfer, (to, amount, gas_limit, gas_price, data), {})

return TransactionReceipt(txid, self, revert_data=revert_data)
return TransactionReceipt(txid, self, silent=silent, revert_data=revert_data)


class Account(_PrivateKeyAccount):
Expand Down
3 changes: 2 additions & 1 deletion docs/api-network.rst
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ Account Methods
>>> accounts[0].estimate_gas(accounts[1], "1 ether")
21000

.. py:classmethod:: Account.transfer(self, to=None, amount=0, gas_limit=None, gas_price=None, data=None)
.. py:classmethod:: Account.transfer(self, to=None, amount=0, gas_limit=None, gas_price=None, data=None, silent=False)

Broadcasts a transaction from this account.

Expand All @@ -302,6 +302,7 @@ Account Methods
* ``gas_limit``: Gas limit for the transaction. The given value is converted to :func:`Wei <brownie.convert.datatypes.Wei>`. If none is given, the price is set using ``eth_estimateGas``.
* ``gas_price``: Gas price for the transaction. The given value is converted to :func:`Wei <brownie.convert.datatypes.Wei>`. If none is given, the price is set using ``eth_gasPrice``.
* ``data``: Transaction data hexstring.
* ``silent``: Toggles console verbosity. If ``True`` is given, suppresses all console output for this transaction.

Returns a :func:`TransactionReceipt <brownie.network.transaction.TransactionReceipt>` instance.

Expand Down
7 changes: 7 additions & 0 deletions tests/network/transaction/test_attributes.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,13 @@ def test_contract_address(accounts, tester):
assert tester.tx.receiver is None


@pytest.mark.parametrize("silent", [False, True])
def test_silent_mode(accounts, tester, console_mode, capsys, silent):
accounts[0].transfer(accounts[1], "1 ether", silent=silent)
captured = capsys.readouterr()
assert (captured.out == "") == silent


def test_input(accounts, tester):
data = tester.revertStrings.encode_input(5)
tx = accounts[0].transfer(tester.address, 0, data=data)
Expand Down