Пример #1
0
async def tip(context: commands.Context, member: discord.Member,
              amount: float):
    user_from: models.User = models.User.objects(
        user_id=context.message.author.id).first()
    user_to: models.User = store.register_user(member.id)
    real_amount = int(amount * M0RKCOIN_DIGITS)

    user_from_wallet: models.Wallet = models.Wallet.objects(
        wallet_address=user_from.balance_wallet_address).first()

    if real_amount + config.tx_fee >= user_from_wallet.actual_balance:
        await bot.reply(f'Insufficient balance to send tip of '
                        f'{real_amount / M0RKCOIN_DIGITS:.4f} '
                        f'{M0RKCOIN_REPR} to {member.mention}.')
        return

    if real_amount > config.max_tx_amount:
        await bot.reply(f'Transactions cannot be bigger than '
                        f'{config.max_tx_amount / M0RKCOIN_DIGITS:.4f} '
                        f'{M0RKCOIN_REPR}.')
        return
    elif real_amount < config.min_tx_amount:
        await bot.reply(f'Transactions cannot be smaller than '
                        f'{config.min_tx_amount / M0RKCOIN_DIGITS:.4f} '
                        f'{M0RKCOIN_REPR}.')
        return

    tip = store.send_tip(user_from, user_to, real_amount)

    await bot.reply(f'Tip of {real_amount / M0RKCOIN_DIGITS:.4f} '
                    f'{M0RKCOIN_REPR} '
                    f'was sent to {member.mention}\n'
                    f'Transaction hash: `{tip.tx_hash}`')
Пример #2
0
async def balance(context: commands.Context):
    user = store.register_user(context.message.author.id)
    wallet = store.get_user_wallet(user.user_id)
    await bot.send_message(
        context.message.author, '**Your balance**\n\n'
        f'Available: {wallet.actual_balance / M0RKCOIN_DIGITS:.4f} '
        f'{M0RKCOIN_REPR}\n'
        f'Pending: {wallet.locked_balance / M0RKCOIN_DIGITS:.4f} '
        f'{M0RKCOIN_REPR}\n')
Пример #3
0
async def register(context: commands.Context, wallet_address: str):
    user_id = context.message.author.id

    existing_user: models.User = models.User.objects(user_id=user_id).first()
    if existing_user:
        prev_address = existing_user.user_wallet_address
        existing_user = store.register_user(existing_user.user_id,
                                            user_wallet=wallet_address)
        if prev_address:
            await bot.send_message(
                context.message.author,
                f'Your deposit address has been changed from:\n'
                f'`{prev_address}`\n to\n '
                f'`{existing_user.user_wallet_address}`')
            return

    user = (existing_user
            or store.register_user(user_id, user_wallet=wallet_address))

    await bot.send_message(
        context.message.author, f'You have been registered.\n'
        f'You can send your deposits to '
        f'`{user.balance_wallet_address}` and your '
        f'balance will be available once confirmed.')
Пример #4
0
async def info(context: commands.Context):
    user = store.register_user(context.message.author.id)
    await bot.send_message(
        context.message.author, f'**Account Info**\n\n'
        f'Deposit Address: `{user.balance_wallet_address}`\n\n'
        f'Registered Wallet: `{user.user_wallet_address}`')