Beispiel #1
0
async def _show_page(page: int, page_count: int, content):
    content = Scrollpage(content[page], page, page_count)
    if page + 1 == page_count:
        await ConfirmDialog(content)
    else:
        content.render()
        await animate_swipe()
Beispiel #2
0
async def _show_page(page: int, page_count: int, content):
    content = Scrollpage(content[page], page, page_count)
    if page + 1 == page_count:
        if await ConfirmDialog(content) != CONFIRMED:
            raise wire.ActionCancelled("Action cancelled")
    else:
        content.render()
        await animate_swipe()
Beispiel #3
0
    async def page_renderer(page: int, page_count: int, pages: list):
        # for some reason page index can be equal to page count
        if page >= page_count:
            page = page_count - 1

        content = Scrollpage(pages[page], page, page_count)
        if page + 1 >= page_count:
            return await confirmation_wrapper(content)
        else:
            content.render()
            await animate_swipe()
Beispiel #4
0
async def show_proposal_page(page: int, page_count: int, pages: list, title: str):
    text = Text(title, ui.ICON_SEND, icon_color=ui.PURPLE)
    text.bold("Proposal {}: ".format(page + 1))
    text.mono(*split_proposal(pages[page]))
    content = Scrollpage(text, page, page_count)

    if page + 1 >= page_count:
        confirm = await ConfirmDialog(content)
        if confirm == CANCELLED:
            raise wire.ActionCancelled("Cancelled")
    else:
        content.render()
        await animate_swipe()
Beispiel #5
0
async def show_mnemonic_page(page: int, page_count: int, pages: list):
    if __debug__:
        debug.reset_current_words = [word for _, word in pages[page]]

    lines = ["%2d. %s" % (wi + 1, word) for wi, word in pages[page]]
    text = Text("Recovery seed", ui.ICON_RESET)
    text.mono(*lines)
    content = Scrollpage(text, page, page_count)

    if page + 1 == page_count:
        await HoldToConfirmDialog(content)
    else:
        content.render()
        await animate_swipe()
Beispiel #6
0
async def show_voter_page(page: int, page_count: int, pages: list):
    lines = [
        "{:2d}. {}".format(wi + 1, helpers.eos_name_to_string(producer))
        for wi, producer in pages[page]
    ]
    text = Text("Vote for producers", ui.ICON_CONFIRM, icon_color=ui.GREEN)
    text.mono(*lines)
    content = Scrollpage(text, page, page_count)

    if page + 1 == page_count:
        if await ConfirmDialog(content) != CONFIRMED:
            raise wire.ActionCancelled("Action cancelled")
    else:
        content.render()
        await animate_swipe()
Beispiel #7
0
async def show_lines_page(page: int, page_count: int, pages: list,
                          header: str):
    if header == "Arbitrary data":
        text = Text(header, ui.ICON_WIPE, icon_color=ui.RED)
    else:
        text = Text(header, ui.ICON_CONFIRM, icon_color=ui.GREEN)
    text.mono(*pages[page])

    content = Scrollpage(text, page, page_count)
    if page + 1 == page_count:
        if await ConfirmDialog(content) != CONFIRMED:
            raise wire.ActionCancelled("Action cancelled")
    else:
        content.render()
        await animate_swipe()
Beispiel #8
0
async def tx_dialog(
    ctx,
    code,
    content,
    cancel_btn,
    confirm_btn,
    cancel_style,
    confirm_style,
    scroll_tuple=None,
):
    from trezor.messages import MessageType
    from trezor.messages.ButtonRequest import ButtonRequest
    from trezor.ui.confirm import ConfirmDialog
    from trezor.ui.scroll import Scrollpage

    await ctx.call(ButtonRequest(code=code), MessageType.ButtonAck)

    if scroll_tuple and scroll_tuple[1] > 1:
        content = Scrollpage(content, scroll_tuple[0], scroll_tuple[1])

    dialog = ConfirmDialog(
        content,
        cancel=cancel_btn,
        confirm=confirm_btn,
        cancel_style=cancel_style,
        confirm_style=confirm_style,
    )
    return await ctx.wait(dialog)
Beispiel #9
0
async def show_mnemonic_page(page: int, page_count: int, pages: list):
    lines = ['%2d. %s' % (wi + 1, word) for wi, word in pages[page]]
    content = Text('Recovery seed', ui.ICON_RESET, ui.MONO, *lines)
    content = Scrollpage(content, page, page_count)

    if page + 1 == page_count:
        await HoldToConfirmDialog(content)
    else:
        content.render()
        await animate_swipe()
Beispiel #10
0
async def show_mnemonic_page(page, page_count, mnemonic):
    from trezor.ui.button import Button
    from trezor.ui.text import Text
    from trezor.ui.scroll import Scrollpage, animate_swipe

    lines = ['%d. %s' % (wi + 1, word) for wi, word in mnemonic[page]]
    scroll_page = Scrollpage(
        Text('Recovery seed setup', ui.ICON_RESET, ui.MONO, lines), page,
        page_count)
    ui.display.clear()
    scroll_page.render()

    if page + 1 == page_count:
        await Button(ui.grid(4, n_x=1),
                     "I'm done",
                     normal_style=ui.BTN_CONFIRM,
                     active_style=ui.BTN_CONFIRM_ACTIVE)
        ui.display.clear()
    else:
        await animate_swipe()
Beispiel #11
0
async def show_text_page(
    page: int,
    page_count: int,
    pages: list,
    title: str,
    icon=ui.ICON_RESET,
    icon_color=ui.ORANGE,
):
    if page_count == 1:
        page = 0

    lines = pages[page]
    content = Text(title, icon, icon_color=icon_color)
    content.mono(*lines)

    content = Scrollpage(content, page, page_count)

    if page + 1 >= page_count:
        return await ConfirmDialog(content)
    else:
        content.render()
        await animate_swipe()