From 9c7a6800e9fc215576df60720855ecd822c4dab4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Peter=20Jas=CC=8Cko?= Date: Thu, 23 Nov 2023 22:58:43 +0100 Subject: [PATCH] feat(cardano): rename drep types --- common/protob/messages-cardano.proto | 4 +- core/src/apps/cardano/certificates.py | 8 ++-- core/src/trezor/enums/CardanoDRepType.py | 4 +- core/src/trezor/enums/__init__.py | 4 +- core/tests/test_apps.cardano.certificate.py | 16 +++---- python/src/trezorlib/messages.py | 4 +- .../src/protos/generated/messages_cardano.rs | 42 +++++++++---------- 7 files changed, 41 insertions(+), 41 deletions(-) diff --git a/common/protob/messages-cardano.proto b/common/protob/messages-cardano.proto index a03ad20aa51..bf1a5d9f8ed 100644 --- a/common/protob/messages-cardano.proto +++ b/common/protob/messages-cardano.proto @@ -64,8 +64,8 @@ enum CardanoCertificateType { enum CardanoDRepType { KEY_HASH = 0; SCRIPT_HASH = 1; - ALWAYS_ABSTAIN = 2; - ALWAYS_NO_CONFIDENCE = 3; + ABSTAIN = 2; + NO_CONFIDENCE = 3; } enum CardanoPoolRelayType { diff --git a/core/src/apps/cardano/certificates.py b/core/src/apps/cardano/certificates.py index 560ba322a05..54da068b08c 100644 --- a/core/src/apps/cardano/certificates.py +++ b/core/src/apps/cardano/certificates.py @@ -275,8 +275,8 @@ def validate_drep( if key_hash or not script_hash or len(script_hash) != SCRIPT_HASH_SIZE: raise error elif drep_type in ( - CardanoDRepType.ALWAYS_ABSTAIN, - CardanoDRepType.ALWAYS_NO_CONFIDENCE, + CardanoDRepType.ABSTAIN, + CardanoDRepType.NO_CONFIDENCE, ): if script_hash or key_hash: raise error @@ -330,9 +330,9 @@ def cborize_drep(drep: messages.CardanoDRep) -> tuple[int, bytes] | tuple[int]: elif drep.type == CardanoDRepType.SCRIPT_HASH: assert drep.script_hash is not None return 1, drep.script_hash - elif drep.type == CardanoDRepType.ALWAYS_ABSTAIN: + elif drep.type == CardanoDRepType.ABSTAIN: return (2,) - elif drep.type == CardanoDRepType.ALWAYS_NO_CONFIDENCE: + elif drep.type == CardanoDRepType.NO_CONFIDENCE: return (3,) else: raise RuntimeError # should be unreachable diff --git a/core/src/trezor/enums/CardanoDRepType.py b/core/src/trezor/enums/CardanoDRepType.py index f94430ff29f..bae3fbe218b 100644 --- a/core/src/trezor/enums/CardanoDRepType.py +++ b/core/src/trezor/enums/CardanoDRepType.py @@ -4,5 +4,5 @@ KEY_HASH = 0 SCRIPT_HASH = 1 -ALWAYS_ABSTAIN = 2 -ALWAYS_NO_CONFIDENCE = 3 +ABSTAIN = 2 +NO_CONFIDENCE = 3 diff --git a/core/src/trezor/enums/__init__.py b/core/src/trezor/enums/__init__.py index 5cfa226551e..b00f2670bd1 100644 --- a/core/src/trezor/enums/__init__.py +++ b/core/src/trezor/enums/__init__.py @@ -385,8 +385,8 @@ class CardanoCertificateType(IntEnum): class CardanoDRepType(IntEnum): KEY_HASH = 0 SCRIPT_HASH = 1 - ALWAYS_ABSTAIN = 2 - ALWAYS_NO_CONFIDENCE = 3 + ABSTAIN = 2 + NO_CONFIDENCE = 3 class CardanoPoolRelayType(IntEnum): SINGLE_HOST_IP = 0 diff --git a/core/tests/test_apps.cardano.certificate.py b/core/tests/test_apps.cardano.certificate.py index cd5b8ccf520..0fe79e5827a 100644 --- a/core/tests/test_apps.cardano.certificate.py +++ b/core/tests/test_apps.cardano.certificate.py @@ -158,14 +158,14 @@ def test_validate_certificate(self): key_hash=unhexlify( "29fb5fd4aa8cadd6705acc8263cee0fc62edca5ac38db593fec2f9fd" ), - drep=CardanoDRep(type=CardanoDRepType.ALWAYS_ABSTAIN), + drep=CardanoDRep(type=CardanoDRepType.ABSTAIN), ), CardanoTxCertificate( type=CardanoCertificateType.VOTE_DELEGATION, key_hash=unhexlify( "29fb5fd4aa8cadd6705acc8263cee0fc62edca5ac38db593fec2f9fd" ), - drep=CardanoDRep(type=CardanoDRepType.ALWAYS_NO_CONFIDENCE), + drep=CardanoDRep(type=CardanoDRepType.NO_CONFIDENCE), ), ] @@ -637,7 +637,7 @@ def test_validate_certificate(self): "29fb5fd4aa8cadd6705acc8263cee0fc62edca5ac38db593fec2f9fd" ), drep=CardanoDRep( - type=CardanoDRepType.ALWAYS_ABSTAIN, + type=CardanoDRepType.ABSTAIN, key_hash=unhexlify( "29fb5fd4aa8cadd6705acc8263cee0fc62edca5ac38db593fec2f9fd" ), @@ -650,7 +650,7 @@ def test_validate_certificate(self): "29fb5fd4aa8cadd6705acc8263cee0fc62edca5ac38db593fec2f9fd" ), drep=CardanoDRep( - type=CardanoDRepType.ALWAYS_NO_CONFIDENCE, + type=CardanoDRepType.NO_CONFIDENCE, key_hash=unhexlify( "29fb5fd4aa8cadd6705acc8263cee0fc62edca5ac38db593fec2f9fd" ), @@ -663,7 +663,7 @@ def test_validate_certificate(self): "29fb5fd4aa8cadd6705acc8263cee0fc62edca5ac38db593fec2f9fd" ), drep=CardanoDRep( - type=CardanoDRepType.ALWAYS_ABSTAIN, + type=CardanoDRepType.ABSTAIN, script_hash=unhexlify( "29fb5fd4aa8cadd6705acc8263cee0fc62edca5ac38db593fec2f9fd" ), @@ -676,7 +676,7 @@ def test_validate_certificate(self): "29fb5fd4aa8cadd6705acc8263cee0fc62edca5ac38db593fec2f9fd" ), drep=CardanoDRep( - type=CardanoDRepType.ALWAYS_NO_CONFIDENCE, + type=CardanoDRepType.NO_CONFIDENCE, script_hash=unhexlify( "29fb5fd4aa8cadd6705acc8263cee0fc62edca5ac38db593fec2f9fd" ), @@ -689,7 +689,7 @@ def test_validate_certificate(self): "29fb5fd4aa8cadd6705acc8263cee0fc62edca5ac38db593fec2f9fd" ), drep=CardanoDRep( - type=CardanoDRepType.ALWAYS_ABSTAIN, + type=CardanoDRepType.ABSTAIN, key_hash=unhexlify( "29fb5fd4aa8cadd6705acc8263cee0fc62edca5ac38db593fec2f9fd" ), @@ -705,7 +705,7 @@ def test_validate_certificate(self): "29fb5fd4aa8cadd6705acc8263cee0fc62edca5ac38db593fec2f9fd" ), drep=CardanoDRep( - type=CardanoDRepType.ALWAYS_NO_CONFIDENCE, + type=CardanoDRepType.NO_CONFIDENCE, key_hash=unhexlify( "29fb5fd4aa8cadd6705acc8263cee0fc62edca5ac38db593fec2f9fd" ), diff --git a/python/src/trezorlib/messages.py b/python/src/trezorlib/messages.py index 0ebeabe13d1..e8bcbb9cc43 100644 --- a/python/src/trezorlib/messages.py +++ b/python/src/trezorlib/messages.py @@ -408,8 +408,8 @@ class CardanoCertificateType(IntEnum): class CardanoDRepType(IntEnum): KEY_HASH = 0 SCRIPT_HASH = 1 - ALWAYS_ABSTAIN = 2 - ALWAYS_NO_CONFIDENCE = 3 + ABSTAIN = 2 + NO_CONFIDENCE = 3 class CardanoPoolRelayType(IntEnum): diff --git a/rust/trezor-client/src/protos/generated/messages_cardano.rs b/rust/trezor-client/src/protos/generated/messages_cardano.rs index 601aea0220e..b06dfaf4bff 100644 --- a/rust/trezor-client/src/protos/generated/messages_cardano.rs +++ b/rust/trezor-client/src/protos/generated/messages_cardano.rs @@ -9940,10 +9940,10 @@ pub enum CardanoDRepType { KEY_HASH = 0, // @@protoc_insertion_point(enum_value:hw.trezor.messages.cardano.CardanoDRepType.SCRIPT_HASH) SCRIPT_HASH = 1, - // @@protoc_insertion_point(enum_value:hw.trezor.messages.cardano.CardanoDRepType.ALWAYS_ABSTAIN) - ALWAYS_ABSTAIN = 2, - // @@protoc_insertion_point(enum_value:hw.trezor.messages.cardano.CardanoDRepType.ALWAYS_NO_CONFIDENCE) - ALWAYS_NO_CONFIDENCE = 3, + // @@protoc_insertion_point(enum_value:hw.trezor.messages.cardano.CardanoDRepType.ABSTAIN) + ABSTAIN = 2, + // @@protoc_insertion_point(enum_value:hw.trezor.messages.cardano.CardanoDRepType.NO_CONFIDENCE) + NO_CONFIDENCE = 3, } impl ::protobuf::Enum for CardanoDRepType { @@ -9957,8 +9957,8 @@ impl ::protobuf::Enum for CardanoDRepType { match value { 0 => ::std::option::Option::Some(CardanoDRepType::KEY_HASH), 1 => ::std::option::Option::Some(CardanoDRepType::SCRIPT_HASH), - 2 => ::std::option::Option::Some(CardanoDRepType::ALWAYS_ABSTAIN), - 3 => ::std::option::Option::Some(CardanoDRepType::ALWAYS_NO_CONFIDENCE), + 2 => ::std::option::Option::Some(CardanoDRepType::ABSTAIN), + 3 => ::std::option::Option::Some(CardanoDRepType::NO_CONFIDENCE), _ => ::std::option::Option::None } } @@ -9966,8 +9966,8 @@ impl ::protobuf::Enum for CardanoDRepType { const VALUES: &'static [CardanoDRepType] = &[ CardanoDRepType::KEY_HASH, CardanoDRepType::SCRIPT_HASH, - CardanoDRepType::ALWAYS_ABSTAIN, - CardanoDRepType::ALWAYS_NO_CONFIDENCE, + CardanoDRepType::ABSTAIN, + CardanoDRepType::NO_CONFIDENCE, ]; } @@ -10447,19 +10447,19 @@ static file_descriptor_proto_data: &'static [u8] = b"\ \x10\0\x12\x18\n\x14STAKE_DEREGISTRATION\x10\x01\x12\x14\n\x10STAKE_DELE\ GATION\x10\x02\x12\x1b\n\x17STAKE_POOL_REGISTRATION\x10\x03\x12\x1d\n\ \x19STAKE_REGISTRATION_CONWAY\x10\x07\x12\x1f\n\x1bSTAKE_DEREGISTRATION_\ - CONWAY\x10\x08\x12\x13\n\x0fVOTE_DELEGATION\x10\t*^\n\x0fCardanoDRepType\ - \x12\x0c\n\x08KEY_HASH\x10\0\x12\x0f\n\x0bSCRIPT_HASH\x10\x01\x12\x12\n\ - \x0eALWAYS_ABSTAIN\x10\x02\x12\x18\n\x14ALWAYS_NO_CONFIDENCE\x10\x03*X\n\ - \x14CardanoPoolRelayType\x12\x12\n\x0eSINGLE_HOST_IP\x10\0\x12\x14\n\x10\ - SINGLE_HOST_NAME\x10\x01\x12\x16\n\x12MULTIPLE_HOST_NAME\x10\x02*R\n$Car\ - danoTxAuxiliaryDataSupplementType\x12\x08\n\x04NONE\x10\0\x12\x20\n\x1cC\ - VOTE_REGISTRATION_SIGNATURE\x10\x01*6\n\x1eCardanoCVoteRegistrationForma\ - t\x12\t\n\x05CIP15\x10\0\x12\t\n\x05CIP36\x10\x01*\x82\x01\n\x14CardanoT\ - xSigningMode\x12\x18\n\x14ORDINARY_TRANSACTION\x10\0\x12\x1e\n\x1aPOOL_R\ - EGISTRATION_AS_OWNER\x10\x01\x12\x18\n\x14MULTISIG_TRANSACTION\x10\x02\ - \x12\x16\n\x12PLUTUS_TRANSACTION\x10\x03*>\n\x14CardanoTxWitnessType\x12\ - \x11\n\rBYRON_WITNESS\x10\0\x12\x13\n\x0fSHELLEY_WITNESS\x10\x01B;\n#com\ - .satoshilabs.trezor.lib.protobufB\x14TrezorMessageCardano\ + CONWAY\x10\x08\x12\x13\n\x0fVOTE_DELEGATION\x10\t*P\n\x0fCardanoDRepType\ + \x12\x0c\n\x08KEY_HASH\x10\0\x12\x0f\n\x0bSCRIPT_HASH\x10\x01\x12\x0b\n\ + \x07ABSTAIN\x10\x02\x12\x11\n\rNO_CONFIDENCE\x10\x03*X\n\x14CardanoPoolR\ + elayType\x12\x12\n\x0eSINGLE_HOST_IP\x10\0\x12\x14\n\x10SINGLE_HOST_NAME\ + \x10\x01\x12\x16\n\x12MULTIPLE_HOST_NAME\x10\x02*R\n$CardanoTxAuxiliaryD\ + ataSupplementType\x12\x08\n\x04NONE\x10\0\x12\x20\n\x1cCVOTE_REGISTRATIO\ + N_SIGNATURE\x10\x01*6\n\x1eCardanoCVoteRegistrationFormat\x12\t\n\x05CIP\ + 15\x10\0\x12\t\n\x05CIP36\x10\x01*\x82\x01\n\x14CardanoTxSigningMode\x12\ + \x18\n\x14ORDINARY_TRANSACTION\x10\0\x12\x1e\n\x1aPOOL_REGISTRATION_AS_O\ + WNER\x10\x01\x12\x18\n\x14MULTISIG_TRANSACTION\x10\x02\x12\x16\n\x12PLUT\ + US_TRANSACTION\x10\x03*>\n\x14CardanoTxWitnessType\x12\x11\n\rBYRON_WITN\ + ESS\x10\0\x12\x13\n\x0fSHELLEY_WITNESS\x10\x01B;\n#com.satoshilabs.trezo\ + r.lib.protobufB\x14TrezorMessageCardano\ "; /// `FileDescriptorProto` object which was a source for this generated file