1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-11-13 19:18:56 +00:00
trezor-firmware/tests/device_tests/solana/construct/transaction.py

38 lines
866 B
Python
Raw Normal View History

2023-10-18 10:07:14 +00:00
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
)