diff --git a/python/src/trezorlib/cli/solana.py b/python/src/trezorlib/cli/solana.py new file mode 100644 index 0000000000..c5ec1e3da6 --- /dev/null +++ b/python/src/trezorlib/cli/solana.py @@ -0,0 +1,36 @@ +import click + +from .. import solana, messages, tools +from . import with_client + +PATH_HELP = "BIP-32 path to key, e.g. m/44'/501'/0'" + +@click.group(name="solana") +def cli() -> None: + """Solana commands.""" + +@cli.command() +@click.option("-n", "--address", required=True, help=PATH_HELP) +@with_client +def get_public_key( + client: "TrezorClient", + address: str, +) -> messages.SolanaPublicKey: + """Get Solana public key.""" + address_n = tools.parse_path(address) + client.init_device() + return solana.get_public_key(client, address_n) + +@cli.command() +@click.option("-n", "--address", required=True, help=PATH_HELP) +@click.option("-d", "--show-display", is_flag=True) +@with_client +def get_address( + client: "TrezorClient", + address: str, + show_display: bool, +) -> messages.SolanaPublicKey: + """Get Solana public key.""" + address_n = tools.parse_path(address) + client.init_device() + return solana.get_address(client, address_n, show_display) diff --git a/python/src/trezorlib/cli/trezorctl.py b/python/src/trezorlib/cli/trezorctl.py index b820f28d96..e00c965aea 100755 --- a/python/src/trezorlib/cli/trezorctl.py +++ b/python/src/trezorlib/cli/trezorctl.py @@ -46,6 +46,7 @@ from . import ( nem, ripple, settings, + solana, stellar, tezos, with_client, @@ -76,6 +77,7 @@ COMMAND_ALIASES = { "bnb": binance.cli, "eth": ethereum.cli, "ada": cardano.cli, + "sol": solana.cli, "xmr": monero.cli, "xrp": ripple.cli, "xlm": stellar.cli, @@ -410,6 +412,7 @@ cli.add_command(monero.cli) cli.add_command(nem.cli) cli.add_command(ripple.cli) cli.add_command(settings.cli) +cli.add_command(solana.cli) cli.add_command(stellar.cli) cli.add_command(tezos.cli) diff --git a/python/src/trezorlib/solana.py b/python/src/trezorlib/solana.py new file mode 100644 index 0000000000..10c46a7e53 --- /dev/null +++ b/python/src/trezorlib/solana.py @@ -0,0 +1,36 @@ +from typing import ( + TYPE_CHECKING, + List, +) + +from . import messages +from .tools import expect + +if TYPE_CHECKING: + from .client import TrezorClient + from .protobuf import MessageType + + +@expect(messages.SolanaPublicKey) +def get_public_key( + client: "TrezorClient", + address_n: List[int], +) -> "MessageType": + return client.call( + messages.SolanaGetPublicKey( + address_n=address_n + ) + ) + +@expect(messages.SolanaAddress) +def get_address( + client: "TrezorClient", + address_n: List[int], + show_display: bool, +) -> "MessageType": + return client.call( + messages.SolanaGetAddress( + address_n=address_n, + show_display=show_display, + ) + )