Skip to content
This repository was archived by the owner on Jul 22, 2024. It is now read-only.
Merged
16 changes: 6 additions & 10 deletions bench/internals.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,7 @@ use starknet_rs::{
business_logic::{
fact_state::in_memory_state_reader::InMemoryStateReader,
state::{cached_state::CachedState, state_api::State},
transaction::objects::{
internal_declare::InternalDeclare, internal_deploy::InternalDeploy,
internal_deploy_account::InternalDeployAccount,
internal_invoke_function::InternalInvokeFunction,
},
transaction::{declare::Declare, Deploy, DeployAccount, InvokeFunction},
},
core::contract_address::compute_deprecated_class_hash,
definitions::{
Expand Down Expand Up @@ -84,7 +80,7 @@ fn deploy_account() {
let signature = SIGNATURE.clone();
scope(|| {
// new consumes more execution time than raw struct instantiation
let internal_deploy_account = InternalDeployAccount::new(
let internal_deploy_account = DeployAccount::new(
class_hash,
0,
0,
Expand Down Expand Up @@ -117,7 +113,7 @@ fn declare() {
let address = CONTRACT_ADDRESS.clone();
scope(|| {
// new consumes more execution time than raw struct instantiation
let declare_tx = InternalDeclare::new(
let declare_tx = Declare::new(
class,
StarknetChainId::TestNet.to_felt(),
address,
Expand Down Expand Up @@ -156,7 +152,7 @@ fn deploy() {
let class = CONTRACT_CLASS.clone();
scope(|| {
// new consumes more execution time than raw struct instantiation
let internal_deploy = InternalDeploy::new(
let internal_deploy = Deploy::new(
salt,
class,
vec![],
Expand Down Expand Up @@ -188,7 +184,7 @@ fn invoke() {
"2669425616857739096022668060305620640217901643963991674344872184515580705509"
));
let class = CONTRACT_CLASS.clone();
let internal_deploy = InternalDeploy::new(
let internal_deploy = Deploy::new(
salt,
class,
vec![],
Expand All @@ -207,7 +203,7 @@ fn invoke() {
let calldata = vec![address.0.clone(), selector.clone(), Felt252::zero()];
scope(|| {
// new consumes more execution time than raw struct instantiation
let internal_invoke = InternalInvokeFunction::new(
let internal_invoke = InvokeFunction::new(
address,
selector,
0,
Expand Down
4 changes: 2 additions & 2 deletions cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use starknet_rs::{
cached_state::CachedState,
state_api::{State, StateReader},
},
transaction::objects::internal_invoke_function::InternalInvokeFunction,
transaction::InvokeFunction,
},
core::{
contract_address::compute_deprecated_class_hash,
Expand Down Expand Up @@ -185,7 +185,7 @@ fn invoke_parser(
Some(vec) => vec.iter().map(|&n| n.into()).collect(),
None => Vec::new(),
};
let internal_invoke = InternalInvokeFunction::new(
let internal_invoke = InvokeFunction::new(
contract_address.clone(),
entrypoint_selector.clone(),
0,
Expand Down
6 changes: 3 additions & 3 deletions src/bin/invoke_with_cachedstate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use starknet_rs::{
business_logic::{
fact_state::in_memory_state_reader::InMemoryStateReader,
state::{cached_state::CachedState, BlockInfo},
transaction::objects::internal_invoke_function::InternalInvokeFunction,
transaction::InvokeFunction,
},
definitions::{
constants::TRANSACTION_VERSION,
Expand Down Expand Up @@ -55,7 +55,7 @@ fn main() {
let general_config = new_starknet_general_config_for_testing();

for i in 0..RUNS {
InternalInvokeFunction::new(
InvokeFunction::new(
CONTRACT_ADDRESS.clone(),
INCREASE_BALANCE_SELECTOR.clone(),
2,
Expand All @@ -70,7 +70,7 @@ fn main() {
.execute(&mut cached_state, &general_config)
.unwrap();

let tx_exec_info = InternalInvokeFunction::new(
let tx_exec_info = InvokeFunction::new(
CONTRACT_ADDRESS.clone(),
GET_BALANCE_SELECTOR.clone(),
2,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ const VERSION_0: u64 = 0;
/// Represents an internal transaction in the StarkNet network that is a declaration of a Cairo
/// contract class.
#[derive(Debug)]
pub struct InternalDeclare {
pub struct Declare {
pub class_hash: ClassHash,
pub sender_address: Address,
pub tx_type: TransactionType,
Expand All @@ -52,7 +52,7 @@ pub struct InternalDeclare {
// ------------------------------------------------------------
// Functions
// ------------------------------------------------------------
impl InternalDeclare {
impl Declare {
#[allow(clippy::too_many_arguments)]
pub fn new(
contract_class: ContractClass,
Expand Down Expand Up @@ -81,7 +81,7 @@ impl InternalDeclare {

let validate_entry_point_selector = VALIDATE_DECLARE_ENTRY_POINT_SELECTOR.clone();

let internal_declare = InternalDeclare {
let internal_declare = Declare {
class_hash,
sender_address,
tx_type: TransactionType::Declare,
Expand Down Expand Up @@ -313,7 +313,7 @@ mod tests {
utils::{felt_to_hash, Address},
};

use super::InternalDeclare;
use super::Declare;

#[test]
fn declare_fibonacci() {
Expand Down Expand Up @@ -356,7 +356,7 @@ mod tests {
let chain_id = StarknetChainId::TestNet.to_felt();

// declare tx
let internal_declare = InternalDeclare::new(
let internal_declare = Declare::new(
fib_contract_class,
chain_id,
Address(Felt252::one()),
Expand Down Expand Up @@ -463,7 +463,7 @@ mod tests {
let version = 0;

// Declare tx should fail because max_fee > 0 and version == 0
let internal_declare = InternalDeclare::new(
let internal_declare = Declare::new(
fib_contract_class,
chain_id,
Address(Felt252::one()),
Expand Down Expand Up @@ -527,7 +527,7 @@ mod tests {
let version = 0;

// Declare tx should fail because nonce > 0 and version == 0
let internal_declare = InternalDeclare::new(
let internal_declare = Declare::new(
fib_contract_class,
chain_id,
Address(Felt252::one()),
Expand Down Expand Up @@ -590,7 +590,7 @@ mod tests {
let signature = vec![1.into(), 2.into()];

// Declare tx should fail because signature is not empty
let internal_declare = InternalDeclare::new(
let internal_declare = Declare::new(
fib_contract_class,
chain_id,
Address(Felt252::one()),
Expand Down Expand Up @@ -652,7 +652,7 @@ mod tests {
let chain_id = StarknetChainId::TestNet.to_felt();

// Declare same class twice
let internal_declare = InternalDeclare::new(
let internal_declare = Declare::new(
fib_contract_class.clone(),
chain_id.clone(),
Address(Felt252::one()),
Expand All @@ -664,7 +664,7 @@ mod tests {
)
.unwrap();

let internal_declare_error = InternalDeclare::new(
let internal_declare_error = Declare::new(
fib_contract_class,
chain_id,
Address(Felt252::one()),
Expand Down Expand Up @@ -734,7 +734,7 @@ mod tests {
let chain_id = StarknetChainId::TestNet.to_felt();

// Declare same class twice
let internal_declare = InternalDeclare::new(
let internal_declare = Declare::new(
fib_contract_class,
chain_id,
Address(Felt252::one()),
Expand Down Expand Up @@ -779,7 +779,7 @@ mod tests {

let chain_id = StarknetChainId::TestNet.to_felt();

let internal_declare = InternalDeclare::new(
let internal_declare = Declare::new(
fib_contract_class,
chain_id,
Address(Felt252::one()),
Expand Down Expand Up @@ -842,7 +842,7 @@ mod tests {
let chain_id = StarknetChainId::TestNet.to_felt();

// Use non-zero value so that the actual fee calculation is done
let internal_declare = InternalDeclare::new(
let internal_declare = Declare::new(
fib_contract_class,
chain_id,
Address(Felt252::one()),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use crate::{
transaction::{
error::TransactionError,
fee::{calculate_tx_fee, execute_fee_transfer, FeeInfo},
objects::internal_invoke_function::verify_no_calls_to_other_contracts,
invoke_function::verify_no_calls_to_other_contracts,
},
},
core::transaction_hash::calculate_declare_v2_transaction_hash,
Expand All @@ -26,7 +26,7 @@ use num_traits::Zero;
use starknet_contract_class::EntryPointType;
use std::collections::HashMap;
#[derive(Debug)]
pub struct InternalDeclareV2 {
pub struct DeclareV2 {
pub sender_address: Address,
pub tx_type: TransactionType,
pub validate_entry_point_selector: Felt252,
Expand All @@ -40,7 +40,7 @@ pub struct InternalDeclareV2 {
pub casm_class: once_cell::unsync::OnceCell<CasmContractClass>,
}

impl InternalDeclareV2 {
impl DeclareV2 {
#[allow(clippy::too_many_arguments)]
pub fn new(
sierra_contract_class: &SierraContractClass,
Expand Down Expand Up @@ -68,7 +68,7 @@ impl InternalDeclareV2 {
)?,
};

let internal_declare = InternalDeclareV2 {
let internal_declare = DeclareV2 {
sierra_contract_class: sierra_contract_class.to_owned(),
sender_address,
tx_type: TransactionType::Declare,
Expand Down Expand Up @@ -110,7 +110,7 @@ impl InternalDeclareV2 {
}

// ~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Internal Account Functions
// Account Functions
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~
pub fn get_execution_context(&self, n_steps: u64) -> TransactionExecutionContext {
TransactionExecutionContext::new(
Expand Down Expand Up @@ -279,7 +279,7 @@ impl InternalDeclareV2 {
mod tests {
use std::{collections::HashMap, fs::File, io::BufReader, path::PathBuf};

use super::InternalDeclareV2;
use super::DeclareV2;
use crate::business_logic::state::state_api::StateReader;
use crate::services::api::contract_classes::compiled_class::CompiledClass;
use crate::{
Expand Down Expand Up @@ -309,7 +309,7 @@ mod tests {

// create internal declare v2

let internal_declare = InternalDeclareV2::new(
let internal_declare = DeclareV2::new(
&sierra_contract_class,
Felt252::one(),
chain_id,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ use num_traits::Zero;
use starknet_contract_class::EntryPointType;

#[derive(Debug)]
pub struct InternalDeploy {
pub struct Deploy {
pub hash_value: Felt252,
pub version: u64,
pub contract_address: Address,
Expand All @@ -36,7 +36,7 @@ pub struct InternalDeploy {
pub tx_type: TransactionType,
}

impl InternalDeploy {
impl Deploy {
pub fn new(
contract_address_salt: Address,
contract_class: ContractClass,
Expand Down Expand Up @@ -66,7 +66,7 @@ impl InternalDeploy {
)?,
};

Ok(InternalDeploy {
Ok(Deploy {
hash_value,
version,
contract_address,
Expand Down Expand Up @@ -246,7 +246,7 @@ mod tests {
.set_contract_class(&class_hash_bytes, &contract_class)
.unwrap();

let internal_deploy = InternalDeploy::new(
let internal_deploy = Deploy::new(
Address(0.into()),
contract_class,
vec![10.into()],
Expand Down Expand Up @@ -296,7 +296,7 @@ mod tests {
.set_contract_class(&class_hash_bytes, &contract_class)
.unwrap();

let internal_deploy = InternalDeploy::new(
let internal_deploy = Deploy::new(
Address(0.into()),
contract_class,
Vec::new(),
Expand Down Expand Up @@ -331,7 +331,7 @@ mod tests {
.set_contract_class(&class_hash_bytes, &contract_class)
.unwrap();

let internal_deploy = InternalDeploy::new(
let internal_deploy = Deploy::new(
Address(0.into()),
contract_class,
vec![10.into()],
Expand Down Expand Up @@ -362,7 +362,7 @@ mod tests {
};

// Should fail when compouting the hash due to a failed contract class
let internal_deploy_error = InternalDeploy::new(
let internal_deploy_error = Deploy::new(
Address(0.into()),
error_contract_class,
Vec::new(),
Expand Down
Loading