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

execute transactions silently #1636

Merged
merged 1 commit into from
Jan 29, 2024
Merged
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
10 changes: 6 additions & 4 deletions brownie/network/contract.py
Original file line number Diff line number Diff line change
Expand Up @@ -527,7 +527,7 @@ def __repr__(self) -> str:
return f"<{type(self).__name__} '{self._name}.constructor({_inputs(self.abi)})'>"

def __call__(
self, *args: Tuple, publish_source: bool = False
self, *args: Tuple, publish_source: bool = False, silent: bool = False
) -> Union["Contract", TransactionReceiptType]:
"""Deploys a contract.

Expand Down Expand Up @@ -558,6 +558,7 @@ def __call__(
required_confs=tx["required_confs"],
allow_revert=tx.get("allow_revert"),
publish_source=publish_source,
silent=silent
)

@staticmethod
Expand Down Expand Up @@ -1711,7 +1712,7 @@ def call(
raise ValueError("No data was returned - the call likely reverted")
return self.decode_output(data)

def transact(self, *args: Tuple) -> TransactionReceiptType:
def transact(self, silent: bool = False, *args: Tuple) -> TransactionReceiptType:
"""
Broadcast a transaction that calls this contract method.

Expand Down Expand Up @@ -1746,6 +1747,7 @@ def transact(self, *args: Tuple) -> TransactionReceiptType:
required_confs=tx["required_confs"],
data=self.encode_input(*args),
allow_revert=tx["allow_revert"],
silent=silent
)

def decode_input(self, hexstr: str) -> List:
Expand Down Expand Up @@ -1845,7 +1847,7 @@ class ContractTx(_ContractMethod):
Bytes4 method signature.
"""

def __call__(self, *args: Tuple) -> TransactionReceiptType:
def __call__(self, *args: Tuple, silent: bool = False) -> TransactionReceiptType:
"""
Broadcast a transaction that calls this contract method.

Expand All @@ -1861,7 +1863,7 @@ def __call__(self, *args: Tuple) -> TransactionReceiptType:
Object representing the broadcasted transaction.
"""

return self.transact(*args)
return self.transact(silent, *args)


class ContractCall(_ContractMethod):
Expand Down