Skip to content
This repository was archived by the owner on Jul 22, 2024. It is now read-only.

Commit efda09e

Browse files
remove duplicated function
1 parent ff4b3bb commit efda09e

File tree

2 files changed

+3
-52
lines changed

2 files changed

+3
-52
lines changed

src/lib.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ pub fn call_contract<T: State + StateReader>(
108108
calldata: Vec<Felt252>,
109109
state: &mut T,
110110
block_context: BlockContext,
111+
caller_address: Address,
111112
) -> Result<Vec<Felt252>, TransactionError> {
112113
let contract_address = Address(contract_address);
113114
let class_hash = state.get_class_hash_at(&contract_address)?;
@@ -118,7 +119,6 @@ pub fn call_contract<T: State + StateReader>(
118119
let signature = vec![];
119120
let max_fee = 1000000000;
120121
let initial_gas = 1000000000;
121-
let caller_address = Address(0.into());
122122
let version = 0;
123123

124124
let execution_entrypoint = ExecutionEntryPoint::new(
@@ -319,6 +319,7 @@ mod test {
319319
calldata,
320320
&mut state,
321321
BlockContext::default(),
322+
Address(0.into()),
322323
)
323324
.unwrap();
324325

src/testing/erc20.rs

Lines changed: 1 addition & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
use std::{collections::HashMap, io::Bytes, path::Path, vec};
33

44
use crate::{
5+
call_contract,
56
definitions::{
67
block_context::{BlockContext, StarknetChainId},
78
constants::CONSTRUCTOR_ENTRY_POINT_SELECTOR,
@@ -37,57 +38,6 @@ use super::{
3738
TEST_ERC20_CONTRACT_CLASS_HASH,
3839
};
3940

40-
pub fn call_contract<T: State + StateReader>(
41-
contract_address: Felt252,
42-
entrypoint_selector: Felt252,
43-
calldata: Vec<Felt252>,
44-
state: &mut T,
45-
block_context: BlockContext,
46-
caller_address: Address,
47-
) -> Result<Vec<Felt252>, TransactionError> {
48-
let contract_address = Address(contract_address);
49-
let class_hash = state.get_class_hash_at(&contract_address)?;
50-
let nonce = state.get_nonce_at(&contract_address)?;
51-
52-
// TODO: Revisit these parameters
53-
let transaction_hash = 0.into();
54-
let signature = vec![];
55-
let max_fee = 1000000000;
56-
let initial_gas = 1000000000;
57-
let version = 0;
58-
59-
let execution_entrypoint = ExecutionEntryPoint::new(
60-
contract_address.clone(),
61-
calldata,
62-
entrypoint_selector,
63-
caller_address,
64-
EntryPointType::External,
65-
Some(CallType::Delegate),
66-
Some(class_hash),
67-
initial_gas,
68-
);
69-
70-
let mut tx_execution_context = TransactionExecutionContext::new(
71-
contract_address,
72-
transaction_hash,
73-
signature,
74-
max_fee,
75-
nonce,
76-
block_context.invoke_tx_max_n_steps(),
77-
version.into(),
78-
);
79-
80-
let call_info = execution_entrypoint.execute(
81-
state,
82-
&block_context,
83-
&mut ExecutionResourcesManager::default(),
84-
&mut tx_execution_context,
85-
false,
86-
)?;
87-
88-
Ok(call_info.retdata)
89-
}
90-
9141
#[test]
9242
fn test_erc20_cairo2() {
9343
// data to deploy

0 commit comments

Comments
 (0)