Skip to content

Commit

Permalink
feat: allow nonce in cli
Browse files Browse the repository at this point in the history
  • Loading branch information
antazoey committed Dec 21, 2023
1 parent 2a0a883 commit d2ae0c6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
11 changes: 6 additions & 5 deletions ape_safe/_cli/pending.py
Original file line number Diff line number Diff line change
Expand Up @@ -265,8 +265,9 @@ def approve(cli_ctx: SafeCliContext, safe, txn_ids, execute):
@safe_option
@txn_ids_argument
# NOTE: Doesn't use --execute because we don't need BOOL values.
@click.option("--submitter", callback=_load_submitter)
def execute(cli_ctx, safe, txn_ids, submitter):
@click.option("--submitter", help="Account to execute", callback=_load_submitter)
@click.option("--nonce", help="Submitter nonce")
def execute(cli_ctx, safe, txn_ids, submitter, nonce):
"""
Execute a transaction
"""
Expand All @@ -285,22 +286,22 @@ def execute(cli_ctx, safe, txn_ids, submitter):
# Not a specified txn.
continue

_execute(safe, txn, submitter)
_execute(safe, txn, submitter, nonce=nonce)

# If any txn_ids remain, they were not handled.
if txn_ids:
cli_ctx.abort_txns_not_found(txn_ids)


def _execute(safe: SafeAccount, txn: UnexecutedTxData, submitter: AccountAPI):
def _execute(safe: SafeAccount, txn: UnexecutedTxData, submitter: AccountAPI, **tx_kwargs):
safe_tx = safe.create_safe_tx(**txn.model_dump(mode="json", by_alias=True))

# TODO: Can remove type ignore after Ape 0.7.1
signatures: Dict[AddressType, MessageSignature] = {
c.owner: MessageSignature.from_rsv(c.signature) for c in txn.confirmations # type: ignore
}

exc_tx = safe.create_execute_transaction(safe_tx, signatures)
exc_tx = safe.create_execute_transaction(safe_tx, signatures, **tx_kwargs)
submitter.call(exc_tx)


Expand Down
3 changes: 1 addition & 2 deletions ape_safe/accounts.py
Original file line number Diff line number Diff line change
Expand Up @@ -707,8 +707,7 @@ def add_signatures(

return signatures

def select_signer(self, for_: str = None) -> AccountAPI:
for_ = for_ or "submitter"
def select_signer(self, for_: str = "submitter") -> AccountAPI:
return select_account(prompt_message=f"Select a {for_}", key=self.local_signers)


Expand Down

0 comments on commit d2ae0c6

Please sign in to comment.