Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 14 additions & 7 deletions core/src/apps/cosmos/transaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@

from .networks import format_amount, formatAmont, getChainName

required_keys = ["account_number", "chain_id", "fee", "memo", "msgs", "sequence"]
_optional_keys = ["timeout_height"]
Comment thread
somebodyLi marked this conversation as resolved.
MessageArgs = namedtuple(
"MessageArgs",
["account_number", "chain_id", "fee", "memo", "msgs", "sequence"],
required_keys,
)

KEY_SUBSTITUTIONS = [
Expand Down Expand Up @@ -224,13 +226,18 @@ def deserialize(raw_message: bytes) -> "Transaction":
j = json.loads(raw_message.decode())
except Exception:
raise wire.DataError("invalid JSON")
if any(
k not in j
for k in ["account_number", "chain_id", "fee", "memo", "msgs", "sequence"]
):
if any(k not in j for k in required_keys):
raise wire.DataError("invalid payload")

return Transaction(MessageArgs(**j))
return Transaction(
MessageArgs(
account_number=j["account_number"],
chain_id=j["chain_id"],
fee=j["fee"],
memo=j["memo"],
msgs=j["msgs"],
sequence=j["sequence"],
)
)
Comment thread
somebodyLi marked this conversation as resolved.


class SendTxn:
Expand Down
Loading