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:
parent
e548108998
commit
9e17119968
36
python/src/trezorlib/cli/solana.py
Normal file
36
python/src/trezorlib/cli/solana.py
Normal 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)
|
@ -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)
|
||||
|
||||
|
36
python/src/trezorlib/solana.py
Normal file
36
python/src/trezorlib/solana.py
Normal 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,
|
||||
)
|
||||
)
|
Loading…
Reference in New Issue
Block a user