Skip to content
Snippets Groups Projects
Commit fdeb8943 authored by Moul's avatar Moul
Browse files

[mod] #328: cert/tx: Import top-level Click module

parent b8872db0
No related branches found
No related tags found
No related merge requests found
......@@ -16,7 +16,7 @@ along with Silkaj. If not, see <https://www.gnu.org/licenses/>.
"""
import sys
from click import command, argument, echo, confirm
import click
from time import time
from tabulate import tabulate
from duniterpy.api import bma
......@@ -33,8 +33,8 @@ from silkaj.constants import SUCCESS_EXIT_STATUS
from silkaj.crypto_tools import is_pubkey_and_check
@command("cert", help="Send certification")
@argument("uid_pubkey_to_certify")
@click.command("cert", help="Send certification")
@click.argument("uid_pubkey_to_certify")
@coroutine
async def send_certification(uid_pubkey_to_certify):
client = ClientInstance().client
......@@ -144,7 +144,7 @@ async def certification_confirmation(
cert_begins = convert_time(time(), "date")
cert_ends = convert_time(time() + params["sigValidity"], "date")
cert.append(["Valid", cert_begins, "—>", cert_ends])
echo(tabulate(cert, tablefmt="fancy_grid"))
if not confirm("Do you confirm sending this certification?"):
click.echo(tabulate(cert, tablefmt="fancy_grid"))
if not click.confirm("Do you confirm sending this certification?"):
await client.close()
sys.exit(SUCCESS_EXIT_STATUS)
......@@ -19,7 +19,7 @@ from re import compile, search
import math
from asyncio import sleep
from tabulate import tabulate
from click import command, option, FloatRange
import click
from silkaj import cli_tools
from silkaj import network_tools as nt
......@@ -44,37 +44,37 @@ from duniterpy.documents.transaction import OutputSource, Unlock, SIGParameter
MAX_COMMENT_LENGTH = 255
@command("tx", help="Send transaction")
@option(
@click.command("tx", help="Send transaction")
@click.option(
"amounts",
"--amount",
"-a",
multiple=True,
type=FloatRange(MINIMAL_ABSOLUTE_TX_AMOUNT),
type=click.FloatRange(MINIMAL_ABSOLUTE_TX_AMOUNT),
help="Quantitative amount(s):\n-a <amount>\nMinimum amount is {0}".format(
MINIMAL_ABSOLUTE_TX_AMOUNT
),
cls=cli_tools.MutuallyExclusiveOption,
mutually_exclusive=["amountsud", "allsources"],
)
@option(
@click.option(
"amountsud",
"--amountUD",
"-d",
multiple=True,
type=FloatRange(MINIMAL_RELATIVE_TX_AMOUNT),
type=click.FloatRange(MINIMAL_RELATIVE_TX_AMOUNT),
help=f"Relative amount(s):\n-d <amount_UD>\nMinimum amount is {MINIMAL_RELATIVE_TX_AMOUNT}",
cls=cli_tools.MutuallyExclusiveOption,
mutually_exclusive=["amounts", "allsources"],
)
@option(
@click.option(
"--allSources",
is_flag=True,
help="Send all sources to one recipient",
cls=cli_tools.MutuallyExclusiveOption,
mutually_exclusive=["amounts", "amountsud"],
)
@option(
@click.option(
"recipients",
"--recipient",
"-r",
......@@ -85,15 +85,23 @@ Sending to many recipients is possible:\n\
* With one amount, all will receive the amount\n\
* With many amounts (one per recipient)",
)
@option("--comment", "-c", default="", help="Comment")
@option(
@click.option("--comment", "-c", default="", help="Comment")
@click.option(
"--outputBackChange",
help="Pubkey recipient to send the rest of the transaction: <pubkey[:checksum]>",
)
@option("--yes", "-y", is_flag=True, help="Assume yes. Do not prompt confirmation")
@click.option(
"--yes", "-y", is_flag=True, help="Assume yes. Do not prompt confirmation"
)
@tools.coroutine
async def send_transaction(
amounts, amountsud, allsources, recipients, comment, outputbackchange, yes
amounts,
amountsud,
allsources,
recipients,
comment,
outputbackchange,
yes,
):
"""
Main function
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment