diff --git a/packages/bytes/src/bytes.cairo b/packages/bytes/src/bytes.cairo index b6dd5dcc..c63de9f0 100644 --- a/packages/bytes/src/bytes.cairo +++ b/packages/bytes/src/bytes.cairo @@ -1,6 +1,5 @@ use alexandria_bytes::utils::{ - u128_join, read_sub_u128, u128_split, u128_array_slice, keccak_u128s_be, u8_array_to_u256, - u32s_to_u256 + u128_join, read_sub_u128, u128_split, u128_array_slice, keccak_u128s_be, u32s_to_u256 }; use alexandria_math::{U128BitShift, U256BitShift}; use core::byte_array::ByteArrayTrait; diff --git a/packages/bytes/src/tests/test_bytes.cairo b/packages/bytes/src/tests/test_bytes.cairo index b7146a5b..46503959 100644 --- a/packages/bytes/src/tests/test_bytes.cairo +++ b/packages/bytes/src/tests/test_bytes.cairo @@ -1,6 +1,5 @@ use alexandria_bytes::utils::{BytesDebug, BytesDisplay}; use alexandria_bytes::{Bytes, BytesTrait, BytesIndex}; -use starknet::ContractAddress; #[test] #[available_gas(20000000)] diff --git a/packages/bytes/src/tests/test_bytes_store.cairo b/packages/bytes/src/tests/test_bytes_store.cairo index b4eca5c6..3172ead2 100644 --- a/packages/bytes/src/tests/test_bytes_store.cairo +++ b/packages/bytes/src/tests/test_bytes_store.cairo @@ -30,9 +30,9 @@ mod ABytesStore { #[cfg(test)] mod tests { use alexandria_bytes::utils::{BytesDebug, BytesDisplay}; - use alexandria_bytes::{Bytes, BytesTrait, BytesStore}; + use alexandria_bytes::{BytesTrait, BytesStore}; use starknet::syscalls::deploy_syscall; - use starknet::{ClassHash, ContractAddress, SyscallResultTrait,}; + use starknet::{ClassHash, SyscallResultTrait,}; use super::{ABytesStore, IABytesStoreDispatcher, IABytesStoreDispatcherTrait}; fn deploy() -> IABytesStoreDispatcher { diff --git a/packages/bytes/src/utils.cairo b/packages/bytes/src/utils.cairo index acc6b422..764c9886 100644 --- a/packages/bytes/src/utils.cairo +++ b/packages/bytes/src/utils.cairo @@ -1,10 +1,9 @@ use alexandria_bytes::{Bytes, BytesTrait}; use alexandria_math::const_pow::pow2; -use alexandria_data_structures::array_ext::ArrayTraitExt; use core::fmt::{Debug, Display, Formatter, Error}; use core::integer::u128_byte_reverse; use core::keccak::cairo_keccak; -use core::to_byte_array::{AppendFormattedToByteArray, FormatAsByteArray}; +use core::to_byte_array::FormatAsByteArray; fn format_byte_hex(byte: u8, ref f: Formatter) -> Result<(), Error> { let base: NonZero = 16_u8.try_into().unwrap(); diff --git a/packages/data_structures/src/tests/array_ext.cairo b/packages/data_structures/src/tests/array_ext.cairo index 0e477453..21432cea 100644 --- a/packages/data_structures/src/tests/array_ext.cairo +++ b/packages/data_structures/src/tests/array_ext.cairo @@ -466,7 +466,7 @@ mod position { } mod occurrences { - use super::{ArrayTraitExt, get_u128_array, get_felt252_array}; + use super::ArrayTraitExt; #[test] #[available_gas(2000000)] @@ -633,7 +633,7 @@ mod max_position { } mod dedup { - use super::{ArrayTraitExt, get_u128_array, get_felt252_array}; + use super::ArrayTraitExt; #[test] #[available_gas(2000000)] @@ -716,7 +716,7 @@ mod dedup { } mod unique { - use super::{ArrayTraitExt, get_u128_array, get_felt252_array}; + use super::ArrayTraitExt; #[test] #[available_gas(2000000)] diff --git a/packages/data_structures/src/tests/queue.cairo b/packages/data_structures/src/tests/queue.cairo index 2387e7e5..020b3964 100644 --- a/packages/data_structures/src/tests/queue.cairo +++ b/packages/data_structures/src/tests/queue.cairo @@ -1,4 +1,4 @@ -use alexandria_data_structures::queue::{Queue, QueueTrait}; +use alexandria_data_structures::queue::QueueTrait; #[test] #[available_gas(2000000)] diff --git a/packages/encoding/src/sol_abi/encode.cairo b/packages/encoding/src/sol_abi/encode.cairo index e1463ba3..46aad910 100644 --- a/packages/encoding/src/sol_abi/encode.cairo +++ b/packages/encoding/src/sol_abi/encode.cairo @@ -1,5 +1,4 @@ use alexandria_bytes::{Bytes, BytesTrait}; -use core::traits::TryInto; use starknet::{ContractAddress, EthAddress}; /// Encode selector trait meant to provide an interface similar to Solidity's diff --git a/packages/encoding/src/tests/base64_felt_test.cairo b/packages/encoding/src/tests/base64_felt_test.cairo index 9d64a92a..72923373 100644 --- a/packages/encoding/src/tests/base64_felt_test.cairo +++ b/packages/encoding/src/tests/base64_felt_test.cairo @@ -2,7 +2,6 @@ use alexandria_data_structures::array_ext::ArrayTraitExt; use alexandria_encoding::base64::{ Base64Encoder, Base64UrlEncoder, Base64FeltEncoder, Base64UrlFeltEncoder }; -use core::traits::TryInto; fn bytes_be(val: felt252) -> Array { let mut result = array![]; diff --git a/packages/math/src/bip340.cairo b/packages/math/src/bip340.cairo index d5b870ec..a145edc5 100644 --- a/packages/math/src/bip340.cairo +++ b/packages/math/src/bip340.cairo @@ -1,12 +1,6 @@ //! bip340 implementation -use core::byte_array::ByteArrayTrait; -use core::math::u256_mul_mod_n; -use core::option::OptionTrait; -use core::result::ResultTrait; use core::sha256::compute_sha256_byte_array; //Available in Cairo ^2.7.0. use core::starknet::SyscallResultTrait; -use core::to_byte_array::{AppendFormattedToByteArray, FormatAsByteArray}; -use core::traits::Into; use starknet::{secp256k1::{Secp256k1Point}, secp256_trait::{Secp256Trait, Secp256PointTrait}}; @@ -76,7 +70,8 @@ fn hash_challenge(rx: u256, px: u256, m: ByteArray) -> u256 { /// * `m`: `ByteArray` - The message for which the signature is being verified. /// /// # Returns -/// * `bool` - `true` if the signature is verified for the message and public key, `false` otherwise. +/// * `bool` - `true` if the signature is verified for the message and public key, `false` +/// otherwise. pub fn verify(px: u256, rx: u256, s: u256, m: ByteArray) -> bool { let n = Secp256Trait::::get_curve_size(); diff --git a/packages/math/src/ed25519.cairo b/packages/math/src/ed25519.cairo index 185e31b2..3813a7b3 100644 --- a/packages/math/src/ed25519.cairo +++ b/packages/math/src/ed25519.cairo @@ -1,11 +1,9 @@ -use alexandria_math::mod_arithmetics::{mult_mod, sqr_mod, div_mod, pow_mod, equality_mod}; +use alexandria_math::mod_arithmetics::{mult_mod, sqr_mod, div_mod, pow_mod}; use alexandria_math::sha512::{sha512, SHA512_LEN}; -use alexandria_math::u512_arithmetics::{u512_add, u512_sub}; +use alexandria_math::u512_arithmetics::{u512_sub}; use core::integer::{u512, u512_safe_div_rem_by_u256}; use core::math::u256_inv_mod; -use core::num::traits::{OverflowingMul, WideMul}; -use core::option::OptionTrait; -use core::traits::{Div, TryInto}; +use core::num::traits::WideMul; // Subtraction without modulo operation // assumes a, b < modulo diff --git a/packages/math/src/mod_arithmetics.cairo b/packages/math/src/mod_arithmetics.cairo index ff31a3bc..ffe811c8 100644 --- a/packages/math/src/mod_arithmetics.cairo +++ b/packages/math/src/mod_arithmetics.cairo @@ -1,7 +1,5 @@ use core::integer::{u512, u512_safe_div_rem_by_u256}; use core::num::traits::{WrappingAdd, OverflowingAdd, OverflowingSub, WideMul}; -use core::option::OptionTrait; -use core::traits::TryInto; /// Function that performs modular addition. Will panick if result is > u256 max /// # Arguments diff --git a/packages/math/src/sha512.cairo b/packages/math/src/sha512.cairo index 8d457bf5..f9c4165b 100644 --- a/packages/math/src/sha512.cairo +++ b/packages/math/src/sha512.cairo @@ -1,7 +1,6 @@ use core::num::traits::Bounded; use core::num::traits::WrappingAdd; use core::traits::{BitAnd, BitXor, BitOr}; -use super::BitShift; // Variable naming is compliant to RFC-6234 (https://datatracker.ietf.org/doc/html/rfc6234) diff --git a/packages/math/src/tests/bip340_test.cairo b/packages/math/src/tests/bip340_test.cairo index b8a262f4..1bb8721b 100644 --- a/packages/math/src/tests/bip340_test.cairo +++ b/packages/math/src/tests/bip340_test.cairo @@ -1,8 +1,5 @@ use alexandria_math::bip340::{verify}; use core::byte_array::ByteArrayTrait; -use core::clone::Clone; -use core::option::OptionTrait; -use core::traits::Into; impl U256IntoByteArray of Into { fn into(self: u256) -> ByteArray { diff --git a/packages/math/src/tests/i257_test.cairo b/packages/math/src/tests/i257_test.cairo index 91a80804..615617e2 100644 --- a/packages/math/src/tests/i257_test.cairo +++ b/packages/math/src/tests/i257_test.cairo @@ -1,4 +1,4 @@ -use alexandria_math::i257::{i257, I257Impl, i257_div_rem, i257_assert_no_negative_zero}; +use alexandria_math::i257::{i257, I257Impl, i257_div_rem}; use core::num::traits::Zero; #[test] diff --git a/packages/math/src/tests/mod_arithmetics_test.cairo b/packages/math/src/tests/mod_arithmetics_test.cairo index e71176fd..11619fe7 100644 --- a/packages/math/src/tests/mod_arithmetics_test.cairo +++ b/packages/math/src/tests/mod_arithmetics_test.cairo @@ -1,5 +1,4 @@ use alexandria_math::mod_arithmetics::{add_mod, sub_mod, mult_mod, sqr_mod, div_mod, pow_mod}; -use core::traits::TryInto; const p: u256 = 57896044618658097711785492504343953926634992332820282019728792003956564819949; // 2^255 - 19 diff --git a/packages/math/src/tests/sha512_test.cairo b/packages/math/src/tests/sha512_test.cairo index 0cb2142b..40a59841 100644 --- a/packages/math/src/tests/sha512_test.cairo +++ b/packages/math/src/tests/sha512_test.cairo @@ -1,4 +1,4 @@ -use alexandria_math::sha512::{WordOperations, sha512, Word64, Word64WordOperations}; +use alexandria_math::sha512::{sha512, Word64WordOperations}; fn get_lorem_ipsum() -> Array { let mut input: Array = array![ diff --git a/packages/math/src/trigonometry.cairo b/packages/math/src/trigonometry.cairo index f49ede6f..746df3bb 100644 --- a/packages/math/src/trigonometry.cairo +++ b/packages/math/src/trigonometry.cairo @@ -1,4 +1,3 @@ -use core::traits::TryInto; const BASE_I64: i64 = 100000000; const FAST_I90: i64 = 90 * BASE_I64; diff --git a/packages/merkle_tree/src/storage_proof.cairo b/packages/merkle_tree/src/storage_proof.cairo index 55cf79dc..96f085fd 100644 --- a/packages/merkle_tree/src/storage_proof.cairo +++ b/packages/merkle_tree/src/storage_proof.cairo @@ -1,7 +1,7 @@ +use alexandria_math::const_pow::pow2_felt252; use core::hash::HashStateTrait; use core::pedersen::PedersenTrait; use core::poseidon::PoseidonTrait; -use alexandria_math::const_pow::pow2_felt252; #[derive(Drop, Serde)] pub struct BinaryNode { diff --git a/packages/merkle_tree/src/tests/merkle_tree_test.cairo b/packages/merkle_tree/src/tests/merkle_tree_test.cairo index 464e0984..1c50bbfd 100644 --- a/packages/merkle_tree/src/tests/merkle_tree_test.cairo +++ b/packages/merkle_tree/src/tests/merkle_tree_test.cairo @@ -1,10 +1,8 @@ // Internal imports use alexandria_merkle_tree::merkle_tree::{ - Hasher, MerkleTree, pedersen::PedersenHasherImpl, poseidon::PoseidonHasherImpl, MerkleTreeTrait, - MerkleTreeImpl + Hasher, MerkleTree, pedersen::PedersenHasherImpl, poseidon::PoseidonHasherImpl, MerkleTreeImpl }; - mod regular_call_merkle_tree_pedersen { // Internal imports use alexandria_merkle_tree::merkle_tree::{ diff --git a/packages/merkle_tree/src/tests/storage_proof_test.cairo b/packages/merkle_tree/src/tests/storage_proof_test.cairo index 3deee73f..f153ef9a 100644 --- a/packages/merkle_tree/src/tests/storage_proof_test.cairo +++ b/packages/merkle_tree/src/tests/storage_proof_test.cairo @@ -1,6 +1,4 @@ -use alexandria_merkle_tree::storage_proof::{ - ContractStateProof, ContractData, TrieNode, BinaryNode, EdgeNode, verify -}; +use alexandria_merkle_tree::storage_proof::verify; use alexandria_merkle_tree::tests::storage_proof_test_data::{balance_proof, total_balance_proof}; diff --git a/packages/merkle_tree/src/tests/storage_proof_test_data.cairo b/packages/merkle_tree/src/tests/storage_proof_test_data.cairo index fefe6fea..f7978204 100644 --- a/packages/merkle_tree/src/tests/storage_proof_test_data.cairo +++ b/packages/merkle_tree/src/tests/storage_proof_test_data.cairo @@ -1,6 +1,6 @@ use alexandria_merkle_tree::storage_proof::{ - ContractStateProof, ContractData, TrieNode, BinaryNode, EdgeNode, BinaryNodeImpl, EdgeNodeImpl, - ContractStateProofImpl, ContractDataImpl + ContractStateProof, TrieNode, BinaryNodeImpl, EdgeNodeImpl, ContractStateProofImpl, + ContractDataImpl }; pub(crate) fn balance_proof() -> ContractStateProof { diff --git a/packages/numeric/src/integers.cairo b/packages/numeric/src/integers.cairo index 73b6b419..019dfe57 100644 --- a/packages/numeric/src/integers.cairo +++ b/packages/numeric/src/integers.cairo @@ -1,5 +1,3 @@ -use alexandria_math::BitShift; - pub trait UIntBytes { fn from_bytes(input: Span) -> Option; fn to_bytes(self: T) -> Span; diff --git a/packages/searching/src/tests/dijkstra_test.cairo b/packages/searching/src/tests/dijkstra_test.cairo index 05e90717..0dd83f31 100644 --- a/packages/searching/src/tests/dijkstra_test.cairo +++ b/packages/searching/src/tests/dijkstra_test.cairo @@ -1,4 +1,4 @@ -use alexandria_searching::dijkstra::{Graph, Node, GraphTrait, NodeGetters}; +use alexandria_searching::dijkstra::{GraphTrait, NodeGetters}; use core::nullable::{FromNullableResult, match_nullable}; diff --git a/packages/storage/src/tests/list_test.cairo b/packages/storage/src/tests/list_test.cairo index a0ea8ea7..6550c05d 100644 --- a/packages/storage/src/tests/list_test.cairo +++ b/packages/storage/src/tests/list_test.cairo @@ -1,10 +1,7 @@ -use alexandria_storage::{List, ListTrait}; -use core::option::OptionTrait; +use alexandria_storage::ListTrait; use core::starknet::storage::StorageAsPointer; -use core::traits::TryInto; use starknet::{ ClassHash, ContractAddress, syscalls::deploy_syscall, SyscallResultTrait, - testing::set_contract_address, storage_access::{ storage_base_address_from_felt252, storage_address_from_base, StorageBaseAddress } diff --git a/packages/utils/src/fmt.cairo b/packages/utils/src/fmt.cairo index 1a61bc0f..c5ba3ada 100644 --- a/packages/utils/src/fmt.cairo +++ b/packages/utils/src/fmt.cairo @@ -5,7 +5,6 @@ use starknet::{ContractAddress, EthAddress, ClassHash, StorageAddress}; /// Display mod display_felt252_based { use core::fmt::{Display, Formatter, Error}; - use core::to_byte_array::AppendFormattedToByteArray; pub impl TDisplay, +Copy> of Display { fn fmt(self: @T, ref f: Formatter) -> Result<(), Error> { let value: felt252 = (*self).into(); @@ -22,7 +21,6 @@ pub impl StorageAddressDisplay = display_felt252_based::TDisplay /// Debug mod debug_display_based { use core::fmt::{Display, Debug, Formatter, Error}; - use core::to_byte_array::AppendFormattedToByteArray; pub impl TDebug> of Debug { fn fmt(self: @T, ref f: Formatter) -> Result<(), Error> { Display::fmt(self, ref f)