# Path: keepkeylib/client.py
# class expect(object):
#     # Decorator checks if the method
#     # returned one of expected protobuf messages
#     # or raises an exception
#     def __init__(self, *expected):
#         self.expected = expected
# 
#     def __call__(self, f):
#         def wrapped_f(*args, **kwargs):
#             ret = f(*args, **kwargs)
#             if not isinstance(ret, self.expected):
#                 raise Exception("Got %s, expected %s" % (ret.__class__, self.expected))
#             return ret
#         return wrapped_f
# 
# def session(f):
#     # Decorator wraps a BaseClient method
#     # with session activation / deactivation
#     def wrapped_f(*args, **kwargs):
#         client = args[0]
#         try:
#             client.transport.session_begin()
#             return f(*args, **kwargs)
#         finally:
#             client.transport.session_end()
#     return wrapped_f
# 
# class field(object):
#     # Decorator extracts single value from
#     # protobuf object. If the field is not
#     # present, raises an exception.
#     def __init__(self, field):
#         self.field = field
# 
#     def __call__(self, f):
#         def wrapped_f(*args, **kwargs):
#             ret = f(*args, **kwargs)
#             ret.HasField(self.field)
#             return getattr(ret, self.field)
#         return wrapped_f


from . import messages_binance_pb2 as messages
from .client import expect, session, field
# This file is part of the Trezor project.
#
# Copyright (C) 2012-2019 SatoshiLabs and contributors
#
# This library is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License version 3
# as published by the Free Software Foundation.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the License along with this library.
# If not, see <https://www.gnu.org/licenses/lgpl-3.0.html>.


@expect(messages.BinanceAddress)
@field("address")
def get_address(client, address_n, show_display=False):
    return client.call(
        messages.BinanceGetAddress(address_n=address_n, show_display=show_display)
    )


@expect(messages.BinancePublicKey)

# Path: keepkeylib/client.py
# class expect(object):
#     # Decorator checks if the method
#     # returned one of expected protobuf messages
#     # or raises an exception
#     def __init__(self, *expected):
#         self.expected = expected
# 
#     def __call__(self, f):
#         def wrapped_f(*args, **kwargs):
#             ret = f(*args, **kwargs)
#             if not isinstance(ret, self.expected):
#                 raise Exception("Got %s, expected %s" % (ret.__class__, self.expected))
#             return ret
#         return wrapped_f
# 
# def session(f):
#     # Decorator wraps a BaseClient method
#     # with session activation / deactivation
#     def wrapped_f(*args, **kwargs):
#         client = args[0]
#         try:
#             client.transport.session_begin()
#             return f(*args, **kwargs)
#         finally:
#             client.transport.session_end()
#     return wrapped_f
# 
# class field(object):
#     # Decorator extracts single value from
#     # protobuf object. If the field is not
#     # present, raises an exception.
#     def __init__(self, field):
#         self.field = field
# 
#     def __call__(self, f):
#         def wrapped_f(*args, **kwargs):
#             ret = f(*args, **kwargs)
#             ret.HasField(self.field)
#             return getattr(ret, self.field)
#         return wrapped_f


# Path: keepkeylib/binance.py
from . import messages_binance_pb2 as messages
from .client import expect, session, field

# This file is part of the Trezor project.
#
# Copyright (C) 2012-2019 SatoshiLabs and contributors
#
# This library is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License version 3
# as published by the Free Software Foundation.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the License along with this library.
# If not, see <https://www.gnu.org/licenses/lgpl-3.0.html>.


@expect(messages.BinanceAddress)
@field("address")
def get_address(client, address_n, show_display=False):
    return client.call(
        messages.BinanceGetAddress(address_n=address_n, show_display=show_display)
    )


@expect(messages.BinancePublicKey)

@field("public_key")