Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update decimal places from 12 to 4. #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions m0rkcoin_tip_bot/bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ async def balance(context: commands.Context):
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:.12f} '
f'Available: {wallet.actual_balance / M0RKCOIN_DIGITS:.4f} '
f'{M0RKCOIN_REPR}\n'
f'Pending: {wallet.locked_balance / M0RKCOIN_DIGITS:.12f} '
f'Pending: {wallet.locked_balance / M0RKCOIN_DIGITS:.4f} '
f'{M0RKCOIN_REPR}\n')


Expand Down Expand Up @@ -94,25 +94,25 @@ async def withdraw(context: commands.Context, amount: float):
if real_amount + config.tx_fee >= user_balance_wallet.actual_balance:
await bot.send_message(context.message.author,
f'Insufficient balance to withdraw '
f'{real_amount / M0RKCOIN_DIGITS:.12f} '
f'{real_amount / M0RKCOIN_DIGITS:.4f} '
f'{M0RKCOIN_REPR}.')
return

if real_amount > config.max_tx_amount:
await bot.reply(f'Transactions cannot be bigger than '
f'{config.max_tx_amount / M0RKCOIN_DIGITS:.12f} '
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 lower than '
f'{config.min_tx_amount / M0RKCOIN_DIGITS:.12f} '
f'{config.min_tx_amount / M0RKCOIN_DIGITS:.4f} '
f'{M0RKCOIN_REPR}')
return

withdrawal = store.withdraw(user, real_amount)
await bot.send_message(
context.message.author,
f'You have withdrawn {real_amount / M0RKCOIN_DIGITS:.12f} '
f'You have withdrawn {real_amount / M0RKCOIN_DIGITS:.4f} '
f'{M0RKCOIN_REPR}.\n'
f'Transaction hash: `{withdrawal.tx_hash}`')

Expand All @@ -130,24 +130,24 @@ async def tip(context: commands.Context, member: discord.Member,

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:.12f} '
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:.12f} '
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:.12f} '
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:.12f} '
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}`')
Expand Down