Skip to content

Commit

Permalink
build(fee): remove more occurnces of resource mapping
Browse files Browse the repository at this point in the history
  • Loading branch information
nimrod-starkware committed Aug 22, 2024
1 parent 2bf3583 commit f92c17b
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 29 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
use std::collections::BTreeMap;

use cairo_vm::Felt252;
use num_traits::Pow;
use starknet_api::core::ChainId;
Expand All @@ -8,14 +6,13 @@ use starknet_api::felt;
use starknet_api::transaction::{
AccountDeploymentData,
Calldata,
DeprecatedResourceBoundsMapping,
Fee,
PaymasterData,
Resource,
ResourceBounds,
Tip,
TransactionHash,
TransactionVersion,
ValidResourceBounds,
};
use starknet_types_core::felt::Felt;
use test_case::test_case;
Expand Down Expand Up @@ -213,23 +210,10 @@ fn test_get_execution_info(
only_query,
..Default::default()
},
resource_bounds: DeprecatedResourceBoundsMapping(BTreeMap::from([
(
Resource::L1Gas,
// TODO(Ori, 1/2/2024): Write an indicative expect message explaining why
// the convertion works.
ResourceBounds {
max_amount: max_amount
.0
.try_into()
.expect("Failed to convert u128 to u64."),
max_price_per_unit: max_price_per_unit.0,
},
),
(Resource::L2Gas, ResourceBounds { max_amount: 0, max_price_per_unit: 0 }),
]))
.try_into()
.unwrap(),
resource_bounds: ValidResourceBounds::L1Gas(ResourceBounds {
max_amount: max_amount.0.try_into().expect("Failed to convert u128 to u64."),
max_price_per_unit: max_price_per_unit.0,
}),
tip: Tip::default(),
nonce_data_availability_mode: DataAvailabilityMode::L1,
fee_data_availability_mode: DataAvailabilityMode::L1,
Expand Down
2 changes: 0 additions & 2 deletions crates/papyrus_storage/src/serialization/serializers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ use starknet_api::transaction::{
DeployAccountTransactionV3,
DeployTransaction,
DeployTransactionOutput,
DeprecatedResourceBoundsMapping,
Event,
EventContent,
EventData,
Expand Down Expand Up @@ -368,7 +367,6 @@ auto_storage_serde! {
pub max_amount: u64,
pub max_price_per_unit: u128,
}
pub struct DeprecatedResourceBoundsMapping(pub BTreeMap<Resource, ResourceBounds>);
pub struct SequencerContractAddress(pub ContractAddress);
pub struct Signature {
pub r: Felt,
Expand Down
2 changes: 0 additions & 2 deletions crates/papyrus_test_utils/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,6 @@ use starknet_api::transaction::{
DeployAccountTransactionV3,
DeployTransaction,
DeployTransactionOutput,
DeprecatedResourceBoundsMapping,
Event,
EventContent,
EventData,
Expand Down Expand Up @@ -729,7 +728,6 @@ auto_impl_get_test_instance! {
pub max_amount: u64,
pub max_price_per_unit: u128,
}
pub struct DeprecatedResourceBoundsMapping(pub BTreeMap<Resource, ResourceBounds>);
pub struct SequencerContractAddress(pub ContractAddress);
pub struct Signature {
pub r: Felt,
Expand Down
8 changes: 4 additions & 4 deletions crates/starknet_client/src/writer/objects/transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@ use starknet_api::transaction::{
AccountDeploymentData,
Calldata,
ContractAddressSalt,
DeprecatedResourceBoundsMapping,
Fee,
PaymasterData,
Tip,
TransactionSignature,
TransactionVersion,
ValidResourceBounds,
};

// Each transaction type has a field called `type`. This field needs to be of a type that
Expand Down Expand Up @@ -104,7 +104,7 @@ pub struct DeployAccountV1Transaction {
#[derive(Debug, Deserialize, Serialize, Clone, Eq, PartialEq)]
#[serde(deny_unknown_fields)]
pub struct DeployAccountV3Transaction {
pub resource_bounds: DeprecatedResourceBoundsMapping,
pub resource_bounds: ValidResourceBounds,
pub tip: Tip,
pub contract_address_salt: ContractAddressSalt,
pub class_hash: ClassHash,
Expand Down Expand Up @@ -169,7 +169,7 @@ pub struct InvokeV1Transaction {
#[derive(Debug, Deserialize, Serialize, Clone, Eq, PartialEq)]
#[serde(deny_unknown_fields)]
pub struct InvokeV3Transaction {
pub resource_bounds: DeprecatedResourceBoundsMapping,
pub resource_bounds: ValidResourceBounds,
pub tip: Tip,
pub calldata: Calldata,
pub sender_address: ContractAddress,
Expand Down Expand Up @@ -235,7 +235,7 @@ pub struct DeclareV2Transaction {
#[serde(deny_unknown_fields)]
pub struct DeclareV3Transaction {
pub contract_class: ContractClass,
pub resource_bounds: DeprecatedResourceBoundsMapping,
pub resource_bounds: ValidResourceBounds,
pub tip: Tip,
pub signature: TransactionSignature,
pub nonce: Nonce,
Expand Down

0 comments on commit f92c17b

Please sign in to comment.