chore(cardano): rename voting public key to vote public key

pull/2868/head
David Misiak 1 year ago committed by matejcik
parent 0754a008e9
commit 826ade2a8d

@ -361,7 +361,7 @@ message CardanoTxWithdrawal {
* @embed * @embed
*/ */
message CardanoCVoteRegistrationDelegation { message CardanoCVoteRegistrationDelegation {
required bytes voting_public_key = 1; required bytes vote_public_key = 1;
required uint32 weight = 2; required uint32 weight = 2;
} }
@ -369,12 +369,12 @@ message CardanoCVoteRegistrationDelegation {
* @embed * @embed
*/ */
message CardanoCVoteRegistrationParametersType { message CardanoCVoteRegistrationParametersType {
optional bytes voting_public_key = 1; // mutually exclusive with delegations optional bytes vote_public_key = 1; // mutually exclusive with delegations
repeated uint32 staking_path = 2; repeated uint32 staking_path = 2;
optional CardanoAddressParametersType payment_address_parameters = 3; // mutually exclusive with payment_address optional CardanoAddressParametersType payment_address_parameters = 3; // mutually exclusive with payment_address
required uint64 nonce = 4; required uint64 nonce = 4;
optional CardanoCVoteRegistrationFormat format = 5 [default=CIP15]; optional CardanoCVoteRegistrationFormat format = 5 [default=CIP15];
repeated CardanoCVoteRegistrationDelegation delegations = 6; // mutually exclusive with voting_public_key; max 32 delegations repeated CardanoCVoteRegistrationDelegation delegations = 6; // mutually exclusive with vote_public_key; max 32 delegations
optional uint64 voting_purpose = 7; optional uint64 voting_purpose = 7;
optional string payment_address = 8; // mutually exclusive with payment_address_parameters optional string payment_address = 8; // mutually exclusive with payment_address_parameters
} }

@ -1310,7 +1310,7 @@
"withdrawals": [], "withdrawals": [],
"auxiliary_data": { "auxiliary_data": {
"cvote_registration_parameters": { "cvote_registration_parameters": {
"voting_public_key": "3b40265111d8bb3c3c608d95b3a0bf83461ace32d79336579a1939b3aad1c0b7", "vote_public_key": "3b40265111d8bb3c3c608d95b3a0bf83461ace32d79336579a1939b3aad1c0b7",
"staking_path": "m/1852'/1815'/0'/2/0", "staking_path": "m/1852'/1815'/0'/2/0",
"nonce": 22634813, "nonce": 22634813,
"payment_address_parameters": { "payment_address_parameters": {
@ -1360,7 +1360,7 @@
"auxiliary_data": { "auxiliary_data": {
"hash": "ea4c91860dd5ec5449f8f985d227946ff39086b17f10b5afb93d12ee87050b6a", "hash": "ea4c91860dd5ec5449f8f985d227946ff39086b17f10b5afb93d12ee87050b6a",
"cvote_registration_parameters": { "cvote_registration_parameters": {
"voting_public_key": "38DA0B509D45BF6C87BD55594B92F97081D3923B8C1334B9B8D0BF13FC1C12D0", "vote_public_key": "38DA0B509D45BF6C87BD55594B92F97081D3923B8C1334B9B8D0BF13FC1C12D0",
"staking_path": "m/1852'/1815'/0'/2/0", "staking_path": "m/1852'/1815'/0'/2/0",
"payment_address_parameters": { "payment_address_parameters": {
"addressType": 0, "addressType": 0,
@ -1399,7 +1399,7 @@
} }
}, },
{ {
"description": "transaction with both voting public key and delegations in cvote registration", "description": "transaction with both vote public key and delegations in cvote registration",
"parameters": { "parameters": {
"protocol_magic": 764824073, "protocol_magic": 764824073,
"network_id": 1, "network_id": 1,
@ -1410,7 +1410,7 @@
"withdrawals": [], "withdrawals": [],
"auxiliary_data": { "auxiliary_data": {
"cvote_registration_parameters": { "cvote_registration_parameters": {
"voting_public_key": "38DA0B509D45BF6C87BD55594B92F97081D3923B8C1334B9B8D0BF13FC1C12D0", "vote_public_key": "38DA0B509D45BF6C87BD55594B92F97081D3923B8C1334B9B8D0BF13FC1C12D0",
"staking_path": "m/1852'/1815'/0'/2/0", "staking_path": "m/1852'/1815'/0'/2/0",
"payment_address_parameters": { "payment_address_parameters": {
"addressType": 0, "addressType": 0,
@ -1421,7 +1421,7 @@
"format": 1, "format": 1,
"delegations": [ "delegations": [
{ {
"voting_public_key": "1af8fa0b754ff99253d983894e63a2b09cbb56c833ba18c3384210163f63dcfc", "vote_public_key": "1af8fa0b754ff99253d983894e63a2b09cbb56c833ba18c3384210163f63dcfc",
"weight": 1 "weight": 1
} }
] ]

@ -1013,7 +1013,7 @@
"withdrawals": [], "withdrawals": [],
"auxiliary_data": { "auxiliary_data": {
"cvote_registration_parameters": { "cvote_registration_parameters": {
"voting_public_key": "1af8fa0b754ff99253d983894e63a2b09cbb56c833ba18c3384210163f63dcfc", "vote_public_key": "1af8fa0b754ff99253d983894e63a2b09cbb56c833ba18c3384210163f63dcfc",
"staking_path": "m/1852'/1815'/0'/2/0", "staking_path": "m/1852'/1815'/0'/2/0",
"payment_address_parameters": { "payment_address_parameters": {
"addressType": 0, "addressType": 0,
@ -1086,11 +1086,11 @@
"format": 1, "format": 1,
"delegations": [ "delegations": [
{ {
"voting_public_key": "1af8fa0b754ff99253d983894e63a2b09cbb56c833ba18c3384210163f63dcfc", "vote_public_key": "1af8fa0b754ff99253d983894e63a2b09cbb56c833ba18c3384210163f63dcfc",
"weight": 1 "weight": 1
}, },
{ {
"voting_public_key": "2af8fa0b754ff99253d983894e63a2b09cbb56c833ba18c3384210163f63dcfc", "vote_public_key": "2af8fa0b754ff99253d983894e63a2b09cbb56c833ba18c3384210163f63dcfc",
"weight": 2 "weight": 2
} }
] ]
@ -1159,7 +1159,7 @@
"format": 1, "format": 1,
"delegations": [ "delegations": [
{ {
"voting_public_key": "1af8fa0b754ff99253d983894e63a2b09cbb56c833ba18c3384210163f63dcfc", "vote_public_key": "1af8fa0b754ff99253d983894e63a2b09cbb56c833ba18c3384210163f63dcfc",
"weight": 1 "weight": 1
} }
], ],
@ -1224,7 +1224,7 @@
"format": 1, "format": 1,
"delegations": [ "delegations": [
{ {
"voting_public_key": "1af8fa0b754ff99253d983894e63a2b09cbb56c833ba18c3384210163f63dcfc", "vote_public_key": "1af8fa0b754ff99253d983894e63a2b09cbb56c833ba18c3384210163f63dcfc",
"weight": 1 "weight": 1
} }
], ],
@ -1293,7 +1293,7 @@
"format": 1, "format": 1,
"delegations": [ "delegations": [
{ {
"voting_public_key": "1af8fa0b754ff99253d983894e63a2b09cbb56c833ba18c3384210163f63dcfc", "vote_public_key": "1af8fa0b754ff99253d983894e63a2b09cbb56c833ba18c3384210163f63dcfc",
"weight": 1 "weight": 1
} }
] ]
@ -1357,7 +1357,7 @@
"format": 1, "format": 1,
"delegations": [ "delegations": [
{ {
"voting_public_key": "1af8fa0b754ff99253d983894e63a2b09cbb56c833ba18c3384210163f63dcfc", "vote_public_key": "1af8fa0b754ff99253d983894e63a2b09cbb56c833ba18c3384210163f63dcfc",
"weight": 1 "weight": 1
} }
], ],
@ -1943,7 +1943,7 @@
"format": 1, "format": 1,
"delegations": [ "delegations": [
{ {
"voting_public_key": "1af8fa0b754ff99253d983894e63a2b09cbb56c833ba18c3384210163f63dcfc", "vote_public_key": "1af8fa0b754ff99253d983894e63a2b09cbb56c833ba18c3384210163f63dcfc",
"weight": 1 "weight": 1
} }
], ],

@ -457,7 +457,7 @@
} }
}, },
{ {
"description": "transaction with CIP36 registration and voting purpose not specified", "description": "transaction with CIP36 registration and vote purpose not specified",
"parameters": { "parameters": {
"protocol_magic": 764824073, "protocol_magic": 764824073,
"network_id": 1, "network_id": 1,
@ -478,11 +478,11 @@
"format": 1, "format": 1,
"delegations": [ "delegations": [
{ {
"voting_public_key": "1af8fa0b754ff99253d983894e63a2b09cbb56c833ba18c3384210163f63dcfc", "vote_public_key": "1af8fa0b754ff99253d983894e63a2b09cbb56c833ba18c3384210163f63dcfc",
"weight": 1 "weight": 1
}, },
{ {
"voting_public_key": "2af8fa0b754ff99253d983894e63a2b09cbb56c833ba18c3384210163f63dcfc", "vote_public_key": "2af8fa0b754ff99253d983894e63a2b09cbb56c833ba18c3384210163f63dcfc",
"weight": 2 "weight": 2
} }
] ]

@ -63,15 +63,15 @@ def _validate_cvote_registration_parameters(
protocol_magic: int, protocol_magic: int,
network_id: int, network_id: int,
) -> None: ) -> None:
voting_key_fields_provided = 0 vote_key_fields_provided = 0
if parameters.voting_public_key is not None: if parameters.vote_public_key is not None:
voting_key_fields_provided += 1 vote_key_fields_provided += 1
_validate_voting_public_key(parameters.voting_public_key) _validate_vote_public_key(parameters.vote_public_key)
if parameters.delegations: if parameters.delegations:
voting_key_fields_provided += 1 vote_key_fields_provided += 1
assert_cond(parameters.format == CardanoCVoteRegistrationFormat.CIP36) assert_cond(parameters.format == CardanoCVoteRegistrationFormat.CIP36)
_validate_delegations(parameters.delegations) _validate_delegations(parameters.delegations)
assert_cond(voting_key_fields_provided == 1) assert_cond(vote_key_fields_provided == 1)
assert_cond(SCHEMA_STAKING_ANY_ACCOUNT.match(parameters.staking_path)) assert_cond(SCHEMA_STAKING_ANY_ACCOUNT.match(parameters.staking_path))
@ -92,7 +92,7 @@ def _validate_cvote_registration_parameters(
assert_cond(parameters.format == CardanoCVoteRegistrationFormat.CIP36) assert_cond(parameters.format == CardanoCVoteRegistrationFormat.CIP36)
def _validate_voting_public_key(key: bytes) -> None: def _validate_vote_public_key(key: bytes) -> None:
assert_cond(len(key) == _CVOTE_PUBLIC_KEY_LENGTH) assert_cond(len(key) == _CVOTE_PUBLIC_KEY_LENGTH)
@ -101,7 +101,7 @@ def _validate_delegations(
) -> None: ) -> None:
assert_cond(len(delegations) <= _MAX_DELEGATION_COUNT) assert_cond(len(delegations) <= _MAX_DELEGATION_COUNT)
for delegation in delegations: for delegation in delegations:
_validate_voting_public_key(delegation.voting_public_key) _validate_vote_public_key(delegation.vote_public_key)
def _get_voting_purpose_to_serialize( def _get_voting_purpose_to_serialize(
@ -158,7 +158,7 @@ async def _show_cvote_registration(
for delegation in parameters.delegations: for delegation in parameters.delegations:
encoded_public_key = bech32.encode( encoded_public_key = bech32.encode(
bech32.HRP_CVOTE_PUBLIC_KEY, delegation.voting_public_key bech32.HRP_CVOTE_PUBLIC_KEY, delegation.vote_public_key
) )
await layout.confirm_cvote_registration_delegation( await layout.confirm_cvote_registration_delegation(
ctx, encoded_public_key, delegation.weight ctx, encoded_public_key, delegation.weight
@ -187,9 +187,9 @@ async def _show_cvote_registration(
) )
encoded_public_key: str | None = None encoded_public_key: str | None = None
if parameters.voting_public_key: if parameters.vote_public_key:
encoded_public_key = bech32.encode( encoded_public_key = bech32.encode(
bech32.HRP_CVOTE_PUBLIC_KEY, parameters.voting_public_key bech32.HRP_CVOTE_PUBLIC_KEY, parameters.vote_public_key
) )
voting_purpose: int | None = ( voting_purpose: int | None = (
@ -271,11 +271,11 @@ def _get_signed_cvote_registration_payload(
delegations_or_key: Delegations | bytes delegations_or_key: Delegations | bytes
if len(parameters.delegations) > 0: if len(parameters.delegations) > 0:
delegations_or_key = [ delegations_or_key = [
(delegation.voting_public_key, delegation.weight) (delegation.vote_public_key, delegation.weight)
for delegation in parameters.delegations for delegation in parameters.delegations
] ]
elif parameters.voting_public_key: elif parameters.vote_public_key:
delegations_or_key = parameters.voting_public_key delegations_or_key = parameters.vote_public_key
else: else:
raise RuntimeError # should not be reached - _validate_cvote_registration_parameters raise RuntimeError # should not be reached - _validate_cvote_registration_parameters

@ -818,14 +818,14 @@ async def confirm_cvote_registration_payment_address(
async def confirm_cvote_registration( async def confirm_cvote_registration(
ctx: Context, ctx: Context,
public_key: str | None, vote_public_key: str | None,
staking_path: list[int], staking_path: list[int],
nonce: int, nonce: int,
voting_purpose: int | None, voting_purpose: int | None,
) -> None: ) -> None:
props: list[PropertyType] = [("Vote key registration (CIP-36)", None)] props: list[PropertyType] = [("Vote key registration (CIP-36)", None)]
if public_key is not None: if vote_public_key is not None:
props.append(("Voting public key:", public_key)) props.append(("Vote public key:", vote_public_key))
props.extend( props.extend(
[ [
( (

@ -1639,13 +1639,13 @@ if TYPE_CHECKING:
return isinstance(msg, cls) return isinstance(msg, cls)
class CardanoCVoteRegistrationDelegation(protobuf.MessageType): class CardanoCVoteRegistrationDelegation(protobuf.MessageType):
voting_public_key: "bytes" vote_public_key: "bytes"
weight: "int" weight: "int"
def __init__( def __init__(
self, self,
*, *,
voting_public_key: "bytes", vote_public_key: "bytes",
weight: "int", weight: "int",
) -> None: ) -> None:
pass pass
@ -1655,7 +1655,7 @@ if TYPE_CHECKING:
return isinstance(msg, cls) return isinstance(msg, cls)
class CardanoCVoteRegistrationParametersType(protobuf.MessageType): class CardanoCVoteRegistrationParametersType(protobuf.MessageType):
voting_public_key: "bytes | None" vote_public_key: "bytes | None"
staking_path: "list[int]" staking_path: "list[int]"
payment_address_parameters: "CardanoAddressParametersType | None" payment_address_parameters: "CardanoAddressParametersType | None"
nonce: "int" nonce: "int"
@ -1670,7 +1670,7 @@ if TYPE_CHECKING:
nonce: "int", nonce: "int",
staking_path: "list[int] | None" = None, staking_path: "list[int] | None" = None,
delegations: "list[CardanoCVoteRegistrationDelegation] | None" = None, delegations: "list[CardanoCVoteRegistrationDelegation] | None" = None,
voting_public_key: "bytes | None" = None, vote_public_key: "bytes | None" = None,
payment_address_parameters: "CardanoAddressParametersType | None" = None, payment_address_parameters: "CardanoAddressParametersType | None" = None,
format: "CardanoCVoteRegistrationFormat | None" = None, format: "CardanoCVoteRegistrationFormat | None" = None,
voting_purpose: "int | None" = None, voting_purpose: "int | None" = None,

@ -65,7 +65,7 @@ REQUIRED_FIELDS_CVOTE_REGISTRATION = (
"staking_path", "staking_path",
"nonce", "nonce",
) )
REQUIRED_FIELDS_CVOTE_DELEGATION = ("voting_public_key", "weight") REQUIRED_FIELDS_CVOTE_DELEGATION = ("vote_public_key", "weight")
INCOMPLETE_OUTPUT_ERROR_MESSAGE = "The output is missing some fields" INCOMPLETE_OUTPUT_ERROR_MESSAGE = "The output is missing some fields"
@ -576,7 +576,7 @@ def parse_auxiliary_data(
raise AUXILIARY_DATA_MISSING_FIELDS_ERROR raise AUXILIARY_DATA_MISSING_FIELDS_ERROR
delegations.append( delegations.append(
messages.CardanoCVoteRegistrationDelegation( messages.CardanoCVoteRegistrationDelegation(
voting_public_key=bytes.fromhex(delegation["voting_public_key"]), vote_public_key=bytes.fromhex(delegation["vote_public_key"]),
weight=int(delegation["weight"]), weight=int(delegation["weight"]),
) )
) )
@ -586,8 +586,8 @@ def parse_auxiliary_data(
voting_purpose = cvote_registration.get("voting_purpose") voting_purpose = cvote_registration.get("voting_purpose")
cvote_registration_parameters = messages.CardanoCVoteRegistrationParametersType( cvote_registration_parameters = messages.CardanoCVoteRegistrationParametersType(
voting_public_key=parse_optional_bytes( vote_public_key=parse_optional_bytes(
cvote_registration.get("voting_public_key") cvote_registration.get("vote_public_key")
), ),
staking_path=tools.parse_path(cvote_registration["staking_path"]), staking_path=tools.parse_path(cvote_registration["staking_path"]),
nonce=cvote_registration["nonce"], nonce=cvote_registration["nonce"],

@ -2639,24 +2639,24 @@ class CardanoTxWithdrawal(protobuf.MessageType):
class CardanoCVoteRegistrationDelegation(protobuf.MessageType): class CardanoCVoteRegistrationDelegation(protobuf.MessageType):
MESSAGE_WIRE_TYPE = None MESSAGE_WIRE_TYPE = None
FIELDS = { FIELDS = {
1: protobuf.Field("voting_public_key", "bytes", repeated=False, required=True), 1: protobuf.Field("vote_public_key", "bytes", repeated=False, required=True),
2: protobuf.Field("weight", "uint32", repeated=False, required=True), 2: protobuf.Field("weight", "uint32", repeated=False, required=True),
} }
def __init__( def __init__(
self, self,
*, *,
voting_public_key: "bytes", vote_public_key: "bytes",
weight: "int", weight: "int",
) -> None: ) -> None:
self.voting_public_key = voting_public_key self.vote_public_key = vote_public_key
self.weight = weight self.weight = weight
class CardanoCVoteRegistrationParametersType(protobuf.MessageType): class CardanoCVoteRegistrationParametersType(protobuf.MessageType):
MESSAGE_WIRE_TYPE = None MESSAGE_WIRE_TYPE = None
FIELDS = { FIELDS = {
1: protobuf.Field("voting_public_key", "bytes", repeated=False, required=False, default=None), 1: protobuf.Field("vote_public_key", "bytes", repeated=False, required=False, default=None),
2: protobuf.Field("staking_path", "uint32", repeated=True, required=False, default=None), 2: protobuf.Field("staking_path", "uint32", repeated=True, required=False, default=None),
3: protobuf.Field("payment_address_parameters", "CardanoAddressParametersType", repeated=False, required=False, default=None), 3: protobuf.Field("payment_address_parameters", "CardanoAddressParametersType", repeated=False, required=False, default=None),
4: protobuf.Field("nonce", "uint64", repeated=False, required=True), 4: protobuf.Field("nonce", "uint64", repeated=False, required=True),
@ -2672,7 +2672,7 @@ class CardanoCVoteRegistrationParametersType(protobuf.MessageType):
nonce: "int", nonce: "int",
staking_path: Optional[Sequence["int"]] = None, staking_path: Optional[Sequence["int"]] = None,
delegations: Optional[Sequence["CardanoCVoteRegistrationDelegation"]] = None, delegations: Optional[Sequence["CardanoCVoteRegistrationDelegation"]] = None,
voting_public_key: Optional["bytes"] = None, vote_public_key: Optional["bytes"] = None,
payment_address_parameters: Optional["CardanoAddressParametersType"] = None, payment_address_parameters: Optional["CardanoAddressParametersType"] = None,
format: Optional["CardanoCVoteRegistrationFormat"] = CardanoCVoteRegistrationFormat.CIP15, format: Optional["CardanoCVoteRegistrationFormat"] = CardanoCVoteRegistrationFormat.CIP15,
voting_purpose: Optional["int"] = None, voting_purpose: Optional["int"] = None,
@ -2681,7 +2681,7 @@ class CardanoCVoteRegistrationParametersType(protobuf.MessageType):
self.staking_path: Sequence["int"] = staking_path if staking_path is not None else [] self.staking_path: Sequence["int"] = staking_path if staking_path is not None else []
self.delegations: Sequence["CardanoCVoteRegistrationDelegation"] = delegations if delegations is not None else [] self.delegations: Sequence["CardanoCVoteRegistrationDelegation"] = delegations if delegations is not None else []
self.nonce = nonce self.nonce = nonce
self.voting_public_key = voting_public_key self.vote_public_key = vote_public_key
self.payment_address_parameters = payment_address_parameters self.payment_address_parameters = payment_address_parameters
self.format = format self.format = format
self.voting_purpose = voting_purpose self.voting_purpose = voting_purpose

Loading…
Cancel
Save