Пример #1
0
async def handle_DoPreauthorized(ctx: wire.Context,
                                 msg: DoPreauthorized) -> protobuf.MessageType:
    authorization: Authorization = storage.cache.get(
        storage.cache.APP_BASE_AUTHORIZATION)
    if not authorization:
        raise wire.ProcessError("No preauthorized operation")

    req = await ctx.call_any(PreauthorizedRequest(),
                             *authorization.expected_wire_types())

    handler = wire.find_registered_workflow_handler(ctx.iface,
                                                    req.MESSAGE_WIRE_TYPE)
    if handler is None:
        return wire.unexpected_message()

    return await handler(ctx, req, authorization)  # type: ignore
Пример #2
0
async def handle_DoPreauthorized(ctx: wire.Context,
                                 msg: DoPreauthorized) -> protobuf.MessageType:
    from trezor.messages.PreauthorizedRequest import PreauthorizedRequest
    from apps.common import authorization

    if not authorization.is_set():
        raise wire.ProcessError("No preauthorized operation")

    wire_types = authorization.get_wire_types()
    utils.ensure(bool(wire_types), "Unsupported preauthorization found")

    req = await ctx.call_any(PreauthorizedRequest(), *wire_types)

    handler = workflow_handlers.find_registered_handler(
        ctx.iface, req.MESSAGE_WIRE_TYPE)
    if handler is None:
        return wire.unexpected_message()

    return await handler(ctx, req, authorization.get())  # type: ignore