Skip to content

Commit dcd8a60

Browse files
committed
remove unused code
1 parent 2d9ae1a commit dcd8a60

File tree

1 file changed

+3
-316
lines changed

1 file changed

+3
-316
lines changed

crates/rpc/rpc-types/src/broadcasted.rs

Lines changed: 3 additions & 316 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,10 @@ use katana_primitives::class::{
77
};
88
use katana_primitives::contract::Nonce;
99
use katana_primitives::da::DataAvailabilityMode;
10-
use katana_primitives::fee::{
11-
L1GasResourceBoundsMapping, ResourceBounds, ResourceBoundsMapping, Tip,
12-
};
10+
use katana_primitives::fee::{ResourceBoundsMapping, Tip};
1311
use katana_primitives::transaction::{
14-
DeclareTx, DeclareTxV0, DeclareTxV1, DeclareTxV2, DeclareTxV3, DeclareTxWithClass,
15-
DeployAccountTx, DeployAccountTxV1, DeployAccountTxV3, ExecutableTx, ExecutableTxWithHash,
16-
InvokeTx, InvokeTxV0, InvokeTxV1, InvokeTxV3, TxHash, TxType,
12+
DeclareTx, DeclareTxV3, DeclareTxWithClass, DeployAccountTx, DeployAccountTxV3, ExecutableTx,
13+
ExecutableTxWithHash, InvokeTx, InvokeTxV3, TxHash, TxType,
1714
};
1815
use katana_primitives::utils::get_contract_address;
1916
use katana_primitives::{ContractAddress, Felt};
@@ -326,316 +323,6 @@ impl From<BroadcastedDeployAccountTx> for UntypedBroadcastedTx {
326323
}
327324
}
328325

329-
// From implementations for primitive types to broadcasted types
330-
331-
impl From<InvokeTx> for BroadcastedInvokeTx {
332-
fn from(tx: InvokeTx) -> Self {
333-
match tx {
334-
InvokeTx::V0(tx) => tx.into(),
335-
InvokeTx::V1(tx) => tx.into(),
336-
InvokeTx::V3(tx) => tx.into(),
337-
}
338-
}
339-
}
340-
341-
impl From<InvokeTxV0> for BroadcastedInvokeTx {
342-
fn from(tx: InvokeTxV0) -> Self {
343-
BroadcastedInvokeTx {
344-
sender_address: tx.contract_address,
345-
calldata: tx.calldata,
346-
signature: tx.signature,
347-
nonce: Felt::ZERO,
348-
paymaster_data: vec![],
349-
tip: 0.into(),
350-
account_deployment_data: vec![],
351-
resource_bounds: ResourceBoundsMapping::L1Gas(L1GasResourceBoundsMapping {
352-
l1_gas: ResourceBounds { max_amount: 0, max_price_per_unit: tx.max_fee },
353-
l2_gas: ResourceBounds { max_amount: 0, max_price_per_unit: 0 },
354-
}),
355-
fee_data_availability_mode: DataAvailabilityMode::L1,
356-
nonce_data_availability_mode: DataAvailabilityMode::L1,
357-
is_query: false,
358-
}
359-
}
360-
}
361-
362-
impl From<InvokeTxV1> for BroadcastedInvokeTx {
363-
fn from(tx: InvokeTxV1) -> Self {
364-
BroadcastedInvokeTx {
365-
sender_address: tx.sender_address,
366-
calldata: tx.calldata,
367-
signature: tx.signature,
368-
nonce: tx.nonce,
369-
paymaster_data: vec![],
370-
tip: 0.into(),
371-
account_deployment_data: vec![],
372-
resource_bounds: ResourceBoundsMapping::L1Gas(L1GasResourceBoundsMapping {
373-
l1_gas: ResourceBounds { max_amount: 0, max_price_per_unit: tx.max_fee },
374-
l2_gas: ResourceBounds { max_amount: 0, max_price_per_unit: 0 },
375-
}),
376-
fee_data_availability_mode: DataAvailabilityMode::L1,
377-
nonce_data_availability_mode: DataAvailabilityMode::L1,
378-
is_query: false,
379-
}
380-
}
381-
}
382-
383-
impl From<InvokeTxV3> for BroadcastedInvokeTx {
384-
fn from(tx: InvokeTxV3) -> Self {
385-
BroadcastedInvokeTx {
386-
sender_address: tx.sender_address,
387-
calldata: tx.calldata,
388-
signature: tx.signature,
389-
nonce: tx.nonce,
390-
paymaster_data: tx.paymaster_data,
391-
tip: tx.tip.into(),
392-
account_deployment_data: tx.account_deployment_data,
393-
resource_bounds: tx.resource_bounds,
394-
fee_data_availability_mode: tx.fee_data_availability_mode,
395-
nonce_data_availability_mode: tx.nonce_data_availability_mode,
396-
is_query: false,
397-
}
398-
}
399-
}
400-
401-
impl From<DeclareTx> for BroadcastedDeclareTx {
402-
fn from(tx: DeclareTx) -> Self {
403-
match tx {
404-
DeclareTx::V0(tx) => tx.into(),
405-
DeclareTx::V1(tx) => tx.into(),
406-
DeclareTx::V2(tx) => tx.into(),
407-
DeclareTx::V3(tx) => tx.into(),
408-
}
409-
}
410-
}
411-
412-
impl From<DeclareTxV0> for BroadcastedDeclareTx {
413-
fn from(tx: DeclareTxV0) -> Self {
414-
// Note: V0 declare transactions use legacy classes, but BroadcastedDeclareTx expects
415-
// Sierra. The actual contract class needs to be provided separately.
416-
BroadcastedDeclareTx {
417-
sender_address: tx.sender_address,
418-
compiled_class_hash: CompiledClassHash::ZERO,
419-
signature: tx.signature,
420-
nonce: Felt::ZERO,
421-
contract_class: Arc::new(SierraClass::default()),
422-
paymaster_data: vec![],
423-
tip: 0.into(),
424-
account_deployment_data: vec![],
425-
resource_bounds: ResourceBoundsMapping::L1Gas(L1GasResourceBoundsMapping {
426-
l1_gas: ResourceBounds { max_amount: 0, max_price_per_unit: tx.max_fee },
427-
l2_gas: ResourceBounds { max_amount: 0, max_price_per_unit: 0 },
428-
}),
429-
fee_data_availability_mode: DataAvailabilityMode::L1,
430-
nonce_data_availability_mode: DataAvailabilityMode::L1,
431-
is_query: false,
432-
}
433-
}
434-
}
435-
436-
impl From<DeclareTxV1> for BroadcastedDeclareTx {
437-
fn from(tx: DeclareTxV1) -> Self {
438-
// Note: V1 declare transactions use legacy classes, but BroadcastedDeclareTx expects
439-
// Sierra. The actual contract class needs to be provided separately.
440-
BroadcastedDeclareTx {
441-
sender_address: tx.sender_address,
442-
compiled_class_hash: CompiledClassHash::ZERO,
443-
signature: tx.signature,
444-
nonce: tx.nonce,
445-
contract_class: Arc::new(SierraClass::default()),
446-
paymaster_data: vec![],
447-
tip: 0.into(),
448-
account_deployment_data: vec![],
449-
resource_bounds: ResourceBoundsMapping::L1Gas(L1GasResourceBoundsMapping {
450-
l1_gas: ResourceBounds { max_amount: 0, max_price_per_unit: tx.max_fee },
451-
l2_gas: ResourceBounds { max_amount: 0, max_price_per_unit: 0 },
452-
}),
453-
fee_data_availability_mode: DataAvailabilityMode::L1,
454-
nonce_data_availability_mode: DataAvailabilityMode::L1,
455-
is_query: false,
456-
}
457-
}
458-
}
459-
460-
impl From<DeclareTxV2> for BroadcastedDeclareTx {
461-
fn from(tx: DeclareTxV2) -> Self {
462-
BroadcastedDeclareTx {
463-
sender_address: tx.sender_address,
464-
compiled_class_hash: tx.compiled_class_hash,
465-
signature: tx.signature,
466-
nonce: tx.nonce,
467-
contract_class: Arc::new(SierraClass::default()),
468-
paymaster_data: vec![],
469-
tip: 0.into(),
470-
account_deployment_data: vec![],
471-
resource_bounds: ResourceBoundsMapping::L1Gas(L1GasResourceBoundsMapping {
472-
l1_gas: ResourceBounds { max_amount: 0, max_price_per_unit: tx.max_fee },
473-
l2_gas: ResourceBounds { max_amount: 0, max_price_per_unit: 0 },
474-
}),
475-
fee_data_availability_mode: DataAvailabilityMode::L1,
476-
nonce_data_availability_mode: DataAvailabilityMode::L1,
477-
is_query: false,
478-
}
479-
}
480-
}
481-
482-
impl From<DeclareTxV3> for BroadcastedDeclareTx {
483-
fn from(tx: DeclareTxV3) -> Self {
484-
BroadcastedDeclareTx {
485-
sender_address: tx.sender_address,
486-
compiled_class_hash: tx.compiled_class_hash,
487-
signature: tx.signature,
488-
nonce: tx.nonce,
489-
contract_class: Arc::new(SierraClass::default()),
490-
paymaster_data: tx.paymaster_data,
491-
tip: tx.tip.into(),
492-
account_deployment_data: tx.account_deployment_data,
493-
resource_bounds: tx.resource_bounds,
494-
fee_data_availability_mode: tx.fee_data_availability_mode,
495-
nonce_data_availability_mode: tx.nonce_data_availability_mode,
496-
is_query: false,
497-
}
498-
}
499-
}
500-
501-
impl From<DeclareTxWithClass> for BroadcastedDeclareTx {
502-
fn from(tx: DeclareTxWithClass) -> Self {
503-
// Convert ContractClass to SierraClass
504-
// Note: This conversion may lose information for legacy classes
505-
let contract_class = match tx.class.as_ref() {
506-
ContractClass::Class(sierra) => Arc::new(SierraClass::from(sierra.clone())),
507-
ContractClass::Legacy(_) => Arc::new(SierraClass::default()),
508-
};
509-
510-
match tx.transaction {
511-
DeclareTx::V0(tx) => BroadcastedDeclareTx {
512-
sender_address: tx.sender_address,
513-
compiled_class_hash: CompiledClassHash::ZERO,
514-
signature: tx.signature,
515-
nonce: Felt::ZERO,
516-
contract_class,
517-
paymaster_data: vec![],
518-
tip: 0.into(),
519-
account_deployment_data: vec![],
520-
resource_bounds: ResourceBoundsMapping::L1Gas(L1GasResourceBoundsMapping {
521-
l1_gas: ResourceBounds { max_amount: 0, max_price_per_unit: tx.max_fee },
522-
l2_gas: ResourceBounds { max_amount: 0, max_price_per_unit: 0 },
523-
}),
524-
fee_data_availability_mode: DataAvailabilityMode::L1,
525-
nonce_data_availability_mode: DataAvailabilityMode::L1,
526-
is_query: false,
527-
},
528-
DeclareTx::V1(tx) => BroadcastedDeclareTx {
529-
sender_address: tx.sender_address,
530-
compiled_class_hash: CompiledClassHash::ZERO,
531-
signature: tx.signature,
532-
nonce: tx.nonce,
533-
contract_class,
534-
paymaster_data: vec![],
535-
tip: 0.into(),
536-
account_deployment_data: vec![],
537-
resource_bounds: ResourceBoundsMapping::L1Gas(L1GasResourceBoundsMapping {
538-
l1_gas: ResourceBounds { max_amount: 0, max_price_per_unit: tx.max_fee },
539-
l2_gas: ResourceBounds { max_amount: 0, max_price_per_unit: 0 },
540-
}),
541-
fee_data_availability_mode: DataAvailabilityMode::L1,
542-
nonce_data_availability_mode: DataAvailabilityMode::L1,
543-
is_query: false,
544-
},
545-
DeclareTx::V2(tx) => BroadcastedDeclareTx {
546-
sender_address: tx.sender_address,
547-
compiled_class_hash: tx.compiled_class_hash,
548-
signature: tx.signature,
549-
nonce: tx.nonce,
550-
contract_class,
551-
paymaster_data: vec![],
552-
tip: 0.into(),
553-
account_deployment_data: vec![],
554-
resource_bounds: ResourceBoundsMapping::L1Gas(L1GasResourceBoundsMapping {
555-
l1_gas: ResourceBounds { max_amount: 0, max_price_per_unit: tx.max_fee },
556-
l2_gas: ResourceBounds { max_amount: 0, max_price_per_unit: 0 },
557-
}),
558-
fee_data_availability_mode: DataAvailabilityMode::L1,
559-
nonce_data_availability_mode: DataAvailabilityMode::L1,
560-
is_query: false,
561-
},
562-
DeclareTx::V3(tx) => BroadcastedDeclareTx {
563-
sender_address: tx.sender_address,
564-
compiled_class_hash: tx.compiled_class_hash,
565-
signature: tx.signature,
566-
nonce: tx.nonce,
567-
contract_class,
568-
paymaster_data: tx.paymaster_data,
569-
tip: tx.tip.into(),
570-
account_deployment_data: tx.account_deployment_data,
571-
resource_bounds: tx.resource_bounds,
572-
fee_data_availability_mode: tx.fee_data_availability_mode,
573-
nonce_data_availability_mode: tx.nonce_data_availability_mode,
574-
is_query: false,
575-
},
576-
}
577-
}
578-
}
579-
580-
impl From<DeployAccountTx> for BroadcastedDeployAccountTx {
581-
fn from(tx: DeployAccountTx) -> Self {
582-
match tx {
583-
DeployAccountTx::V1(tx) => tx.into(),
584-
DeployAccountTx::V3(tx) => tx.into(),
585-
}
586-
}
587-
}
588-
589-
impl From<DeployAccountTxV1> for BroadcastedDeployAccountTx {
590-
fn from(tx: DeployAccountTxV1) -> Self {
591-
BroadcastedDeployAccountTx {
592-
signature: tx.signature,
593-
nonce: tx.nonce,
594-
contract_address_salt: tx.contract_address_salt,
595-
constructor_calldata: tx.constructor_calldata,
596-
class_hash: tx.class_hash,
597-
paymaster_data: vec![],
598-
tip: 0.into(),
599-
resource_bounds: ResourceBoundsMapping::L1Gas(L1GasResourceBoundsMapping {
600-
l1_gas: ResourceBounds { max_amount: 0, max_price_per_unit: tx.max_fee },
601-
l2_gas: ResourceBounds { max_amount: 0, max_price_per_unit: 0 },
602-
}),
603-
fee_data_availability_mode: DataAvailabilityMode::L1,
604-
nonce_data_availability_mode: DataAvailabilityMode::L1,
605-
is_query: false,
606-
}
607-
}
608-
}
609-
610-
impl From<DeployAccountTxV3> for BroadcastedDeployAccountTx {
611-
fn from(tx: DeployAccountTxV3) -> Self {
612-
BroadcastedDeployAccountTx {
613-
signature: tx.signature,
614-
nonce: tx.nonce,
615-
contract_address_salt: tx.contract_address_salt,
616-
constructor_calldata: tx.constructor_calldata,
617-
class_hash: tx.class_hash,
618-
paymaster_data: tx.paymaster_data,
619-
tip: tx.tip.into(),
620-
resource_bounds: tx.resource_bounds,
621-
fee_data_availability_mode: tx.fee_data_availability_mode,
622-
nonce_data_availability_mode: tx.nonce_data_availability_mode,
623-
is_query: false,
624-
}
625-
}
626-
}
627-
628-
impl From<ExecutableTx> for BroadcastedTx {
629-
fn from(tx: ExecutableTx) -> Self {
630-
match tx {
631-
ExecutableTx::Invoke(tx) => BroadcastedTx::Invoke(tx.into()),
632-
ExecutableTx::Declare(tx) => BroadcastedTx::Declare(tx.into()),
633-
ExecutableTx::DeployAccount(tx) => BroadcastedTx::DeployAccount(tx.into()),
634-
ExecutableTx::L1Handler(_) => unimplemented!(),
635-
}
636-
}
637-
}
638-
639326
/// A broadcasted transaction.
640327
#[derive(Debug, Clone, Serialize)]
641328
pub struct BroadcastedTxWithChainId {

0 commit comments

Comments
 (0)