Skip to content

Commit

Permalink
added extract element rlp util
Browse files Browse the repository at this point in the history
  • Loading branch information
ametel01 committed May 12, 2024
1 parent 6b36e4e commit 16e900f
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/library/rlp_utils.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,18 @@ pub fn to_rlp_array(rlp: Words64Sequence) -> Array<RLPItem> {
rlp_array
}

pub fn extract_element(rlp: Words64Sequence, position: usize) -> Words64Sequence {
let element = get_element(rlp, position);
let position = element.position;
let length = element.length;

if length == 0 {
return Words64Sequence { values: array![].span(), len_bytes: 0 };
}

extract_data(rlp, position, length)
}

fn get_element(rlp: Words64Sequence, position: usize) -> RLPItem {
let first_byte = *extract_data(rlp, position, 1).values.at(0);

Expand Down

0 comments on commit 16e900f

Please sign in to comment.