Skip to content

Commit 162bed1

Browse files
feat: bump to scarb 2.9.2 (#342)
bump `scarb` to 2.9.2 add missing `data_structures` package dependency to encoding package update `bigdecimal` to 0.4.7 in macros package update `cairo-lang-macro` to 0.1.1 in `macros` package cargo.toml update `cairo-lang-parser` 2.9.2 in `macros` package cargo.toml update `cairo-lang-syntax` 2.9.2 in `macros` package cargo.toml ## Pull Request type <!-- Please try to limit your pull request to one type; submit multiple pull requests if needed. --> Please check the type of change your PR introduces: - [ ] Bugfix - [ ] Feature - [ ] Code style update (formatting, renaming) - [ ] Refactoring (no functional changes, no API changes) - [ ] Build-related changes - [ ] Documentation content changes - [x] Other (please describe): update version ## What is the current behavior? <!-- Please describe the current behavior that you are modifying, or link to a relevant issue. --> Issue Number: N/A ## What is the new behavior? <!-- Please describe the behavior or changes that are being added by this PR. --> - - - ## Does this introduce a breaking change? - [ ] Yes - [x] No <!-- If this does introduce a breaking change, please describe the impact and migration path for existing applications below. --> ## Other information <!-- Any other information that is important to this PR, such as screenshots of how the component looks before and after the change. --> --------- Co-authored-by: LucasLvy <lucaslevy10@gmail.com>
1 parent 6a989d6 commit 162bed1

File tree

89 files changed

+1091
-1258
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

89 files changed

+1091
-1258
lines changed

.tool-versions

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
scarb 2.8.2
1+
scarb 2.9.2

Scarb.lock

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ name = "alexandria_encoding"
2828
version = "0.1.0"
2929
dependencies = [
3030
"alexandria_bytes",
31+
"alexandria_data_structures",
3132
"alexandria_math",
3233
"alexandria_numeric",
3334
]

Scarb.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@ name = "alexandria"
1818
version = "0.1.0"
1919
description = "Community maintained Cairo and Starknet libraries"
2020
homepage = "https://github.com/keep-starknet-strange/alexandria/"
21-
cairo-version = "2.8.2"
21+
cairo-version = "2.9.2"
2222

2323
[workspace.dependencies]
24-
starknet = "2.8.2"
25-
cairo_test = "2.8.2"
24+
starknet = "2.9.2"
25+
cairo_test = "2.9.2"
2626

2727
[workspace.tool.fmt]
2828
sort-module-level-items = true

packages/ascii/src/integer.cairo

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ impl ToAsciiArrayTraitImpl<
3939
let mut num = self;
4040
while num.is_non_zero() {
4141
let (quotient, remainder) = DivRem::div_rem(
42-
num, TryInto::<felt252, T>::try_into(10).unwrap().try_into().expect('Division by 0')
42+
num,
43+
TryInto::<felt252, T>::try_into(10).unwrap().try_into().expect('Division by 0'),
4344
);
4445
new_arr.append(remainder.into() + 48);
4546
num = quotient;
@@ -153,7 +154,7 @@ impl U256ToAsciiArrayTraitImpl of ToAsciiArrayTrait<u256> {
153154
let mut num = self;
154155
while num != 0 {
155156
let (quotient, remainder) = DivRem::div_rem(
156-
num, 10_u256.try_into().expect('Division by 0')
157+
num, 10_u256.try_into().expect('Division by 0'),
157158
);
158159
new_arr.append(remainder.try_into().expect('number overflow felt252') + 48);
159160
num = quotient;

packages/ascii/src/lib.cairo

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ pub mod integer;
22

33
#[cfg(test)]
44
mod tests;
5-
use integer::{ToAsciiTrait, ToAsciiArrayTrait};
5+
use integer::{ToAsciiArrayTrait, ToAsciiTrait};

packages/bytes/src/bytes.cairo

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use alexandria_bytes::utils::{
2-
u128_join, read_sub_u128, u128_split, u128_array_slice, keccak_u128s_be, u32s_to_u256
2+
keccak_u128s_be, read_sub_u128, u128_array_slice, u128_join, u128_split, u32s_to_u256,
33
};
44
use alexandria_math::{U128BitShift, U256BitShift};
55
use core::byte_array::ByteArrayTrait;
@@ -34,7 +34,7 @@ pub const BYTES_PER_ELEMENT: usize = 16;
3434
#[derive(Drop, Clone, PartialEq, Serde)]
3535
pub struct Bytes {
3636
size: usize,
37-
data: Array<u128>
37+
data: Array<u128>,
3838
}
3939

4040
pub impl BytesIndex of IndexView<Bytes, usize> {
@@ -64,7 +64,7 @@ pub trait BytesTrait {
6464
fn read_u128_packed(self: @Bytes, offset: usize, size: usize) -> (usize, u128);
6565
/// Read value with element_size bytes from Bytes, and packed into u128 array
6666
fn read_u128_array_packed(
67-
self: @Bytes, offset: usize, array_length: usize, element_size: usize
67+
self: @Bytes, offset: usize, array_length: usize, element_size: usize,
6868
) -> (usize, Array<u128>);
6969
/// Read value with size bytes from Bytes, and packed into felt252
7070
fn read_felt252_packed(self: @Bytes, offset: usize, size: usize) -> (usize, felt252);
@@ -120,14 +120,14 @@ pub trait BytesTrait {
120120
#[deprecated(
121121
feature: "deprecated-keccak",
122122
note: "Use `core::keccak::compute_keccak_byte_array`.",
123-
since: "2.7.0"
123+
since: "2.7.0",
124124
)]
125125
fn keccak(self: @Bytes) -> u256;
126126
/// sha256 hash
127127
#[deprecated(
128128
feature: "deprecated-sha256",
129129
note: "Use `core::sha256::compute_sha256_byte_array`.",
130-
since: "2.7.0"
130+
since: "2.7.0",
131131
)]
132132
fn sha256(self: @Bytes) -> u256;
133133
}
@@ -146,7 +146,7 @@ impl BytesImpl of BytesTrait {
146146
fn zero(size: usize) -> Bytes {
147147
let mut data = array![];
148148
let (data_index, mut data_len) = DivRem::div_rem(
149-
size, BYTES_PER_ELEMENT.try_into().expect('Division by 0')
149+
size, BYTES_PER_ELEMENT.try_into().expect('Division by 0'),
150150
);
151151

152152
if data_index != 0 {
@@ -228,18 +228,18 @@ impl BytesImpl of BytesTrait {
228228
*self.data[element_index],
229229
BYTES_PER_ELEMENT,
230230
element_offset,
231-
BYTES_PER_ELEMENT - element_offset
231+
BYTES_PER_ELEMENT - element_offset,
232232
);
233233
let right = read_sub_u128(
234-
*self.data[element_index + 1], BYTES_PER_ELEMENT, 0, end_element_offset
234+
*self.data[element_index + 1], BYTES_PER_ELEMENT, 0, end_element_offset,
235235
);
236236
u128_join(left, right, end_element_offset)
237237
};
238238
(offset + size, value)
239239
}
240240

241241
fn read_u128_array_packed(
242-
self: @Bytes, offset: usize, array_length: usize, element_size: usize
242+
self: @Bytes, offset: usize, array_length: usize, element_size: usize,
243243
) -> (usize, Array<u128>) {
244244
assert(offset + array_length * element_size <= self.size(), 'out of bound');
245245
let mut array = array![];
@@ -431,17 +431,17 @@ impl BytesImpl of BytesTrait {
431431
if size + last_element_size > BYTES_PER_ELEMENT {
432432
let (left, right) = u128_split(value, size, BYTES_PER_ELEMENT - last_element_size);
433433
let value_full = u128_join(
434-
last_element_value, left, BYTES_PER_ELEMENT - last_element_size
434+
last_element_value, left, BYTES_PER_ELEMENT - last_element_size,
435435
);
436436
let value_padded = u128_join(
437-
right, 0, 2 * BYTES_PER_ELEMENT - size - last_element_size
437+
right, 0, 2 * BYTES_PER_ELEMENT - size - last_element_size,
438438
);
439439
data.append(value_full);
440440
data.append(value_padded);
441441
} else {
442442
let value = u128_join(last_element_value, value, size);
443443
let value_padded = u128_join(
444-
value, 0, BYTES_PER_ELEMENT - size - last_element_size
444+
value, 0, BYTES_PER_ELEMENT - size - last_element_size,
445445
);
446446
data.append(value_padded);
447447
}
@@ -543,7 +543,7 @@ impl BytesImpl of BytesTrait {
543543
let mut hash_data = u128_array_slice(self.data, 0, last_data_index);
544544
// To compute hash, we should remove 0 padded
545545
let (last_element_value, _) = u128_split(
546-
*self.data[last_data_index], BYTES_PER_ELEMENT, last_element_size
546+
*self.data[last_data_index], BYTES_PER_ELEMENT, last_element_size,
547547
);
548548
hash_data.append(last_element_value);
549549
return keccak_u128s_be(hash_data.span(), self.size());

packages/bytes/src/lib.cairo

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@ pub mod storage;
55
mod tests;
66
pub mod utils;
77

8-
pub use bytes::{Bytes, BytesTrait, BytesIndex};
8+
pub use bytes::{Bytes, BytesIndex, BytesTrait};
99
pub use storage::BytesStore;

packages/bytes/src/storage.cairo

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
use alexandria_bytes::bytes::{Bytes, BytesTrait, BYTES_PER_ELEMENT};
1+
use alexandria_bytes::bytes::{BYTES_PER_ELEMENT, Bytes, BytesTrait};
22
use core::num::traits::CheckedAdd;
33
use starknet::SyscallResult;
44
use starknet::storage_access::{
5-
Store, StorageAddress, StorageBaseAddress, storage_address_from_base,
6-
storage_base_address_from_felt252, storage_address_from_base_and_offset,
5+
StorageAddress, StorageBaseAddress, Store, storage_address_from_base,
6+
storage_address_from_base_and_offset, storage_base_address_from_felt252,
77
};
88

99
/// Store for a `Bytes` object.
@@ -27,13 +27,13 @@ pub impl BytesStore of Store<Bytes> {
2727
}
2828
#[inline(always)]
2929
fn read_at_offset(
30-
address_domain: u32, base: StorageBaseAddress, offset: u8
30+
address_domain: u32, base: StorageBaseAddress, offset: u8,
3131
) -> SyscallResult<Bytes> {
3232
inner_read_bytes(address_domain, storage_address_from_base_and_offset(base, offset))
3333
}
3434
#[inline(always)]
3535
fn write_at_offset(
36-
address_domain: u32, base: StorageBaseAddress, offset: u8, value: Bytes
36+
address_domain: u32, base: StorageBaseAddress, offset: u8, value: Bytes,
3737
) -> SyscallResult<()> {
3838
inner_write_bytes(address_domain, storage_address_from_base_and_offset(base, offset), value)
3939
}
@@ -64,7 +64,7 @@ fn inner_read_bytes(address_domain: u32, address: StorageAddress) -> SyscallResu
6464
Option::None => { return SyscallResult::Err(array!['Invalid Bytes size']); },
6565
};
6666
let (mut remaining_full_words, last_word_len) = DivRem::div_rem(
67-
size, BYTES_PER_ELEMENT.try_into().unwrap()
67+
size, BYTES_PER_ELEMENT.try_into().unwrap(),
6868
);
6969
let mut chunk = 0;
7070
let mut chunk_base = inner_bytes_pointer(address, chunk);
@@ -76,7 +76,7 @@ fn inner_read_bytes(address_domain: u32, address: StorageAddress) -> SyscallResu
7676
}
7777
let value =
7878
match starknet::syscalls::storage_read_syscall(
79-
address_domain, storage_address_from_base_and_offset(chunk_base, index_in_chunk)
79+
address_domain, storage_address_from_base_and_offset(chunk_base, index_in_chunk),
8080
) {
8181
Result::Ok(value) => value,
8282
Result::Err(err) => { break Result::Err(err); },
@@ -99,7 +99,7 @@ fn inner_read_bytes(address_domain: u32, address: StorageAddress) -> SyscallResu
9999
}?;
100100
if last_word_len != 0 {
101101
let last_word = starknet::syscalls::storage_read_syscall(
102-
address_domain, storage_address_from_base_and_offset(chunk_base, index_in_chunk)
102+
address_domain, storage_address_from_base_and_offset(chunk_base, index_in_chunk),
103103
)?;
104104
data.append(last_word.try_into().expect('Invalid last word'));
105105
}
@@ -110,7 +110,7 @@ fn inner_read_bytes(address_domain: u32, address: StorageAddress) -> SyscallResu
110110
/// The length of the bytes is written to `address` at domain `address_domain`.
111111
/// For more info read the documentation of `BytesStore`.
112112
fn inner_write_bytes(
113-
address_domain: u32, address: StorageAddress, value: Bytes
113+
address_domain: u32, address: StorageAddress, value: Bytes,
114114
) -> SyscallResult<()> {
115115
let size = value.size();
116116
starknet::syscalls::storage_write_syscall(address_domain, address, size.into())?;
@@ -126,7 +126,7 @@ fn inner_write_bytes(
126126
match starknet::syscalls::storage_write_syscall(
127127
address_domain,
128128
storage_address_from_base_and_offset(chunk_base, index_in_chunk),
129-
(*curr_value).into()
129+
(*curr_value).into(),
130130
) {
131131
Result::Ok(_) => {},
132132
Result::Err(err) => { break Result::Err(err); },

0 commit comments

Comments
 (0)