Exemplo n.º 1
0
async def confirm_action_delegate(ctx, msg: EosActionDelegate):
    await ctx.call(ButtonRequest(code=ButtonRequestType.ConfirmOutput),
                   MessageType.ButtonAck)

    text = "Delegate"
    fields = []
    fields.append("Sender:")
    fields.append(helpers.eos_name_to_string(msg.sender))
    fields.append("Receiver:")
    fields.append(helpers.eos_name_to_string(msg.receiver))
    fields.append("CPU:")
    fields.append(helpers.eos_asset_to_string(msg.cpu_quantity))
    fields.append("NET:")
    fields.append(helpers.eos_asset_to_string(msg.net_quantity))

    if msg.transfer:
        fields.append("Transfer: Yes")
        fields.append("Receiver:")
        fields.append(helpers.eos_name_to_string(msg.receiver))
    else:
        fields.append("Transfer: No")

    pages = list(chunks(fields, _FOUR_FIELDS_PER_PAGE))
    paginator = paginate(show_lines_page, len(pages), _FIRST_PAGE, pages, text)

    await ctx.wait(paginator)
Exemplo n.º 2
0
async def confirm_action_undelegate(ctx, msg: EosActionUndelegate):
    text = "Undelegate"
    fields = []
    fields.append("Sender:")
    fields.append(helpers.eos_name_to_string(msg.sender))
    fields.append("Receiver:")
    fields.append(helpers.eos_name_to_string(msg.receiver))
    fields.append("CPU:")
    fields.append(helpers.eos_asset_to_string(msg.cpu_quantity))
    fields.append("NET:")
    fields.append(helpers.eos_asset_to_string(msg.net_quantity))
    await _require_confirm_paginated(ctx, text, fields, _FOUR_FIELDS_PER_PAGE)
Exemplo n.º 3
0
async def confirm_action_buyram(ctx, msg: EosActionBuyRam):
    text = "Buy RAM"
    fields = []
    fields.append("Payer:")
    fields.append(helpers.eos_name_to_string(msg.payer))
    fields.append("Receiver:")
    fields.append(helpers.eos_name_to_string(msg.receiver))
    fields.append("Amount:")
    fields.append(helpers.eos_asset_to_string(msg.quantity))
    await _require_confirm_paginated(ctx, text, fields, _FOUR_FIELDS_PER_PAGE)
Exemplo n.º 4
0
async def confirm_action_delegate(ctx: wire.Context,
                                  msg: EosActionDelegate) -> None:
    text = "Delegate"
    fields = []
    fields.append("Sender:")
    fields.append(helpers.eos_name_to_string(msg.sender))
    fields.append("Receiver:")
    fields.append(helpers.eos_name_to_string(msg.receiver))
    fields.append("CPU:")
    fields.append(helpers.eos_asset_to_string(msg.cpu_quantity))
    fields.append("NET:")
    fields.append(helpers.eos_asset_to_string(msg.net_quantity))

    if msg.transfer:
        fields.append("Transfer: Yes")
        fields.append("Receiver:")
        fields.append(helpers.eos_name_to_string(msg.receiver))
    else:
        fields.append("Transfer: No")

    await _require_confirm_paginated(ctx, text, fields, _FOUR_FIELDS_PER_PAGE)
Exemplo n.º 5
0
async def confirm_action_transfer(ctx, msg: EosActionTransfer, account: str):
    text = "Transfer"
    fields = []
    fields.append("From:")
    fields.append(helpers.eos_name_to_string(msg.sender))
    fields.append("To:")
    fields.append(helpers.eos_name_to_string(msg.receiver))
    fields.append("Amount:")
    fields.append(helpers.eos_asset_to_string(msg.quantity))
    fields.append("Contract:")
    fields.append(account)

    if msg.memo is not None:
        fields.append("Memo:")
        fields.extend(split_data(msg.memo[:512]))

    await _require_confirm_paginated(ctx, text, fields, _FOUR_FIELDS_PER_PAGE)
Exemplo n.º 6
0
async def confirm_action_buyram(ctx, msg: EosActionBuyRam):
    await ctx.call(ButtonRequest(code=ButtonRequestType.ConfirmOutput),
                   MessageType.ButtonAck)

    text = "Buy RAM"
    fields = []
    fields.append("Payer:")
    fields.append(helpers.eos_name_to_string(msg.payer))
    fields.append("Receiver:")
    fields.append(helpers.eos_name_to_string(msg.receiver))
    fields.append("Amount:")
    fields.append(helpers.eos_asset_to_string(msg.quantity))

    pages = list(chunks(fields, _FOUR_FIELDS_PER_PAGE))

    paginator = paginate(show_lines_page, len(pages), _FIRST_PAGE, pages, text)
    await ctx.wait(paginator)
Exemplo n.º 7
0
async def confirm_action_transfer(ctx, msg: EosActionTransfer, account: str):
    await ctx.call(ButtonRequest(code=ButtonRequestType.ConfirmOutput),
                   MessageType.ButtonAck)

    text = "Transfer"
    fields = []
    fields.append("From:")
    fields.append(helpers.eos_name_to_string(msg.sender))
    fields.append("To:")
    fields.append(helpers.eos_name_to_string(msg.receiver))
    fields.append("Amount:")
    fields.append(helpers.eos_asset_to_string(msg.quantity))
    fields.append("Contract:")
    fields.append(account)

    if msg.memo is not None:
        fields.append("Memo:")
        fields += split_data(msg.memo[:512])

    pages = list(chunks(fields, _FOUR_FIELDS_PER_PAGE))

    paginator = paginate(show_lines_page, len(pages), _FIRST_PAGE, pages, text)
    await ctx.wait(paginator)
 def test_eos_asset_to_string(self):
     asset_in = [
         EosAsset(
             amount=10000,
             symbol=1397703940,
         ),
         EosAsset(
             amount=200000,
             symbol=1397703940,
         ),
         EosAsset(
             amount=255000,
             symbol=1397703940,
         ),
         EosAsset(
             amount=999999,
             symbol=1397703939,
         ),
         EosAsset(
             amount=1,
             symbol=1397703940,
         ),
         EosAsset(
             amount=999,
             symbol=1397703939,
         ),
     ]
     asset_out = [
         '1.0000 EOS',
         '20.0000 EOS',
         '25.5000 EOS',
         '999.999 EOS',
         '0.0001 EOS',
         '0.999 EOS',
     ]
     for i, o in zip(asset_in, asset_out):
         self.assertEqual(helpers.eos_asset_to_string(i), o)