From b91bcbf1b6a0e0ad2da8855268347f379d2d6e58 Mon Sep 17 00:00:00 2001 From: glihm Date: Thu, 10 Oct 2024 17:32:28 -0600 Subject: [PATCH] fix: fix cairo tests --- .../src/plugin/plugin_test_data/system | 6036 ++++++++++++++--- crates/types/src/world.rs | 194 +- 2 files changed, 5241 insertions(+), 989 deletions(-) diff --git a/crates/compiler/src/plugin/plugin_test_data/system b/crates/compiler/src/plugin/plugin_test_data/system index 1f5087d..c40dec6 100644 --- a/crates/compiler/src/plugin/plugin_test_data/system +++ b/crates/compiler/src/plugin/plugin_test_data/system @@ -699,16 +699,123 @@ impl StorageStorageBaseMutCopy of core::traits::Copy::; } #[constructor] - fn constructor(ref self: ContractState) { - self.world_provider.initializer(); - } + fn constructor(ref self: ContractState) { + self.world_provider.initializer(); + } +#[starknet::interface] +pub trait IDojoInit { + fn dojo_init(self: @ContractState); +} + +#[abi(embed_v0)] +pub impl IDojoInitImpl of IDojoInit { + fn dojo_init(self: @ContractState) { + if starknet::get_caller_address() != self.world_provider.world().contract_address { + core::panics::panic_with_byte_array( + @format!("Only the world can init contract `{}`, but caller is `{:?}`", + self.tag(), + starknet::get_caller_address(), + )); + } + } +} + #[event] #[derive(Drop, starknet::Event)] enum Event { UpgradeableEvent: upgradeable_cpt::Event, WorldProviderEvent: world_provider_cpt::Event, } +pub trait IDojoInitDispatcherTrait { + fn dojo_init(self: T); +} + +#[derive(Copy, Drop, starknet::Store, Serde)] +pub struct IDojoInitDispatcher { + pub contract_address: starknet::ContractAddress, +} + +impl IDojoInitDispatcherImpl of IDojoInitDispatcherTrait { + fn dojo_init(self: IDojoInitDispatcher) { + let mut __calldata__ = core::traits::Default::default(); + + let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( + self.contract_address, + selector!("dojo_init"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); + () + } + +} + +#[derive(Copy, Drop, starknet::Store, Serde)] +pub struct IDojoInitLibraryDispatcher { + pub class_hash: starknet::ClassHash, +} + +impl IDojoInitLibraryDispatcherImpl of IDojoInitDispatcherTrait { + fn dojo_init(self: IDojoInitLibraryDispatcher) { + let mut __calldata__ = core::traits::Default::default(); + + let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( + self.class_hash, + selector!("dojo_init"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); + () + } + +} + +pub trait IDojoInitSafeDispatcherTrait { + #[unstable(feature: "safe_dispatcher")] + fn dojo_init(self: T) -> starknet::SyscallResult<()>; +} + +#[derive(Copy, Drop, starknet::Store, Serde)] +pub struct IDojoInitSafeLibraryDispatcher { + pub class_hash: starknet::ClassHash, +} + +impl IDojoInitSafeLibraryDispatcherImpl of IDojoInitSafeDispatcherTrait { + fn dojo_init(self: IDojoInitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { + let mut __calldata__ = core::traits::Default::default(); + + let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( + self.class_hash, + selector!("dojo_init"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = __dispatcher_return_data__?; + Result::Ok(()) + } + +} + + +#[derive(Copy, Drop, starknet::Store, Serde)] +pub struct IDojoInitSafeDispatcher { + pub contract_address: starknet::ContractAddress, +} + +impl IDojoInitSafeDispatcherImpl of IDojoInitSafeDispatcherTrait { + fn dojo_init(self: IDojoInitSafeDispatcher) -> starknet::SyscallResult<()> { + let mut __calldata__ = core::traits::Default::default(); + + let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( + self.contract_address, + selector!("dojo_init"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = __dispatcher_return_data__?; + Result::Ok(()) + } + +} impl EventDrop of core::traits::Drop::; impl EventIsEvent of starknet::Event { fn append_keys_and_data( @@ -978,6 +1085,24 @@ fn __wrapper__constructor(mut data: Span::) -> Span:: { core::array::ArrayTrait::span(@arr) } +#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] +fn __wrapper__IDojoInitImpl__dojo_init(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + IDojoInitImpl::dojo_init(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::array::ArrayTrait::span(@arr) +} + pub mod __external { pub use super::__wrapper__ContractImpl__name as name; @@ -986,6 +1111,7 @@ pub mod __external { pub use super::__wrapper__ContractImpl__name_hash as name_hash; pub use super::__wrapper__ContractImpl__namespace_hash as namespace_hash; pub use super::__wrapper__ContractImpl__selector as selector; + pub use super::__wrapper__IDojoInitImpl__dojo_init as dojo_init; } pub mod __l1_handler { } @@ -1049,162 +1175,1477 @@ impl HasComponentImpl_upgradeable_cpt of upgradeable_cpt::HasComponent; -impl StorageStorageBaseCopy of core::traits::Copy::; -impl StorageStorageBaseMutDrop of core::traits::Drop::; -impl StorageStorageBaseMutCopy of core::traits::Copy::; - - } - - #[starknet::contract] - pub mod proxy { - use dojo::world; - use dojo::world::IWorldDispatcher; - use dojo::world::IWorldDispatcherTrait; - use dojo::contract::components::world_provider::{world_provider_cpt, world_provider_cpt::InternalTrait as WorldProviderInternal, IWorldProvider}; - use dojo::contract::components::upgradeable::upgradeable_cpt; - use dojo::contract::IContract; - use starknet::storage::{ - StorageMapReadAccess, StorageMapWriteAccess, StoragePointerReadAccess, StoragePointerWriteAccess - }; - - #[abi(embed_v0)] - impl WorldProviderImpl = world_provider_cpt::WorldProviderImpl; - - #[abi(embed_v0)] - impl UpgradeableImpl = upgradeable_cpt::UpgradeableImpl; - - #[abi(embed_v0)] - pub impl ContractImpl of IContract { - fn name(self: @ContractState) -> ByteArray { - "proxy" - } - - fn namespace(self: @ContractState) -> ByteArray { - "my_namespace" - } - - fn tag(self: @ContractState) -> ByteArray { - "my_namespace-proxy" - } - - fn name_hash(self: @ContractState) -> felt252 { - 379211399603323842291430789821178524592027629543381998047225121027704003915 - } - - fn namespace_hash(self: @ContractState) -> felt252 { - 1685136890688416384941629523783652800960468745356230625531475538826800548713 - } - - fn selector(self: @ContractState) -> felt252 { - 1517897915978631541665409557725081861100844369870047691780983681552158397188 - } - } - - fn execute(value: felt252) -> felt252 { - value +impl IDojoInitDispatcherCopy of core::traits::Copy::; +impl IDojoInitDispatcherDrop of core::traits::Drop::; +impl IDojoInitDispatcherSerde of core::serde::Serde:: { + fn serialize(self: @IDojoInitDispatcher, ref output: core::array::Array) { + core::serde::Serde::serialize(self.contract_address, ref output) } - - #[constructor] - fn constructor(ref self: ContractState) { - self.world_provider.initializer(); - } - - #[event] - #[derive(Drop, starknet::Event)] - enum Event { - UpgradeableEvent: upgradeable_cpt::Event, - WorldProviderEvent: world_provider_cpt::Event, + fn deserialize(ref serialized: core::array::Span) -> core::option::Option { + core::option::Option::Some(IDojoInitDispatcher { + contract_address: core::serde::Serde::deserialize(ref serialized)?, + }) + } +} +impl StoreIDojoInitDispatcher of starknet::Store:: { + fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { + let contract_address = starknet::Store::::read(address_domain, base)?; + starknet::SyscallResult::Ok( + IDojoInitDispatcher { + contract_address, } -impl EventDrop of core::traits::Drop::; -impl EventIsEvent of starknet::Event { - fn append_keys_and_data( - self: @Event, ref keys: Array, ref data: Array - ) { - match self { - Event::UpgradeableEvent(val) => { - core::array::ArrayTrait::append(ref keys, selector!("UpgradeableEvent")); - starknet::Event::append_keys_and_data( - val, ref keys, ref data - ); - }, - Event::WorldProviderEvent(val) => { - core::array::ArrayTrait::append(ref keys, selector!("WorldProviderEvent")); - starknet::Event::append_keys_and_data( - val, ref keys, ref data - ); - }, - } + ) } - fn deserialize( - ref keys: Span, ref data: Span, - ) -> Option { - let __selector__ = *core::array::SpanTrait::pop_front(ref keys)?; - if __selector__ == selector!("UpgradeableEvent") { - let val = starknet::Event::deserialize( - ref keys, ref data - )?; - return Option::Some(Event::UpgradeableEvent(val)); - } - if __selector__ == selector!("WorldProviderEvent") { - let val = starknet::Event::deserialize( - ref keys, ref data - )?; - return Option::Some(Event::WorldProviderEvent(val)); - } - Option::None + fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write(address_domain, base, value.contract_address)?; + starknet::SyscallResult::Ok(()) } -} -impl EventUpgradeableEventIntoEvent of Into { - fn into(self: upgradeable_cpt::Event) -> Event { - Event::UpgradeableEvent(self) + fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { + let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; + starknet::SyscallResult::Ok( + IDojoInitDispatcher { + contract_address, + } + ) } -} -impl EventWorldProviderEventIntoEvent of Into { - fn into(self: world_provider_cpt::Event) -> Event { - Event::WorldProviderEvent(self) + #[inline(always)] + fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; + starknet::SyscallResult::Ok(()) + } + #[inline(always)] + fn size() -> u8 { + starknet::Store::::size() } -} - - -#[phantom] -pub struct Storage { - #[substorage(v0)] - pub upgradeable: upgradeable_cpt::Storage, - #[substorage(v0)] - pub world_provider: world_provider_cpt::Storage, } #[derive(Drop, Copy)] -pub struct StorageStorageBase { - pub upgradeable: starknet::storage::FlattenedStorage, - pub world_provider: starknet::storage::FlattenedStorage, +pub struct IDojoInitDispatcherSubPointers { + pub contract_address: starknet::storage::StoragePointer, } -impl StorageStorageImpl of starknet::storage::StorageTrait { - type BaseType = StorageStorageBase; - fn storage(self: starknet::storage::FlattenedStorage) -> StorageStorageBase { - let upgradeable_value = starknet::storage::FlattenedStorage {}; - let world_provider_value = starknet::storage::FlattenedStorage {}; - StorageStorageBase { - upgradeable: upgradeable_value, - world_provider: world_provider_value, +impl IDojoInitDispatcherSubPointersImpl of starknet::storage::SubPointers { + type SubPointersType = IDojoInitDispatcherSubPointers; + fn sub_pointers(self: starknet::storage::StoragePointer) -> IDojoInitDispatcherSubPointers { + let base_address = self.__storage_pointer_address__; + let mut current_offset = self.__storage_pointer_offset__; + let contract_address_value = starknet::storage::StoragePointer { + __storage_pointer_address__: base_address, + __storage_pointer_offset__: current_offset, + }; + IDojoInitDispatcherSubPointers { + contract_address: contract_address_value, } } } #[derive(Drop, Copy)] -pub struct StorageStorageBaseMut { - pub upgradeable: starknet::storage::FlattenedStorage>, - pub world_provider: starknet::storage::FlattenedStorage>, +pub struct IDojoInitDispatcherSubPointersMut { + pub contract_address: starknet::storage::StoragePointer>, } -impl StorageStorageMutImpl of starknet::storage::StorageTraitMut { - type BaseType = StorageStorageBaseMut; - fn storage_mut(self: starknet::storage::FlattenedStorage>) -> StorageStorageBaseMut { - let upgradeable_value = starknet::storage::FlattenedStorage {}; - let world_provider_value = starknet::storage::FlattenedStorage {}; - StorageStorageBaseMut { - upgradeable: upgradeable_value, - world_provider: world_provider_value, - } +impl IDojoInitDispatcherSubPointersMutImpl of starknet::storage::SubPointersMut { + type SubPointersType = IDojoInitDispatcherSubPointersMut; + fn sub_pointers_mut(self: starknet::storage::StoragePointer>) -> IDojoInitDispatcherSubPointersMut { + let base_address = self.__storage_pointer_address__; + let mut current_offset = self.__storage_pointer_offset__; + let contract_address_value = starknet::storage::StoragePointer { + __storage_pointer_address__: base_address, + __storage_pointer_offset__: current_offset, + }; + IDojoInitDispatcherSubPointersMut { + contract_address: contract_address_value, + } + } +} +impl IDojoInitLibraryDispatcherCopy of core::traits::Copy::; +impl IDojoInitLibraryDispatcherDrop of core::traits::Drop::; +impl IDojoInitLibraryDispatcherSerde of core::serde::Serde:: { + fn serialize(self: @IDojoInitLibraryDispatcher, ref output: core::array::Array) { + core::serde::Serde::serialize(self.class_hash, ref output) + } + fn deserialize(ref serialized: core::array::Span) -> core::option::Option { + core::option::Option::Some(IDojoInitLibraryDispatcher { + class_hash: core::serde::Serde::deserialize(ref serialized)?, + }) + } +} +impl StoreIDojoInitLibraryDispatcher of starknet::Store:: { + fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { + let class_hash = starknet::Store::::read(address_domain, base)?; + starknet::SyscallResult::Ok( + IDojoInitLibraryDispatcher { + class_hash, + } + ) + } + fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitLibraryDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write(address_domain, base, value.class_hash)?; + starknet::SyscallResult::Ok(()) + } + fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { + let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; + starknet::SyscallResult::Ok( + IDojoInitLibraryDispatcher { + class_hash, + } + ) + } + #[inline(always)] + fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitLibraryDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; + starknet::SyscallResult::Ok(()) + } + #[inline(always)] + fn size() -> u8 { + starknet::Store::::size() + } +} + +#[derive(Drop, Copy)] +pub struct IDojoInitLibraryDispatcherSubPointers { + pub class_hash: starknet::storage::StoragePointer, +} +impl IDojoInitLibraryDispatcherSubPointersImpl of starknet::storage::SubPointers { + type SubPointersType = IDojoInitLibraryDispatcherSubPointers; + fn sub_pointers(self: starknet::storage::StoragePointer) -> IDojoInitLibraryDispatcherSubPointers { + let base_address = self.__storage_pointer_address__; + let mut current_offset = self.__storage_pointer_offset__; + let class_hash_value = starknet::storage::StoragePointer { + __storage_pointer_address__: base_address, + __storage_pointer_offset__: current_offset, + }; + IDojoInitLibraryDispatcherSubPointers { + class_hash: class_hash_value, + } + } +} +#[derive(Drop, Copy)] +pub struct IDojoInitLibraryDispatcherSubPointersMut { + pub class_hash: starknet::storage::StoragePointer>, +} +impl IDojoInitLibraryDispatcherSubPointersMutImpl of starknet::storage::SubPointersMut { + type SubPointersType = IDojoInitLibraryDispatcherSubPointersMut; + fn sub_pointers_mut(self: starknet::storage::StoragePointer>) -> IDojoInitLibraryDispatcherSubPointersMut { + let base_address = self.__storage_pointer_address__; + let mut current_offset = self.__storage_pointer_offset__; + let class_hash_value = starknet::storage::StoragePointer { + __storage_pointer_address__: base_address, + __storage_pointer_offset__: current_offset, + }; + IDojoInitLibraryDispatcherSubPointersMut { + class_hash: class_hash_value, + } + } +} +impl IDojoInitSafeLibraryDispatcherCopy of core::traits::Copy::; +impl IDojoInitSafeLibraryDispatcherDrop of core::traits::Drop::; +impl IDojoInitSafeLibraryDispatcherSerde of core::serde::Serde:: { + fn serialize(self: @IDojoInitSafeLibraryDispatcher, ref output: core::array::Array) { + core::serde::Serde::serialize(self.class_hash, ref output) + } + fn deserialize(ref serialized: core::array::Span) -> core::option::Option { + core::option::Option::Some(IDojoInitSafeLibraryDispatcher { + class_hash: core::serde::Serde::deserialize(ref serialized)?, + }) + } +} +impl StoreIDojoInitSafeLibraryDispatcher of starknet::Store:: { + fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { + let class_hash = starknet::Store::::read(address_domain, base)?; + starknet::SyscallResult::Ok( + IDojoInitSafeLibraryDispatcher { + class_hash, + } + ) + } + fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write(address_domain, base, value.class_hash)?; + starknet::SyscallResult::Ok(()) + } + fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { + let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; + starknet::SyscallResult::Ok( + IDojoInitSafeLibraryDispatcher { + class_hash, + } + ) + } + #[inline(always)] + fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; + starknet::SyscallResult::Ok(()) + } + #[inline(always)] + fn size() -> u8 { + starknet::Store::::size() + } +} + +#[derive(Drop, Copy)] +pub struct IDojoInitSafeLibraryDispatcherSubPointers { + pub class_hash: starknet::storage::StoragePointer, +} +impl IDojoInitSafeLibraryDispatcherSubPointersImpl of starknet::storage::SubPointers { + type SubPointersType = IDojoInitSafeLibraryDispatcherSubPointers; + fn sub_pointers(self: starknet::storage::StoragePointer) -> IDojoInitSafeLibraryDispatcherSubPointers { + let base_address = self.__storage_pointer_address__; + let mut current_offset = self.__storage_pointer_offset__; + let class_hash_value = starknet::storage::StoragePointer { + __storage_pointer_address__: base_address, + __storage_pointer_offset__: current_offset, + }; + IDojoInitSafeLibraryDispatcherSubPointers { + class_hash: class_hash_value, + } + } +} +#[derive(Drop, Copy)] +pub struct IDojoInitSafeLibraryDispatcherSubPointersMut { + pub class_hash: starknet::storage::StoragePointer>, +} +impl IDojoInitSafeLibraryDispatcherSubPointersMutImpl of starknet::storage::SubPointersMut { + type SubPointersType = IDojoInitSafeLibraryDispatcherSubPointersMut; + fn sub_pointers_mut(self: starknet::storage::StoragePointer>) -> IDojoInitSafeLibraryDispatcherSubPointersMut { + let base_address = self.__storage_pointer_address__; + let mut current_offset = self.__storage_pointer_offset__; + let class_hash_value = starknet::storage::StoragePointer { + __storage_pointer_address__: base_address, + __storage_pointer_offset__: current_offset, + }; + IDojoInitSafeLibraryDispatcherSubPointersMut { + class_hash: class_hash_value, + } + } +} +impl IDojoInitSafeDispatcherCopy of core::traits::Copy::; +impl IDojoInitSafeDispatcherDrop of core::traits::Drop::; +impl IDojoInitSafeDispatcherSerde of core::serde::Serde:: { + fn serialize(self: @IDojoInitSafeDispatcher, ref output: core::array::Array) { + core::serde::Serde::serialize(self.contract_address, ref output) + } + fn deserialize(ref serialized: core::array::Span) -> core::option::Option { + core::option::Option::Some(IDojoInitSafeDispatcher { + contract_address: core::serde::Serde::deserialize(ref serialized)?, + }) + } +} +impl StoreIDojoInitSafeDispatcher of starknet::Store:: { + fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { + let contract_address = starknet::Store::::read(address_domain, base)?; + starknet::SyscallResult::Ok( + IDojoInitSafeDispatcher { + contract_address, + } + ) + } + fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitSafeDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write(address_domain, base, value.contract_address)?; + starknet::SyscallResult::Ok(()) + } + fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { + let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; + starknet::SyscallResult::Ok( + IDojoInitSafeDispatcher { + contract_address, + } + ) + } + #[inline(always)] + fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitSafeDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; + starknet::SyscallResult::Ok(()) + } + #[inline(always)] + fn size() -> u8 { + starknet::Store::::size() + } +} + +#[derive(Drop, Copy)] +pub struct IDojoInitSafeDispatcherSubPointers { + pub contract_address: starknet::storage::StoragePointer, +} +impl IDojoInitSafeDispatcherSubPointersImpl of starknet::storage::SubPointers { + type SubPointersType = IDojoInitSafeDispatcherSubPointers; + fn sub_pointers(self: starknet::storage::StoragePointer) -> IDojoInitSafeDispatcherSubPointers { + let base_address = self.__storage_pointer_address__; + let mut current_offset = self.__storage_pointer_offset__; + let contract_address_value = starknet::storage::StoragePointer { + __storage_pointer_address__: base_address, + __storage_pointer_offset__: current_offset, + }; + IDojoInitSafeDispatcherSubPointers { + contract_address: contract_address_value, + } + } +} +#[derive(Drop, Copy)] +pub struct IDojoInitSafeDispatcherSubPointersMut { + pub contract_address: starknet::storage::StoragePointer>, +} +impl IDojoInitSafeDispatcherSubPointersMutImpl of starknet::storage::SubPointersMut { + type SubPointersType = IDojoInitSafeDispatcherSubPointersMut; + fn sub_pointers_mut(self: starknet::storage::StoragePointer>) -> IDojoInitSafeDispatcherSubPointersMut { + let base_address = self.__storage_pointer_address__; + let mut current_offset = self.__storage_pointer_offset__; + let contract_address_value = starknet::storage::StoragePointer { + __storage_pointer_address__: base_address, + __storage_pointer_offset__: current_offset, + }; + IDojoInitSafeDispatcherSubPointersMut { + contract_address: contract_address_value, + } + } +} +impl StorageStorageBaseDrop of core::traits::Drop::; +impl StorageStorageBaseCopy of core::traits::Copy::; +impl StorageStorageBaseMutDrop of core::traits::Drop::; +impl StorageStorageBaseMutCopy of core::traits::Copy::; +impl IDojoInitDispatcherSubPointersDrop of core::traits::Drop::; +impl IDojoInitDispatcherSubPointersCopy of core::traits::Copy::; +impl IDojoInitDispatcherSubPointersMutDrop of core::traits::Drop::; +impl IDojoInitDispatcherSubPointersMutCopy of core::traits::Copy::; +impl IDojoInitLibraryDispatcherSubPointersDrop of core::traits::Drop::; +impl IDojoInitLibraryDispatcherSubPointersCopy of core::traits::Copy::; +impl IDojoInitLibraryDispatcherSubPointersMutDrop of core::traits::Drop::; +impl IDojoInitLibraryDispatcherSubPointersMutCopy of core::traits::Copy::; +impl IDojoInitSafeLibraryDispatcherSubPointersDrop of core::traits::Drop::; +impl IDojoInitSafeLibraryDispatcherSubPointersCopy of core::traits::Copy::; +impl IDojoInitSafeLibraryDispatcherSubPointersMutDrop of core::traits::Drop::; +impl IDojoInitSafeLibraryDispatcherSubPointersMutCopy of core::traits::Copy::; +impl IDojoInitSafeDispatcherSubPointersDrop of core::traits::Drop::; +impl IDojoInitSafeDispatcherSubPointersCopy of core::traits::Copy::; +impl IDojoInitSafeDispatcherSubPointersMutDrop of core::traits::Drop::; +impl IDojoInitSafeDispatcherSubPointersMutCopy of core::traits::Copy::; + + } + + #[starknet::contract] + pub mod proxy { + use dojo::world; + use dojo::world::IWorldDispatcher; + use dojo::world::IWorldDispatcherTrait; + use dojo::contract::components::world_provider::{world_provider_cpt, world_provider_cpt::InternalTrait as WorldProviderInternal, IWorldProvider}; + use dojo::contract::components::upgradeable::upgradeable_cpt; + use dojo::contract::IContract; + use starknet::storage::{ + StorageMapReadAccess, StorageMapWriteAccess, StoragePointerReadAccess, StoragePointerWriteAccess + }; + + #[abi(embed_v0)] + impl WorldProviderImpl = world_provider_cpt::WorldProviderImpl; + + #[abi(embed_v0)] + impl UpgradeableImpl = upgradeable_cpt::UpgradeableImpl; + + #[abi(embed_v0)] + pub impl ContractImpl of IContract { + fn name(self: @ContractState) -> ByteArray { + "proxy" + } + + fn namespace(self: @ContractState) -> ByteArray { + "my_namespace" + } + + fn tag(self: @ContractState) -> ByteArray { + "my_namespace-proxy" + } + + fn name_hash(self: @ContractState) -> felt252 { + 379211399603323842291430789821178524592027629543381998047225121027704003915 + } + + fn namespace_hash(self: @ContractState) -> felt252 { + 1685136890688416384941629523783652800960468745356230625531475538826800548713 + } + + fn selector(self: @ContractState) -> felt252 { + 1517897915978631541665409557725081861100844369870047691780983681552158397188 + } + } + + fn execute(value: felt252) -> felt252 { + value + } + + #[constructor] + fn constructor(ref self: ContractState) { + self.world_provider.initializer(); + } + +#[starknet::interface] +pub trait IDojoInit { + fn dojo_init(self: @ContractState); +} + +#[abi(embed_v0)] +pub impl IDojoInitImpl of IDojoInit { + fn dojo_init(self: @ContractState) { + if starknet::get_caller_address() != self.world_provider.world().contract_address { + core::panics::panic_with_byte_array( + @format!("Only the world can init contract `{}`, but caller is `{:?}`", + self.tag(), + starknet::get_caller_address(), + )); + } + } +} + + #[event] + #[derive(Drop, starknet::Event)] + enum Event { + UpgradeableEvent: upgradeable_cpt::Event, + WorldProviderEvent: world_provider_cpt::Event, + } +pub trait IDojoInitDispatcherTrait { + fn dojo_init(self: T); +} + +#[derive(Copy, Drop, starknet::Store, Serde)] +pub struct IDojoInitDispatcher { + pub contract_address: starknet::ContractAddress, +} + +impl IDojoInitDispatcherImpl of IDojoInitDispatcherTrait { + fn dojo_init(self: IDojoInitDispatcher) { + let mut __calldata__ = core::traits::Default::default(); + + let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( + self.contract_address, + selector!("dojo_init"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); + () + } + +} + +#[derive(Copy, Drop, starknet::Store, Serde)] +pub struct IDojoInitLibraryDispatcher { + pub class_hash: starknet::ClassHash, +} + +impl IDojoInitLibraryDispatcherImpl of IDojoInitDispatcherTrait { + fn dojo_init(self: IDojoInitLibraryDispatcher) { + let mut __calldata__ = core::traits::Default::default(); + + let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( + self.class_hash, + selector!("dojo_init"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); + () + } + +} + +pub trait IDojoInitSafeDispatcherTrait { + #[unstable(feature: "safe_dispatcher")] + fn dojo_init(self: T) -> starknet::SyscallResult<()>; +} + +#[derive(Copy, Drop, starknet::Store, Serde)] +pub struct IDojoInitSafeLibraryDispatcher { + pub class_hash: starknet::ClassHash, +} + +impl IDojoInitSafeLibraryDispatcherImpl of IDojoInitSafeDispatcherTrait { + fn dojo_init(self: IDojoInitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { + let mut __calldata__ = core::traits::Default::default(); + + let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( + self.class_hash, + selector!("dojo_init"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = __dispatcher_return_data__?; + Result::Ok(()) + } + +} + + +#[derive(Copy, Drop, starknet::Store, Serde)] +pub struct IDojoInitSafeDispatcher { + pub contract_address: starknet::ContractAddress, +} + +impl IDojoInitSafeDispatcherImpl of IDojoInitSafeDispatcherTrait { + fn dojo_init(self: IDojoInitSafeDispatcher) -> starknet::SyscallResult<()> { + let mut __calldata__ = core::traits::Default::default(); + + let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( + self.contract_address, + selector!("dojo_init"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = __dispatcher_return_data__?; + Result::Ok(()) + } + +} +impl EventDrop of core::traits::Drop::; +impl EventIsEvent of starknet::Event { + fn append_keys_and_data( + self: @Event, ref keys: Array, ref data: Array + ) { + match self { + Event::UpgradeableEvent(val) => { + core::array::ArrayTrait::append(ref keys, selector!("UpgradeableEvent")); + starknet::Event::append_keys_and_data( + val, ref keys, ref data + ); + }, + Event::WorldProviderEvent(val) => { + core::array::ArrayTrait::append(ref keys, selector!("WorldProviderEvent")); + starknet::Event::append_keys_and_data( + val, ref keys, ref data + ); + }, + } + } + fn deserialize( + ref keys: Span, ref data: Span, + ) -> Option { + let __selector__ = *core::array::SpanTrait::pop_front(ref keys)?; + if __selector__ == selector!("UpgradeableEvent") { + let val = starknet::Event::deserialize( + ref keys, ref data + )?; + return Option::Some(Event::UpgradeableEvent(val)); + } + if __selector__ == selector!("WorldProviderEvent") { + let val = starknet::Event::deserialize( + ref keys, ref data + )?; + return Option::Some(Event::WorldProviderEvent(val)); + } + Option::None + } +} +impl EventUpgradeableEventIntoEvent of Into { + fn into(self: upgradeable_cpt::Event) -> Event { + Event::UpgradeableEvent(self) + } +} +impl EventWorldProviderEventIntoEvent of Into { + fn into(self: world_provider_cpt::Event) -> Event { + Event::WorldProviderEvent(self) + } +} + + +#[phantom] +pub struct Storage { + #[substorage(v0)] + pub upgradeable: upgradeable_cpt::Storage, + #[substorage(v0)] + pub world_provider: world_provider_cpt::Storage, +} + +#[derive(Drop, Copy)] +pub struct StorageStorageBase { + pub upgradeable: starknet::storage::FlattenedStorage, + pub world_provider: starknet::storage::FlattenedStorage, +} +impl StorageStorageImpl of starknet::storage::StorageTrait { + type BaseType = StorageStorageBase; + fn storage(self: starknet::storage::FlattenedStorage) -> StorageStorageBase { + let upgradeable_value = starknet::storage::FlattenedStorage {}; + let world_provider_value = starknet::storage::FlattenedStorage {}; + StorageStorageBase { + upgradeable: upgradeable_value, + world_provider: world_provider_value, + } + } +} +#[derive(Drop, Copy)] +pub struct StorageStorageBaseMut { + pub upgradeable: starknet::storage::FlattenedStorage>, + pub world_provider: starknet::storage::FlattenedStorage>, +} +impl StorageStorageMutImpl of starknet::storage::StorageTraitMut { + type BaseType = StorageStorageBaseMut; + fn storage_mut(self: starknet::storage::FlattenedStorage>) -> StorageStorageBaseMut { + let upgradeable_value = starknet::storage::FlattenedStorage {}; + let world_provider_value = starknet::storage::FlattenedStorage {}; + StorageStorageBaseMut { + upgradeable: upgradeable_value, + world_provider: world_provider_value, + } + } +} + +pub struct ContractState { + pub upgradeable: upgradeable_cpt::ComponentState, + pub world_provider: world_provider_cpt::ComponentState, +} + +impl ContractStateDrop of Drop {} + +impl ContractStateDeref of core::ops::SnapshotDeref { + type Target = starknet::storage::FlattenedStorage; + fn snapshot_deref(self: @ContractState) -> starknet::storage::FlattenedStorage { + starknet::storage::FlattenedStorage {} + } +} +impl ContractStateDerefMut of core::ops::DerefMut { + type Target = starknet::storage::FlattenedStorage> ; + fn deref_mut(ref self: ContractState) -> starknet::storage::FlattenedStorage> { + starknet::storage::FlattenedStorage {} + } +} +pub fn unsafe_new_contract_state() -> ContractState { + ContractState { + upgradeable: upgradeable_cpt::unsafe_new_component_state::(), + world_provider: world_provider_cpt::unsafe_new_component_state::(), + } +} + +// TODO(Gil): This generates duplicate diagnostics because of the plugin system, squash the duplicates into one. +#[deprecated( + feature: "deprecated_legacy_map", + note: "Use `starknet::storage::Map` instead." +)] +use starknet::storage::Map as LegacyMap; + +impl ContractStateWorldProviderImpl of + world_provider_cpt::UnsafeNewContractStateTraitForWorldProviderImpl { + fn unsafe_new_contract_state() -> ContractState { + unsafe_new_contract_state() + } +} +impl ContractStateUpgradeableImpl of + upgradeable_cpt::UnsafeNewContractStateTraitForUpgradeableImpl { + fn unsafe_new_contract_state() -> ContractState { + unsafe_new_contract_state() + } +} +#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] +fn __wrapper__ContractImpl__name(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = ContractImpl::name(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] +fn __wrapper__ContractImpl__namespace(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = ContractImpl::namespace(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] +fn __wrapper__ContractImpl__tag(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = ContractImpl::tag(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] +fn __wrapper__ContractImpl__name_hash(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = ContractImpl::name_hash(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] +fn __wrapper__ContractImpl__namespace_hash(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = ContractImpl::namespace_hash(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] +fn __wrapper__ContractImpl__selector(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = ContractImpl::selector(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] +fn __wrapper__constructor(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + constructor(ref contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] +fn __wrapper__IDojoInitImpl__dojo_init(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + IDojoInitImpl::dojo_init(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::array::ArrayTrait::span(@arr) +} + + +pub mod __external { + pub use super::__wrapper__ContractImpl__name as name; + pub use super::__wrapper__ContractImpl__namespace as namespace; + pub use super::__wrapper__ContractImpl__tag as tag; + pub use super::__wrapper__ContractImpl__name_hash as name_hash; + pub use super::__wrapper__ContractImpl__namespace_hash as namespace_hash; + pub use super::__wrapper__ContractImpl__selector as selector; + pub use super::__wrapper__IDojoInitImpl__dojo_init as dojo_init; +} +pub mod __l1_handler { +} +pub mod __constructor { + pub use super::__wrapper__constructor as constructor; +} + impl ContractStateEventEmitter of starknet::event::EventEmitter< + ContractState, Event + > { + fn emit>( + ref self: ContractState, event: S + ) { + let event: Event = core::traits::Into::into(event); + let mut keys = Default::::default(); + let mut data = Default::::default(); + starknet::Event::append_keys_and_data(@event, ref keys, ref data); + starknet::SyscallResultTrait::unwrap_syscall( + starknet::syscalls::emit_event_syscall( + core::array::ArrayTrait::span(@keys), + core::array::ArrayTrait::span(@data), + ) + ) + } + } + +impl HasComponentImpl_world_provider_cpt of world_provider_cpt::HasComponent { + fn get_component(self: @ContractState) -> @world_provider_cpt::ComponentState { + @world_provider_cpt::unsafe_new_component_state::() + } + fn get_component_mut(ref self: ContractState) -> world_provider_cpt::ComponentState { + world_provider_cpt::unsafe_new_component_state::() + } + fn get_contract(self: @world_provider_cpt::ComponentState) -> @ContractState { + @unsafe_new_contract_state() + } + fn get_contract_mut(ref self: world_provider_cpt::ComponentState) -> ContractState { + unsafe_new_contract_state() + } + fn emit>(ref self: world_provider_cpt::ComponentState, event: S) { + let event: world_provider_cpt::Event = core::traits::Into::into(event); + let mut contract = world_provider_cpt::HasComponent::get_contract_mut(ref self); + ContractStateEventEmitter::emit(ref contract, Event::WorldProviderEvent(event)); + } +} +impl HasComponentImpl_upgradeable_cpt of upgradeable_cpt::HasComponent { + fn get_component(self: @ContractState) -> @upgradeable_cpt::ComponentState { + @upgradeable_cpt::unsafe_new_component_state::() + } + fn get_component_mut(ref self: ContractState) -> upgradeable_cpt::ComponentState { + upgradeable_cpt::unsafe_new_component_state::() + } + fn get_contract(self: @upgradeable_cpt::ComponentState) -> @ContractState { + @unsafe_new_contract_state() + } + fn get_contract_mut(ref self: upgradeable_cpt::ComponentState) -> ContractState { + unsafe_new_contract_state() + } + fn emit>(ref self: upgradeable_cpt::ComponentState, event: S) { + let event: upgradeable_cpt::Event = core::traits::Into::into(event); + let mut contract = upgradeable_cpt::HasComponent::get_contract_mut(ref self); + ContractStateEventEmitter::emit(ref contract, Event::UpgradeableEvent(event)); + } +} +impl IDojoInitDispatcherCopy of core::traits::Copy::; +impl IDojoInitDispatcherDrop of core::traits::Drop::; +impl IDojoInitDispatcherSerde of core::serde::Serde:: { + fn serialize(self: @IDojoInitDispatcher, ref output: core::array::Array) { + core::serde::Serde::serialize(self.contract_address, ref output) + } + fn deserialize(ref serialized: core::array::Span) -> core::option::Option { + core::option::Option::Some(IDojoInitDispatcher { + contract_address: core::serde::Serde::deserialize(ref serialized)?, + }) + } +} +impl StoreIDojoInitDispatcher of starknet::Store:: { + fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { + let contract_address = starknet::Store::::read(address_domain, base)?; + starknet::SyscallResult::Ok( + IDojoInitDispatcher { + contract_address, + } + ) + } + fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write(address_domain, base, value.contract_address)?; + starknet::SyscallResult::Ok(()) + } + fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { + let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; + starknet::SyscallResult::Ok( + IDojoInitDispatcher { + contract_address, + } + ) + } + #[inline(always)] + fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; + starknet::SyscallResult::Ok(()) + } + #[inline(always)] + fn size() -> u8 { + starknet::Store::::size() + } +} + +#[derive(Drop, Copy)] +pub struct IDojoInitDispatcherSubPointers { + pub contract_address: starknet::storage::StoragePointer, +} +impl IDojoInitDispatcherSubPointersImpl of starknet::storage::SubPointers { + type SubPointersType = IDojoInitDispatcherSubPointers; + fn sub_pointers(self: starknet::storage::StoragePointer) -> IDojoInitDispatcherSubPointers { + let base_address = self.__storage_pointer_address__; + let mut current_offset = self.__storage_pointer_offset__; + let contract_address_value = starknet::storage::StoragePointer { + __storage_pointer_address__: base_address, + __storage_pointer_offset__: current_offset, + }; + IDojoInitDispatcherSubPointers { + contract_address: contract_address_value, + } + } +} +#[derive(Drop, Copy)] +pub struct IDojoInitDispatcherSubPointersMut { + pub contract_address: starknet::storage::StoragePointer>, +} +impl IDojoInitDispatcherSubPointersMutImpl of starknet::storage::SubPointersMut { + type SubPointersType = IDojoInitDispatcherSubPointersMut; + fn sub_pointers_mut(self: starknet::storage::StoragePointer>) -> IDojoInitDispatcherSubPointersMut { + let base_address = self.__storage_pointer_address__; + let mut current_offset = self.__storage_pointer_offset__; + let contract_address_value = starknet::storage::StoragePointer { + __storage_pointer_address__: base_address, + __storage_pointer_offset__: current_offset, + }; + IDojoInitDispatcherSubPointersMut { + contract_address: contract_address_value, + } + } +} +impl IDojoInitLibraryDispatcherCopy of core::traits::Copy::; +impl IDojoInitLibraryDispatcherDrop of core::traits::Drop::; +impl IDojoInitLibraryDispatcherSerde of core::serde::Serde:: { + fn serialize(self: @IDojoInitLibraryDispatcher, ref output: core::array::Array) { + core::serde::Serde::serialize(self.class_hash, ref output) + } + fn deserialize(ref serialized: core::array::Span) -> core::option::Option { + core::option::Option::Some(IDojoInitLibraryDispatcher { + class_hash: core::serde::Serde::deserialize(ref serialized)?, + }) + } +} +impl StoreIDojoInitLibraryDispatcher of starknet::Store:: { + fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { + let class_hash = starknet::Store::::read(address_domain, base)?; + starknet::SyscallResult::Ok( + IDojoInitLibraryDispatcher { + class_hash, + } + ) + } + fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitLibraryDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write(address_domain, base, value.class_hash)?; + starknet::SyscallResult::Ok(()) + } + fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { + let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; + starknet::SyscallResult::Ok( + IDojoInitLibraryDispatcher { + class_hash, + } + ) + } + #[inline(always)] + fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitLibraryDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; + starknet::SyscallResult::Ok(()) + } + #[inline(always)] + fn size() -> u8 { + starknet::Store::::size() + } +} + +#[derive(Drop, Copy)] +pub struct IDojoInitLibraryDispatcherSubPointers { + pub class_hash: starknet::storage::StoragePointer, +} +impl IDojoInitLibraryDispatcherSubPointersImpl of starknet::storage::SubPointers { + type SubPointersType = IDojoInitLibraryDispatcherSubPointers; + fn sub_pointers(self: starknet::storage::StoragePointer) -> IDojoInitLibraryDispatcherSubPointers { + let base_address = self.__storage_pointer_address__; + let mut current_offset = self.__storage_pointer_offset__; + let class_hash_value = starknet::storage::StoragePointer { + __storage_pointer_address__: base_address, + __storage_pointer_offset__: current_offset, + }; + IDojoInitLibraryDispatcherSubPointers { + class_hash: class_hash_value, + } + } +} +#[derive(Drop, Copy)] +pub struct IDojoInitLibraryDispatcherSubPointersMut { + pub class_hash: starknet::storage::StoragePointer>, +} +impl IDojoInitLibraryDispatcherSubPointersMutImpl of starknet::storage::SubPointersMut { + type SubPointersType = IDojoInitLibraryDispatcherSubPointersMut; + fn sub_pointers_mut(self: starknet::storage::StoragePointer>) -> IDojoInitLibraryDispatcherSubPointersMut { + let base_address = self.__storage_pointer_address__; + let mut current_offset = self.__storage_pointer_offset__; + let class_hash_value = starknet::storage::StoragePointer { + __storage_pointer_address__: base_address, + __storage_pointer_offset__: current_offset, + }; + IDojoInitLibraryDispatcherSubPointersMut { + class_hash: class_hash_value, + } + } +} +impl IDojoInitSafeLibraryDispatcherCopy of core::traits::Copy::; +impl IDojoInitSafeLibraryDispatcherDrop of core::traits::Drop::; +impl IDojoInitSafeLibraryDispatcherSerde of core::serde::Serde:: { + fn serialize(self: @IDojoInitSafeLibraryDispatcher, ref output: core::array::Array) { + core::serde::Serde::serialize(self.class_hash, ref output) + } + fn deserialize(ref serialized: core::array::Span) -> core::option::Option { + core::option::Option::Some(IDojoInitSafeLibraryDispatcher { + class_hash: core::serde::Serde::deserialize(ref serialized)?, + }) + } +} +impl StoreIDojoInitSafeLibraryDispatcher of starknet::Store:: { + fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { + let class_hash = starknet::Store::::read(address_domain, base)?; + starknet::SyscallResult::Ok( + IDojoInitSafeLibraryDispatcher { + class_hash, + } + ) + } + fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write(address_domain, base, value.class_hash)?; + starknet::SyscallResult::Ok(()) + } + fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { + let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; + starknet::SyscallResult::Ok( + IDojoInitSafeLibraryDispatcher { + class_hash, + } + ) + } + #[inline(always)] + fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; + starknet::SyscallResult::Ok(()) + } + #[inline(always)] + fn size() -> u8 { + starknet::Store::::size() + } +} + +#[derive(Drop, Copy)] +pub struct IDojoInitSafeLibraryDispatcherSubPointers { + pub class_hash: starknet::storage::StoragePointer, +} +impl IDojoInitSafeLibraryDispatcherSubPointersImpl of starknet::storage::SubPointers { + type SubPointersType = IDojoInitSafeLibraryDispatcherSubPointers; + fn sub_pointers(self: starknet::storage::StoragePointer) -> IDojoInitSafeLibraryDispatcherSubPointers { + let base_address = self.__storage_pointer_address__; + let mut current_offset = self.__storage_pointer_offset__; + let class_hash_value = starknet::storage::StoragePointer { + __storage_pointer_address__: base_address, + __storage_pointer_offset__: current_offset, + }; + IDojoInitSafeLibraryDispatcherSubPointers { + class_hash: class_hash_value, + } + } +} +#[derive(Drop, Copy)] +pub struct IDojoInitSafeLibraryDispatcherSubPointersMut { + pub class_hash: starknet::storage::StoragePointer>, +} +impl IDojoInitSafeLibraryDispatcherSubPointersMutImpl of starknet::storage::SubPointersMut { + type SubPointersType = IDojoInitSafeLibraryDispatcherSubPointersMut; + fn sub_pointers_mut(self: starknet::storage::StoragePointer>) -> IDojoInitSafeLibraryDispatcherSubPointersMut { + let base_address = self.__storage_pointer_address__; + let mut current_offset = self.__storage_pointer_offset__; + let class_hash_value = starknet::storage::StoragePointer { + __storage_pointer_address__: base_address, + __storage_pointer_offset__: current_offset, + }; + IDojoInitSafeLibraryDispatcherSubPointersMut { + class_hash: class_hash_value, + } + } +} +impl IDojoInitSafeDispatcherCopy of core::traits::Copy::; +impl IDojoInitSafeDispatcherDrop of core::traits::Drop::; +impl IDojoInitSafeDispatcherSerde of core::serde::Serde:: { + fn serialize(self: @IDojoInitSafeDispatcher, ref output: core::array::Array) { + core::serde::Serde::serialize(self.contract_address, ref output) + } + fn deserialize(ref serialized: core::array::Span) -> core::option::Option { + core::option::Option::Some(IDojoInitSafeDispatcher { + contract_address: core::serde::Serde::deserialize(ref serialized)?, + }) + } +} +impl StoreIDojoInitSafeDispatcher of starknet::Store:: { + fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { + let contract_address = starknet::Store::::read(address_domain, base)?; + starknet::SyscallResult::Ok( + IDojoInitSafeDispatcher { + contract_address, + } + ) + } + fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitSafeDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write(address_domain, base, value.contract_address)?; + starknet::SyscallResult::Ok(()) + } + fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { + let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; + starknet::SyscallResult::Ok( + IDojoInitSafeDispatcher { + contract_address, + } + ) + } + #[inline(always)] + fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitSafeDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; + starknet::SyscallResult::Ok(()) + } + #[inline(always)] + fn size() -> u8 { + starknet::Store::::size() + } +} + +#[derive(Drop, Copy)] +pub struct IDojoInitSafeDispatcherSubPointers { + pub contract_address: starknet::storage::StoragePointer, +} +impl IDojoInitSafeDispatcherSubPointersImpl of starknet::storage::SubPointers { + type SubPointersType = IDojoInitSafeDispatcherSubPointers; + fn sub_pointers(self: starknet::storage::StoragePointer) -> IDojoInitSafeDispatcherSubPointers { + let base_address = self.__storage_pointer_address__; + let mut current_offset = self.__storage_pointer_offset__; + let contract_address_value = starknet::storage::StoragePointer { + __storage_pointer_address__: base_address, + __storage_pointer_offset__: current_offset, + }; + IDojoInitSafeDispatcherSubPointers { + contract_address: contract_address_value, + } + } +} +#[derive(Drop, Copy)] +pub struct IDojoInitSafeDispatcherSubPointersMut { + pub contract_address: starknet::storage::StoragePointer>, +} +impl IDojoInitSafeDispatcherSubPointersMutImpl of starknet::storage::SubPointersMut { + type SubPointersType = IDojoInitSafeDispatcherSubPointersMut; + fn sub_pointers_mut(self: starknet::storage::StoragePointer>) -> IDojoInitSafeDispatcherSubPointersMut { + let base_address = self.__storage_pointer_address__; + let mut current_offset = self.__storage_pointer_offset__; + let contract_address_value = starknet::storage::StoragePointer { + __storage_pointer_address__: base_address, + __storage_pointer_offset__: current_offset, + }; + IDojoInitSafeDispatcherSubPointersMut { + contract_address: contract_address_value, + } + } +} +impl StorageStorageBaseDrop of core::traits::Drop::; +impl StorageStorageBaseCopy of core::traits::Copy::; +impl StorageStorageBaseMutDrop of core::traits::Drop::; +impl StorageStorageBaseMutCopy of core::traits::Copy::; +impl IDojoInitDispatcherSubPointersDrop of core::traits::Drop::; +impl IDojoInitDispatcherSubPointersCopy of core::traits::Copy::; +impl IDojoInitDispatcherSubPointersMutDrop of core::traits::Drop::; +impl IDojoInitDispatcherSubPointersMutCopy of core::traits::Copy::; +impl IDojoInitLibraryDispatcherSubPointersDrop of core::traits::Drop::; +impl IDojoInitLibraryDispatcherSubPointersCopy of core::traits::Copy::; +impl IDojoInitLibraryDispatcherSubPointersMutDrop of core::traits::Drop::; +impl IDojoInitLibraryDispatcherSubPointersMutCopy of core::traits::Copy::; +impl IDojoInitSafeLibraryDispatcherSubPointersDrop of core::traits::Drop::; +impl IDojoInitSafeLibraryDispatcherSubPointersCopy of core::traits::Copy::; +impl IDojoInitSafeLibraryDispatcherSubPointersMutDrop of core::traits::Drop::; +impl IDojoInitSafeLibraryDispatcherSubPointersMutCopy of core::traits::Copy::; +impl IDojoInitSafeDispatcherSubPointersDrop of core::traits::Drop::; +impl IDojoInitSafeDispatcherSubPointersCopy of core::traits::Copy::; +impl IDojoInitSafeDispatcherSubPointersMutDrop of core::traits::Drop::; +impl IDojoInitSafeDispatcherSubPointersMutCopy of core::traits::Copy::; + + } + + #[starknet::contract] + pub mod ctxnamed { + use dojo::world; + use dojo::world::IWorldDispatcher; + use dojo::world::IWorldDispatcherTrait; + use dojo::contract::components::world_provider::{world_provider_cpt, world_provider_cpt::InternalTrait as WorldProviderInternal, IWorldProvider}; + use dojo::contract::components::upgradeable::upgradeable_cpt; + use dojo::contract::IContract; + use starknet::storage::{ + StorageMapReadAccess, StorageMapWriteAccess, StoragePointerReadAccess, StoragePointerWriteAccess + }; + + #[abi(embed_v0)] + impl WorldProviderImpl = world_provider_cpt::WorldProviderImpl; + + #[abi(embed_v0)] + impl UpgradeableImpl = upgradeable_cpt::UpgradeableImpl; + + #[abi(embed_v0)] + pub impl ContractImpl of IContract { + fn name(self: @ContractState) -> ByteArray { + "ctxnamed" + } + + fn namespace(self: @ContractState) -> ByteArray { + "dojo_test" + } + + fn tag(self: @ContractState) -> ByteArray { + "dojo_test-ctxnamed" + } + + fn name_hash(self: @ContractState) -> felt252 { + 1120614286815912604239420768209466007446460277061516527925636408561239543041 + } + + fn namespace_hash(self: @ContractState) -> felt252 { + 1452123528942907587532668415362544424816022573043154497385993678618948064048 + } + + fn selector(self: @ContractState) -> felt252 { + 1088922133313711214547564678240399488767278073212336739350382494993498982824 + } + } + + use traits::Into; + use dojo::world::Context; + + fn execute(ctx2: Context, name: felt252) { + return (); + } + + #[constructor] + fn constructor(ref self: ContractState) { + self.world_provider.initializer(); + } + +#[starknet::interface] +pub trait IDojoInit { + fn dojo_init(self: @ContractState); +} + +#[abi(embed_v0)] +pub impl IDojoInitImpl of IDojoInit { + fn dojo_init(self: @ContractState) { + if starknet::get_caller_address() != self.world_provider.world().contract_address { + core::panics::panic_with_byte_array( + @format!("Only the world can init contract `{}`, but caller is `{:?}`", + self.tag(), + starknet::get_caller_address(), + )); + } + } +} + + #[event] + #[derive(Drop, starknet::Event)] + enum Event { + UpgradeableEvent: upgradeable_cpt::Event, + WorldProviderEvent: world_provider_cpt::Event, + } +pub trait IDojoInitDispatcherTrait { + fn dojo_init(self: T); +} + +#[derive(Copy, Drop, starknet::Store, Serde)] +pub struct IDojoInitDispatcher { + pub contract_address: starknet::ContractAddress, +} + +impl IDojoInitDispatcherImpl of IDojoInitDispatcherTrait { + fn dojo_init(self: IDojoInitDispatcher) { + let mut __calldata__ = core::traits::Default::default(); + + let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( + self.contract_address, + selector!("dojo_init"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); + () + } + +} + +#[derive(Copy, Drop, starknet::Store, Serde)] +pub struct IDojoInitLibraryDispatcher { + pub class_hash: starknet::ClassHash, +} + +impl IDojoInitLibraryDispatcherImpl of IDojoInitDispatcherTrait { + fn dojo_init(self: IDojoInitLibraryDispatcher) { + let mut __calldata__ = core::traits::Default::default(); + + let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( + self.class_hash, + selector!("dojo_init"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); + () + } + +} + +pub trait IDojoInitSafeDispatcherTrait { + #[unstable(feature: "safe_dispatcher")] + fn dojo_init(self: T) -> starknet::SyscallResult<()>; +} + +#[derive(Copy, Drop, starknet::Store, Serde)] +pub struct IDojoInitSafeLibraryDispatcher { + pub class_hash: starknet::ClassHash, +} + +impl IDojoInitSafeLibraryDispatcherImpl of IDojoInitSafeDispatcherTrait { + fn dojo_init(self: IDojoInitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { + let mut __calldata__ = core::traits::Default::default(); + + let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( + self.class_hash, + selector!("dojo_init"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = __dispatcher_return_data__?; + Result::Ok(()) + } + +} + + +#[derive(Copy, Drop, starknet::Store, Serde)] +pub struct IDojoInitSafeDispatcher { + pub contract_address: starknet::ContractAddress, +} + +impl IDojoInitSafeDispatcherImpl of IDojoInitSafeDispatcherTrait { + fn dojo_init(self: IDojoInitSafeDispatcher) -> starknet::SyscallResult<()> { + let mut __calldata__ = core::traits::Default::default(); + + let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( + self.contract_address, + selector!("dojo_init"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = __dispatcher_return_data__?; + Result::Ok(()) + } + +} +impl EventDrop of core::traits::Drop::; +impl EventIsEvent of starknet::Event { + fn append_keys_and_data( + self: @Event, ref keys: Array, ref data: Array + ) { + match self { + Event::UpgradeableEvent(val) => { + core::array::ArrayTrait::append(ref keys, selector!("UpgradeableEvent")); + starknet::Event::append_keys_and_data( + val, ref keys, ref data + ); + }, + Event::WorldProviderEvent(val) => { + core::array::ArrayTrait::append(ref keys, selector!("WorldProviderEvent")); + starknet::Event::append_keys_and_data( + val, ref keys, ref data + ); + }, + } + } + fn deserialize( + ref keys: Span, ref data: Span, + ) -> Option { + let __selector__ = *core::array::SpanTrait::pop_front(ref keys)?; + if __selector__ == selector!("UpgradeableEvent") { + let val = starknet::Event::deserialize( + ref keys, ref data + )?; + return Option::Some(Event::UpgradeableEvent(val)); + } + if __selector__ == selector!("WorldProviderEvent") { + let val = starknet::Event::deserialize( + ref keys, ref data + )?; + return Option::Some(Event::WorldProviderEvent(val)); + } + Option::None + } +} +impl EventUpgradeableEventIntoEvent of Into { + fn into(self: upgradeable_cpt::Event) -> Event { + Event::UpgradeableEvent(self) + } +} +impl EventWorldProviderEventIntoEvent of Into { + fn into(self: world_provider_cpt::Event) -> Event { + Event::WorldProviderEvent(self) + } +} + + +#[phantom] +pub struct Storage { + #[substorage(v0)] + pub upgradeable: upgradeable_cpt::Storage, + #[substorage(v0)] + pub world_provider: world_provider_cpt::Storage, +} + +#[derive(Drop, Copy)] +pub struct StorageStorageBase { + pub upgradeable: starknet::storage::FlattenedStorage, + pub world_provider: starknet::storage::FlattenedStorage, +} +impl StorageStorageImpl of starknet::storage::StorageTrait { + type BaseType = StorageStorageBase; + fn storage(self: starknet::storage::FlattenedStorage) -> StorageStorageBase { + let upgradeable_value = starknet::storage::FlattenedStorage {}; + let world_provider_value = starknet::storage::FlattenedStorage {}; + StorageStorageBase { + upgradeable: upgradeable_value, + world_provider: world_provider_value, + } + } +} +#[derive(Drop, Copy)] +pub struct StorageStorageBaseMut { + pub upgradeable: starknet::storage::FlattenedStorage>, + pub world_provider: starknet::storage::FlattenedStorage>, +} +impl StorageStorageMutImpl of starknet::storage::StorageTraitMut { + type BaseType = StorageStorageBaseMut; + fn storage_mut(self: starknet::storage::FlattenedStorage>) -> StorageStorageBaseMut { + let upgradeable_value = starknet::storage::FlattenedStorage {}; + let world_provider_value = starknet::storage::FlattenedStorage {}; + StorageStorageBaseMut { + upgradeable: upgradeable_value, + world_provider: world_provider_value, + } } } @@ -1385,86 +2826,441 @@ fn __wrapper__constructor(mut data: Span::) -> Span:: { core::array::ArrayTrait::span(@arr) } - -pub mod __external { - pub use super::__wrapper__ContractImpl__name as name; - pub use super::__wrapper__ContractImpl__namespace as namespace; - pub use super::__wrapper__ContractImpl__tag as tag; - pub use super::__wrapper__ContractImpl__name_hash as name_hash; - pub use super::__wrapper__ContractImpl__namespace_hash as namespace_hash; - pub use super::__wrapper__ContractImpl__selector as selector; +#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] +fn __wrapper__IDojoInitImpl__dojo_init(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + IDojoInitImpl::dojo_init(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::array::ArrayTrait::span(@arr) +} + + +pub mod __external { + pub use super::__wrapper__ContractImpl__name as name; + pub use super::__wrapper__ContractImpl__namespace as namespace; + pub use super::__wrapper__ContractImpl__tag as tag; + pub use super::__wrapper__ContractImpl__name_hash as name_hash; + pub use super::__wrapper__ContractImpl__namespace_hash as namespace_hash; + pub use super::__wrapper__ContractImpl__selector as selector; + pub use super::__wrapper__IDojoInitImpl__dojo_init as dojo_init; +} +pub mod __l1_handler { +} +pub mod __constructor { + pub use super::__wrapper__constructor as constructor; +} + impl ContractStateEventEmitter of starknet::event::EventEmitter< + ContractState, Event + > { + fn emit>( + ref self: ContractState, event: S + ) { + let event: Event = core::traits::Into::into(event); + let mut keys = Default::::default(); + let mut data = Default::::default(); + starknet::Event::append_keys_and_data(@event, ref keys, ref data); + starknet::SyscallResultTrait::unwrap_syscall( + starknet::syscalls::emit_event_syscall( + core::array::ArrayTrait::span(@keys), + core::array::ArrayTrait::span(@data), + ) + ) + } + } + +impl HasComponentImpl_world_provider_cpt of world_provider_cpt::HasComponent { + fn get_component(self: @ContractState) -> @world_provider_cpt::ComponentState { + @world_provider_cpt::unsafe_new_component_state::() + } + fn get_component_mut(ref self: ContractState) -> world_provider_cpt::ComponentState { + world_provider_cpt::unsafe_new_component_state::() + } + fn get_contract(self: @world_provider_cpt::ComponentState) -> @ContractState { + @unsafe_new_contract_state() + } + fn get_contract_mut(ref self: world_provider_cpt::ComponentState) -> ContractState { + unsafe_new_contract_state() + } + fn emit>(ref self: world_provider_cpt::ComponentState, event: S) { + let event: world_provider_cpt::Event = core::traits::Into::into(event); + let mut contract = world_provider_cpt::HasComponent::get_contract_mut(ref self); + ContractStateEventEmitter::emit(ref contract, Event::WorldProviderEvent(event)); + } +} +impl HasComponentImpl_upgradeable_cpt of upgradeable_cpt::HasComponent { + fn get_component(self: @ContractState) -> @upgradeable_cpt::ComponentState { + @upgradeable_cpt::unsafe_new_component_state::() + } + fn get_component_mut(ref self: ContractState) -> upgradeable_cpt::ComponentState { + upgradeable_cpt::unsafe_new_component_state::() + } + fn get_contract(self: @upgradeable_cpt::ComponentState) -> @ContractState { + @unsafe_new_contract_state() + } + fn get_contract_mut(ref self: upgradeable_cpt::ComponentState) -> ContractState { + unsafe_new_contract_state() + } + fn emit>(ref self: upgradeable_cpt::ComponentState, event: S) { + let event: upgradeable_cpt::Event = core::traits::Into::into(event); + let mut contract = upgradeable_cpt::HasComponent::get_contract_mut(ref self); + ContractStateEventEmitter::emit(ref contract, Event::UpgradeableEvent(event)); + } +} +impl IDojoInitDispatcherCopy of core::traits::Copy::; +impl IDojoInitDispatcherDrop of core::traits::Drop::; +impl IDojoInitDispatcherSerde of core::serde::Serde:: { + fn serialize(self: @IDojoInitDispatcher, ref output: core::array::Array) { + core::serde::Serde::serialize(self.contract_address, ref output) + } + fn deserialize(ref serialized: core::array::Span) -> core::option::Option { + core::option::Option::Some(IDojoInitDispatcher { + contract_address: core::serde::Serde::deserialize(ref serialized)?, + }) + } +} +impl StoreIDojoInitDispatcher of starknet::Store:: { + fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { + let contract_address = starknet::Store::::read(address_domain, base)?; + starknet::SyscallResult::Ok( + IDojoInitDispatcher { + contract_address, + } + ) + } + fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write(address_domain, base, value.contract_address)?; + starknet::SyscallResult::Ok(()) + } + fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { + let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; + starknet::SyscallResult::Ok( + IDojoInitDispatcher { + contract_address, + } + ) + } + #[inline(always)] + fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; + starknet::SyscallResult::Ok(()) + } + #[inline(always)] + fn size() -> u8 { + starknet::Store::::size() + } +} + +#[derive(Drop, Copy)] +pub struct IDojoInitDispatcherSubPointers { + pub contract_address: starknet::storage::StoragePointer, +} +impl IDojoInitDispatcherSubPointersImpl of starknet::storage::SubPointers { + type SubPointersType = IDojoInitDispatcherSubPointers; + fn sub_pointers(self: starknet::storage::StoragePointer) -> IDojoInitDispatcherSubPointers { + let base_address = self.__storage_pointer_address__; + let mut current_offset = self.__storage_pointer_offset__; + let contract_address_value = starknet::storage::StoragePointer { + __storage_pointer_address__: base_address, + __storage_pointer_offset__: current_offset, + }; + IDojoInitDispatcherSubPointers { + contract_address: contract_address_value, + } + } +} +#[derive(Drop, Copy)] +pub struct IDojoInitDispatcherSubPointersMut { + pub contract_address: starknet::storage::StoragePointer>, +} +impl IDojoInitDispatcherSubPointersMutImpl of starknet::storage::SubPointersMut { + type SubPointersType = IDojoInitDispatcherSubPointersMut; + fn sub_pointers_mut(self: starknet::storage::StoragePointer>) -> IDojoInitDispatcherSubPointersMut { + let base_address = self.__storage_pointer_address__; + let mut current_offset = self.__storage_pointer_offset__; + let contract_address_value = starknet::storage::StoragePointer { + __storage_pointer_address__: base_address, + __storage_pointer_offset__: current_offset, + }; + IDojoInitDispatcherSubPointersMut { + contract_address: contract_address_value, + } + } +} +impl IDojoInitLibraryDispatcherCopy of core::traits::Copy::; +impl IDojoInitLibraryDispatcherDrop of core::traits::Drop::; +impl IDojoInitLibraryDispatcherSerde of core::serde::Serde:: { + fn serialize(self: @IDojoInitLibraryDispatcher, ref output: core::array::Array) { + core::serde::Serde::serialize(self.class_hash, ref output) + } + fn deserialize(ref serialized: core::array::Span) -> core::option::Option { + core::option::Option::Some(IDojoInitLibraryDispatcher { + class_hash: core::serde::Serde::deserialize(ref serialized)?, + }) + } +} +impl StoreIDojoInitLibraryDispatcher of starknet::Store:: { + fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { + let class_hash = starknet::Store::::read(address_domain, base)?; + starknet::SyscallResult::Ok( + IDojoInitLibraryDispatcher { + class_hash, + } + ) + } + fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitLibraryDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write(address_domain, base, value.class_hash)?; + starknet::SyscallResult::Ok(()) + } + fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { + let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; + starknet::SyscallResult::Ok( + IDojoInitLibraryDispatcher { + class_hash, + } + ) + } + #[inline(always)] + fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitLibraryDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; + starknet::SyscallResult::Ok(()) + } + #[inline(always)] + fn size() -> u8 { + starknet::Store::::size() + } +} + +#[derive(Drop, Copy)] +pub struct IDojoInitLibraryDispatcherSubPointers { + pub class_hash: starknet::storage::StoragePointer, +} +impl IDojoInitLibraryDispatcherSubPointersImpl of starknet::storage::SubPointers { + type SubPointersType = IDojoInitLibraryDispatcherSubPointers; + fn sub_pointers(self: starknet::storage::StoragePointer) -> IDojoInitLibraryDispatcherSubPointers { + let base_address = self.__storage_pointer_address__; + let mut current_offset = self.__storage_pointer_offset__; + let class_hash_value = starknet::storage::StoragePointer { + __storage_pointer_address__: base_address, + __storage_pointer_offset__: current_offset, + }; + IDojoInitLibraryDispatcherSubPointers { + class_hash: class_hash_value, + } + } +} +#[derive(Drop, Copy)] +pub struct IDojoInitLibraryDispatcherSubPointersMut { + pub class_hash: starknet::storage::StoragePointer>, +} +impl IDojoInitLibraryDispatcherSubPointersMutImpl of starknet::storage::SubPointersMut { + type SubPointersType = IDojoInitLibraryDispatcherSubPointersMut; + fn sub_pointers_mut(self: starknet::storage::StoragePointer>) -> IDojoInitLibraryDispatcherSubPointersMut { + let base_address = self.__storage_pointer_address__; + let mut current_offset = self.__storage_pointer_offset__; + let class_hash_value = starknet::storage::StoragePointer { + __storage_pointer_address__: base_address, + __storage_pointer_offset__: current_offset, + }; + IDojoInitLibraryDispatcherSubPointersMut { + class_hash: class_hash_value, + } + } +} +impl IDojoInitSafeLibraryDispatcherCopy of core::traits::Copy::; +impl IDojoInitSafeLibraryDispatcherDrop of core::traits::Drop::; +impl IDojoInitSafeLibraryDispatcherSerde of core::serde::Serde:: { + fn serialize(self: @IDojoInitSafeLibraryDispatcher, ref output: core::array::Array) { + core::serde::Serde::serialize(self.class_hash, ref output) + } + fn deserialize(ref serialized: core::array::Span) -> core::option::Option { + core::option::Option::Some(IDojoInitSafeLibraryDispatcher { + class_hash: core::serde::Serde::deserialize(ref serialized)?, + }) + } +} +impl StoreIDojoInitSafeLibraryDispatcher of starknet::Store:: { + fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { + let class_hash = starknet::Store::::read(address_domain, base)?; + starknet::SyscallResult::Ok( + IDojoInitSafeLibraryDispatcher { + class_hash, + } + ) + } + fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write(address_domain, base, value.class_hash)?; + starknet::SyscallResult::Ok(()) + } + fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { + let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; + starknet::SyscallResult::Ok( + IDojoInitSafeLibraryDispatcher { + class_hash, + } + ) + } + #[inline(always)] + fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; + starknet::SyscallResult::Ok(()) + } + #[inline(always)] + fn size() -> u8 { + starknet::Store::::size() + } +} + +#[derive(Drop, Copy)] +pub struct IDojoInitSafeLibraryDispatcherSubPointers { + pub class_hash: starknet::storage::StoragePointer, } -pub mod __l1_handler { +impl IDojoInitSafeLibraryDispatcherSubPointersImpl of starknet::storage::SubPointers { + type SubPointersType = IDojoInitSafeLibraryDispatcherSubPointers; + fn sub_pointers(self: starknet::storage::StoragePointer) -> IDojoInitSafeLibraryDispatcherSubPointers { + let base_address = self.__storage_pointer_address__; + let mut current_offset = self.__storage_pointer_offset__; + let class_hash_value = starknet::storage::StoragePointer { + __storage_pointer_address__: base_address, + __storage_pointer_offset__: current_offset, + }; + IDojoInitSafeLibraryDispatcherSubPointers { + class_hash: class_hash_value, + } + } } -pub mod __constructor { - pub use super::__wrapper__constructor as constructor; +#[derive(Drop, Copy)] +pub struct IDojoInitSafeLibraryDispatcherSubPointersMut { + pub class_hash: starknet::storage::StoragePointer>, } - impl ContractStateEventEmitter of starknet::event::EventEmitter< - ContractState, Event - > { - fn emit>( - ref self: ContractState, event: S - ) { - let event: Event = core::traits::Into::into(event); - let mut keys = Default::::default(); - let mut data = Default::::default(); - starknet::Event::append_keys_and_data(@event, ref keys, ref data); - starknet::SyscallResultTrait::unwrap_syscall( - starknet::syscalls::emit_event_syscall( - core::array::ArrayTrait::span(@keys), - core::array::ArrayTrait::span(@data), - ) - ) +impl IDojoInitSafeLibraryDispatcherSubPointersMutImpl of starknet::storage::SubPointersMut { + type SubPointersType = IDojoInitSafeLibraryDispatcherSubPointersMut; + fn sub_pointers_mut(self: starknet::storage::StoragePointer>) -> IDojoInitSafeLibraryDispatcherSubPointersMut { + let base_address = self.__storage_pointer_address__; + let mut current_offset = self.__storage_pointer_offset__; + let class_hash_value = starknet::storage::StoragePointer { + __storage_pointer_address__: base_address, + __storage_pointer_offset__: current_offset, + }; + IDojoInitSafeLibraryDispatcherSubPointersMut { + class_hash: class_hash_value, } } - -impl HasComponentImpl_world_provider_cpt of world_provider_cpt::HasComponent { - fn get_component(self: @ContractState) -> @world_provider_cpt::ComponentState { - @world_provider_cpt::unsafe_new_component_state::() - } - fn get_component_mut(ref self: ContractState) -> world_provider_cpt::ComponentState { - world_provider_cpt::unsafe_new_component_state::() +} +impl IDojoInitSafeDispatcherCopy of core::traits::Copy::; +impl IDojoInitSafeDispatcherDrop of core::traits::Drop::; +impl IDojoInitSafeDispatcherSerde of core::serde::Serde:: { + fn serialize(self: @IDojoInitSafeDispatcher, ref output: core::array::Array) { + core::serde::Serde::serialize(self.contract_address, ref output) } - fn get_contract(self: @world_provider_cpt::ComponentState) -> @ContractState { - @unsafe_new_contract_state() + fn deserialize(ref serialized: core::array::Span) -> core::option::Option { + core::option::Option::Some(IDojoInitSafeDispatcher { + contract_address: core::serde::Serde::deserialize(ref serialized)?, + }) } - fn get_contract_mut(ref self: world_provider_cpt::ComponentState) -> ContractState { - unsafe_new_contract_state() +} +impl StoreIDojoInitSafeDispatcher of starknet::Store:: { + fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { + let contract_address = starknet::Store::::read(address_domain, base)?; + starknet::SyscallResult::Ok( + IDojoInitSafeDispatcher { + contract_address, + } + ) } - fn emit>(ref self: world_provider_cpt::ComponentState, event: S) { - let event: world_provider_cpt::Event = core::traits::Into::into(event); - let mut contract = world_provider_cpt::HasComponent::get_contract_mut(ref self); - ContractStateEventEmitter::emit(ref contract, Event::WorldProviderEvent(event)); + fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitSafeDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write(address_domain, base, value.contract_address)?; + starknet::SyscallResult::Ok(()) } -} -impl HasComponentImpl_upgradeable_cpt of upgradeable_cpt::HasComponent { - fn get_component(self: @ContractState) -> @upgradeable_cpt::ComponentState { - @upgradeable_cpt::unsafe_new_component_state::() + fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { + let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; + starknet::SyscallResult::Ok( + IDojoInitSafeDispatcher { + contract_address, + } + ) } - fn get_component_mut(ref self: ContractState) -> upgradeable_cpt::ComponentState { - upgradeable_cpt::unsafe_new_component_state::() + #[inline(always)] + fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitSafeDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; + starknet::SyscallResult::Ok(()) } - fn get_contract(self: @upgradeable_cpt::ComponentState) -> @ContractState { - @unsafe_new_contract_state() + #[inline(always)] + fn size() -> u8 { + starknet::Store::::size() } - fn get_contract_mut(ref self: upgradeable_cpt::ComponentState) -> ContractState { - unsafe_new_contract_state() +} + +#[derive(Drop, Copy)] +pub struct IDojoInitSafeDispatcherSubPointers { + pub contract_address: starknet::storage::StoragePointer, +} +impl IDojoInitSafeDispatcherSubPointersImpl of starknet::storage::SubPointers { + type SubPointersType = IDojoInitSafeDispatcherSubPointers; + fn sub_pointers(self: starknet::storage::StoragePointer) -> IDojoInitSafeDispatcherSubPointers { + let base_address = self.__storage_pointer_address__; + let mut current_offset = self.__storage_pointer_offset__; + let contract_address_value = starknet::storage::StoragePointer { + __storage_pointer_address__: base_address, + __storage_pointer_offset__: current_offset, + }; + IDojoInitSafeDispatcherSubPointers { + contract_address: contract_address_value, + } } - fn emit>(ref self: upgradeable_cpt::ComponentState, event: S) { - let event: upgradeable_cpt::Event = core::traits::Into::into(event); - let mut contract = upgradeable_cpt::HasComponent::get_contract_mut(ref self); - ContractStateEventEmitter::emit(ref contract, Event::UpgradeableEvent(event)); +} +#[derive(Drop, Copy)] +pub struct IDojoInitSafeDispatcherSubPointersMut { + pub contract_address: starknet::storage::StoragePointer>, +} +impl IDojoInitSafeDispatcherSubPointersMutImpl of starknet::storage::SubPointersMut { + type SubPointersType = IDojoInitSafeDispatcherSubPointersMut; + fn sub_pointers_mut(self: starknet::storage::StoragePointer>) -> IDojoInitSafeDispatcherSubPointersMut { + let base_address = self.__storage_pointer_address__; + let mut current_offset = self.__storage_pointer_offset__; + let contract_address_value = starknet::storage::StoragePointer { + __storage_pointer_address__: base_address, + __storage_pointer_offset__: current_offset, + }; + IDojoInitSafeDispatcherSubPointersMut { + contract_address: contract_address_value, + } } } impl StorageStorageBaseDrop of core::traits::Drop::; impl StorageStorageBaseCopy of core::traits::Copy::; impl StorageStorageBaseMutDrop of core::traits::Drop::; impl StorageStorageBaseMutCopy of core::traits::Copy::; +impl IDojoInitDispatcherSubPointersDrop of core::traits::Drop::; +impl IDojoInitDispatcherSubPointersCopy of core::traits::Copy::; +impl IDojoInitDispatcherSubPointersMutDrop of core::traits::Drop::; +impl IDojoInitDispatcherSubPointersMutCopy of core::traits::Copy::; +impl IDojoInitLibraryDispatcherSubPointersDrop of core::traits::Drop::; +impl IDojoInitLibraryDispatcherSubPointersCopy of core::traits::Copy::; +impl IDojoInitLibraryDispatcherSubPointersMutDrop of core::traits::Drop::; +impl IDojoInitLibraryDispatcherSubPointersMutCopy of core::traits::Copy::; +impl IDojoInitSafeLibraryDispatcherSubPointersDrop of core::traits::Drop::; +impl IDojoInitSafeLibraryDispatcherSubPointersCopy of core::traits::Copy::; +impl IDojoInitSafeLibraryDispatcherSubPointersMutDrop of core::traits::Drop::; +impl IDojoInitSafeLibraryDispatcherSubPointersMutCopy of core::traits::Copy::; +impl IDojoInitSafeDispatcherSubPointersDrop of core::traits::Drop::; +impl IDojoInitSafeDispatcherSubPointersCopy of core::traits::Copy::; +impl IDojoInitSafeDispatcherSubPointersMutDrop of core::traits::Drop::; +impl IDojoInitSafeDispatcherSubPointersMutCopy of core::traits::Copy::; } #[starknet::contract] - pub mod ctxnamed { + pub mod withevent { use dojo::world; use dojo::world::IWorldDispatcher; use dojo::world::IWorldDispatcherTrait; @@ -1484,7 +3280,7 @@ impl StorageStorageBaseMutCopy of core::traits::Copy::; #[abi(embed_v0)] pub impl ContractImpl of IContract { fn name(self: @ContractState) -> ByteArray { - "ctxnamed" + "withevent" } fn namespace(self: @ContractState) -> ByteArray { @@ -1492,11 +3288,11 @@ impl StorageStorageBaseMutCopy of core::traits::Copy::; } fn tag(self: @ContractState) -> ByteArray { - "dojo_test-ctxnamed" + "dojo_test-withevent" } fn name_hash(self: @ContractState) -> felt252 { - 1120614286815912604239420768209466007446460277061516527925636408561239543041 + 2196275886623691942883456540767114081898043897719876113518403014973431884540 } fn namespace_hash(self: @ContractState) -> felt252 { @@ -1504,28 +3300,46 @@ impl StorageStorageBaseMutCopy of core::traits::Copy::; } fn selector(self: @ContractState) -> felt252 { - 1088922133313711214547564678240399488767278073212336739350382494993498982824 + 3549898308100844368972151697544420289462059777504886668025232769583717017648 } } - use traits::Into; - use dojo::world::Context; - - fn execute(ctx2: Context, name: felt252) { - return (); - } - - #[constructor] - fn constructor(ref self: ContractState) { - self.world_provider.initializer(); - } #[event] #[derive(Drop, starknet::Event)] enum Event { UpgradeableEvent: upgradeable_cpt::Event, WorldProviderEvent: world_provider_cpt::Event, + TestEvent: TestEvent } + + #[derive(Drop, starknet::Event)] + struct TestEvent { + address: ContractAddress, + } + + #[constructor] + fn constructor(ref self: ContractState) { + self.world_provider.initializer(); + } + +#[starknet::interface] +pub trait IDojoInit { + fn dojo_init(self: @ContractState); +} + +#[abi(embed_v0)] +pub impl IDojoInitImpl of IDojoInit { + fn dojo_init(self: @ContractState) { + if starknet::get_caller_address() != self.world_provider.world().contract_address { + core::panics::panic_with_byte_array( + @format!("Only the world can init contract `{}`, but caller is `{:?}`", + self.tag(), + starknet::get_caller_address(), + )); + } + } +} impl EventDrop of core::traits::Drop::; impl EventIsEvent of starknet::Event { fn append_keys_and_data( @@ -1544,6 +3358,12 @@ impl EventIsEvent of starknet::Event { val, ref keys, ref data ); }, + Event::TestEvent(val) => { + core::array::ArrayTrait::append(ref keys, selector!("TestEvent")); + starknet::Event::append_keys_and_data( + val, ref keys, ref data + ); + }, } } fn deserialize( @@ -1562,18 +3382,134 @@ impl EventIsEvent of starknet::Event { )?; return Option::Some(Event::WorldProviderEvent(val)); } + if __selector__ == selector!("TestEvent") { + let val = starknet::Event::deserialize( + ref keys, ref data + )?; + return Option::Some(Event::TestEvent(val)); + } Option::None } } -impl EventUpgradeableEventIntoEvent of Into { - fn into(self: upgradeable_cpt::Event) -> Event { - Event::UpgradeableEvent(self) +impl EventUpgradeableEventIntoEvent of Into { + fn into(self: upgradeable_cpt::Event) -> Event { + Event::UpgradeableEvent(self) + } +} +impl EventWorldProviderEventIntoEvent of Into { + fn into(self: world_provider_cpt::Event) -> Event { + Event::WorldProviderEvent(self) + } +} +impl EventTestEventIntoEvent of Into { + fn into(self: TestEvent) -> Event { + Event::TestEvent(self) + } +} +impl TestEventDrop of core::traits::Drop::; +impl TestEventIsEvent of starknet::Event { + fn append_keys_and_data( + self: @TestEvent, ref keys: Array, ref data: Array + ) { + core::serde::Serde::serialize(self.address, ref data); + } + fn deserialize( + ref keys: Span, ref data: Span, + ) -> Option { + let address = core::serde::Serde::deserialize( + ref data + )?; + Option::Some(TestEvent {address, }) + } +} +pub trait IDojoInitDispatcherTrait { + fn dojo_init(self: T); +} + +#[derive(Copy, Drop, starknet::Store, Serde)] +pub struct IDojoInitDispatcher { + pub contract_address: starknet::ContractAddress, +} + +impl IDojoInitDispatcherImpl of IDojoInitDispatcherTrait { + fn dojo_init(self: IDojoInitDispatcher) { + let mut __calldata__ = core::traits::Default::default(); + + let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( + self.contract_address, + selector!("dojo_init"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); + () + } + +} + +#[derive(Copy, Drop, starknet::Store, Serde)] +pub struct IDojoInitLibraryDispatcher { + pub class_hash: starknet::ClassHash, +} + +impl IDojoInitLibraryDispatcherImpl of IDojoInitDispatcherTrait { + fn dojo_init(self: IDojoInitLibraryDispatcher) { + let mut __calldata__ = core::traits::Default::default(); + + let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( + self.class_hash, + selector!("dojo_init"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); + () + } + +} + +pub trait IDojoInitSafeDispatcherTrait { + #[unstable(feature: "safe_dispatcher")] + fn dojo_init(self: T) -> starknet::SyscallResult<()>; +} + +#[derive(Copy, Drop, starknet::Store, Serde)] +pub struct IDojoInitSafeLibraryDispatcher { + pub class_hash: starknet::ClassHash, +} + +impl IDojoInitSafeLibraryDispatcherImpl of IDojoInitSafeDispatcherTrait { + fn dojo_init(self: IDojoInitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { + let mut __calldata__ = core::traits::Default::default(); + + let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( + self.class_hash, + selector!("dojo_init"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = __dispatcher_return_data__?; + Result::Ok(()) } + } -impl EventWorldProviderEventIntoEvent of Into { - fn into(self: world_provider_cpt::Event) -> Event { - Event::WorldProviderEvent(self) + + +#[derive(Copy, Drop, starknet::Store, Serde)] +pub struct IDojoInitSafeDispatcher { + pub contract_address: starknet::ContractAddress, +} + +impl IDojoInitSafeDispatcherImpl of IDojoInitSafeDispatcherTrait { + fn dojo_init(self: IDojoInitSafeDispatcher) -> starknet::SyscallResult<()> { + let mut __calldata__ = core::traits::Default::default(); + + let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( + self.contract_address, + selector!("dojo_init"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = __dispatcher_return_data__?; + Result::Ok(()) } + } @@ -1795,6 +3731,24 @@ fn __wrapper__constructor(mut data: Span::) -> Span:: { core::array::ArrayTrait::span(@arr) } +#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] +fn __wrapper__IDojoInitImpl__dojo_init(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + IDojoInitImpl::dojo_init(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::array::ArrayTrait::span(@arr) +} + pub mod __external { pub use super::__wrapper__ContractImpl__name as name; @@ -1803,6 +3757,7 @@ pub mod __external { pub use super::__wrapper__ContractImpl__name_hash as name_hash; pub use super::__wrapper__ContractImpl__namespace_hash as namespace_hash; pub use super::__wrapper__ContractImpl__selector as selector; + pub use super::__wrapper__IDojoInitImpl__dojo_init as dojo_init; } pub mod __l1_handler { } @@ -1827,54 +3782,390 @@ pub mod __constructor { ) } } - -impl HasComponentImpl_world_provider_cpt of world_provider_cpt::HasComponent { - fn get_component(self: @ContractState) -> @world_provider_cpt::ComponentState { - @world_provider_cpt::unsafe_new_component_state::() - } - fn get_component_mut(ref self: ContractState) -> world_provider_cpt::ComponentState { - world_provider_cpt::unsafe_new_component_state::() + +impl HasComponentImpl_world_provider_cpt of world_provider_cpt::HasComponent { + fn get_component(self: @ContractState) -> @world_provider_cpt::ComponentState { + @world_provider_cpt::unsafe_new_component_state::() + } + fn get_component_mut(ref self: ContractState) -> world_provider_cpt::ComponentState { + world_provider_cpt::unsafe_new_component_state::() + } + fn get_contract(self: @world_provider_cpt::ComponentState) -> @ContractState { + @unsafe_new_contract_state() + } + fn get_contract_mut(ref self: world_provider_cpt::ComponentState) -> ContractState { + unsafe_new_contract_state() + } + fn emit>(ref self: world_provider_cpt::ComponentState, event: S) { + let event: world_provider_cpt::Event = core::traits::Into::into(event); + let mut contract = world_provider_cpt::HasComponent::get_contract_mut(ref self); + ContractStateEventEmitter::emit(ref contract, Event::WorldProviderEvent(event)); + } +} +impl HasComponentImpl_upgradeable_cpt of upgradeable_cpt::HasComponent { + fn get_component(self: @ContractState) -> @upgradeable_cpt::ComponentState { + @upgradeable_cpt::unsafe_new_component_state::() + } + fn get_component_mut(ref self: ContractState) -> upgradeable_cpt::ComponentState { + upgradeable_cpt::unsafe_new_component_state::() + } + fn get_contract(self: @upgradeable_cpt::ComponentState) -> @ContractState { + @unsafe_new_contract_state() + } + fn get_contract_mut(ref self: upgradeable_cpt::ComponentState) -> ContractState { + unsafe_new_contract_state() + } + fn emit>(ref self: upgradeable_cpt::ComponentState, event: S) { + let event: upgradeable_cpt::Event = core::traits::Into::into(event); + let mut contract = upgradeable_cpt::HasComponent::get_contract_mut(ref self); + ContractStateEventEmitter::emit(ref contract, Event::UpgradeableEvent(event)); + } +} +impl IDojoInitDispatcherCopy of core::traits::Copy::; +impl IDojoInitDispatcherDrop of core::traits::Drop::; +impl IDojoInitDispatcherSerde of core::serde::Serde:: { + fn serialize(self: @IDojoInitDispatcher, ref output: core::array::Array) { + core::serde::Serde::serialize(self.contract_address, ref output) + } + fn deserialize(ref serialized: core::array::Span) -> core::option::Option { + core::option::Option::Some(IDojoInitDispatcher { + contract_address: core::serde::Serde::deserialize(ref serialized)?, + }) + } +} +impl StoreIDojoInitDispatcher of starknet::Store:: { + fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { + let contract_address = starknet::Store::::read(address_domain, base)?; + starknet::SyscallResult::Ok( + IDojoInitDispatcher { + contract_address, + } + ) + } + fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write(address_domain, base, value.contract_address)?; + starknet::SyscallResult::Ok(()) + } + fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { + let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; + starknet::SyscallResult::Ok( + IDojoInitDispatcher { + contract_address, + } + ) + } + #[inline(always)] + fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; + starknet::SyscallResult::Ok(()) + } + #[inline(always)] + fn size() -> u8 { + starknet::Store::::size() + } +} + +#[derive(Drop, Copy)] +pub struct IDojoInitDispatcherSubPointers { + pub contract_address: starknet::storage::StoragePointer, +} +impl IDojoInitDispatcherSubPointersImpl of starknet::storage::SubPointers { + type SubPointersType = IDojoInitDispatcherSubPointers; + fn sub_pointers(self: starknet::storage::StoragePointer) -> IDojoInitDispatcherSubPointers { + let base_address = self.__storage_pointer_address__; + let mut current_offset = self.__storage_pointer_offset__; + let contract_address_value = starknet::storage::StoragePointer { + __storage_pointer_address__: base_address, + __storage_pointer_offset__: current_offset, + }; + IDojoInitDispatcherSubPointers { + contract_address: contract_address_value, + } + } +} +#[derive(Drop, Copy)] +pub struct IDojoInitDispatcherSubPointersMut { + pub contract_address: starknet::storage::StoragePointer>, +} +impl IDojoInitDispatcherSubPointersMutImpl of starknet::storage::SubPointersMut { + type SubPointersType = IDojoInitDispatcherSubPointersMut; + fn sub_pointers_mut(self: starknet::storage::StoragePointer>) -> IDojoInitDispatcherSubPointersMut { + let base_address = self.__storage_pointer_address__; + let mut current_offset = self.__storage_pointer_offset__; + let contract_address_value = starknet::storage::StoragePointer { + __storage_pointer_address__: base_address, + __storage_pointer_offset__: current_offset, + }; + IDojoInitDispatcherSubPointersMut { + contract_address: contract_address_value, + } + } +} +impl IDojoInitLibraryDispatcherCopy of core::traits::Copy::; +impl IDojoInitLibraryDispatcherDrop of core::traits::Drop::; +impl IDojoInitLibraryDispatcherSerde of core::serde::Serde:: { + fn serialize(self: @IDojoInitLibraryDispatcher, ref output: core::array::Array) { + core::serde::Serde::serialize(self.class_hash, ref output) + } + fn deserialize(ref serialized: core::array::Span) -> core::option::Option { + core::option::Option::Some(IDojoInitLibraryDispatcher { + class_hash: core::serde::Serde::deserialize(ref serialized)?, + }) + } +} +impl StoreIDojoInitLibraryDispatcher of starknet::Store:: { + fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { + let class_hash = starknet::Store::::read(address_domain, base)?; + starknet::SyscallResult::Ok( + IDojoInitLibraryDispatcher { + class_hash, + } + ) + } + fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitLibraryDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write(address_domain, base, value.class_hash)?; + starknet::SyscallResult::Ok(()) + } + fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { + let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; + starknet::SyscallResult::Ok( + IDojoInitLibraryDispatcher { + class_hash, + } + ) + } + #[inline(always)] + fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitLibraryDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; + starknet::SyscallResult::Ok(()) + } + #[inline(always)] + fn size() -> u8 { + starknet::Store::::size() + } +} + +#[derive(Drop, Copy)] +pub struct IDojoInitLibraryDispatcherSubPointers { + pub class_hash: starknet::storage::StoragePointer, +} +impl IDojoInitLibraryDispatcherSubPointersImpl of starknet::storage::SubPointers { + type SubPointersType = IDojoInitLibraryDispatcherSubPointers; + fn sub_pointers(self: starknet::storage::StoragePointer) -> IDojoInitLibraryDispatcherSubPointers { + let base_address = self.__storage_pointer_address__; + let mut current_offset = self.__storage_pointer_offset__; + let class_hash_value = starknet::storage::StoragePointer { + __storage_pointer_address__: base_address, + __storage_pointer_offset__: current_offset, + }; + IDojoInitLibraryDispatcherSubPointers { + class_hash: class_hash_value, + } + } +} +#[derive(Drop, Copy)] +pub struct IDojoInitLibraryDispatcherSubPointersMut { + pub class_hash: starknet::storage::StoragePointer>, +} +impl IDojoInitLibraryDispatcherSubPointersMutImpl of starknet::storage::SubPointersMut { + type SubPointersType = IDojoInitLibraryDispatcherSubPointersMut; + fn sub_pointers_mut(self: starknet::storage::StoragePointer>) -> IDojoInitLibraryDispatcherSubPointersMut { + let base_address = self.__storage_pointer_address__; + let mut current_offset = self.__storage_pointer_offset__; + let class_hash_value = starknet::storage::StoragePointer { + __storage_pointer_address__: base_address, + __storage_pointer_offset__: current_offset, + }; + IDojoInitLibraryDispatcherSubPointersMut { + class_hash: class_hash_value, + } + } +} +impl IDojoInitSafeLibraryDispatcherCopy of core::traits::Copy::; +impl IDojoInitSafeLibraryDispatcherDrop of core::traits::Drop::; +impl IDojoInitSafeLibraryDispatcherSerde of core::serde::Serde:: { + fn serialize(self: @IDojoInitSafeLibraryDispatcher, ref output: core::array::Array) { + core::serde::Serde::serialize(self.class_hash, ref output) + } + fn deserialize(ref serialized: core::array::Span) -> core::option::Option { + core::option::Option::Some(IDojoInitSafeLibraryDispatcher { + class_hash: core::serde::Serde::deserialize(ref serialized)?, + }) + } +} +impl StoreIDojoInitSafeLibraryDispatcher of starknet::Store:: { + fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { + let class_hash = starknet::Store::::read(address_domain, base)?; + starknet::SyscallResult::Ok( + IDojoInitSafeLibraryDispatcher { + class_hash, + } + ) + } + fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write(address_domain, base, value.class_hash)?; + starknet::SyscallResult::Ok(()) + } + fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { + let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; + starknet::SyscallResult::Ok( + IDojoInitSafeLibraryDispatcher { + class_hash, + } + ) + } + #[inline(always)] + fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; + starknet::SyscallResult::Ok(()) + } + #[inline(always)] + fn size() -> u8 { + starknet::Store::::size() + } +} + +#[derive(Drop, Copy)] +pub struct IDojoInitSafeLibraryDispatcherSubPointers { + pub class_hash: starknet::storage::StoragePointer, +} +impl IDojoInitSafeLibraryDispatcherSubPointersImpl of starknet::storage::SubPointers { + type SubPointersType = IDojoInitSafeLibraryDispatcherSubPointers; + fn sub_pointers(self: starknet::storage::StoragePointer) -> IDojoInitSafeLibraryDispatcherSubPointers { + let base_address = self.__storage_pointer_address__; + let mut current_offset = self.__storage_pointer_offset__; + let class_hash_value = starknet::storage::StoragePointer { + __storage_pointer_address__: base_address, + __storage_pointer_offset__: current_offset, + }; + IDojoInitSafeLibraryDispatcherSubPointers { + class_hash: class_hash_value, + } + } +} +#[derive(Drop, Copy)] +pub struct IDojoInitSafeLibraryDispatcherSubPointersMut { + pub class_hash: starknet::storage::StoragePointer>, +} +impl IDojoInitSafeLibraryDispatcherSubPointersMutImpl of starknet::storage::SubPointersMut { + type SubPointersType = IDojoInitSafeLibraryDispatcherSubPointersMut; + fn sub_pointers_mut(self: starknet::storage::StoragePointer>) -> IDojoInitSafeLibraryDispatcherSubPointersMut { + let base_address = self.__storage_pointer_address__; + let mut current_offset = self.__storage_pointer_offset__; + let class_hash_value = starknet::storage::StoragePointer { + __storage_pointer_address__: base_address, + __storage_pointer_offset__: current_offset, + }; + IDojoInitSafeLibraryDispatcherSubPointersMut { + class_hash: class_hash_value, + } + } +} +impl IDojoInitSafeDispatcherCopy of core::traits::Copy::; +impl IDojoInitSafeDispatcherDrop of core::traits::Drop::; +impl IDojoInitSafeDispatcherSerde of core::serde::Serde:: { + fn serialize(self: @IDojoInitSafeDispatcher, ref output: core::array::Array) { + core::serde::Serde::serialize(self.contract_address, ref output) } - fn get_contract(self: @world_provider_cpt::ComponentState) -> @ContractState { - @unsafe_new_contract_state() + fn deserialize(ref serialized: core::array::Span) -> core::option::Option { + core::option::Option::Some(IDojoInitSafeDispatcher { + contract_address: core::serde::Serde::deserialize(ref serialized)?, + }) } - fn get_contract_mut(ref self: world_provider_cpt::ComponentState) -> ContractState { - unsafe_new_contract_state() +} +impl StoreIDojoInitSafeDispatcher of starknet::Store:: { + fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { + let contract_address = starknet::Store::::read(address_domain, base)?; + starknet::SyscallResult::Ok( + IDojoInitSafeDispatcher { + contract_address, + } + ) } - fn emit>(ref self: world_provider_cpt::ComponentState, event: S) { - let event: world_provider_cpt::Event = core::traits::Into::into(event); - let mut contract = world_provider_cpt::HasComponent::get_contract_mut(ref self); - ContractStateEventEmitter::emit(ref contract, Event::WorldProviderEvent(event)); + fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitSafeDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write(address_domain, base, value.contract_address)?; + starknet::SyscallResult::Ok(()) } -} -impl HasComponentImpl_upgradeable_cpt of upgradeable_cpt::HasComponent { - fn get_component(self: @ContractState) -> @upgradeable_cpt::ComponentState { - @upgradeable_cpt::unsafe_new_component_state::() + fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { + let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; + starknet::SyscallResult::Ok( + IDojoInitSafeDispatcher { + contract_address, + } + ) } - fn get_component_mut(ref self: ContractState) -> upgradeable_cpt::ComponentState { - upgradeable_cpt::unsafe_new_component_state::() + #[inline(always)] + fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitSafeDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; + starknet::SyscallResult::Ok(()) } - fn get_contract(self: @upgradeable_cpt::ComponentState) -> @ContractState { - @unsafe_new_contract_state() + #[inline(always)] + fn size() -> u8 { + starknet::Store::::size() } - fn get_contract_mut(ref self: upgradeable_cpt::ComponentState) -> ContractState { - unsafe_new_contract_state() +} + +#[derive(Drop, Copy)] +pub struct IDojoInitSafeDispatcherSubPointers { + pub contract_address: starknet::storage::StoragePointer, +} +impl IDojoInitSafeDispatcherSubPointersImpl of starknet::storage::SubPointers { + type SubPointersType = IDojoInitSafeDispatcherSubPointers; + fn sub_pointers(self: starknet::storage::StoragePointer) -> IDojoInitSafeDispatcherSubPointers { + let base_address = self.__storage_pointer_address__; + let mut current_offset = self.__storage_pointer_offset__; + let contract_address_value = starknet::storage::StoragePointer { + __storage_pointer_address__: base_address, + __storage_pointer_offset__: current_offset, + }; + IDojoInitSafeDispatcherSubPointers { + contract_address: contract_address_value, + } } - fn emit>(ref self: upgradeable_cpt::ComponentState, event: S) { - let event: upgradeable_cpt::Event = core::traits::Into::into(event); - let mut contract = upgradeable_cpt::HasComponent::get_contract_mut(ref self); - ContractStateEventEmitter::emit(ref contract, Event::UpgradeableEvent(event)); +} +#[derive(Drop, Copy)] +pub struct IDojoInitSafeDispatcherSubPointersMut { + pub contract_address: starknet::storage::StoragePointer>, +} +impl IDojoInitSafeDispatcherSubPointersMutImpl of starknet::storage::SubPointersMut { + type SubPointersType = IDojoInitSafeDispatcherSubPointersMut; + fn sub_pointers_mut(self: starknet::storage::StoragePointer>) -> IDojoInitSafeDispatcherSubPointersMut { + let base_address = self.__storage_pointer_address__; + let mut current_offset = self.__storage_pointer_offset__; + let contract_address_value = starknet::storage::StoragePointer { + __storage_pointer_address__: base_address, + __storage_pointer_offset__: current_offset, + }; + IDojoInitSafeDispatcherSubPointersMut { + contract_address: contract_address_value, + } } } impl StorageStorageBaseDrop of core::traits::Drop::; impl StorageStorageBaseCopy of core::traits::Copy::; impl StorageStorageBaseMutDrop of core::traits::Drop::; impl StorageStorageBaseMutCopy of core::traits::Copy::; +impl IDojoInitDispatcherSubPointersDrop of core::traits::Drop::; +impl IDojoInitDispatcherSubPointersCopy of core::traits::Copy::; +impl IDojoInitDispatcherSubPointersMutDrop of core::traits::Drop::; +impl IDojoInitDispatcherSubPointersMutCopy of core::traits::Copy::; +impl IDojoInitLibraryDispatcherSubPointersDrop of core::traits::Drop::; +impl IDojoInitLibraryDispatcherSubPointersCopy of core::traits::Copy::; +impl IDojoInitLibraryDispatcherSubPointersMutDrop of core::traits::Drop::; +impl IDojoInitLibraryDispatcherSubPointersMutCopy of core::traits::Copy::; +impl IDojoInitSafeLibraryDispatcherSubPointersDrop of core::traits::Drop::; +impl IDojoInitSafeLibraryDispatcherSubPointersCopy of core::traits::Copy::; +impl IDojoInitSafeLibraryDispatcherSubPointersMutDrop of core::traits::Drop::; +impl IDojoInitSafeLibraryDispatcherSubPointersMutCopy of core::traits::Copy::; +impl IDojoInitSafeDispatcherSubPointersDrop of core::traits::Drop::; +impl IDojoInitSafeDispatcherSubPointersCopy of core::traits::Copy::; +impl IDojoInitSafeDispatcherSubPointersMutDrop of core::traits::Drop::; +impl IDojoInitSafeDispatcherSubPointersMutCopy of core::traits::Copy::; } #[starknet::contract] - pub mod withevent { + pub mod withcomponent { use dojo::world; use dojo::world::IWorldDispatcher; use dojo::world::IWorldDispatcherTrait; @@ -1894,7 +4185,7 @@ impl StorageStorageBaseMutCopy of core::traits::Copy::; #[abi(embed_v0)] pub impl ContractImpl of IContract { fn name(self: @ContractState) -> ByteArray { - "withevent" + "withcomponent" } fn namespace(self: @ContractState) -> ByteArray { @@ -1902,11 +4193,11 @@ impl StorageStorageBaseMutCopy of core::traits::Copy::; } fn tag(self: @ContractState) -> ByteArray { - "dojo_test-withevent" + "dojo_test-withcomponent" } fn name_hash(self: @ContractState) -> felt252 { - 2196275886623691942883456540767114081898043897719876113518403014973431884540 + 999850881662666048155666650426666132968026605763740651763663703103974774091 } fn namespace_hash(self: @ContractState) -> felt252 { @@ -1914,108 +4205,40 @@ impl StorageStorageBaseMutCopy of core::traits::Copy::; } fn selector(self: @ContractState) -> felt252 { - 3549898308100844368972151697544420289462059777504886668025232769583717017648 + 3051237314154062498758064027519150695325862034415997374893619833554034627226 } } - - + #[event] #[derive(Drop, starknet::Event)] enum Event { UpgradeableEvent: upgradeable_cpt::Event, WorldProviderEvent: world_provider_cpt::Event, - TestEvent: TestEvent + #[flat] + testcomponent1_event: testcomponent1::Event, + testcomponent2_event: testcomponent2::Event } - #[derive(Drop, starknet::Event)] - struct TestEvent { - address: ContractAddress, - } - #[constructor] - fn constructor(ref self: ContractState) { - self.world_provider.initializer(); - } -impl EventDrop of core::traits::Drop::; -impl EventIsEvent of starknet::Event { - fn append_keys_and_data( - self: @Event, ref keys: Array, ref data: Array - ) { - match self { - Event::UpgradeableEvent(val) => { - core::array::ArrayTrait::append(ref keys, selector!("UpgradeableEvent")); - starknet::Event::append_keys_and_data( - val, ref keys, ref data - ); - }, - Event::WorldProviderEvent(val) => { - core::array::ArrayTrait::append(ref keys, selector!("WorldProviderEvent")); - starknet::Event::append_keys_and_data( - val, ref keys, ref data - ); - }, - Event::TestEvent(val) => { - core::array::ArrayTrait::append(ref keys, selector!("TestEvent")); - starknet::Event::append_keys_and_data( - val, ref keys, ref data - ); - }, - } - } - fn deserialize( - ref keys: Span, ref data: Span, - ) -> Option { - let __selector__ = *core::array::SpanTrait::pop_front(ref keys)?; - if __selector__ == selector!("UpgradeableEvent") { - let val = starknet::Event::deserialize( - ref keys, ref data - )?; - return Option::Some(Event::UpgradeableEvent(val)); - } - if __selector__ == selector!("WorldProviderEvent") { - let val = starknet::Event::deserialize( - ref keys, ref data - )?; - return Option::Some(Event::WorldProviderEvent(val)); - } - if __selector__ == selector!("TestEvent") { - let val = starknet::Event::deserialize( - ref keys, ref data - )?; - return Option::Some(Event::TestEvent(val)); + fn constructor(ref self: ContractState) { + self.world_provider.initializer(); + } + +#[starknet::interface] +pub trait IDojoInit { + fn dojo_init(self: @ContractState); +} + +#[abi(embed_v0)] +pub impl IDojoInitImpl of IDojoInit { + fn dojo_init(self: @ContractState) { + if starknet::get_caller_address() != self.world_provider.world().contract_address { + core::panics::panic_with_byte_array( + @format!("Only the world can init contract `{}`, but caller is `{:?}`", + self.tag(), + starknet::get_caller_address(), + )); } - Option::None - } -} -impl EventUpgradeableEventIntoEvent of Into { - fn into(self: upgradeable_cpt::Event) -> Event { - Event::UpgradeableEvent(self) - } -} -impl EventWorldProviderEventIntoEvent of Into { - fn into(self: world_provider_cpt::Event) -> Event { - Event::WorldProviderEvent(self) - } -} -impl EventTestEventIntoEvent of Into { - fn into(self: TestEvent) -> Event { - Event::TestEvent(self) - } -} -impl TestEventDrop of core::traits::Drop::; -impl TestEventIsEvent of starknet::Event { - fn append_keys_and_data( - self: @TestEvent, ref keys: Array, ref data: Array - ) { - core::serde::Serde::serialize(self.address, ref data); - } - fn deserialize( - ref keys: Span, ref data: Span, - ) -> Option { - let address = core::serde::Serde::deserialize( - ref data - )?; - Option::Some(TestEvent {address, }) } } @@ -2026,21 +4249,31 @@ pub struct Storage { pub upgradeable: upgradeable_cpt::Storage, #[substorage(v0)] pub world_provider: world_provider_cpt::Storage, + #[substorage(v0)] + pub testcomponent1_storage: testcomponent1::Storage, + #[substorage(v0)] + pub testcomponent2_storage: testcomponent2::Storage, } #[derive(Drop, Copy)] pub struct StorageStorageBase { pub upgradeable: starknet::storage::FlattenedStorage, pub world_provider: starknet::storage::FlattenedStorage, + pub testcomponent1_storage: starknet::storage::FlattenedStorage, + pub testcomponent2_storage: starknet::storage::FlattenedStorage, } impl StorageStorageImpl of starknet::storage::StorageTrait { type BaseType = StorageStorageBase; fn storage(self: starknet::storage::FlattenedStorage) -> StorageStorageBase { let upgradeable_value = starknet::storage::FlattenedStorage {}; let world_provider_value = starknet::storage::FlattenedStorage {}; + let testcomponent1_storage_value = starknet::storage::FlattenedStorage {}; + let testcomponent2_storage_value = starknet::storage::FlattenedStorage {}; StorageStorageBase { upgradeable: upgradeable_value, world_provider: world_provider_value, + testcomponent1_storage: testcomponent1_storage_value, + testcomponent2_storage: testcomponent2_storage_value, } } } @@ -2048,15 +4281,21 @@ impl StorageStorageImpl of starknet::storage::StorageTrait { pub struct StorageStorageBaseMut { pub upgradeable: starknet::storage::FlattenedStorage>, pub world_provider: starknet::storage::FlattenedStorage>, + pub testcomponent1_storage: starknet::storage::FlattenedStorage>, + pub testcomponent2_storage: starknet::storage::FlattenedStorage>, } impl StorageStorageMutImpl of starknet::storage::StorageTraitMut { type BaseType = StorageStorageBaseMut; fn storage_mut(self: starknet::storage::FlattenedStorage>) -> StorageStorageBaseMut { let upgradeable_value = starknet::storage::FlattenedStorage {}; let world_provider_value = starknet::storage::FlattenedStorage {}; + let testcomponent1_storage_value = starknet::storage::FlattenedStorage {}; + let testcomponent2_storage_value = starknet::storage::FlattenedStorage {}; StorageStorageBaseMut { upgradeable: upgradeable_value, world_provider: world_provider_value, + testcomponent1_storage: testcomponent1_storage_value, + testcomponent2_storage: testcomponent2_storage_value, } } } @@ -2064,6 +4303,8 @@ impl StorageStorageMutImpl of starknet::storage::StorageTraitMut { pub struct ContractState { pub upgradeable: upgradeable_cpt::ComponentState, pub world_provider: world_provider_cpt::ComponentState, + pub testcomponent1_storage: testcomponent1::ComponentState, + pub testcomponent2_storage: testcomponent2::ComponentState, } impl ContractStateDrop of Drop {} @@ -2084,6 +4325,8 @@ pub fn unsafe_new_contract_state() -> ContractState { ContractState { upgradeable: upgradeable_cpt::unsafe_new_component_state::(), world_provider: world_provider_cpt::unsafe_new_component_state::(), + testcomponent1_storage: testcomponent1::unsafe_new_component_state::(), + testcomponent2_storage: testcomponent2::unsafe_new_component_state::(), } } @@ -2238,6 +4481,24 @@ fn __wrapper__constructor(mut data: Span::) -> Span:: { core::array::ArrayTrait::span(@arr) } +#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] +fn __wrapper__IDojoInitImpl__dojo_init(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + IDojoInitImpl::dojo_init(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::array::ArrayTrait::span(@arr) +} + pub mod __external { pub use super::__wrapper__ContractImpl__name as name; @@ -2246,6 +4507,7 @@ pub mod __external { pub use super::__wrapper__ContractImpl__name_hash as name_hash; pub use super::__wrapper__ContractImpl__namespace_hash as namespace_hash; pub use super::__wrapper__ContractImpl__selector as selector; + pub use super::__wrapper__IDojoInitImpl__dojo_init as dojo_init; } pub mod __l1_handler { } @@ -2290,531 +4552,579 @@ impl HasComponentImpl_world_provider_cpt of world_provider_cpt::HasComponent { - fn get_component(self: @ContractState) -> @upgradeable_cpt::ComponentState { - @upgradeable_cpt::unsafe_new_component_state::() +impl HasComponentImpl_upgradeable_cpt of upgradeable_cpt::HasComponent { + fn get_component(self: @ContractState) -> @upgradeable_cpt::ComponentState { + @upgradeable_cpt::unsafe_new_component_state::() + } + fn get_component_mut(ref self: ContractState) -> upgradeable_cpt::ComponentState { + upgradeable_cpt::unsafe_new_component_state::() + } + fn get_contract(self: @upgradeable_cpt::ComponentState) -> @ContractState { + @unsafe_new_contract_state() + } + fn get_contract_mut(ref self: upgradeable_cpt::ComponentState) -> ContractState { + unsafe_new_contract_state() + } + fn emit>(ref self: upgradeable_cpt::ComponentState, event: S) { + let event: upgradeable_cpt::Event = core::traits::Into::into(event); + let mut contract = upgradeable_cpt::HasComponent::get_contract_mut(ref self); + ContractStateEventEmitter::emit(ref contract, Event::UpgradeableEvent(event)); + } +} +impl HasComponentImpl_testcomponent1 of testcomponent1::HasComponent { + fn get_component(self: @ContractState) -> @testcomponent1::ComponentState { + @testcomponent1::unsafe_new_component_state::() + } + fn get_component_mut(ref self: ContractState) -> testcomponent1::ComponentState { + testcomponent1::unsafe_new_component_state::() + } + fn get_contract(self: @testcomponent1::ComponentState) -> @ContractState { + @unsafe_new_contract_state() + } + fn get_contract_mut(ref self: testcomponent1::ComponentState) -> ContractState { + unsafe_new_contract_state() + } + fn emit>(ref self: testcomponent1::ComponentState, event: S) { + let event: testcomponent1::Event = core::traits::Into::into(event); + let mut contract = testcomponent1::HasComponent::get_contract_mut(ref self); + ContractStateEventEmitter::emit(ref contract, Event::testcomponent1_event(event)); + } +} +impl HasComponentImpl_testcomponent2 of testcomponent2::HasComponent { + fn get_component(self: @ContractState) -> @testcomponent2::ComponentState { + @testcomponent2::unsafe_new_component_state::() } - fn get_component_mut(ref self: ContractState) -> upgradeable_cpt::ComponentState { - upgradeable_cpt::unsafe_new_component_state::() + fn get_component_mut(ref self: ContractState) -> testcomponent2::ComponentState { + testcomponent2::unsafe_new_component_state::() } - fn get_contract(self: @upgradeable_cpt::ComponentState) -> @ContractState { + fn get_contract(self: @testcomponent2::ComponentState) -> @ContractState { @unsafe_new_contract_state() } - fn get_contract_mut(ref self: upgradeable_cpt::ComponentState) -> ContractState { + fn get_contract_mut(ref self: testcomponent2::ComponentState) -> ContractState { unsafe_new_contract_state() } - fn emit>(ref self: upgradeable_cpt::ComponentState, event: S) { - let event: upgradeable_cpt::Event = core::traits::Into::into(event); - let mut contract = upgradeable_cpt::HasComponent::get_contract_mut(ref self); - ContractStateEventEmitter::emit(ref contract, Event::UpgradeableEvent(event)); + fn emit>(ref self: testcomponent2::ComponentState, event: S) { + let event: testcomponent2::Event = core::traits::Into::into(event); + let mut contract = testcomponent2::HasComponent::get_contract_mut(ref self); + ContractStateEventEmitter::emit(ref contract, Event::testcomponent2_event(event)); } } -impl StorageStorageBaseDrop of core::traits::Drop::; -impl StorageStorageBaseCopy of core::traits::Copy::; -impl StorageStorageBaseMutDrop of core::traits::Drop::; -impl StorageStorageBaseMutCopy of core::traits::Copy::; - - } - - #[starknet::contract] - pub mod withcomponent { - use dojo::world; - use dojo::world::IWorldDispatcher; - use dojo::world::IWorldDispatcherTrait; - use dojo::contract::components::world_provider::{world_provider_cpt, world_provider_cpt::InternalTrait as WorldProviderInternal, IWorldProvider}; - use dojo::contract::components::upgradeable::upgradeable_cpt; - use dojo::contract::IContract; - use starknet::storage::{ - StorageMapReadAccess, StorageMapWriteAccess, StoragePointerReadAccess, StoragePointerWriteAccess - }; - - #[abi(embed_v0)] - impl WorldProviderImpl = world_provider_cpt::WorldProviderImpl; - - #[abi(embed_v0)] - impl UpgradeableImpl = upgradeable_cpt::UpgradeableImpl; - - #[abi(embed_v0)] - pub impl ContractImpl of IContract { - fn name(self: @ContractState) -> ByteArray { - "withcomponent" - } - - fn namespace(self: @ContractState) -> ByteArray { - "dojo_test" - } - - fn tag(self: @ContractState) -> ByteArray { - "dojo_test-withcomponent" - } - - fn name_hash(self: @ContractState) -> felt252 { - 999850881662666048155666650426666132968026605763740651763663703103974774091 - } - - fn namespace_hash(self: @ContractState) -> felt252 { - 1452123528942907587532668415362544424816022573043154497385993678618948064048 - } - - fn selector(self: @ContractState) -> felt252 { - 3051237314154062498758064027519150695325862034415997374893619833554034627226 - } - } - - #[event] - #[derive(Drop, starknet::Event)] - enum Event { - UpgradeableEvent: upgradeable_cpt::Event, - WorldProviderEvent: world_provider_cpt::Event, - #[flat] - testcomponent1_event: testcomponent1::Event, - testcomponent2_event: testcomponent2::Event - } - - #[constructor] - fn constructor(ref self: ContractState) { - self.world_provider.initializer(); - } - - -#[phantom] -pub struct Storage { - #[substorage(v0)] - pub upgradeable: upgradeable_cpt::Storage, - #[substorage(v0)] - pub world_provider: world_provider_cpt::Storage, - #[substorage(v0)] - pub testcomponent1_storage: testcomponent1::Storage, - #[substorage(v0)] - pub testcomponent2_storage: testcomponent2::Storage, -} - -#[derive(Drop, Copy)] -pub struct StorageStorageBase { - pub upgradeable: starknet::storage::FlattenedStorage, - pub world_provider: starknet::storage::FlattenedStorage, - pub testcomponent1_storage: starknet::storage::FlattenedStorage, - pub testcomponent2_storage: starknet::storage::FlattenedStorage, -} -impl StorageStorageImpl of starknet::storage::StorageTrait { - type BaseType = StorageStorageBase; - fn storage(self: starknet::storage::FlattenedStorage) -> StorageStorageBase { - let upgradeable_value = starknet::storage::FlattenedStorage {}; - let world_provider_value = starknet::storage::FlattenedStorage {}; - let testcomponent1_storage_value = starknet::storage::FlattenedStorage {}; - let testcomponent2_storage_value = starknet::storage::FlattenedStorage {}; - StorageStorageBase { - upgradeable: upgradeable_value, - world_provider: world_provider_value, - testcomponent1_storage: testcomponent1_storage_value, - testcomponent2_storage: testcomponent2_storage_value, +impl EventDrop of core::traits::Drop::; +impl EventIsEvent of starknet::Event { + fn append_keys_and_data( + self: @Event, ref keys: Array, ref data: Array + ) { + match self { + Event::UpgradeableEvent(val) => { + core::array::ArrayTrait::append(ref keys, selector!("UpgradeableEvent")); + starknet::Event::append_keys_and_data( + val, ref keys, ref data + ); + }, + Event::WorldProviderEvent(val) => { + core::array::ArrayTrait::append(ref keys, selector!("WorldProviderEvent")); + starknet::Event::append_keys_and_data( + val, ref keys, ref data + ); + }, + Event::testcomponent1_event(val) => { + starknet::Event::append_keys_and_data( + val, ref keys, ref data + ); + }, + Event::testcomponent2_event(val) => { + core::array::ArrayTrait::append(ref keys, selector!("testcomponent2_event")); + starknet::Event::append_keys_and_data( + val, ref keys, ref data + ); + }, } } -} -#[derive(Drop, Copy)] -pub struct StorageStorageBaseMut { - pub upgradeable: starknet::storage::FlattenedStorage>, - pub world_provider: starknet::storage::FlattenedStorage>, - pub testcomponent1_storage: starknet::storage::FlattenedStorage>, - pub testcomponent2_storage: starknet::storage::FlattenedStorage>, -} -impl StorageStorageMutImpl of starknet::storage::StorageTraitMut { - type BaseType = StorageStorageBaseMut; - fn storage_mut(self: starknet::storage::FlattenedStorage>) -> StorageStorageBaseMut { - let upgradeable_value = starknet::storage::FlattenedStorage {}; - let world_provider_value = starknet::storage::FlattenedStorage {}; - let testcomponent1_storage_value = starknet::storage::FlattenedStorage {}; - let testcomponent2_storage_value = starknet::storage::FlattenedStorage {}; - StorageStorageBaseMut { - upgradeable: upgradeable_value, - world_provider: world_provider_value, - testcomponent1_storage: testcomponent1_storage_value, - testcomponent2_storage: testcomponent2_storage_value, + fn deserialize( + ref keys: Span, ref data: Span, + ) -> Option { + { + let mut keys = keys; + let mut data = data; + match starknet::Event::deserialize(ref keys, ref data) { + Option::Some(val) => { + return Option::Some(Event::testcomponent1_event(val)); + }, + Option::None => {}, + }; } + let __selector__ = *core::array::SpanTrait::pop_front(ref keys)?; + if __selector__ == selector!("UpgradeableEvent") { + let val = starknet::Event::deserialize( + ref keys, ref data + )?; + return Option::Some(Event::UpgradeableEvent(val)); + } + if __selector__ == selector!("WorldProviderEvent") { + let val = starknet::Event::deserialize( + ref keys, ref data + )?; + return Option::Some(Event::WorldProviderEvent(val)); + } + if __selector__ == selector!("testcomponent2_event") { + let val = starknet::Event::deserialize( + ref keys, ref data + )?; + return Option::Some(Event::testcomponent2_event(val)); + } + Option::None } } - -pub struct ContractState { - pub upgradeable: upgradeable_cpt::ComponentState, - pub world_provider: world_provider_cpt::ComponentState, - pub testcomponent1_storage: testcomponent1::ComponentState, - pub testcomponent2_storage: testcomponent2::ComponentState, -} - -impl ContractStateDrop of Drop {} - -impl ContractStateDeref of core::ops::SnapshotDeref { - type Target = starknet::storage::FlattenedStorage; - fn snapshot_deref(self: @ContractState) -> starknet::storage::FlattenedStorage { - starknet::storage::FlattenedStorage {} - } -} -impl ContractStateDerefMut of core::ops::DerefMut { - type Target = starknet::storage::FlattenedStorage> ; - fn deref_mut(ref self: ContractState) -> starknet::storage::FlattenedStorage> { - starknet::storage::FlattenedStorage {} +impl EventUpgradeableEventIntoEvent of Into { + fn into(self: upgradeable_cpt::Event) -> Event { + Event::UpgradeableEvent(self) } } -pub fn unsafe_new_contract_state() -> ContractState { - ContractState { - upgradeable: upgradeable_cpt::unsafe_new_component_state::(), - world_provider: world_provider_cpt::unsafe_new_component_state::(), - testcomponent1_storage: testcomponent1::unsafe_new_component_state::(), - testcomponent2_storage: testcomponent2::unsafe_new_component_state::(), +impl EventWorldProviderEventIntoEvent of Into { + fn into(self: world_provider_cpt::Event) -> Event { + Event::WorldProviderEvent(self) } } - -// TODO(Gil): This generates duplicate diagnostics because of the plugin system, squash the duplicates into one. -#[deprecated( - feature: "deprecated_legacy_map", - note: "Use `starknet::storage::Map` instead." -)] -use starknet::storage::Map as LegacyMap; - -impl ContractStateWorldProviderImpl of - world_provider_cpt::UnsafeNewContractStateTraitForWorldProviderImpl { - fn unsafe_new_contract_state() -> ContractState { - unsafe_new_contract_state() +impl Eventtestcomponent1_eventIntoEvent of Into { + fn into(self: testcomponent1::Event) -> Event { + Event::testcomponent1_event(self) } } -impl ContractStateUpgradeableImpl of - upgradeable_cpt::UnsafeNewContractStateTraitForUpgradeableImpl { - fn unsafe_new_contract_state() -> ContractState { - unsafe_new_contract_state() +impl Eventtestcomponent2_eventIntoEvent of Into { + fn into(self: testcomponent2::Event) -> Event { + Event::testcomponent2_event(self) } } -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__ContractImpl__name(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::name(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) +pub trait IDojoInitDispatcherTrait { + fn dojo_init(self: T); } -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__ContractImpl__namespace(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::namespace(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) +#[derive(Copy, Drop, starknet::Store, Serde)] +pub struct IDojoInitDispatcher { + pub contract_address: starknet::ContractAddress, } -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__ContractImpl__tag(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::tag(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) +impl IDojoInitDispatcherImpl of IDojoInitDispatcherTrait { + fn dojo_init(self: IDojoInitDispatcher) { + let mut __calldata__ = core::traits::Default::default(); + + let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( + self.contract_address, + selector!("dojo_init"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); + () + } + } -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__ContractImpl__name_hash(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::name_hash(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) +#[derive(Copy, Drop, starknet::Store, Serde)] +pub struct IDojoInitLibraryDispatcher { + pub class_hash: starknet::ClassHash, } -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__ContractImpl__namespace_hash(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::namespace_hash(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) +impl IDojoInitLibraryDispatcherImpl of IDojoInitDispatcherTrait { + fn dojo_init(self: IDojoInitLibraryDispatcher) { + let mut __calldata__ = core::traits::Default::default(); + + let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( + self.class_hash, + selector!("dojo_init"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); + () + } + } -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__ContractImpl__selector(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::selector(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) +pub trait IDojoInitSafeDispatcherTrait { + #[unstable(feature: "safe_dispatcher")] + fn dojo_init(self: T) -> starknet::SyscallResult<()>; } -#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] -fn __wrapper__constructor(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - constructor(ref contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::array::ArrayTrait::span(@arr) +#[derive(Copy, Drop, starknet::Store, Serde)] +pub struct IDojoInitSafeLibraryDispatcher { + pub class_hash: starknet::ClassHash, } +impl IDojoInitSafeLibraryDispatcherImpl of IDojoInitSafeDispatcherTrait { + fn dojo_init(self: IDojoInitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { + let mut __calldata__ = core::traits::Default::default(); + + let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( + self.class_hash, + selector!("dojo_init"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = __dispatcher_return_data__?; + Result::Ok(()) + } -pub mod __external { - pub use super::__wrapper__ContractImpl__name as name; - pub use super::__wrapper__ContractImpl__namespace as namespace; - pub use super::__wrapper__ContractImpl__tag as tag; - pub use super::__wrapper__ContractImpl__name_hash as name_hash; - pub use super::__wrapper__ContractImpl__namespace_hash as namespace_hash; - pub use super::__wrapper__ContractImpl__selector as selector; -} -pub mod __l1_handler { } -pub mod __constructor { - pub use super::__wrapper__constructor as constructor; + + +#[derive(Copy, Drop, starknet::Store, Serde)] +pub struct IDojoInitSafeDispatcher { + pub contract_address: starknet::ContractAddress, } - impl ContractStateEventEmitter of starknet::event::EventEmitter< - ContractState, Event - > { - fn emit>( - ref self: ContractState, event: S - ) { - let event: Event = core::traits::Into::into(event); - let mut keys = Default::::default(); - let mut data = Default::::default(); - starknet::Event::append_keys_and_data(@event, ref keys, ref data); - starknet::SyscallResultTrait::unwrap_syscall( - starknet::syscalls::emit_event_syscall( - core::array::ArrayTrait::span(@keys), - core::array::ArrayTrait::span(@data), - ) - ) - } + +impl IDojoInitSafeDispatcherImpl of IDojoInitSafeDispatcherTrait { + fn dojo_init(self: IDojoInitSafeDispatcher) -> starknet::SyscallResult<()> { + let mut __calldata__ = core::traits::Default::default(); + + let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( + self.contract_address, + selector!("dojo_init"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = __dispatcher_return_data__?; + Result::Ok(()) } -impl HasComponentImpl_world_provider_cpt of world_provider_cpt::HasComponent { - fn get_component(self: @ContractState) -> @world_provider_cpt::ComponentState { - @world_provider_cpt::unsafe_new_component_state::() +} +impl StorageStorageBaseDrop of core::traits::Drop::; +impl StorageStorageBaseCopy of core::traits::Copy::; +impl StorageStorageBaseMutDrop of core::traits::Drop::; +impl StorageStorageBaseMutCopy of core::traits::Copy::; +impl IDojoInitDispatcherCopy of core::traits::Copy::; +impl IDojoInitDispatcherDrop of core::traits::Drop::; +impl IDojoInitDispatcherSerde of core::serde::Serde:: { + fn serialize(self: @IDojoInitDispatcher, ref output: core::array::Array) { + core::serde::Serde::serialize(self.contract_address, ref output) } - fn get_component_mut(ref self: ContractState) -> world_provider_cpt::ComponentState { - world_provider_cpt::unsafe_new_component_state::() + fn deserialize(ref serialized: core::array::Span) -> core::option::Option { + core::option::Option::Some(IDojoInitDispatcher { + contract_address: core::serde::Serde::deserialize(ref serialized)?, + }) } - fn get_contract(self: @world_provider_cpt::ComponentState) -> @ContractState { - @unsafe_new_contract_state() +} +impl StoreIDojoInitDispatcher of starknet::Store:: { + fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { + let contract_address = starknet::Store::::read(address_domain, base)?; + starknet::SyscallResult::Ok( + IDojoInitDispatcher { + contract_address, + } + ) + } + fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write(address_domain, base, value.contract_address)?; + starknet::SyscallResult::Ok(()) + } + fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { + let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; + starknet::SyscallResult::Ok( + IDojoInitDispatcher { + contract_address, + } + ) + } + #[inline(always)] + fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; + starknet::SyscallResult::Ok(()) + } + #[inline(always)] + fn size() -> u8 { + starknet::Store::::size() + } +} + +#[derive(Drop, Copy)] +pub struct IDojoInitDispatcherSubPointers { + pub contract_address: starknet::storage::StoragePointer, +} +impl IDojoInitDispatcherSubPointersImpl of starknet::storage::SubPointers { + type SubPointersType = IDojoInitDispatcherSubPointers; + fn sub_pointers(self: starknet::storage::StoragePointer) -> IDojoInitDispatcherSubPointers { + let base_address = self.__storage_pointer_address__; + let mut current_offset = self.__storage_pointer_offset__; + let contract_address_value = starknet::storage::StoragePointer { + __storage_pointer_address__: base_address, + __storage_pointer_offset__: current_offset, + }; + IDojoInitDispatcherSubPointers { + contract_address: contract_address_value, + } + } +} +#[derive(Drop, Copy)] +pub struct IDojoInitDispatcherSubPointersMut { + pub contract_address: starknet::storage::StoragePointer>, +} +impl IDojoInitDispatcherSubPointersMutImpl of starknet::storage::SubPointersMut { + type SubPointersType = IDojoInitDispatcherSubPointersMut; + fn sub_pointers_mut(self: starknet::storage::StoragePointer>) -> IDojoInitDispatcherSubPointersMut { + let base_address = self.__storage_pointer_address__; + let mut current_offset = self.__storage_pointer_offset__; + let contract_address_value = starknet::storage::StoragePointer { + __storage_pointer_address__: base_address, + __storage_pointer_offset__: current_offset, + }; + IDojoInitDispatcherSubPointersMut { + contract_address: contract_address_value, + } } - fn get_contract_mut(ref self: world_provider_cpt::ComponentState) -> ContractState { - unsafe_new_contract_state() +} +impl IDojoInitLibraryDispatcherCopy of core::traits::Copy::; +impl IDojoInitLibraryDispatcherDrop of core::traits::Drop::; +impl IDojoInitLibraryDispatcherSerde of core::serde::Serde:: { + fn serialize(self: @IDojoInitLibraryDispatcher, ref output: core::array::Array) { + core::serde::Serde::serialize(self.class_hash, ref output) } - fn emit>(ref self: world_provider_cpt::ComponentState, event: S) { - let event: world_provider_cpt::Event = core::traits::Into::into(event); - let mut contract = world_provider_cpt::HasComponent::get_contract_mut(ref self); - ContractStateEventEmitter::emit(ref contract, Event::WorldProviderEvent(event)); + fn deserialize(ref serialized: core::array::Span) -> core::option::Option { + core::option::Option::Some(IDojoInitLibraryDispatcher { + class_hash: core::serde::Serde::deserialize(ref serialized)?, + }) } } -impl HasComponentImpl_upgradeable_cpt of upgradeable_cpt::HasComponent { - fn get_component(self: @ContractState) -> @upgradeable_cpt::ComponentState { - @upgradeable_cpt::unsafe_new_component_state::() +impl StoreIDojoInitLibraryDispatcher of starknet::Store:: { + fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { + let class_hash = starknet::Store::::read(address_domain, base)?; + starknet::SyscallResult::Ok( + IDojoInitLibraryDispatcher { + class_hash, + } + ) } - fn get_component_mut(ref self: ContractState) -> upgradeable_cpt::ComponentState { - upgradeable_cpt::unsafe_new_component_state::() + fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitLibraryDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write(address_domain, base, value.class_hash)?; + starknet::SyscallResult::Ok(()) } - fn get_contract(self: @upgradeable_cpt::ComponentState) -> @ContractState { - @unsafe_new_contract_state() + fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { + let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; + starknet::SyscallResult::Ok( + IDojoInitLibraryDispatcher { + class_hash, + } + ) } - fn get_contract_mut(ref self: upgradeable_cpt::ComponentState) -> ContractState { - unsafe_new_contract_state() + #[inline(always)] + fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitLibraryDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; + starknet::SyscallResult::Ok(()) } - fn emit>(ref self: upgradeable_cpt::ComponentState, event: S) { - let event: upgradeable_cpt::Event = core::traits::Into::into(event); - let mut contract = upgradeable_cpt::HasComponent::get_contract_mut(ref self); - ContractStateEventEmitter::emit(ref contract, Event::UpgradeableEvent(event)); + #[inline(always)] + fn size() -> u8 { + starknet::Store::::size() } } -impl HasComponentImpl_testcomponent1 of testcomponent1::HasComponent { - fn get_component(self: @ContractState) -> @testcomponent1::ComponentState { - @testcomponent1::unsafe_new_component_state::() - } - fn get_component_mut(ref self: ContractState) -> testcomponent1::ComponentState { - testcomponent1::unsafe_new_component_state::() + +#[derive(Drop, Copy)] +pub struct IDojoInitLibraryDispatcherSubPointers { + pub class_hash: starknet::storage::StoragePointer, +} +impl IDojoInitLibraryDispatcherSubPointersImpl of starknet::storage::SubPointers { + type SubPointersType = IDojoInitLibraryDispatcherSubPointers; + fn sub_pointers(self: starknet::storage::StoragePointer) -> IDojoInitLibraryDispatcherSubPointers { + let base_address = self.__storage_pointer_address__; + let mut current_offset = self.__storage_pointer_offset__; + let class_hash_value = starknet::storage::StoragePointer { + __storage_pointer_address__: base_address, + __storage_pointer_offset__: current_offset, + }; + IDojoInitLibraryDispatcherSubPointers { + class_hash: class_hash_value, + } } - fn get_contract(self: @testcomponent1::ComponentState) -> @ContractState { - @unsafe_new_contract_state() +} +#[derive(Drop, Copy)] +pub struct IDojoInitLibraryDispatcherSubPointersMut { + pub class_hash: starknet::storage::StoragePointer>, +} +impl IDojoInitLibraryDispatcherSubPointersMutImpl of starknet::storage::SubPointersMut { + type SubPointersType = IDojoInitLibraryDispatcherSubPointersMut; + fn sub_pointers_mut(self: starknet::storage::StoragePointer>) -> IDojoInitLibraryDispatcherSubPointersMut { + let base_address = self.__storage_pointer_address__; + let mut current_offset = self.__storage_pointer_offset__; + let class_hash_value = starknet::storage::StoragePointer { + __storage_pointer_address__: base_address, + __storage_pointer_offset__: current_offset, + }; + IDojoInitLibraryDispatcherSubPointersMut { + class_hash: class_hash_value, + } } - fn get_contract_mut(ref self: testcomponent1::ComponentState) -> ContractState { - unsafe_new_contract_state() +} +impl IDojoInitSafeLibraryDispatcherCopy of core::traits::Copy::; +impl IDojoInitSafeLibraryDispatcherDrop of core::traits::Drop::; +impl IDojoInitSafeLibraryDispatcherSerde of core::serde::Serde:: { + fn serialize(self: @IDojoInitSafeLibraryDispatcher, ref output: core::array::Array) { + core::serde::Serde::serialize(self.class_hash, ref output) } - fn emit>(ref self: testcomponent1::ComponentState, event: S) { - let event: testcomponent1::Event = core::traits::Into::into(event); - let mut contract = testcomponent1::HasComponent::get_contract_mut(ref self); - ContractStateEventEmitter::emit(ref contract, Event::testcomponent1_event(event)); + fn deserialize(ref serialized: core::array::Span) -> core::option::Option { + core::option::Option::Some(IDojoInitSafeLibraryDispatcher { + class_hash: core::serde::Serde::deserialize(ref serialized)?, + }) } } -impl HasComponentImpl_testcomponent2 of testcomponent2::HasComponent { - fn get_component(self: @ContractState) -> @testcomponent2::ComponentState { - @testcomponent2::unsafe_new_component_state::() +impl StoreIDojoInitSafeLibraryDispatcher of starknet::Store:: { + fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { + let class_hash = starknet::Store::::read(address_domain, base)?; + starknet::SyscallResult::Ok( + IDojoInitSafeLibraryDispatcher { + class_hash, + } + ) } - fn get_component_mut(ref self: ContractState) -> testcomponent2::ComponentState { - testcomponent2::unsafe_new_component_state::() + fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write(address_domain, base, value.class_hash)?; + starknet::SyscallResult::Ok(()) } - fn get_contract(self: @testcomponent2::ComponentState) -> @ContractState { - @unsafe_new_contract_state() + fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { + let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; + starknet::SyscallResult::Ok( + IDojoInitSafeLibraryDispatcher { + class_hash, + } + ) } - fn get_contract_mut(ref self: testcomponent2::ComponentState) -> ContractState { - unsafe_new_contract_state() + #[inline(always)] + fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; + starknet::SyscallResult::Ok(()) } - fn emit>(ref self: testcomponent2::ComponentState, event: S) { - let event: testcomponent2::Event = core::traits::Into::into(event); - let mut contract = testcomponent2::HasComponent::get_contract_mut(ref self); - ContractStateEventEmitter::emit(ref contract, Event::testcomponent2_event(event)); + #[inline(always)] + fn size() -> u8 { + starknet::Store::::size() } } -impl EventDrop of core::traits::Drop::; -impl EventIsEvent of starknet::Event { - fn append_keys_and_data( - self: @Event, ref keys: Array, ref data: Array - ) { - match self { - Event::UpgradeableEvent(val) => { - core::array::ArrayTrait::append(ref keys, selector!("UpgradeableEvent")); - starknet::Event::append_keys_and_data( - val, ref keys, ref data - ); - }, - Event::WorldProviderEvent(val) => { - core::array::ArrayTrait::append(ref keys, selector!("WorldProviderEvent")); - starknet::Event::append_keys_and_data( - val, ref keys, ref data - ); - }, - Event::testcomponent1_event(val) => { - starknet::Event::append_keys_and_data( - val, ref keys, ref data - ); - }, - Event::testcomponent2_event(val) => { - core::array::ArrayTrait::append(ref keys, selector!("testcomponent2_event")); - starknet::Event::append_keys_and_data( - val, ref keys, ref data - ); - }, + +#[derive(Drop, Copy)] +pub struct IDojoInitSafeLibraryDispatcherSubPointers { + pub class_hash: starknet::storage::StoragePointer, +} +impl IDojoInitSafeLibraryDispatcherSubPointersImpl of starknet::storage::SubPointers { + type SubPointersType = IDojoInitSafeLibraryDispatcherSubPointers; + fn sub_pointers(self: starknet::storage::StoragePointer) -> IDojoInitSafeLibraryDispatcherSubPointers { + let base_address = self.__storage_pointer_address__; + let mut current_offset = self.__storage_pointer_offset__; + let class_hash_value = starknet::storage::StoragePointer { + __storage_pointer_address__: base_address, + __storage_pointer_offset__: current_offset, + }; + IDojoInitSafeLibraryDispatcherSubPointers { + class_hash: class_hash_value, } } - fn deserialize( - ref keys: Span, ref data: Span, - ) -> Option { - { - let mut keys = keys; - let mut data = data; - match starknet::Event::deserialize(ref keys, ref data) { - Option::Some(val) => { - return Option::Some(Event::testcomponent1_event(val)); - }, - Option::None => {}, - }; - } - let __selector__ = *core::array::SpanTrait::pop_front(ref keys)?; - if __selector__ == selector!("UpgradeableEvent") { - let val = starknet::Event::deserialize( - ref keys, ref data - )?; - return Option::Some(Event::UpgradeableEvent(val)); - } - if __selector__ == selector!("WorldProviderEvent") { - let val = starknet::Event::deserialize( - ref keys, ref data - )?; - return Option::Some(Event::WorldProviderEvent(val)); - } - if __selector__ == selector!("testcomponent2_event") { - let val = starknet::Event::deserialize( - ref keys, ref data - )?; - return Option::Some(Event::testcomponent2_event(val)); +} +#[derive(Drop, Copy)] +pub struct IDojoInitSafeLibraryDispatcherSubPointersMut { + pub class_hash: starknet::storage::StoragePointer>, +} +impl IDojoInitSafeLibraryDispatcherSubPointersMutImpl of starknet::storage::SubPointersMut { + type SubPointersType = IDojoInitSafeLibraryDispatcherSubPointersMut; + fn sub_pointers_mut(self: starknet::storage::StoragePointer>) -> IDojoInitSafeLibraryDispatcherSubPointersMut { + let base_address = self.__storage_pointer_address__; + let mut current_offset = self.__storage_pointer_offset__; + let class_hash_value = starknet::storage::StoragePointer { + __storage_pointer_address__: base_address, + __storage_pointer_offset__: current_offset, + }; + IDojoInitSafeLibraryDispatcherSubPointersMut { + class_hash: class_hash_value, } - Option::None } } -impl EventUpgradeableEventIntoEvent of Into { - fn into(self: upgradeable_cpt::Event) -> Event { - Event::UpgradeableEvent(self) +impl IDojoInitSafeDispatcherCopy of core::traits::Copy::; +impl IDojoInitSafeDispatcherDrop of core::traits::Drop::; +impl IDojoInitSafeDispatcherSerde of core::serde::Serde:: { + fn serialize(self: @IDojoInitSafeDispatcher, ref output: core::array::Array) { + core::serde::Serde::serialize(self.contract_address, ref output) + } + fn deserialize(ref serialized: core::array::Span) -> core::option::Option { + core::option::Option::Some(IDojoInitSafeDispatcher { + contract_address: core::serde::Serde::deserialize(ref serialized)?, + }) } } -impl EventWorldProviderEventIntoEvent of Into { - fn into(self: world_provider_cpt::Event) -> Event { - Event::WorldProviderEvent(self) +impl StoreIDojoInitSafeDispatcher of starknet::Store:: { + fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { + let contract_address = starknet::Store::::read(address_domain, base)?; + starknet::SyscallResult::Ok( + IDojoInitSafeDispatcher { + contract_address, + } + ) + } + fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitSafeDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write(address_domain, base, value.contract_address)?; + starknet::SyscallResult::Ok(()) + } + fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { + let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; + starknet::SyscallResult::Ok( + IDojoInitSafeDispatcher { + contract_address, + } + ) + } + #[inline(always)] + fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitSafeDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; + starknet::SyscallResult::Ok(()) + } + #[inline(always)] + fn size() -> u8 { + starknet::Store::::size() } } -impl Eventtestcomponent1_eventIntoEvent of Into { - fn into(self: testcomponent1::Event) -> Event { - Event::testcomponent1_event(self) + +#[derive(Drop, Copy)] +pub struct IDojoInitSafeDispatcherSubPointers { + pub contract_address: starknet::storage::StoragePointer, +} +impl IDojoInitSafeDispatcherSubPointersImpl of starknet::storage::SubPointers { + type SubPointersType = IDojoInitSafeDispatcherSubPointers; + fn sub_pointers(self: starknet::storage::StoragePointer) -> IDojoInitSafeDispatcherSubPointers { + let base_address = self.__storage_pointer_address__; + let mut current_offset = self.__storage_pointer_offset__; + let contract_address_value = starknet::storage::StoragePointer { + __storage_pointer_address__: base_address, + __storage_pointer_offset__: current_offset, + }; + IDojoInitSafeDispatcherSubPointers { + contract_address: contract_address_value, + } } } -impl Eventtestcomponent2_eventIntoEvent of Into { - fn into(self: testcomponent2::Event) -> Event { - Event::testcomponent2_event(self) +#[derive(Drop, Copy)] +pub struct IDojoInitSafeDispatcherSubPointersMut { + pub contract_address: starknet::storage::StoragePointer>, +} +impl IDojoInitSafeDispatcherSubPointersMutImpl of starknet::storage::SubPointersMut { + type SubPointersType = IDojoInitSafeDispatcherSubPointersMut; + fn sub_pointers_mut(self: starknet::storage::StoragePointer>) -> IDojoInitSafeDispatcherSubPointersMut { + let base_address = self.__storage_pointer_address__; + let mut current_offset = self.__storage_pointer_offset__; + let contract_address_value = starknet::storage::StoragePointer { + __storage_pointer_address__: base_address, + __storage_pointer_offset__: current_offset, + }; + IDojoInitSafeDispatcherSubPointersMut { + contract_address: contract_address_value, + } } } -impl StorageStorageBaseDrop of core::traits::Drop::; -impl StorageStorageBaseCopy of core::traits::Copy::; -impl StorageStorageBaseMutDrop of core::traits::Drop::; -impl StorageStorageBaseMutCopy of core::traits::Copy::; - +impl IDojoInitDispatcherSubPointersDrop of core::traits::Drop::; +impl IDojoInitDispatcherSubPointersCopy of core::traits::Copy::; +impl IDojoInitDispatcherSubPointersMutDrop of core::traits::Drop::; +impl IDojoInitDispatcherSubPointersMutCopy of core::traits::Copy::; +impl IDojoInitLibraryDispatcherSubPointersDrop of core::traits::Drop::; +impl IDojoInitLibraryDispatcherSubPointersCopy of core::traits::Copy::; +impl IDojoInitLibraryDispatcherSubPointersMutDrop of core::traits::Drop::; +impl IDojoInitLibraryDispatcherSubPointersMutCopy of core::traits::Copy::; +impl IDojoInitSafeLibraryDispatcherSubPointersDrop of core::traits::Drop::; +impl IDojoInitSafeLibraryDispatcherSubPointersCopy of core::traits::Copy::; +impl IDojoInitSafeLibraryDispatcherSubPointersMutDrop of core::traits::Drop::; +impl IDojoInitSafeLibraryDispatcherSubPointersMutCopy of core::traits::Copy::; +impl IDojoInitSafeDispatcherSubPointersDrop of core::traits::Drop::; +impl IDojoInitSafeDispatcherSubPointersCopy of core::traits::Copy::; +impl IDojoInitSafeDispatcherSubPointersMutDrop of core::traits::Drop::; +impl IDojoInitSafeDispatcherSubPointersMutCopy of core::traits::Copy::; + } #[starknet::interface] @@ -2897,10 +5207,28 @@ impl StorageStorageBaseMutCopy of core::traits::Copy::; impl InternalImplBad of InternalUtils {fn bad_func_using_generate(self: @ContractState) -> felt252 {let world = self.world_provider.world(); 'land' }} #[constructor] - fn constructor(ref self: ContractState) { - self.world_provider.initializer(); - } + fn constructor(ref self: ContractState) { + self.world_provider.initializer(); + } +#[starknet::interface] +pub trait IDojoInit { + fn dojo_init(self: @ContractState); +} + +#[abi(embed_v0)] +pub impl IDojoInitImpl of IDojoInit { + fn dojo_init(self: @ContractState) { + if starknet::get_caller_address() != self.world_provider.world().contract_address { + core::panics::panic_with_byte_array( + @format!("Only the world can init contract `{}`, but caller is `{:?}`", + self.tag(), + starknet::get_caller_address(), + )); + } + } +} + #[event] #[derive(Drop, starknet::Event)] enum Event { @@ -2909,6 +5237,95 @@ impl StorageStorageBaseMutCopy of core::traits::Copy::; } trait InternalUtils{fn bad_func_using_generate(self: @ContractState) -> felt252; } +pub trait IDojoInitDispatcherTrait { + fn dojo_init(self: T); +} + +#[derive(Copy, Drop, starknet::Store, Serde)] +pub struct IDojoInitDispatcher { + pub contract_address: starknet::ContractAddress, +} + +impl IDojoInitDispatcherImpl of IDojoInitDispatcherTrait { + fn dojo_init(self: IDojoInitDispatcher) { + let mut __calldata__ = core::traits::Default::default(); + + let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( + self.contract_address, + selector!("dojo_init"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); + () + } + +} + +#[derive(Copy, Drop, starknet::Store, Serde)] +pub struct IDojoInitLibraryDispatcher { + pub class_hash: starknet::ClassHash, +} + +impl IDojoInitLibraryDispatcherImpl of IDojoInitDispatcherTrait { + fn dojo_init(self: IDojoInitLibraryDispatcher) { + let mut __calldata__ = core::traits::Default::default(); + + let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( + self.class_hash, + selector!("dojo_init"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); + () + } + +} + +pub trait IDojoInitSafeDispatcherTrait { + #[unstable(feature: "safe_dispatcher")] + fn dojo_init(self: T) -> starknet::SyscallResult<()>; +} + +#[derive(Copy, Drop, starknet::Store, Serde)] +pub struct IDojoInitSafeLibraryDispatcher { + pub class_hash: starknet::ClassHash, +} + +impl IDojoInitSafeLibraryDispatcherImpl of IDojoInitSafeDispatcherTrait { + fn dojo_init(self: IDojoInitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { + let mut __calldata__ = core::traits::Default::default(); + + let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( + self.class_hash, + selector!("dojo_init"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = __dispatcher_return_data__?; + Result::Ok(()) + } + +} + + +#[derive(Copy, Drop, starknet::Store, Serde)] +pub struct IDojoInitSafeDispatcher { + pub contract_address: starknet::ContractAddress, +} + +impl IDojoInitSafeDispatcherImpl of IDojoInitSafeDispatcherTrait { + fn dojo_init(self: IDojoInitSafeDispatcher) -> starknet::SyscallResult<()> { + let mut __calldata__ = core::traits::Default::default(); + + let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( + self.contract_address, + selector!("dojo_init"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = __dispatcher_return_data__?; + Result::Ok(()) + } + +} impl EventDrop of core::traits::Drop::; impl EventIsEvent of starknet::Event { fn append_keys_and_data( @@ -3332,88 +5749,443 @@ fn __wrapper__constructor(mut data: Span::) -> Span:: { core::array::ArrayTrait::span(@arr) } - -pub mod __external { - pub use super::__wrapper__ContractImpl__name as name; - pub use super::__wrapper__ContractImpl__namespace as namespace; - pub use super::__wrapper__ContractImpl__tag as tag; - pub use super::__wrapper__ContractImpl__name_hash as name_hash; - pub use super::__wrapper__ContractImpl__namespace_hash as namespace_hash; - pub use super::__wrapper__ContractImpl__selector as selector; - pub use super::__wrapper__TestFaultyImpl__do_with_self_and_world as do_with_self_and_world; - pub use super::__wrapper__TestFaultyImpl__do_with_ref_self_and_world as do_with_ref_self_and_world; - pub use super::__wrapper__TestFaultyImpl__do_with_self_and_world_inv as do_with_self_and_world_inv; - pub use super::__wrapper__TestFaultyImpl__do_with_ref_self_and_world_inv as do_with_ref_self_and_world_inv; - pub use super::__wrapper__TestFaultyImpl__do_with_several_world_dispatchers as do_with_several_world_dispatchers; - pub use super::__wrapper__TestFaultyImpl__do_with_world_not_named_world as do_with_world_not_named_world; - pub use super::__wrapper__TestFaultyImpl__do_with_world_not_first as do_with_world_not_first; +#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] +fn __wrapper__IDojoInitImpl__dojo_init(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + IDojoInitImpl::dojo_init(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::array::ArrayTrait::span(@arr) +} + + +pub mod __external { + pub use super::__wrapper__ContractImpl__name as name; + pub use super::__wrapper__ContractImpl__namespace as namespace; + pub use super::__wrapper__ContractImpl__tag as tag; + pub use super::__wrapper__ContractImpl__name_hash as name_hash; + pub use super::__wrapper__ContractImpl__namespace_hash as namespace_hash; + pub use super::__wrapper__ContractImpl__selector as selector; + pub use super::__wrapper__TestFaultyImpl__do_with_self_and_world as do_with_self_and_world; + pub use super::__wrapper__TestFaultyImpl__do_with_ref_self_and_world as do_with_ref_self_and_world; + pub use super::__wrapper__TestFaultyImpl__do_with_self_and_world_inv as do_with_self_and_world_inv; + pub use super::__wrapper__TestFaultyImpl__do_with_ref_self_and_world_inv as do_with_ref_self_and_world_inv; + pub use super::__wrapper__TestFaultyImpl__do_with_several_world_dispatchers as do_with_several_world_dispatchers; + pub use super::__wrapper__TestFaultyImpl__do_with_world_not_named_world as do_with_world_not_named_world; + pub use super::__wrapper__TestFaultyImpl__do_with_world_not_first as do_with_world_not_first; + pub use super::__wrapper__IDojoInitImpl__dojo_init as dojo_init; +} +pub mod __l1_handler { +} +pub mod __constructor { + pub use super::__wrapper__constructor as constructor; +} + impl ContractStateEventEmitter of starknet::event::EventEmitter< + ContractState, Event + > { + fn emit>( + ref self: ContractState, event: S + ) { + let event: Event = core::traits::Into::into(event); + let mut keys = Default::::default(); + let mut data = Default::::default(); + starknet::Event::append_keys_and_data(@event, ref keys, ref data); + starknet::SyscallResultTrait::unwrap_syscall( + starknet::syscalls::emit_event_syscall( + core::array::ArrayTrait::span(@keys), + core::array::ArrayTrait::span(@data), + ) + ) + } + } + +impl HasComponentImpl_world_provider_cpt of world_provider_cpt::HasComponent { + fn get_component(self: @ContractState) -> @world_provider_cpt::ComponentState { + @world_provider_cpt::unsafe_new_component_state::() + } + fn get_component_mut(ref self: ContractState) -> world_provider_cpt::ComponentState { + world_provider_cpt::unsafe_new_component_state::() + } + fn get_contract(self: @world_provider_cpt::ComponentState) -> @ContractState { + @unsafe_new_contract_state() + } + fn get_contract_mut(ref self: world_provider_cpt::ComponentState) -> ContractState { + unsafe_new_contract_state() + } + fn emit>(ref self: world_provider_cpt::ComponentState, event: S) { + let event: world_provider_cpt::Event = core::traits::Into::into(event); + let mut contract = world_provider_cpt::HasComponent::get_contract_mut(ref self); + ContractStateEventEmitter::emit(ref contract, Event::WorldProviderEvent(event)); + } +} +impl HasComponentImpl_upgradeable_cpt of upgradeable_cpt::HasComponent { + fn get_component(self: @ContractState) -> @upgradeable_cpt::ComponentState { + @upgradeable_cpt::unsafe_new_component_state::() + } + fn get_component_mut(ref self: ContractState) -> upgradeable_cpt::ComponentState { + upgradeable_cpt::unsafe_new_component_state::() + } + fn get_contract(self: @upgradeable_cpt::ComponentState) -> @ContractState { + @unsafe_new_contract_state() + } + fn get_contract_mut(ref self: upgradeable_cpt::ComponentState) -> ContractState { + unsafe_new_contract_state() + } + fn emit>(ref self: upgradeable_cpt::ComponentState, event: S) { + let event: upgradeable_cpt::Event = core::traits::Into::into(event); + let mut contract = upgradeable_cpt::HasComponent::get_contract_mut(ref self); + ContractStateEventEmitter::emit(ref contract, Event::UpgradeableEvent(event)); + } +} +impl IDojoInitDispatcherCopy of core::traits::Copy::; +impl IDojoInitDispatcherDrop of core::traits::Drop::; +impl IDojoInitDispatcherSerde of core::serde::Serde:: { + fn serialize(self: @IDojoInitDispatcher, ref output: core::array::Array) { + core::serde::Serde::serialize(self.contract_address, ref output) + } + fn deserialize(ref serialized: core::array::Span) -> core::option::Option { + core::option::Option::Some(IDojoInitDispatcher { + contract_address: core::serde::Serde::deserialize(ref serialized)?, + }) + } +} +impl StoreIDojoInitDispatcher of starknet::Store:: { + fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { + let contract_address = starknet::Store::::read(address_domain, base)?; + starknet::SyscallResult::Ok( + IDojoInitDispatcher { + contract_address, + } + ) + } + fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write(address_domain, base, value.contract_address)?; + starknet::SyscallResult::Ok(()) + } + fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { + let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; + starknet::SyscallResult::Ok( + IDojoInitDispatcher { + contract_address, + } + ) + } + #[inline(always)] + fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; + starknet::SyscallResult::Ok(()) + } + #[inline(always)] + fn size() -> u8 { + starknet::Store::::size() + } +} + +#[derive(Drop, Copy)] +pub struct IDojoInitDispatcherSubPointers { + pub contract_address: starknet::storage::StoragePointer, +} +impl IDojoInitDispatcherSubPointersImpl of starknet::storage::SubPointers { + type SubPointersType = IDojoInitDispatcherSubPointers; + fn sub_pointers(self: starknet::storage::StoragePointer) -> IDojoInitDispatcherSubPointers { + let base_address = self.__storage_pointer_address__; + let mut current_offset = self.__storage_pointer_offset__; + let contract_address_value = starknet::storage::StoragePointer { + __storage_pointer_address__: base_address, + __storage_pointer_offset__: current_offset, + }; + IDojoInitDispatcherSubPointers { + contract_address: contract_address_value, + } + } +} +#[derive(Drop, Copy)] +pub struct IDojoInitDispatcherSubPointersMut { + pub contract_address: starknet::storage::StoragePointer>, +} +impl IDojoInitDispatcherSubPointersMutImpl of starknet::storage::SubPointersMut { + type SubPointersType = IDojoInitDispatcherSubPointersMut; + fn sub_pointers_mut(self: starknet::storage::StoragePointer>) -> IDojoInitDispatcherSubPointersMut { + let base_address = self.__storage_pointer_address__; + let mut current_offset = self.__storage_pointer_offset__; + let contract_address_value = starknet::storage::StoragePointer { + __storage_pointer_address__: base_address, + __storage_pointer_offset__: current_offset, + }; + IDojoInitDispatcherSubPointersMut { + contract_address: contract_address_value, + } + } +} +impl IDojoInitLibraryDispatcherCopy of core::traits::Copy::; +impl IDojoInitLibraryDispatcherDrop of core::traits::Drop::; +impl IDojoInitLibraryDispatcherSerde of core::serde::Serde:: { + fn serialize(self: @IDojoInitLibraryDispatcher, ref output: core::array::Array) { + core::serde::Serde::serialize(self.class_hash, ref output) + } + fn deserialize(ref serialized: core::array::Span) -> core::option::Option { + core::option::Option::Some(IDojoInitLibraryDispatcher { + class_hash: core::serde::Serde::deserialize(ref serialized)?, + }) + } +} +impl StoreIDojoInitLibraryDispatcher of starknet::Store:: { + fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { + let class_hash = starknet::Store::::read(address_domain, base)?; + starknet::SyscallResult::Ok( + IDojoInitLibraryDispatcher { + class_hash, + } + ) + } + fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitLibraryDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write(address_domain, base, value.class_hash)?; + starknet::SyscallResult::Ok(()) + } + fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { + let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; + starknet::SyscallResult::Ok( + IDojoInitLibraryDispatcher { + class_hash, + } + ) + } + #[inline(always)] + fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitLibraryDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; + starknet::SyscallResult::Ok(()) + } + #[inline(always)] + fn size() -> u8 { + starknet::Store::::size() + } +} + +#[derive(Drop, Copy)] +pub struct IDojoInitLibraryDispatcherSubPointers { + pub class_hash: starknet::storage::StoragePointer, } -pub mod __l1_handler { +impl IDojoInitLibraryDispatcherSubPointersImpl of starknet::storage::SubPointers { + type SubPointersType = IDojoInitLibraryDispatcherSubPointers; + fn sub_pointers(self: starknet::storage::StoragePointer) -> IDojoInitLibraryDispatcherSubPointers { + let base_address = self.__storage_pointer_address__; + let mut current_offset = self.__storage_pointer_offset__; + let class_hash_value = starknet::storage::StoragePointer { + __storage_pointer_address__: base_address, + __storage_pointer_offset__: current_offset, + }; + IDojoInitLibraryDispatcherSubPointers { + class_hash: class_hash_value, + } + } } -pub mod __constructor { - pub use super::__wrapper__constructor as constructor; +#[derive(Drop, Copy)] +pub struct IDojoInitLibraryDispatcherSubPointersMut { + pub class_hash: starknet::storage::StoragePointer>, } - impl ContractStateEventEmitter of starknet::event::EventEmitter< - ContractState, Event - > { - fn emit>( - ref self: ContractState, event: S - ) { - let event: Event = core::traits::Into::into(event); - let mut keys = Default::::default(); - let mut data = Default::::default(); - starknet::Event::append_keys_and_data(@event, ref keys, ref data); - starknet::SyscallResultTrait::unwrap_syscall( - starknet::syscalls::emit_event_syscall( - core::array::ArrayTrait::span(@keys), - core::array::ArrayTrait::span(@data), - ) - ) +impl IDojoInitLibraryDispatcherSubPointersMutImpl of starknet::storage::SubPointersMut { + type SubPointersType = IDojoInitLibraryDispatcherSubPointersMut; + fn sub_pointers_mut(self: starknet::storage::StoragePointer>) -> IDojoInitLibraryDispatcherSubPointersMut { + let base_address = self.__storage_pointer_address__; + let mut current_offset = self.__storage_pointer_offset__; + let class_hash_value = starknet::storage::StoragePointer { + __storage_pointer_address__: base_address, + __storage_pointer_offset__: current_offset, + }; + IDojoInitLibraryDispatcherSubPointersMut { + class_hash: class_hash_value, } } - -impl HasComponentImpl_world_provider_cpt of world_provider_cpt::HasComponent { - fn get_component(self: @ContractState) -> @world_provider_cpt::ComponentState { - @world_provider_cpt::unsafe_new_component_state::() +} +impl IDojoInitSafeLibraryDispatcherCopy of core::traits::Copy::; +impl IDojoInitSafeLibraryDispatcherDrop of core::traits::Drop::; +impl IDojoInitSafeLibraryDispatcherSerde of core::serde::Serde:: { + fn serialize(self: @IDojoInitSafeLibraryDispatcher, ref output: core::array::Array) { + core::serde::Serde::serialize(self.class_hash, ref output) } - fn get_component_mut(ref self: ContractState) -> world_provider_cpt::ComponentState { - world_provider_cpt::unsafe_new_component_state::() + fn deserialize(ref serialized: core::array::Span) -> core::option::Option { + core::option::Option::Some(IDojoInitSafeLibraryDispatcher { + class_hash: core::serde::Serde::deserialize(ref serialized)?, + }) } - fn get_contract(self: @world_provider_cpt::ComponentState) -> @ContractState { - @unsafe_new_contract_state() +} +impl StoreIDojoInitSafeLibraryDispatcher of starknet::Store:: { + fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { + let class_hash = starknet::Store::::read(address_domain, base)?; + starknet::SyscallResult::Ok( + IDojoInitSafeLibraryDispatcher { + class_hash, + } + ) } - fn get_contract_mut(ref self: world_provider_cpt::ComponentState) -> ContractState { - unsafe_new_contract_state() + fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write(address_domain, base, value.class_hash)?; + starknet::SyscallResult::Ok(()) } - fn emit>(ref self: world_provider_cpt::ComponentState, event: S) { - let event: world_provider_cpt::Event = core::traits::Into::into(event); - let mut contract = world_provider_cpt::HasComponent::get_contract_mut(ref self); - ContractStateEventEmitter::emit(ref contract, Event::WorldProviderEvent(event)); + fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { + let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; + starknet::SyscallResult::Ok( + IDojoInitSafeLibraryDispatcher { + class_hash, + } + ) + } + #[inline(always)] + fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; + starknet::SyscallResult::Ok(()) + } + #[inline(always)] + fn size() -> u8 { + starknet::Store::::size() } } -impl HasComponentImpl_upgradeable_cpt of upgradeable_cpt::HasComponent { - fn get_component(self: @ContractState) -> @upgradeable_cpt::ComponentState { - @upgradeable_cpt::unsafe_new_component_state::() + +#[derive(Drop, Copy)] +pub struct IDojoInitSafeLibraryDispatcherSubPointers { + pub class_hash: starknet::storage::StoragePointer, +} +impl IDojoInitSafeLibraryDispatcherSubPointersImpl of starknet::storage::SubPointers { + type SubPointersType = IDojoInitSafeLibraryDispatcherSubPointers; + fn sub_pointers(self: starknet::storage::StoragePointer) -> IDojoInitSafeLibraryDispatcherSubPointers { + let base_address = self.__storage_pointer_address__; + let mut current_offset = self.__storage_pointer_offset__; + let class_hash_value = starknet::storage::StoragePointer { + __storage_pointer_address__: base_address, + __storage_pointer_offset__: current_offset, + }; + IDojoInitSafeLibraryDispatcherSubPointers { + class_hash: class_hash_value, + } } - fn get_component_mut(ref self: ContractState) -> upgradeable_cpt::ComponentState { - upgradeable_cpt::unsafe_new_component_state::() +} +#[derive(Drop, Copy)] +pub struct IDojoInitSafeLibraryDispatcherSubPointersMut { + pub class_hash: starknet::storage::StoragePointer>, +} +impl IDojoInitSafeLibraryDispatcherSubPointersMutImpl of starknet::storage::SubPointersMut { + type SubPointersType = IDojoInitSafeLibraryDispatcherSubPointersMut; + fn sub_pointers_mut(self: starknet::storage::StoragePointer>) -> IDojoInitSafeLibraryDispatcherSubPointersMut { + let base_address = self.__storage_pointer_address__; + let mut current_offset = self.__storage_pointer_offset__; + let class_hash_value = starknet::storage::StoragePointer { + __storage_pointer_address__: base_address, + __storage_pointer_offset__: current_offset, + }; + IDojoInitSafeLibraryDispatcherSubPointersMut { + class_hash: class_hash_value, + } } - fn get_contract(self: @upgradeable_cpt::ComponentState) -> @ContractState { - @unsafe_new_contract_state() +} +impl IDojoInitSafeDispatcherCopy of core::traits::Copy::; +impl IDojoInitSafeDispatcherDrop of core::traits::Drop::; +impl IDojoInitSafeDispatcherSerde of core::serde::Serde:: { + fn serialize(self: @IDojoInitSafeDispatcher, ref output: core::array::Array) { + core::serde::Serde::serialize(self.contract_address, ref output) } - fn get_contract_mut(ref self: upgradeable_cpt::ComponentState) -> ContractState { - unsafe_new_contract_state() + fn deserialize(ref serialized: core::array::Span) -> core::option::Option { + core::option::Option::Some(IDojoInitSafeDispatcher { + contract_address: core::serde::Serde::deserialize(ref serialized)?, + }) } - fn emit>(ref self: upgradeable_cpt::ComponentState, event: S) { - let event: upgradeable_cpt::Event = core::traits::Into::into(event); - let mut contract = upgradeable_cpt::HasComponent::get_contract_mut(ref self); - ContractStateEventEmitter::emit(ref contract, Event::UpgradeableEvent(event)); +} +impl StoreIDojoInitSafeDispatcher of starknet::Store:: { + fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { + let contract_address = starknet::Store::::read(address_domain, base)?; + starknet::SyscallResult::Ok( + IDojoInitSafeDispatcher { + contract_address, + } + ) + } + fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitSafeDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write(address_domain, base, value.contract_address)?; + starknet::SyscallResult::Ok(()) + } + fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { + let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; + starknet::SyscallResult::Ok( + IDojoInitSafeDispatcher { + contract_address, + } + ) + } + #[inline(always)] + fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitSafeDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; + starknet::SyscallResult::Ok(()) + } + #[inline(always)] + fn size() -> u8 { + starknet::Store::::size() + } +} + +#[derive(Drop, Copy)] +pub struct IDojoInitSafeDispatcherSubPointers { + pub contract_address: starknet::storage::StoragePointer, +} +impl IDojoInitSafeDispatcherSubPointersImpl of starknet::storage::SubPointers { + type SubPointersType = IDojoInitSafeDispatcherSubPointers; + fn sub_pointers(self: starknet::storage::StoragePointer) -> IDojoInitSafeDispatcherSubPointers { + let base_address = self.__storage_pointer_address__; + let mut current_offset = self.__storage_pointer_offset__; + let contract_address_value = starknet::storage::StoragePointer { + __storage_pointer_address__: base_address, + __storage_pointer_offset__: current_offset, + }; + IDojoInitSafeDispatcherSubPointers { + contract_address: contract_address_value, + } + } +} +#[derive(Drop, Copy)] +pub struct IDojoInitSafeDispatcherSubPointersMut { + pub contract_address: starknet::storage::StoragePointer>, +} +impl IDojoInitSafeDispatcherSubPointersMutImpl of starknet::storage::SubPointersMut { + type SubPointersType = IDojoInitSafeDispatcherSubPointersMut; + fn sub_pointers_mut(self: starknet::storage::StoragePointer>) -> IDojoInitSafeDispatcherSubPointersMut { + let base_address = self.__storage_pointer_address__; + let mut current_offset = self.__storage_pointer_offset__; + let contract_address_value = starknet::storage::StoragePointer { + __storage_pointer_address__: base_address, + __storage_pointer_offset__: current_offset, + }; + IDojoInitSafeDispatcherSubPointersMut { + contract_address: contract_address_value, + } } } impl StorageStorageBaseDrop of core::traits::Drop::; impl StorageStorageBaseCopy of core::traits::Copy::; impl StorageStorageBaseMutDrop of core::traits::Drop::; impl StorageStorageBaseMutCopy of core::traits::Copy::; +impl IDojoInitDispatcherSubPointersDrop of core::traits::Drop::; +impl IDojoInitDispatcherSubPointersCopy of core::traits::Copy::; +impl IDojoInitDispatcherSubPointersMutDrop of core::traits::Drop::; +impl IDojoInitDispatcherSubPointersMutCopy of core::traits::Copy::; +impl IDojoInitLibraryDispatcherSubPointersDrop of core::traits::Drop::; +impl IDojoInitLibraryDispatcherSubPointersCopy of core::traits::Copy::; +impl IDojoInitLibraryDispatcherSubPointersMutDrop of core::traits::Drop::; +impl IDojoInitLibraryDispatcherSubPointersMutCopy of core::traits::Copy::; +impl IDojoInitSafeLibraryDispatcherSubPointersDrop of core::traits::Drop::; +impl IDojoInitSafeLibraryDispatcherSubPointersCopy of core::traits::Copy::; +impl IDojoInitSafeLibraryDispatcherSubPointersMutDrop of core::traits::Drop::; +impl IDojoInitSafeLibraryDispatcherSubPointersMutCopy of core::traits::Copy::; +impl IDojoInitSafeDispatcherSubPointersDrop of core::traits::Drop::; +impl IDojoInitSafeDispatcherSubPointersCopy of core::traits::Copy::; +impl IDojoInitSafeDispatcherSubPointersMutDrop of core::traits::Drop::; +impl IDojoInitSafeDispatcherSubPointersMutCopy of core::traits::Copy::; } @@ -3485,21 +6257,128 @@ impl StorageStorageBaseMutCopy of core::traits::Copy::; } } - #[constructor] - fn constructor(ref self: ContractState) { - self.world_provider.initializer(); - } - - #[event] - #[derive(Drop, starknet::Event)] - enum Event { - UpgradeableEvent: upgradeable_cpt::Event, - WorldProviderEvent: world_provider_cpt::Event, - } -impl ActionDrop of core::traits::Drop::; - trait InternalNoContractState { - fn func1(world: IWorldDispatcher) -> felt252; + #[constructor] + fn constructor(ref self: ContractState) { + self.world_provider.initializer(); + } + +#[starknet::interface] +pub trait IDojoInit { + fn dojo_init(self: @ContractState); +} + +#[abi(embed_v0)] +pub impl IDojoInitImpl of IDojoInit { + fn dojo_init(self: @ContractState) { + if starknet::get_caller_address() != self.world_provider.world().contract_address { + core::panics::panic_with_byte_array( + @format!("Only the world can init contract `{}`, but caller is `{:?}`", + self.tag(), + starknet::get_caller_address(), + )); + } + } +} + + #[event] + #[derive(Drop, starknet::Event)] + enum Event { + UpgradeableEvent: upgradeable_cpt::Event, + WorldProviderEvent: world_provider_cpt::Event, + } +impl ActionDrop of core::traits::Drop::; + trait InternalNoContractState { + fn func1(world: IWorldDispatcher) -> felt252; + } +pub trait IDojoInitDispatcherTrait { + fn dojo_init(self: T); +} + +#[derive(Copy, Drop, starknet::Store, Serde)] +pub struct IDojoInitDispatcher { + pub contract_address: starknet::ContractAddress, +} + +impl IDojoInitDispatcherImpl of IDojoInitDispatcherTrait { + fn dojo_init(self: IDojoInitDispatcher) { + let mut __calldata__ = core::traits::Default::default(); + + let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( + self.contract_address, + selector!("dojo_init"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); + () + } + +} + +#[derive(Copy, Drop, starknet::Store, Serde)] +pub struct IDojoInitLibraryDispatcher { + pub class_hash: starknet::ClassHash, +} + +impl IDojoInitLibraryDispatcherImpl of IDojoInitDispatcherTrait { + fn dojo_init(self: IDojoInitLibraryDispatcher) { + let mut __calldata__ = core::traits::Default::default(); + + let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( + self.class_hash, + selector!("dojo_init"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); + () + } + +} + +pub trait IDojoInitSafeDispatcherTrait { + #[unstable(feature: "safe_dispatcher")] + fn dojo_init(self: T) -> starknet::SyscallResult<()>; +} + +#[derive(Copy, Drop, starknet::Store, Serde)] +pub struct IDojoInitSafeLibraryDispatcher { + pub class_hash: starknet::ClassHash, +} + +impl IDojoInitSafeLibraryDispatcherImpl of IDojoInitSafeDispatcherTrait { + fn dojo_init(self: IDojoInitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { + let mut __calldata__ = core::traits::Default::default(); + + let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( + self.class_hash, + selector!("dojo_init"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = __dispatcher_return_data__?; + Result::Ok(()) + } + +} + + +#[derive(Copy, Drop, starknet::Store, Serde)] +pub struct IDojoInitSafeDispatcher { + pub contract_address: starknet::ContractAddress, +} + +impl IDojoInitSafeDispatcherImpl of IDojoInitSafeDispatcherTrait { + fn dojo_init(self: IDojoInitSafeDispatcher) -> starknet::SyscallResult<()> { + let mut __calldata__ = core::traits::Default::default(); + + let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( + self.contract_address, + selector!("dojo_init"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = __dispatcher_return_data__?; + Result::Ok(()) } + +} impl EventDrop of core::traits::Drop::; impl EventIsEvent of starknet::Event { fn append_keys_and_data( @@ -3934,6 +6813,24 @@ fn __wrapper__constructor(mut data: Span::) -> Span:: { core::array::ArrayTrait::span(@arr) } +#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] +fn __wrapper__IDojoInitImpl__dojo_init(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + IDojoInitImpl::dojo_init(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::array::ArrayTrait::span(@arr) +} + pub mod __external { pub use super::__wrapper__ContractImpl__name as name; @@ -3950,6 +6847,7 @@ pub mod __external { pub use super::__wrapper__TestNominalImpl__do_params_and_world_ref as do_params_and_world_ref; pub use super::__wrapper__TestNominalImpl__do_with_self as do_with_self; pub use super::__wrapper__TestNominalImpl__do_with_ref_self as do_with_ref_self; + pub use super::__wrapper__IDojoInitImpl__dojo_init as dojo_init; } pub mod __l1_handler { } @@ -4013,10 +6911,346 @@ impl HasComponentImpl_upgradeable_cpt of upgradeable_cpt::HasComponent; +impl IDojoInitDispatcherDrop of core::traits::Drop::; +impl IDojoInitDispatcherSerde of core::serde::Serde:: { + fn serialize(self: @IDojoInitDispatcher, ref output: core::array::Array) { + core::serde::Serde::serialize(self.contract_address, ref output) + } + fn deserialize(ref serialized: core::array::Span) -> core::option::Option { + core::option::Option::Some(IDojoInitDispatcher { + contract_address: core::serde::Serde::deserialize(ref serialized)?, + }) + } +} +impl StoreIDojoInitDispatcher of starknet::Store:: { + fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { + let contract_address = starknet::Store::::read(address_domain, base)?; + starknet::SyscallResult::Ok( + IDojoInitDispatcher { + contract_address, + } + ) + } + fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write(address_domain, base, value.contract_address)?; + starknet::SyscallResult::Ok(()) + } + fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { + let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; + starknet::SyscallResult::Ok( + IDojoInitDispatcher { + contract_address, + } + ) + } + #[inline(always)] + fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; + starknet::SyscallResult::Ok(()) + } + #[inline(always)] + fn size() -> u8 { + starknet::Store::::size() + } +} + +#[derive(Drop, Copy)] +pub struct IDojoInitDispatcherSubPointers { + pub contract_address: starknet::storage::StoragePointer, +} +impl IDojoInitDispatcherSubPointersImpl of starknet::storage::SubPointers { + type SubPointersType = IDojoInitDispatcherSubPointers; + fn sub_pointers(self: starknet::storage::StoragePointer) -> IDojoInitDispatcherSubPointers { + let base_address = self.__storage_pointer_address__; + let mut current_offset = self.__storage_pointer_offset__; + let contract_address_value = starknet::storage::StoragePointer { + __storage_pointer_address__: base_address, + __storage_pointer_offset__: current_offset, + }; + IDojoInitDispatcherSubPointers { + contract_address: contract_address_value, + } + } +} +#[derive(Drop, Copy)] +pub struct IDojoInitDispatcherSubPointersMut { + pub contract_address: starknet::storage::StoragePointer>, +} +impl IDojoInitDispatcherSubPointersMutImpl of starknet::storage::SubPointersMut { + type SubPointersType = IDojoInitDispatcherSubPointersMut; + fn sub_pointers_mut(self: starknet::storage::StoragePointer>) -> IDojoInitDispatcherSubPointersMut { + let base_address = self.__storage_pointer_address__; + let mut current_offset = self.__storage_pointer_offset__; + let contract_address_value = starknet::storage::StoragePointer { + __storage_pointer_address__: base_address, + __storage_pointer_offset__: current_offset, + }; + IDojoInitDispatcherSubPointersMut { + contract_address: contract_address_value, + } + } +} +impl IDojoInitLibraryDispatcherCopy of core::traits::Copy::; +impl IDojoInitLibraryDispatcherDrop of core::traits::Drop::; +impl IDojoInitLibraryDispatcherSerde of core::serde::Serde:: { + fn serialize(self: @IDojoInitLibraryDispatcher, ref output: core::array::Array) { + core::serde::Serde::serialize(self.class_hash, ref output) + } + fn deserialize(ref serialized: core::array::Span) -> core::option::Option { + core::option::Option::Some(IDojoInitLibraryDispatcher { + class_hash: core::serde::Serde::deserialize(ref serialized)?, + }) + } +} +impl StoreIDojoInitLibraryDispatcher of starknet::Store:: { + fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { + let class_hash = starknet::Store::::read(address_domain, base)?; + starknet::SyscallResult::Ok( + IDojoInitLibraryDispatcher { + class_hash, + } + ) + } + fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitLibraryDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write(address_domain, base, value.class_hash)?; + starknet::SyscallResult::Ok(()) + } + fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { + let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; + starknet::SyscallResult::Ok( + IDojoInitLibraryDispatcher { + class_hash, + } + ) + } + #[inline(always)] + fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitLibraryDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; + starknet::SyscallResult::Ok(()) + } + #[inline(always)] + fn size() -> u8 { + starknet::Store::::size() + } +} + +#[derive(Drop, Copy)] +pub struct IDojoInitLibraryDispatcherSubPointers { + pub class_hash: starknet::storage::StoragePointer, +} +impl IDojoInitLibraryDispatcherSubPointersImpl of starknet::storage::SubPointers { + type SubPointersType = IDojoInitLibraryDispatcherSubPointers; + fn sub_pointers(self: starknet::storage::StoragePointer) -> IDojoInitLibraryDispatcherSubPointers { + let base_address = self.__storage_pointer_address__; + let mut current_offset = self.__storage_pointer_offset__; + let class_hash_value = starknet::storage::StoragePointer { + __storage_pointer_address__: base_address, + __storage_pointer_offset__: current_offset, + }; + IDojoInitLibraryDispatcherSubPointers { + class_hash: class_hash_value, + } + } +} +#[derive(Drop, Copy)] +pub struct IDojoInitLibraryDispatcherSubPointersMut { + pub class_hash: starknet::storage::StoragePointer>, +} +impl IDojoInitLibraryDispatcherSubPointersMutImpl of starknet::storage::SubPointersMut { + type SubPointersType = IDojoInitLibraryDispatcherSubPointersMut; + fn sub_pointers_mut(self: starknet::storage::StoragePointer>) -> IDojoInitLibraryDispatcherSubPointersMut { + let base_address = self.__storage_pointer_address__; + let mut current_offset = self.__storage_pointer_offset__; + let class_hash_value = starknet::storage::StoragePointer { + __storage_pointer_address__: base_address, + __storage_pointer_offset__: current_offset, + }; + IDojoInitLibraryDispatcherSubPointersMut { + class_hash: class_hash_value, + } + } +} +impl IDojoInitSafeLibraryDispatcherCopy of core::traits::Copy::; +impl IDojoInitSafeLibraryDispatcherDrop of core::traits::Drop::; +impl IDojoInitSafeLibraryDispatcherSerde of core::serde::Serde:: { + fn serialize(self: @IDojoInitSafeLibraryDispatcher, ref output: core::array::Array) { + core::serde::Serde::serialize(self.class_hash, ref output) + } + fn deserialize(ref serialized: core::array::Span) -> core::option::Option { + core::option::Option::Some(IDojoInitSafeLibraryDispatcher { + class_hash: core::serde::Serde::deserialize(ref serialized)?, + }) + } +} +impl StoreIDojoInitSafeLibraryDispatcher of starknet::Store:: { + fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { + let class_hash = starknet::Store::::read(address_domain, base)?; + starknet::SyscallResult::Ok( + IDojoInitSafeLibraryDispatcher { + class_hash, + } + ) + } + fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write(address_domain, base, value.class_hash)?; + starknet::SyscallResult::Ok(()) + } + fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { + let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; + starknet::SyscallResult::Ok( + IDojoInitSafeLibraryDispatcher { + class_hash, + } + ) + } + #[inline(always)] + fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; + starknet::SyscallResult::Ok(()) + } + #[inline(always)] + fn size() -> u8 { + starknet::Store::::size() + } +} + +#[derive(Drop, Copy)] +pub struct IDojoInitSafeLibraryDispatcherSubPointers { + pub class_hash: starknet::storage::StoragePointer, +} +impl IDojoInitSafeLibraryDispatcherSubPointersImpl of starknet::storage::SubPointers { + type SubPointersType = IDojoInitSafeLibraryDispatcherSubPointers; + fn sub_pointers(self: starknet::storage::StoragePointer) -> IDojoInitSafeLibraryDispatcherSubPointers { + let base_address = self.__storage_pointer_address__; + let mut current_offset = self.__storage_pointer_offset__; + let class_hash_value = starknet::storage::StoragePointer { + __storage_pointer_address__: base_address, + __storage_pointer_offset__: current_offset, + }; + IDojoInitSafeLibraryDispatcherSubPointers { + class_hash: class_hash_value, + } + } +} +#[derive(Drop, Copy)] +pub struct IDojoInitSafeLibraryDispatcherSubPointersMut { + pub class_hash: starknet::storage::StoragePointer>, +} +impl IDojoInitSafeLibraryDispatcherSubPointersMutImpl of starknet::storage::SubPointersMut { + type SubPointersType = IDojoInitSafeLibraryDispatcherSubPointersMut; + fn sub_pointers_mut(self: starknet::storage::StoragePointer>) -> IDojoInitSafeLibraryDispatcherSubPointersMut { + let base_address = self.__storage_pointer_address__; + let mut current_offset = self.__storage_pointer_offset__; + let class_hash_value = starknet::storage::StoragePointer { + __storage_pointer_address__: base_address, + __storage_pointer_offset__: current_offset, + }; + IDojoInitSafeLibraryDispatcherSubPointersMut { + class_hash: class_hash_value, + } + } +} +impl IDojoInitSafeDispatcherCopy of core::traits::Copy::; +impl IDojoInitSafeDispatcherDrop of core::traits::Drop::; +impl IDojoInitSafeDispatcherSerde of core::serde::Serde:: { + fn serialize(self: @IDojoInitSafeDispatcher, ref output: core::array::Array) { + core::serde::Serde::serialize(self.contract_address, ref output) + } + fn deserialize(ref serialized: core::array::Span) -> core::option::Option { + core::option::Option::Some(IDojoInitSafeDispatcher { + contract_address: core::serde::Serde::deserialize(ref serialized)?, + }) + } +} +impl StoreIDojoInitSafeDispatcher of starknet::Store:: { + fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { + let contract_address = starknet::Store::::read(address_domain, base)?; + starknet::SyscallResult::Ok( + IDojoInitSafeDispatcher { + contract_address, + } + ) + } + fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitSafeDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write(address_domain, base, value.contract_address)?; + starknet::SyscallResult::Ok(()) + } + fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { + let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; + starknet::SyscallResult::Ok( + IDojoInitSafeDispatcher { + contract_address, + } + ) + } + #[inline(always)] + fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitSafeDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; + starknet::SyscallResult::Ok(()) + } + #[inline(always)] + fn size() -> u8 { + starknet::Store::::size() + } +} + +#[derive(Drop, Copy)] +pub struct IDojoInitSafeDispatcherSubPointers { + pub contract_address: starknet::storage::StoragePointer, +} +impl IDojoInitSafeDispatcherSubPointersImpl of starknet::storage::SubPointers { + type SubPointersType = IDojoInitSafeDispatcherSubPointers; + fn sub_pointers(self: starknet::storage::StoragePointer) -> IDojoInitSafeDispatcherSubPointers { + let base_address = self.__storage_pointer_address__; + let mut current_offset = self.__storage_pointer_offset__; + let contract_address_value = starknet::storage::StoragePointer { + __storage_pointer_address__: base_address, + __storage_pointer_offset__: current_offset, + }; + IDojoInitSafeDispatcherSubPointers { + contract_address: contract_address_value, + } + } +} +#[derive(Drop, Copy)] +pub struct IDojoInitSafeDispatcherSubPointersMut { + pub contract_address: starknet::storage::StoragePointer>, +} +impl IDojoInitSafeDispatcherSubPointersMutImpl of starknet::storage::SubPointersMut { + type SubPointersType = IDojoInitSafeDispatcherSubPointersMut; + fn sub_pointers_mut(self: starknet::storage::StoragePointer>) -> IDojoInitSafeDispatcherSubPointersMut { + let base_address = self.__storage_pointer_address__; + let mut current_offset = self.__storage_pointer_offset__; + let contract_address_value = starknet::storage::StoragePointer { + __storage_pointer_address__: base_address, + __storage_pointer_offset__: current_offset, + }; + IDojoInitSafeDispatcherSubPointersMut { + contract_address: contract_address_value, + } + } +} impl StorageStorageBaseDrop of core::traits::Drop::; impl StorageStorageBaseCopy of core::traits::Copy::; impl StorageStorageBaseMutDrop of core::traits::Drop::; impl StorageStorageBaseMutCopy of core::traits::Copy::; +impl IDojoInitDispatcherSubPointersDrop of core::traits::Drop::; +impl IDojoInitDispatcherSubPointersCopy of core::traits::Copy::; +impl IDojoInitDispatcherSubPointersMutDrop of core::traits::Drop::; +impl IDojoInitDispatcherSubPointersMutCopy of core::traits::Copy::; +impl IDojoInitLibraryDispatcherSubPointersDrop of core::traits::Drop::; +impl IDojoInitLibraryDispatcherSubPointersCopy of core::traits::Copy::; +impl IDojoInitLibraryDispatcherSubPointersMutDrop of core::traits::Drop::; +impl IDojoInitLibraryDispatcherSubPointersMutCopy of core::traits::Copy::; +impl IDojoInitSafeLibraryDispatcherSubPointersDrop of core::traits::Drop::; +impl IDojoInitSafeLibraryDispatcherSubPointersCopy of core::traits::Copy::; +impl IDojoInitSafeLibraryDispatcherSubPointersMutDrop of core::traits::Drop::; +impl IDojoInitSafeLibraryDispatcherSubPointersMutCopy of core::traits::Copy::; +impl IDojoInitSafeDispatcherSubPointersDrop of core::traits::Drop::; +impl IDojoInitSafeDispatcherSubPointersCopy of core::traits::Copy::; +impl IDojoInitSafeDispatcherSubPointersMutDrop of core::traits::Drop::; +impl IDojoInitSafeDispatcherSubPointersMutCopy of core::traits::Copy::; } @@ -4071,12 +7305,119 @@ impl StorageStorageBaseMutCopy of core::traits::Copy::; self.world_provider.initializer(); } +#[starknet::interface] +pub trait IDojoInit { + fn dojo_init(self: @ContractState); +} + +#[abi(embed_v0)] +pub impl IDojoInitImpl of IDojoInit { + fn dojo_init(self: @ContractState) { + if starknet::get_caller_address() != self.world_provider.world().contract_address { + core::panics::panic_with_byte_array( + @format!("Only the world can init contract `{}`, but caller is `{:?}`", + self.tag(), + starknet::get_caller_address(), + )); + } + } +} + #[event] #[derive(Drop, starknet::Event)] enum Event { UpgradeableEvent: upgradeable_cpt::Event, WorldProviderEvent: world_provider_cpt::Event, } +pub trait IDojoInitDispatcherTrait { + fn dojo_init(self: T); +} + +#[derive(Copy, Drop, starknet::Store, Serde)] +pub struct IDojoInitDispatcher { + pub contract_address: starknet::ContractAddress, +} + +impl IDojoInitDispatcherImpl of IDojoInitDispatcherTrait { + fn dojo_init(self: IDojoInitDispatcher) { + let mut __calldata__ = core::traits::Default::default(); + + let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( + self.contract_address, + selector!("dojo_init"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); + () + } + +} + +#[derive(Copy, Drop, starknet::Store, Serde)] +pub struct IDojoInitLibraryDispatcher { + pub class_hash: starknet::ClassHash, +} + +impl IDojoInitLibraryDispatcherImpl of IDojoInitDispatcherTrait { + fn dojo_init(self: IDojoInitLibraryDispatcher) { + let mut __calldata__ = core::traits::Default::default(); + + let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( + self.class_hash, + selector!("dojo_init"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); + () + } + +} + +pub trait IDojoInitSafeDispatcherTrait { + #[unstable(feature: "safe_dispatcher")] + fn dojo_init(self: T) -> starknet::SyscallResult<()>; +} + +#[derive(Copy, Drop, starknet::Store, Serde)] +pub struct IDojoInitSafeLibraryDispatcher { + pub class_hash: starknet::ClassHash, +} + +impl IDojoInitSafeLibraryDispatcherImpl of IDojoInitSafeDispatcherTrait { + fn dojo_init(self: IDojoInitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { + let mut __calldata__ = core::traits::Default::default(); + + let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( + self.class_hash, + selector!("dojo_init"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = __dispatcher_return_data__?; + Result::Ok(()) + } + +} + + +#[derive(Copy, Drop, starknet::Store, Serde)] +pub struct IDojoInitSafeDispatcher { + pub contract_address: starknet::ContractAddress, +} + +impl IDojoInitSafeDispatcherImpl of IDojoInitSafeDispatcherTrait { + fn dojo_init(self: IDojoInitSafeDispatcher) -> starknet::SyscallResult<()> { + let mut __calldata__ = core::traits::Default::default(); + + let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( + self.contract_address, + selector!("dojo_init"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = __dispatcher_return_data__?; + Result::Ok(()) + } + +} impl EventDrop of core::traits::Drop::; impl EventIsEvent of starknet::Event { fn append_keys_and_data( @@ -4349,81 +7690,436 @@ fn __wrapper__constructor(mut data: Span::) -> Span:: { core::array::ArrayTrait::span(@arr) } - -pub mod __external { - pub use super::__wrapper__ContractImpl__name as name; - pub use super::__wrapper__ContractImpl__namespace as namespace; - pub use super::__wrapper__ContractImpl__tag as tag; - pub use super::__wrapper__ContractImpl__name_hash as name_hash; - pub use super::__wrapper__ContractImpl__namespace_hash as namespace_hash; - pub use super::__wrapper__ContractImpl__selector as selector; +#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] +fn __wrapper__IDojoInitImpl__dojo_init(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + IDojoInitImpl::dojo_init(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::array::ArrayTrait::span(@arr) +} + + +pub mod __external { + pub use super::__wrapper__ContractImpl__name as name; + pub use super::__wrapper__ContractImpl__namespace as namespace; + pub use super::__wrapper__ContractImpl__tag as tag; + pub use super::__wrapper__ContractImpl__name_hash as name_hash; + pub use super::__wrapper__ContractImpl__namespace_hash as namespace_hash; + pub use super::__wrapper__ContractImpl__selector as selector; + pub use super::__wrapper__IDojoInitImpl__dojo_init as dojo_init; +} +pub mod __l1_handler { +} +pub mod __constructor { + pub use super::__wrapper__constructor as constructor; +} + impl ContractStateEventEmitter of starknet::event::EventEmitter< + ContractState, Event + > { + fn emit>( + ref self: ContractState, event: S + ) { + let event: Event = core::traits::Into::into(event); + let mut keys = Default::::default(); + let mut data = Default::::default(); + starknet::Event::append_keys_and_data(@event, ref keys, ref data); + starknet::SyscallResultTrait::unwrap_syscall( + starknet::syscalls::emit_event_syscall( + core::array::ArrayTrait::span(@keys), + core::array::ArrayTrait::span(@data), + ) + ) + } + } + +impl HasComponentImpl_world_provider_cpt of world_provider_cpt::HasComponent { + fn get_component(self: @ContractState) -> @world_provider_cpt::ComponentState { + @world_provider_cpt::unsafe_new_component_state::() + } + fn get_component_mut(ref self: ContractState) -> world_provider_cpt::ComponentState { + world_provider_cpt::unsafe_new_component_state::() + } + fn get_contract(self: @world_provider_cpt::ComponentState) -> @ContractState { + @unsafe_new_contract_state() + } + fn get_contract_mut(ref self: world_provider_cpt::ComponentState) -> ContractState { + unsafe_new_contract_state() + } + fn emit>(ref self: world_provider_cpt::ComponentState, event: S) { + let event: world_provider_cpt::Event = core::traits::Into::into(event); + let mut contract = world_provider_cpt::HasComponent::get_contract_mut(ref self); + ContractStateEventEmitter::emit(ref contract, Event::WorldProviderEvent(event)); + } +} +impl HasComponentImpl_upgradeable_cpt of upgradeable_cpt::HasComponent { + fn get_component(self: @ContractState) -> @upgradeable_cpt::ComponentState { + @upgradeable_cpt::unsafe_new_component_state::() + } + fn get_component_mut(ref self: ContractState) -> upgradeable_cpt::ComponentState { + upgradeable_cpt::unsafe_new_component_state::() + } + fn get_contract(self: @upgradeable_cpt::ComponentState) -> @ContractState { + @unsafe_new_contract_state() + } + fn get_contract_mut(ref self: upgradeable_cpt::ComponentState) -> ContractState { + unsafe_new_contract_state() + } + fn emit>(ref self: upgradeable_cpt::ComponentState, event: S) { + let event: upgradeable_cpt::Event = core::traits::Into::into(event); + let mut contract = upgradeable_cpt::HasComponent::get_contract_mut(ref self); + ContractStateEventEmitter::emit(ref contract, Event::UpgradeableEvent(event)); + } +} +impl IDojoInitDispatcherCopy of core::traits::Copy::; +impl IDojoInitDispatcherDrop of core::traits::Drop::; +impl IDojoInitDispatcherSerde of core::serde::Serde:: { + fn serialize(self: @IDojoInitDispatcher, ref output: core::array::Array) { + core::serde::Serde::serialize(self.contract_address, ref output) + } + fn deserialize(ref serialized: core::array::Span) -> core::option::Option { + core::option::Option::Some(IDojoInitDispatcher { + contract_address: core::serde::Serde::deserialize(ref serialized)?, + }) + } +} +impl StoreIDojoInitDispatcher of starknet::Store:: { + fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { + let contract_address = starknet::Store::::read(address_domain, base)?; + starknet::SyscallResult::Ok( + IDojoInitDispatcher { + contract_address, + } + ) + } + fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write(address_domain, base, value.contract_address)?; + starknet::SyscallResult::Ok(()) + } + fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { + let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; + starknet::SyscallResult::Ok( + IDojoInitDispatcher { + contract_address, + } + ) + } + #[inline(always)] + fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; + starknet::SyscallResult::Ok(()) + } + #[inline(always)] + fn size() -> u8 { + starknet::Store::::size() + } +} + +#[derive(Drop, Copy)] +pub struct IDojoInitDispatcherSubPointers { + pub contract_address: starknet::storage::StoragePointer, +} +impl IDojoInitDispatcherSubPointersImpl of starknet::storage::SubPointers { + type SubPointersType = IDojoInitDispatcherSubPointers; + fn sub_pointers(self: starknet::storage::StoragePointer) -> IDojoInitDispatcherSubPointers { + let base_address = self.__storage_pointer_address__; + let mut current_offset = self.__storage_pointer_offset__; + let contract_address_value = starknet::storage::StoragePointer { + __storage_pointer_address__: base_address, + __storage_pointer_offset__: current_offset, + }; + IDojoInitDispatcherSubPointers { + contract_address: contract_address_value, + } + } +} +#[derive(Drop, Copy)] +pub struct IDojoInitDispatcherSubPointersMut { + pub contract_address: starknet::storage::StoragePointer>, +} +impl IDojoInitDispatcherSubPointersMutImpl of starknet::storage::SubPointersMut { + type SubPointersType = IDojoInitDispatcherSubPointersMut; + fn sub_pointers_mut(self: starknet::storage::StoragePointer>) -> IDojoInitDispatcherSubPointersMut { + let base_address = self.__storage_pointer_address__; + let mut current_offset = self.__storage_pointer_offset__; + let contract_address_value = starknet::storage::StoragePointer { + __storage_pointer_address__: base_address, + __storage_pointer_offset__: current_offset, + }; + IDojoInitDispatcherSubPointersMut { + contract_address: contract_address_value, + } + } +} +impl IDojoInitLibraryDispatcherCopy of core::traits::Copy::; +impl IDojoInitLibraryDispatcherDrop of core::traits::Drop::; +impl IDojoInitLibraryDispatcherSerde of core::serde::Serde:: { + fn serialize(self: @IDojoInitLibraryDispatcher, ref output: core::array::Array) { + core::serde::Serde::serialize(self.class_hash, ref output) + } + fn deserialize(ref serialized: core::array::Span) -> core::option::Option { + core::option::Option::Some(IDojoInitLibraryDispatcher { + class_hash: core::serde::Serde::deserialize(ref serialized)?, + }) + } +} +impl StoreIDojoInitLibraryDispatcher of starknet::Store:: { + fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { + let class_hash = starknet::Store::::read(address_domain, base)?; + starknet::SyscallResult::Ok( + IDojoInitLibraryDispatcher { + class_hash, + } + ) + } + fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitLibraryDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write(address_domain, base, value.class_hash)?; + starknet::SyscallResult::Ok(()) + } + fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { + let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; + starknet::SyscallResult::Ok( + IDojoInitLibraryDispatcher { + class_hash, + } + ) + } + #[inline(always)] + fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitLibraryDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; + starknet::SyscallResult::Ok(()) + } + #[inline(always)] + fn size() -> u8 { + starknet::Store::::size() + } +} + +#[derive(Drop, Copy)] +pub struct IDojoInitLibraryDispatcherSubPointers { + pub class_hash: starknet::storage::StoragePointer, } -pub mod __l1_handler { +impl IDojoInitLibraryDispatcherSubPointersImpl of starknet::storage::SubPointers { + type SubPointersType = IDojoInitLibraryDispatcherSubPointers; + fn sub_pointers(self: starknet::storage::StoragePointer) -> IDojoInitLibraryDispatcherSubPointers { + let base_address = self.__storage_pointer_address__; + let mut current_offset = self.__storage_pointer_offset__; + let class_hash_value = starknet::storage::StoragePointer { + __storage_pointer_address__: base_address, + __storage_pointer_offset__: current_offset, + }; + IDojoInitLibraryDispatcherSubPointers { + class_hash: class_hash_value, + } + } } -pub mod __constructor { - pub use super::__wrapper__constructor as constructor; +#[derive(Drop, Copy)] +pub struct IDojoInitLibraryDispatcherSubPointersMut { + pub class_hash: starknet::storage::StoragePointer>, } - impl ContractStateEventEmitter of starknet::event::EventEmitter< - ContractState, Event - > { - fn emit>( - ref self: ContractState, event: S - ) { - let event: Event = core::traits::Into::into(event); - let mut keys = Default::::default(); - let mut data = Default::::default(); - starknet::Event::append_keys_and_data(@event, ref keys, ref data); - starknet::SyscallResultTrait::unwrap_syscall( - starknet::syscalls::emit_event_syscall( - core::array::ArrayTrait::span(@keys), - core::array::ArrayTrait::span(@data), - ) - ) +impl IDojoInitLibraryDispatcherSubPointersMutImpl of starknet::storage::SubPointersMut { + type SubPointersType = IDojoInitLibraryDispatcherSubPointersMut; + fn sub_pointers_mut(self: starknet::storage::StoragePointer>) -> IDojoInitLibraryDispatcherSubPointersMut { + let base_address = self.__storage_pointer_address__; + let mut current_offset = self.__storage_pointer_offset__; + let class_hash_value = starknet::storage::StoragePointer { + __storage_pointer_address__: base_address, + __storage_pointer_offset__: current_offset, + }; + IDojoInitLibraryDispatcherSubPointersMut { + class_hash: class_hash_value, } } - -impl HasComponentImpl_world_provider_cpt of world_provider_cpt::HasComponent { - fn get_component(self: @ContractState) -> @world_provider_cpt::ComponentState { - @world_provider_cpt::unsafe_new_component_state::() +} +impl IDojoInitSafeLibraryDispatcherCopy of core::traits::Copy::; +impl IDojoInitSafeLibraryDispatcherDrop of core::traits::Drop::; +impl IDojoInitSafeLibraryDispatcherSerde of core::serde::Serde:: { + fn serialize(self: @IDojoInitSafeLibraryDispatcher, ref output: core::array::Array) { + core::serde::Serde::serialize(self.class_hash, ref output) } - fn get_component_mut(ref self: ContractState) -> world_provider_cpt::ComponentState { - world_provider_cpt::unsafe_new_component_state::() + fn deserialize(ref serialized: core::array::Span) -> core::option::Option { + core::option::Option::Some(IDojoInitSafeLibraryDispatcher { + class_hash: core::serde::Serde::deserialize(ref serialized)?, + }) } - fn get_contract(self: @world_provider_cpt::ComponentState) -> @ContractState { - @unsafe_new_contract_state() +} +impl StoreIDojoInitSafeLibraryDispatcher of starknet::Store:: { + fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { + let class_hash = starknet::Store::::read(address_domain, base)?; + starknet::SyscallResult::Ok( + IDojoInitSafeLibraryDispatcher { + class_hash, + } + ) } - fn get_contract_mut(ref self: world_provider_cpt::ComponentState) -> ContractState { - unsafe_new_contract_state() + fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write(address_domain, base, value.class_hash)?; + starknet::SyscallResult::Ok(()) } - fn emit>(ref self: world_provider_cpt::ComponentState, event: S) { - let event: world_provider_cpt::Event = core::traits::Into::into(event); - let mut contract = world_provider_cpt::HasComponent::get_contract_mut(ref self); - ContractStateEventEmitter::emit(ref contract, Event::WorldProviderEvent(event)); + fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { + let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; + starknet::SyscallResult::Ok( + IDojoInitSafeLibraryDispatcher { + class_hash, + } + ) + } + #[inline(always)] + fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; + starknet::SyscallResult::Ok(()) + } + #[inline(always)] + fn size() -> u8 { + starknet::Store::::size() } } -impl HasComponentImpl_upgradeable_cpt of upgradeable_cpt::HasComponent { - fn get_component(self: @ContractState) -> @upgradeable_cpt::ComponentState { - @upgradeable_cpt::unsafe_new_component_state::() + +#[derive(Drop, Copy)] +pub struct IDojoInitSafeLibraryDispatcherSubPointers { + pub class_hash: starknet::storage::StoragePointer, +} +impl IDojoInitSafeLibraryDispatcherSubPointersImpl of starknet::storage::SubPointers { + type SubPointersType = IDojoInitSafeLibraryDispatcherSubPointers; + fn sub_pointers(self: starknet::storage::StoragePointer) -> IDojoInitSafeLibraryDispatcherSubPointers { + let base_address = self.__storage_pointer_address__; + let mut current_offset = self.__storage_pointer_offset__; + let class_hash_value = starknet::storage::StoragePointer { + __storage_pointer_address__: base_address, + __storage_pointer_offset__: current_offset, + }; + IDojoInitSafeLibraryDispatcherSubPointers { + class_hash: class_hash_value, + } } - fn get_component_mut(ref self: ContractState) -> upgradeable_cpt::ComponentState { - upgradeable_cpt::unsafe_new_component_state::() +} +#[derive(Drop, Copy)] +pub struct IDojoInitSafeLibraryDispatcherSubPointersMut { + pub class_hash: starknet::storage::StoragePointer>, +} +impl IDojoInitSafeLibraryDispatcherSubPointersMutImpl of starknet::storage::SubPointersMut { + type SubPointersType = IDojoInitSafeLibraryDispatcherSubPointersMut; + fn sub_pointers_mut(self: starknet::storage::StoragePointer>) -> IDojoInitSafeLibraryDispatcherSubPointersMut { + let base_address = self.__storage_pointer_address__; + let mut current_offset = self.__storage_pointer_offset__; + let class_hash_value = starknet::storage::StoragePointer { + __storage_pointer_address__: base_address, + __storage_pointer_offset__: current_offset, + }; + IDojoInitSafeLibraryDispatcherSubPointersMut { + class_hash: class_hash_value, + } } - fn get_contract(self: @upgradeable_cpt::ComponentState) -> @ContractState { - @unsafe_new_contract_state() +} +impl IDojoInitSafeDispatcherCopy of core::traits::Copy::; +impl IDojoInitSafeDispatcherDrop of core::traits::Drop::; +impl IDojoInitSafeDispatcherSerde of core::serde::Serde:: { + fn serialize(self: @IDojoInitSafeDispatcher, ref output: core::array::Array) { + core::serde::Serde::serialize(self.contract_address, ref output) } - fn get_contract_mut(ref self: upgradeable_cpt::ComponentState) -> ContractState { - unsafe_new_contract_state() + fn deserialize(ref serialized: core::array::Span) -> core::option::Option { + core::option::Option::Some(IDojoInitSafeDispatcher { + contract_address: core::serde::Serde::deserialize(ref serialized)?, + }) } - fn emit>(ref self: upgradeable_cpt::ComponentState, event: S) { - let event: upgradeable_cpt::Event = core::traits::Into::into(event); - let mut contract = upgradeable_cpt::HasComponent::get_contract_mut(ref self); - ContractStateEventEmitter::emit(ref contract, Event::UpgradeableEvent(event)); +} +impl StoreIDojoInitSafeDispatcher of starknet::Store:: { + fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { + let contract_address = starknet::Store::::read(address_domain, base)?; + starknet::SyscallResult::Ok( + IDojoInitSafeDispatcher { + contract_address, + } + ) + } + fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitSafeDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write(address_domain, base, value.contract_address)?; + starknet::SyscallResult::Ok(()) + } + fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { + let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; + starknet::SyscallResult::Ok( + IDojoInitSafeDispatcher { + contract_address, + } + ) + } + #[inline(always)] + fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitSafeDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; + starknet::SyscallResult::Ok(()) + } + #[inline(always)] + fn size() -> u8 { + starknet::Store::::size() + } +} + +#[derive(Drop, Copy)] +pub struct IDojoInitSafeDispatcherSubPointers { + pub contract_address: starknet::storage::StoragePointer, +} +impl IDojoInitSafeDispatcherSubPointersImpl of starknet::storage::SubPointers { + type SubPointersType = IDojoInitSafeDispatcherSubPointers; + fn sub_pointers(self: starknet::storage::StoragePointer) -> IDojoInitSafeDispatcherSubPointers { + let base_address = self.__storage_pointer_address__; + let mut current_offset = self.__storage_pointer_offset__; + let contract_address_value = starknet::storage::StoragePointer { + __storage_pointer_address__: base_address, + __storage_pointer_offset__: current_offset, + }; + IDojoInitSafeDispatcherSubPointers { + contract_address: contract_address_value, + } + } +} +#[derive(Drop, Copy)] +pub struct IDojoInitSafeDispatcherSubPointersMut { + pub contract_address: starknet::storage::StoragePointer>, +} +impl IDojoInitSafeDispatcherSubPointersMutImpl of starknet::storage::SubPointersMut { + type SubPointersType = IDojoInitSafeDispatcherSubPointersMut; + fn sub_pointers_mut(self: starknet::storage::StoragePointer>) -> IDojoInitSafeDispatcherSubPointersMut { + let base_address = self.__storage_pointer_address__; + let mut current_offset = self.__storage_pointer_offset__; + let contract_address_value = starknet::storage::StoragePointer { + __storage_pointer_address__: base_address, + __storage_pointer_offset__: current_offset, + }; + IDojoInitSafeDispatcherSubPointersMut { + contract_address: contract_address_value, + } } } impl StorageStorageBaseDrop of core::traits::Drop::; impl StorageStorageBaseCopy of core::traits::Copy::; impl StorageStorageBaseMutDrop of core::traits::Drop::; impl StorageStorageBaseMutCopy of core::traits::Copy::; +impl IDojoInitDispatcherSubPointersDrop of core::traits::Drop::; +impl IDojoInitDispatcherSubPointersCopy of core::traits::Copy::; +impl IDojoInitDispatcherSubPointersMutDrop of core::traits::Drop::; +impl IDojoInitDispatcherSubPointersMutCopy of core::traits::Copy::; +impl IDojoInitLibraryDispatcherSubPointersDrop of core::traits::Drop::; +impl IDojoInitLibraryDispatcherSubPointersCopy of core::traits::Copy::; +impl IDojoInitLibraryDispatcherSubPointersMutDrop of core::traits::Drop::; +impl IDojoInitLibraryDispatcherSubPointersMutCopy of core::traits::Copy::; +impl IDojoInitSafeLibraryDispatcherSubPointersDrop of core::traits::Drop::; +impl IDojoInitSafeLibraryDispatcherSubPointersCopy of core::traits::Copy::; +impl IDojoInitSafeLibraryDispatcherSubPointersMutDrop of core::traits::Drop::; +impl IDojoInitSafeLibraryDispatcherSubPointersMutCopy of core::traits::Copy::; +impl IDojoInitSafeDispatcherSubPointersDrop of core::traits::Drop::; +impl IDojoInitSafeDispatcherSubPointersCopy of core::traits::Copy::; +impl IDojoInitSafeDispatcherSubPointersMutDrop of core::traits::Drop::; +impl IDojoInitSafeDispatcherSubPointersMutCopy of core::traits::Copy::; } @@ -4472,18 +8168,125 @@ impl StorageStorageBaseMutCopy of core::traits::Copy::; } } - - #[constructor] - fn constructor(ref self: ContractState) { - self.world_provider.initializer(); - } - - #[event] - #[derive(Drop, starknet::Event)] - enum Event { - UpgradeableEvent: upgradeable_cpt::Event, - WorldProviderEvent: world_provider_cpt::Event, - } + + #[constructor] + fn constructor(ref self: ContractState) { + self.world_provider.initializer(); + } + +#[starknet::interface] +pub trait IDojoInit { + fn dojo_init(self: @ContractState); +} + +#[abi(embed_v0)] +pub impl IDojoInitImpl of IDojoInit { + fn dojo_init(self: @ContractState) { + if starknet::get_caller_address() != self.world_provider.world().contract_address { + core::panics::panic_with_byte_array( + @format!("Only the world can init contract `{}`, but caller is `{:?}`", + self.tag(), + starknet::get_caller_address(), + )); + } + } +} + + #[event] + #[derive(Drop, starknet::Event)] + enum Event { + UpgradeableEvent: upgradeable_cpt::Event, + WorldProviderEvent: world_provider_cpt::Event, + } +pub trait IDojoInitDispatcherTrait { + fn dojo_init(self: T); +} + +#[derive(Copy, Drop, starknet::Store, Serde)] +pub struct IDojoInitDispatcher { + pub contract_address: starknet::ContractAddress, +} + +impl IDojoInitDispatcherImpl of IDojoInitDispatcherTrait { + fn dojo_init(self: IDojoInitDispatcher) { + let mut __calldata__ = core::traits::Default::default(); + + let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( + self.contract_address, + selector!("dojo_init"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); + () + } + +} + +#[derive(Copy, Drop, starknet::Store, Serde)] +pub struct IDojoInitLibraryDispatcher { + pub class_hash: starknet::ClassHash, +} + +impl IDojoInitLibraryDispatcherImpl of IDojoInitDispatcherTrait { + fn dojo_init(self: IDojoInitLibraryDispatcher) { + let mut __calldata__ = core::traits::Default::default(); + + let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( + self.class_hash, + selector!("dojo_init"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); + () + } + +} + +pub trait IDojoInitSafeDispatcherTrait { + #[unstable(feature: "safe_dispatcher")] + fn dojo_init(self: T) -> starknet::SyscallResult<()>; +} + +#[derive(Copy, Drop, starknet::Store, Serde)] +pub struct IDojoInitSafeLibraryDispatcher { + pub class_hash: starknet::ClassHash, +} + +impl IDojoInitSafeLibraryDispatcherImpl of IDojoInitSafeDispatcherTrait { + fn dojo_init(self: IDojoInitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { + let mut __calldata__ = core::traits::Default::default(); + + let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( + self.class_hash, + selector!("dojo_init"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = __dispatcher_return_data__?; + Result::Ok(()) + } + +} + + +#[derive(Copy, Drop, starknet::Store, Serde)] +pub struct IDojoInitSafeDispatcher { + pub contract_address: starknet::ContractAddress, +} + +impl IDojoInitSafeDispatcherImpl of IDojoInitSafeDispatcherTrait { + fn dojo_init(self: IDojoInitSafeDispatcher) -> starknet::SyscallResult<()> { + let mut __calldata__ = core::traits::Default::default(); + + let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( + self.contract_address, + selector!("dojo_init"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = __dispatcher_return_data__?; + Result::Ok(()) + } + +} impl EventDrop of core::traits::Drop::; impl EventIsEvent of starknet::Event { fn append_keys_and_data( @@ -4753,6 +8556,24 @@ fn __wrapper__constructor(mut data: Span::) -> Span:: { core::array::ArrayTrait::span(@arr) } +#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] +fn __wrapper__IDojoInitImpl__dojo_init(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + IDojoInitImpl::dojo_init(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::array::ArrayTrait::span(@arr) +} + pub mod __external { pub use super::__wrapper__ContractImpl__name as name; @@ -4761,6 +8582,7 @@ pub mod __external { pub use super::__wrapper__ContractImpl__name_hash as name_hash; pub use super::__wrapper__ContractImpl__namespace_hash as namespace_hash; pub use super::__wrapper__ContractImpl__selector as selector; + pub use super::__wrapper__IDojoInitImpl__dojo_init as dojo_init; } pub mod __l1_handler { } @@ -4824,10 +8646,346 @@ impl HasComponentImpl_upgradeable_cpt of upgradeable_cpt::HasComponent; +impl IDojoInitDispatcherDrop of core::traits::Drop::; +impl IDojoInitDispatcherSerde of core::serde::Serde:: { + fn serialize(self: @IDojoInitDispatcher, ref output: core::array::Array) { + core::serde::Serde::serialize(self.contract_address, ref output) + } + fn deserialize(ref serialized: core::array::Span) -> core::option::Option { + core::option::Option::Some(IDojoInitDispatcher { + contract_address: core::serde::Serde::deserialize(ref serialized)?, + }) + } +} +impl StoreIDojoInitDispatcher of starknet::Store:: { + fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { + let contract_address = starknet::Store::::read(address_domain, base)?; + starknet::SyscallResult::Ok( + IDojoInitDispatcher { + contract_address, + } + ) + } + fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write(address_domain, base, value.contract_address)?; + starknet::SyscallResult::Ok(()) + } + fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { + let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; + starknet::SyscallResult::Ok( + IDojoInitDispatcher { + contract_address, + } + ) + } + #[inline(always)] + fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; + starknet::SyscallResult::Ok(()) + } + #[inline(always)] + fn size() -> u8 { + starknet::Store::::size() + } +} + +#[derive(Drop, Copy)] +pub struct IDojoInitDispatcherSubPointers { + pub contract_address: starknet::storage::StoragePointer, +} +impl IDojoInitDispatcherSubPointersImpl of starknet::storage::SubPointers { + type SubPointersType = IDojoInitDispatcherSubPointers; + fn sub_pointers(self: starknet::storage::StoragePointer) -> IDojoInitDispatcherSubPointers { + let base_address = self.__storage_pointer_address__; + let mut current_offset = self.__storage_pointer_offset__; + let contract_address_value = starknet::storage::StoragePointer { + __storage_pointer_address__: base_address, + __storage_pointer_offset__: current_offset, + }; + IDojoInitDispatcherSubPointers { + contract_address: contract_address_value, + } + } +} +#[derive(Drop, Copy)] +pub struct IDojoInitDispatcherSubPointersMut { + pub contract_address: starknet::storage::StoragePointer>, +} +impl IDojoInitDispatcherSubPointersMutImpl of starknet::storage::SubPointersMut { + type SubPointersType = IDojoInitDispatcherSubPointersMut; + fn sub_pointers_mut(self: starknet::storage::StoragePointer>) -> IDojoInitDispatcherSubPointersMut { + let base_address = self.__storage_pointer_address__; + let mut current_offset = self.__storage_pointer_offset__; + let contract_address_value = starknet::storage::StoragePointer { + __storage_pointer_address__: base_address, + __storage_pointer_offset__: current_offset, + }; + IDojoInitDispatcherSubPointersMut { + contract_address: contract_address_value, + } + } +} +impl IDojoInitLibraryDispatcherCopy of core::traits::Copy::; +impl IDojoInitLibraryDispatcherDrop of core::traits::Drop::; +impl IDojoInitLibraryDispatcherSerde of core::serde::Serde:: { + fn serialize(self: @IDojoInitLibraryDispatcher, ref output: core::array::Array) { + core::serde::Serde::serialize(self.class_hash, ref output) + } + fn deserialize(ref serialized: core::array::Span) -> core::option::Option { + core::option::Option::Some(IDojoInitLibraryDispatcher { + class_hash: core::serde::Serde::deserialize(ref serialized)?, + }) + } +} +impl StoreIDojoInitLibraryDispatcher of starknet::Store:: { + fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { + let class_hash = starknet::Store::::read(address_domain, base)?; + starknet::SyscallResult::Ok( + IDojoInitLibraryDispatcher { + class_hash, + } + ) + } + fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitLibraryDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write(address_domain, base, value.class_hash)?; + starknet::SyscallResult::Ok(()) + } + fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { + let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; + starknet::SyscallResult::Ok( + IDojoInitLibraryDispatcher { + class_hash, + } + ) + } + #[inline(always)] + fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitLibraryDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; + starknet::SyscallResult::Ok(()) + } + #[inline(always)] + fn size() -> u8 { + starknet::Store::::size() + } +} + +#[derive(Drop, Copy)] +pub struct IDojoInitLibraryDispatcherSubPointers { + pub class_hash: starknet::storage::StoragePointer, +} +impl IDojoInitLibraryDispatcherSubPointersImpl of starknet::storage::SubPointers { + type SubPointersType = IDojoInitLibraryDispatcherSubPointers; + fn sub_pointers(self: starknet::storage::StoragePointer) -> IDojoInitLibraryDispatcherSubPointers { + let base_address = self.__storage_pointer_address__; + let mut current_offset = self.__storage_pointer_offset__; + let class_hash_value = starknet::storage::StoragePointer { + __storage_pointer_address__: base_address, + __storage_pointer_offset__: current_offset, + }; + IDojoInitLibraryDispatcherSubPointers { + class_hash: class_hash_value, + } + } +} +#[derive(Drop, Copy)] +pub struct IDojoInitLibraryDispatcherSubPointersMut { + pub class_hash: starknet::storage::StoragePointer>, +} +impl IDojoInitLibraryDispatcherSubPointersMutImpl of starknet::storage::SubPointersMut { + type SubPointersType = IDojoInitLibraryDispatcherSubPointersMut; + fn sub_pointers_mut(self: starknet::storage::StoragePointer>) -> IDojoInitLibraryDispatcherSubPointersMut { + let base_address = self.__storage_pointer_address__; + let mut current_offset = self.__storage_pointer_offset__; + let class_hash_value = starknet::storage::StoragePointer { + __storage_pointer_address__: base_address, + __storage_pointer_offset__: current_offset, + }; + IDojoInitLibraryDispatcherSubPointersMut { + class_hash: class_hash_value, + } + } +} +impl IDojoInitSafeLibraryDispatcherCopy of core::traits::Copy::; +impl IDojoInitSafeLibraryDispatcherDrop of core::traits::Drop::; +impl IDojoInitSafeLibraryDispatcherSerde of core::serde::Serde:: { + fn serialize(self: @IDojoInitSafeLibraryDispatcher, ref output: core::array::Array) { + core::serde::Serde::serialize(self.class_hash, ref output) + } + fn deserialize(ref serialized: core::array::Span) -> core::option::Option { + core::option::Option::Some(IDojoInitSafeLibraryDispatcher { + class_hash: core::serde::Serde::deserialize(ref serialized)?, + }) + } +} +impl StoreIDojoInitSafeLibraryDispatcher of starknet::Store:: { + fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { + let class_hash = starknet::Store::::read(address_domain, base)?; + starknet::SyscallResult::Ok( + IDojoInitSafeLibraryDispatcher { + class_hash, + } + ) + } + fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write(address_domain, base, value.class_hash)?; + starknet::SyscallResult::Ok(()) + } + fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { + let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; + starknet::SyscallResult::Ok( + IDojoInitSafeLibraryDispatcher { + class_hash, + } + ) + } + #[inline(always)] + fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; + starknet::SyscallResult::Ok(()) + } + #[inline(always)] + fn size() -> u8 { + starknet::Store::::size() + } +} + +#[derive(Drop, Copy)] +pub struct IDojoInitSafeLibraryDispatcherSubPointers { + pub class_hash: starknet::storage::StoragePointer, +} +impl IDojoInitSafeLibraryDispatcherSubPointersImpl of starknet::storage::SubPointers { + type SubPointersType = IDojoInitSafeLibraryDispatcherSubPointers; + fn sub_pointers(self: starknet::storage::StoragePointer) -> IDojoInitSafeLibraryDispatcherSubPointers { + let base_address = self.__storage_pointer_address__; + let mut current_offset = self.__storage_pointer_offset__; + let class_hash_value = starknet::storage::StoragePointer { + __storage_pointer_address__: base_address, + __storage_pointer_offset__: current_offset, + }; + IDojoInitSafeLibraryDispatcherSubPointers { + class_hash: class_hash_value, + } + } +} +#[derive(Drop, Copy)] +pub struct IDojoInitSafeLibraryDispatcherSubPointersMut { + pub class_hash: starknet::storage::StoragePointer>, +} +impl IDojoInitSafeLibraryDispatcherSubPointersMutImpl of starknet::storage::SubPointersMut { + type SubPointersType = IDojoInitSafeLibraryDispatcherSubPointersMut; + fn sub_pointers_mut(self: starknet::storage::StoragePointer>) -> IDojoInitSafeLibraryDispatcherSubPointersMut { + let base_address = self.__storage_pointer_address__; + let mut current_offset = self.__storage_pointer_offset__; + let class_hash_value = starknet::storage::StoragePointer { + __storage_pointer_address__: base_address, + __storage_pointer_offset__: current_offset, + }; + IDojoInitSafeLibraryDispatcherSubPointersMut { + class_hash: class_hash_value, + } + } +} +impl IDojoInitSafeDispatcherCopy of core::traits::Copy::; +impl IDojoInitSafeDispatcherDrop of core::traits::Drop::; +impl IDojoInitSafeDispatcherSerde of core::serde::Serde:: { + fn serialize(self: @IDojoInitSafeDispatcher, ref output: core::array::Array) { + core::serde::Serde::serialize(self.contract_address, ref output) + } + fn deserialize(ref serialized: core::array::Span) -> core::option::Option { + core::option::Option::Some(IDojoInitSafeDispatcher { + contract_address: core::serde::Serde::deserialize(ref serialized)?, + }) + } +} +impl StoreIDojoInitSafeDispatcher of starknet::Store:: { + fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { + let contract_address = starknet::Store::::read(address_domain, base)?; + starknet::SyscallResult::Ok( + IDojoInitSafeDispatcher { + contract_address, + } + ) + } + fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitSafeDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write(address_domain, base, value.contract_address)?; + starknet::SyscallResult::Ok(()) + } + fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { + let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; + starknet::SyscallResult::Ok( + IDojoInitSafeDispatcher { + contract_address, + } + ) + } + #[inline(always)] + fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitSafeDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; + starknet::SyscallResult::Ok(()) + } + #[inline(always)] + fn size() -> u8 { + starknet::Store::::size() + } +} + +#[derive(Drop, Copy)] +pub struct IDojoInitSafeDispatcherSubPointers { + pub contract_address: starknet::storage::StoragePointer, +} +impl IDojoInitSafeDispatcherSubPointersImpl of starknet::storage::SubPointers { + type SubPointersType = IDojoInitSafeDispatcherSubPointers; + fn sub_pointers(self: starknet::storage::StoragePointer) -> IDojoInitSafeDispatcherSubPointers { + let base_address = self.__storage_pointer_address__; + let mut current_offset = self.__storage_pointer_offset__; + let contract_address_value = starknet::storage::StoragePointer { + __storage_pointer_address__: base_address, + __storage_pointer_offset__: current_offset, + }; + IDojoInitSafeDispatcherSubPointers { + contract_address: contract_address_value, + } + } +} +#[derive(Drop, Copy)] +pub struct IDojoInitSafeDispatcherSubPointersMut { + pub contract_address: starknet::storage::StoragePointer>, +} +impl IDojoInitSafeDispatcherSubPointersMutImpl of starknet::storage::SubPointersMut { + type SubPointersType = IDojoInitSafeDispatcherSubPointersMut; + fn sub_pointers_mut(self: starknet::storage::StoragePointer>) -> IDojoInitSafeDispatcherSubPointersMut { + let base_address = self.__storage_pointer_address__; + let mut current_offset = self.__storage_pointer_offset__; + let contract_address_value = starknet::storage::StoragePointer { + __storage_pointer_address__: base_address, + __storage_pointer_offset__: current_offset, + }; + IDojoInitSafeDispatcherSubPointersMut { + contract_address: contract_address_value, + } + } +} impl StorageStorageBaseDrop of core::traits::Drop::; impl StorageStorageBaseCopy of core::traits::Copy::; impl StorageStorageBaseMutDrop of core::traits::Drop::; impl StorageStorageBaseMutCopy of core::traits::Copy::; +impl IDojoInitDispatcherSubPointersDrop of core::traits::Drop::; +impl IDojoInitDispatcherSubPointersCopy of core::traits::Copy::; +impl IDojoInitDispatcherSubPointersMutDrop of core::traits::Drop::; +impl IDojoInitDispatcherSubPointersMutCopy of core::traits::Copy::; +impl IDojoInitLibraryDispatcherSubPointersDrop of core::traits::Drop::; +impl IDojoInitLibraryDispatcherSubPointersCopy of core::traits::Copy::; +impl IDojoInitLibraryDispatcherSubPointersMutDrop of core::traits::Drop::; +impl IDojoInitLibraryDispatcherSubPointersMutCopy of core::traits::Copy::; +impl IDojoInitSafeLibraryDispatcherSubPointersDrop of core::traits::Drop::; +impl IDojoInitSafeLibraryDispatcherSubPointersCopy of core::traits::Copy::; +impl IDojoInitSafeLibraryDispatcherSubPointersMutDrop of core::traits::Drop::; +impl IDojoInitSafeLibraryDispatcherSubPointersMutCopy of core::traits::Copy::; +impl IDojoInitSafeDispatcherSubPointersDrop of core::traits::Drop::; +impl IDojoInitSafeDispatcherSubPointersCopy of core::traits::Copy::; +impl IDojoInitSafeDispatcherSubPointersMutDrop of core::traits::Drop::; +impl IDojoInitSafeDispatcherSubPointersMutCopy of core::traits::Copy::; } pub trait IEmptyTraitDispatcherTrait { diff --git a/crates/types/src/world.rs b/crates/types/src/world.rs index 0b1d9a7..16e922a 100644 --- a/crates/types/src/world.rs +++ b/crates/types/src/world.rs @@ -60,12 +60,52 @@ impl WorldContractReader

{ } } #[derive(Clone, serde::Serialize, serde::Deserialize, PartialEq, Debug)] +pub struct ContractInitialized { + pub selector: starknet::core::types::Felt, + pub init_calldata: Vec, +} +impl cainome::cairo_serde::CairoSerde for ContractInitialized { + type RustType = Self; + const SERIALIZED_SIZE: std::option::Option = None; + #[inline] + fn cairo_serialized_size(__rust: &Self::RustType) -> usize { + let mut __size = 0; + __size += starknet::core::types::Felt::cairo_serialized_size(&__rust.selector); + __size += Vec::::cairo_serialized_size(&__rust.init_calldata); + __size + } + fn cairo_serialize(__rust: &Self::RustType) -> Vec { + let mut __out: Vec = vec![]; + __out.extend(starknet::core::types::Felt::cairo_serialize( + &__rust.selector, + )); + __out.extend(Vec::::cairo_serialize( + &__rust.init_calldata, + )); + __out + } + fn cairo_deserialize( + __felts: &[starknet::core::types::Felt], + __offset: usize, + ) -> cainome::cairo_serde::Result { + let mut __offset = __offset; + let selector = starknet::core::types::Felt::cairo_deserialize(__felts, __offset)?; + __offset += starknet::core::types::Felt::cairo_serialized_size(&selector); + let init_calldata = + Vec::::cairo_deserialize(__felts, __offset)?; + __offset += Vec::::cairo_serialized_size(&init_calldata); + Ok(ContractInitialized { + selector, + init_calldata, + }) + } +} +#[derive(Clone, serde::Serialize, serde::Deserialize, PartialEq, Debug)] pub struct ContractRegistered { pub selector: starknet::core::types::Felt, pub address: cainome::cairo_serde::ContractAddress, pub class_hash: cainome::cairo_serde::ClassHash, pub salt: starknet::core::types::Felt, - pub constructor_calldata: Vec, } impl cainome::cairo_serde::CairoSerde for ContractRegistered { type RustType = Self; @@ -77,8 +117,6 @@ impl cainome::cairo_serde::CairoSerde for ContractRegistered { __size += cainome::cairo_serde::ContractAddress::cairo_serialized_size(&__rust.address); __size += cainome::cairo_serde::ClassHash::cairo_serialized_size(&__rust.class_hash); __size += starknet::core::types::Felt::cairo_serialized_size(&__rust.salt); - __size += - Vec::::cairo_serialized_size(&__rust.constructor_calldata); __size } fn cairo_serialize(__rust: &Self::RustType) -> Vec { @@ -93,9 +131,6 @@ impl cainome::cairo_serde::CairoSerde for ContractRegistered { &__rust.class_hash, )); __out.extend(starknet::core::types::Felt::cairo_serialize(&__rust.salt)); - __out.extend(Vec::::cairo_serialize( - &__rust.constructor_calldata, - )); __out } fn cairo_deserialize( @@ -111,16 +146,11 @@ impl cainome::cairo_serde::CairoSerde for ContractRegistered { __offset += cainome::cairo_serde::ClassHash::cairo_serialized_size(&class_hash); let salt = starknet::core::types::Felt::cairo_deserialize(__felts, __offset)?; __offset += starknet::core::types::Felt::cairo_serialized_size(&salt); - let constructor_calldata = - Vec::::cairo_deserialize(__felts, __offset)?; - __offset += - Vec::::cairo_serialized_size(&constructor_calldata); Ok(ContractRegistered { selector, address, class_hash, salt, - constructor_calldata, }) } } @@ -965,6 +995,7 @@ pub enum Event { ModelUpgraded(ModelUpgraded), EventUpgraded(EventUpgraded), ContractUpgraded(ContractUpgraded), + ContractInitialized(ContractInitialized), EventEmitted(EventEmitted), MetadataUpdate(MetadataUpdate), StoreSetRecord(StoreSetRecord), @@ -989,6 +1020,7 @@ impl cainome::cairo_serde::CairoSerde for Event { Event::ModelUpgraded(val) => ModelUpgraded::cairo_serialized_size(val) + 1, Event::EventUpgraded(val) => EventUpgraded::cairo_serialized_size(val) + 1, Event::ContractUpgraded(val) => ContractUpgraded::cairo_serialized_size(val) + 1, + Event::ContractInitialized(val) => ContractInitialized::cairo_serialized_size(val) + 1, Event::EventEmitted(val) => EventEmitted::cairo_serialized_size(val) + 1, Event::MetadataUpdate(val) => MetadataUpdate::cairo_serialized_size(val) + 1, Event::StoreSetRecord(val) => StoreSetRecord::cairo_serialized_size(val) + 1, @@ -1056,51 +1088,57 @@ impl cainome::cairo_serde::CairoSerde for Event { temp.extend(ContractUpgraded::cairo_serialize(val)); temp } - Event::EventEmitted(val) => { + Event::ContractInitialized(val) => { let mut temp = vec![]; temp.extend(usize::cairo_serialize(&9usize)); + temp.extend(ContractInitialized::cairo_serialize(val)); + temp + } + Event::EventEmitted(val) => { + let mut temp = vec![]; + temp.extend(usize::cairo_serialize(&10usize)); temp.extend(EventEmitted::cairo_serialize(val)); temp } Event::MetadataUpdate(val) => { let mut temp = vec![]; - temp.extend(usize::cairo_serialize(&10usize)); + temp.extend(usize::cairo_serialize(&11usize)); temp.extend(MetadataUpdate::cairo_serialize(val)); temp } Event::StoreSetRecord(val) => { let mut temp = vec![]; - temp.extend(usize::cairo_serialize(&11usize)); + temp.extend(usize::cairo_serialize(&12usize)); temp.extend(StoreSetRecord::cairo_serialize(val)); temp } Event::StoreUpdateRecord(val) => { let mut temp = vec![]; - temp.extend(usize::cairo_serialize(&12usize)); + temp.extend(usize::cairo_serialize(&13usize)); temp.extend(StoreUpdateRecord::cairo_serialize(val)); temp } Event::StoreUpdateMember(val) => { let mut temp = vec![]; - temp.extend(usize::cairo_serialize(&13usize)); + temp.extend(usize::cairo_serialize(&14usize)); temp.extend(StoreUpdateMember::cairo_serialize(val)); temp } Event::StoreDelRecord(val) => { let mut temp = vec![]; - temp.extend(usize::cairo_serialize(&14usize)); + temp.extend(usize::cairo_serialize(&15usize)); temp.extend(StoreDelRecord::cairo_serialize(val)); temp } Event::WriterUpdated(val) => { let mut temp = vec![]; - temp.extend(usize::cairo_serialize(&15usize)); + temp.extend(usize::cairo_serialize(&16usize)); temp.extend(WriterUpdated::cairo_serialize(val)); temp } Event::OwnerUpdated(val) => { let mut temp = vec![]; - temp.extend(usize::cairo_serialize(&16usize)); + temp.extend(usize::cairo_serialize(&17usize)); temp.extend(OwnerUpdated::cairo_serialize(val)); temp } @@ -1147,33 +1185,36 @@ impl cainome::cairo_serde::CairoSerde for Event { 8usize => Ok(Event::ContractUpgraded( ContractUpgraded::cairo_deserialize(__felts, __offset + 1)?, )), - 9usize => Ok(Event::EventEmitted(EventEmitted::cairo_deserialize( + 9usize => Ok(Event::ContractInitialized( + ContractInitialized::cairo_deserialize(__felts, __offset + 1)?, + )), + 10usize => Ok(Event::EventEmitted(EventEmitted::cairo_deserialize( __felts, __offset + 1, )?)), - 10usize => Ok(Event::MetadataUpdate(MetadataUpdate::cairo_deserialize( + 11usize => Ok(Event::MetadataUpdate(MetadataUpdate::cairo_deserialize( __felts, __offset + 1, )?)), - 11usize => Ok(Event::StoreSetRecord(StoreSetRecord::cairo_deserialize( + 12usize => Ok(Event::StoreSetRecord(StoreSetRecord::cairo_deserialize( __felts, __offset + 1, )?)), - 12usize => Ok(Event::StoreUpdateRecord( + 13usize => Ok(Event::StoreUpdateRecord( StoreUpdateRecord::cairo_deserialize(__felts, __offset + 1)?, )), - 13usize => Ok(Event::StoreUpdateMember( + 14usize => Ok(Event::StoreUpdateMember( StoreUpdateMember::cairo_deserialize(__felts, __offset + 1)?, )), - 14usize => Ok(Event::StoreDelRecord(StoreDelRecord::cairo_deserialize( + 15usize => Ok(Event::StoreDelRecord(StoreDelRecord::cairo_deserialize( __felts, __offset + 1, )?)), - 15usize => Ok(Event::WriterUpdated(WriterUpdated::cairo_deserialize( + 16usize => Ok(Event::WriterUpdated(WriterUpdated::cairo_deserialize( __felts, __offset + 1, )?)), - 16usize => Ok(Event::OwnerUpdated(OwnerUpdated::cairo_deserialize( + 17usize => Ok(Event::OwnerUpdated(OwnerUpdated::cairo_deserialize( __felts, __offset + 1, )?)), @@ -1466,26 +1507,11 @@ impl TryFrom for Event { } }; data_offset += starknet::core::types::Felt::cairo_serialized_size(&salt); - let constructor_calldata = match Vec::::cairo_deserialize( - &event.data, - data_offset, - ) { - Ok(v) => v, - Err(e) => { - return Err(format!( - "Could not deserialize field {} for {}: {:?}", - "constructor_calldata", "ContractRegistered", e - )); - } - }; - data_offset += - Vec::::cairo_serialized_size(&constructor_calldata); return Ok(Event::ContractRegistered(ContractRegistered { selector, address, class_hash, salt, - constructor_calldata, })); } let selector = event.keys[0]; @@ -1655,6 +1681,43 @@ impl TryFrom for Event { })); } let selector = event.keys[0]; + if selector + == starknet::core::utils::get_selector_from_name("ContractInitialized") + .unwrap_or_else(|_| panic!("Invalid selector for {}", "ContractInitialized")) + { + let mut key_offset = 0 + 1; + let mut data_offset = 0; + let selector = + match starknet::core::types::Felt::cairo_deserialize(&event.keys, key_offset) { + Ok(v) => v, + Err(e) => { + return Err(format!( + "Could not deserialize field {} for {}: {:?}", + "selector", "ContractInitialized", e + )); + } + }; + key_offset += starknet::core::types::Felt::cairo_serialized_size(&selector); + let init_calldata = match Vec::::cairo_deserialize( + &event.data, + data_offset, + ) { + Ok(v) => v, + Err(e) => { + return Err(format!( + "Could not deserialize field {} for {}: {:?}", + "init_calldata", "ContractInitialized", e + )); + } + }; + data_offset += + Vec::::cairo_serialized_size(&init_calldata); + return Ok(Event::ContractInitialized(ContractInitialized { + selector, + init_calldata, + })); + } + let selector = event.keys[0]; if selector == starknet::core::utils::get_selector_from_name("EventEmitted") .unwrap_or_else(|_| panic!("Invalid selector for {}", "EventEmitted")) @@ -2635,19 +2698,54 @@ impl WorldContract { } #[allow(clippy::ptr_arg)] #[allow(clippy::too_many_arguments)] + pub fn init_contract_getcall( + &self, + selector: &starknet::core::types::Felt, + init_calldata: &Vec, + ) -> starknet::core::types::Call { + use cainome::cairo_serde::CairoSerde; + let mut __calldata = vec![]; + __calldata.extend(starknet::core::types::Felt::cairo_serialize(selector)); + __calldata.extend(Vec::::cairo_serialize( + init_calldata, + )); + starknet::core::types::Call { + to: self.address, + selector: starknet::macros::selector!("init_contract"), + calldata: __calldata, + } + } + #[allow(clippy::ptr_arg)] + #[allow(clippy::too_many_arguments)] + pub fn init_contract( + &self, + selector: &starknet::core::types::Felt, + init_calldata: &Vec, + ) -> starknet::accounts::ExecutionV1 { + use cainome::cairo_serde::CairoSerde; + let mut __calldata = vec![]; + __calldata.extend(starknet::core::types::Felt::cairo_serialize(selector)); + __calldata.extend(Vec::::cairo_serialize( + init_calldata, + )); + let __call = starknet::core::types::Call { + to: self.address, + selector: starknet::macros::selector!("init_contract"), + calldata: __calldata, + }; + self.account.execute_v1(vec![__call]) + } + #[allow(clippy::ptr_arg)] + #[allow(clippy::too_many_arguments)] pub fn register_contract_getcall( &self, salt: &starknet::core::types::Felt, class_hash: &cainome::cairo_serde::ClassHash, - constructor_calldata: &Vec, ) -> starknet::core::types::Call { use cainome::cairo_serde::CairoSerde; let mut __calldata = vec![]; __calldata.extend(starknet::core::types::Felt::cairo_serialize(salt)); __calldata.extend(cainome::cairo_serde::ClassHash::cairo_serialize(class_hash)); - __calldata.extend(Vec::::cairo_serialize( - constructor_calldata, - )); starknet::core::types::Call { to: self.address, selector: starknet::macros::selector!("register_contract"), @@ -2660,15 +2758,11 @@ impl WorldContract { &self, salt: &starknet::core::types::Felt, class_hash: &cainome::cairo_serde::ClassHash, - constructor_calldata: &Vec, ) -> starknet::accounts::ExecutionV1 { use cainome::cairo_serde::CairoSerde; let mut __calldata = vec![]; __calldata.extend(starknet::core::types::Felt::cairo_serialize(salt)); __calldata.extend(cainome::cairo_serde::ClassHash::cairo_serialize(class_hash)); - __calldata.extend(Vec::::cairo_serialize( - constructor_calldata, - )); let __call = starknet::core::types::Call { to: self.address, selector: starknet::macros::selector!("register_contract"),