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

Use explicit transaction version in InternalInvokeFunction::new #549

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
3 changes: 2 additions & 1 deletion bench/internals.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use starknet_rs::{
},
},
core::contract_address::starknet_contract_address::compute_deprecated_class_hash,
definitions::general_config::StarknetChainId,
definitions::{constants::TRANSACTION_VERSION, general_config::StarknetChainId},
public::abi::VALIDATE_ENTRY_POINT_SELECTOR,
services::api::contract_classes::deprecated_contract_class::ContractClass,
utils::Address,
Expand Down Expand Up @@ -209,6 +209,7 @@ fn invoke() {
address,
selector,
0,
TRANSACTION_VERSION,
calldata,
signature,
StarknetChainId::TestNet.to_felt(),
Expand Down
7 changes: 6 additions & 1 deletion src/bin/invoke_with_cachedstate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ use starknet_rs::{
state::{cached_state::CachedState, state_api_objects::BlockInfo},
transaction::objects::internal_invoke_function::InternalInvokeFunction,
},
definitions::general_config::{StarknetChainId, StarknetGeneralConfig, StarknetOsConfig},
definitions::{
constants::TRANSACTION_VERSION,
general_config::{StarknetChainId, StarknetGeneralConfig, StarknetOsConfig},
},
services::api::contract_classes::deprecated_contract_class::ContractClass,
utils::Address,
};
Expand Down Expand Up @@ -56,6 +59,7 @@ fn main() {
CONTRACT_ADDRESS.clone(),
INCREASE_BALANCE_SELECTOR.clone(),
2,
TRANSACTION_VERSION,
vec![1000.into()],
vec![],
StarknetChainId::TestNet.to_felt(),
Expand All @@ -70,6 +74,7 @@ fn main() {
CONTRACT_ADDRESS.clone(),
GET_BALANCE_SELECTOR.clone(),
2,
TRANSACTION_VERSION,
vec![],
vec![],
StarknetChainId::TestNet.to_felt(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ use crate::{
calculate_transaction_hash_common, TransactionHashPrefix,
},
definitions::{
constants::{EXECUTE_ENTRY_POINT_SELECTOR, TRANSACTION_VERSION},
general_config::StarknetGeneralConfig,
constants::EXECUTE_ENTRY_POINT_SELECTOR, general_config::StarknetGeneralConfig,
transaction_type::TransactionType,
},
public::abi::VALIDATE_ENTRY_POINT_SELECTOR,
Expand Down Expand Up @@ -54,13 +53,13 @@ impl InternalInvokeFunction {
contract_address: Address,
entry_point_selector: Felt252,
max_fee: u128,
version: u64,
calldata: Vec<Felt252>,
signature: Vec<Felt252>,
chain_id: Felt252,
nonce: Option<Felt252>,
hash_value: Option<Felt252>,
) -> Result<Self, TransactionError> {
let version = TRANSACTION_VERSION;
let (entry_point_selector_field, additional_data) = preprocess_invoke_function_fields(
entry_point_selector.clone(),
nonce.clone(),
Expand Down
6 changes: 5 additions & 1 deletion src/core/syscalls/deprecated_syscall_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,10 @@ mod tests {
DeprecatedDeployRequest, DeprecatedSendMessageToL1SysCallRequest,
DeprecatedSyscallRequest,
},
definitions::{general_config::StarknetGeneralConfig, transaction_type::TransactionType},
definitions::{
constants::TRANSACTION_VERSION, general_config::StarknetGeneralConfig,
transaction_type::TransactionType,
},
memory_insert,
services::api::contract_classes::deprecated_contract_class::{
ContractClass, EntryPointType,
Expand Down Expand Up @@ -1090,6 +1093,7 @@ mod tests {
)
.unwrap(),
0,
TRANSACTION_VERSION,
vec![10.into()],
Vec::new(),
0.into(),
Expand Down
1 change: 1 addition & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ fn invoke_parser(
contract_address.clone(),
entrypoint_selector.clone(),
0,
TRANSACTION_VERSION,
calldata.clone(),
vec![],
Felt252::zero(),
Expand Down
1 change: 1 addition & 0 deletions src/testing/starknet_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,7 @@ impl StarknetState {
contract_address,
entry_point_selector,
max_fee,
TRANSACTION_VERSION,
calldata,
signature,
self.chain_id(),
Expand Down
2 changes: 2 additions & 0 deletions tests/internals.rs
Original file line number Diff line number Diff line change
Expand Up @@ -527,6 +527,7 @@ fn invoke_tx(calldata: Vec<Felt252>) -> InternalInvokeFunction {
TEST_ACCOUNT_CONTRACT_ADDRESS.clone(),
EXECUTE_ENTRY_POINT_SELECTOR.clone(),
2,
TRANSACTION_VERSION,
calldata,
vec![],
StarknetChainId::TestNet.to_felt(),
Expand Down Expand Up @@ -1317,6 +1318,7 @@ fn test_invoke_tx_wrong_entrypoint() {
// Entrypoiont that doesnt exits in the contract
Felt252::from_bytes_be(&calculate_sn_keccak(b"none_function")),
1,
TRANSACTION_VERSION,
vec![
test_contract_address, // CONTRACT_ADDRESS
Felt252::from_bytes_be(&calculate_sn_keccak(b"return_result")), // CONTRACT FUNCTION SELECTOR
Expand Down