Exemplo n.º 1
0
def process_print_money(author: AccountId, message: str, server: Server, **kwargs):
    """Processes a request to print a batch of money and deposit it in an account."""
    author_account = assert_authorized(author, server, Authorization.ADMIN)
    parsed = parse_print_money(message)
    if parsed is None:
        raise CommandException('Command formatted incorrectly. Expected format `print-money AMOUNT BENEFICIARY`.')

    amount, beneficiary = parsed
    beneficiary_account = assert_is_account(beneficiary, server)
    server.print_money(author_account, beneficiary_account, amount)
    return 'Money printed successfully.'
Exemplo n.º 2
0
def print_money(author_id: Union[AccountId, str], account_id: Union[AccountId,
                                                                    str],
                amount: Fraction, server: Server):
    """Print an amount of money into an account,
       with the authorization of author, on server
       """
    if amount <= 0:
        raise ValueCommandException(amount)

    author = _get_account(author_id, server)
    account = _get_account(account_id, server)
    _assert_authorized(author, None)

    server.print_money(author_id, account, amount)