Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecated direct usages of core::starknet or crate::starknet. #7304

Merged
merged 1 commit into from
Feb 18, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion corelib/src/keccak.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@
//! 0x85c9aab73219c1e95c5b5966a4ecc8db4418c3500072a830cfb5a2d13d2c2249);
//! ```

use starknet::SyscallResultTrait;
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;
Expand Down
2 changes: 2 additions & 0 deletions corelib/src/lib.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -383,8 +383,10 @@ pub mod debug;
pub mod fmt;

#[feature("corelib-internal-use")]
#[deprecated(feature: "corelib-internal-use", note: "Use `starknet` directly")]
pub mod starknet;
#[allow(unused_imports)]
#[feature("corelib-internal-use")]
use starknet::System;

pub mod internal;
Expand Down
9 changes: 6 additions & 3 deletions corelib/src/prelude/v2023_01.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ use crate::poseidon::Poseidon;
use crate::result::Result::{Err, Ok};
use crate::result::{Result, ResultTrait};
use crate::serde::Serde;
use crate::starknet::System;
use crate::string::StringLiteral;
use crate::traits::{
Add, BitAnd, BitNot, BitOr, BitXor, Copy, Default, Destruct, Div, DivRem, Drop,
Expand All @@ -49,10 +48,14 @@ use crate::{
bool_not_impl, bool_or_impl, bool_to_felt252, bool_xor_impl, box, byte_array, bytes_31, clone,
cmp, debug, dict, drop, dup, ec, ecdsa, felt252, felt252_add, felt252_const, felt252_div,
felt252_is_zero, felt252_mul, felt252_sub, gas, hash, integer, internal, keccak, math, never,
nullable, option, panic_with_felt252, panics, pedersen, poseidon, result, serde, starknet,
string, testing, to_byte_array, traits, usize, zeroable,
nullable, option, panic_with_felt252, panics, pedersen, poseidon, result, serde, string,
testing, to_byte_array, traits, usize, zeroable,
};
#[feature("corelib-internal-use")]
use crate::starknet::System;
#[feature("corelib-internal-use")]
use crate::starknet;
#[feature("corelib-internal-use")]
#[deprecated(feature: "corelib-internal-use", note: "Use `core::num::traits::Sqrt` instead")]
use crate::integer::{u128_sqrt, u256_sqrt};
#[cfg(test)]
Expand Down
7 changes: 5 additions & 2 deletions corelib/src/prelude/v2023_10.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,19 @@ pub use crate::poseidon::Poseidon;
pub use crate::result::Result::{Err, Ok};
pub use crate::result::{Result, ResultTrait};
pub use crate::serde::Serde;
pub use crate::starknet::System;
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::iter::{FromIterator, IntoIterator, Iterator};
pub use crate::zeroable::NonZero;
pub use crate::{
RangeCheck, SegmentArena, assert, bool, felt252, keccak, math, starknet, to_byte_array, usize,
RangeCheck, SegmentArena, assert, bool, felt252, keccak, math, to_byte_array, usize,
};
#[feature("corelib-internal-use")]
pub use crate::starknet::System;
#[feature("corelib-internal-use")]
pub use crate::starknet;
#[deprecated(
feature: "deprecated-op-assign-traits", note: "Use `core::ops::AddAssign`.", since: "2.7.0",
)]
Expand Down
7 changes: 5 additions & 2 deletions corelib/src/prelude/v2024_07.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,15 @@ pub use crate::panics::{Panic, PanicResult, panic};
pub use crate::result::Result::{Err, Ok};
pub use crate::result::{Result, ResultTrait};
pub use crate::serde::Serde;
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::iter::{FromIterator, IntoIterator, Iterator};
pub use crate::{assert, bool, felt252, starknet, usize};
pub use crate::{assert, bool, felt252, usize};
#[feature("corelib-internal-use")]
pub use crate::starknet::System;
#[feature("corelib-internal-use")]
pub use crate::starknet;

pub use crate::zeroable::NonZero;
2 changes: 1 addition & 1 deletion corelib/src/sha256.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
//! assert!(hash == [0x185f8db3, 0x2271fe25, 0xf561a6fc, 0x938b2e26, 0x4306ec30, 0x4eda5180,
//! 0x7d17648, 0x26381969]);
//! ```
use crate::starknet::SyscallResultTrait;
use starknet::SyscallResultTrait;

/// A handle to the state of a SHA-256 hash.
#[derive(Copy, Drop)]
Expand Down
4 changes: 2 additions & 2 deletions corelib/src/starknet/account.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,13 @@ pub struct Call {
pub trait AccountContract<TContractState> {
/// An entry point that is called to check if the account is willing to pay for the declaration
/// of the class with the given hash.
/// The entry point should return `core::starknet::VALIDATED` if the account is willing to pay
/// The entry point should return `starknet::VALIDATED` if the account is willing to pay
/// for the declaration.
fn __validate_declare__(self: @TContractState, class_hash: felt252) -> felt252;

/// An entry point that is called to check if the account is willing to pay for
/// executing a given set of calls.
/// The entry point should return `core::starknet::VALIDATED` if the account is willing to pay
/// The entry point should return `starknet::VALIDATED` if the account is willing to pay
/// for the execution, in which case `__execute__` will be called on the same set of calls.
fn __validate__(ref self: TContractState, calls: Array<Call>) -> felt252;

Expand Down
4 changes: 2 additions & 2 deletions corelib/src/starknet/class_hash.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
//! # Examples
//!
//! ```
//! use core::starknet::class_hash::class_hash_const;
//! use starknet::class_hash::class_hash_const;
//!
//! let hash = class_hash_const::<0x123>();
//! let hash = 0x123.try_into().unwrap();
Expand All @@ -29,7 +29,7 @@ pub extern type ClassHash;
/// # Examples
///
/// ```
/// use core::starknet::class_hash::class_hash_const;
/// use starknet::class_hash::class_hash_const;
///
/// let class_hash = class_hash_const::<0x123>();
/// ```
Expand Down
4 changes: 2 additions & 2 deletions corelib/src/starknet/contract_address.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
//! # Examples
//!
//! ```
//! use core::starknet::contract_address::contract_address_const;
//! use starknet::contract_address::contract_address_const;
//!
//! let contract_address = contract_address_const::<0x0>();
//! ```
Expand All @@ -30,7 +30,7 @@ pub extern type ContractAddress;
/// # Examples
///
/// ```
/// use core::starknet::contract_address::contract_address_const;
/// use starknet::contract_address::contract_address_const;
///
/// let contract_address = contract_address_const::<0x0>();
/// ```
Expand Down
18 changes: 9 additions & 9 deletions corelib/src/starknet/eth_signature.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ use starknet::{EthAddress, SyscallResult, SyscallResultTrait};
/// # Examples
///
/// ```
/// use core::starknet::eth_address::EthAddress;
/// use core::starknet::eth_signature::verify_eth_signature;
/// use core::starknet::secp256_trait::Signature;
/// use starknet::eth_address::EthAddress;
/// use starknet::eth_signature::verify_eth_signature;
/// use starknet::secp256_trait::Signature;
///
/// let msg_hash = 0xe888fbb4cf9ae6254f19ba12e6d9af54788f195a6f509ca3e934f78d7a71dd85;
/// let r = 0x4c8e4fbc1fbb1dece52185e532812c4f7a5f81cf3ee10044320a0d03b62d3e9a;
Expand Down Expand Up @@ -73,9 +73,9 @@ pub fn verify_eth_signature(msg_hash: u256, signature: Signature, eth_address: E
/// # Examples
///
/// ```
/// use core::starknet::eth_address::EthAddress;
/// use core::starknet::eth_signature::is_eth_signature_valid;
/// use core::starknet::secp256_trait::Signature;
/// use starknet::eth_address::EthAddress;
/// use starknet::eth_signature::is_eth_signature_valid;
/// use starknet::secp256_trait::Signature;
///
/// let msg_hash = 0xe888fbb4cf9ae6254f19ba12e6d9af54788f195a6f509ca3e934f78d7a71dd85;
/// let r = 0x4c8e4fbc1fbb1dece52185e532812c4f7a5f81cf3ee10044320a0d03b62d3e9a;
Expand Down Expand Up @@ -120,9 +120,9 @@ pub fn is_eth_signature_valid(
/// # Examples
///
/// ```
/// use core::starknet::eth_signature::public_key_point_to_eth_address;
/// use core::starknet::secp256k1::Secp256k1Point;
/// use core::starknet::secp256_trait::Secp256Trait;
/// use starknet::eth_signature::public_key_point_to_eth_address;
/// use starknet::secp256k1::Secp256k1Point;
/// use starknet::secp256_trait::Secp256Trait;
///
/// let public_key: Secp256k1Point = Secp256Trait::secp256_ec_get_point_from_x_syscall(
/// 0xa9a02d48081294b9bb0d8740d70d3607feb20876964d432846d9b9100b91eefd, false,
Expand Down
16 changes: 8 additions & 8 deletions corelib/src/starknet/info.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
//! # Examples
//!
//! ```
//! use core::starknet::{get_block_info, get_caller_address, get_contract_address};
//! use starknet::{get_block_info, get_caller_address, get_contract_address};
//!
//! // Get block information
//! let block_info = get_block_info().unbox();
Expand Down Expand Up @@ -83,7 +83,7 @@ pub struct TxInfo {
/// # Examples
///
/// ```
/// use core::starknet::get_execution_info;
/// use starknet::get_execution_info;
///
/// let execution_info = get_execution_info().unbox();
///
Expand All @@ -101,7 +101,7 @@ pub fn get_execution_info() -> Box<v2::ExecutionInfo> {
/// # Examples
///
/// ```
/// use core::starknet::get_caller_address;
/// use starknet::get_caller_address;
///
/// let caller = get_caller_address();
/// ```
Expand All @@ -114,7 +114,7 @@ pub fn get_caller_address() -> ContractAddress {
/// # Examples
///
/// ```
/// use core::starknet::get_contract_address;
/// use starknet::get_contract_address;
///
/// let contract_address = get_contract_address();
/// ```
Expand All @@ -127,7 +127,7 @@ pub fn get_contract_address() -> ContractAddress {
/// # Examples
///
/// ```
/// use core::starknet::get_block_info;
/// use starknet::get_block_info;
///
/// let block_info = get_block_info().unbox();
///
Expand All @@ -144,7 +144,7 @@ pub fn get_block_info() -> Box<BlockInfo> {
/// # Examples
///
/// ```
/// use core::starknet::get_tx_info;
/// use starknet::get_tx_info;
///
/// let tx_info = get_tx_info().unbox();
///
Expand All @@ -165,7 +165,7 @@ pub fn get_tx_info() -> Box<v2::TxInfo> {
/// # Examples
///
/// ```
/// use core::starknet::get_block_timestamp;
/// use starknet::get_block_timestamp;
///
/// let block_timestamp = get_block_timestamp();
/// ```
Expand All @@ -178,7 +178,7 @@ pub fn get_block_timestamp() -> u64 {
/// # Examples
///
/// ```
/// use core::starknet::get_block_number;
/// use starknet::get_block_number;
///
/// let block_number = get_block_number();
/// ```
Expand Down
36 changes: 18 additions & 18 deletions corelib/src/starknet/secp256_trait.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
//! # Examples
//!
//! ```
//! use core::starknet::SyscallResultTrait;
/// use core::starknet::secp256r1::Secp256r1Point;
/// use core::starknet::secp256_trait::{Secp256Trait, Signature, is_signature_entry_valid,
//! use starknet::SyscallResultTrait;
/// use starknet::secp256r1::Secp256r1Point;
/// use starknet::secp256_trait::{Secp256Trait, Signature, is_signature_entry_valid,
/// is_valid_signature, recover_public_key};
///
/// assert!(
Expand Down Expand Up @@ -86,7 +86,7 @@ impl SignatureStorePacking of starknet::StorePacking<Signature, (u256, u256, boo
/// # Examples
///
/// ```
/// use core::starknet::secp256_trait::signature_from_vrs;
/// use starknet::secp256_trait::signature_from_vrs;
///
/// let signature = signature_from_vrs(0,
/// 0xa73bd4903f0ce3b639bbbf6e8e80d16931ff4bcf5993d58468e8fb19086e8cac,
Expand All @@ -104,9 +104,9 @@ pub fn signature_from_vrs(v: u32, r: u256, s: u256) -> Signature {
/// # Examples
///
/// ```
/// use core::starknet::secp256k1::Secp256k1Point;
/// use core::starknet::secp256_trait::Secp256Trait;
/// use core::starknet::SyscallResultTrait;
/// use starknet::secp256k1::Secp256k1Point;
/// use starknet::secp256_trait::Secp256Trait;
/// use starknet::SyscallResultTrait;
///
/// assert!(
/// Secp256Trait::<
Expand Down Expand Up @@ -171,10 +171,10 @@ pub trait Secp256Trait<Secp256Point> {
/// # Examples
///
/// ```
/// use core::starknet::SyscallResultTrait;
/// use core::starknet::secp256k1::Secp256k1Point;
/// use core::starknet::secp256_trait::Secp256PointTrait;
/// use core::starknet::secp256_trait::Secp256Trait;
/// use starknet::SyscallResultTrait;
/// use starknet::secp256k1::Secp256k1Point;
/// use starknet::secp256_trait::Secp256PointTrait;
/// use starknet::secp256_trait::Secp256Trait;
///
/// let generator = Secp256Trait::<Secp256k1Point>::get_generator_point();
///
Expand Down Expand Up @@ -220,8 +220,8 @@ pub trait Secp256PointTrait<Secp256Point> {
/// # Examples
///
/// ```
/// use core::starknet::secp256r1::Secp256r1Point;
/// use core::starknet::secp256_trait::is_signature_entry_valid;
/// use starknet::secp256r1::Secp256r1Point;
/// use starknet::secp256_trait::is_signature_entry_valid;
///
/// assert!(!is_signature_entry_valid::<Secp256r1Point>(0));
/// ```
Expand All @@ -238,9 +238,9 @@ pub fn is_signature_entry_valid<
/// # Examples
///
/// ```
/// use core::starknet::SyscallResultTrait;
/// use core::starknet::secp256r1::Secp256r1Point;
/// use core::starknet::secp256_trait::{Secp256Trait, is_valid_signature};
/// use starknet::SyscallResultTrait;
/// use starknet::secp256r1::Secp256r1Point;
/// use starknet::secp256_trait::{Secp256Trait, is_valid_signature};
///
/// let msg_hash = 0x4cee90eb86eaa050036147a12d49004b6b9c72bd725d39d4785011fe190f0b4d;
/// let r = 0xa73bd4903f0ce3b639bbbf6e8e80d16931ff4bcf5993d58468e8fb19086e8cac;
Expand Down Expand Up @@ -288,8 +288,8 @@ pub fn is_valid_signature<
/// # Examples
///
/// ```
/// use core::starknet::secp256r1::Secp256r1Point;
/// use core::starknet::secp256_trait::{Signature, recover_public_key};
/// use starknet::secp256r1::Secp256r1Point;
/// use starknet::secp256_trait::{Signature, recover_public_key};
///
/// let msg_hash = 0x4cee90eb86eaa050036147a12d49004b6b9c72bd725d39d4785011fe190f0b4d;
///
Expand Down
18 changes: 9 additions & 9 deletions corelib/src/starknet/storage.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
//! [`StoragePointerWriteAccess`] traits, along with useful storage-only collection types like
//! [`Vec`] and [`Map`].
//!
//! [`Vec`]: crate::starknet::storage::vec::Vec
//! [`Map`]: crate::starknet::storage::map::Map
//! [`Vec`]: starknet::storage::vec::Vec
//! [`Map`]: starknet::storage::map::Map
//!
//! # Overview
//!
Expand Down Expand Up @@ -54,11 +54,11 @@
//! with the `StoragePointer` traits to read and write in these entries.
//! - [`VecTrait`] and [`MutableVecTrait`] allow for interacting with storage [`Vec`]s.
//!
//! [`VecTrait`]: crate::starknet::storage::vec::VecTrait
//! [`MutableVecTrait`]: crate::starknet::storage::vec::MutableVecTrait
//! [`StorageMapReadAccess`]: crate::starknet::storage::map::StorageMapReadAccess
//! [`StorageMapWriteAccess`]: crate::starknet::storage::map::StorageMapWriteAccess
//! [`StoragePathEntry`]: crate::starknet::storage::map::StoragePathEntry
//! [`VecTrait`]: starknet::storage::vec::VecTrait
//! [`MutableVecTrait`]: starknet::storage::vec::MutableVecTrait
//! [`StorageMapReadAccess`]: starknet::storage::map::StorageMapReadAccess
//! [`StorageMapWriteAccess`]: starknet::storage::map::StorageMapWriteAccess
//! [`StoragePathEntry`]: starknet::storage::map::StoragePathEntry
//!
//! ## Examples
//!
Expand Down Expand Up @@ -215,7 +215,7 @@ pub trait StorageAsPointer<TMemberState> {
/// # Examples
///
//! ```
//! use core::starknet::storage::StoragePointerReadAccess;
//! use starknet::storage::StoragePointerReadAccess;
//!
//! #[storage]
//! struct Storage {
Expand All @@ -236,7 +236,7 @@ pub trait StoragePointerReadAccess<T> {
/// # Examples
///
//! ```
//! use core::starknet::storage::StoragePointerWriteAccess;
//! use starknet::storage::StoragePointerWriteAccess;
//!
//! #[storage]
//! struct Storage {
Expand Down
Loading