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

Commit 496786c

Browse files
authored
Remove redundant tx_type field from transactions. (#1019)
Co-authored-by: Esteve Soler Arderiu <esteve.soler@lambdaclass.com>
1 parent 6327d2c commit 496786c

File tree

5 files changed

+7
-20
lines changed

5 files changed

+7
-20
lines changed

src/lib.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,6 @@ mod test {
216216
EXECUTE_ENTRY_POINT_SELECTOR, VALIDATE_DECLARE_ENTRY_POINT_SELECTOR,
217217
VALIDATE_ENTRY_POINT_SELECTOR,
218218
},
219-
transaction_type::TransactionType,
220219
};
221220
use crate::estimate_fee;
222221
use crate::estimate_message_fee;
@@ -870,7 +869,6 @@ mod test {
870869

871870
DeclareV2 {
872871
sender_address: TEST_ACCOUNT_CONTRACT_ADDRESS.clone(),
873-
tx_type: TransactionType::Declare,
874872
validate_entry_point_selector: VALIDATE_DECLARE_ENTRY_POINT_SELECTOR.clone(),
875873
version: 1.into(),
876874
max_fee: INITIAL_GAS_COST,

src/transaction/declare.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ use std::sync::Arc;
3939
pub struct Declare {
4040
pub class_hash: ClassHash,
4141
pub sender_address: Address,
42-
pub tx_type: TransactionType,
4342
pub validate_entry_point_selector: Felt252,
4443
pub version: Felt252,
4544
pub max_fee: u128,
@@ -83,7 +82,6 @@ impl Declare {
8382
let internal_declare = Declare {
8483
class_hash,
8584
sender_address,
86-
tx_type: TransactionType::Declare,
8785
validate_entry_point_selector,
8886
version,
8987
max_fee,
@@ -124,7 +122,6 @@ impl Declare {
124122
let internal_declare = Declare {
125123
class_hash,
126124
sender_address,
127-
tx_type: TransactionType::Declare,
128125
validate_entry_point_selector,
129126
version,
130127
max_fee,
@@ -187,7 +184,7 @@ impl Declare {
187184
None,
188185
None,
189186
actual_resources,
190-
Some(self.tx_type),
187+
Some(TransactionType::Declare),
191188
))
192189
}
193190

src/transaction/declare_v2.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ use std::sync::Arc;
3535
#[derive(Debug, Clone)]
3636
pub struct DeclareV2 {
3737
pub sender_address: Address,
38-
pub tx_type: TransactionType,
3938
pub validate_entry_point_selector: Felt252,
4039
pub version: Felt252,
4140
pub max_fee: u128,
@@ -135,7 +134,6 @@ impl DeclareV2 {
135134
sierra_contract_class: sierra_contract_class.to_owned(),
136135
sierra_class_hash,
137136
sender_address,
138-
tx_type: TransactionType::Declare,
139137
validate_entry_point_selector,
140138
version,
141139
max_fee,
@@ -327,7 +325,7 @@ impl DeclareV2 {
327325
let actual_resources = calculate_tx_resources(
328326
resources_manager,
329327
&[execution_result.call_info.clone()],
330-
self.tx_type,
328+
TransactionType::Declare,
331329
storage_changes,
332330
None,
333331
execution_result.n_reverted_steps,
@@ -350,7 +348,7 @@ impl DeclareV2 {
350348
None,
351349
None,
352350
actual_resources,
353-
Some(self.tx_type),
351+
Some(TransactionType::Declare),
354352
);
355353
tx_exec_info.set_fee_info(actual_fee, fee_transfer_info);
356354

src/transaction/deploy.rs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ pub struct Deploy {
4343
pub contract_hash: ClassHash,
4444
pub contract_class: CompiledClass,
4545
pub constructor_calldata: Vec<Felt252>,
46-
pub tx_type: TransactionType,
4746
pub skip_validate: bool,
4847
pub skip_execute: bool,
4948
pub skip_fee_transfer: bool,
@@ -84,7 +83,6 @@ impl Deploy {
8483
contract_hash,
8584
contract_class: CompiledClass::Deprecated(Arc::new(contract_class)),
8685
constructor_calldata,
87-
tx_type: TransactionType::Deploy,
8886
skip_validate: false,
8987
skip_execute: false,
9088
skip_fee_transfer: false,
@@ -117,7 +115,6 @@ impl Deploy {
117115
contract_hash,
118116
constructor_calldata,
119117
contract_class: CompiledClass::Deprecated(Arc::new(contract_class)),
120-
tx_type: TransactionType::Deploy,
121118
skip_validate: false,
122119
skip_execute: false,
123120
skip_fee_transfer: false,
@@ -186,7 +183,7 @@ impl Deploy {
186183
let actual_resources = calculate_tx_resources(
187184
resources_manager,
188185
&[Some(call_info.clone())],
189-
self.tx_type,
186+
TransactionType::Deploy,
190187
changes,
191188
None,
192189
0,
@@ -197,7 +194,7 @@ impl Deploy {
197194
Some(call_info),
198195
None,
199196
actual_resources,
200-
Some(self.tx_type),
197+
Some(TransactionType::Deploy),
201198
))
202199
}
203200

@@ -249,7 +246,7 @@ impl Deploy {
249246
let actual_resources = calculate_tx_resources(
250247
resources_manager,
251248
&[call_info.clone()],
252-
self.tx_type,
249+
TransactionType::Deploy,
253250
changes,
254251
None,
255252
n_reverted_steps,
@@ -260,7 +257,7 @@ impl Deploy {
260257
call_info,
261258
revert_error,
262259
actual_resources,
263-
Some(self.tx_type),
260+
Some(TransactionType::Deploy),
264261
))
265262
}
266263

tests/internals.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -739,7 +739,6 @@ fn declare_tx() -> Declare {
739739
contract_class: ContractClass::from_path(TEST_EMPTY_CONTRACT_PATH).unwrap(),
740740
class_hash: felt_to_hash(&TEST_EMPTY_CONTRACT_CLASS_HASH),
741741
sender_address: TEST_ACCOUNT_CONTRACT_ADDRESS.clone(),
742-
tx_type: TransactionType::Declare,
743742
validate_entry_point_selector: VALIDATE_DECLARE_ENTRY_POINT_SELECTOR.clone(),
744743
version: 1.into(),
745744
max_fee: 100000,
@@ -765,7 +764,6 @@ fn declarev2_tx() -> DeclareV2 {
765764

766765
DeclareV2 {
767766
sender_address: TEST_ACCOUNT_CONTRACT_ADDRESS.clone(),
768-
tx_type: TransactionType::Declare,
769767
validate_entry_point_selector: VALIDATE_DECLARE_ENTRY_POINT_SELECTOR.clone(),
770768
version: 1.into(),
771769
max_fee: 50000000,
@@ -808,7 +806,6 @@ fn deploy_fib_syscall() -> Deploy {
808806
contract_hash,
809807
contract_class,
810808
constructor_calldata: Vec::new(),
811-
tx_type: TransactionType::Deploy,
812809
skip_execute: false,
813810
skip_fee_transfer: false,
814811
skip_validate: false,

0 commit comments

Comments
 (0)