From 73a92691ab3739333bb96533d3aba68918516157 Mon Sep 17 00:00:00 2001 From: Scott Piriou <30843220+pscott@users.noreply.github.com> Date: Fri, 6 Oct 2023 13:13:40 +0200 Subject: [PATCH] fix: use felt252 size and u8 size to compute length and offset --- starknet/src/types/strategy.cairo | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/starknet/src/types/strategy.cairo b/starknet/src/types/strategy.cairo index 45bc7ea4d..e0984608a 100644 --- a/starknet/src/types/strategy.cairo +++ b/starknet/src/types/strategy.cairo @@ -44,10 +44,10 @@ impl StoreFelt252Array of Store> { // Read the stored array's length. If the length is superior to 255, the read will fail. let len: u8 = Store::::read_at_offset(address_domain, base, offset) .expect('Storage Span too large'); - offset += 1; + offset += Store::::size(); // Sequentially read all stored elements and append them to the array. - let exit = len + offset; + let exit = (len * Store::::size()) + offset; loop { if offset >= exit { break; @@ -68,7 +68,7 @@ impl StoreFelt252Array of Store> { // // Store the length of the array in the first storage slot. let len: u8 = value.len().try_into().expect('Storage - Span too large'); Store::::write_at_offset(address_domain, base, offset, len); - offset += 1; + offset += Store::::size(); // Store the array elements sequentially loop {