Skip to content

Commit

Permalink
fix: use felt252 size and u8 size to compute length and offset
Browse files Browse the repository at this point in the history
  • Loading branch information
pscott committed Oct 6, 2023
1 parent c36adc3 commit 73a9269
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions starknet/src/types/strategy.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,10 @@ impl StoreFelt252Array of Store<Array<felt252>> {
// Read the stored array's length. If the length is superior to 255, the read will fail.
let len: u8 = Store::<u8>::read_at_offset(address_domain, base, offset)
.expect('Storage Span too large');
offset += 1;
offset += Store::<u8>::size();

// Sequentially read all stored elements and append them to the array.
let exit = len + offset;
let exit = (len * Store::<felt252>::size()) + offset;
loop {
if offset >= exit {
break;
Expand All @@ -68,7 +68,7 @@ impl StoreFelt252Array of Store<Array<felt252>> {
// // Store the length of the array in the first storage slot.
let len: u8 = value.len().try_into().expect('Storage - Span too large');
Store::<u8>::write_at_offset(address_domain, base, offset, len);
offset += 1;
offset += Store::<u8>::size();

// Store the array elements sequentially
loop {
Expand Down

0 comments on commit 73a9269

Please sign in to comment.