Skip to content

Commit

Permalink
feat(cardano): rename drep types
Browse files Browse the repository at this point in the history
  • Loading branch information
jaskp committed Nov 23, 2023
1 parent e5f9d1e commit 9c7a680
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 41 deletions.
4 changes: 2 additions & 2 deletions common/protob/messages-cardano.proto
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
8 changes: 4 additions & 4 deletions core/src/apps/cardano/certificates.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions core/src/trezor/enums/CardanoDRepType.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@

KEY_HASH = 0
SCRIPT_HASH = 1
ALWAYS_ABSTAIN = 2
ALWAYS_NO_CONFIDENCE = 3
ABSTAIN = 2
NO_CONFIDENCE = 3
4 changes: 2 additions & 2 deletions core/src/trezor/enums/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
16 changes: 8 additions & 8 deletions core/tests/test_apps.cardano.certificate.py
Original file line number Diff line number Diff line change
Expand Up @@ -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),
),
]

Expand Down Expand Up @@ -637,7 +637,7 @@ def test_validate_certificate(self):
"29fb5fd4aa8cadd6705acc8263cee0fc62edca5ac38db593fec2f9fd"
),
drep=CardanoDRep(
type=CardanoDRepType.ALWAYS_ABSTAIN,
type=CardanoDRepType.ABSTAIN,
key_hash=unhexlify(
"29fb5fd4aa8cadd6705acc8263cee0fc62edca5ac38db593fec2f9fd"
),
Expand All @@ -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"
),
Expand All @@ -663,7 +663,7 @@ def test_validate_certificate(self):
"29fb5fd4aa8cadd6705acc8263cee0fc62edca5ac38db593fec2f9fd"
),
drep=CardanoDRep(
type=CardanoDRepType.ALWAYS_ABSTAIN,
type=CardanoDRepType.ABSTAIN,
script_hash=unhexlify(
"29fb5fd4aa8cadd6705acc8263cee0fc62edca5ac38db593fec2f9fd"
),
Expand All @@ -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"
),
Expand All @@ -689,7 +689,7 @@ def test_validate_certificate(self):
"29fb5fd4aa8cadd6705acc8263cee0fc62edca5ac38db593fec2f9fd"
),
drep=CardanoDRep(
type=CardanoDRepType.ALWAYS_ABSTAIN,
type=CardanoDRepType.ABSTAIN,
key_hash=unhexlify(
"29fb5fd4aa8cadd6705acc8263cee0fc62edca5ac38db593fec2f9fd"
),
Expand All @@ -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"
),
Expand Down
4 changes: 2 additions & 2 deletions python/src/trezorlib/messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
42 changes: 21 additions & 21 deletions rust/trezor-client/src/protos/generated/messages_cardano.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -9957,17 +9957,17 @@ 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
}
}

const VALUES: &'static [CardanoDRepType] = &[
CardanoDRepType::KEY_HASH,
CardanoDRepType::SCRIPT_HASH,
CardanoDRepType::ALWAYS_ABSTAIN,
CardanoDRepType::ALWAYS_NO_CONFIDENCE,
CardanoDRepType::ABSTAIN,
CardanoDRepType::NO_CONFIDENCE,
];
}

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 9c7a680

Please sign in to comment.