diff --git a/crates/cairo-lang-starknet/src/plugin/plugin_test_data/components/component b/crates/cairo-lang-starknet/src/plugin/plugin_test_data/components/component index d235fc42987..61da52b35c3 100644 --- a/crates/cairo-lang-starknet/src/plugin/plugin_test_data/components/component +++ b/crates/cairo-lang-starknet/src/plugin/plugin_test_data/components/component @@ -1,7 +1,7 @@ //! > Test expansion of a basic component. //! > test_runner_name -ExpandContractTestRunner(expect_diagnostics: warnings_only) +ExpandContractTestRunner(expect_diagnostics: false) //! > cairo_code #[derive(Drop, starknet::Store)] @@ -17,6 +17,7 @@ mod component { #[storage] struct Storage { data: u32, + #[feature("deprecated_legacy_map")] map: LegacyMap, my_type_var: super::MyType, } @@ -66,6 +67,7 @@ mod component { #[storage] struct Storage { data: u32, + #[feature("deprecated_legacy_map")] map: LegacyMap, my_type_var: super::MyType, } @@ -186,7 +188,7 @@ impl MyTypeSubPointersMutImpl of starknet::storage::SubPointersMut { } -lib.cairo:41:1 +lib.cairo:42:1 #[starknet::interface] ^********************^ MyTraitDispatcherTrait: @@ -375,7 +377,7 @@ impl MyTypeSubPointersMutDrop of core::traits::Drop::; impl MyTypeSubPointersMutCopy of core::traits::Copy::; -lib.cairo:41:1 +lib.cairo:42:1 #[starknet::interface] ^********************^ impls: @@ -394,7 +396,7 @@ impl MyTraitDispatcherSerde of core::serde::Serde:: { } -lib.cairo:41:1 +lib.cairo:42:1 #[starknet::interface] ^********************^ starknet_derive: @@ -473,7 +475,7 @@ impl MyTraitDispatcherSubPointersMutImpl of starknet::storage::SubPointersMut { } -lib.cairo:41:1 +lib.cairo:42:1 #[starknet::interface] ^********************^ starknet_derive: @@ -767,7 +769,7 @@ impl MyTraitSafeDispatcherSubPointersMutImpl of starknet::storage::SubPointersMu } -lib.cairo:41:1 +lib.cairo:42:1 #[starknet::interface] ^********************^ impls: @@ -776,7 +778,7 @@ impl MyTraitDispatcherSubPointersDrop of core::traits::Drop::; -lib.cairo:41:1 +lib.cairo:42:1 #[starknet::interface] ^********************^ impls: @@ -785,7 +787,7 @@ impl MyTraitDispatcherSubPointersMutDrop of core::traits::Drop::; -lib.cairo:41:1 +lib.cairo:42:1 #[starknet::interface] ^********************^ impls: @@ -794,7 +796,7 @@ impl MyTraitLibraryDispatcherSubPointersDrop of core::traits::Drop::; -lib.cairo:41:1 +lib.cairo:42:1 #[starknet::interface] ^********************^ impls: @@ -803,7 +805,7 @@ impl MyTraitLibraryDispatcherSubPointersMutDrop of core::traits::Drop::; -lib.cairo:41:1 +lib.cairo:42:1 #[starknet::interface] ^********************^ impls: @@ -812,7 +814,7 @@ impl MyTraitSafeLibraryDispatcherSubPointersDrop of core::traits::Drop::; -lib.cairo:41:1 +lib.cairo:42:1 #[starknet::interface] ^********************^ impls: @@ -821,7 +823,7 @@ impl MyTraitSafeLibraryDispatcherSubPointersMutDrop of core::traits::Drop::; -lib.cairo:41:1 +lib.cairo:42:1 #[starknet::interface] ^********************^ impls: @@ -830,7 +832,7 @@ impl MyTraitSafeDispatcherSubPointersDrop of core::traits::Drop::; -lib.cairo:41:1 +lib.cairo:42:1 #[starknet::interface] ^********************^ impls: @@ -849,6 +851,7 @@ component: #[phantom] pub struct Storage { pub data: u32, + #[feature("deprecated_legacy_map")] pub map: LegacyMap, pub my_type_var: super::MyType, } @@ -857,6 +860,7 @@ pub struct Storage { #[doc(hidden)] pub struct StorageStorageBase { pub data: starknet::storage::StorageBase, + #[feature("deprecated_legacy_map")] pub map: starknet::storage::StorageBase>, pub my_type_var: starknet::storage::StorageBase, } @@ -878,6 +882,7 @@ impl StorageStorageImpl of starknet::storage::StorageTrait { #[doc(hidden)] pub struct StorageStorageBaseMut { pub data: starknet::storage::StorageBase>, + #[feature("deprecated_legacy_map")] pub map: starknet::storage::StorageBase>>, pub my_type_var: starknet::storage::StorageBase>, } @@ -956,7 +961,7 @@ impl TContractStateDrop: Drop } } -lib.cairo:19:14 +lib.cairo:20:14 #[derive(Drop, starknet::Event)] ^**^ impls: @@ -964,7 +969,7 @@ impls: impl EventDrop of core::traits::Drop::; -lib.cairo:19:20 +lib.cairo:20:20 #[derive(Drop, starknet::Event)] ^*************^ starknet_derive: @@ -1003,7 +1008,7 @@ impl EventLogIntoEvent of Into { -lib.cairo:23:14 +lib.cairo:24:14 #[derive(Drop, starknet::Event)] ^**^ impls: @@ -1011,7 +1016,7 @@ impls: impl LogDrop of core::traits::Drop::; -lib.cairo:23:20 +lib.cairo:24:20 #[derive(Drop, starknet::Event)] ^*************^ starknet_derive: @@ -1047,7 +1052,7 @@ impl StorageStorageBaseMutDrop of core::traits::Drop::; impl StorageStorageBaseMutCopy of core::traits::Copy::; -lib.cairo:26:5 +lib.cairo:27:5 #[embeddable_as(MyImpl)] ^**********************^ embeddable: @@ -1123,7 +1128,3 @@ pub mod __constructor_MyImpl { } //! > expected_diagnostics -warning: Usage of deprecated feature `"deprecated_legacy_map"` with no `#[feature("deprecated_legacy_map")]` attribute. Note: "Use `starknet::storage::Map` instead." - --> lib.cairo:14:14 - map: LegacyMap, - ^*******^ diff --git a/crates/cairo-lang-starknet/src/plugin/plugin_test_data/contracts/diagnostics b/crates/cairo-lang-starknet/src/plugin/plugin_test_data/contracts/diagnostics index 4252e750bf1..ff40443f3ba 100644 --- a/crates/cairo-lang-starknet/src/plugin/plugin_test_data/contracts/diagnostics +++ b/crates/cairo-lang-starknet/src/plugin/plugin_test_data/contracts/diagnostics @@ -8161,6 +8161,7 @@ pub struct Storage { #[derive(Drop, Copy)] #[doc(hidden)] pub struct StorageStorageBase { + #[substorage(v0)] pub component_storage: starknet::storage::FlattenedStorage, } #[doc(hidden)] @@ -8176,6 +8177,7 @@ impl StorageStorageImpl of starknet::storage::StorageTrait { #[derive(Drop, Copy)] #[doc(hidden)] pub struct StorageStorageBaseMut { + #[substorage(v0)] pub component_storage: starknet::storage::FlattenedStorage>, } #[doc(hidden)] @@ -8190,6 +8192,7 @@ impl StorageStorageMutImpl of starknet::storage::StorageTraitMut { } pub struct ContractState { + #[substorage(v0)] pub component_storage: super::component::ComponentState, } @@ -12718,6 +12721,7 @@ pub struct Storage { #[derive(Drop, Copy)] #[doc(hidden)] pub struct StorageStorageBase { + #[substorage(v0)] pub component_member: starknet::storage::FlattenedStorage, } #[doc(hidden)] @@ -12733,6 +12737,7 @@ impl StorageStorageImpl of starknet::storage::StorageTrait { #[derive(Drop, Copy)] #[doc(hidden)] pub struct StorageStorageBaseMut { + #[substorage(v0)] pub component_member: starknet::storage::FlattenedStorage>, } #[doc(hidden)] @@ -12747,6 +12752,7 @@ impl StorageStorageMutImpl of starknet::storage::StorageTraitMut { } pub struct ContractState { + #[substorage(v0)] pub component_member: super::test_component::ComponentState, } @@ -14674,6 +14680,7 @@ pub struct Storage { #[derive(Drop, Copy)] #[doc(hidden)] pub struct StorageStorageBase { + #[substorage(v0)] pub component_storage: starknet::storage::FlattenedStorage, } #[doc(hidden)] @@ -14689,6 +14696,7 @@ impl StorageStorageImpl of starknet::storage::StorageTrait { #[derive(Drop, Copy)] #[doc(hidden)] pub struct StorageStorageBaseMut { + #[substorage(v0)] pub component_storage: starknet::storage::FlattenedStorage>, } #[doc(hidden)] @@ -14703,6 +14711,7 @@ impl StorageStorageMutImpl of starknet::storage::StorageTraitMut { } pub struct ContractState { + #[substorage(v0)] pub component_storage: super::component::ComponentState, } diff --git a/crates/cairo-lang-starknet/src/plugin/plugin_test_data/contracts/events b/crates/cairo-lang-starknet/src/plugin/plugin_test_data/contracts/events index f45ddf8242e..e224b8d47b6 100644 --- a/crates/cairo-lang-starknet/src/plugin/plugin_test_data/contracts/events +++ b/crates/cairo-lang-starknet/src/plugin/plugin_test_data/contracts/events @@ -161,6 +161,7 @@ impl StoreA of starknet::Store:: { #[doc(hidden)] pub struct ASubPointers { pub x: starknet::storage::StoragePointer, + #[key] pub data: starknet::storage::StoragePointer, } #[doc(hidden)] @@ -188,6 +189,7 @@ impl ASubPointersImpl of starknet::storage::SubPointers { #[doc(hidden)] pub struct ASubPointersMut { pub x: starknet::storage::StoragePointer>, + #[key] pub data: starknet::storage::StoragePointer>, } #[doc(hidden)] diff --git a/crates/cairo-lang-starknet/src/plugin/plugin_test_data/contracts/interfaces b/crates/cairo-lang-starknet/src/plugin/plugin_test_data/contracts/interfaces index 4c945d16419..6fccff43be3 100644 --- a/crates/cairo-lang-starknet/src/plugin/plugin_test_data/contracts/interfaces +++ b/crates/cairo-lang-starknet/src/plugin/plugin_test_data/contracts/interfaces @@ -1504,6 +1504,7 @@ pub struct Storage { #[derive(Drop, Copy)] #[doc(hidden)] pub struct StorageStorageBase { + #[substorage(v0)] pub comp_storage: starknet::storage::FlattenedStorage, } #[doc(hidden)] @@ -1519,6 +1520,7 @@ impl StorageStorageImpl of starknet::storage::StorageTrait { #[derive(Drop, Copy)] #[doc(hidden)] pub struct StorageStorageBaseMut { + #[substorage(v0)] pub comp_storage: starknet::storage::FlattenedStorage>, } #[doc(hidden)] @@ -1533,6 +1535,7 @@ impl StorageStorageMutImpl of starknet::storage::StorageTraitMut { } pub struct ContractState { + #[substorage(v0)] pub comp_storage: super::comp::ComponentState, } diff --git a/crates/cairo-lang-starknet/src/plugin/plugin_test_data/contracts/mintable b/crates/cairo-lang-starknet/src/plugin/plugin_test_data/contracts/mintable index 29d55efd766..bea866908ad 100644 --- a/crates/cairo-lang-starknet/src/plugin/plugin_test_data/contracts/mintable +++ b/crates/cairo-lang-starknet/src/plugin/plugin_test_data/contracts/mintable @@ -79,8 +79,11 @@ mod mintable_erc20_ownable { #[derive(Drop, Copy)] #[doc(hidden)] struct StorageStorageBase { + #[substorage(v0)] erc20_storage: starknet::storage::FlattenedStorage, + #[substorage(v0)] ownable_storage: starknet::storage::FlattenedStorage, + #[substorage(v0)] mintable_storage: starknet::storage::FlattenedStorage, } #[doc(hidden)] @@ -100,8 +103,11 @@ impl StorageStorageImpl of starknet::storage::StorageTrait { #[derive(Drop, Copy)] #[doc(hidden)] struct StorageStorageBaseMut { + #[substorage(v0)] erc20_storage: starknet::storage::FlattenedStorage>, + #[substorage(v0)] ownable_storage: starknet::storage::FlattenedStorage>, + #[substorage(v0)] mintable_storage: starknet::storage::FlattenedStorage>, } #[doc(hidden)] @@ -120,8 +126,11 @@ impl StorageStorageMutImpl of starknet::storage::StorageTraitMut { } pub struct ContractState { + #[substorage(v0)] erc20_storage: erc20_comp::ComponentState, + #[substorage(v0)] ownable_storage: ownable_comp::ComponentState, + #[substorage(v0)] mintable_storage: mintable_comp::ComponentState, } @@ -926,8 +935,11 @@ impl GetSupplySafeDispatcherSubPointersMutCopy of core::traits::Copy::, + #[substorage(v0)] ownable_storage: starknet::storage::FlattenedStorage, + #[substorage(v0)] mintable_storage: starknet::storage::FlattenedStorage, } #[doc(hidden)] @@ -947,8 +959,11 @@ impl StorageStorageImpl of starknet::storage::StorageTrait { #[derive(Drop, Copy)] #[doc(hidden)] struct StorageStorageBaseMut { + #[substorage(v0)] erc20_storage: starknet::storage::FlattenedStorage>, + #[substorage(v0)] ownable_storage: starknet::storage::FlattenedStorage>, + #[substorage(v0)] mintable_storage: starknet::storage::FlattenedStorage>, } #[doc(hidden)] @@ -967,8 +982,11 @@ impl StorageStorageMutImpl of starknet::storage::StorageTraitMut { } pub struct ContractState { + #[substorage(v0)] erc20_storage: erc20_comp::ComponentState, + #[substorage(v0)] ownable_storage: ownable_comp::ComponentState, + #[substorage(v0)] mintable_storage: mintable_comp::ComponentState, } diff --git a/crates/cairo-lang-starknet/src/plugin/plugin_test_data/contracts/multi_component b/crates/cairo-lang-starknet/src/plugin/plugin_test_data/contracts/multi_component index 6d2c802d3ae..05dd4386827 100644 --- a/crates/cairo-lang-starknet/src/plugin/plugin_test_data/contracts/multi_component +++ b/crates/cairo-lang-starknet/src/plugin/plugin_test_data/contracts/multi_component @@ -86,9 +86,13 @@ pub mod contract_with_4_components { #[derive(Drop, Copy)] #[doc(hidden)] struct StorageStorageBase { + #[substorage(v0)] erc20_storage: starknet::storage::FlattenedStorage, + #[substorage(v0)] ownable_storage: starknet::storage::FlattenedStorage, + #[substorage(v0)] mintable_storage: starknet::storage::FlattenedStorage, + #[substorage(v0)] upgradable_storage: starknet::storage::FlattenedStorage, } #[doc(hidden)] @@ -110,9 +114,13 @@ impl StorageStorageImpl of starknet::storage::StorageTrait { #[derive(Drop, Copy)] #[doc(hidden)] struct StorageStorageBaseMut { + #[substorage(v0)] erc20_storage: starknet::storage::FlattenedStorage>, + #[substorage(v0)] ownable_storage: starknet::storage::FlattenedStorage>, + #[substorage(v0)] mintable_storage: starknet::storage::FlattenedStorage>, + #[substorage(v0)] upgradable_storage: starknet::storage::FlattenedStorage>, } #[doc(hidden)] @@ -133,9 +141,13 @@ impl StorageStorageMutImpl of starknet::storage::StorageTraitMut { } pub struct ContractState { + #[substorage(v0)] erc20_storage: erc20_comp::ComponentState, + #[substorage(v0)] ownable_storage: ownable_comp::ComponentState, + #[substorage(v0)] mintable_storage: mintable_comp::ComponentState, + #[substorage(v0)] upgradable_storage: upgradable_comp::ComponentState, } @@ -990,9 +1002,13 @@ impl GetSupplySafeDispatcherSubPointersMutCopy of core::traits::Copy::, + #[substorage(v0)] ownable_storage: starknet::storage::FlattenedStorage, + #[substorage(v0)] mintable_storage: starknet::storage::FlattenedStorage, + #[substorage(v0)] upgradable_storage: starknet::storage::FlattenedStorage, } #[doc(hidden)] @@ -1014,9 +1030,13 @@ impl StorageStorageImpl of starknet::storage::StorageTrait { #[derive(Drop, Copy)] #[doc(hidden)] struct StorageStorageBaseMut { + #[substorage(v0)] erc20_storage: starknet::storage::FlattenedStorage>, + #[substorage(v0)] ownable_storage: starknet::storage::FlattenedStorage>, + #[substorage(v0)] mintable_storage: starknet::storage::FlattenedStorage>, + #[substorage(v0)] upgradable_storage: starknet::storage::FlattenedStorage>, } #[doc(hidden)] @@ -1037,9 +1057,13 @@ impl StorageStorageMutImpl of starknet::storage::StorageTraitMut { } pub struct ContractState { + #[substorage(v0)] erc20_storage: erc20_comp::ComponentState, + #[substorage(v0)] ownable_storage: ownable_comp::ComponentState, + #[substorage(v0)] mintable_storage: mintable_comp::ComponentState, + #[substorage(v0)] upgradable_storage: upgradable_comp::ComponentState, } diff --git a/crates/cairo-lang-starknet/src/plugin/plugin_test_data/contracts/new_storage_interface b/crates/cairo-lang-starknet/src/plugin/plugin_test_data/contracts/new_storage_interface index 8ffbb986749..c90acda821d 100644 --- a/crates/cairo-lang-starknet/src/plugin/plugin_test_data/contracts/new_storage_interface +++ b/crates/cairo-lang-starknet/src/plugin/plugin_test_data/contracts/new_storage_interface @@ -1349,6 +1349,7 @@ storage_node: #[doc(hidden)] pub struct BalancePairStorageBase { pub balance1: starknet::storage::StorageBase, + #[flat] pub balance2: starknet::storage::FlattenedStorage, } #[doc(hidden)] @@ -1367,6 +1368,7 @@ impl BalancePairStorageImpl of starknet::storage::StorageTrait { #[doc(hidden)] pub struct BalancePairStorageBaseMut { pub balance1: starknet::storage::StorageBase>, + #[flat] pub balance2: starknet::storage::FlattenedStorage>, } #[doc(hidden)] @@ -1385,6 +1387,7 @@ impl BalancePairStorageMutImpl of starknet::storage::StorageTraitMut, + #[flat] pub balance2: starknet::storage::StoragePath, } #[doc(hidden)] @@ -1406,6 +1409,7 @@ impl BalancePairStorageNodeImpl of starknet::storage::StorageNode { #[doc(hidden)] pub struct BalancePairStorageNodeMut { pub balance1: starknet::storage::PendingStoragePath>, + #[flat] pub balance2: starknet::storage::StoragePath>, } #[doc(hidden)] diff --git a/crates/cairo-lang-starknet/src/plugin/plugin_test_data/contracts/ownable_erc20 b/crates/cairo-lang-starknet/src/plugin/plugin_test_data/contracts/ownable_erc20 index 2ff77dcf6ef..d323baff7ac 100644 --- a/crates/cairo-lang-starknet/src/plugin/plugin_test_data/contracts/ownable_erc20 +++ b/crates/cairo-lang-starknet/src/plugin/plugin_test_data/contracts/ownable_erc20 @@ -60,7 +60,9 @@ mod ownable_erc20_contract { #[derive(Drop, Copy)] #[doc(hidden)] struct StorageStorageBase { + #[substorage(v0)] ownable_storage: starknet::storage::FlattenedStorage, + #[substorage(v0)] erc20_storage: starknet::storage::FlattenedStorage, } #[doc(hidden)] @@ -78,7 +80,9 @@ impl StorageStorageImpl of starknet::storage::StorageTrait { #[derive(Drop, Copy)] #[doc(hidden)] struct StorageStorageBaseMut { + #[substorage(v0)] ownable_storage: starknet::storage::FlattenedStorage>, + #[substorage(v0)] erc20_storage: starknet::storage::FlattenedStorage>, } #[doc(hidden)] @@ -95,7 +99,9 @@ impl StorageStorageMutImpl of starknet::storage::StorageTraitMut { } pub struct ContractState { + #[substorage(v0)] ownable_storage: ownable_comp::ComponentState, + #[substorage(v0)] erc20_storage: erc20_comp::ComponentState, } @@ -365,7 +371,9 @@ impl StorageStorageBaseMutCopy of core::traits::Copy::; #[derive(Drop, Copy)] #[doc(hidden)] struct StorageStorageBase { + #[substorage(v0)] ownable_storage: starknet::storage::FlattenedStorage, + #[substorage(v0)] erc20_storage: starknet::storage::FlattenedStorage, } #[doc(hidden)] @@ -383,7 +391,9 @@ impl StorageStorageImpl of starknet::storage::StorageTrait { #[derive(Drop, Copy)] #[doc(hidden)] struct StorageStorageBaseMut { + #[substorage(v0)] ownable_storage: starknet::storage::FlattenedStorage>, + #[substorage(v0)] erc20_storage: starknet::storage::FlattenedStorage>, } #[doc(hidden)] @@ -400,7 +410,9 @@ impl StorageStorageMutImpl of starknet::storage::StorageTraitMut { } pub struct ContractState { + #[substorage(v0)] ownable_storage: ownable_comp::ComponentState, + #[substorage(v0)] erc20_storage: erc20_comp::ComponentState, } diff --git a/crates/cairo-lang-starknet/src/plugin/plugin_test_data/contracts/upgradable_counter b/crates/cairo-lang-starknet/src/plugin/plugin_test_data/contracts/upgradable_counter index 161433f1276..9519bec32f9 100644 --- a/crates/cairo-lang-starknet/src/plugin/plugin_test_data/contracts/upgradable_counter +++ b/crates/cairo-lang-starknet/src/plugin/plugin_test_data/contracts/upgradable_counter @@ -81,7 +81,9 @@ mod counter_contract { #[doc(hidden)] struct StorageStorageBase { counter: starknet::storage::StorageBase, + #[substorage(v0)] upgradable: starknet::storage::FlattenedStorage, + #[substorage(v0)] ownable: starknet::storage::FlattenedStorage, } #[doc(hidden)] @@ -102,7 +104,9 @@ impl StorageStorageImpl of starknet::storage::StorageTrait { #[doc(hidden)] struct StorageStorageBaseMut { counter: starknet::storage::StorageBase>, + #[substorage(v0)] upgradable: starknet::storage::FlattenedStorage>, + #[substorage(v0)] ownable: starknet::storage::FlattenedStorage>, } #[doc(hidden)] @@ -121,7 +125,9 @@ impl StorageStorageMutImpl of starknet::storage::StorageTraitMut { } pub struct ContractState { + #[substorage(v0)] upgradable: upgradable_comp::ComponentState, + #[substorage(v0)] ownable: ownable_comp::ComponentState, } @@ -1059,7 +1065,9 @@ impl ICounterContractSafeDispatcherSubPointersMutCopy of core::traits::Copy::, + #[substorage(v0)] upgradable: starknet::storage::FlattenedStorage, + #[substorage(v0)] ownable: starknet::storage::FlattenedStorage, } #[doc(hidden)] @@ -1080,7 +1088,9 @@ impl StorageStorageImpl of starknet::storage::StorageTrait { #[doc(hidden)] struct StorageStorageBaseMut { counter: starknet::storage::StorageBase>, + #[substorage(v0)] upgradable: starknet::storage::FlattenedStorage>, + #[substorage(v0)] ownable: starknet::storage::FlattenedStorage>, } #[doc(hidden)] @@ -1099,7 +1109,9 @@ impl StorageStorageMutImpl of starknet::storage::StorageTraitMut { } pub struct ContractState { + #[substorage(v0)] upgradable: upgradable_comp::ComponentState, + #[substorage(v0)] ownable: ownable_comp::ComponentState, } diff --git a/crates/cairo-lang-starknet/src/plugin/plugin_test_data/contracts/with_component b/crates/cairo-lang-starknet/src/plugin/plugin_test_data/contracts/with_component index b2b26beeb31..0c4a5351ab2 100644 --- a/crates/cairo-lang-starknet/src/plugin/plugin_test_data/contracts/with_component +++ b/crates/cairo-lang-starknet/src/plugin/plugin_test_data/contracts/with_component @@ -226,6 +226,7 @@ pub struct Storage { #[derive(Drop, Copy)] #[doc(hidden)] pub struct StorageStorageBase { + #[substorage(v0)] pub test_component_storage: starknet::storage::FlattenedStorage, pub normal_member1: starknet::storage::StorageBase, pub normal_member2: starknet::storage::StorageBase, @@ -247,6 +248,7 @@ impl StorageStorageImpl of starknet::storage::StorageTrait { #[derive(Drop, Copy)] #[doc(hidden)] pub struct StorageStorageBaseMut { + #[substorage(v0)] pub test_component_storage: starknet::storage::FlattenedStorage>, pub normal_member1: starknet::storage::StorageBase>, pub normal_member2: starknet::storage::StorageBase>, @@ -267,6 +269,7 @@ impl StorageStorageMutImpl of starknet::storage::StorageTraitMut { } pub struct ContractState { + #[substorage(v0)] pub test_component_storage: super::test_component::ComponentState, } @@ -828,7 +831,9 @@ pub struct Storage { #[derive(Drop, Copy)] #[doc(hidden)] pub struct StorageStorageBase { + #[substorage(v0)] pub component1_storage: starknet::storage::FlattenedStorage, + #[substorage(v0)] pub component2_storage: starknet::storage::FlattenedStorage, } #[doc(hidden)] @@ -846,7 +851,9 @@ impl StorageStorageImpl of starknet::storage::StorageTrait { #[derive(Drop, Copy)] #[doc(hidden)] pub struct StorageStorageBaseMut { + #[substorage(v0)] pub component1_storage: starknet::storage::FlattenedStorage>, + #[substorage(v0)] pub component2_storage: starknet::storage::FlattenedStorage>, } #[doc(hidden)] @@ -863,7 +870,9 @@ impl StorageStorageMutImpl of starknet::storage::StorageTraitMut { } pub struct ContractState { + #[substorage(v0)] pub component1_storage: super::component1::ComponentState, + #[substorage(v0)] pub component2_storage: super::component2::ComponentState, } @@ -1472,7 +1481,9 @@ pub struct Storage { #[derive(Drop, Copy)] #[doc(hidden)] pub struct StorageStorageBase { + #[substorage(v0)] pub component1_storage: starknet::storage::FlattenedStorage, + #[substorage(v0)] pub component2_storage: starknet::storage::FlattenedStorage, } #[doc(hidden)] @@ -1490,7 +1501,9 @@ impl StorageStorageImpl of starknet::storage::StorageTrait { #[derive(Drop, Copy)] #[doc(hidden)] pub struct StorageStorageBaseMut { + #[substorage(v0)] pub component1_storage: starknet::storage::FlattenedStorage>, + #[substorage(v0)] pub component2_storage: starknet::storage::FlattenedStorage>, } #[doc(hidden)] @@ -1507,7 +1520,9 @@ impl StorageStorageMutImpl of starknet::storage::StorageTraitMut { } pub struct ContractState { + #[substorage(v0)] pub component1_storage: super::component1::ComponentState, + #[substorage(v0)] pub component2_storage: super::component2::ComponentState, } diff --git a/crates/cairo-lang-starknet/src/plugin/plugin_test_data/contracts/with_component_diagnostics b/crates/cairo-lang-starknet/src/plugin/plugin_test_data/contracts/with_component_diagnostics index 60d5a33bf76..0e45fdd545f 100644 --- a/crates/cairo-lang-starknet/src/plugin/plugin_test_data/contracts/with_component_diagnostics +++ b/crates/cairo-lang-starknet/src/plugin/plugin_test_data/contracts/with_component_diagnostics @@ -1768,8 +1768,12 @@ pub struct Storage { #[derive(Drop, Copy)] #[doc(hidden)] pub struct StorageStorageBase { + #[substorage(v0)] pub non_path_type: starknet::storage::FlattenedStorage<(usize, usize)>, + #[substorage(v0)] pub non_component: starknet::storage::FlattenedStorage, + // non-v0 substorage member. + #[substorage] pub test_component_storage: starknet::storage::FlattenedStorage, } #[doc(hidden)] @@ -1789,8 +1793,12 @@ impl StorageStorageImpl of starknet::storage::StorageTrait { #[derive(Drop, Copy)] #[doc(hidden)] pub struct StorageStorageBaseMut { + #[substorage(v0)] pub non_path_type: starknet::storage::FlattenedStorage>, + #[substorage(v0)] pub non_component: starknet::storage::FlattenedStorage>, + // non-v0 substorage member. + #[substorage] pub test_component_storage: starknet::storage::FlattenedStorage>, } #[doc(hidden)] @@ -1809,6 +1817,8 @@ impl StorageStorageMutImpl of starknet::storage::StorageTraitMut { } pub struct ContractState { + // non-v0 substorage member. + #[substorage] pub test_component_storage: super::test_component::ComponentState, } @@ -2942,6 +2952,7 @@ pub struct Storage { #[derive(Drop, Copy)] #[doc(hidden)] pub struct StorageStorageBase { + #[substorage(v0)] pub test_component_storage: starknet::storage::FlattenedStorage, } #[doc(hidden)] @@ -2957,6 +2968,7 @@ impl StorageStorageImpl of starknet::storage::StorageTrait { #[derive(Drop, Copy)] #[doc(hidden)] pub struct StorageStorageBaseMut { + #[substorage(v0)] pub test_component_storage: starknet::storage::FlattenedStorage>, } #[doc(hidden)] @@ -2971,6 +2983,7 @@ impl StorageStorageMutImpl of starknet::storage::StorageTraitMut { } pub struct ContractState { + #[substorage(v0)] pub test_component_storage: super::test_component::ComponentState, } @@ -3391,6 +3404,7 @@ pub struct Storage { #[derive(Drop, Copy)] #[doc(hidden)] pub struct StorageStorageBase { + #[substorage(v0)] pub test_component_storage: starknet::storage::FlattenedStorage, } #[doc(hidden)] @@ -3406,6 +3420,7 @@ impl StorageStorageImpl of starknet::storage::StorageTrait { #[derive(Drop, Copy)] #[doc(hidden)] pub struct StorageStorageBaseMut { + #[substorage(v0)] pub test_component_storage: starknet::storage::FlattenedStorage>, } #[doc(hidden)] @@ -3420,6 +3435,7 @@ impl StorageStorageMutImpl of starknet::storage::StorageTraitMut { } pub struct ContractState { + #[substorage(v0)] pub test_component_storage: super::test_component::ComponentState, } @@ -3931,7 +3947,9 @@ pub struct Storage { #[derive(Drop, Copy)] #[doc(hidden)] pub struct StorageStorageBase { + #[substorage(v0)] pub component1_storage: starknet::storage::FlattenedStorage, + #[substorage(v0)] pub component2_storage: starknet::storage::FlattenedStorage, } #[doc(hidden)] @@ -3949,7 +3967,9 @@ impl StorageStorageImpl of starknet::storage::StorageTrait { #[derive(Drop, Copy)] #[doc(hidden)] pub struct StorageStorageBaseMut { + #[substorage(v0)] pub component1_storage: starknet::storage::FlattenedStorage>, + #[substorage(v0)] pub component2_storage: starknet::storage::FlattenedStorage>, } #[doc(hidden)] @@ -3966,7 +3986,9 @@ impl StorageStorageMutImpl of starknet::storage::StorageTraitMut { } pub struct ContractState { + #[substorage(v0)] pub component1_storage: super::component1::ComponentState, + #[substorage(v0)] pub component2_storage: super::component2::ComponentState, } diff --git a/crates/cairo-lang-starknet/src/plugin/plugin_test_data/contracts/with_erc20 b/crates/cairo-lang-starknet/src/plugin/plugin_test_data/contracts/with_erc20 index ba7335f630f..af041b6a814 100644 --- a/crates/cairo-lang-starknet/src/plugin/plugin_test_data/contracts/with_erc20 +++ b/crates/cairo-lang-starknet/src/plugin/plugin_test_data/contracts/with_erc20 @@ -49,6 +49,7 @@ mod erc20_contract { #[derive(Drop, Copy)] #[doc(hidden)] struct StorageStorageBase { + #[substorage(v0)] erc20_token: starknet::storage::FlattenedStorage, } #[doc(hidden)] @@ -64,6 +65,7 @@ impl StorageStorageImpl of starknet::storage::StorageTrait { #[derive(Drop, Copy)] #[doc(hidden)] struct StorageStorageBaseMut { + #[substorage(v0)] erc20_token: starknet::storage::FlattenedStorage>, } #[doc(hidden)] @@ -78,6 +80,7 @@ impl StorageStorageMutImpl of starknet::storage::StorageTraitMut { } pub struct ContractState { + #[substorage(v0)] erc20_token: erc20_comp::ComponentState, } @@ -288,6 +291,7 @@ impl StorageStorageBaseMutCopy of core::traits::Copy::; #[derive(Drop, Copy)] #[doc(hidden)] struct StorageStorageBase { + #[substorage(v0)] erc20_token: starknet::storage::FlattenedStorage, } #[doc(hidden)] @@ -303,6 +307,7 @@ impl StorageStorageImpl of starknet::storage::StorageTrait { #[derive(Drop, Copy)] #[doc(hidden)] struct StorageStorageBaseMut { + #[substorage(v0)] erc20_token: starknet::storage::FlattenedStorage>, } #[doc(hidden)] @@ -317,6 +322,7 @@ impl StorageStorageMutImpl of starknet::storage::StorageTraitMut { } pub struct ContractState { + #[substorage(v0)] erc20_token: erc20_comp::ComponentState, } diff --git a/crates/cairo-lang-starknet/src/plugin/plugin_test_data/contracts/with_erc20_mini b/crates/cairo-lang-starknet/src/plugin/plugin_test_data/contracts/with_erc20_mini index 4da1667bc1d..d829d69d378 100644 --- a/crates/cairo-lang-starknet/src/plugin/plugin_test_data/contracts/with_erc20_mini +++ b/crates/cairo-lang-starknet/src/plugin/plugin_test_data/contracts/with_erc20_mini @@ -61,6 +61,7 @@ mod erc20_mini_contract { #[derive(Drop, Copy)] #[doc(hidden)] struct StorageStorageBase { + #[flat] erc20_token: starknet::storage::FlattenedStorage, } #[doc(hidden)] @@ -76,6 +77,7 @@ impl StorageStorageImpl of starknet::storage::StorageTrait { #[derive(Drop, Copy)] #[doc(hidden)] struct StorageStorageBaseMut { + #[flat] erc20_token: starknet::storage::FlattenedStorage>, } #[doc(hidden)] @@ -290,6 +292,7 @@ impl StorageStorageBaseMutCopy of core::traits::Copy::; #[derive(Drop, Copy)] #[doc(hidden)] struct StorageStorageBase { + #[flat] erc20_token: starknet::storage::FlattenedStorage, } #[doc(hidden)] @@ -305,6 +308,7 @@ impl StorageStorageImpl of starknet::storage::StorageTrait { #[derive(Drop, Copy)] #[doc(hidden)] struct StorageStorageBaseMut { + #[flat] erc20_token: starknet::storage::FlattenedStorage>, } #[doc(hidden)] diff --git a/crates/cairo-lang-starknet/src/plugin/plugin_test_data/contracts/with_ownable b/crates/cairo-lang-starknet/src/plugin/plugin_test_data/contracts/with_ownable index 7b2579fb326..a60bf65abcb 100644 --- a/crates/cairo-lang-starknet/src/plugin/plugin_test_data/contracts/with_ownable +++ b/crates/cairo-lang-starknet/src/plugin/plugin_test_data/contracts/with_ownable @@ -54,6 +54,7 @@ mod ownable_balance { #[derive(Drop, Copy)] #[doc(hidden)] struct StorageStorageBase { + #[substorage(v0)] ownable: starknet::storage::FlattenedStorage, balance: starknet::storage::StorageBase, } @@ -72,6 +73,7 @@ impl StorageStorageImpl of starknet::storage::StorageTrait { #[derive(Drop, Copy)] #[doc(hidden)] struct StorageStorageBaseMut { + #[substorage(v0)] ownable: starknet::storage::FlattenedStorage>, balance: starknet::storage::StorageBase>, } @@ -89,6 +91,7 @@ impl StorageStorageMutImpl of starknet::storage::StorageTraitMut { } pub struct ContractState { + #[substorage(v0)] ownable: ownable_comp::ComponentState, } @@ -333,6 +336,7 @@ impl StorageStorageBaseMutCopy of core::traits::Copy::; #[derive(Drop, Copy)] #[doc(hidden)] struct StorageStorageBase { + #[substorage(v0)] ownable: starknet::storage::FlattenedStorage, balance: starknet::storage::StorageBase, } @@ -351,6 +355,7 @@ impl StorageStorageImpl of starknet::storage::StorageTrait { #[derive(Drop, Copy)] #[doc(hidden)] struct StorageStorageBaseMut { + #[substorage(v0)] ownable: starknet::storage::FlattenedStorage>, balance: starknet::storage::StorageBase>, } @@ -368,6 +373,7 @@ impl StorageStorageMutImpl of starknet::storage::StorageTraitMut { } pub struct ContractState { + #[substorage(v0)] ownable: ownable_comp::ComponentState, } diff --git a/crates/cairo-lang-starknet/src/plugin/storage.rs b/crates/cairo-lang-starknet/src/plugin/storage.rs index f777f72709d..a2eb64a9d62 100644 --- a/crates/cairo-lang-starknet/src/plugin/storage.rs +++ b/crates/cairo-lang-starknet/src/plugin/storage.rs @@ -165,8 +165,9 @@ fn get_substorage_member_code( Some(( RewriteNode::interpolate_patched( - &format!("\n $member_visibility$ $name$: $component_path$::{CONCRETE_COMPONENT_STATE_NAME},"), + &format!("\n$attributes$ $member_visibility$ $name$: $component_path$::{CONCRETE_COMPONENT_STATE_NAME},"), &[ + ("attributes".to_string(), RewriteNode::from_ast(&member.attributes(db))), ( "member_visibility".to_string(), member_visibility, @@ -228,56 +229,44 @@ fn get_simple_member_code( } else { RewriteNode::from_ast(&member.visibility(db)) }; + let patches = [ + ("attributes".to_string(), RewriteNode::from_ast(&member.attributes(db))), + ("member_visibility".to_string(), member_visibility.clone()), + ("member_wrapper_type".to_string(), member_wrapper_type.clone()), + ("member_name".to_string(), RewriteNode::new_trimmed(member_name.clone())), + ("member_type".to_string(), RewriteNode::new_trimmed(member_type.clone())), + ] + .into(); SimpleMemberGeneratedCode { struct_code: RewriteNode::interpolate_patched( - "\n $member_visibility$ $member_name$: \ + "\n$attributes$ $member_visibility$ $member_name$: \ starknet::storage::$member_wrapper_type$<$member_type$>,", - &[ - ("member_visibility".to_string(), member_visibility.clone()), - ("member_wrapper_type".to_string(), member_wrapper_type.clone()), - ("member_name".to_string(), RewriteNode::new_trimmed(member_name.clone())), - ("member_type".to_string(), RewriteNode::new_trimmed(member_type.clone())), - ] - .into(), + &patches, ) .mapped(db, member), struct_code_mut: RewriteNode::interpolate_patched( - "\n $member_visibility$ $member_name$: \ + "\n$attributes$ $member_visibility$ $member_name$: \ starknet::storage::$member_wrapper_type$>,", - &[ - ("member_visibility".to_string(), member_visibility.clone()), - ("member_wrapper_type".to_string(), member_wrapper_type.clone()), - ("member_name".to_string(), RewriteNode::new_trimmed(member_name.clone())), - ("member_type".to_string(), RewriteNode::new_trimmed(member_type.clone())), - ] - .into(), + &patches, ) .mapped(db, member), init_code: if member.has_attr(db, SUBSTORAGE_ATTR) || member.has_attr(db, FLAT_ATTR) { RewriteNode::interpolate_patched( "\n $member_name$: starknet::storage::FlattenedStorage{},", - &[("member_name".to_string(), RewriteNode::new_trimmed(member_name.clone()))] - .into(), + &patches, ) } else { RewriteNode::interpolate_patched( "\n $member_name$: starknet::storage::StorageBase{ address: \ selector!(\"$member_name$\") },", - &[("member_name".to_string(), RewriteNode::new_trimmed(member_name.clone()))] - .into(), + &patches, ) } .mapped(db, member), storage_member: RewriteNode::interpolate_patched( "\n$attributes$ $member_visibility$ $member_name$: $member_type$,", - &[ - ("attributes".to_string(), RewriteNode::from_ast(&member.attributes(db))), - ("member_visibility".to_string(), member_visibility), - ("member_name".to_string(), RewriteNode::new_trimmed(member_name.clone())), - ("member_type".to_string(), RewriteNode::new_trimmed(member_type.clone())), - ] - .into(), + &patches, ) .mapped(db, member), } diff --git a/crates/cairo-lang-starknet/src/plugin/storage_interfaces.rs b/crates/cairo-lang-starknet/src/plugin/storage_interfaces.rs index f0fcbd540ca..46a7246cfb4 100644 --- a/crates/cairo-lang-starknet/src/plugin/storage_interfaces.rs +++ b/crates/cairo-lang-starknet/src/plugin/storage_interfaces.rs @@ -545,8 +545,11 @@ fn add_interface_struct_definition( }; builder.add_modified(RewriteNode::interpolate_patched( - &format!(" $field_visibility$$field_name$: {concrete_node_members_type},\n",), + &format!( + "$attributes$ $field_visibility$$field_name$: {concrete_node_members_type},\n", + ), &[ + ("attributes".to_string(), RewriteNode::from_ast(&field.attributes(db))), ("field_visibility".to_string(), field_visibility), ("field_name".to_string(), RewriteNode::new_trimmed(field_name)), ("field_type".to_string(), RewriteNode::new_trimmed(field_type)), @@ -647,8 +650,9 @@ fn add_node_enum_definition( }; builder.add_modified(RewriteNode::interpolate_patched( - &format!(" $field_name$: {concrete_node_members_type},\n",), + &format!("$attributes$ $field_name$: {concrete_node_members_type},\n",), &[ + ("attributes".to_string(), RewriteNode::from_ast(&variant.attributes(db))), ("field_name".to_string(), RewriteNode::new_trimmed(field_name)), ("field_type".to_string(), field_type), ]