From 2f11ca3f4556b4f9bc162790d25862e76df09730 Mon Sep 17 00:00:00 2001 From: notV4l Date: Wed, 17 Jan 2024 18:53:20 +0100 Subject: [PATCH] revert prev commit & add missing impl & regen tests --- crates/dojo-core/src/world.cairo | 4 + crates/dojo-lang/src/contract.rs | 7 +- .../dojo-lang/src/manifest_test_data/manifest | 24 +++- crates/dojo-lang/src/plugin_test_data/system | 117 ++++++++++-------- crates/dojo-lang/src/semantics/test_data/get | 2 +- crates/torii/graphql/src/tests/mod.rs | 7 +- 6 files changed, 101 insertions(+), 60 deletions(-) diff --git a/crates/dojo-core/src/world.cairo b/crates/dojo-core/src/world.cairo index 687aa0b986..8f2e498b6f 100644 --- a/crates/dojo-core/src/world.cairo +++ b/crates/dojo-core/src/world.cairo @@ -55,6 +55,10 @@ trait IWorldProvider { fn world(self: @T) -> IWorldDispatcher; } +#[starknet::interface] +trait IDojoResourceProvider { + fn dojo_resource(self: @T) -> felt252; +} #[starknet::contract] mod world { diff --git a/crates/dojo-lang/src/contract.rs b/crates/dojo-lang/src/contract.rs index f55d603348..cef635d421 100644 --- a/crates/dojo-lang/src/contract.rs +++ b/crates/dojo-lang/src/contract.rs @@ -65,13 +65,16 @@ impl DojoContract { use dojo::world::IWorldDispatcher; use dojo::world::IWorldDispatcherTrait; use dojo::world::IWorldProvider; + use dojo::world::IDojoResourceProvider; component!(path: dojo::components::upgradeable::upgradeable, storage: \ upgradeable, event: UpgradeableEvent); #[abi(embed_v0)] - fn dojo_resource(self: @ContractState) -> felt252 { - '$name$' + impl DojoResourceProviderImpl of IDojoResourceProvider { + fn dojo_resource(self: @ContractState) -> felt252 { + '$name$' + } } #[abi(embed_v0)] diff --git a/crates/dojo-lang/src/manifest_test_data/manifest b/crates/dojo-lang/src/manifest_test_data/manifest index 351a9ea317..00f98974f8 100644 --- a/crates/dojo-lang/src/manifest_test_data/manifest +++ b/crates/dojo-lang/src/manifest_test_data/manifest @@ -955,8 +955,30 @@ test_manifest_file { "name": "dojo_examples::actions::actions", "address": null, - "class_hash": "0x2d0b29efea4f6ba1c3ad62e1031c3e388173e5b3961b0d946b88e9c4d583e91", + "class_hash": "0x52d3920cfb6eef13c2bcd2c04eb1d7b7123325da7f16bbeeb0f83b8b33c00f", "abi": [ + { + "type": "impl", + "name": "DojoResourceProviderImpl", + "interface_name": "dojo::world::IDojoResourceProvider" + }, + { + "type": "interface", + "name": "dojo::world::IDojoResourceProvider", + "items": [ + { + "type": "function", + "name": "dojo_resource", + "inputs": [], + "outputs": [ + { + "type": "core::felt252" + } + ], + "state_mutability": "view" + } + ] + }, { "type": "impl", "name": "WorldProviderImpl", diff --git a/crates/dojo-lang/src/plugin_test_data/system b/crates/dojo-lang/src/plugin_test_data/system index 667044c043..c4c0070362 100644 --- a/crates/dojo-lang/src/plugin_test_data/system +++ b/crates/dojo-lang/src/plugin_test_data/system @@ -241,207 +241,207 @@ error: Unsupported attribute. ^********^ error: Unknown inline item macro: 'component'. - --> test_src/lib.cairo[spawn]:9:21 + --> test_src/lib.cairo[spawn]:10:21 component!(path: dojo::components::upgradeable::upgradeable, storage: upgradeable, event: UpgradeableEvent); ^**********************************************************************************************************^ error: Unsupported attribute. - --> test_src/lib.cairo[spawn]:11:21 + --> test_src/lib.cairo[spawn]:12:21 #[abi(embed_v0)] ^**************^ error: Unsupported attribute. - --> test_src/lib.cairo[spawn]:16:21 + --> test_src/lib.cairo[spawn]:19:21 #[abi(embed_v0)] ^**************^ error: Unsupported attribute. - --> test_src/lib.cairo[spawn]:23:21 + --> test_src/lib.cairo[spawn]:26:21 #[abi(embed_v0)] ^**************^ error: Unsupported attribute. - --> test_src/lib.cairo[spawn]:33:13 + --> test_src/lib.cairo[spawn]:36:13 #[event] ^******^ error: Unsupported attribute. - --> test_src/lib.cairo[spawn]:39:13 + --> test_src/lib.cairo[spawn]:42:13 #[storage] ^********^ error: Unsupported attribute. - --> test_src/lib.cairo[spawn]:42:17 + --> test_src/lib.cairo[spawn]:45:17 #[substorage(v0)] ^***************^ error: Unknown inline item macro: 'component'. - --> test_src/lib.cairo[proxy]:9:21 + --> test_src/lib.cairo[proxy]:10:21 component!(path: dojo::components::upgradeable::upgradeable, storage: upgradeable, event: UpgradeableEvent); ^**********************************************************************************************************^ error: Unsupported attribute. - --> test_src/lib.cairo[proxy]:11:21 + --> test_src/lib.cairo[proxy]:12:21 #[abi(embed_v0)] ^**************^ error: Unsupported attribute. - --> test_src/lib.cairo[proxy]:16:21 + --> test_src/lib.cairo[proxy]:19:21 #[abi(embed_v0)] ^**************^ error: Unsupported attribute. - --> test_src/lib.cairo[proxy]:23:21 + --> test_src/lib.cairo[proxy]:26:21 #[abi(embed_v0)] ^**************^ error: Unsupported attribute. - --> test_src/lib.cairo[proxy]:30:13 + --> test_src/lib.cairo[proxy]:33:13 #[event] ^******^ error: Unsupported attribute. - --> test_src/lib.cairo[proxy]:36:13 + --> test_src/lib.cairo[proxy]:39:13 #[storage] ^********^ error: Unsupported attribute. - --> test_src/lib.cairo[proxy]:39:17 + --> test_src/lib.cairo[proxy]:42:17 #[substorage(v0)] ^***************^ error: Unknown inline item macro: 'component'. - --> test_src/lib.cairo[ctxnamed]:9:21 + --> test_src/lib.cairo[ctxnamed]:10:21 component!(path: dojo::components::upgradeable::upgradeable, storage: upgradeable, event: UpgradeableEvent); ^**********************************************************************************************************^ error: Unsupported attribute. - --> test_src/lib.cairo[ctxnamed]:11:21 + --> test_src/lib.cairo[ctxnamed]:12:21 #[abi(embed_v0)] ^**************^ error: Unsupported attribute. - --> test_src/lib.cairo[ctxnamed]:16:21 + --> test_src/lib.cairo[ctxnamed]:19:21 #[abi(embed_v0)] ^**************^ error: Unsupported attribute. - --> test_src/lib.cairo[ctxnamed]:23:21 + --> test_src/lib.cairo[ctxnamed]:26:21 #[abi(embed_v0)] ^**************^ error: Unsupported attribute. - --> test_src/lib.cairo[ctxnamed]:33:13 + --> test_src/lib.cairo[ctxnamed]:36:13 #[event] ^******^ error: Unsupported attribute. - --> test_src/lib.cairo[ctxnamed]:39:13 + --> test_src/lib.cairo[ctxnamed]:42:13 #[storage] ^********^ error: Unsupported attribute. - --> test_src/lib.cairo[ctxnamed]:42:17 + --> test_src/lib.cairo[ctxnamed]:45:17 #[substorage(v0)] ^***************^ error: Unknown inline item macro: 'component'. - --> test_src/lib.cairo[withevent]:9:21 + --> test_src/lib.cairo[withevent]:10:21 component!(path: dojo::components::upgradeable::upgradeable, storage: upgradeable, event: UpgradeableEvent); ^**********************************************************************************************************^ error: Unsupported attribute. - --> test_src/lib.cairo[withevent]:11:21 + --> test_src/lib.cairo[withevent]:12:21 #[abi(embed_v0)] ^**************^ error: Unsupported attribute. - --> test_src/lib.cairo[withevent]:16:21 + --> test_src/lib.cairo[withevent]:19:21 #[abi(embed_v0)] ^**************^ error: Unsupported attribute. - --> test_src/lib.cairo[withevent]:23:21 + --> test_src/lib.cairo[withevent]:26:21 #[abi(embed_v0)] ^**************^ error: Unsupported attribute. - --> test_src/lib.cairo[withevent]:27:13 + --> test_src/lib.cairo[withevent]:30:13 #[event] ^******^ error: Unsupported attribute. - --> test_src/lib.cairo[withevent]:39:5 + --> test_src/lib.cairo[withevent]:42:5 #[abi(embed_v0)] ^**************^ error: Unsupported attribute. - --> test_src/lib.cairo[withevent]:44:13 + --> test_src/lib.cairo[withevent]:47:13 #[storage] ^********^ error: Unsupported attribute. - --> test_src/lib.cairo[withevent]:47:17 + --> test_src/lib.cairo[withevent]:50:17 #[substorage(v0)] ^***************^ error: Unknown inline item macro: 'component'. - --> test_src/lib.cairo[withcomponent]:9:21 + --> test_src/lib.cairo[withcomponent]:10:21 component!(path: dojo::components::upgradeable::upgradeable, storage: upgradeable, event: UpgradeableEvent); ^**********************************************************************************************************^ error: Unsupported attribute. - --> test_src/lib.cairo[withcomponent]:11:21 + --> test_src/lib.cairo[withcomponent]:12:21 #[abi(embed_v0)] ^**************^ error: Unsupported attribute. - --> test_src/lib.cairo[withcomponent]:16:21 + --> test_src/lib.cairo[withcomponent]:19:21 #[abi(embed_v0)] ^**************^ error: Unsupported attribute. - --> test_src/lib.cairo[withcomponent]:23:21 + --> test_src/lib.cairo[withcomponent]:26:21 #[abi(embed_v0)] ^**************^ error: Unknown inline item macro: 'component'. - --> test_src/lib.cairo[withcomponent]:27:5 + --> test_src/lib.cairo[withcomponent]:30:5 component!(path: testcomponent1, storage: testcomponent1_storage, event: testcomponent1_event); ^*********************************************************************************************^ error: Unknown inline item macro: 'component'. - --> test_src/lib.cairo[withcomponent]:28:5 + --> test_src/lib.cairo[withcomponent]:31:5 component!(path: testcomponent2, storage: testcomponent2_storage, event: testcomponent2_event); ^*********************************************************************************************^ error: Unsupported attribute. - --> test_src/lib.cairo[withcomponent]:30:13 + --> test_src/lib.cairo[withcomponent]:33:13 #[storage] ^********^ error: Unsupported attribute. - --> test_src/lib.cairo[withcomponent]:33:17 + --> test_src/lib.cairo[withcomponent]:36:17 #[substorage(v0)] ^***************^ error: Unsupported attribute. - --> test_src/lib.cairo[withcomponent]:35:25 + --> test_src/lib.cairo[withcomponent]:38:25 #[substorage(v0)] ^***************^ error: Unsupported attribute. - --> test_src/lib.cairo[withcomponent]:37:9 + --> test_src/lib.cairo[withcomponent]:40:9 #[substorage(v0)] ^***************^ error: Unsupported attribute. - --> test_src/lib.cairo[withcomponent]:41:13 + --> test_src/lib.cairo[withcomponent]:44:13 #[event] ^******^ error: Unsupported attribute. - --> test_src/lib.cairo[withcomponent]:45:25 + --> test_src/lib.cairo[withcomponent]:48:25 #[flat] ^*****^ @@ -464,10 +464,13 @@ mod testcomponent2 { use dojo::world::IWorldDispatcher; use dojo::world::IWorldDispatcherTrait; use dojo::world::IWorldProvider; + use dojo::world::IDojoResourceProvider; #[abi(embed_v0)] - fn dojo_resource(self: @ContractState) -> felt252 { - 'spawn' + impl DojoResourceProviderImpl of IDojoResourceProvider { + fn dojo_resource(self: @ContractState) -> felt252 { + 'spawn' + } } #[abi(embed_v0)] @@ -509,10 +512,13 @@ impl EventDrop of core::traits::Drop::; use dojo::world::IWorldDispatcher; use dojo::world::IWorldDispatcherTrait; use dojo::world::IWorldProvider; + use dojo::world::IDojoResourceProvider; #[abi(embed_v0)] - fn dojo_resource(self: @ContractState) -> felt252 { - 'proxy' + impl DojoResourceProviderImpl of IDojoResourceProvider { + fn dojo_resource(self: @ContractState) -> felt252 { + 'proxy' + } } #[abi(embed_v0)] @@ -551,10 +557,13 @@ impl EventDrop of core::traits::Drop::; use dojo::world::IWorldDispatcher; use dojo::world::IWorldDispatcherTrait; use dojo::world::IWorldProvider; + use dojo::world::IDojoResourceProvider; #[abi(embed_v0)] - fn dojo_resource(self: @ContractState) -> felt252 { - 'ctxnamed' + impl DojoResourceProviderImpl of IDojoResourceProvider { + fn dojo_resource(self: @ContractState) -> felt252 { + 'ctxnamed' + } } #[abi(embed_v0)] @@ -596,10 +605,13 @@ impl EventDrop of core::traits::Drop::; use dojo::world::IWorldDispatcher; use dojo::world::IWorldDispatcherTrait; use dojo::world::IWorldProvider; + use dojo::world::IDojoResourceProvider; #[abi(embed_v0)] - fn dojo_resource(self: @ContractState) -> felt252 { - 'withevent' + impl DojoResourceProviderImpl of IDojoResourceProvider { + fn dojo_resource(self: @ContractState) -> felt252 { + 'withevent' + } } #[abi(embed_v0)] @@ -647,10 +659,13 @@ impl TestEventDrop of core::traits::Drop::; use dojo::world::IWorldDispatcher; use dojo::world::IWorldDispatcherTrait; use dojo::world::IWorldProvider; + use dojo::world::IDojoResourceProvider; #[abi(embed_v0)] - fn dojo_resource(self: @ContractState) -> felt252 { - 'withcomponent' + impl DojoResourceProviderImpl of IDojoResourceProvider { + fn dojo_resource(self: @ContractState) -> felt252 { + 'withcomponent' + } } #[abi(embed_v0)] diff --git a/crates/dojo-lang/src/semantics/test_data/get b/crates/dojo-lang/src/semantics/test_data/get index d8816cfa5e..ed614c0f7b 100644 --- a/crates/dojo-lang/src/semantics/test_data/get +++ b/crates/dojo-lang/src/semantics/test_data/get @@ -657,7 +657,7 @@ Block( ), Type( TypeId( - 328, + 462, ), ), ], diff --git a/crates/torii/graphql/src/tests/mod.rs b/crates/torii/graphql/src/tests/mod.rs index e3b5e79341..9d2c71e16f 100644 --- a/crates/torii/graphql/src/tests/mod.rs +++ b/crates/torii/graphql/src/tests/mod.rs @@ -271,11 +271,8 @@ pub async fn spinup_types_test() -> Result { Manifest::load_from_remote(&provider, migration.world_address().unwrap()).await.unwrap(); // Execute `create` and insert 10 records into storage - let records_contract = manifest - .contracts - .iter() - .find(|contract| contract.name.eq("types_test::contracts::records")) - .unwrap(); + let records_contract = + manifest.contracts.iter().find(|contract| contract.name.eq("records")).unwrap(); let InvokeTransactionResult { transaction_hash } = account .execute(vec![Call { calldata: vec![FieldElement::from_str("0xa").unwrap()],