Skip to content

Commit

Permalink
refactor: use account_option instead of callback_factory
Browse files Browse the repository at this point in the history
  • Loading branch information
fubuloubu committed Jun 5, 2024
1 parent 00b4bfa commit 2148cf0
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions ape_safe/_cli/delegates.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import click
from ape.cli import ConnectedProviderCommand
from ape.cli import ConnectedProviderCommand, account_option
from ape.types import AddressType
from eth_typing import ChecksumAddress

from ape_safe._cli.click_ext import callback_factory, safe_argument, safe_cli_ctx, safe_option
from ape_safe._cli.click_ext import safe_argument, safe_cli_ctx, safe_option


@click.group()
Expand Down Expand Up @@ -35,29 +35,30 @@ def _list(cli_ctx, safe):
@safe_option
@click.argument("delegate", type=ChecksumAddress)
@click.argument("label")
@click.argument("signer", callback=callback_factory.submitter_callback)
def add(cli_ctx, safe, delegate, label, signer):
@account_option()
def add(cli_ctx, safe, delegate, label, account):
"""
Add a delegate for a signer in a Safe
"""
delegate = cli_ctx.conversion_manager.convert(delegate, AddressType)
safe.client.add_delegate(delegate, label, signer)
safe.client.add_delegate(delegate, label, account)
cli_ctx.logger.success(
f"Added delegate {delegate} ({label}) for {signer.address} in {safe.address} ({safe.alias})"
f"Added delegate {delegate} ({label}) for {account.address} "
f"in {safe.address} ({safe.alias})"
)


@delegates.command(cls=ConnectedProviderCommand)
@safe_cli_ctx()
@safe_option
@click.argument("delegate", type=ChecksumAddress)
@click.argument("signer", callback=callback_factory.submitter_callback)
def remove(cli_ctx, safe, delegate, signer):
@account_option()
def remove(cli_ctx, safe, delegate, account):
"""
Remove a delegate for a specific signer in a Safe
"""
delegate = cli_ctx.conversion_manager.convert(delegate, AddressType)
safe.client.remove_delegate(delegate, signer)
safe.client.remove_delegate(delegate, account)
cli_ctx.logger.success(
f"Removed delegate {delegate} for {signer.address} in {safe.address} ({safe.alias})"
f"Removed delegate {delegate} for {account.address} in {safe.address} ({safe.alias})"
)

0 comments on commit 2148cf0

Please sign in to comment.