1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2025-04-10 20:35:54 +00:00

feat(trezorlib): add Solana get_public_key and get_address calls

This commit is contained in:
gabrielkerekes 2023-08-01 15:49:29 +02:00
parent e548108998
commit 9e17119968
3 changed files with 75 additions and 0 deletions

View File

@ -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)

View File

@ -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)

View File

@ -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,
)
)