mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-12-18 04:18:10 +00:00
fix(cardano): use OrderedMap for output tokens and withdrawals
This commit is contained in:
parent
4e5772662c
commit
db657615f4
4
common/tests/fixtures/cardano/sign_tx.json
vendored
4
common/tests/fixtures/cardano/sign_tx.json
vendored
@ -779,8 +779,8 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"result": {
|
"result": {
|
||||||
"tx_hash": "0b929def7bd9f44f5602f809bc0f9be30521f6b93d625525cf33b956993bfb22",
|
"tx_hash": "43183c8de97886fc82f5981409c6cf4784e65ec9d945d53360ddd78350327856",
|
||||||
"serialized_tx": "83a500818258203b40265111d8bb3c3c608d95b3a0bf83461ace32d79336579a1939b3aad1c0b700018282583901eb0baa5e570cffbe2934db29df0b6a3d7c0430ee65d4c3a7ab2fefb91bc428e4720702ebd5dab4fb175324c192dc9bb76cc5da956e3c8dff821904d2a2581c75a292ffee938be03e9bae5657982a74e9014eb4960108c9e23a5b39a1487564247542686911182f581c95a292ffee938be03e9bae5657982a74e9014eb4960108c9e23a5b39a248456c204e69c3b16f1904d24874652474436f696e1a007838628258390180f9e2c88e6c817008f3a812ed889b4a4da8e0bd103f86e7335422aa122a946b9ad3d2ddf029d3a828f0468aece76895f15c9efbd69b42771a006ca79302182a030a08182fa100818258205d010cf16fdeff40955633d6c565f3844a288a24967cf6b76acbeb271b4f13c158408751e397bd9610735a92e65eab02c04aa61507f425e53c0119ddc06047bfac279439ee2bf6e0d572defa9e5649a1ea1fc2b8144041ab4970f39cd6850d4d670ef6"
|
"serialized_tx": "83a500818258203b40265111d8bb3c3c608d95b3a0bf83461ace32d79336579a1939b3aad1c0b700018282583901eb0baa5e570cffbe2934db29df0b6a3d7c0430ee65d4c3a7ab2fefb91bc428e4720702ebd5dab4fb175324c192dc9bb76cc5da956e3c8dff821904d2a2581c95a292ffee938be03e9bae5657982a74e9014eb4960108c9e23a5b39a24874652474436f696e1a0078386248456c204e69c3b16f1904d2581c75a292ffee938be03e9bae5657982a74e9014eb4960108c9e23a5b39a1487564247542686911182f8258390180f9e2c88e6c817008f3a812ed889b4a4da8e0bd103f86e7335422aa122a946b9ad3d2ddf029d3a828f0468aece76895f15c9efbd69b42771a006ca79302182a030a08182fa100818258205d010cf16fdeff40955633d6c565f3844a288a24967cf6b76acbeb271b4f13c158403e6aeb2c2e2a5d3f84f53ebe74b884be4a66c4bda9cb023f2041cd559321964d355c9dfb97aaf75a63b7a796bbe0bdcf1a9636d75708ffd89fec1c14c919670af6"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -87,7 +87,7 @@ if False:
|
|||||||
from apps.common.cbor import CborSequence
|
from apps.common.cbor import CborSequence
|
||||||
from apps.common.paths import PathSchema
|
from apps.common.paths import PathSchema
|
||||||
|
|
||||||
CborizedTokenBundle = dict[bytes, dict[bytes, int]]
|
CborizedTokenBundle = cbor.OrderedMap[bytes, cbor.OrderedMap[bytes, int]]
|
||||||
CborizedTxOutput = tuple[bytes, Union[int, tuple[int, CborizedTokenBundle]]]
|
CborizedTxOutput = tuple[bytes, Union[int, tuple[int, CborizedTokenBundle]]]
|
||||||
CborizedSignedTx = tuple[dict, dict, Optional[cbor.Raw]]
|
CborizedSignedTx = tuple[dict, dict, Optional[cbor.Raw]]
|
||||||
TxHash = bytes
|
TxHash = bytes
|
||||||
@ -428,11 +428,11 @@ def _cborize_output(
|
|||||||
def _cborize_token_bundle(
|
def _cborize_token_bundle(
|
||||||
token_bundle: list[CardanoAssetGroupType],
|
token_bundle: list[CardanoAssetGroupType],
|
||||||
) -> CborizedTokenBundle:
|
) -> CborizedTokenBundle:
|
||||||
result: CborizedTokenBundle = {}
|
result: CborizedTokenBundle = cbor.OrderedMap()
|
||||||
|
|
||||||
for token_group in token_bundle:
|
for token_group in token_bundle:
|
||||||
cborized_policy_id = bytes(token_group.policy_id)
|
cborized_policy_id = bytes(token_group.policy_id)
|
||||||
cborized_token_group = result[cborized_policy_id] = {}
|
cborized_token_group = result[cborized_policy_id] = cbor.OrderedMap()
|
||||||
|
|
||||||
for token in token_group.tokens:
|
for token in token_group.tokens:
|
||||||
cborized_asset_name = bytes(token.asset_name_bytes)
|
cborized_asset_name = bytes(token.asset_name_bytes)
|
||||||
@ -453,8 +453,8 @@ def _cborize_withdrawals(
|
|||||||
withdrawals: list[CardanoTxWithdrawalType],
|
withdrawals: list[CardanoTxWithdrawalType],
|
||||||
protocol_magic: int,
|
protocol_magic: int,
|
||||||
network_id: int,
|
network_id: int,
|
||||||
) -> dict[bytes, int]:
|
) -> cbor.OrderedMap[bytes, int]:
|
||||||
result = {}
|
result: cbor.OrderedMap[bytes, int] = cbor.OrderedMap()
|
||||||
for withdrawal in withdrawals:
|
for withdrawal in withdrawals:
|
||||||
reward_address = derive_address_bytes(
|
reward_address = derive_address_bytes(
|
||||||
keychain,
|
keychain,
|
||||||
|
Loading…
Reference in New Issue
Block a user