Skip to content

Commit

Permalink
Introuces non-interactive mode to Transactor.
Browse files Browse the repository at this point in the history
  • Loading branch information
KPrasch committed Sep 24, 2024
1 parent 691d7e4 commit 27f0f4c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 12 deletions.
21 changes: 10 additions & 11 deletions deployment/params.py
Original file line number Diff line number Diff line change
Expand Up @@ -480,15 +480,15 @@ class Transactor:
Represents an ape account plus validated/annotated transaction execution.
"""

def __init__(self, account: typing.Optional[AccountAPI] = None, non_interactive: bool = False):
if non_interactive and not account:
raise ValueError("'non_interactive' can only be used if an account is provided")

self._non_interactive = non_interactive
def __init__(self, account: typing.Optional[AccountAPI] = None, autosign: bool = False):
if account is None:
self._account = select_account()
else:
self._account = account
if autosign:
print("WARNING: Autosign is enabled. Transactions will be signed automatically.")
self._autosign = autosign
self._account.set_autosign(autosign)

def get_account(self) -> AccountAPI:
"""Returns the transactor account."""
Expand All @@ -506,8 +506,7 @@ def transact(self, method: ContractTransactionHandler, *args) -> ReceiptAPI:
else:
message = f"{base_message} with no arguments"
print(message)

if not self._non_interactive:
if not self._autosign:
_continue()

result = method(
Expand All @@ -534,9 +533,9 @@ def __init__(
path: Path,
verify: bool,
account: typing.Optional[AccountAPI] = None,
non_interactive: bool = False,
autosign: bool = False,
):
super().__init__(account, non_interactive)
super().__init__(account, autosign)

check_plugins()
self.path = path
Expand All @@ -554,7 +553,7 @@ def __init__(
self.verify = verify
self._print_deployment_info()

if not self._non_interactive:
if not self._autosign:
# Confirms the start of the deployment.
_continue()

Expand Down Expand Up @@ -597,7 +596,7 @@ def _deploy_contract(
self, container: ContractContainer, resolved_params: OrderedDict
) -> ContractInstance:
contract_name = container.contract_type.name
if not self._non_interactive:
if not self._autosign:
_confirm_resolution(resolved_params, contract_name)
deployment_params = [container, *resolved_params.values()]
kwargs = self._get_kwargs()
Expand Down
7 changes: 6 additions & 1 deletion scripts/initiate_ritual.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@
help="The filepath of a file containing newline separated staking provider addresses.",
type=click.File("r"),
)
@click.option(
"--autosign",
is_flag=True,
)
def cli(
domain,
account,
Expand All @@ -84,6 +88,7 @@ def cli(
random_seed,
handpicked,
min_version,
autosign,
):
"""Initiate a ritual for a TACo domain."""

Expand Down Expand Up @@ -147,7 +152,7 @@ def cli(
)

# Initiate the ritual
transactor = Transactor(account=account)
transactor = Transactor(account=account, autosign=autosign)
transactor.transact(
coordinator_contract.initiateRitual,
fee_model_contract.address,
Expand Down

0 comments on commit 27f0f4c

Please sign in to comment.