1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-11-26 17:38:39 +00:00
trezor-firmware/tests/device_tests/solana/construct/transaction.py
2023-12-05 22:11:41 +01:00

38 lines
866 B
Python

from construct import Byte, GreedyBytes, If, Int8ul, Prefixed, RawCopy, Struct, this
from .custom_constructs import CompactArray, CompactU16, PublicKey, Version
Header = Struct(
"signers" / Int8ul,
"readonly_signers" / Int8ul,
"readonly_non_signers" / Int8ul,
)
Accounts = CompactArray(PublicKey)
Lut = Struct(
"account" / PublicKey,
"readwrite" / CompactArray(Int8ul),
"readonly" / CompactArray(Int8ul),
)
Luts = CompactArray(Lut)
RawInstruction = RawCopy(
Struct(
"program_id" / Byte,
"accounts" / CompactArray(Byte),
"data" / Prefixed(CompactU16, GreedyBytes),
)
)
Message = Struct(
"version" / Version,
"header" / Header,
"accounts" / Accounts,
"blockhash" / PublicKey,
"instructions" / CompactArray(RawInstruction),
"luts" / If(this.version != None, Luts), # noqa: E711
)