Skip to content

Commit

Permalink
Fix formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
siy committed Nov 1, 2024
1 parent 157e4a3 commit 8987be6
Show file tree
Hide file tree
Showing 8 changed files with 36 additions and 39 deletions.
2 changes: 1 addition & 1 deletion sbor/src/bech32/address.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use crate::math::StaticVec;
use crate::type_info::ADDRESS_STATIC_LEN;

/// Reusable storage for various types of addresses. All addresses share same length.
/// For convenience in use with stream decoders, additional boolean flag is maintained.
/// For convenience in use with stream decoders, additional boolean flag is maintained.
#[derive(Copy, Clone, Debug)]
pub struct Address {
address: [u8; ADDRESS_STATIC_LEN as usize],
Expand Down
4 changes: 2 additions & 2 deletions sbor/src/print/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,9 @@ pub struct ParameterPrinterState<T: Copy> {
pub data: StaticVec<u8, { PARAMETER_AREA_SIZE }>,
pub title: StaticVec<u8, { TITLE_SIZE }>, // Intermediate buffer for formatting instruction titles (instruction number)
pub stack: StaticVec<ValueState, { STACK_DEPTH as usize }>,
pub nesting_level: u8, // Active nesting level in the stack
pub nesting_level: u8, // Active nesting level in the stack
pub network_id: NetworkId,
pub show_instructions: bool, // Whether to show instructions or not
pub show_instructions: bool, // Whether to show instructions or not
tty: TTY<T>,
}

Expand Down
8 changes: 4 additions & 4 deletions sbor/src/print/tx_summary_detector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,10 @@ pub enum DecodingPhase {
#[derive(Copy, Clone, Debug)]
pub struct TransferDetails {
pub fee: Option<Decimal>,
pub src_address: Address, // From ...
pub dst_address: Address, // To ...
pub res_address: Address, // Resource ...
pub amount: Decimal, // Amount ...
pub src_address: Address, // From ...
pub dst_address: Address, // To ...
pub res_address: Address, // Resource ...
pub amount: Decimal, // Amount ...
}

#[derive(Copy, Clone, Debug)]
Expand Down
41 changes: 20 additions & 21 deletions sbor/src/sbor_decoder.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/// Streaming decoder for SBOR format
use crate::decoder_error::DecoderError;
use crate::type_info::*;
use core::option::Option::{None, Some};
Expand Down Expand Up @@ -73,10 +72,10 @@ impl Flags {
#[repr(C, packed)]
#[derive(Copy, Clone, Debug)]
struct State {
items_to_read: u32, // How many items we need to read for arrays, tuples, enums, maps, etc.)
active_type_id: u8, // The ID of the type which we're decoding at this nesting level
key_type_id: u8, // Map key type ID
element_type_id: u8, // Map value type ID; Array/Tuple/Enum - element type ID
items_to_read: u32, // How many items we need to read for arrays, tuples, enums, maps, etc.)
active_type_id: u8, // The ID of the type which we're decoding at this nesting level
key_type_id: u8, // Map key type ID
element_type_id: u8, // Map value type ID; Array/Tuple/Enum - element type ID
flags: Flags,
}

Expand All @@ -92,22 +91,22 @@ pub enum DecodingOutcome {
#[derive(Copy, Clone, Debug, PartialEq)]
pub enum SborEvent {
Start {
type_id: u8, // The type of the element that we're starting to decode
nesting_level: u8, // The nesting level of the element
fixed_size: u8, // Non-zero value means that element is of fixed size (e.g. u8, i32, etc.)
type_id: u8, // The type of the element that we're starting to decode
nesting_level: u8, // The nesting level of the element
fixed_size: u8, // Non-zero value means that element is of fixed size (e.g. u8, i32, etc.)
},
Len(u32), // The length of the element (e.g. array length, string length, etc.)
Len(u32), // The length of the element (e.g. array length, string length, etc.)
ElementType {
kind: SubTypeKind, // The kind of the element (element, key, value)
type_id: u8, // The type of the element
kind: SubTypeKind, // The kind of the element (element, key, value)
type_id: u8, // The type of the element
},
Discriminator(u8), // Enum discriminator
Data(u8), // Single raw data byte for the element content (e.g. u8, i32, string, array, etc.)
Discriminator(u8), // Enum discriminator
Data(u8), // Single raw data byte for the element content (e.g. u8, i32, string, array, etc.)
End {
type_id: u8, // The type of the element that we're ending to decode
nesting_level: u8, // The nesting level of the element
type_id: u8, // The type of the element that we're ending to decode
nesting_level: u8, // The nesting level of the element
},
InputByte(u8), // Plain input byte
InputByte(u8), // Plain input byte
}

#[repr(u8)]
Expand All @@ -127,11 +126,11 @@ pub trait SborEventHandler {
#[repr(C, packed)]
pub struct SborDecoder {
stack: [State; STACK_DEPTH as usize],
byte_count: usize, // Number of processed bytes
len_acc: usize, // Encoded length accumulator
head: u8, // Decoding stack head index
len_shift: u8, // Number of bits which need to be shifted in len_acc to get the final value
expect_leading_byte: bool, // Expect SBOR leading byte at the beginning of the input
byte_count: usize, // Number of processed bytes
len_acc: usize, // Encoded length accumulator
head: u8, // Decoding stack head index
len_shift: u8, // Number of bits which need to be shifted in len_acc to get the final value
expect_leading_byte: bool, // Expect SBOR leading byte at the beginning of the input
}

impl SborDecoder {
Expand Down
8 changes: 3 additions & 5 deletions sbor/src/type_info.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/// Various SBOR type information
use crate::math::{Decimal, PreciseDecimal};
use core::option::Option;
use core::prelude::rust_2024::derive;
Expand Down Expand Up @@ -82,9 +81,9 @@ pub enum DecoderPhase {
#[repr(C, align(4))]
#[derive(Copy, Clone, Debug)]
pub struct TypeInfo {
pub next_phases: &'static [DecoderPhase], // Decoding phases for this type
pub fixed_len: u8, // Fixed length of this type (if greater than zero)
pub type_id: u8, // Type ID
pub next_phases: &'static [DecoderPhase], // Decoding phases for this type
pub fixed_len: u8, // Fixed length of this type (if greater than zero)
pub type_id: u8, // Type ID
}

/// Placeholder, it is here for completeness (i.e. each type has a corresponding TypeInfo)
Expand Down Expand Up @@ -121,7 +120,6 @@ const LIST_DECODING: [DecoderPhase; 4] = [
DecoderPhase::ReadingData,
];


/// Decoding phases for maps.
const MAP_DECODING: [DecoderPhase; 5] = [
DecoderPhase::ReadingTypeId,
Expand Down
2 changes: 1 addition & 1 deletion simple-bigint/src/bigint.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::bcd::BCD;
use crate::ceil_div;

/// Simple big integer implementation which supports very limited number of operations
/// Simple big integer implementation which supports very limited number of operations
/// necessary for the Babylon Ledger App.
/// N - number of bits in the big integer
#[derive(Clone, Copy, Debug)]
Expand Down
4 changes: 2 additions & 2 deletions src/sign/decoding_mode.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
/// Decoding modes for the signing flow
/// There are two types of the decoding modes - "short" (they contain only 2 steps) and "long", which may contain
/// There are two types of the decoding modes - "short" (they contain only 2 steps) and "long", which may contain
/// 2 or more steps, depending on the blob size.
/// "Short" types are `Auth` and `PreAuth`, which assume that host will send (1) derivation path and (2) relevant data.
/// "Long" type is `Transaction`, which processes (1) derivation path and then one or more parts of the blob (SBOR-encoded transaction or subintent).
/// It is assumed that each new 2-step commands will require adding dedicated decoding mode, although multistep processing most likely will go through
/// the same SBOR decoding process and reuse the same `Transaction` decoding mode.
/// the same SBOR decoding process and reuse the same `Transaction` decoding mode.
#[repr(u8)]
#[derive(PartialEq, Copy, Clone)]
pub enum DecodingMode {
Expand Down
6 changes: 3 additions & 3 deletions src/sign/tx_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -212,16 +212,16 @@ impl<T: Copy> TxState<T> {
if !(Settings::get().blind_signing) {
return Err(AppError::BadSubintentSignState);
}

self.finalize_sign_si(comm, sign_mode, digest.as_bytes(), &digest)
}

fn finalize_sign_si(
&mut self,
comm: &mut Comm,
sign_mode: SignMode,
message: &[u8],
digest: &Digest
digest: &Digest,
) -> Result<SignOutcome, AppError> {
let mut message_hex = [0u8; SUBINTENT_MESSAGE_LENGTH * 2];
Self::convert_to_hex_text(message, &mut message_hex);
Expand Down

0 comments on commit 8987be6

Please sign in to comment.