-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Subintent hash at device side #75
base: develop
Are you sure you want to change the base?
Changes from 1 commit
88bbea9
c86b702
4be4d1d
fc436bc
5dce883
eb8b306
d15611d
6bc5848
9d52ebd
a4e1241
281f4b8
2ee99be
b5324fd
55a1abf
9c6f30e
9a8c9f6
51f3bb6
d492709
48b1f74
7ebf756
9c966ee
c782067
fa07f8e
27da62c
470780b
3641a0c
41c65bc
5abb80b
bbaf46f
0668ff2
b27a7b2
939c002
0858f59
6ec1f4c
9cac6bc
682d261
5c17e0f
c89fb72
157e4a3
8987be6
339b94d
02b07af
3ef483d
b7da2ec
5fe86fe
3c87fdf
96be00e
aa6c9f0
a66808d
42d2918
73f1cd3
af84512
eb58fab
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
// Process events received from decoder and extract data related to instructions | ||
|
||
/// Process events received from SBOR decoder and extract data related to each instruction | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. incorrect doc, if this doc is for this file, then you should use |
||
/// and its parameters. | ||
/// Implemented as a state machine which "walks" through the transaction intent and when it reaches | ||
/// the instructions it starts emitting relevant events. | ||
use crate::instruction::{to_instruction, InstructionInfo}; | ||
use crate::sbor_decoder::SborEvent; | ||
use crate::type_info::{to_type_info, TypeInfo, TYPE_ENUM, TYPE_NONE, TYPE_TUPLE}; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,7 @@ use crate::static_vec::StaticVec; | |
#[derive(Copy, Clone, Debug)] | ||
pub struct Decimal(BigInt<192>); | ||
|
||
/// Ledger app-specific counterpart of the Scrypto Decimal type | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. incorrectly place doc, should go on top of derive on top of |
||
impl Decimal { | ||
pub const SIZE_IN_BYTES: usize = BigInt::<192>::NUM_BYTES; | ||
pub const ZERO: Decimal = Decimal(BigInt::from_limbs([0, 0, 0, 0, 0, 0])); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,7 @@ use crate::static_vec::StaticVec; | |
#[derive(Copy, Clone)] | ||
pub struct PreciseDecimal(BigInt<256>); | ||
|
||
/// Ledger app-specific counterpart of the Scrypto PreciseDecimal type | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. incorrectly place doc, should go on top of derive on top of |
||
impl PreciseDecimal { | ||
pub const SIZE_IN_BYTES: usize = BigInt::<256>::NUM_BYTES; | ||
pub const SCALE: usize = 36; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,7 @@ use crate::print::tty::TTY; | |
use crate::sbor_decoder::STACK_DEPTH; | ||
use crate::static_vec::StaticVec; | ||
|
||
/// Element of the parameter printer nesting stack. | ||
#[repr(C, packed)] | ||
#[derive(Copy, Clone, Debug)] | ||
pub struct ValueState { | ||
|
@@ -38,13 +39,15 @@ impl Default for ValueState { | |
} | ||
} | ||
|
||
/// The intermediate buffer size for the individual parameters. | ||
#[cfg(target_os = "nanos")] | ||
pub const PARAMETER_AREA_SIZE: usize = 96; | ||
#[cfg(any(target_os = "nanox", target_os = "nanosplus"))] | ||
pub const PARAMETER_AREA_SIZE: usize = 256; | ||
#[cfg(not(any(target_os = "nanos", target_os = "nanox", target_os = "nanosplus")))] | ||
pub const PARAMETER_AREA_SIZE: usize = 256; | ||
|
||
/// The buffer size of the entire message to be displayed. | ||
#[cfg(target_os = "nanos")] | ||
pub const DISPLAY_SIZE: usize = 256; // Use smaller buffer for Nano S | ||
#[cfg(any(target_os = "nanox", target_os = "nanosplus"))] | ||
|
@@ -57,11 +60,11 @@ pub const TITLE_SIZE: usize = 32; | |
pub struct ParameterPrinterState<T: Copy> { | ||
pub display: StaticVec<u8, { DISPLAY_SIZE }>, | ||
pub data: StaticVec<u8, { PARAMETER_AREA_SIZE }>, | ||
pub title: StaticVec<u8, { TITLE_SIZE }>, | ||
pub title: StaticVec<u8, { TITLE_SIZE }>, // Intermediate buffer for formatting instruction titles (instruction number) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. docs must go op top of field, or are you "waiting" with that until last minute? just dont forget :) |
||
pub stack: StaticVec<ValueState, { STACK_DEPTH as usize }>, | ||
pub nesting_level: u8, | ||
pub nesting_level: u8, // Active nesting level in the stack | ||
pub network_id: NetworkId, | ||
pub show_instructions: bool, | ||
pub show_instructions: bool, // Whether to show instructions or not | ||
tty: TTY<T>, | ||
} | ||
|
||
|
@@ -87,7 +90,7 @@ impl<T: Copy> ParameterPrinterState<T> { | |
nesting_level: 0, | ||
network_id, | ||
show_instructions: true, | ||
tty: tty, | ||
tty, | ||
} | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,8 @@ | ||
/// Transaction summary detector is used to determine the type of the transaction intent and collect | ||
/// information about fees. | ||
/// Implementation consists of two independent state machines - one for detecting the intent type and | ||
/// other to collect fee information. Both of them use information about decoded instructions | ||
/// received from `InstructionExtractor`. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. incorrect doc, either use |
||
use crate::bech32::address::Address; | ||
use crate::instruction::{Instruction, InstructionInfo}; | ||
use crate::instruction_extractor::ExtractorEvent; | ||
|
@@ -7,7 +12,7 @@ use crate::sbor_decoder::SborEvent; | |
use crate::static_vec::StaticVec; | ||
use crate::type_info::*; | ||
|
||
// Lock_fee: CallMethod -> Address -> Name ("lock_fee") -> TupleLockFee -> (ValueLockFee) -> DoneLockFee | ||
/// Transaction fee collector state machine phases. | ||
#[derive(Copy, Clone, PartialEq)] | ||
#[repr(u8)] | ||
pub enum FeePhase { | ||
|
@@ -20,6 +25,7 @@ pub enum FeePhase { | |
ValueStart, | ||
} | ||
|
||
/// Transaction type detector state machine phases. | ||
#[derive(Copy, Clone, PartialEq)] | ||
#[repr(u8)] | ||
pub enum DecodingPhase { | ||
|
@@ -46,10 +52,10 @@ pub enum DecodingPhase { | |
#[derive(Copy, Clone, Debug)] | ||
pub struct TransferDetails { | ||
pub fee: Option<Decimal>, | ||
pub src_address: Address, | ||
pub dst_address: Address, | ||
pub res_address: Address, | ||
pub amount: Decimal, | ||
pub src_address: Address, // From ... | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. don't forget to fix doc for fields... |
||
pub dst_address: Address, // To ... | ||
pub res_address: Address, // Resource ... | ||
pub amount: Decimal, // Amount ... | ||
} | ||
|
||
#[derive(Copy, Clone, Debug)] | ||
|
@@ -132,14 +138,16 @@ impl DetectedTxType { | |
} | ||
} | ||
|
||
//Max of address length and decimal length | ||
/// Size of temporary buffer for parameter data. It should be enough to store any parameter data | ||
/// which we're going to use. So far we're operating with addresses, decimal numbers and fixed | ||
/// method names. None of them exceeds 40 bytes. | ||
const MAX_TX_DATA_SIZE: usize = 40; | ||
|
||
pub struct TxSummaryDetector { | ||
intent_type: TxIntentType, | ||
decoding_phase: DecodingPhase, | ||
fee_phase: FeePhase, | ||
data: StaticVec<u8, { MAX_TX_DATA_SIZE }>, | ||
data: StaticVec<u8, { MAX_TX_DATA_SIZE }>, // Temporary buffer for parameter data | ||
fee: Decimal, | ||
amount: Decimal, | ||
src_address: Address, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
incorrect doc, there is an empty space between this doc and the type
enum Instruction
, the doc must go on top of#[repr()u8]
, without newline between. And every line in the doc must be///