From 99518956aeeec7b298ab75d5c338c0fcbb3040a0 Mon Sep 17 00:00:00 2001 From: Gil Ben-Shachar Date: Tue, 10 Dec 2024 11:14:25 +0200 Subject: [PATCH] Make the formatter sort imports by default. commit-id:2e64ce0b --- corelib/src/array.cairo | 11 +- corelib/src/byte_array.cairo | 2 +- corelib/src/bytes_31.cairo | 4 +- corelib/src/circuit.cairo | 11 +- corelib/src/debug.cairo | 2 +- corelib/src/dict.cairo | 6 +- corelib/src/ec.cairo | 2 +- corelib/src/ecdsa.cairo | 5 +- corelib/src/integer.cairo | 13 +- corelib/src/internal/bounded_int.cairo | 20 +- corelib/src/iter.cairo | 2 +- corelib/src/keccak.cairo | 4 +- corelib/src/lib.cairo | 70 +++---- corelib/src/math.cairo | 8 +- corelib/src/nullable.cairo | 3 +- corelib/src/num/traits.cairo | 13 +- corelib/src/num/traits/ops.cairo | 6 +- corelib/src/num/traits/ops/widesquare.cairo | 4 +- corelib/src/ops.cairo | 7 +- corelib/src/ops/arith.cairo | 3 +- corelib/src/ops/index.cairo | 4 +- corelib/src/ops/range.cairo | 6 +- corelib/src/poseidon.cairo | 5 +- corelib/src/prelude/v2023_01.cairo | 173 +++++++++++------- corelib/src/prelude/v2023_10.cairo | 56 +++--- corelib/src/prelude/v2024_07.cairo | 13 +- corelib/src/result.cairo | 4 +- corelib/src/serde.cairo | 2 +- corelib/src/starknet.cairo | 33 ++-- corelib/src/starknet/class_hash.cairo | 3 +- corelib/src/starknet/contract_address.cairo | 7 +- corelib/src/starknet/eth_address.cairo | 5 +- corelib/src/starknet/eth_signature.cairo | 13 +- corelib/src/starknet/info.cairo | 4 +- corelib/src/starknet/secp256_trait.cairo | 10 +- corelib/src/starknet/secp256k1.cairo | 12 +- corelib/src/starknet/secp256r1.cairo | 9 +- corelib/src/starknet/storage.cairo | 14 +- corelib/src/starknet/storage/map.cairo | 24 ++- .../src/starknet/storage/storage_base.cairo | 5 +- .../src/starknet/storage/storage_node.cairo | 3 +- .../src/starknet/storage/sub_pointers.cairo | 5 +- corelib/src/starknet/storage/vec.cairo | 13 +- corelib/src/starknet/storage_access.cairo | 22 ++- corelib/src/starknet/syscalls.cairo | 4 +- corelib/src/starknet/testing.cairo | 6 +- corelib/src/test.cairo | 2 +- corelib/src/test/array_test.cairo | 2 +- corelib/src/test/bytes31_test.cairo | 2 +- corelib/src/test/circuit_test.cairo | 7 +- corelib/src/test/dict_test.cairo | 4 +- corelib/src/test/hash_test.cairo | 4 +- corelib/src/test/integer_test.cairo | 14 +- .../const_folding_test.cairo | 2 +- .../language_features/glob_use_test.cairo | 1 - .../test/language_features/panics_test.cairo | 3 +- corelib/src/test/math_test.cairo | 2 +- corelib/src/test/nullable_test.cairo | 2 +- corelib/src/test/num_test.cairo | 7 +- corelib/src/test/secp256k1_test.cairo | 12 +- corelib/src/test/secp256r1_test.cairo | 6 +- corelib/src/test/to_byte_array_test.cairo | 2 +- crates/cairo-lang-formatter/src/lib.rs | 4 +- .../src/parser_test_data/partial_trees/use | 10 +- .../src/profiling_test_data/circuit | 6 +- .../src/profiling_test_data/major_test_cases | 5 +- .../src/diagnostic_test_data/tests | 29 +-- .../src/expr/semantic_test_data/use | 23 +-- .../src/items/tests/early_conform | 2 +- .../abi_dispatchers_tests.cairo | 6 +- .../cairo_level_tests/collections_test.cairo | 2 +- .../component_usage_test.cairo | 2 +- .../cairo_level_tests/components.cairo | 4 +- .../cairo_level_tests/components/erc20.cairo | 6 +- .../components/erc20_mini.cairo | 8 +- .../components/mintable.cairo | 11 +- .../components/upgradable.cairo | 5 +- .../cairo_level_tests/contract_tests.cairo | 5 +- .../cairo_level_tests/contracts.cairo | 22 +-- .../cairo_level_tests/contracts/account.cairo | 5 +- .../contracts/circuit_contract.cairo | 4 +- .../cairo_level_tests/contracts/erc20.cairo | 8 +- .../contracts/libfuncs_coverage.cairo | 23 +-- .../contracts/mintable.cairo | 7 +- .../contracts/multi_component.cairo | 8 +- .../contracts/new_syntax_test_contract.cairo | 4 +- .../contracts/ownable_erc20.cairo | 3 +- .../contracts/storage_accesses.cairo | 13 +- .../contracts/test_contract.cairo | 8 +- .../contracts/token_bridge.cairo | 9 +- .../contracts/upgradable_counter.cairo | 7 +- .../contracts/with_erc20_mini.cairo | 2 +- .../contracts/with_ownable.cairo | 2 +- .../cairo_level_tests/deployment.cairo | 3 +- .../cairo_level_tests/erc20_test.cairo | 6 +- .../cairo_level_tests/events.cairo | 6 +- .../cairo_level_tests/flat_storage_test.cairo | 2 +- .../cairo_level_tests/interoperability.cairo | 3 +- .../cairo_level_tests/l2_to_l1_messages.cairo | 6 +- .../cairo_level_tests/lib.cairo | 24 +-- .../multi_component_test.cairo | 6 +- .../renamed_storage_test.cairo | 2 +- .../replace_class_test.cairo | 8 +- .../cairo_level_tests/storage_access.cairo | 19 +- .../plugin_test_data/contracts/contract | 14 +- .../plugin_test_data/contracts/diagnostics | 14 +- .../plugin_test_data/contracts/mintable | 14 +- .../contracts/multi_component | 16 +- .../contracts/new_storage_interface | 36 ++-- .../plugin_test_data/contracts/ownable_erc20 | 6 +- .../contracts/storage_accesses | 23 ++- .../contracts/upgradable_counter | 14 +- .../contracts/with_component_diagnostics | 4 +- .../contracts/with_erc20_mini | 4 +- .../plugin_test_data/contracts/with_ownable | 4 +- .../src/test_data/storage_path_check | 19 +- .../cairo-lang-starknet/test_data/lib.cairo | 4 +- .../test_data/mintable.cairo | 2 +- .../test_data/lib.cairo | 5 +- examples/lib.cairo | 8 +- tests/bug_samples/inconsistent_gas.cairo | 15 +- tests/bug_samples/indirect_impl_alias.cairo | 1 - tests/bug_samples/issue2171.cairo | 2 +- tests/bug_samples/issue2932.cairo | 2 +- tests/bug_samples/issue3153.cairo | 8 +- tests/bug_samples/issue3345.cairo | 4 +- tests/bug_samples/issue4036.cairo | 4 +- 127 files changed, 643 insertions(+), 641 deletions(-) diff --git a/corelib/src/array.cairo b/corelib/src/array.cairo index 77e81180c6f..3f6fe2b17c8 100644 --- a/corelib/src/array.cairo +++ b/corelib/src/array.cairo @@ -61,18 +61,17 @@ //! //! [`append`]: ArrayTrait::append -#[feature("deprecated-index-traits")] -use crate::traits::IndexView; - +use crate::RangeCheck; use crate::box::BoxTrait; #[allow(unused_imports)] use crate::gas::withdraw_gas; +use crate::iter::Iterator; +use crate::metaprogramming::TypeEqual; #[allow(unused_imports)] use crate::option::OptionTrait; use crate::serde::Serde; -use crate::metaprogramming::TypeEqual; -use crate::iter::Iterator; -use crate::RangeCheck; +#[feature("deprecated-index-traits")] +use crate::traits::IndexView; /// A collection of elements of the same type continuous in memory. #[derive(Drop)] diff --git a/corelib/src/byte_array.cairo b/corelib/src/byte_array.cairo index ac371e5d1c3..d9a8e84da52 100644 --- a/corelib/src/byte_array.cairo +++ b/corelib/src/byte_array.cairo @@ -51,7 +51,7 @@ use crate::bytes_31::{ use crate::clone::Clone; use crate::cmp::min; #[allow(unused_imports)] -use crate::integer::{u128_safe_divmod, U32TryIntoNonZero}; +use crate::integer::{U32TryIntoNonZero, u128_safe_divmod}; use crate::option::OptionTrait; #[allow(unused_imports)] use crate::serde::Serde; diff --git a/corelib/src/bytes_31.cairo b/corelib/src/bytes_31.cairo index 5f66c12a0fa..988c80e5c3e 100644 --- a/corelib/src/bytes_31.cairo +++ b/corelib/src/bytes_31.cairo @@ -14,11 +14,11 @@ //! assert!(value[0] == 0xbb); //! ``` +use crate::RangeCheck; #[allow(unused_imports)] use crate::integer::{u128_safe_divmod, u128_to_felt252}; #[allow(unused_imports)] use crate::option::OptionTrait; -use crate::RangeCheck; use crate::traits::{Into, TryInto}; pub(crate) const BYTES_IN_BYTES31: usize = 31; @@ -232,7 +232,7 @@ impl Bytes31PartialEq of PartialEq { } mod helpers { - use core::internal::bounded_int::{DivRemHelper, BoundedInt, div_rem}; + use core::internal::bounded_int::{BoundedInt, DivRemHelper, div_rem}; impl DivRemU128By256 of DivRemHelper> { type DivT = BoundedInt<0, 0xffffffffffffffffffffffffffffff>; diff --git a/corelib/src/circuit.cairo b/corelib/src/circuit.cairo index efe4825d716..50b22410814 100644 --- a/corelib/src/circuit.cairo +++ b/corelib/src/circuit.cairo @@ -424,12 +424,11 @@ extern fn get_circuit_output( /// Helper module to convert into `u384`. mod conversions { - use crate::internal::{ - bounded_int, bounded_int::{BoundedInt, AddHelper, MulHelper, DivRemHelper}, - }; - use crate::integer::{upcast, downcast}; - - use super::{u384, u96}; + use crate::integer::{downcast, upcast}; + use crate::internal::bounded_int; + use crate::internal::bounded_int::{AddHelper, BoundedInt, DivRemHelper, MulHelper}; + use super::u384; + use super::u96; type ConstValue = BoundedInt; const POW128: felt252 = 0x100000000000000000000000000000000; diff --git a/corelib/src/debug.cairo b/corelib/src/debug.cairo index 4740aa85551..05bb8ac2a1e 100644 --- a/corelib/src/debug.cairo +++ b/corelib/src/debug.cairo @@ -5,9 +5,9 @@ #[allow(unused_imports)] use crate::array::ArrayTrait; -use crate::traits::Into; #[allow(unused_imports)] use crate::option::Option; +use crate::traits::Into; pub(crate) extern fn print(message: Array) nopanic; diff --git a/corelib/src/dict.cairo b/corelib/src/dict.cairo index 4d6d2307d1a..d2f0b6723ef 100644 --- a/corelib/src/dict.cairo +++ b/corelib/src/dict.cairo @@ -48,7 +48,7 @@ //! ``` #[feature("deprecated-index-traits")] -use crate::traits::{Index, Default, Felt252DictValue}; +use crate::traits::{Default, Felt252DictValue, Index}; /// A dictionary that maps `felt252` keys to a value of any type. pub extern type Felt252Dict; @@ -62,8 +62,8 @@ pub extern type SquashedFelt252Dict; pub extern type Felt252DictEntry; impl SquashedFelt252DictDrop> of Drop>; - -use crate::{RangeCheck, SegmentArena}; +use crate::RangeCheck; +use crate::SegmentArena; use crate::gas::GasBuiltin; pub(crate) extern fn felt252_dict_new() -> Felt252Dict implicits(SegmentArena) nopanic; diff --git a/corelib/src/ec.cairo b/corelib/src/ec.cairo index 96e7dbe2f62..96721580fbe 100644 --- a/corelib/src/ec.cairo +++ b/corelib/src/ec.cairo @@ -51,12 +51,12 @@ //! let _result = state.finalize(); //! ``` +use crate::RangeCheck; #[allow(unused_imports)] use crate::array::ArrayTrait; #[allow(unused_imports)] use crate::traits::{Into, TryInto}; use crate::zeroable::IsZeroResult; -use crate::RangeCheck; pub mod stark_curve { /// The STARK Curve is defined by the equation y² ≡ x³ + α·x + β (mod p). diff --git a/corelib/src/ecdsa.cairo b/corelib/src/ecdsa.cairo index 1f0df12624a..5d46344a5a2 100644 --- a/corelib/src/ecdsa.cairo +++ b/corelib/src/ecdsa.cairo @@ -13,10 +13,11 @@ //! * x = 0x1ef15c18599971b7beced415a40f0c7deacfd9b0d1819e03d723d8bc943cfca //! * y = 0x5668060aa49730b7be4801df46ec62de53ecd11abe43a32873000c36e8dc1f -use crate::{ec, ec::{EcPoint, EcPointTrait, EcStateTrait}}; +use crate::ec; +use crate::ec::{EcPoint, EcPointTrait, EcStateTrait}; +use crate::math; #[allow(unused_imports)] use crate::option::OptionTrait; -use crate::math; #[allow(unused_imports)] use crate::traits::{Into, TryInto}; #[allow(unused_imports)] diff --git a/corelib/src/integer.cairo b/corelib/src/integer.cairo index 3e2d8a9d104..c151ec2854e 100644 --- a/corelib/src/integer.cairo +++ b/corelib/src/integer.cairo @@ -1,13 +1,11 @@ +use crate::RangeCheck; +#[allow(unused_imports)] +use crate::array::{ArrayTrait, SpanTrait}; use crate::option::OptionTrait; use crate::result::ResultTrait; -use crate::traits::{BitAnd, BitNot, BitOr, BitXor, Into, TryInto, Default, Felt252DictValue}; +use crate::traits::{BitAnd, BitNot, BitOr, BitXor, Default, Felt252DictValue, Into, TryInto}; #[allow(unused_imports)] use crate::zeroable::{IsZeroResult, NonZeroIntoImpl, Zeroable}; -#[allow(unused_imports)] -use crate::array::ArrayTrait; -#[allow(unused_imports)] -use crate::array::SpanTrait; -use crate::RangeCheck; // TODO(spapini): Add method for const creation from Integer. pub trait NumericLiteral; @@ -2159,7 +2157,8 @@ mod signed_div_rem { use crate::internal::bounded_int::{ BoundedInt, ConstrainHelper, DivRemHelper, NegateHelper, constrain, div_rem, is_zero, }; - use super::{upcast, downcast}; + use super::downcast; + use super::upcast; impl DivRemImpl< T, diff --git a/corelib/src/internal/bounded_int.cairo b/corelib/src/internal/bounded_int.cairo index 0380f5cfee7..60f909ae654 100644 --- a/corelib/src/internal/bounded_int.cairo +++ b/corelib/src/internal/bounded_int.cairo @@ -1,5 +1,5 @@ -use crate::integer::{downcast, upcast}; use crate::RangeCheck; +use crate::integer::{downcast, upcast}; #[derive(Copy, Drop)] pub(crate) extern type BoundedInt; @@ -269,8 +269,16 @@ impl MulMinusOneNegateHelper> of NegateHelper< } } -pub use { - bounded_int_add as add, bounded_int_sub as sub, bounded_int_mul as mul, - bounded_int_div_rem as div_rem, bounded_int_constrain as constrain, - bounded_int_is_zero as is_zero, bounded_int_trim as trim, -}; +pub use bounded_int_add as add; + +pub use bounded_int_constrain as constrain; + +pub use bounded_int_div_rem as div_rem; + +pub use bounded_int_is_zero as is_zero; + +pub use bounded_int_mul as mul; + +pub use bounded_int_sub as sub; + +pub use bounded_int_trim as trim; diff --git a/corelib/src/iter.cairo b/corelib/src/iter.cairo index 18bb2e47aa9..1bd4484d82b 100644 --- a/corelib/src/iter.cairo +++ b/corelib/src/iter.cairo @@ -1,4 +1,4 @@ mod traits; +pub use traits::iterator::IntoIterator; pub use traits::iterator::Iterator; -pub use traits::iterator::IntoIterator; diff --git a/corelib/src/keccak.cairo b/corelib/src/keccak.cairo index 2f2bd42e074..85507cfad49 100644 --- a/corelib/src/keccak.cairo +++ b/corelib/src/keccak.cairo @@ -25,10 +25,10 @@ //! 0x85c9aab73219c1e95c5b5966a4ecc8db4418c3500072a830cfb5a2d13d2c2249); //! ``` -use crate::array::{Span, ArrayTrait, SpanTrait}; -use crate::traits::TryInto; +use crate::array::{ArrayTrait, Span, SpanTrait}; use crate::option::OptionTrait; use crate::starknet::SyscallResultTrait; +use crate::traits::TryInto; const KECCAK_FULL_RATE_IN_BYTES: usize = 136; const KECCAK_FULL_RATE_IN_U64S: usize = 17; diff --git a/corelib/src/lib.cairo b/corelib/src/lib.cairo index 20cd56493e7..4b9d34d5d38 100644 --- a/corelib/src/lib.cairo +++ b/corelib/src/lib.cairo @@ -1,13 +1,13 @@ pub mod traits; +use serde::Serde; #[feature("deprecated-index-traits")] #[feature("deprecated-op-assign-traits")] #[allow(unused_imports)] use traits::{ - Add, AddEq, BitAnd, BitNot, BitOr, BitXor, Copy, Div, DivEq, DivRem, Drop, Mul, MulEq, - PartialEq, PartialOrd, Rem, RemEq, Sub, SubEq, TupleSize0Copy, TupleSize0Drop, Not, Neg, Into, - TryInto, Index, IndexView, Destruct, Default, Felt252DictValue, PanicDestruct, + Add, AddEq, BitAnd, BitNot, BitOr, BitXor, Copy, Default, Destruct, Div, DivEq, DivRem, Drop, + Felt252DictValue, Index, IndexView, Into, Mul, MulEq, Neg, Not, PanicDestruct, PartialEq, + PartialOrd, Rem, RemEq, Sub, SubEq, TryInto, TupleSize0Copy, TupleSize0Drop, }; -use serde::Serde; pub type usize = u32; @@ -250,7 +250,7 @@ use array::{Span, SpanTrait}; pub mod dict; #[allow(unused_imports)] use dict::{ - Felt252Dict, SquashedFelt252Dict, felt252_dict_new, felt252_dict_squash, Felt252DictTrait, + Felt252Dict, Felt252DictTrait, SquashedFelt252Dict, felt252_dict_new, felt252_dict_squash, }; /// Result. @@ -280,17 +280,23 @@ pub mod ecdsa; pub mod integer; #[allow(unused_imports)] use integer::{ - i8, I8IntoFelt252, i16, I16IntoFelt252, i32, I32IntoFelt252, i64, I64IntoFelt252, i128, - I128IntoFelt252, NumericLiteral, u128, u128_is_zero, u8, u16, u32, u64, u256, Felt252TryIntoU8, - U8IntoFelt252, Felt252TryIntoU16, U16IntoFelt252, Felt252TryIntoU32, U32IntoFelt252, - Felt252TryIntoU64, U64IntoFelt252, Felt252TryIntoU128, U128IntoFelt252, Felt252IntoU256, - Bitwise, + Bitwise, Felt252IntoU256, Felt252TryIntoU128, Felt252TryIntoU16, Felt252TryIntoU32, + Felt252TryIntoU64, Felt252TryIntoU8, I128IntoFelt252, I16IntoFelt252, I32IntoFelt252, + I64IntoFelt252, I8IntoFelt252, NumericLiteral, U128IntoFelt252, U16IntoFelt252, U32IntoFelt252, + U64IntoFelt252, U8IntoFelt252, i128, i16, i32, i64, i8, u128, u128_is_zero, u16, u256, u32, u64, + u8, }; #[feature("corelib-internal-use")] #[deprecated(feature: "corelib-internal-use", note: "Use `core::num::traits::Sqrt` instead")] #[allow(unused_imports)] use integer::{u128_sqrt, u256_sqrt}; +/// Module for comparison operations. +pub mod cmp; + +/// Module for handling gas operations. +pub mod gas; + /// Math. #[feature("corelib-internal-use")] pub mod math; @@ -300,12 +306,6 @@ pub mod num; /// Module containing the operations that can be performed on the different types. pub mod ops; - -/// Module for comparison operations. -pub mod cmp; - -/// Module for handling gas operations. -pub mod gas; #[allow(unused_imports)] use gas::{BuiltinCosts, GasBuiltin, get_builtin_costs}; @@ -313,7 +313,7 @@ use gas::{BuiltinCosts, GasBuiltin, get_builtin_costs}; /// Panics. pub mod panics; #[allow(unused_imports)] -use panics::{panic, Panic, PanicResult}; +use panics::{Panic, PanicResult, panic}; pub enum never {} @@ -329,18 +329,18 @@ pub fn assert(cond: bool, err_code: felt252) { } } -/// Serialization and Deserialization. -pub mod serde; - /// Hash functions. pub mod hash; pub mod keccak; -pub mod sha256; - /// Pedersen pub mod pedersen; + +/// Serialization and Deserialization. +pub mod serde; + +pub mod sha256; #[allow(unused_imports)] use pedersen::Pedersen; @@ -366,14 +366,14 @@ pub mod internal; /// Zeroable. pub mod zeroable; #[allow(unused_imports)] -use zeroable::{Zeroable, NonZero}; +use zeroable::{NonZero, Zeroable}; /// bytes31. pub mod bytes_31; #[allow(unused_imports)] use bytes_31::{ - bytes31, bytes31_const, Bytes31IndexView, Bytes31IntoFelt252, Bytes31Trait, - Felt252TryIntoBytes31, + Bytes31IndexView, Bytes31IntoFelt252, Bytes31Trait, Felt252TryIntoBytes31, bytes31, + bytes31_const, }; /// BytesArray. @@ -386,14 +386,8 @@ pub mod string; #[allow(unused_imports)] use string::StringLiteral; -/// to_byte_array. -pub mod to_byte_array; - -#[cfg(test)] -mod test; - -/// Module for testing only. -pub mod testing; +/// Iterators. +pub mod iter; /// Metaprogramming. pub mod metaprogramming; @@ -402,5 +396,11 @@ pub mod metaprogramming; #[allow(unused_imports)] mod prelude; -/// Iterators. -pub mod iter; +#[cfg(test)] +mod test; + +/// Module for testing only. +pub mod testing; + +/// to_byte_array. +pub mod to_byte_array; diff --git a/corelib/src/math.cairo b/corelib/src/math.cairo index 0c0bad6b66a..5d73034f4ec 100644 --- a/corelib/src/math.cairo +++ b/corelib/src/math.cairo @@ -2,14 +2,14 @@ //! //! Provides extended GCD, modular inverse, and modular arithmetic operations. +use crate::RangeCheck; +use crate::integer::{U128MulGuarantee, u256_wide_mul, u512_safe_div_rem_by_u256}; #[allow(unused_imports)] -use crate::zeroable::{IsZeroResult, NonZeroIntoImpl, Zeroable}; +use crate::option::OptionTrait; #[allow(unused_imports)] use crate::traits::{Into, TryInto}; #[allow(unused_imports)] -use crate::option::OptionTrait; -use crate::integer::{u256_wide_mul, u512_safe_div_rem_by_u256, U128MulGuarantee}; -use crate::RangeCheck; +use crate::zeroable::{IsZeroResult, NonZeroIntoImpl, Zeroable}; // TODO(yuval): use signed integers once supported. // TODO(yuval): use a single impl of a trait with associated impls, once associated impls are diff --git a/corelib/src/nullable.cairo b/corelib/src/nullable.cairo index 74097ea5296..ed56f22507b 100644 --- a/corelib/src/nullable.cairo +++ b/corelib/src/nullable.cairo @@ -32,8 +32,7 @@ //! ``` use crate::box::BoxTrait; -use crate::traits::Default; -use crate::traits::Felt252DictValue; +use crate::traits::{Default, Felt252DictValue}; /// A type that can either be null or contain a boxed value. #[derive(Copy, Drop)] diff --git a/corelib/src/num/traits.cairo b/corelib/src/num/traits.cairo index 4e797bb423e..ed033122f18 100644 --- a/corelib/src/num/traits.cairo +++ b/corelib/src/num/traits.cairo @@ -12,11 +12,8 @@ pub use bounded::Bounded; #[feature("corelib-internal-use")] pub mod ops; -pub use ops::overflowing::{OverflowingAdd, OverflowingSub, OverflowingMul}; -pub use ops::wrapping::{WrappingAdd, WrappingSub, WrappingMul}; -pub use ops::checked::{CheckedAdd, CheckedSub, CheckedMul}; -pub use ops::pow::Pow; -pub use ops::saturating::{SaturatingAdd, SaturatingSub, SaturatingMul}; -pub use ops::widemul::WideMul; -pub use ops::widesquare::WideSquare; -pub use ops::sqrt::Sqrt; +pub use ops::checked::{CheckedAdd, CheckedMul, CheckedSub}; +pub use ops::overflowing::{OverflowingAdd, OverflowingMul, OverflowingSub}; +pub use ops::saturating::{SaturatingAdd, SaturatingMul, SaturatingSub}; +pub use ops::wrapping::{WrappingAdd, WrappingMul, WrappingSub}; +pub use ops::{pow::Pow, sqrt::Sqrt, widemul::WideMul, widesquare::WideSquare}; diff --git a/corelib/src/num/traits/ops.cairo b/corelib/src/num/traits/ops.cairo index 9c9016b0eb2..752abd2391b 100644 --- a/corelib/src/num/traits/ops.cairo +++ b/corelib/src/num/traits/ops.cairo @@ -1,8 +1,8 @@ -pub mod overflowing; -pub mod wrapping; pub mod checked; -pub mod saturating; +pub mod overflowing; pub mod pow; +pub mod saturating; pub(crate) mod sqrt; pub(crate) mod widemul; pub(crate) mod widesquare; +pub mod wrapping; diff --git a/corelib/src/num/traits/ops/widesquare.cairo b/corelib/src/num/traits/ops/widesquare.cairo index a3ec687521b..d74e7055a79 100644 --- a/corelib/src/num/traits/ops/widesquare.cairo +++ b/corelib/src/num/traits/ops/widesquare.cairo @@ -85,9 +85,9 @@ impl WideSquareU256 of WideSquare { } mod inner { - use crate::integer::{u512, u128_add_with_bounded_int_carry, upcast}; + use crate::integer::{u128_add_with_bounded_int_carry, u512, upcast}; use crate::internal::bounded_int; - use crate::num::traits::{WideSquare, WideMul, WrappingAdd}; + use crate::num::traits::{WideMul, WideSquare, WrappingAdd}; pub fn u256_wide_square(value: u256) -> u512 { let u256 { high: limb1, low: limb0 } = value.low.wide_square(); diff --git a/corelib/src/ops.cairo b/corelib/src/ops.cairo index 4efd6830abc..75b15fd8c50 100644 --- a/corelib/src/ops.cairo +++ b/corelib/src/ops.cairo @@ -2,11 +2,11 @@ pub mod index; pub use index::{Index, IndexView}; mod arith; -pub use arith::{AddAssign, SubAssign, MulAssign, DivAssign, RemAssign}; +pub use arith::{AddAssign, DivAssign, MulAssign, RemAssign, SubAssign}; mod deref; -pub use deref::{Deref, SnapshotDeref}; #[feature("deref_mut")] pub use deref::DerefMut; +pub use deref::{Deref, SnapshotDeref}; mod range; pub use range::Range; // `RangeOp` is used internally by the compiler. @@ -14,5 +14,4 @@ pub use range::Range; use range::RangeOp; mod function; -pub use function::FnOnce; -pub use function::Fn; +pub use function::{Fn, FnOnce}; diff --git a/corelib/src/ops/arith.cairo b/corelib/src/ops/arith.cairo index 69aaeb487f6..e7c4506437c 100644 --- a/corelib/src/ops/arith.cairo +++ b/corelib/src/ops/arith.cairo @@ -73,9 +73,8 @@ pub trait RemAssign { /// ``` fn rem_assign(ref self: Lhs, rhs: Rhs); } - #[feature("deprecated-op-assign-traits")] -use crate::traits::{AddEq, SubEq, MulEq, DivEq, RemEq}; +use crate::traits::{AddEq, DivEq, MulEq, RemEq, SubEq}; impl DeprecatedAddAssign> of AddAssign { fn add_assign(ref self: T, rhs: T) { diff --git a/corelib/src/ops/index.cairo b/corelib/src/ops/index.cairo index 07b377bf73a..b24c2b361d3 100644 --- a/corelib/src/ops/index.cairo +++ b/corelib/src/ops/index.cairo @@ -19,9 +19,7 @@ //! [`Felt252Dict`]: core::dict::Felt252Dict #[feature("deprecated-index-traits")] -use crate::traits::IndexView as DeprecatedIndexView; -#[feature("deprecated-index-traits")] -use crate::traits::Index as DeprecatedIndex; +use crate::traits::{Index as DeprecatedIndex, IndexView as DeprecatedIndexView}; /// A trait for indexing operations (`container[index]`) where the input type is not modified. /// diff --git a/corelib/src/ops/range.cairo b/corelib/src/ops/range.cairo index 44a8d02bdfe..a76c698769d 100644 --- a/corelib/src/ops/range.cairo +++ b/corelib/src/ops/range.cairo @@ -1,6 +1,5 @@ use core::iter::{IntoIterator, Iterator}; -use core::num::traits::One; -use core::traits::Add; +use core::{num::traits::One, traits::Add}; /// Represents the range [start, end). #[derive(Clone, Drop)] @@ -72,8 +71,7 @@ impl RangeIntoIterator< // Sierra optimization. mod internal { - use core::iter::Iterator; - use core::internal::OptionRev; + use core::{internal::OptionRev, iter::Iterator}; #[derive(Copy, Drop)] pub extern type IntRange; diff --git a/corelib/src/poseidon.cairo b/corelib/src/poseidon.cairo index 2af9f89cbc0..cddbf7113ce 100644 --- a/corelib/src/poseidon.cairo +++ b/corelib/src/poseidon.cairo @@ -23,10 +23,9 @@ //! let hash = state.finalize(); //! ``` -use crate::array::Span; -use crate::array::SpanTrait; -use crate::option::OptionTrait; +use crate::array::{Span, SpanTrait}; use crate::hash::HashStateTrait; +use crate::option::OptionTrait; pub extern type Poseidon; diff --git a/corelib/src/prelude/v2023_01.cairo b/corelib/src/prelude/v2023_01.cairo index d9bdc051d83..8595d7dd44b 100644 --- a/corelib/src/prelude/v2023_01.cairo +++ b/corelib/src/prelude/v2023_01.cairo @@ -1,46 +1,73 @@ -use crate::{ - BoolBitAnd, BoolBitOr, BoolBitXor, BoolFelt252DictValue, BoolIntoFelt252, BoolNot, - BoolPartialEq, BoolSerde, Felt252Add, Felt252AddEq, Felt252Default, Felt252Felt252DictValue, - Felt252Mul, Felt252MulEq, Felt252Neg, Felt252PartialEq, Felt252Serde, Felt252Sub, Felt252SubEq, - Felt252TryIntoNonZero, RangeCheck, SegmentArena, assert, bool, bool_and_impl, bool_not_impl, - bool_or_impl, bool_to_felt252, bool_xor_impl, drop, dup, felt252, felt252_add, felt252_const, - felt252_div, felt252_is_zero, felt252_mul, felt252_sub, never, panic_with_felt252, usize, +use crate::BoolBitAnd; +use crate::BoolBitOr; +use crate::BoolBitXor; +use crate::BoolFelt252DictValue; +use crate::BoolIntoFelt252; +use crate::BoolNot; +use crate::BoolPartialEq; +use crate::BoolSerde; +use crate::Felt252Add; +use crate::Felt252AddEq; +use crate::Felt252Default; +use crate::Felt252Felt252DictValue; +use crate::Felt252Mul; +use crate::Felt252MulEq; +use crate::Felt252Neg; +use crate::Felt252PartialEq; +use crate::Felt252Serde; +use crate::Felt252Sub; +use crate::Felt252SubEq; +use crate::Felt252TryIntoNonZero; +use crate::RangeCheck; +use crate::SegmentArena; +use crate::array; +use crate::array::{Array, ArrayTrait, Span, SpanTrait, ToSpanTrait}; +use crate::assert; +use crate::bool; +use crate::bool_and_impl; +use crate::bool_not_impl; +use crate::bool_or_impl; +use crate::bool_to_felt252; +use crate::bool_xor_impl; +use crate::box; +use crate::box::{Box, BoxTrait}; +use crate::byte_array; +use crate::byte_array::{ByteArray, ByteArrayIndexView, ByteArrayStringLiteral, ByteArrayTrait}; +use crate::bytes_31; +use crate::bytes_31::{ + Bytes31IndexView, Bytes31IntoFelt252, Bytes31Trait, Felt252TryIntoBytes31, bytes31, + bytes31_const, }; - -use crate::{array, array::{Array, ArrayTrait, Span, SpanTrait, ToSpanTrait}}; -use crate::{box, box::{Box, BoxTrait}}; -use crate::{ - bytes_31, - bytes_31::{ - Bytes31IndexView, Bytes31IntoFelt252, Bytes31Trait, Felt252TryIntoBytes31, bytes31, - bytes31_const, - }, -}; -use crate::{ - byte_array, byte_array::{ByteArray, ByteArrayIndexView, ByteArrayStringLiteral, ByteArrayTrait}, -}; -use crate::{clone, clone::Clone}; +use crate::clone; +use crate::clone::Clone; use crate::cmp; use crate::debug; -use crate::{ - dict, - dict::{ - Felt252Dict, Felt252DictTrait, SquashedFelt252Dict, felt252_dict_new, felt252_dict_squash, - }, +use crate::dict; +use crate::dict::{ + Felt252Dict, Felt252DictTrait, SquashedFelt252Dict, felt252_dict_new, felt252_dict_squash, }; -use crate::{ec, ec::{EcOp, EcPoint, EcState}}; +use crate::drop; +use crate::dup; +use crate::ec; +use crate::ec::{EcOp, EcPoint, EcState}; use crate::ecdsa; -use crate::{gas, gas::{BuiltinCosts, GasBuiltin, get_builtin_costs}}; +use crate::felt252; +use crate::felt252_add; +use crate::felt252_const; +use crate::felt252_div; +use crate::felt252_is_zero; +use crate::felt252_mul; +use crate::felt252_sub; +use crate::gas; +use crate::gas::{BuiltinCosts, GasBuiltin, get_builtin_costs}; use crate::hash; -use crate::{ - integer, - integer::{ - Bitwise, Felt252IntoU256, Felt252TryIntoU128, Felt252TryIntoU16, Felt252TryIntoU32, - Felt252TryIntoU64, Felt252TryIntoU8, I128IntoFelt252, I16IntoFelt252, I32IntoFelt252, - I64IntoFelt252, I8IntoFelt252, NumericLiteral, U128IntoFelt252, U16IntoFelt252, - U32IntoFelt252, U64IntoFelt252, U8IntoFelt252, i128, i16, i32, i64, i8, u128, u128_is_zero, - u16, u256, u32, u64, u8, - }, +use crate::integer; +use crate::integer::{ + Bitwise, Felt252IntoU256, Felt252TryIntoU128, Felt252TryIntoU16, Felt252TryIntoU32, + Felt252TryIntoU64, Felt252TryIntoU8, I128IntoFelt252, I16IntoFelt252, I32IntoFelt252, + I64IntoFelt252, I8IntoFelt252, NumericLiteral, U128IntoFelt252, U16IntoFelt252, U32IntoFelt252, + U64IntoFelt252, U8IntoFelt252, i128, i16, i32, i64, i8, u128, u128_is_zero, u16, u256, u32, u64, + u8, }; #[feature("corelib-internal-use")] #[deprecated(feature: "corelib-internal-use", note: "Use `core::num::traits::Sqrt` instead")] @@ -48,61 +75,67 @@ use crate::integer::{u128_sqrt, u256_sqrt}; use crate::internal; use crate::keccak; use crate::math; -use crate::{nullable, nullable::{Nullable, NullableTrait, match_nullable, null, nullable_from_box}}; -use crate::{option, option::{Option, OptionTrait}}; -use crate::{panics, panics::{Panic, PanicResult, panic}}; -use crate::{pedersen, pedersen::Pedersen}; -use crate::{poseidon, poseidon::Poseidon}; -use crate::{result, result::{Result, ResultTrait}}; -use crate::{serde, serde::Serde}; -use crate::{starknet, starknet::System}; -use crate::{string, string::StringLiteral}; +use crate::never; +use crate::nullable; +use crate::nullable::{Nullable, NullableTrait, match_nullable, null, nullable_from_box}; +pub use crate::ops::Deref; +use crate::option; +use crate::option::{Option, OptionTrait}; +use crate::panic_with_felt252; +use crate::panics; +use crate::panics::{Panic, PanicResult, panic}; +use crate::pedersen; +use crate::pedersen::Pedersen; +use crate::poseidon; +use crate::poseidon::Poseidon; +use crate::result; +use crate::result::{Result, ResultTrait}; +use crate::serde; +use crate::serde::Serde; +use crate::starknet; +use crate::starknet::System; +use crate::string; +use crate::string::StringLiteral; +#[cfg(test)] +use crate::test; use crate::testing; use crate::to_byte_array; -use crate::{ - traits, - traits::{ - Add, BitAnd, BitNot, BitOr, BitXor, Copy, Default, Destruct, Div, DivRem, Drop, - Felt252DictValue, Into, Mul, Neg, Not, PanicDestruct, PartialEq, PartialOrd, Rem, Sub, - TryInto, TupleSize0Copy, TupleSize0Drop, - }, -}; - +use crate::traits; #[deprecated( feature: "deprecated-op-assign-traits", note: "Use `core::ops::AddAssign`.", since: "2.7.0", )] #[feature("deprecated-op-assign-traits")] pub use crate::traits::AddEq; #[deprecated( - feature: "deprecated-op-assign-traits", note: "Use `core::ops::SubAssign`.", since: "2.7.0", + feature: "deprecated-op-assign-traits", note: "Use `core::ops::DivAssign`.", since: "2.7.0", )] #[feature("deprecated-op-assign-traits")] -pub use crate::traits::SubEq; +pub use crate::traits::DivEq; #[deprecated( feature: "deprecated-op-assign-traits", note: "Use `core::ops::MulAssign`.", since: "2.7.0", )] #[feature("deprecated-op-assign-traits")] pub use crate::traits::MulEq; #[deprecated( - feature: "deprecated-op-assign-traits", note: "Use `core::ops::DivAssign`.", since: "2.7.0", + feature: "deprecated-op-assign-traits", note: "Use `core::ops::RemAssign`.", since: "2.7.0", )] #[feature("deprecated-op-assign-traits")] -pub use crate::traits::DivEq; +pub use crate::traits::RemEq; #[deprecated( - feature: "deprecated-op-assign-traits", note: "Use `core::ops::RemAssign`.", since: "2.7.0", + feature: "deprecated-op-assign-traits", note: "Use `core::ops::SubAssign`.", since: "2.7.0", )] #[feature("deprecated-op-assign-traits")] -pub use crate::traits::RemEq; - -#[feature("deprecated-index-traits")] -use crate::traits::Index; +pub use crate::traits::SubEq; +use crate::traits::{ + Add, BitAnd, BitNot, BitOr, BitXor, Copy, Default, Destruct, Div, DivRem, Drop, + Felt252DictValue, Into, Mul, Neg, Not, PanicDestruct, PartialEq, PartialOrd, Rem, Sub, TryInto, + TupleSize0Copy, TupleSize0Drop, +}; #[feature("deprecated-index-traits")] -use crate::traits::IndexView; -use crate::{zeroable, zeroable::{NonZero, Zeroable}}; - -#[cfg(test)] -use crate::test; -pub use crate::ops::Deref; +use crate::traits::{Index, IndexView}; +use crate::usize; +use crate::zeroable; +use crate::zeroable::{NonZero, Zeroable}; pub use starknet::storage::{ diff --git a/corelib/src/prelude/v2023_10.cairo b/corelib/src/prelude/v2023_10.cairo index 36bbdea36c2..725fa9005e4 100644 --- a/corelib/src/prelude/v2023_10.cairo +++ b/corelib/src/prelude/v2023_10.cairo @@ -1,56 +1,39 @@ -pub use crate::{RangeCheck, SegmentArena, assert, bool, felt252, usize}; - +pub use crate::RangeCheck; +pub use crate::SegmentArena; pub use crate::array::{Array, ArrayTrait, Span, SpanTrait, ToSpanTrait}; +pub use crate::assert; +pub use crate::bool; pub use crate::box::{Box, BoxTrait}; -pub use crate::bytes_31::{Bytes31Trait, bytes31}; pub use crate::byte_array::{ByteArray, ByteArrayTrait}; +pub use crate::bytes_31::{Bytes31Trait, bytes31}; pub use crate::clone::Clone; pub use crate::dict::{Felt252Dict, Felt252DictTrait, SquashedFelt252Dict}; +pub use crate::felt252; pub use crate::gas::GasBuiltin; pub use crate::integer::{Bitwise, i128, i16, i32, i64, i8, u128, u16, u256, u32, u64, u8}; pub use crate::keccak; pub use crate::math; pub use crate::nullable::{Nullable, NullableTrait}; +pub use crate::ops::Deref; pub use crate::option::{Option, OptionTrait}; pub use crate::panics::{Panic, PanicResult, panic}; pub use crate::pedersen::Pedersen; pub use crate::poseidon::Poseidon; pub use crate::result::{Result, ResultTrait}; pub use crate::serde::Serde; -pub use crate::{starknet, starknet::System}; +pub use crate::starknet; +pub use crate::starknet::System; pub use crate::to_byte_array; -pub use crate::traits::{ - Add, BitAnd, BitNot, BitOr, BitXor, Copy, Default, Destruct, Div, DivRem, Drop, - Felt252DictValue, Into, Mul, Neg, Not, PanicDestruct, PartialEq, PartialOrd, Rem, Sub, TryInto, -}; - - #[deprecated( feature: "deprecated-op-assign-traits", note: "Use `core::ops::AddAssign`.", since: "2.7.0", )] #[feature("deprecated-op-assign-traits")] pub use crate::traits::AddEq; -#[deprecated( - feature: "deprecated-op-assign-traits", note: "Use `core::ops::SubAssign`.", since: "2.7.0", -)] -#[feature("deprecated-op-assign-traits")] -pub use crate::traits::SubEq; -#[deprecated( - feature: "deprecated-op-assign-traits", note: "Use `core::ops::MulAssign`.", since: "2.7.0", -)] -#[feature("deprecated-op-assign-traits")] -pub use crate::traits::MulEq; #[deprecated( feature: "deprecated-op-assign-traits", note: "Use `core::ops::DivAssign`.", since: "2.7.0", )] #[feature("deprecated-op-assign-traits")] pub use crate::traits::DivEq; -#[deprecated( - feature: "deprecated-op-assign-traits", note: "Use `core::ops::RemAssign`.", since: "2.7.0", -)] -#[feature("deprecated-op-assign-traits")] -pub use crate::traits::RemEq; - #[deprecated( feature: "deprecated-index-traits", note: "Use `core::ops::index::Index`.", since: "2.7.0", )] @@ -61,8 +44,27 @@ pub use crate::traits::Index; )] #[feature("deprecated-index-traits")] pub use crate::traits::IndexView; +#[deprecated( + feature: "deprecated-op-assign-traits", note: "Use `core::ops::MulAssign`.", since: "2.7.0", +)] +#[feature("deprecated-op-assign-traits")] +pub use crate::traits::MulEq; +#[deprecated( + feature: "deprecated-op-assign-traits", note: "Use `core::ops::RemAssign`.", since: "2.7.0", +)] +#[feature("deprecated-op-assign-traits")] +pub use crate::traits::RemEq; +#[deprecated( + feature: "deprecated-op-assign-traits", note: "Use `core::ops::SubAssign`.", since: "2.7.0", +)] +#[feature("deprecated-op-assign-traits")] +pub use crate::traits::SubEq; +pub use crate::traits::{ + Add, BitAnd, BitNot, BitOr, BitXor, Copy, Default, Destruct, Div, DivRem, Drop, + Felt252DictValue, Into, Mul, Neg, Not, PanicDestruct, PartialEq, PartialOrd, Rem, Sub, TryInto, +}; +pub use crate::usize; pub use crate::zeroable::NonZero; -pub use crate::ops::Deref; pub use starknet::storage::{ StorageMapReadAccess, StorageMapWriteAccess, StoragePointerReadAccess, diff --git a/corelib/src/prelude/v2024_07.cairo b/corelib/src/prelude/v2024_07.cairo index b26f16b073b..2b628104d9c 100644 --- a/corelib/src/prelude/v2024_07.cairo +++ b/corelib/src/prelude/v2024_07.cairo @@ -1,22 +1,25 @@ -pub use crate::{assert, bool, felt252, usize}; - pub use crate::array::{Array, ArrayTrait, Span, SpanTrait, ToSpanTrait}; +pub use crate::assert; +pub use crate::bool; pub use crate::box::{Box, BoxTrait}; -pub use crate::bytes_31::{Bytes31Trait, bytes31}; pub use crate::byte_array::{ByteArray, ByteArrayTrait}; +pub use crate::bytes_31::{Bytes31Trait, bytes31}; pub use crate::clone::Clone; pub use crate::dict::Felt252DictTrait; +pub use crate::felt252; pub use crate::integer::{i128, i16, i32, i64, i8, u128, u16, u256, u32, u64, u8}; pub use crate::nullable::{Nullable, NullableTrait}; +pub use crate::ops::Deref; pub use crate::option::{Option, OptionTrait}; pub use crate::panics::{Panic, PanicResult, panic}; pub use crate::result::{Result, ResultTrait}; pub use crate::serde::Serde; -pub use crate::{starknet, starknet::System}; +pub use crate::starknet; +pub use crate::starknet::System; pub use crate::traits::{ Add, Copy, Default, Destruct, Div, DivRem, Drop, Felt252DictValue, Into, Mul, Neg, Not, PanicDestruct, PartialEq, PartialOrd, Rem, Sub, TryInto, }; +pub use crate::usize; pub use crate::zeroable::NonZero; -pub use crate::ops::Deref; diff --git a/corelib/src/result.cairo b/corelib/src/result.cairo index 080024840c3..e9baf1d6f29 100644 --- a/corelib/src/result.cairo +++ b/corelib/src/result.cairo @@ -113,11 +113,9 @@ //! [`Err`]: Result::Err #[allow(unused_imports)] -use crate::array::ArrayTrait; +use crate::array::{ArrayTrait, SpanTrait}; #[allow(unused_imports)] use crate::serde::Serde; -#[allow(unused_imports)] -use crate::array::SpanTrait; /// The type used for returning and propagating errors. It is an enum with the variants `Ok: T`, /// representing success and containing a value, and `Err: E`, representing error and containing an diff --git a/corelib/src/serde.cairo b/corelib/src/serde.cairo index 5415d69eb7a..7242dcfda8d 100644 --- a/corelib/src/serde.cairo +++ b/corelib/src/serde.cairo @@ -195,8 +195,8 @@ impl DeserializeTupleNext< } pub mod into_felt252_based { - use crate::traits::{Into, TryInto}; use crate::array::ArrayTrait; + use crate::traits::{Into, TryInto}; /// A generic `Serde` implementation for types that can be converted into `felt252` using the /// `Into` trait and from `felt252` using the `TryInto` trait. diff --git a/corelib/src/starknet.cairo b/corelib/src/starknet.cairo index 095bc55d7e0..879737384ab 100644 --- a/corelib/src/starknet.cairo +++ b/corelib/src/starknet.cairo @@ -14,40 +14,33 @@ //! current contract execution, such as the caller address, contract address, block info, and //! transaction info. -#[allow(unused_imports)] -use core::box::Box; -#[allow(unused_imports)] -use core::option::OptionTrait; -#[allow(unused_imports)] -use core::array::Span; #[allow(unused_imports)] use core::traits::{Into, TryInto}; #[allow(unused_imports)] -use core::zeroable::Zeroable; +use core::{array::Span, box::Box, option::OptionTrait, zeroable::Zeroable}; pub mod storage_access; -pub use storage_access::{Store, StorageAddress}; +pub use storage_access::{StorageAddress, Store}; #[allow(unused_imports)] use storage_access::{ - StorePacking, StorageBaseAddress, storage_base_address_const, storage_base_address_from_felt252, - storage_address_from_base, storage_address_from_base_and_offset, storage_address_to_felt252, - storage_address_try_from_felt252, + StorageBaseAddress, StorePacking, storage_address_from_base, + storage_address_from_base_and_offset, storage_address_to_felt252, + storage_address_try_from_felt252, storage_base_address_const, storage_base_address_from_felt252, }; pub mod syscalls; #[allow(unused_imports)] use syscalls::{ call_contract_syscall, deploy_syscall, emit_event_syscall, get_block_hash_syscall, - get_execution_info_syscall, library_call_syscall, send_message_to_l1_syscall, - storage_read_syscall, storage_write_syscall, replace_class_syscall, keccak_syscall, - get_class_hash_at_syscall, + get_class_hash_at_syscall, get_execution_info_syscall, keccak_syscall, library_call_syscall, + replace_class_syscall, send_message_to_l1_syscall, storage_read_syscall, storage_write_syscall, }; +pub mod contract_address; + pub mod secp256_trait; pub mod secp256k1; pub mod secp256r1; - -pub mod contract_address; pub use contract_address::{ContractAddress, contract_address_const}; #[allow(unused_imports)] use contract_address::{ @@ -76,10 +69,12 @@ use class_hash::{ // Not `pub` on purpose, only used for direct reexport by the next line. mod info; +pub use info::v2::{ + ExecutionInfo as ExecutionInfo, ResourceBounds as ResourcesBounds, TxInfo as TxInfo, +}; pub use info::{ - v2::ExecutionInfo as ExecutionInfo, BlockInfo, v2::TxInfo as TxInfo, get_execution_info, - get_caller_address, get_contract_address, get_block_info, get_tx_info, get_block_timestamp, - get_block_number, v2::ResourceBounds as ResourcesBounds, + BlockInfo, get_block_info, get_block_number, get_block_timestamp, get_caller_address, + get_contract_address, get_execution_info, get_tx_info, }; pub mod event; diff --git a/corelib/src/starknet/class_hash.cairo b/corelib/src/starknet/class_hash.cairo index 7189df5a5ce..ce45885afc7 100644 --- a/corelib/src/starknet/class_hash.cairo +++ b/corelib/src/starknet/class_hash.cairo @@ -16,8 +16,7 @@ #[allow(unused_imports)] use core::hash::{Hash, HashStateTrait}; -use core::RangeCheck; -use core::serde::Serde; +use core::{RangeCheck, serde::Serde}; /// Represents a Starknet contract class hash. /// The value range of this type is `[0, 2**251)`. diff --git a/corelib/src/starknet/contract_address.cairo b/corelib/src/starknet/contract_address.cairo index 57f18b6e3a6..73f9569257e 100644 --- a/corelib/src/starknet/contract_address.cairo +++ b/corelib/src/starknet/contract_address.cairo @@ -1,9 +1,8 @@ #[allow(unused_imports)] -use core::zeroable::Zeroable; -use core::serde::Serde; -#[allow(unused_imports)] use core::hash::{Hash, HashStateTrait}; -use core::RangeCheck; +#[allow(unused_imports)] +use core::zeroable::Zeroable; +use core::{RangeCheck, serde::Serde}; /// Represents a Starknet contract address. /// The value range of this type is `[0, 2**251)`. diff --git a/corelib/src/starknet/eth_address.cairo b/corelib/src/starknet/eth_address.cairo index c84d18a09cb..248cd450f20 100644 --- a/corelib/src/starknet/eth_address.cairo +++ b/corelib/src/starknet/eth_address.cairo @@ -3,12 +3,11 @@ //! This module provides the [`EthAddress`] type, which is used when interacting with Ethereum //! primitives, such as signatures and L1 <-> L2 messages. -use core::debug::PrintTrait; #[allow(unused_imports)] -use core::integer::{u128_safe_divmod, U128TryIntoNonZero, U256TryIntoFelt252}; +use core::integer::{U128TryIntoNonZero, U256TryIntoFelt252, u128_safe_divmod}; use core::option::{Option, OptionTrait}; -use core::serde::Serde; use core::traits::{Into, TryInto}; +use core::{debug::PrintTrait, serde::Serde}; /// An Ethereum address, 20 bytes in length. #[derive(Copy, Drop, Hash, PartialEq)] diff --git a/corelib/src/starknet/eth_signature.cairo b/corelib/src/starknet/eth_signature.cairo index 4dabb9adf2c..821ca9e131d 100644 --- a/corelib/src/starknet/eth_signature.cairo +++ b/corelib/src/starknet/eth_signature.cairo @@ -4,16 +4,13 @@ //! It implements verification of Ethereum signatures against addresses and conversion of public //! keys to Ethereum addresses. -use core::keccak::keccak_u256s_be_inputs; -use core::option::OptionTrait; +use core::{keccak::keccak_u256s_be_inputs, option::OptionTrait}; #[allow(unused_imports)] -use starknet::{ - EthAddress, - secp256_trait::{ - Secp256Trait, Secp256PointTrait, recover_public_key, is_signature_entry_valid, Signature, - }, - secp256k1::Secp256k1Point, SyscallResult, SyscallResultTrait, +use starknet::secp256_trait::{ + Secp256PointTrait, Secp256Trait, Signature, is_signature_entry_valid, recover_public_key, }; +#[allow(unused_imports)] +use starknet::{EthAddress, SyscallResult, SyscallResultTrait, secp256k1::Secp256k1Point}; /// Asserts that an Ethereum signature is valid for a given message hash and Ethereum address. /// Also verifies that the `r` and `s` components of the signature are in the range `[1, N)`, diff --git a/corelib/src/starknet/info.cairo b/corelib/src/starknet/info.cairo index 737c0259b90..d102d4c2cf8 100644 --- a/corelib/src/starknet/info.cairo +++ b/corelib/src/starknet/info.cairo @@ -22,8 +22,8 @@ use core::box::BoxTrait; #[allow(unused_imports)] use starknet::{ - SyscallResultTrait, SyscallResult, syscalls::get_execution_info_syscall, - contract_address::ContractAddress, + SyscallResult, SyscallResultTrait, contract_address::ContractAddress, + syscalls::get_execution_info_syscall, }; /// The execution information for the current entry point. diff --git a/corelib/src/starknet/secp256_trait.cairo b/corelib/src/starknet/secp256_trait.cairo index 871271106d8..bf3bf5cdbd4 100644 --- a/corelib/src/starknet/secp256_trait.cairo +++ b/corelib/src/starknet/secp256_trait.cairo @@ -1,12 +1,10 @@ -#[allow(unused_imports)] -use core::array::ArrayTrait; -use core::math::{u256_mul_mod_n, u256_inv_mod}; +use core::math::{u256_inv_mod, u256_mul_mod_n}; use core::option::OptionTrait; -#[allow(unused_imports)] -use starknet::{eth_address::U256IntoEthAddress, EthAddress, SyscallResult, SyscallResultTrait}; use core::traits::{Into, TryInto}; #[allow(unused_imports)] -use core::integer::U256TryIntoNonZero; +use core::{array::ArrayTrait, integer::U256TryIntoNonZero}; +#[allow(unused_imports)] +use starknet::{EthAddress, SyscallResult, SyscallResultTrait, eth_address::U256IntoEthAddress}; /// Secp256{k/r}1 ECDSA signature. #[derive(Copy, Drop, Debug, PartialEq, Serde, Hash)] diff --git a/corelib/src/starknet/secp256k1.cairo b/corelib/src/starknet/secp256k1.cairo index e5cb92e5314..450d2e8136e 100644 --- a/corelib/src/starknet/secp256k1.cairo +++ b/corelib/src/starknet/secp256k1.cairo @@ -12,15 +12,13 @@ //! 0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141 //! * Curve equation: y^2 = x^3 + 7 -use core::gas::GasBuiltin; -use core::option::OptionTrait; +use core::{gas::GasBuiltin, option::OptionTrait}; #[allow(unused_imports)] -use starknet::{ - secp256_trait::{ - Secp256Trait, Secp256PointTrait, recover_public_key, is_signature_entry_valid, Signature, - }, - SyscallResult, SyscallResultTrait, +use starknet::secp256_trait::{ + Secp256PointTrait, Secp256Trait, Signature, is_signature_entry_valid, recover_public_key, }; +#[allow(unused_imports)] +use starknet::{SyscallResult, SyscallResultTrait}; /// A point on the secp256k1 curve. #[derive(Copy, Drop)] diff --git a/corelib/src/starknet/secp256r1.cairo b/corelib/src/starknet/secp256r1.cairo index a870e8bb95e..2918065624a 100644 --- a/corelib/src/starknet/secp256r1.cairo +++ b/corelib/src/starknet/secp256r1.cairo @@ -13,12 +13,11 @@ //! * b = 0x5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b //! * Curve equation: y^2 = x^3 + ax + b -use core::gas::GasBuiltin; -use core::option::OptionTrait; +use core::{gas::GasBuiltin, option::OptionTrait}; #[allow(unused_imports)] -use starknet::{ - EthAddress, secp256_trait::{Secp256Trait, Secp256PointTrait}, SyscallResult, SyscallResultTrait, -}; +use starknet::secp256_trait::{Secp256PointTrait, Secp256Trait}; +#[allow(unused_imports)] +use starknet::{EthAddress, SyscallResult, SyscallResultTrait}; /// Represents a point on the secp256r1 elliptic curve. #[derive(Copy, Drop)] diff --git a/corelib/src/starknet/storage.cairo b/corelib/src/starknet/storage.cairo index fca65820b2c..ebf7d5ff8cf 100644 --- a/corelib/src/starknet/storage.cairo +++ b/corelib/src/starknet/storage.cairo @@ -69,25 +69,23 @@ //! indicates that the storage object is mutable, i.e., it was created from a `ref` contract state, //! and thus the object can be written to. -use core::traits::Into; #[allow(unused_imports)] use core::pedersen::HashState; -use core::hash::HashStateTrait; -use starknet::storage_access::StorageBaseAddress; +use core::{hash::HashStateTrait, traits::Into}; #[allow(unused_imports)] use starknet::SyscallResult; -use starknet::storage_access::storage_base_address_from_felt252; +use starknet::storage_access::{StorageBaseAddress, storage_base_address_from_felt252}; mod vec; -pub use vec::{Vec, VecTrait, MutableVecTrait}; -use vec::{VecIndexView, MutableVecIndexView}; +use vec::{MutableVecIndexView, VecIndexView}; +pub use vec::{MutableVecTrait, Vec, VecTrait}; mod storage_node; pub use storage_node::{StorageNode, StorageNodeMut}; mod sub_pointers; -pub use sub_pointers::{SubPointers, SubPointersMut, SubPointersForward, SubPointersMutForward}; +pub use sub_pointers::{SubPointers, SubPointersForward, SubPointersMut, SubPointersMutForward}; mod storage_base; -pub use storage_base::{StorageBase, FlattenedStorage, StorageTrait, StorageTraitMut}; +pub use storage_base::{FlattenedStorage, StorageBase, StorageTrait, StorageTraitMut}; mod map; pub use map::{Map, StorageMapReadAccess, StorageMapWriteAccess, StoragePathEntry}; diff --git a/corelib/src/starknet/storage/map.cairo b/corelib/src/starknet/storage/map.cairo index d7e02dd6fca..6e3b8bc4ead 100644 --- a/corelib/src/starknet/storage/map.cairo +++ b/corelib/src/starknet/storage/map.cairo @@ -1,9 +1,23 @@ #[allow(unused_imports)] -use super::{ - StoragePath, Mutable, StoragePathHashState, StoragePathTrait, StoragePathUpdateTrait, - MutableTrait, StorageAsPointer, StoragePointerReadAccess, StoragePointerWriteAccess, - StorageAsPath, -}; +use super::Mutable; +#[allow(unused_imports)] +use super::MutableTrait; +#[allow(unused_imports)] +use super::StorageAsPath; +#[allow(unused_imports)] +use super::StorageAsPointer; +#[allow(unused_imports)] +use super::StoragePath; +#[allow(unused_imports)] +use super::StoragePathHashState; +#[allow(unused_imports)] +use super::StoragePathTrait; +#[allow(unused_imports)] +use super::StoragePathUpdateTrait; +#[allow(unused_imports)] +use super::StoragePointerReadAccess; +#[allow(unused_imports)] +use super::StoragePointerWriteAccess; /// Trait for reading a contract/component storage member in a specific key place. pub trait StorageMapReadAccess { diff --git a/corelib/src/starknet/storage/storage_base.cairo b/corelib/src/starknet/storage/storage_base.cairo index bd68c8ee9f4..11dcd314bc9 100644 --- a/corelib/src/starknet/storage/storage_base.cairo +++ b/corelib/src/starknet/storage/storage_base.cairo @@ -1,4 +1,7 @@ -use super::{Mutable, StoragePath, StorageAsPath, StoragePathTrait}; +use super::Mutable; +use super::StorageAsPath; +use super::StoragePath; +use super::StoragePathTrait; /// A struct for holding an address to initialize a storage path with. The members (not direct /// members, but accessible using deref) of a contract state are either `StorageBase` or diff --git a/corelib/src/starknet/storage/storage_node.cairo b/corelib/src/starknet/storage/storage_node.cairo index ca07d001c72..a55747d1725 100644 --- a/corelib/src/starknet/storage/storage_node.cairo +++ b/corelib/src/starknet/storage/storage_node.cairo @@ -1,4 +1,5 @@ -use super::{StoragePath, Mutable}; +use super::Mutable; +use super::StoragePath; /// A trait that given a storage path of a struct, generates the storage node of this struct. diff --git a/corelib/src/starknet/storage/sub_pointers.cairo b/corelib/src/starknet/storage/sub_pointers.cairo index e2f361ceaab..6c7f6fad285 100644 --- a/corelib/src/starknet/storage/sub_pointers.cairo +++ b/corelib/src/starknet/storage/sub_pointers.cairo @@ -1,4 +1,7 @@ -use super::{StoragePointer, Mutable, StorageAsPointer, StoragePointer0Offset}; +use super::Mutable; +use super::StorageAsPointer; +use super::StoragePointer; +use super::StoragePointer0Offset; /// Similar to storage node, but for structs which are stored sequentially in the storage. In /// contrast to storage node, the fields of the struct are just offsetted from the base address of diff --git a/corelib/src/starknet/storage/vec.cairo b/corelib/src/starknet/storage/vec.cairo index fd16658e7d9..fec9efd1b3f 100644 --- a/corelib/src/starknet/storage/vec.cairo +++ b/corelib/src/starknet/storage/vec.cairo @@ -1,8 +1,13 @@ -use super::{ - StorageAsPath, StorageAsPointer, StoragePath, StoragePointer0Offset, Mutable, StoragePathTrait, - StoragePathUpdateTrait, StoragePointerReadAccess, StoragePointerWriteAccess, -}; use core::Option; +use super::Mutable; +use super::StorageAsPath; +use super::StorageAsPointer; +use super::StoragePath; +use super::StoragePathTrait; +use super::StoragePathUpdateTrait; +use super::StoragePointer0Offset; +use super::StoragePointerReadAccess; +use super::StoragePointerWriteAccess; /// A type to represent a vec in storage. The length of the storage is stored in the storage /// base, while the elements are stored in hash(storage_base, index). diff --git a/corelib/src/starknet/storage_access.cairo b/corelib/src/starknet/storage_access.cairo index 18220af314a..066f28ad553 100644 --- a/corelib/src/starknet/storage_access.cairo +++ b/corelib/src/starknet/storage_access.cairo @@ -1,16 +1,18 @@ -use core::array::ArrayTrait; use core::traits::{Into, TryInto}; -use core::option::OptionTrait; -use core::byte_array::ByteArrayTrait; -use core::bytes_31::BYTES_IN_BYTES31; +use core::{ + RangeCheck, array::ArrayTrait, byte_array::ByteArrayTrait, bytes_31::BYTES_IN_BYTES31, + option::OptionTrait, serde::Serde, +}; +#[allow(unused_imports)] +use starknet::SyscallResult; #[allow(unused_imports)] -use starknet::{ - SyscallResult, syscalls::{storage_read_syscall, storage_write_syscall}, - contract_address::{ContractAddress, Felt252TryIntoContractAddress, ContractAddressIntoFelt252}, - class_hash::{ClassHash, Felt252TryIntoClassHash, ClassHashIntoFelt252}, +use starknet::class_hash::{ClassHash, ClassHashIntoFelt252, Felt252TryIntoClassHash}; +#[allow(unused_imports)] +use starknet::contract_address::{ + ContractAddress, ContractAddressIntoFelt252, Felt252TryIntoContractAddress, }; -use core::serde::Serde; -use core::RangeCheck; +#[allow(unused_imports)] +use starknet::syscalls::{storage_read_syscall, storage_write_syscall}; /// Represents the address of a storage value in a Starknet contract. /// The value range of this type is `[0, 2**251)`. diff --git a/corelib/src/starknet/syscalls.cairo b/corelib/src/starknet/syscalls.cairo index 49f85d8449e..2242224914c 100644 --- a/corelib/src/starknet/syscalls.cairo +++ b/corelib/src/starknet/syscalls.cairo @@ -11,8 +11,8 @@ use core::gas::GasBuiltin; use starknet::{ - SyscallResult, storage_access::StorageAddress, class_hash::ClassHash, - contract_address::ContractAddress, + SyscallResult, class_hash::ClassHash, contract_address::ContractAddress, + storage_access::StorageAddress, }; /// Calls a given contract. diff --git a/corelib/src/starknet/testing.cairo b/corelib/src/starknet/testing.cairo index 8b799865f71..2164c186f13 100644 --- a/corelib/src/starknet/testing.cairo +++ b/corelib/src/starknet/testing.cairo @@ -8,12 +8,10 @@ //! If you are using Starknet Foundry, refer to its //! [documentation](https://foundry-rs.github.io/starknet-foundry/appendix/cheatcodes.html). -use starknet::ContractAddress; -#[allow(unused_imports)] -use core::array::ArrayTrait; #[allow(unused_imports)] -use core::array::SpanTrait; +use core::array::{ArrayTrait, SpanTrait}; use core::traits::Into; +use starknet::ContractAddress; /// A general cheatcode function used to simplify implementation of Starknet testing functions. /// diff --git a/corelib/src/test.cairo b/corelib/src/test.cairo index 0e67969471b..b7fa57ea55d 100644 --- a/corelib/src/test.cairo +++ b/corelib/src/test.cairo @@ -34,8 +34,8 @@ mod language_features { mod closure_test; mod const_folding_test; mod const_test; - mod glob_use_test; mod for_test; + mod glob_use_test; mod panics_test; mod trait_test; mod while_test; diff --git a/corelib/src/test/array_test.cairo b/corelib/src/test/array_test.cairo index 7fffc886db0..7f70e6e6d45 100644 --- a/corelib/src/test/array_test.cairo +++ b/corelib/src/test/array_test.cairo @@ -1,5 +1,5 @@ -use crate::test::test_utils::assert_eq; use crate::iter::{IntoIterator, Iterator}; +use crate::test::test_utils::assert_eq; #[test] fn test_array() { diff --git a/corelib/src/test/bytes31_test.cairo b/corelib/src/test/bytes31_test.cairo index 4980984ec3b..9371b19e745 100644 --- a/corelib/src/test/bytes31_test.cairo +++ b/corelib/src/test/bytes31_test.cairo @@ -1,4 +1,4 @@ -use crate::bytes_31::{split_bytes31, bytes31_const}; +use crate::bytes_31::{bytes31_const, split_bytes31}; const POW_2_248: felt252 = 0x100000000000000000000000000000000000000000000000000000000000000; diff --git a/corelib/src/test/circuit_test.cairo b/corelib/src/test/circuit_test.cairo index 18ba219a1a1..0648fad5a20 100644 --- a/corelib/src/test/circuit_test.cairo +++ b/corelib/src/test/circuit_test.cairo @@ -1,9 +1,8 @@ use crate::circuit::{ - RangeCheck96, AddMod, MulMod, u96, CircuitElement, CircuitInput, circuit_add, circuit_sub, - circuit_mul, circuit_inverse, EvalCircuitTrait, u384, CircuitOutputsTrait, CircuitModulus, - AddInputResultTrait, CircuitInputs, + AddInputResultTrait, AddMod, CircuitElement, CircuitInput, CircuitInputs, CircuitModulus, + CircuitOutputsTrait, EvalCircuitTrait, MulMod, RangeCheck96, circuit_add, circuit_inverse, + circuit_mul, circuit_sub, u384, u96, }; - use crate::num::traits::Zero; use crate::traits::TryInto; diff --git a/corelib/src/test/dict_test.cairo b/corelib/src/test/dict_test.cairo index 0fbcbb1fbe8..eb6287b918e 100644 --- a/corelib/src/test/dict_test.cairo +++ b/corelib/src/test/dict_test.cairo @@ -1,6 +1,6 @@ -use crate::dict::{Felt252DictEntryTrait, Felt252Dict}; -use crate::test::test_utils::assert_eq; +use crate::dict::{Felt252Dict, Felt252DictEntryTrait}; use crate::nullable; +use crate::test::test_utils::assert_eq; #[test] fn test_dict_new() -> Felt252Dict { diff --git a/corelib/src/test/hash_test.cairo b/corelib/src/test/hash_test.cairo index b09518daeb0..17bf43e13b3 100644 --- a/corelib/src/test/hash_test.cairo +++ b/corelib/src/test/hash_test.cairo @@ -1,6 +1,6 @@ -use crate::test::test_utils::assert_eq; -use crate::hash::{HashStateTrait, HashStateExTrait}; +use crate::hash::{HashStateExTrait, HashStateTrait}; use crate::poseidon::PoseidonTrait; +use crate::test::test_utils::assert_eq; #[test] fn test_pedersen_hash() { diff --git a/corelib/src/test/integer_test.cairo b/corelib/src/test/integer_test.cairo index 43a4b3e572a..a3d8d86277d 100644 --- a/corelib/src/test/integer_test.cairo +++ b/corelib/src/test/integer_test.cairo @@ -1,7 +1,9 @@ #[feature("deprecated-bounded-int-trait")] -use crate::{integer, integer::{u512_safe_div_rem_by_u256, u512}}; -use crate::test::test_utils::{assert_eq, assert_ne, assert_le, assert_lt, assert_gt, assert_ge}; +use crate::integer; +#[feature("deprecated-bounded-int-trait")] +use crate::integer::{u512, u512_safe_div_rem_by_u256}; use crate::num::traits::{Bounded, Sqrt, WideMul, WideSquare, WrappingSub}; +use crate::test::test_utils::{assert_eq, assert_ge, assert_gt, assert_le, assert_lt, assert_ne}; #[test] fn test_u8_operators() { @@ -1873,11 +1875,11 @@ fn test_signed_int_diff() { } mod bounded_int { - use crate::internal::{ - bounded_int, - bounded_int::{BoundedInt, AddHelper, SubHelper, MulHelper, DivRemHelper, ConstrainHelper}, - }; use crate::RangeCheck; + use crate::internal::bounded_int; + use crate::internal::bounded_int::{ + AddHelper, BoundedInt, ConstrainHelper, DivRemHelper, MulHelper, SubHelper, + }; extern fn downcast(index: T) -> Option implicits(RangeCheck) nopanic; extern fn upcast(index: T) -> S nopanic; diff --git a/corelib/src/test/language_features/const_folding_test.cairo b/corelib/src/test/language_features/const_folding_test.cairo index 7945eb81d7d..3cd92587589 100644 --- a/corelib/src/test/language_features/const_folding_test.cairo +++ b/corelib/src/test/language_features/const_folding_test.cairo @@ -1,5 +1,5 @@ -use crate::num::traits::{WrappingAdd, WrappingSub, WrappingMul}; use crate::integer::i8_diff; +use crate::num::traits::{WrappingAdd, WrappingMul, WrappingSub}; /// Helper to prevent const folding. #[inline(never)] diff --git a/corelib/src/test/language_features/glob_use_test.cairo b/corelib/src/test/language_features/glob_use_test.cairo index a238f8d73b9..549117200ec 100644 --- a/corelib/src/test/language_features/glob_use_test.cairo +++ b/corelib/src/test/language_features/glob_use_test.cairo @@ -4,7 +4,6 @@ pub mod a { } pub const SHADOWED: felt252 = 'new_shadowed'; - use a::*; #[test] diff --git a/corelib/src/test/language_features/panics_test.cairo b/corelib/src/test/language_features/panics_test.cairo index a7d67ee8571..0f2b7233674 100644 --- a/corelib/src/test/language_features/panics_test.cairo +++ b/corelib/src/test/language_features/panics_test.cairo @@ -1,5 +1,6 @@ use crate::byte_array::BYTE_ARRAY_MAGIC; -use crate::{panics, panic_with_felt252}; +use crate::panic_with_felt252; +use crate::panics; #[test] #[should_panic(expected: 'short_string')] diff --git a/corelib/src/test/math_test.cairo b/corelib/src/test/math_test.cairo index 6a0323b7572..961361bb640 100644 --- a/corelib/src/test/math_test.cairo +++ b/corelib/src/test/math_test.cairo @@ -1,5 +1,5 @@ -use crate::option::OptionTrait; use crate::math; +use crate::option::OptionTrait; #[test] fn test_egcd() { diff --git a/corelib/src/test/nullable_test.cairo b/corelib/src/test/nullable_test.cairo index 92a6d8ea588..53353b3f1b4 100644 --- a/corelib/src/test/nullable_test.cairo +++ b/corelib/src/test/nullable_test.cairo @@ -1,5 +1,5 @@ -use crate::test::test_utils::assert_eq; use crate::nullable::null; +use crate::test::test_utils::assert_eq; #[test] fn test_nullable_felt252s() { diff --git a/corelib/src/test/num_test.cairo b/corelib/src/test/num_test.cairo index 4d4eb3548f6..b02b771b0b8 100644 --- a/corelib/src/test/num_test.cairo +++ b/corelib/src/test/num_test.cairo @@ -1,9 +1,8 @@ -use crate::num::traits::BitSize; use crate::num::traits::{ - OverflowingAdd, OverflowingSub, OverflowingMul, WrappingAdd, WrappingSub, WrappingMul, - CheckedAdd, CheckedSub, CheckedMul, SaturatingAdd, SaturatingSub, SaturatingMul, Pow, + BitSize, Bounded, CheckedAdd, CheckedMul, CheckedSub, OverflowingAdd, OverflowingMul, + OverflowingSub, Pow, SaturatingAdd, SaturatingMul, SaturatingSub, WrappingAdd, WrappingMul, + WrappingSub, }; -use crate::num::traits::Bounded; #[test] diff --git a/corelib/src/test/secp256k1_test.cairo b/corelib/src/test/secp256k1_test.cairo index 2796774d884..3c5a7ac8f3d 100644 --- a/corelib/src/test/secp256k1_test.cairo +++ b/corelib/src/test/secp256k1_test.cairo @@ -1,12 +1,12 @@ use crate::serde::Serde; -use starknet::{ - eth_address::U256IntoEthAddress, EthAddress, secp256k1::Secp256k1Impl, SyscallResultTrait, -}; use starknet::secp256_trait::{ - Signature, recover_public_key, Secp256PointTrait, signature_from_vrs, is_valid_signature, + Secp256PointTrait, Signature, is_valid_signature, recover_public_key, signature_from_vrs, +}; +use starknet::secp256k1::{Secp256k1Impl, Secp256k1Point}; +use starknet::{ + EthAddress, SyscallResultTrait, eth_address::U256IntoEthAddress, + eth_signature::verify_eth_signature, }; -use starknet::secp256k1::Secp256k1Point; -use starknet::eth_signature::verify_eth_signature; #[test] fn test_secp256k1_point_serde() { diff --git a/corelib/src/test/secp256r1_test.cairo b/corelib/src/test/secp256r1_test.cairo index 545bc0cf297..359232fd6f6 100644 --- a/corelib/src/test/secp256r1_test.cairo +++ b/corelib/src/test/secp256r1_test.cairo @@ -1,8 +1,8 @@ use crate::option::OptionTrait; -use starknet::{secp256r1::Secp256r1Impl, SyscallResultTrait}; -use starknet::secp256_trait::{recover_public_key, Secp256PointTrait, Signature, is_valid_signature}; -use starknet::secp256r1::Secp256r1Point; use crate::test::test_utils::assert_eq; +use starknet::SyscallResultTrait; +use starknet::secp256_trait::{Secp256PointTrait, Signature, is_valid_signature, recover_public_key}; +use starknet::secp256r1::{Secp256r1Impl, Secp256r1Point}; #[test] fn test_secp256k1_point_serde() { diff --git a/corelib/src/test/to_byte_array_test.cairo b/corelib/src/test/to_byte_array_test.cairo index bb89f79b080..cc0e2bce6eb 100644 --- a/corelib/src/test/to_byte_array_test.cairo +++ b/corelib/src/test/to_byte_array_test.cairo @@ -1,5 +1,5 @@ use crate::test::test_utils::assert_eq; -use crate::to_byte_array::{FormatAsByteArray, AppendFormattedToByteArray}; +use crate::to_byte_array::{AppendFormattedToByteArray, FormatAsByteArray}; #[test] fn test_to_string_hex() { diff --git a/crates/cairo-lang-formatter/src/lib.rs b/crates/cairo-lang-formatter/src/lib.rs index 3e45afa49b8..e977ab761cc 100644 --- a/crates/cairo-lang-formatter/src/lib.rs +++ b/crates/cairo-lang-formatter/src/lib.rs @@ -163,10 +163,10 @@ impl Default for FormatterConfig { Self { tab_size: TAB_SIZE, max_line_length: MAX_LINE_LENGTH, - sort_module_level_items: false, + sort_module_level_items: true, tuple_breaking_behavior: CollectionsBreakingBehavior::LineByLine, fixed_array_breaking_behavior: CollectionsBreakingBehavior::SingleBreakPoint, - merge_use_items: false, + merge_use_items: true, allow_duplicate_uses: false, } } diff --git a/crates/cairo-lang-parser/src/parser_test_data/partial_trees/use b/crates/cairo-lang-parser/src/parser_test_data/partial_trees/use index 05a8a2f2b1f..2fea0fce44b 100644 --- a/crates/cairo-lang-parser/src/parser_test_data/partial_trees/use +++ b/crates/cairo-lang-parser/src/parser_test_data/partial_trees/use @@ -155,7 +155,7 @@ test_partial_parser_tree(expect_diagnostics: false) //! > cairo_code fn foo() { - use X::{A, *, B}; + use X::{*, A, B}; } //! > top_level_kind @@ -177,13 +177,13 @@ ItemUse │ └── use_path (kind: UsePathMulti) │ ├── lbrace (kind: TokenLBrace): '{' │ ├── use_paths (kind: UsePathList) - │ │ ├── item #0 (kind: UsePathLeaf) + │ │ ├── item #0 (kind: UsePathStar) + │ │ │ └── star (kind: TokenMul): '*' + │ │ ├── separator #0 (kind: TokenComma): ',' + │ │ ├── item #1 (kind: UsePathLeaf) │ │ │ ├── ident (kind: PathSegmentSimple) │ │ │ │ └── ident (kind: TokenIdentifier): 'A' │ │ │ └── alias_clause (kind: OptionAliasClauseEmpty) [] - │ │ ├── separator #0 (kind: TokenComma): ',' - │ │ ├── item #1 (kind: UsePathStar) - │ │ │ └── star (kind: TokenMul): '*' │ │ ├── separator #1 (kind: TokenComma): ',' │ │ └── item #2 (kind: UsePathLeaf) │ │ ├── ident (kind: PathSegmentSimple) diff --git a/crates/cairo-lang-runner/src/profiling_test_data/circuit b/crates/cairo-lang-runner/src/profiling_test_data/circuit index 47f3b0c4e2f..3291db5d11e 100644 --- a/crates/cairo-lang-runner/src/profiling_test_data/circuit +++ b/crates/cairo-lang-runner/src/profiling_test_data/circuit @@ -5,9 +5,9 @@ test_profiling //! > cairo_code use core::circuit::{ - RangeCheck96, AddMod, MulMod, u96, CircuitElement, CircuitInput, circuit_add, circuit_sub, - circuit_mul, circuit_inverse, EvalCircuitResult, EvalCircuitTrait, u384, CircuitOutputsTrait, - CircuitModulus, AddInputResultTrait, CircuitInputs, + AddInputResultTrait, AddMod, CircuitElement, CircuitInput, CircuitInputs, CircuitModulus, + CircuitOutputsTrait, EvalCircuitResult, EvalCircuitTrait, MulMod, RangeCheck96, circuit_add, + circuit_inverse, circuit_mul, circuit_sub, u384, u96, }; pub fn eval_circuit() -> u384 { diff --git a/crates/cairo-lang-runner/src/profiling_test_data/major_test_cases b/crates/cairo-lang-runner/src/profiling_test_data/major_test_cases index 7180da97086..25ae080aabc 100644 --- a/crates/cairo-lang-runner/src/profiling_test_data/major_test_cases +++ b/crates/cairo-lang-runner/src/profiling_test_data/major_test_cases @@ -818,10 +818,7 @@ trait IERC20 { #[starknet::contract] mod erc_20 { use core::num::traits::Zero; - use starknet::get_caller_address; - use starknet::contract_address_const; - use starknet::ContractAddress; - use starknet::storage::Map; + use starknet::{ContractAddress, contract_address_const, get_caller_address, storage::Map}; #[storage] diff --git a/crates/cairo-lang-semantic/src/diagnostic_test_data/tests b/crates/cairo-lang-semantic/src/diagnostic_test_data/tests index c6edf415a16..ec6cfc3f9d5 100644 --- a/crates/cairo-lang-semantic/src/diagnostic_test_data/tests +++ b/crates/cairo-lang-semantic/src/diagnostic_test_data/tests @@ -192,14 +192,13 @@ test_expr_diagnostics(expect_diagnostics: true) mod a { use super::B; } - use a::B; //! > function_body //! > expected_diagnostics error: Cycle detected while resolving 'use' items. - --> lib.cairo:5:8 + --> lib.cairo:4:8 use a::B; ^ @@ -921,7 +920,6 @@ pub mod a { pub mod b { pub const AMBIGUOUS: u8 = 4; } - use a::*; use b::*; @@ -934,7 +932,7 @@ AMBIGUOUS //! > expected_diagnostics error: Ambiguous path. Multiple matching items: `test::a::AMBIGUOUS`, `test::b::AMBIGUOUS` - --> lib.cairo:12:1 + --> lib.cairo:11:1 AMBIGUOUS ^^^^^^^^^ @@ -976,8 +974,8 @@ edition = "2024_07" //! > module_code mod a { - use super::*; use a::a::a::a::*; + use super::*; } //! > function_body @@ -989,7 +987,7 @@ mod a { //! > expected_diagnostics error: Cycle detected while resolving 'use' items. - --> lib.cairo:3:21 + --> lib.cairo:2:21 use a::a::a::a::*; ^ @@ -1033,7 +1031,6 @@ edition = "2024_07" mod a { const INACCESSIBLE: u8 = 1; } - use a::*; //! > function_body @@ -1045,7 +1042,7 @@ INACCESSIBLE //! > expected_diagnostics error: Item `test::a::INACCESSIBLE` is not visible in this context through module `test::a`. - --> lib.cairo:7:1 + --> lib.cairo:6:1 INACCESSIBLE ^^^^^^^^^^^^ @@ -1065,7 +1062,6 @@ mod a { pub const C: u8 = 1; } } - use a::*; //! > function_body @@ -1077,7 +1073,7 @@ inaccessible::C //! > expected_diagnostics error: Item `test::a::inaccessible` is not visible in this context through module `test::a`. - --> lib.cairo:9:1 + --> lib.cairo:8:1 inaccessible::C ^^^^^^^^^^^^ @@ -1103,7 +1099,6 @@ mod c { use super::super::a::b::*; } } - use c::d::*; //! > function_body @@ -1115,7 +1110,7 @@ C //! > expected_diagnostics error: Item `test::a::b::C` is not visible in this context through module `test::a::b`. - --> lib.cairo:15:1 + --> lib.cairo:14:1 C ^ @@ -1146,7 +1141,6 @@ mod c { pub use super::super::a::b::*; } } - use c::d::*; //! > function_body @@ -1158,7 +1152,7 @@ C //! > expected_diagnostics error: Item `test::a::b::C` is not visible in this context through module `test::a::b`. - --> lib.cairo:15:1 + --> lib.cairo:14:1 C ^ @@ -1190,7 +1184,6 @@ mod e { pub use super::super::c::d::*; } } - use e::f::*; //! > function_body @@ -1202,7 +1195,7 @@ C //! > expected_diagnostics error: Item `test::a::b::C` is not visible in this context through module `test::a::b`. - --> lib.cairo:21:1 + --> lib.cairo:20:1 C ^ @@ -1234,7 +1227,6 @@ mod e { pub use super::super::c::d::*; } } - use e::f::*; //! > function_body @@ -1264,7 +1256,6 @@ edition = "2023_01" mod a { pub const C: u8 = 1; } - use a::*; //! > function_body @@ -1276,6 +1267,6 @@ use a::*; //! > expected_diagnostics error: Global `use` item is not supported in `V2023_01` edition. - --> lib.cairo:5:8 + --> lib.cairo:4:8 use a::*; ^ diff --git a/crates/cairo-lang-semantic/src/expr/semantic_test_data/use b/crates/cairo-lang-semantic/src/expr/semantic_test_data/use index 632ee408bf3..1b3d575bc9a 100644 --- a/crates/cairo-lang-semantic/src/expr/semantic_test_data/use +++ b/crates/cairo-lang-semantic/src/expr/semantic_test_data/use @@ -413,8 +413,7 @@ mod X { extern type R; extern fn new_r() -> R nopanic; } -use X::R as RR; -use X::new_r; +use X::{R as RR, new_r}; //! > function_body @@ -482,8 +481,7 @@ mod X { extern type R; extern fn new_r() -> R nopanic; } -use X::R as RR; -use X::new_r; +use X::{R as RR, new_r}; //! > function_body @@ -539,12 +537,12 @@ Block( //! > expected_diagnostics warning[E0001]: Unused variable. Consider ignoring by prefixing with `_`. - --> lib.cairo:9:9 + --> lib.cairo:8:9 let y: RR:: = new_r(); ^ warning[E0001]: Unused variable. Consider ignoring by prefixing with `_`. - --> lib.cairo:11:9 + --> lib.cairo:10:9 let x: R:: = new_r(); ^ @@ -701,7 +699,6 @@ mod X { B: u16, } } - use X::R; //! > function_body @@ -771,7 +768,6 @@ pub mod generic_type { B: u16, } } - use generic_type::E as EE; //! > function_body @@ -1023,8 +1019,8 @@ edition = "2024_07" //! > module_code mod a { - use super::*; use a::a::a::a as b; + use super::*; } //! > function_body @@ -1043,7 +1039,7 @@ Block( //! > expected_diagnostics warning: Unused import: `test::a::b` - --> lib.cairo:3:18 + --> lib.cairo:2:18 use a::a::a::a as b; ^^^^^^ @@ -1063,7 +1059,6 @@ mod a { pub const ACCESSIBLE: u8 = 1; } } - use a::b::*; //! > function_body @@ -1103,7 +1098,6 @@ mod c { pub use super::super::a::b::*; } } - use c::d::*; //! > function_body @@ -1137,7 +1131,6 @@ mod a { pub const C: u8 = 1; } } - use a::*; //! > function_body @@ -1183,9 +1176,7 @@ mod e { use super::super::a::b::*; } } - use c::d::*; - use e::f::*; //! > function_body @@ -1227,7 +1218,6 @@ mod b { } } } - use a::*; //! > function_body @@ -1285,7 +1275,6 @@ mod b { mod c { pub struct V {} } - use b::*; //! > function_body diff --git a/crates/cairo-lang-semantic/src/items/tests/early_conform b/crates/cairo-lang-semantic/src/items/tests/early_conform index 353ed59d840..62c3d737f10 100644 --- a/crates/cairo-lang-semantic/src/items/tests/early_conform +++ b/crates/cairo-lang-semantic/src/items/tests/early_conform @@ -805,7 +805,7 @@ mod inner { } } } -use inner::{MyType, MyGenericType}; +use inner::{MyGenericType, MyType}; fn main(other: MyGenericType) { let _: MyGenericType = MyGenericType { x: 3_u16.my_into(), ..2_u32.my_into() }; } diff --git a/crates/cairo-lang-starknet/cairo_level_tests/abi_dispatchers_tests.cairo b/crates/cairo-lang-starknet/cairo_level_tests/abi_dispatchers_tests.cairo index fd1d33adb92..293b5766821 100644 --- a/crates/cairo-lang-starknet/cairo_level_tests/abi_dispatchers_tests.cairo +++ b/crates/cairo-lang-starknet/cairo_level_tests/abi_dispatchers_tests.cairo @@ -1,5 +1,4 @@ use starknet::account::Call; - use super::utils::serialized; #[starknet::interface] @@ -7,9 +6,10 @@ trait IAnotherContract {} #[starknet::contract(account)] mod test_contract { - use starknet::{account::Call, ContractAddress, ClassHash}; use starknet::storage::{StoragePointerReadAccess, StoragePointerWriteAccess}; - use super::{IAnotherContractDispatcher, IAnotherContractLibraryDispatcher}; + use starknet::{ClassHash, ContractAddress, account::Call}; + use super::IAnotherContractDispatcher; + use super::IAnotherContractLibraryDispatcher; #[storage] diff --git a/crates/cairo-lang-starknet/cairo_level_tests/collections_test.cairo b/crates/cairo-lang-starknet/cairo_level_tests/collections_test.cairo index 57aff4debcb..e0b2427e084 100644 --- a/crates/cairo-lang-starknet/cairo_level_tests/collections_test.cairo +++ b/crates/cairo-lang-starknet/cairo_level_tests/collections_test.cairo @@ -1,5 +1,5 @@ use starknet::storage::{ - StoragePointerReadAccess, StoragePointerWriteAccess, MutableVecTrait, StoragePathEntry, + MutableVecTrait, StoragePathEntry, StoragePointerReadAccess, StoragePointerWriteAccess, }; diff --git a/crates/cairo-lang-starknet/cairo_level_tests/component_usage_test.cairo b/crates/cairo-lang-starknet/cairo_level_tests/component_usage_test.cairo index 355ca0caaf4..45aeebec72d 100644 --- a/crates/cairo-lang-starknet/cairo_level_tests/component_usage_test.cairo +++ b/crates/cairo-lang-starknet/cairo_level_tests/component_usage_test.cairo @@ -1,4 +1,4 @@ -use core::starknet::storage::{StoragePointerWriteAccess, StoragePointerReadAccess}; +use core::starknet::storage::{StoragePointerReadAccess, StoragePointerWriteAccess}; #[starknet::component] mod comp_v0 { diff --git a/crates/cairo-lang-starknet/cairo_level_tests/components.cairo b/crates/cairo-lang-starknet/cairo_level_tests/components.cairo index a86d2884079..08262c1ac93 100644 --- a/crates/cairo-lang-starknet/cairo_level_tests/components.cairo +++ b/crates/cairo-lang-starknet/cairo_level_tests/components.cairo @@ -1,6 +1,6 @@ pub mod erc20; +pub mod erc20_mini; pub mod mintable; pub mod ownable; -pub mod upgradable; pub mod ownable_mini; -pub mod erc20_mini; +pub mod upgradable; diff --git a/crates/cairo-lang-starknet/cairo_level_tests/components/erc20.cairo b/crates/cairo-lang-starknet/cairo_level_tests/components/erc20.cairo index 0587b2f4ca5..128c80aed23 100644 --- a/crates/cairo-lang-starknet/cairo_level_tests/components/erc20.cairo +++ b/crates/cairo-lang-starknet/cairo_level_tests/components/erc20.cairo @@ -19,12 +19,12 @@ pub trait ERC20Trait { #[starknet::component] pub mod erc20 { - use starknet::{ContractAddress, get_caller_address, contract_address_const}; use core::num::traits::Zero; use starknet::storage::{ - Map, StoragePointerReadAccess, StoragePointerWriteAccess, StorageMapReadAccess, - StorageMapWriteAccess, + Map, StorageMapReadAccess, StorageMapWriteAccess, StoragePointerReadAccess, + StoragePointerWriteAccess, }; + use starknet::{ContractAddress, contract_address_const, get_caller_address}; #[storage] pub struct Storage { pub name: felt252, diff --git a/crates/cairo-lang-starknet/cairo_level_tests/components/erc20_mini.cairo b/crates/cairo-lang-starknet/cairo_level_tests/components/erc20_mini.cairo index 8db4811b3ef..0484158893a 100644 --- a/crates/cairo-lang-starknet/cairo_level_tests/components/erc20_mini.cairo +++ b/crates/cairo-lang-starknet/cairo_level_tests/components/erc20_mini.cairo @@ -1,8 +1,8 @@ -use starknet::{ContractAddress, get_caller_address, contract_address_const}; use starknet::storage::{ - StoragePointerReadAccess, StoragePointerWriteAccess, StorageMapReadAccess, - StorageMapWriteAccess, + StorageMapReadAccess, StorageMapWriteAccess, StoragePointerReadAccess, + StoragePointerWriteAccess, }; +use starknet::{ContractAddress, contract_address_const, get_caller_address}; #[starknet::interface] @@ -35,8 +35,6 @@ pub trait HasStorage< fn storage(self: @TContractState) -> StorageImpl::BaseType; fn storage_mut(ref self: TContractState) -> StorageImplMut::BaseType; } - - use core::num::traits::Zero; use starknet::storage::Map; #[starknet::storage_node] diff --git a/crates/cairo-lang-starknet/cairo_level_tests/components/mintable.cairo b/crates/cairo-lang-starknet/cairo_level_tests/components/mintable.cairo index 1c9f2a6db7b..edd79a7c0c7 100644 --- a/crates/cairo-lang-starknet/cairo_level_tests/components/mintable.cairo +++ b/crates/cairo-lang-starknet/cairo_level_tests/components/mintable.cairo @@ -8,14 +8,13 @@ pub trait MintTrait { #[starknet::component] pub mod mintable { use core::num::traits::Zero; - use starknet::{ContractAddress, contract_address_const}; + use crate::components::{erc20::erc20 as erc20_comp, ownable::ownable as ownable_comp}; + use ownable_comp::OwnableHelperImpl; use starknet::storage::{ - StoragePointerReadAccess, StoragePointerWriteAccess, StorageMapWriteAccess, - StorageMapReadAccess, + StorageMapReadAccess, StorageMapWriteAccess, StoragePointerReadAccess, + StoragePointerWriteAccess, }; - use crate::components::erc20::erc20 as erc20_comp; - use crate::components::ownable::ownable as ownable_comp; - use ownable_comp::OwnableHelperImpl; + use starknet::{ContractAddress, contract_address_const}; #[storage] pub struct Storage {} diff --git a/crates/cairo-lang-starknet/cairo_level_tests/components/upgradable.cairo b/crates/cairo-lang-starknet/cairo_level_tests/components/upgradable.cairo index c90532be651..943278f220e 100644 --- a/crates/cairo-lang-starknet/cairo_level_tests/components/upgradable.cairo +++ b/crates/cairo-lang-starknet/cairo_level_tests/components/upgradable.cairo @@ -5,11 +5,10 @@ pub trait IUpgradable { } #[starknet::component] pub mod upgradable { - use starknet::storage::{StoragePointerReadAccess, StoragePointerWriteAccess}; - use starknet::ClassHash; - use starknet::syscalls::replace_class_syscall; use crate::components::ownable::ownable as ownable_comp; use ownable_comp::OwnableHelperImpl; + use starknet::storage::{StoragePointerReadAccess, StoragePointerWriteAccess}; + use starknet::{ClassHash, syscalls::replace_class_syscall}; #[storage] pub struct Storage { pub current_implementation: ClassHash, diff --git a/crates/cairo-lang-starknet/cairo_level_tests/contract_tests.cairo b/crates/cairo-lang-starknet/cairo_level_tests/contract_tests.cairo index 57c9f75decf..69786f56d1a 100644 --- a/crates/cairo-lang-starknet/cairo_level_tests/contract_tests.cairo +++ b/crates/cairo-lang-starknet/cairo_level_tests/contract_tests.cairo @@ -1,5 +1,4 @@ use core::num::traits::Zero; - use super::utils::serialized; #[starknet::interface] @@ -9,8 +8,8 @@ trait ITestContract {} mod test_contract { use starknet::StorageAddress; use starknet::storage::{ - Map, StoragePointerReadAccess, StoragePointerWriteAccess, StorageMapReadAccess, - StorageMapWriteAccess, + Map, StorageMapReadAccess, StorageMapWriteAccess, StoragePointerReadAccess, + StoragePointerWriteAccess, }; #[storage] diff --git a/crates/cairo-lang-starknet/cairo_level_tests/contracts.cairo b/crates/cairo-lang-starknet/cairo_level_tests/contracts.cairo index d0002019263..39160e5b25a 100644 --- a/crates/cairo-lang-starknet/cairo_level_tests/contracts.cairo +++ b/crates/cairo-lang-starknet/cairo_level_tests/contracts.cairo @@ -1,18 +1,18 @@ -pub mod multi_component; mod account; mod circuit_contract; -pub mod test_contract; -mod new_syntax_test_contract; -mod minimal_contract; -mod hello_starknet; pub mod erc20; +mod hello_starknet; +mod libfuncs_coverage; +mod minimal_contract; +mod mintable; +pub mod multi_component; +mod new_syntax_test_contract; +mod ownable_erc20; +mod storage_accesses; +pub mod test_contract; mod token_bridge; +mod upgradable_counter; mod with_erc20; +mod with_erc20_mini; mod with_ownable; -mod ownable_erc20; -mod upgradable_counter; -mod mintable; -mod storage_accesses; mod with_ownable_mini; -mod with_erc20_mini; -mod libfuncs_coverage; diff --git a/crates/cairo-lang-starknet/cairo_level_tests/contracts/account.cairo b/crates/cairo-lang-starknet/cairo_level_tests/contracts/account.cairo index a01586352b3..43dc4dd040f 100644 --- a/crates/cairo-lang-starknet/cairo_level_tests/contracts/account.cairo +++ b/crates/cairo-lang-starknet/cairo_level_tests/contracts/account.cairo @@ -1,9 +1,8 @@ #[starknet::contract(account)] mod account { - use core::num::traits::Zero; - use core::ecdsa::check_ecdsa_signature; - use starknet::{account::Call, syscalls::call_contract_syscall, SyscallResultTrait}; + use core::{ecdsa::check_ecdsa_signature, num::traits::Zero}; use starknet::storage::{StoragePointerReadAccess, StoragePointerWriteAccess}; + use starknet::{SyscallResultTrait, account::Call, syscalls::call_contract_syscall}; #[storage] struct Storage { diff --git a/crates/cairo-lang-starknet/cairo_level_tests/contracts/circuit_contract.cairo b/crates/cairo-lang-starknet/cairo_level_tests/contracts/circuit_contract.cairo index 510fd154e8b..64e3c3f018d 100644 --- a/crates/cairo-lang-starknet/cairo_level_tests/contracts/circuit_contract.cairo +++ b/crates/cairo-lang-starknet/cairo_level_tests/contracts/circuit_contract.cairo @@ -1,8 +1,8 @@ #[starknet::contract] mod circuit_contract { use core::circuit::{ - CircuitElement, CircuitInput, circuit_add, circuit_inverse, CircuitModulus, - AddInputResultTrait, CircuitInputs, EvalCircuitTrait, + AddInputResultTrait, CircuitElement, CircuitInput, CircuitInputs, CircuitModulus, + EvalCircuitTrait, circuit_add, circuit_inverse, }; #[storage] diff --git a/crates/cairo-lang-starknet/cairo_level_tests/contracts/erc20.cairo b/crates/cairo-lang-starknet/cairo_level_tests/contracts/erc20.cairo index 612a602ea06..456acccf9ad 100644 --- a/crates/cairo-lang-starknet/cairo_level_tests/contracts/erc20.cairo +++ b/crates/cairo-lang-starknet/cairo_level_tests/contracts/erc20.cairo @@ -22,13 +22,11 @@ pub trait IERC20 { #[starknet::contract] pub mod erc_20 { use core::num::traits::Zero; - use starknet::get_caller_address; - use starknet::contract_address_const; - use starknet::ContractAddress; use starknet::storage::{ - Map, StoragePointerReadAccess, StoragePointerWriteAccess, StorageMapReadAccess, - StorageMapWriteAccess, + Map, StorageMapReadAccess, StorageMapWriteAccess, StoragePointerReadAccess, + StoragePointerWriteAccess, }; + use starknet::{ContractAddress, contract_address_const, get_caller_address}; #[storage] struct Storage { diff --git a/crates/cairo-lang-starknet/cairo_level_tests/contracts/libfuncs_coverage.cairo b/crates/cairo-lang-starknet/cairo_level_tests/contracts/libfuncs_coverage.cairo index b5853265c1b..28953d86606 100644 --- a/crates/cairo-lang-starknet/cairo_level_tests/contracts/libfuncs_coverage.cairo +++ b/crates/cairo-lang-starknet/cairo_level_tests/contracts/libfuncs_coverage.cairo @@ -1,7 +1,5 @@ use core::dict::{Felt252Dict, Felt252DictEntryTrait}; -use starknet::storage::StoragePathEntry; -use starknet::storage::StoragePointerWriteAccess; -use starknet::storage::StoragePointerReadAccess; +use starknet::storage::{StoragePathEntry, StoragePointerReadAccess, StoragePointerWriteAccess}; #[starknet::contract] mod libfuncs_coverage { @@ -233,7 +231,6 @@ fn all_libfuncs(libfuncs: Libfuncs) { Libfuncs::Snapshot(libfuncs) => snapshot_libfuncs(libfuncs), } } - use core::num::traits::Sqrt; use core::traits::{BitAnd, BitOr, BitXor}; @@ -405,11 +402,10 @@ fn nullable_libfuncs>, +Destruct>(libfuncs: Nullable NullableLibfuncs::Deref(nullable) => use_and_panic(nullable.deref()), } } - use core::circuit::{ - circuit_add, circuit_inverse, circuit_mul, circuit_sub, u384, AddInputResultTrait, - CircuitElement, CircuitInput, CircuitInputs, CircuitModulus, CircuitOutputsTrait, - EvalCircuitTrait, + AddInputResultTrait, CircuitElement, CircuitInput, CircuitInputs, CircuitModulus, + CircuitOutputsTrait, EvalCircuitTrait, circuit_add, circuit_inverse, circuit_mul, circuit_sub, + u384, }; fn circuit_libfuncs(n: u384, input0: u384, input1: u384) { @@ -431,8 +427,7 @@ fn circuit_libfuncs(n: u384, input0: u384, input1: u384) { .unwrap(); use_and_panic(outputs.get_output(add)); } - -use starknet::secp256_trait::{Secp256Trait, Secp256PointTrait, is_valid_signature, Signature}; +use starknet::secp256_trait::{Secp256PointTrait, Secp256Trait, Signature, is_valid_signature}; fn secp_libfuncs< Secp256Point, @@ -451,7 +446,6 @@ fn secp_libfuncs< trait Foo { fn foo(ref self: TContractState); } - use starknet::syscalls; fn starknet_libfuncs(libfuncs: StarknetLibfuncs) { @@ -495,9 +489,10 @@ extern fn i32_const() -> i32 nopanic; extern fn i64_const() -> i64 nopanic; extern fn i128_const() -> i128 nopanic; extern fn bytes31_const() -> bytes31 nopanic; -use starknet::storage_access::storage_base_address_const; -use starknet::contract_address::contract_address_const; -use starknet::class_hash::class_hash_const; +use starknet::{ + class_hash::class_hash_const, contract_address::contract_address_const, + storage_access::storage_base_address_const, +}; fn consts_libfuncs(libfuncs: ConstsLibfuncs) { match libfuncs { diff --git a/crates/cairo-lang-starknet/cairo_level_tests/contracts/mintable.cairo b/crates/cairo-lang-starknet/cairo_level_tests/contracts/mintable.cairo index 9200414c5c8..71e299a1dc2 100644 --- a/crates/cairo-lang-starknet/cairo_level_tests/contracts/mintable.cairo +++ b/crates/cairo-lang-starknet/cairo_level_tests/contracts/mintable.cairo @@ -5,10 +5,11 @@ trait GetSupply { #[starknet::contract] mod mintable_erc20_ownable { + use crate::components::{ + erc20::erc20 as erc20_comp, mintable::mintable as mintable_comp, + ownable::ownable as ownable_comp, + }; use starknet::ContractAddress; - use crate::components::erc20::erc20 as erc20_comp; - use crate::components::ownable::ownable as ownable_comp; - use crate::components::mintable::mintable as mintable_comp; #[storage] struct Storage { #[substorage(v0)] diff --git a/crates/cairo-lang-starknet/cairo_level_tests/contracts/multi_component.cairo b/crates/cairo-lang-starknet/cairo_level_tests/contracts/multi_component.cairo index b78b74c2642..4cf21ab00a6 100644 --- a/crates/cairo-lang-starknet/cairo_level_tests/contracts/multi_component.cairo +++ b/crates/cairo-lang-starknet/cairo_level_tests/contracts/multi_component.cairo @@ -5,11 +5,11 @@ pub trait GetSupply { #[starknet::contract] pub mod contract_with_4_components { + use crate::components::{ + erc20::erc20 as erc20_comp, mintable::mintable as mintable_comp, + ownable::ownable as ownable_comp, upgradable::upgradable as upgradable_comp, + }; use starknet::ContractAddress; - use crate::components::erc20::erc20 as erc20_comp; - use crate::components::ownable::ownable as ownable_comp; - use crate::components::mintable::mintable as mintable_comp; - use crate::components::upgradable::upgradable as upgradable_comp; #[storage] struct Storage { #[substorage(v0)] diff --git a/crates/cairo-lang-starknet/cairo_level_tests/contracts/new_syntax_test_contract.cairo b/crates/cairo-lang-starknet/cairo_level_tests/contracts/new_syntax_test_contract.cairo index 2ca1004d974..555a8158a20 100644 --- a/crates/cairo-lang-starknet/cairo_level_tests/contracts/new_syntax_test_contract.cairo +++ b/crates/cairo-lang-starknet/cairo_level_tests/contracts/new_syntax_test_contract.cairo @@ -17,8 +17,10 @@ struct OutOfScopeEvent {} #[starknet::contract] mod counter_contract { use starknet::ContractAddress; - use super::{IOtherContractDispatcher, IOtherContractDispatcherTrait, OutOfScopeEvent}; use starknet::storage::{StoragePointerReadAccess, StoragePointerWriteAccess}; + use super::IOtherContractDispatcher; + use super::IOtherContractDispatcherTrait; + use super::OutOfScopeEvent; component!(path: super::test_component, storage: test_component_storage, event: ABC); diff --git a/crates/cairo-lang-starknet/cairo_level_tests/contracts/ownable_erc20.cairo b/crates/cairo-lang-starknet/cairo_level_tests/contracts/ownable_erc20.cairo index 279c26e3fcb..230a6e98060 100644 --- a/crates/cairo-lang-starknet/cairo_level_tests/contracts/ownable_erc20.cairo +++ b/crates/cairo-lang-starknet/cairo_level_tests/contracts/ownable_erc20.cairo @@ -1,7 +1,6 @@ #[starknet::contract] mod ownable_erc20_contract { - use crate::components::erc20::erc20 as erc20_comp; - use crate::components::ownable::ownable as ownable_comp; + use crate::components::{erc20::erc20 as erc20_comp, ownable::ownable as ownable_comp}; use starknet::ContractAddress; #[storage] struct Storage { diff --git a/crates/cairo-lang-starknet/cairo_level_tests/contracts/storage_accesses.cairo b/crates/cairo-lang-starknet/cairo_level_tests/contracts/storage_accesses.cairo index 5bceab8706d..d42a4ecfcad 100644 --- a/crates/cairo-lang-starknet/cairo_level_tests/contracts/storage_accesses.cairo +++ b/crates/cairo-lang-starknet/cairo_level_tests/contracts/storage_accesses.cairo @@ -1,5 +1,4 @@ -use starknet::ContractAddress; -use starknet::storage::Map; +use starknet::{ContractAddress, storage::Map}; #[starknet::interface] trait IERC20 { @@ -34,13 +33,13 @@ struct TransactionInfo { #[starknet::contract] mod storage_accesses { use core::num::traits::Zero; - use starknet::get_caller_address; - use starknet::ContractAddress; - use super::{UserInfo, TransactionInfo}; use starknet::storage::{ - StoragePathEntry, StoragePointerReadAccess, StoragePointerWriteAccess, StorageMapReadAccess, - StorageMapWriteAccess, + StorageMapReadAccess, StorageMapWriteAccess, StoragePathEntry, StoragePointerReadAccess, + StoragePointerWriteAccess, }; + use starknet::{ContractAddress, get_caller_address}; + use super::TransactionInfo; + use super::UserInfo; #[storage] struct Storage { diff --git a/crates/cairo-lang-starknet/cairo_level_tests/contracts/test_contract.cairo b/crates/cairo-lang-starknet/cairo_level_tests/contracts/test_contract.cairo index decc4b4c806..d59fa2230a0 100644 --- a/crates/cairo-lang-starknet/cairo_level_tests/contracts/test_contract.cairo +++ b/crates/cairo-lang-starknet/cairo_level_tests/contracts/test_contract.cairo @@ -16,12 +16,12 @@ impl OutsideImpl> of OutsideTrait { #[starknet::contract] mod token_bridge { - use starknet::storage::{StoragePointerReadAccess, StoragePointerWriteAccess}; use core::num::traits::Zero; - use starknet::SyscallResultTrait; + use starknet::storage::{StoragePointerReadAccess, StoragePointerWriteAccess}; use starknet::{ - ContractAddress, get_caller_address, EthAddress, syscalls::send_message_to_l1_syscall, + ContractAddress, EthAddress, SyscallResultTrait, get_caller_address, + syscalls::send_message_to_l1_syscall, }; - use super::{IMintableTokenDispatcher, IMintableTokenDispatcherTrait}; + use super::IMintableTokenDispatcher; + use super::IMintableTokenDispatcherTrait; const WITHDRAW_MESSAGE: felt252 = 0; const CONTRACT_IDENTITY: felt252 = 'STARKGATE'; diff --git a/crates/cairo-lang-starknet/cairo_level_tests/contracts/upgradable_counter.cairo b/crates/cairo-lang-starknet/cairo_level_tests/contracts/upgradable_counter.cairo index f62124108c1..65f1dbabe46 100644 --- a/crates/cairo-lang-starknet/cairo_level_tests/contracts/upgradable_counter.cairo +++ b/crates/cairo-lang-starknet/cairo_level_tests/contracts/upgradable_counter.cairo @@ -7,9 +7,10 @@ trait ICounterContract { #[starknet::contract] mod counter_contract { - use starknet::storage::{StoragePointerWriteAccess, StoragePointerReadAccess}; - use crate::components::upgradable::upgradable as upgradable_comp; - use crate::components::ownable::ownable as ownable_comp; + use crate::components::{ + ownable::ownable as ownable_comp, upgradable::upgradable as upgradable_comp, + }; + use starknet::storage::{StoragePointerReadAccess, StoragePointerWriteAccess}; component!(path: upgradable_comp, storage: upgradable, event: UpgradableEvent); component!(path: ownable_comp, storage: ownable, event: OwnableEvent); diff --git a/crates/cairo-lang-starknet/cairo_level_tests/contracts/with_erc20_mini.cairo b/crates/cairo-lang-starknet/cairo_level_tests/contracts/with_erc20_mini.cairo index d818c2292f4..4fab7ae316d 100644 --- a/crates/cairo-lang-starknet/cairo_level_tests/contracts/with_erc20_mini.cairo +++ b/crates/cairo-lang-starknet/cairo_level_tests/contracts/with_erc20_mini.cairo @@ -2,7 +2,7 @@ mod erc20_mini_contract { use crate::components::erc20_mini; use starknet::ContractAddress; - use starknet::storage::{StorageTraitMut, StorageTrait}; + use starknet::storage::{StorageTrait, StorageTraitMut}; #[storage] struct Storage { #[flat] diff --git a/crates/cairo-lang-starknet/cairo_level_tests/contracts/with_ownable.cairo b/crates/cairo-lang-starknet/cairo_level_tests/contracts/with_ownable.cairo index e29b10cbbd5..aca050afb7c 100644 --- a/crates/cairo-lang-starknet/cairo_level_tests/contracts/with_ownable.cairo +++ b/crates/cairo-lang-starknet/cairo_level_tests/contracts/with_ownable.cairo @@ -1,8 +1,8 @@ #[starknet::contract] mod ownable_balance { - use starknet::storage::{StoragePointerReadAccess, StoragePointerWriteAccess}; use crate::components::ownable::ownable as ownable_comp; use starknet::ContractAddress; + use starknet::storage::{StoragePointerReadAccess, StoragePointerWriteAccess}; #[storage] struct Storage { #[substorage(v0)] diff --git a/crates/cairo-lang-starknet/cairo_level_tests/deployment.cairo b/crates/cairo-lang-starknet/cairo_level_tests/deployment.cairo index 238d5c0d8e5..1a2b71b2f44 100644 --- a/crates/cairo-lang-starknet/cairo_level_tests/deployment.cairo +++ b/crates/cairo-lang-starknet/cairo_level_tests/deployment.cairo @@ -9,7 +9,8 @@ trait IValue { #[starknet::contract] mod self_caller { use starknet::storage::{StoragePointerReadAccess, StoragePointerWriteAccess}; - use super::{IValueDispatcher, IValueDispatcherTrait}; + use super::IValueDispatcher; + use super::IValueDispatcherTrait; #[storage] struct Storage { value: felt252, diff --git a/crates/cairo-lang-starknet/cairo_level_tests/erc20_test.cairo b/crates/cairo-lang-starknet/cairo_level_tests/erc20_test.cairo index c13a30a93ec..bffac3ba809 100644 --- a/crates/cairo-lang-starknet/cairo_level_tests/erc20_test.cairo +++ b/crates/cairo-lang-starknet/cairo_level_tests/erc20_test.cairo @@ -1,7 +1,5 @@ -use crate::contracts::erc20::{erc_20, IERC20LibraryDispatcher, IERC20DispatcherTrait}; -use starknet::testing::set_caller_address; - -use starknet::contract_address::contract_address_const; +use crate::contracts::erc20::{IERC20DispatcherTrait, IERC20LibraryDispatcher, erc_20}; +use starknet::{contract_address::contract_address_const, testing::set_caller_address}; #[test] fn test_erc20_transfer() { diff --git a/crates/cairo-lang-starknet/cairo_level_tests/events.cairo b/crates/cairo-lang-starknet/cairo_level_tests/events.cairo index 93d654eb76c..a62c2abeac8 100644 --- a/crates/cairo-lang-starknet/cairo_level_tests/events.cairo +++ b/crates/cairo-lang-starknet/cairo_level_tests/events.cairo @@ -1,5 +1,4 @@ -use starknet::syscalls::deploy_syscall; -use starknet::SyscallResultTrait; +use starknet::{SyscallResultTrait, syscalls::deploy_syscall}; #[starknet::interface] trait IContractWithEvent { @@ -58,8 +57,7 @@ mod contract_with_event { self.emit(FlatEvent::FlatEvent(StaticEvent {})); } } - -use contract_with_event::{Event, IncrementalEvent, StaticEvent, FlatEvent}; +use contract_with_event::{Event, FlatEvent, IncrementalEvent, StaticEvent}; #[test] fn test_events() { diff --git a/crates/cairo-lang-starknet/cairo_level_tests/flat_storage_test.cairo b/crates/cairo-lang-starknet/cairo_level_tests/flat_storage_test.cairo index b4b41928b04..34694c41f12 100644 --- a/crates/cairo-lang-starknet/cairo_level_tests/flat_storage_test.cairo +++ b/crates/cairo-lang-starknet/cairo_level_tests/flat_storage_test.cairo @@ -1,4 +1,4 @@ -use core::starknet::storage::{StoragePointerWriteAccess, StoragePointerReadAccess}; +use core::starknet::storage::{StoragePointerReadAccess, StoragePointerWriteAccess}; #[starknet::storage_node] struct Struct1 { diff --git a/crates/cairo-lang-starknet/cairo_level_tests/interoperability.cairo b/crates/cairo-lang-starknet/cairo_level_tests/interoperability.cairo index 37ca8ab14c2..b420f2cd81b 100644 --- a/crates/cairo-lang-starknet/cairo_level_tests/interoperability.cairo +++ b/crates/cairo-lang-starknet/cairo_level_tests/interoperability.cairo @@ -1,5 +1,5 @@ -use starknet::syscalls::{deploy_syscall, get_block_hash_syscall}; use starknet::SyscallResultTrait; +use starknet::syscalls::{deploy_syscall, get_block_hash_syscall}; #[starknet::interface] trait IContract { @@ -34,7 +34,6 @@ mod contract_a { } } } - use contract_a::MyTrait; #[test] fn test_internal_func() { diff --git a/crates/cairo-lang-starknet/cairo_level_tests/l2_to_l1_messages.cairo b/crates/cairo-lang-starknet/cairo_level_tests/l2_to_l1_messages.cairo index c92a1592610..1cabfbd2c35 100644 --- a/crates/cairo-lang-starknet/cairo_level_tests/l2_to_l1_messages.cairo +++ b/crates/cairo-lang-starknet/cairo_level_tests/l2_to_l1_messages.cairo @@ -1,13 +1,11 @@ -use starknet::{testing, SyscallResultTrait}; - use contract_with_messages_sent_to_l1::IContractWithMessagesSentToL1; +use starknet::{SyscallResultTrait, testing}; #[starknet::contract] mod contract_with_messages_sent_to_l1 { + use core::array::ArrayTrait; use starknet::SyscallResultTrait; use starknet::storage::{StoragePointerReadAccess, StoragePointerWriteAccess}; - use core::array::ArrayTrait; - use super::generate_payload; #[storage] diff --git a/crates/cairo-lang-starknet/cairo_level_tests/lib.cairo b/crates/cairo-lang-starknet/cairo_level_tests/lib.cairo index d9c973a18fc..ff4c468e48d 100644 --- a/crates/cairo-lang-starknet/cairo_level_tests/lib.cairo +++ b/crates/cairo-lang-starknet/cairo_level_tests/lib.cairo @@ -1,15 +1,23 @@ #[cfg(test)] mod abi_dispatchers_tests; +#[cfg(test)] +mod collections_test; +#[cfg(test)] +mod component_usage_test; mod components; -mod contracts; +#[cfg(test)] +mod contract_address_test; #[cfg(test)] mod contract_tests; +mod contracts; #[cfg(test)] mod deployment; #[cfg(test)] +mod erc20_test; +#[cfg(test)] mod events; #[cfg(test)] -mod erc20_test; +mod flat_storage_test; #[cfg(test)] mod interoperability; #[cfg(test)] @@ -19,17 +27,9 @@ mod l2_to_l1_messages; #[cfg(test)] mod multi_component_test; #[cfg(test)] +mod renamed_storage_test; +#[cfg(test)] mod replace_class_test; #[cfg(test)] mod storage_access; -#[cfg(test)] -mod contract_address_test; mod utils; -#[cfg(test)] -mod collections_test; -#[cfg(test)] -mod component_usage_test; -#[cfg(test)] -mod flat_storage_test; -#[cfg(test)] -mod renamed_storage_test; diff --git a/crates/cairo-lang-starknet/cairo_level_tests/multi_component_test.cairo b/crates/cairo-lang-starknet/cairo_level_tests/multi_component_test.cairo index 34aabd5e2df..a6f9a175737 100644 --- a/crates/cairo-lang-starknet/cairo_level_tests/multi_component_test.cairo +++ b/crates/cairo-lang-starknet/cairo_level_tests/multi_component_test.cairo @@ -1,8 +1,8 @@ -use super::utils::serialized; -use crate::components::mintable::{MintTraitDispatcherTrait, MintTraitDispatcher}; +use crate::components::mintable::{MintTraitDispatcher, MintTraitDispatcherTrait}; use crate::contracts::multi_component::{ - contract_with_4_components, GetSupplyDispatcher, GetSupplyDispatcherTrait, + GetSupplyDispatcher, GetSupplyDispatcherTrait, contract_with_4_components, }; +use super::utils::serialized; #[test] fn test_flow() { diff --git a/crates/cairo-lang-starknet/cairo_level_tests/renamed_storage_test.cairo b/crates/cairo-lang-starknet/cairo_level_tests/renamed_storage_test.cairo index 2c8255ffde9..f5b074dfe57 100644 --- a/crates/cairo-lang-starknet/cairo_level_tests/renamed_storage_test.cairo +++ b/crates/cairo-lang-starknet/cairo_level_tests/renamed_storage_test.cairo @@ -1,4 +1,4 @@ -use core::starknet::storage::{StoragePointerWriteAccess, StoragePointerReadAccess}; +use core::starknet::storage::{StoragePointerReadAccess, StoragePointerWriteAccess}; #[starknet::storage_node] struct A { diff --git a/crates/cairo-lang-starknet/cairo_level_tests/replace_class_test.cairo b/crates/cairo-lang-starknet/cairo_level_tests/replace_class_test.cairo index 916ae138171..bd07a894119 100644 --- a/crates/cairo-lang-starknet/cairo_level_tests/replace_class_test.cairo +++ b/crates/cairo-lang-starknet/cairo_level_tests/replace_class_test.cairo @@ -1,6 +1,6 @@ -use starknet::syscalls::{deploy_syscall, get_class_hash_at_syscall}; -use starknet::class_hash::{class_hash_const, ClassHash}; +use starknet::class_hash::{ClassHash, class_hash_const}; use starknet::contract_address::contract_address_const; +use starknet::syscalls::{deploy_syscall, get_class_hash_at_syscall}; #[starknet::interface] trait IWithReplace { @@ -9,9 +9,7 @@ trait IWithReplace { #[starknet::contract] mod contract_a { - use starknet::storage::StoragePointerWriteAccess; - use starknet::class_hash::ClassHash; - use starknet::SyscallResultTrait; + use starknet::{SyscallResultTrait, class_hash::ClassHash, storage::StoragePointerWriteAccess}; #[storage] struct Storage { diff --git a/crates/cairo-lang-starknet/cairo_level_tests/storage_access.cairo b/crates/cairo-lang-starknet/cairo_level_tests/storage_access.cairo index ea6b27a00d8..53538a1a191 100644 --- a/crates/cairo-lang-starknet/cairo_level_tests/storage_access.cairo +++ b/crates/cairo-lang-starknet/cairo_level_tests/storage_access.cairo @@ -1,10 +1,8 @@ -use starknet::{ClassHash, ContractAddress, EthAddress, StorageAddress}; -use super::utils::{deserialized, serialized}; - #[feature("deprecated-bounded-int-trait")] use core::integer::BoundedInt; use core::num::traits::Zero; -use starknet::storage::Vec; +use starknet::{ClassHash, ContractAddress, EthAddress, StorageAddress, storage::Vec}; +use super::utils::{deserialized, serialized}; impl StorageAddressPartialEq of PartialEq { fn eq(lhs: @StorageAddress, rhs: @StorageAddress) -> bool { @@ -98,13 +96,16 @@ enum QueryableEnum { #[starknet::contract] mod test_contract { use core::starknet::storage::{SubPointersForward, SubPointersMutForward}; - use super::{ - AbcEtc, ByteArrays, NonZeros, Vecs, QueryableEnum, QueryableEnumVariants, - QueryableEnumVariantsMut, - }; use starknet::storage::{ - VecTrait, MutableVecTrait, StoragePointerWriteAccess, StoragePointerReadAccess, + MutableVecTrait, StoragePointerReadAccess, StoragePointerWriteAccess, VecTrait, }; + use super::AbcEtc; + use super::ByteArrays; + use super::NonZeros; + use super::QueryableEnum; + use super::QueryableEnumVariants; + use super::QueryableEnumVariantsMut; + use super::Vecs; #[storage] struct Storage { diff --git a/crates/cairo-lang-starknet/src/plugin/plugin_test_data/contracts/contract b/crates/cairo-lang-starknet/src/plugin/plugin_test_data/contracts/contract index 9d0ff9c6747..ed0626f0b4b 100644 --- a/crates/cairo-lang-starknet/src/plugin/plugin_test_data/contracts/contract +++ b/crates/cairo-lang-starknet/src/plugin/plugin_test_data/contracts/contract @@ -6,9 +6,9 @@ ExpandContractTestRunner(expect_diagnostics: false) //! > cairo_code #[starknet::contract] mod test_contract { - use starknet::class_hash::ClassHash; - use starknet::contract_address::ContractAddress; - use starknet::storage_access::StorageAddress; + use starknet::{ + class_hash::ClassHash, contract_address::ContractAddress, storage_access::StorageAddress, + }; #[storage] struct Storage {} @@ -59,9 +59,9 @@ lib.cairo: #[starknet::contract] mod test_contract { - use starknet::class_hash::ClassHash; - use starknet::contract_address::ContractAddress; - use starknet::storage_access::StorageAddress; + use starknet::{ + class_hash::ClassHash, contract_address::ContractAddress, storage_access::StorageAddress, + }; #[storage] struct Storage {} @@ -178,7 +178,7 @@ pub fn contract_state_for_testing() -> ContractState { #[allow(unused_imports)] use starknet::storage::Map as LegacyMap; #[cfg(target: 'test')] -pub const TEST_CLASS_HASH: felt252 = 0x50afb5642ad6a435e97435ad44ec6060db9755b206a962ddf6d6cbb4a8b99d; +pub const TEST_CLASS_HASH: felt252 = 0x7d78bbc63d0935bbe4605338d9056b8e40dfba68144cf5e32c7fc07a671eb4; #[doc(hidden)] #[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] diff --git a/crates/cairo-lang-starknet/src/plugin/plugin_test_data/contracts/diagnostics b/crates/cairo-lang-starknet/src/plugin/plugin_test_data/contracts/diagnostics index 63b3bf45b2b..c3c413a8137 100644 --- a/crates/cairo-lang-starknet/src/plugin/plugin_test_data/contracts/diagnostics +++ b/crates/cairo-lang-starknet/src/plugin/plugin_test_data/contracts/diagnostics @@ -11980,7 +11980,6 @@ trait ContractTrait { #[starknet::contract] mod contract { component!(path: super::test_component, storage: component_member, event: CompEvent); - use super::ContractTrait; #[storage] struct Storage { @@ -12007,7 +12006,7 @@ mod contract { error[E0002]: Method `write` could not be called on type `core::starknet::storage::storage_base::StorageBase::`. Candidate `core::starknet::storage::map::StorageMapWriteAccess::write` inference failed with: Trait has no implementation in context: core::starknet::storage::map::StorageMapWriteAccess::>. Candidate `core::starknet::storage::StoragePointerWriteAccess::write` inference failed with: Trait has no implementation in context: core::starknet::storage::StoragePointerWriteAccess::>. - --> lib.cairo:35:40 + --> lib.cairo:34:40 self.component_member.data.write(); ^^^^^ @@ -12030,7 +12029,6 @@ trait ContractTrait { #[starknet::contract] mod contract { component!(path: super::test_component, storage: component_member, event: CompEvent); - use super::ContractTrait; #[storage] struct Storage { @@ -12836,7 +12834,7 @@ pub fn contract_state_for_testing() -> ContractState { #[allow(unused_imports)] use starknet::storage::Map as LegacyMap; #[cfg(target: 'test')] -pub const TEST_CLASS_HASH: felt252 = 0x3ce880c1c1fe3435239eab46a6ebc0ff304b8a4b4eb9e2c683d2ddb2746437f; +pub const TEST_CLASS_HASH: felt252 = 0x29df08f1d7a448905745936c947da165c96a5e2fdbd90ffd2bdabbc7a7e0b1d; #[doc(hidden)] #[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] @@ -12905,7 +12903,7 @@ impl HasComponentImpl_test_component of super::test_component::HasComponent; -lib.cairo:26:20 +lib.cairo:25:20 #[derive(Drop, starknet::Event)] ^^^^^^^^^^^^^^^ starknet_derive: @@ -12952,7 +12950,7 @@ impl EventCompEventIntoEvent of Into { -lib.cairo:19:5 +lib.cairo:18:5 #[storage] ^^^^^^^^^^ impls: @@ -12961,7 +12959,7 @@ impl StorageStorageBaseDrop of core::traits::Drop::; impl StorageStorageBaseCopy of core::traits::Copy::; -lib.cairo:19:5 +lib.cairo:18:5 #[storage] ^^^^^^^^^^ impls: diff --git a/crates/cairo-lang-starknet/src/plugin/plugin_test_data/contracts/mintable b/crates/cairo-lang-starknet/src/plugin/plugin_test_data/contracts/mintable index bea866908ad..8bdf1ee4632 100644 --- a/crates/cairo-lang-starknet/src/plugin/plugin_test_data/contracts/mintable +++ b/crates/cairo-lang-starknet/src/plugin/plugin_test_data/contracts/mintable @@ -14,10 +14,11 @@ trait GetSupply { #[starknet::contract] mod mintable_erc20_ownable { + use crate::components::{ + erc20::erc20 as erc20_comp, mintable::mintable as mintable_comp, + ownable::ownable as ownable_comp, + }; use starknet::ContractAddress; - use crate::components::erc20::erc20 as erc20_comp; - use crate::components::ownable::ownable as ownable_comp; - use crate::components::mintable::mintable as mintable_comp; #[storage] struct Storage { #[substorage(v0)] @@ -870,10 +871,11 @@ impl GetSupplySafeDispatcherSubPointersCopy of core::traits::Copy::; impl GetSupplySafeDispatcherSubPointersMutCopy of core::traits::Copy::; + use crate::components::{ + erc20::erc20 as erc20_comp, mintable::mintable as mintable_comp, + ownable::ownable as ownable_comp, + }; use starknet::ContractAddress; - use crate::components::erc20::erc20 as erc20_comp; - use crate::components::ownable::ownable as ownable_comp; - use crate::components::mintable::mintable as mintable_comp; #[storage] struct Storage { #[substorage(v0)] diff --git a/crates/cairo-lang-starknet/src/plugin/plugin_test_data/contracts/multi_component b/crates/cairo-lang-starknet/src/plugin/plugin_test_data/contracts/multi_component index 05dd4386827..ac49a4fbec3 100644 --- a/crates/cairo-lang-starknet/src/plugin/plugin_test_data/contracts/multi_component +++ b/crates/cairo-lang-starknet/src/plugin/plugin_test_data/contracts/multi_component @@ -14,11 +14,11 @@ pub trait GetSupply { #[starknet::contract] pub mod contract_with_4_components { + use crate::components::{ + erc20::erc20 as erc20_comp, mintable::mintable as mintable_comp, + ownable::ownable as ownable_comp, upgradable::upgradable as upgradable_comp, + }; use starknet::ContractAddress; - use crate::components::erc20::erc20 as erc20_comp; - use crate::components::ownable::ownable as ownable_comp; - use crate::components::mintable::mintable as mintable_comp; - use crate::components::upgradable::upgradable as upgradable_comp; #[storage] struct Storage { #[substorage(v0)] @@ -930,11 +930,11 @@ impl GetSupplySafeDispatcherSubPointersCopy of core::traits::Copy::; impl GetSupplySafeDispatcherSubPointersMutCopy of core::traits::Copy::; + use crate::components::{ + erc20::erc20 as erc20_comp, mintable::mintable as mintable_comp, + ownable::ownable as ownable_comp, upgradable::upgradable as upgradable_comp, + }; use starknet::ContractAddress; - use crate::components::erc20::erc20 as erc20_comp; - use crate::components::ownable::ownable as ownable_comp; - use crate::components::mintable::mintable as mintable_comp; - use crate::components::upgradable::upgradable as upgradable_comp; #[storage] struct Storage { #[substorage(v0)] diff --git a/crates/cairo-lang-starknet/src/plugin/plugin_test_data/contracts/new_storage_interface b/crates/cairo-lang-starknet/src/plugin/plugin_test_data/contracts/new_storage_interface index 2b0165441fe..501e73e4491 100644 --- a/crates/cairo-lang-starknet/src/plugin/plugin_test_data/contracts/new_storage_interface +++ b/crates/cairo-lang-starknet/src/plugin/plugin_test_data/contracts/new_storage_interface @@ -65,13 +65,15 @@ enum QueryableEnum { #[starknet::contract] mod hello_starknet { use starknet::storage::{ - StorageAsPointer, StorageAsPath, StoragePathEntry, Map, SubPointersDeref, Vec, VecTrait, - MutableVecTrait, SubPointers, SubPointersForward, SubPointersMutForward, - }; - use super::{ - BalancePair, SlicedBalancePair, SlicedBalanceTrio, LinkedList, QueryableEnum, - QueryableEnumVariants, + Map, MutableVecTrait, StorageAsPath, StorageAsPointer, StoragePathEntry, SubPointers, + SubPointersDeref, SubPointersForward, SubPointersMutForward, Vec, VecTrait, }; + use super::BalancePair; + use super::LinkedList; + use super::QueryableEnum; + use super::QueryableEnumVariants; + use super::SlicedBalancePair; + use super::SlicedBalanceTrio; #[storage] struct Storage { @@ -210,13 +212,15 @@ enum QueryableEnum { #[starknet::contract] mod hello_starknet { use starknet::storage::{ - StorageAsPointer, StorageAsPath, StoragePathEntry, Map, SubPointersDeref, Vec, VecTrait, - MutableVecTrait, SubPointers, SubPointersForward, SubPointersMutForward, - }; - use super::{ - BalancePair, SlicedBalancePair, SlicedBalanceTrio, LinkedList, QueryableEnum, - QueryableEnumVariants, + Map, MutableVecTrait, StorageAsPath, StorageAsPointer, StoragePathEntry, SubPointers, + SubPointersDeref, SubPointersForward, SubPointersMutForward, Vec, VecTrait, }; + use super::BalancePair; + use super::LinkedList; + use super::QueryableEnum; + use super::QueryableEnumVariants; + use super::SlicedBalancePair; + use super::SlicedBalanceTrio; #[storage] struct Storage { @@ -2633,7 +2637,7 @@ pub fn contract_state_for_testing() -> ContractState { #[allow(unused_imports)] use starknet::storage::Map as LegacyMap; #[cfg(target: 'test')] -pub const TEST_CLASS_HASH: felt252 = 0x1a68a3a571fad80df57476d9fabeb1f73c276067243a61aceb1727204a0bfb0; +pub const TEST_CLASS_HASH: felt252 = 0x384354420ec9ef8898b8f14416708fec97e69bb488205689fecb2dd7e8b49d9; #[doc(hidden)] #[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] @@ -3065,7 +3069,7 @@ impl EventIsEvent of starknet::Event { -lib.cairo:70:5 +lib.cairo:72:5 #[storage] ^^^^^^^^^^ impls: @@ -3074,7 +3078,7 @@ impl StorageStorageBaseDrop of core::traits::Drop::; impl StorageStorageBaseCopy of core::traits::Copy::; -lib.cairo:70:5 +lib.cairo:72:5 #[storage] ^^^^^^^^^^ impls: @@ -3092,6 +3096,6 @@ warning: Plugin diagnostic: Enum with `#[derive(starknet::Store)] has no default |_^ warning: Usage of deprecated feature `"deprecated_legacy_map"` with no `#[feature("deprecated_legacy_map")]` attribute. Note: "Use `starknet::storage::Map` instead." - --> lib.cairo:75:28 + --> lib.cairo:77:28 legacy_map_balace: LegacyMap, ^^^^^^^^^ diff --git a/crates/cairo-lang-starknet/src/plugin/plugin_test_data/contracts/ownable_erc20 b/crates/cairo-lang-starknet/src/plugin/plugin_test_data/contracts/ownable_erc20 index d323baff7ac..837831b504c 100644 --- a/crates/cairo-lang-starknet/src/plugin/plugin_test_data/contracts/ownable_erc20 +++ b/crates/cairo-lang-starknet/src/plugin/plugin_test_data/contracts/ownable_erc20 @@ -9,8 +9,7 @@ cairo_level_tests/contracts/ownable_erc20.cairo //! > generated_cairo_code #[starknet::contract] mod ownable_erc20_contract { - use crate::components::erc20::erc20 as erc20_comp; - use crate::components::ownable::ownable as ownable_comp; + use crate::components::{erc20::erc20 as erc20_comp, ownable::ownable as ownable_comp}; use starknet::ContractAddress; #[storage] struct Storage { @@ -320,8 +319,7 @@ impl StorageStorageBaseMutDrop of core::traits::Drop::; impl StorageStorageBaseMutCopy of core::traits::Copy::; } - use crate::components::erc20::erc20 as erc20_comp; - use crate::components::ownable::ownable as ownable_comp; + use crate::components::{erc20::erc20 as erc20_comp, ownable::ownable as ownable_comp}; use starknet::ContractAddress; #[storage] struct Storage { diff --git a/crates/cairo-lang-starknet/src/plugin/plugin_test_data/contracts/storage_accesses b/crates/cairo-lang-starknet/src/plugin/plugin_test_data/contracts/storage_accesses index a465fc6f0de..01e47325701 100644 --- a/crates/cairo-lang-starknet/src/plugin/plugin_test_data/contracts/storage_accesses +++ b/crates/cairo-lang-starknet/src/plugin/plugin_test_data/contracts/storage_accesses @@ -7,8 +7,7 @@ ExpandContractFromCrateTestRunner(expect_diagnostics: false) cairo_level_tests/contracts/storage_accesses.cairo //! > generated_cairo_code -use starknet::ContractAddress; -use starknet::storage::Map; +use starknet::{ContractAddress, storage::Map}; #[starknet::interface] trait IERC20 { @@ -43,13 +42,13 @@ struct TransactionInfo { #[starknet::contract] mod storage_accesses { use core::num::traits::Zero; - use starknet::get_caller_address; - use starknet::ContractAddress; - use super::{UserInfo, TransactionInfo}; use starknet::storage::{ - StoragePathEntry, StoragePointerReadAccess, StoragePointerWriteAccess, StorageMapReadAccess, - StorageMapWriteAccess, + StorageMapReadAccess, StorageMapWriteAccess, StoragePathEntry, StoragePointerReadAccess, + StoragePointerWriteAccess, }; + use starknet::{ContractAddress, get_caller_address}; + use super::TransactionInfo; + use super::UserInfo; #[storage] struct Storage { @@ -1845,13 +1844,13 @@ impl IERC20SafeDispatcherSubPointersMutDrop of core::traits::Drop::; use core::num::traits::Zero; - use starknet::get_caller_address; - use starknet::ContractAddress; - use super::{UserInfo, TransactionInfo}; use starknet::storage::{ - StoragePathEntry, StoragePointerReadAccess, StoragePointerWriteAccess, StorageMapReadAccess, - StorageMapWriteAccess, + StorageMapReadAccess, StorageMapWriteAccess, StoragePathEntry, StoragePointerReadAccess, + StoragePointerWriteAccess, }; + use starknet::{ContractAddress, get_caller_address}; + use super::TransactionInfo; + use super::UserInfo; #[storage] struct Storage { diff --git a/crates/cairo-lang-starknet/src/plugin/plugin_test_data/contracts/upgradable_counter b/crates/cairo-lang-starknet/src/plugin/plugin_test_data/contracts/upgradable_counter index 9519bec32f9..46fd896dff9 100644 --- a/crates/cairo-lang-starknet/src/plugin/plugin_test_data/contracts/upgradable_counter +++ b/crates/cairo-lang-starknet/src/plugin/plugin_test_data/contracts/upgradable_counter @@ -16,9 +16,10 @@ trait ICounterContract { #[starknet::contract] mod counter_contract { - use starknet::storage::{StoragePointerWriteAccess, StoragePointerReadAccess}; - use crate::components::upgradable::upgradable as upgradable_comp; - use crate::components::ownable::ownable as ownable_comp; + use crate::components::{ + ownable::ownable as ownable_comp, upgradable::upgradable as upgradable_comp, + }; + use starknet::storage::{StoragePointerReadAccess, StoragePointerWriteAccess}; #[storage] struct Storage { @@ -1000,9 +1001,10 @@ impl ICounterContractSafeDispatcherSubPointersCopy of core::traits::Copy::; impl ICounterContractSafeDispatcherSubPointersMutCopy of core::traits::Copy::; - use starknet::storage::{StoragePointerWriteAccess, StoragePointerReadAccess}; - use crate::components::upgradable::upgradable as upgradable_comp; - use crate::components::ownable::ownable as ownable_comp; + use crate::components::{ + ownable::ownable as ownable_comp, upgradable::upgradable as upgradable_comp, + }; + use starknet::storage::{StoragePointerReadAccess, StoragePointerWriteAccess}; #[storage] struct Storage { diff --git a/crates/cairo-lang-starknet/src/plugin/plugin_test_data/contracts/with_component_diagnostics b/crates/cairo-lang-starknet/src/plugin/plugin_test_data/contracts/with_component_diagnostics index 76f1fd7c1c5..76bb060128d 100644 --- a/crates/cairo-lang-starknet/src/plugin/plugin_test_data/contracts/with_component_diagnostics +++ b/crates/cairo-lang-starknet/src/plugin/plugin_test_data/contracts/with_component_diagnostics @@ -3159,7 +3159,6 @@ mod test_contract { #[substorage(v0)] test_component_storage: super::test_component::Storage, } - #[event] use super::Event; @@ -3204,7 +3203,6 @@ mod test_contract { #[substorage(v0)] test_component_storage: super::test_component::Storage, } - #[event] use super::Event; @@ -3484,7 +3482,7 @@ pub fn contract_state_for_testing() -> ContractState { #[allow(unused_imports)] use starknet::storage::Map as LegacyMap; #[cfg(target: 'test')] -pub const TEST_CLASS_HASH: felt252 = 0x150d2e1961908098174a1d0101315691e91ab91682760b04003683fab54f03e; +pub const TEST_CLASS_HASH: felt252 = 0x1c59c1f2e69fc61b0f9162b5cdb7fd6a0828ffb8f03548b02c3c52f2ef1c284; #[doc(hidden)] #[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] diff --git a/crates/cairo-lang-starknet/src/plugin/plugin_test_data/contracts/with_erc20_mini b/crates/cairo-lang-starknet/src/plugin/plugin_test_data/contracts/with_erc20_mini index d829d69d378..53048e8c750 100644 --- a/crates/cairo-lang-starknet/src/plugin/plugin_test_data/contracts/with_erc20_mini +++ b/crates/cairo-lang-starknet/src/plugin/plugin_test_data/contracts/with_erc20_mini @@ -11,7 +11,7 @@ cairo_level_tests/contracts/with_erc20_mini.cairo mod erc20_mini_contract { use crate::components::erc20_mini; use starknet::ContractAddress; - use starknet::storage::{StorageTraitMut, StorageTrait}; + use starknet::storage::{StorageTrait, StorageTraitMut}; #[storage] struct Storage { #[flat] @@ -242,7 +242,7 @@ impl StorageStorageBaseMutCopy of core::traits::Copy::; use crate::components::erc20_mini; use starknet::ContractAddress; - use starknet::storage::{StorageTraitMut, StorageTrait}; + use starknet::storage::{StorageTrait, StorageTraitMut}; #[storage] struct Storage { #[flat] diff --git a/crates/cairo-lang-starknet/src/plugin/plugin_test_data/contracts/with_ownable b/crates/cairo-lang-starknet/src/plugin/plugin_test_data/contracts/with_ownable index a60bf65abcb..c18a38dc38f 100644 --- a/crates/cairo-lang-starknet/src/plugin/plugin_test_data/contracts/with_ownable +++ b/crates/cairo-lang-starknet/src/plugin/plugin_test_data/contracts/with_ownable @@ -9,9 +9,9 @@ cairo_level_tests/contracts/with_ownable.cairo //! > generated_cairo_code #[starknet::contract] mod ownable_balance { - use starknet::storage::{StoragePointerReadAccess, StoragePointerWriteAccess}; use crate::components::ownable::ownable as ownable_comp; use starknet::ContractAddress; + use starknet::storage::{StoragePointerReadAccess, StoragePointerWriteAccess}; #[storage] struct Storage { #[substorage(v0)] @@ -291,9 +291,9 @@ impl StorageStorageBaseMutDrop of core::traits::Drop::; impl StorageStorageBaseMutCopy of core::traits::Copy::; } - use starknet::storage::{StoragePointerReadAccess, StoragePointerWriteAccess}; use crate::components::ownable::ownable as ownable_comp; use starknet::ContractAddress; + use starknet::storage::{StoragePointerReadAccess, StoragePointerWriteAccess}; #[storage] struct Storage { #[substorage(v0)] diff --git a/crates/cairo-lang-starknet/src/test_data/storage_path_check b/crates/cairo-lang-starknet/src/test_data/storage_path_check index 54d4ba6346e..024c9f346e0 100644 --- a/crates/cairo-lang-starknet/src/test_data/storage_path_check +++ b/crates/cairo-lang-starknet/src/test_data/storage_path_check @@ -62,7 +62,8 @@ struct IgnoredMemberStruct { #[starknet::contract] mod contract_with_and_without_ignored { - use super::{IgnoredMemberStruct, Struct0}; + use super::IgnoredMemberStruct; + use super::Struct0; #[storage] pub struct Storage { #[flat] @@ -76,7 +77,7 @@ mod contract_with_and_without_ignored { //! > diagnostics warning: Plugin diagnostic: The path `y.member0` collides with existing path `x.ignored_member.member0`. Fix or add `#[allow(starknet::colliding_storage_paths)]` if intentional. - --> lib.cairo:25:13 + --> lib.cairo:26:13 pub y: Struct0, ^ @@ -101,7 +102,8 @@ struct HasHasA { #[starknet::component] mod component_with_and_without_ignored { - use super::{HasA, HasHasA}; + use super::HasA; + use super::HasHasA; #[storage] pub struct Storage { pub a: felt252, @@ -116,12 +118,12 @@ mod component_with_and_without_ignored { //! > diagnostics warning: Plugin diagnostic: The path `has_a.a` collides with existing path `a`. Fix or add `#[allow(starknet::colliding_storage_paths)]` if intentional. - --> lib.cairo:19:13 + --> lib.cairo:20:13 pub has_a: HasA, ^^^^^ warning: Plugin diagnostic: The path `has_has_a.has_a.a` collides with existing path `a`. Fix or add `#[allow(starknet::colliding_storage_paths)]` if intentional. - --> lib.cairo:21:13 + --> lib.cairo:22:13 pub has_has_a: HasHasA, ^^^^^^^^^ @@ -151,7 +153,8 @@ struct IgnoredMemberStruct { #[starknet::component] mod component { - use super::{Struct0, IgnoredMemberStruct}; + use super::IgnoredMemberStruct; + use super::Struct0; #[storage] pub struct Storage { #[flat] @@ -175,12 +178,12 @@ mod contract_with_component { //! > diagnostics warning: Plugin diagnostic: The path `y.ignored_member.member0` collides with existing path `x.member0`. Fix or add `#[allow(starknet::colliding_storage_paths)]` if intentional. - --> lib.cairo:25:13 + --> lib.cairo:26:13 pub y: IgnoredMemberStruct, ^ warning: Plugin diagnostic: The path `member.y.ignored_member.member0` collides with existing path `member.x.member0`. Fix or add `#[allow(starknet::colliding_storage_paths)]` if intentional. - --> lib.cairo:35:9 + --> lib.cairo:36:9 member: component::Storage, ^^^^^^ diff --git a/crates/cairo-lang-starknet/test_data/lib.cairo b/crates/cairo-lang-starknet/test_data/lib.cairo index 510e00800ab..1378e9e4e6c 100644 --- a/crates/cairo-lang-starknet/test_data/lib.cairo +++ b/crates/cairo-lang-starknet/test_data/lib.cairo @@ -1,12 +1,12 @@ mod account; mod erc20; mod hello_starknet; +mod interfaces; mod minimal_contract; mod new_syntax_test_contract; +mod ownable_erc20; mod test_contract; mod token_bridge; mod upgradable_counter; mod with_erc20; mod with_ownable; -mod ownable_erc20; -mod interfaces; diff --git a/crates/cairo-lang-starknet/test_data/mintable.cairo b/crates/cairo-lang-starknet/test_data/mintable.cairo index 38575b998f4..da5d48a033b 100644 --- a/crates/cairo-lang-starknet/test_data/mintable.cairo +++ b/crates/cairo-lang-starknet/test_data/mintable.cairo @@ -70,7 +70,7 @@ trait ERC20Trait { #[starknet::component] mod erc20 { use core::num::traits::Zero; - use starknet::{ContractAddress, get_caller_address, contract_address_const}; + use starknet::{ContractAddress, contract_address_const, get_caller_address}; #[storage] struct Storage { name: felt252, diff --git a/crates/cairo-lang-test-runner/test_data/lib.cairo b/crates/cairo-lang-test-runner/test_data/lib.cairo index 62e158d18a8..4fad4aff8fc 100644 --- a/crates/cairo-lang-test-runner/test_data/lib.cairo +++ b/crates/cairo-lang-test-runner/test_data/lib.cairo @@ -32,8 +32,9 @@ mod Balance { #[cfg(test)] mod tests { use starknet::syscalls::deploy_syscall; - - use super::{Balance, IBalanceDispatcher, IBalanceDispatcherTrait}; + use super::Balance; + use super::IBalanceDispatcher; + use super::IBalanceDispatcherTrait; #[test] fn test_flow() { diff --git a/examples/lib.cairo b/examples/lib.cairo index 80be58f24d6..343754a5760 100644 --- a/examples/lib.cairo +++ b/examples/lib.cairo @@ -6,14 +6,14 @@ mod fib_array; mod fib_box; mod fib_caller; mod fib_counter; -mod fib_loop; mod fib_local; +mod fib_loop; mod fib_match; mod fib_struct; -mod fib_u128_checked; mod fib_u128; +mod fib_u128_checked; mod fib_unary; -mod hash_chain_gas; mod hash_chain; -mod pedersen_test; +mod hash_chain_gas; mod match_or; +mod pedersen_test; diff --git a/tests/bug_samples/inconsistent_gas.cairo b/tests/bug_samples/inconsistent_gas.cairo index 8527c895d67..744aaf7abeb 100644 --- a/tests/bug_samples/inconsistent_gas.cairo +++ b/tests/bug_samples/inconsistent_gas.cairo @@ -1,13 +1,12 @@ #[starknet::contract] mod test_contract { - use starknet::get_caller_address; - use starknet::storage_read_syscall; - use starknet::storage_write_syscall; - use starknet::syscalls::emit_event_syscall; - use starknet::storage_access::storage_base_address_from_felt252; - use starknet::storage_access::storage_address_from_base_and_offset; - use starknet::ContractAddress; - use starknet::SyscallResultTrait; + use starknet::storage_access::{ + storage_address_from_base_and_offset, storage_base_address_from_felt252, + }; + use starknet::{ + ContractAddress, SyscallResultTrait, get_caller_address, storage_read_syscall, + storage_write_syscall, syscalls::emit_event_syscall, + }; #[storage] struct Storage { diff --git a/tests/bug_samples/indirect_impl_alias.cairo b/tests/bug_samples/indirect_impl_alias.cairo index 42e9bda66b6..2a98b4dc57c 100644 --- a/tests/bug_samples/indirect_impl_alias.cairo +++ b/tests/bug_samples/indirect_impl_alias.cairo @@ -16,7 +16,6 @@ mod impls { } pub impl ImplAlias2 = Impl2; } - use impls::ImplAlias1; impl Impl2 = impls::ImplAlias2; diff --git a/tests/bug_samples/issue2171.cairo b/tests/bug_samples/issue2171.cairo index 1c71caa9ed4..5a92b0de9d2 100644 --- a/tests/bug_samples/issue2171.cairo +++ b/tests/bug_samples/issue2171.cairo @@ -1,5 +1,5 @@ -use starknet::ContractAddress; use core::test::test_utils::assert_eq; +use starknet::ContractAddress; #[test] fn main() { diff --git a/tests/bug_samples/issue2932.cairo b/tests/bug_samples/issue2932.cairo index 76e0cf873fb..e9c8aff017d 100644 --- a/tests/bug_samples/issue2932.cairo +++ b/tests/bug_samples/issue2932.cairo @@ -1,5 +1,5 @@ -use starknet::get_tx_info; use core::test::test_utils::assert_ne; +use starknet::get_tx_info; fn foo(v: felt252) { if v == 1 { diff --git a/tests/bug_samples/issue3153.cairo b/tests/bug_samples/issue3153.cairo index 9d6d30300cf..f406a9785a0 100644 --- a/tests/bug_samples/issue3153.cairo +++ b/tests/bug_samples/issue3153.cairo @@ -1,8 +1,8 @@ +use core::integer::u256_from_felt252; use starknet::{ - Store, SyscallResult, StorageBaseAddress, storage_read_syscall, storage_write_syscall, - storage_address_from_base_and_offset, + StorageBaseAddress, Store, SyscallResult, storage_address_from_base_and_offset, + storage_read_syscall, storage_write_syscall, }; -use core::integer::u256_from_felt252; impl U256TryIntoU64 of TryInto { fn try_into(self: u256) -> Option { @@ -83,8 +83,8 @@ impl ProposalStore of Store { #[starknet::contract] mod test_contract { - use super::Proposal; use starknet::storage::Map; + use super::Proposal; #[storage] struct Storage { _proposals: Map, diff --git a/tests/bug_samples/issue3345.cairo b/tests/bug_samples/issue3345.cairo index e2dfe8dd815..ae1199506fa 100644 --- a/tests/bug_samples/issue3345.cairo +++ b/tests/bug_samples/issue3345.cairo @@ -11,9 +11,9 @@ trait ITree { #[starknet::contract] mod example_failure { - use super::Node; - use super::ITree; use starknet::storage::Map; + use super::ITree; + use super::Node; #[storage] struct Storage { diff --git a/tests/bug_samples/issue4036.cairo b/tests/bug_samples/issue4036.cairo index 5118344be70..ccf0c79b896 100644 --- a/tests/bug_samples/issue4036.cairo +++ b/tests/bug_samples/issue4036.cairo @@ -11,8 +11,8 @@ trait FirstInterface { mod toto { #[storage] struct Storage {} - - use super::{FirstInterfaceDispatcher, FirstInterfaceDispatcherTrait}; + use super::FirstInterfaceDispatcher; + use super::FirstInterfaceDispatcherTrait; #[external(v0)] fn test_mint_and_unbox(self: @ContractState) {