|
2 | 2 | use std::{collections::HashMap, io::Bytes, path::Path, vec};
|
3 | 3 |
|
4 | 4 | use crate::{
|
| 5 | + call_contract, |
5 | 6 | definitions::{
|
6 | 7 | block_context::{BlockContext, StarknetChainId},
|
7 | 8 | constants::CONSTRUCTOR_ENTRY_POINT_SELECTOR,
|
@@ -37,57 +38,6 @@ use super::{
|
37 | 38 | TEST_ERC20_CONTRACT_CLASS_HASH,
|
38 | 39 | };
|
39 | 40 |
|
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 |
| - |
91 | 41 | #[test]
|
92 | 42 | fn test_erc20_cairo2() {
|
93 | 43 | // data to deploy
|
|
0 commit comments