1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-11-15 20:19:23 +00:00

feat(cardano): Format stake pool ids as bech32 instead of hex

This commit is contained in:
Rafael Korbas 2021-02-08 22:00:00 +01:00 committed by matejcik
parent 3197741795
commit ceea21ec1f
3 changed files with 21 additions and 10 deletions

View File

@ -1,5 +1,7 @@
from apps.cardano.helpers.paths import ACCOUNT_PATH_INDEX, unharden from apps.cardano.helpers.paths import ACCOUNT_PATH_INDEX, unharden
from . import bech32
if False: if False:
from typing import List, Optional from typing import List, Optional
@ -42,3 +44,7 @@ def format_optional_int(number: Optional[int]) -> str:
return "n/a" return "n/a"
return str(number) return str(number)
def format_stake_pool_id(pool_id_bytes: bytes) -> str:
return bech32.encode("pool", pool_id_bytes)

View File

@ -23,7 +23,12 @@ from .address import (
pack_reward_address_bytes, pack_reward_address_bytes,
) )
from .helpers import protocol_magics from .helpers import protocol_magics
from .helpers.utils import format_account_number, format_optional_int, to_account_path from .helpers.utils import (
format_account_number,
format_optional_int,
format_stake_pool_id,
to_account_path,
)
if False: if False:
from typing import List, Optional from typing import List, Optional
@ -280,7 +285,7 @@ async def confirm_certificate(
assert certificate.pool is not None # validate_certificate assert certificate.pool is not None # validate_certificate
page2 = Text("Confirm transaction", ui.ICON_SEND, ui.GREEN) page2 = Text("Confirm transaction", ui.ICON_SEND, ui.GREEN)
page2.normal("to pool:") page2.normal("to pool:")
page2.bold(hexlify(certificate.pool).decode()) page2.bold(format_stake_pool_id(certificate.pool))
pages.append(page2) pages.append(page2)
await require_confirm(ctx, Paginated(pages)) await require_confirm(ctx, Paginated(pages))
@ -294,8 +299,8 @@ async def confirm_stake_pool_parameters(
) -> None: ) -> None:
page1 = Text("Confirm transaction", ui.ICON_SEND, ui.GREEN) page1 = Text("Confirm transaction", ui.ICON_SEND, ui.GREEN)
page1.bold("Stake pool registration") page1.bold("Stake pool registration")
page1.normal("Pool id:") page1.normal("Pool ID:")
page1.bold(hexlify(pool_parameters.pool_id).decode()) page1.bold(format_stake_pool_id(pool_parameters.pool_id))
page2 = Text("Confirm transaction", ui.ICON_SEND, ui.GREEN) page2 = Text("Confirm transaction", ui.ICON_SEND, ui.GREEN)
page2.normal("Pool reward account:") page2.normal("Pool reward account:")

View File

@ -8,15 +8,15 @@
"cardano-test_sign_tx.py::test_cardano_sign_tx[mary_era_transaction_with_different_policies_-1dbb1bfb": "0f14d371c83adf4ceaa05530581df86eb653b9e8226be61fcd2bc1cc97e3581a", "cardano-test_sign_tx.py::test_cardano_sign_tx[mary_era_transaction_with_different_policies_-1dbb1bfb": "0f14d371c83adf4ceaa05530581df86eb653b9e8226be61fcd2bc1cc97e3581a",
"cardano-test_sign_tx.py::test_cardano_sign_tx[mary_era_transaction_with_multiasset_output]": "a24edeaaefca10b45235836264b8385148048a23bd34c56570c3de69de4f3d06", "cardano-test_sign_tx.py::test_cardano_sign_tx[mary_era_transaction_with_multiasset_output]": "a24edeaaefca10b45235836264b8385148048a23bd34c56570c3de69de4f3d06",
"cardano-test_sign_tx.py::test_cardano_sign_tx[mary_era_transaction_with_no_ttl-validity_start]": "db76676358164a3b3dab5148f09ba5515d079212366b79c44f95e2ba613abc71", "cardano-test_sign_tx.py::test_cardano_sign_tx[mary_era_transaction_with_no_ttl-validity_start]": "db76676358164a3b3dab5148f09ba5515d079212366b79c44f95e2ba613abc71",
"cardano-test_sign_tx.py::test_cardano_sign_tx[sample_stake_pool_registration_certificate]": "c5a5ef80ccefc8df0c2df100678e686458ef92d00738f038fe069e5fb169a8b1", "cardano-test_sign_tx.py::test_cardano_sign_tx[sample_stake_pool_registration_certificate]": "f56482d4a0f2c07fe04291a7d9c29ed4aedfd31e6a80fed1563d80e3a4c4005c",
"cardano-test_sign_tx.py::test_cardano_sign_tx[sample_stake_pool_registration_certificate_wi-d3427614": "2bb355fab3aa8cf7b6705e36045287525e5442e8236033e4efefd79d5b913d7d", "cardano-test_sign_tx.py::test_cardano_sign_tx[sample_stake_pool_registration_certificate_wi-d3427614": "629ccaa5b660247843b366582c1bc505831c1800e028474a784b0f8b35fc473a",
"cardano-test_sign_tx.py::test_cardano_sign_tx[simple_transaction_with_base_address_change_o-0c37e6dc": "a9bbc7137d32d71acc1b4d4b7c19aacf7ec8b63c06fe53c16759bf81f5d0ad96", "cardano-test_sign_tx.py::test_cardano_sign_tx[simple_transaction_with_base_address_change_o-0c37e6dc": "a9bbc7137d32d71acc1b4d4b7c19aacf7ec8b63c06fe53c16759bf81f5d0ad96",
"cardano-test_sign_tx.py::test_cardano_sign_tx[simple_transaction_with_base_address_change_output]": "3e55bbf1c01e9a889f2be7e3ae07db4348c13f6bdb6d746e7cb812a18329c9bb", "cardano-test_sign_tx.py::test_cardano_sign_tx[simple_transaction_with_base_address_change_output]": "3e55bbf1c01e9a889f2be7e3ae07db4348c13f6bdb6d746e7cb812a18329c9bb",
"cardano-test_sign_tx.py::test_cardano_sign_tx[simple_transaction_with_base_script_address_c-466ef44c": "cdc9707b2c4ad61bb2037b93b68fac3aef071f1b1458a948a53a3997f3ffc131", "cardano-test_sign_tx.py::test_cardano_sign_tx[simple_transaction_with_base_script_address_c-466ef44c": "cdc9707b2c4ad61bb2037b93b68fac3aef071f1b1458a948a53a3997f3ffc131",
"cardano-test_sign_tx.py::test_cardano_sign_tx[simple_transaction_with_enterprise_address_ch-15518a4c": "4db403239beeaa24f8b1b9d98dedf49a68f6e57b52526822e49d7851f407555e", "cardano-test_sign_tx.py::test_cardano_sign_tx[simple_transaction_with_enterprise_address_ch-15518a4c": "4db403239beeaa24f8b1b9d98dedf49a68f6e57b52526822e49d7851f407555e",
"cardano-test_sign_tx.py::test_cardano_sign_tx[simple_transaction_with_pointer_address_change_output]": "8d24fb46f5aa9232873c3d1216e643365cb8f8dbc66f9f81f5cb64943b2476cc", "cardano-test_sign_tx.py::test_cardano_sign_tx[simple_transaction_with_pointer_address_change_output]": "8d24fb46f5aa9232873c3d1216e643365cb8f8dbc66f9f81f5cb64943b2476cc",
"cardano-test_sign_tx.py::test_cardano_sign_tx[stake_pool_registration_certificate_with_no_p-0bbad967": "7169657ca34ba6a228b89ef1c44ef1e6f9f740a348d778d0bb60deaac2819381", "cardano-test_sign_tx.py::test_cardano_sign_tx[stake_pool_registration_certificate_with_no_p-0bbad967": "c226da53263bde948424d2943280cab606a70be21a78ce9ba853c729b5bc03c9",
"cardano-test_sign_tx.py::test_cardano_sign_tx[stake_pool_registration_on_testnet]": "83f78636b8ccbd850bd4f7b36d0ea84a69b96db56b572707ab5aaf5f10ae7397", "cardano-test_sign_tx.py::test_cardano_sign_tx[stake_pool_registration_on_testnet]": "998043271c02cb725b27ba335efebf4895365d602b84df0fe04e26fa3c0bd3fa",
"cardano-test_sign_tx.py::test_cardano_sign_tx[testnet_transaction0]": "7178cb7c264c15ab13152a87fe14c39fbdfa8571c166ddcda6e7c65680bbc784", "cardano-test_sign_tx.py::test_cardano_sign_tx[testnet_transaction0]": "7178cb7c264c15ab13152a87fe14c39fbdfa8571c166ddcda6e7c65680bbc784",
"cardano-test_sign_tx.py::test_cardano_sign_tx[testnet_transaction1]": "fcd2bfb85ff1b0ec7a204b2d525c8adf4204afbdcc726d4485820ff36ded4b2c", "cardano-test_sign_tx.py::test_cardano_sign_tx[testnet_transaction1]": "fcd2bfb85ff1b0ec7a204b2d525c8adf4204afbdcc726d4485820ff36ded4b2c",
"cardano-test_sign_tx.py::test_cardano_sign_tx[transaction_with_base_address_change_output_p-3c7243e1": "32458c03d03f4cfc2d83369a7b4a766a7b410452cb27682d5959a09a78d19b90", "cardano-test_sign_tx.py::test_cardano_sign_tx[transaction_with_base_address_change_output_p-3c7243e1": "32458c03d03f4cfc2d83369a7b4a766a7b410452cb27682d5959a09a78d19b90",
@ -25,7 +25,7 @@
"cardano-test_sign_tx.py::test_cardano_sign_tx[transaction_with_stake_deregistration]": "555219b1572cd91037379ebd95e2a979c5e0486148cb0c00f837277820cb4cbe", "cardano-test_sign_tx.py::test_cardano_sign_tx[transaction_with_stake_deregistration]": "555219b1572cd91037379ebd95e2a979c5e0486148cb0c00f837277820cb4cbe",
"cardano-test_sign_tx.py::test_cardano_sign_tx[transaction_with_stake_deregistration_and_withdrawal]": "7d7915b4300974d5f45a8308da218b7e4bac938a2d033a6db2b6dccdbec5e4d8", "cardano-test_sign_tx.py::test_cardano_sign_tx[transaction_with_stake_deregistration_and_withdrawal]": "7d7915b4300974d5f45a8308da218b7e4bac938a2d033a6db2b6dccdbec5e4d8",
"cardano-test_sign_tx.py::test_cardano_sign_tx[transaction_with_stake_deregistration_with_ac-9ca046f0": "e5b8662ef9abe58a835d6d5765e413ee1dc63cc870e2c6627f9da6a93c5ead9f", "cardano-test_sign_tx.py::test_cardano_sign_tx[transaction_with_stake_deregistration_with_ac-9ca046f0": "e5b8662ef9abe58a835d6d5765e413ee1dc63cc870e2c6627f9da6a93c5ead9f",
"cardano-test_sign_tx.py::test_cardano_sign_tx[transaction_with_stake_registration_and_stake-3fdfc583": "043a0d9689c74a63a4da5067b0b69ced14d3ca1717490e11de52f1bb31610659", "cardano-test_sign_tx.py::test_cardano_sign_tx[transaction_with_stake_registration_and_stake-3fdfc583": "ffdd46df1aa7b4e0f8f6b3ded1fb04296c9ff70741791e32f81653e18b546db7",
"cardano-test_sign_tx.py::test_cardano_sign_tx[transaction_with_stake_registration_certifica-e7bd462a": "5a983375390be55cb4fca80a58546cc333148101a02ccfc8c80e1a64b9f47b57", "cardano-test_sign_tx.py::test_cardano_sign_tx[transaction_with_stake_registration_certifica-e7bd462a": "5a983375390be55cb4fca80a58546cc333148101a02ccfc8c80e1a64b9f47b57",
"cardano-test_sign_tx.py::test_cardano_sign_tx[transaction_with_stake_registration_certificate]": "367088bed7ede0e6f317d3662f990b4300f93fcff2ccd6309c6c4f50fd8da6f9", "cardano-test_sign_tx.py::test_cardano_sign_tx[transaction_with_stake_registration_certificate]": "367088bed7ede0e6f317d3662f990b4300f93fcff2ccd6309c6c4f50fd8da6f9",
"cardano-test_sign_tx.py::test_cardano_sign_tx_failed[all_tx_inputs_must_be_external_(without_path)]": "612dad8ab8762162a186ec9279d7de0bdfc589c52b4e4f4eba0545a00f21c3f0", "cardano-test_sign_tx.py::test_cardano_sign_tx_failed[all_tx_inputs_must_be_external_(without_path)]": "612dad8ab8762162a186ec9279d7de0bdfc589c52b4e4f4eba0545a00f21c3f0",
@ -55,7 +55,7 @@
"cardano-test_sign_tx.py::test_cardano_sign_tx_failed[pool_reward_address_is_a_base_address]": "612dad8ab8762162a186ec9279d7de0bdfc589c52b4e4f4eba0545a00f21c3f0", "cardano-test_sign_tx.py::test_cardano_sign_tx_failed[pool_reward_address_is_a_base_address]": "612dad8ab8762162a186ec9279d7de0bdfc589c52b4e4f4eba0545a00f21c3f0",
"cardano-test_sign_tx.py::test_cardano_sign_tx_failed[repeated_asset_name_in_multiasset_token_group]": "612dad8ab8762162a186ec9279d7de0bdfc589c52b4e4f4eba0545a00f21c3f0", "cardano-test_sign_tx.py::test_cardano_sign_tx_failed[repeated_asset_name_in_multiasset_token_group]": "612dad8ab8762162a186ec9279d7de0bdfc589c52b4e4f4eba0545a00f21c3f0",
"cardano-test_sign_tx.py::test_cardano_sign_tx_failed[repeated_policyid_in_multiasset_output]": "612dad8ab8762162a186ec9279d7de0bdfc589c52b4e4f4eba0545a00f21c3f0", "cardano-test_sign_tx.py::test_cardano_sign_tx_failed[repeated_policyid_in_multiasset_output]": "612dad8ab8762162a186ec9279d7de0bdfc589c52b4e4f4eba0545a00f21c3f0",
"cardano-test_sign_tx.py::test_cardano_sign_tx_failed[sample_stake_pool_registration_certifi-883e81d5": "2468c4f540e8532d28300a7c4209d893536fb099d8036252277634198e9b1c66", "cardano-test_sign_tx.py::test_cardano_sign_tx_failed[sample_stake_pool_registration_certifi-883e81d5": "01e5fee96bb2c6fe86ab720c7b561e3c00ac202c401a0ff5f7801b0a911d07f2",
"cardano-test_sign_tx.py::test_cardano_sign_tx_failed[shelley_mainnet_transaction_with_testn-af110e3e": "612dad8ab8762162a186ec9279d7de0bdfc589c52b4e4f4eba0545a00f21c3f0", "cardano-test_sign_tx.py::test_cardano_sign_tx_failed[shelley_mainnet_transaction_with_testn-af110e3e": "612dad8ab8762162a186ec9279d7de0bdfc589c52b4e4f4eba0545a00f21c3f0",
"cardano-test_sign_tx.py::test_cardano_sign_tx_failed[shelley_testnet_transaction_with_mainn-ba78ab8f": "612dad8ab8762162a186ec9279d7de0bdfc589c52b4e4f4eba0545a00f21c3f0", "cardano-test_sign_tx.py::test_cardano_sign_tx_failed[shelley_testnet_transaction_with_mainn-ba78ab8f": "612dad8ab8762162a186ec9279d7de0bdfc589c52b4e4f4eba0545a00f21c3f0",
"cardano-test_sign_tx.py::test_cardano_sign_tx_failed[stake_deregistration_account_larger_than_100]": "ffae5d78193ba3e989f025b67c544ce77ac4fde9d547e4588a9fe6f90354a4c2", "cardano-test_sign_tx.py::test_cardano_sign_tx_failed[stake_deregistration_account_larger_than_100]": "ffae5d78193ba3e989f025b67c544ce77ac4fde9d547e4588a9fe6f90354a4c2",