diff --git a/etc/architecture/overview.md b/etc/architecture/overview.md new file mode 100644 index 00000000..2e7ece7b --- /dev/null +++ b/etc/architecture/overview.md @@ -0,0 +1,71 @@ +# Dojo.js Architecture Overview + +## High-Level Components + +Dojo.js is organized as a set of focused packages that cooperate to index, query, and interact with Dojo worlds on Starknet. + +- **@dojoengine/sdk** orchestrates Torii clients, message signing flows, and schema-aware queries for both web and node runtimes. +- **@dojoengine/core** exposes the `DojoProvider`, a thin Starknet RPC wrapper that performs direct world contract reads and invokes. +- **@dojoengine/grpc** supplies a rich gRPC client with streaming subscriptions and data mappers for Torii indexer interactions. +- **@dojoengine/internal** concentrates shared schema utilities, query builders, pagination helpers, and token tooling used by the SDK. +- **@dojoengine/state** and **@dojoengine/react** provide state management and UI bindings, enabling entity streaming and optimistic updates in applications. +- **Tooling packages** such as `@dojoengine/create-burner`, `@dojoengine/predeployed-connector`, and `@dojoengine/create-dojo` enhance developer experience with wallet utilities and project scaffolding. + +## Runtime Flow + +```mermaid +flowchart LR + subgraph OnChain + World[Dojo World Contracts] + end + + subgraph Indexer & Messaging + ToriiIndexer[Torii Service\nHTTP/WebSocket/gRPC] + end + + subgraph CoreClient + CoreProvider[@dojoengine/core\nRpcProvider & World ABI] + ToriiWasm[@dojoengine/torii-wasm\n+ torii-client shim] + GrpcClient[@dojoengine/grpc\nToriiGrpcClient] + Internal[@dojoengine/internal\nSchema & Query Toolkit] + SDK[@dojoengine/sdk\ninit/createSDK] + end + + subgraph App Integrations + StatePkg[@dojoengine/state\nZustand & RECS stores] + ReactPkg[@dojoengine/react\nHooks & RX bindings] + Burner[@dojoengine/create-burner\nLocal wallets] + Predeployed[@dojoengine/predeployed-connector\nInjected connector] + UtilsPkg[@dojoengine/utils] + end + + subgraph Tooling + Scaffolder[@dojoengine/create-dojo\nCLI scaffolds] + Examples[Examples & Templates] + end + + World -- events & state --> ToriiIndexer + CoreProvider -- invoke/call --> World + ToriiIndexer -- queries/subscriptions --> ToriiWasm + ToriiIndexer -- gRPC streams --> GrpcClient + ToriiWasm --> SDK + GrpcClient --> SDK + Internal --> SDK + SDK --> StatePkg + SDK --> ReactPkg + StatePkg --> ReactPkg + SDK --> Burner + SDK --> Predeployed + SDK --> UtilsPkg + Scaffolder --> Examples + Burner --> ReactPkg + Predeployed --> ReactPkg +``` + +## Key Responsibilities + +1. Torii indexes on-chain world events and exposes them via WASM bindings and gRPC streams for consumption by the SDK. +2. The SDK coordinates Torii clients, message signing, and schema-driven parsing to provide a cohesive developer surface. +3. `DojoProvider` gives direct Starknet RPC access when applications need to call world contracts outside the indexer path. +4. Application layers like React hooks and Zustand stores sit on top of the SDK to deliver real-time entity state to UIs. +5. Wallet tooling and scaffolding packages round out the developer workflow for building and testing Dojo-powered apps. diff --git a/etc/architecture/whats-next.md b/etc/architecture/whats-next.md new file mode 100644 index 00000000..7da85135 --- /dev/null +++ b/etc/architecture/whats-next.md @@ -0,0 +1,62 @@ +# What's Next for Dojo.js + +This roadmap captures the near-to-mid term architecture initiatives planned for the main branch. Each stream lists intent, key activities, and expected outcomes to inform prioritisation and sequencing. + +## 1. Revamped Type System + +- **Objective**: Replace the existing world/type plumbing with the new type system in `packages/core/src/types` to improve safety and compatibility with Cairo models. +- **Key Steps**: + 1. Audit current exports and downstream usage across `core`, `sdk`, `state`, and `react` packages. + 2. Implement adapters or codemods to bridge the new types with legacy consumers while migration is in progress. + 3. Expand compiler/test coverage to prevent regressions (e.g., schema parsing, manifests, provider actions). +- **Deliverables**: Updated type definitions, migration guide, comprehensive test suite for the new abstractions. + +## 2. Framework-Agnostic Application Bindings + +- **Objective**: Reduce React-specific hooks in favour of framework-agnostic bindings that can power multiple UI layers. +- **Key Steps**: + 1. Extract core data subscription logic (currently in `@dojoengine/react`) into reusable primitives (signals, observables, store interfaces). + 2. Provide thin React adapters while enabling alternative bindings (e.g., Solid, Vue, Svelte) to consume the same core APIs. + 3. Update examples and documentation to highlight the framework-neutral approach. +- **Deliverables**: Core binding package with React wrapper, updated samples, migration notes. + +## 3. Abstract Starknet.js Dependencies + +- **Objective**: Introduce an abstraction layer over Starknet.js so that downstream packages can swap providers or polyfill functionality. +- **Key Steps**: + 1. Identify all points where Starknet.js types/classes are imported directly (providers, accounts, signing flows). + 2. Define an interface-based contract (e.g., `IStarknetTransport`, `Signer`, `AccountAdapter`) and implement default Starknet.js adapters. + 3. Provide dependency injection hooks in SDK/provider constructors and document how to supply alternative transports. +- **Deliverables**: Adapter interfaces, default Starknet.js implementation, updated dependency guidelines. + +## 4. TanStack/DB Integration + +- **Objective**: Leverage TanStack DB for richer client-side entity persistence, caching, and querying. +- **Key Steps**: + 1. Experiment with a proof-of-concept mapping Torii entity snapshots into TanStack DB tables. + 2. Define schema generation rules based on Dojo manifests and integrate with state management. + 3. Expose opt-in APIs within the SDK or a companion package for consuming TanStack DB features. +- **Deliverables**: Prototype integration, API surface proposal, pilot example demonstrating offline/query benefits. + +## 5. Native gRPC Client Enhancements + +- **Objective**: Continue maturing the native gRPC client for reliability and feature completeness. +- **Key Steps**: + 1. Close remaining parity gaps with Torii WASM client (subscriptions, controllers, token operations). + 2. Harden connection lifecycle management (reconnects, backoff, streaming ergonomics). + 3. Ship performance benchmarks and cross-platform validation (Node, Bun, browser with WASM transport). +- **Deliverables**: Stable gRPC client API, resilience improvements, documentation and benchmarks. + +## 6. Frontend Observability Integrations + +- **Objective**: Provide opt-in hooks to plug observability tools (Sentry, PostHog, etc.) into Dojo.js-powered apps. +- **Key Steps**: + 1. Define instrumentation points (SDK events, subscription lifecycle, transaction workflows). + 2. Create lightweight adapters for popular observability providers with configuration patterns. + 3. Document best practices and privacy considerations for instrumenting on-chain interactions. +- **Deliverables**: Observability integration guide, reference adapters, example instrumentation snippets. + +## Cross-Cutting Considerations + +- Prioritise documentation and migration notes alongside each feature. +- Invest in automated tests and benchmarks as new abstractions are introduced to safeguard performance and developer experience. diff --git a/etc/knowledge-base.md b/etc/knowledge-base.md new file mode 100644 index 00000000..7ced89e1 --- /dev/null +++ b/etc/knowledge-base.md @@ -0,0 +1,13 @@ +# Dojo.js Knowledge Base + +## Architecture Snapshot (Main Branch) + +- Reference diagram: [docs/architecture/overview.md](architecture/overview.md) +- Highlights: + - `@dojoengine/sdk` connects Torii indexer clients, message signing, and schema parsing for app consumption. + - `@dojoengine/core` offers the `DojoProvider` Starknet RPC interface for direct world contract access. + - `@dojoengine/grpc` provides streaming access to Torii via the `ToriiGrpcClient` and related mappers. + - UI/state layers (`@dojoengine/state`, `@dojoengine/react`) build on the SDK for entity subscriptions and optimistic updates. + - Tooling packages (`create-burner`, `predeployed-connector`, `create-dojo`) streamline wallet setup and application scaffolding. + +_Last updated: 2025-09-25T13:27:58Z diff --git a/examples/example-vite-react-sdk/src/App.tsx b/examples/example-vite-react-sdk/src/App.tsx index 6eb6fd24..f09ed8df 100644 --- a/examples/example-vite-react-sdk/src/App.tsx +++ b/examples/example-vite-react-sdk/src/App.tsx @@ -12,6 +12,7 @@ import { WalletAccount } from "./wallet-account.tsx"; import { useSystemCalls } from "./useSystemCalls.ts"; import { Events } from "./events.tsx"; import { HistoricalEvents } from "./historical-events.tsx"; +import { dojoProvider } from "./types.ts"; /** * Main application component that provides game functionality and UI. @@ -20,10 +21,9 @@ import { HistoricalEvents } from "./historical-events.tsx"; * @param props.sdk - The Dojo SDK instance configured with the game schema */ function App() { - const { useDojoStore, client } = useDojoSDK(); + const { useDojoStore } = useDojoSDK(); const { account } = useAccount(); const entities = useDojoStore((state) => state.entities); - console.log(entities); const { spawn } = useSystemCalls(); @@ -117,10 +117,9 @@ function App() { className={`${col} h-12 w-12 bg-gray-600 rounded-full shadow-md active:shadow-inner active:bg-gray-500 focus:outline-none text-2xl font-bold text-gray-200`} key={idx} onClick={async () => { - await client.actions.move( - account!, - direction - ); + await dojoProvider.move(account!, { + direction: direction, + }); }} > {label} diff --git a/examples/example-vite-react-sdk/src/dojo_starter_dev.json b/examples/example-vite-react-sdk/src/dojo_starter_dev.json new file mode 100644 index 00000000..b00135cc --- /dev/null +++ b/examples/example-vite-react-sdk/src/dojo_starter_dev.json @@ -0,0 +1,3641 @@ +{ + "abi": [ + { + "type": "constructor", + "name": "constructor", + "inputs": [ + { + "name": "world_class_hash", + "type": "core::starknet::class_hash::ClassHash" + } + ] + }, + { + "type": "enum", + "name": "core::bool", + "variants": [ + { + "name": "False", + "type": "()" + }, + { + "name": "True", + "type": "()" + } + ] + }, + { + "type": "enum", + "name": "core::option::Option::", + "variants": [ + { + "name": "Some", + "type": "core::integer::u32" + }, + { + "name": "None", + "type": "()" + } + ] + }, + { + "type": "enum", + "name": "core::option::Option::", + "variants": [ + { + "name": "Some", + "type": "dojo_starter::models::Direction" + }, + { + "name": "None", + "type": "()" + } + ] + }, + { + "type": "enum", + "name": "dojo_starter::models::Direction", + "variants": [ + { + "name": "Left", + "type": "()" + }, + { + "name": "Right", + "type": "()" + }, + { + "name": "Up", + "type": "()" + }, + { + "name": "Down", + "type": "()" + } + ] + }, + { + "type": "enum", + "name": "dojo::meta::introspect::Ty", + "variants": [ + { + "name": "Primitive", + "type": "core::felt252" + }, + { + "name": "Struct", + "type": "dojo::meta::introspect::Struct" + }, + { + "name": "Enum", + "type": "dojo::meta::introspect::Enum" + }, + { + "name": "Tuple", + "type": "core::array::Span::" + }, + { + "name": "Array", + "type": "core::array::Span::" + }, + { + "name": "ByteArray", + "type": "()" + } + ] + }, + { + "type": "enum", + "name": "dojo::meta::layout::Layout", + "variants": [ + { + "name": "Fixed", + "type": "core::array::Span::" + }, + { + "name": "Struct", + "type": "core::array::Span::" + }, + { + "name": "Tuple", + "type": "core::array::Span::" + }, + { + "name": "Array", + "type": "core::array::Span::" + }, + { + "name": "ByteArray", + "type": "()" + }, + { + "name": "Enum", + "type": "core::array::Span::" + } + ] + }, + { + "type": "enum", + "name": "dojo::model::definition::ModelIndex", + "variants": [ + { + "name": "Keys", + "type": "core::array::Span::" + }, + { + "name": "Id", + "type": "core::felt252" + }, + { + "name": "MemberId", + "type": "(core::felt252, core::felt252)" + } + ] + }, + { + "type": "enum", + "name": "dojo::world::resource::Resource", + "variants": [ + { + "name": "Model", + "type": "(core::starknet::contract_address::ContractAddress, core::felt252)" + }, + { + "name": "Event", + "type": "(core::starknet::contract_address::ContractAddress, core::felt252)" + }, + { + "name": "Contract", + "type": "(core::starknet::contract_address::ContractAddress, core::felt252)" + }, + { + "name": "Namespace", + "type": "core::byte_array::ByteArray" + }, + { + "name": "World", + "type": "()" + }, + { + "name": "Unregistered", + "type": "()" + }, + { + "name": "Library", + "type": "(core::starknet::class_hash::ClassHash, core::felt252)" + } + ] + }, + { + "type": "event", + "name": "dojo_starter::models::m_DirectionsAvailable::Event", + "kind": "enum", + "variants": [] + }, + { + "type": "event", + "name": "dojo_starter::models::m_Moves::Event", + "kind": "enum", + "variants": [] + }, + { + "type": "event", + "name": "dojo_starter::models::m_Position::Event", + "kind": "enum", + "variants": [] + }, + { + "type": "event", + "name": "dojo_starter::models::m_PositionCount::Event", + "kind": "enum", + "variants": [] + }, + { + "type": "event", + "name": "dojo_starter::systems::actions::actions::e_Moved::Event", + "kind": "enum", + "variants": [] + }, + { + "type": "event", + "name": "dojo_starter::systems::actions::actions::Event", + "kind": "enum", + "variants": [ + { + "name": "UpgradeableEvent", + "type": "dojo::contract::components::upgradeable::upgradeable_cpt::Event", + "kind": "nested" + }, + { + "name": "WorldProviderEvent", + "type": "dojo::contract::components::world_provider::world_provider_cpt::Event", + "kind": "nested" + } + ] + }, + { + "type": "event", + "name": "dojo::contract::components::upgradeable::upgradeable_cpt::Event", + "kind": "enum", + "variants": [ + { + "name": "Upgraded", + "type": "dojo::contract::components::upgradeable::upgradeable_cpt::Upgraded", + "kind": "nested" + } + ] + }, + { + "type": "event", + "name": "dojo::contract::components::upgradeable::upgradeable_cpt::Upgraded", + "kind": "struct", + "members": [ + { + "name": "class_hash", + "type": "core::starknet::class_hash::ClassHash", + "kind": "data" + } + ] + }, + { + "type": "event", + "name": "dojo::contract::components::world_provider::world_provider_cpt::Event", + "kind": "enum", + "variants": [] + }, + { + "type": "event", + "name": "dojo::world::world_contract::world::ContractInitialized", + "kind": "struct", + "members": [ + { + "name": "selector", + "type": "core::felt252", + "kind": "key" + }, + { + "name": "init_calldata", + "type": "core::array::Span::", + "kind": "data" + } + ] + }, + { + "type": "event", + "name": "dojo::world::world_contract::world::ContractRegistered", + "kind": "struct", + "members": [ + { + "name": "name", + "type": "core::byte_array::ByteArray", + "kind": "key" + }, + { + "name": "namespace", + "type": "core::byte_array::ByteArray", + "kind": "key" + }, + { + "name": "address", + "type": "core::starknet::contract_address::ContractAddress", + "kind": "data" + }, + { + "name": "class_hash", + "type": "core::starknet::class_hash::ClassHash", + "kind": "data" + }, + { + "name": "salt", + "type": "core::felt252", + "kind": "data" + } + ] + }, + { + "type": "event", + "name": "dojo::world::world_contract::world::ContractUpgraded", + "kind": "struct", + "members": [ + { + "name": "selector", + "type": "core::felt252", + "kind": "key" + }, + { + "name": "class_hash", + "type": "core::starknet::class_hash::ClassHash", + "kind": "data" + } + ] + }, + { + "type": "event", + "name": "dojo::world::world_contract::world::Event", + "kind": "enum", + "variants": [ + { + "name": "WorldSpawned", + "type": "dojo::world::world_contract::world::WorldSpawned", + "kind": "nested" + }, + { + "name": "WorldUpgraded", + "type": "dojo::world::world_contract::world::WorldUpgraded", + "kind": "nested" + }, + { + "name": "NamespaceRegistered", + "type": "dojo::world::world_contract::world::NamespaceRegistered", + "kind": "nested" + }, + { + "name": "ModelRegistered", + "type": "dojo::world::world_contract::world::ModelRegistered", + "kind": "nested" + }, + { + "name": "EventRegistered", + "type": "dojo::world::world_contract::world::EventRegistered", + "kind": "nested" + }, + { + "name": "ContractRegistered", + "type": "dojo::world::world_contract::world::ContractRegistered", + "kind": "nested" + }, + { + "name": "ModelUpgraded", + "type": "dojo::world::world_contract::world::ModelUpgraded", + "kind": "nested" + }, + { + "name": "EventUpgraded", + "type": "dojo::world::world_contract::world::EventUpgraded", + "kind": "nested" + }, + { + "name": "ContractUpgraded", + "type": "dojo::world::world_contract::world::ContractUpgraded", + "kind": "nested" + }, + { + "name": "ContractInitialized", + "type": "dojo::world::world_contract::world::ContractInitialized", + "kind": "nested" + }, + { + "name": "LibraryRegistered", + "type": "dojo::world::world_contract::world::LibraryRegistered", + "kind": "nested" + }, + { + "name": "EventEmitted", + "type": "dojo::world::world_contract::world::EventEmitted", + "kind": "nested" + }, + { + "name": "MetadataUpdate", + "type": "dojo::world::world_contract::world::MetadataUpdate", + "kind": "nested" + }, + { + "name": "StoreSetRecord", + "type": "dojo::world::world_contract::world::StoreSetRecord", + "kind": "nested" + }, + { + "name": "StoreUpdateRecord", + "type": "dojo::world::world_contract::world::StoreUpdateRecord", + "kind": "nested" + }, + { + "name": "StoreUpdateMember", + "type": "dojo::world::world_contract::world::StoreUpdateMember", + "kind": "nested" + }, + { + "name": "StoreDelRecord", + "type": "dojo::world::world_contract::world::StoreDelRecord", + "kind": "nested" + }, + { + "name": "WriterUpdated", + "type": "dojo::world::world_contract::world::WriterUpdated", + "kind": "nested" + }, + { + "name": "OwnerUpdated", + "type": "dojo::world::world_contract::world::OwnerUpdated", + "kind": "nested" + } + ] + }, + { + "type": "event", + "name": "dojo::world::world_contract::world::EventEmitted", + "kind": "struct", + "members": [ + { + "name": "selector", + "type": "core::felt252", + "kind": "key" + }, + { + "name": "system_address", + "type": "core::starknet::contract_address::ContractAddress", + "kind": "key" + }, + { + "name": "keys", + "type": "core::array::Span::", + "kind": "data" + }, + { + "name": "values", + "type": "core::array::Span::", + "kind": "data" + } + ] + }, + { + "type": "event", + "name": "dojo::world::world_contract::world::EventRegistered", + "kind": "struct", + "members": [ + { + "name": "name", + "type": "core::byte_array::ByteArray", + "kind": "key" + }, + { + "name": "namespace", + "type": "core::byte_array::ByteArray", + "kind": "key" + }, + { + "name": "class_hash", + "type": "core::starknet::class_hash::ClassHash", + "kind": "data" + }, + { + "name": "address", + "type": "core::starknet::contract_address::ContractAddress", + "kind": "data" + } + ] + }, + { + "type": "event", + "name": "dojo::world::world_contract::world::EventUpgraded", + "kind": "struct", + "members": [ + { + "name": "selector", + "type": "core::felt252", + "kind": "key" + }, + { + "name": "class_hash", + "type": "core::starknet::class_hash::ClassHash", + "kind": "data" + }, + { + "name": "address", + "type": "core::starknet::contract_address::ContractAddress", + "kind": "data" + }, + { + "name": "prev_address", + "type": "core::starknet::contract_address::ContractAddress", + "kind": "data" + } + ] + }, + { + "type": "event", + "name": "dojo::world::world_contract::world::LibraryRegistered", + "kind": "struct", + "members": [ + { + "name": "name", + "type": "core::byte_array::ByteArray", + "kind": "key" + }, + { + "name": "namespace", + "type": "core::byte_array::ByteArray", + "kind": "key" + }, + { + "name": "class_hash", + "type": "core::starknet::class_hash::ClassHash", + "kind": "data" + } + ] + }, + { + "type": "event", + "name": "dojo::world::world_contract::world::MetadataUpdate", + "kind": "struct", + "members": [ + { + "name": "resource", + "type": "core::felt252", + "kind": "key" + }, + { + "name": "uri", + "type": "core::byte_array::ByteArray", + "kind": "data" + }, + { + "name": "hash", + "type": "core::felt252", + "kind": "data" + } + ] + }, + { + "type": "event", + "name": "dojo::world::world_contract::world::ModelRegistered", + "kind": "struct", + "members": [ + { + "name": "name", + "type": "core::byte_array::ByteArray", + "kind": "key" + }, + { + "name": "namespace", + "type": "core::byte_array::ByteArray", + "kind": "key" + }, + { + "name": "class_hash", + "type": "core::starknet::class_hash::ClassHash", + "kind": "data" + }, + { + "name": "address", + "type": "core::starknet::contract_address::ContractAddress", + "kind": "data" + } + ] + }, + { + "type": "event", + "name": "dojo::world::world_contract::world::ModelUpgraded", + "kind": "struct", + "members": [ + { + "name": "selector", + "type": "core::felt252", + "kind": "key" + }, + { + "name": "class_hash", + "type": "core::starknet::class_hash::ClassHash", + "kind": "data" + }, + { + "name": "address", + "type": "core::starknet::contract_address::ContractAddress", + "kind": "data" + }, + { + "name": "prev_address", + "type": "core::starknet::contract_address::ContractAddress", + "kind": "data" + } + ] + }, + { + "type": "event", + "name": "dojo::world::world_contract::world::NamespaceRegistered", + "kind": "struct", + "members": [ + { + "name": "namespace", + "type": "core::byte_array::ByteArray", + "kind": "key" + }, + { + "name": "hash", + "type": "core::felt252", + "kind": "data" + } + ] + }, + { + "type": "event", + "name": "dojo::world::world_contract::world::OwnerUpdated", + "kind": "struct", + "members": [ + { + "name": "resource", + "type": "core::felt252", + "kind": "key" + }, + { + "name": "contract", + "type": "core::starknet::contract_address::ContractAddress", + "kind": "key" + }, + { + "name": "value", + "type": "core::bool", + "kind": "data" + } + ] + }, + { + "type": "event", + "name": "dojo::world::world_contract::world::StoreDelRecord", + "kind": "struct", + "members": [ + { + "name": "selector", + "type": "core::felt252", + "kind": "key" + }, + { + "name": "entity_id", + "type": "core::felt252", + "kind": "key" + } + ] + }, + { + "type": "event", + "name": "dojo::world::world_contract::world::StoreSetRecord", + "kind": "struct", + "members": [ + { + "name": "selector", + "type": "core::felt252", + "kind": "key" + }, + { + "name": "entity_id", + "type": "core::felt252", + "kind": "key" + }, + { + "name": "keys", + "type": "core::array::Span::", + "kind": "data" + }, + { + "name": "values", + "type": "core::array::Span::", + "kind": "data" + } + ] + }, + { + "type": "event", + "name": "dojo::world::world_contract::world::StoreUpdateMember", + "kind": "struct", + "members": [ + { + "name": "selector", + "type": "core::felt252", + "kind": "key" + }, + { + "name": "entity_id", + "type": "core::felt252", + "kind": "key" + }, + { + "name": "member_selector", + "type": "core::felt252", + "kind": "key" + }, + { + "name": "values", + "type": "core::array::Span::", + "kind": "data" + } + ] + }, + { + "type": "event", + "name": "dojo::world::world_contract::world::StoreUpdateRecord", + "kind": "struct", + "members": [ + { + "name": "selector", + "type": "core::felt252", + "kind": "key" + }, + { + "name": "entity_id", + "type": "core::felt252", + "kind": "key" + }, + { + "name": "values", + "type": "core::array::Span::", + "kind": "data" + } + ] + }, + { + "type": "event", + "name": "dojo::world::world_contract::world::WorldSpawned", + "kind": "struct", + "members": [ + { + "name": "creator", + "type": "core::starknet::contract_address::ContractAddress", + "kind": "data" + }, + { + "name": "class_hash", + "type": "core::starknet::class_hash::ClassHash", + "kind": "data" + } + ] + }, + { + "type": "event", + "name": "dojo::world::world_contract::world::WorldUpgraded", + "kind": "struct", + "members": [ + { + "name": "class_hash", + "type": "core::starknet::class_hash::ClassHash", + "kind": "data" + } + ] + }, + { + "type": "event", + "name": "dojo::world::world_contract::world::WriterUpdated", + "kind": "struct", + "members": [ + { + "name": "resource", + "type": "core::felt252", + "kind": "key" + }, + { + "name": "contract", + "type": "core::starknet::contract_address::ContractAddress", + "kind": "key" + }, + { + "name": "value", + "type": "core::bool", + "kind": "data" + } + ] + }, + { + "type": "function", + "name": "dojo_init", + "inputs": [], + "outputs": [], + "state_mutability": "view" + }, + { + "type": "function", + "name": "ensure_abi", + "inputs": [ + { + "name": "model", + "type": "dojo_starter::models::Position" + } + ], + "outputs": [], + "state_mutability": "view" + }, + { + "type": "function", + "name": "ensure_unique", + "inputs": [], + "outputs": [], + "state_mutability": "view" + }, + { + "type": "function", + "name": "ensure_values", + "inputs": [ + { + "name": "value", + "type": "dojo_starter::models::PositionValue" + } + ], + "outputs": [], + "state_mutability": "view" + }, + { + "type": "impl", + "name": "actions__ContractImpl", + "interface_name": "dojo::contract::interface::IContract" + }, + { + "type": "impl", + "name": "actions__DeployedContractImpl", + "interface_name": "dojo::meta::interface::IDeployedResource" + }, + { + "type": "impl", + "name": "ActionsImpl", + "interface_name": "dojo_starter::systems::actions::IActions" + }, + { + "type": "impl", + "name": "DirectionsAvailable__DojoDeployedModelImpl", + "interface_name": "dojo::meta::interface::IDeployedResource" + }, + { + "type": "impl", + "name": "DirectionsAvailable__DojoModelImpl", + "interface_name": "dojo::model::interface::IModel" + }, + { + "type": "impl", + "name": "DirectionsAvailable__DojoStoredModelImpl", + "interface_name": "dojo::meta::interface::IStoredResource" + }, + { + "type": "impl", + "name": "Moved__DeployedEventImpl", + "interface_name": "dojo::meta::interface::IDeployedResource" + }, + { + "type": "impl", + "name": "Moved__EventImpl", + "interface_name": "dojo::event::interface::IEvent" + }, + { + "type": "impl", + "name": "Moved__StoredEventImpl", + "interface_name": "dojo::meta::interface::IStoredResource" + }, + { + "type": "impl", + "name": "Moves__DojoDeployedModelImpl", + "interface_name": "dojo::meta::interface::IDeployedResource" + }, + { + "type": "impl", + "name": "Moves__DojoModelImpl", + "interface_name": "dojo::model::interface::IModel" + }, + { + "type": "impl", + "name": "Moves__DojoStoredModelImpl", + "interface_name": "dojo::meta::interface::IStoredResource" + }, + { + "type": "impl", + "name": "Position__DojoDeployedModelImpl", + "interface_name": "dojo::meta::interface::IDeployedResource" + }, + { + "type": "impl", + "name": "Position__DojoModelImpl", + "interface_name": "dojo::model::interface::IModel" + }, + { + "type": "impl", + "name": "Position__DojoStoredModelImpl", + "interface_name": "dojo::meta::interface::IStoredResource" + }, + { + "type": "impl", + "name": "PositionCount__DojoDeployedModelImpl", + "interface_name": "dojo::meta::interface::IDeployedResource" + }, + { + "type": "impl", + "name": "PositionCount__DojoModelImpl", + "interface_name": "dojo::model::interface::IModel" + }, + { + "type": "impl", + "name": "PositionCount__DojoStoredModelImpl", + "interface_name": "dojo::meta::interface::IStoredResource" + }, + { + "type": "impl", + "name": "UpgradeableImpl", + "interface_name": "dojo::contract::components::upgradeable::IUpgradeable" + }, + { + "type": "impl", + "name": "UpgradeableWorld", + "interface_name": "dojo::world::iworld::IUpgradeableWorld" + }, + { + "type": "impl", + "name": "World", + "interface_name": "dojo::world::iworld::IWorld" + }, + { + "type": "impl", + "name": "WorldProviderImpl", + "interface_name": "dojo::contract::components::world_provider::IWorldProvider" + }, + { + "type": "interface", + "name": "dojo_starter::systems::actions::IActions", + "items": [ + { + "type": "function", + "name": "spawn", + "inputs": [], + "outputs": [], + "state_mutability": "external" + }, + { + "type": "function", + "name": "move", + "inputs": [ + { + "name": "direction", + "type": "dojo_starter::models::Direction" + } + ], + "outputs": [], + "state_mutability": "external" + } + ] + }, + { + "type": "interface", + "name": "dojo::contract::components::upgradeable::IUpgradeable", + "items": [ + { + "type": "function", + "name": "upgrade", + "inputs": [ + { + "name": "new_class_hash", + "type": "core::starknet::class_hash::ClassHash" + } + ], + "outputs": [], + "state_mutability": "external" + } + ] + }, + { + "type": "interface", + "name": "dojo::contract::components::world_provider::IWorldProvider", + "items": [ + { + "type": "function", + "name": "world_dispatcher", + "inputs": [], + "outputs": [ + { + "type": "dojo::world::iworld::IWorldDispatcher" + } + ], + "state_mutability": "view" + } + ] + }, + { + "type": "interface", + "name": "dojo::contract::interface::IContract", + "items": [] + }, + { + "type": "interface", + "name": "dojo::event::interface::IEvent", + "items": [ + { + "type": "function", + "name": "definition", + "inputs": [], + "outputs": [ + { + "type": "dojo::event::event::EventDef" + } + ], + "state_mutability": "view" + } + ] + }, + { + "type": "interface", + "name": "dojo::meta::interface::IDeployedResource", + "items": [ + { + "type": "function", + "name": "dojo_name", + "inputs": [], + "outputs": [ + { + "type": "core::byte_array::ByteArray" + } + ], + "state_mutability": "view" + } + ] + }, + { + "type": "interface", + "name": "dojo::meta::interface::IStoredResource", + "items": [ + { + "type": "function", + "name": "layout", + "inputs": [], + "outputs": [ + { + "type": "dojo::meta::layout::Layout" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "schema", + "inputs": [], + "outputs": [ + { + "type": "dojo::meta::introspect::Struct" + } + ], + "state_mutability": "view" + } + ] + }, + { + "type": "interface", + "name": "dojo::model::interface::IModel", + "items": [ + { + "type": "function", + "name": "unpacked_size", + "inputs": [], + "outputs": [ + { + "type": "core::option::Option::" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "packed_size", + "inputs": [], + "outputs": [ + { + "type": "core::option::Option::" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "definition", + "inputs": [], + "outputs": [ + { + "type": "dojo::model::definition::ModelDef" + } + ], + "state_mutability": "view" + } + ] + }, + { + "type": "interface", + "name": "dojo::world::iworld::IUpgradeableWorld", + "items": [ + { + "type": "function", + "name": "upgrade", + "inputs": [ + { + "name": "new_class_hash", + "type": "core::starknet::class_hash::ClassHash" + } + ], + "outputs": [], + "state_mutability": "external" + } + ] + }, + { + "type": "interface", + "name": "dojo::world::iworld::IWorld", + "items": [ + { + "type": "function", + "name": "resource", + "inputs": [ + { + "name": "selector", + "type": "core::felt252" + } + ], + "outputs": [ + { + "type": "dojo::world::resource::Resource" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "uuid", + "inputs": [], + "outputs": [ + { + "type": "core::integer::u32" + } + ], + "state_mutability": "external" + }, + { + "type": "function", + "name": "metadata", + "inputs": [ + { + "name": "resource_selector", + "type": "core::felt252" + } + ], + "outputs": [ + { + "type": "dojo::model::metadata::ResourceMetadata" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "set_metadata", + "inputs": [ + { + "name": "metadata", + "type": "dojo::model::metadata::ResourceMetadata" + } + ], + "outputs": [], + "state_mutability": "external" + }, + { + "type": "function", + "name": "register_namespace", + "inputs": [ + { + "name": "namespace", + "type": "core::byte_array::ByteArray" + } + ], + "outputs": [], + "state_mutability": "external" + }, + { + "type": "function", + "name": "register_event", + "inputs": [ + { + "name": "namespace", + "type": "core::byte_array::ByteArray" + }, + { + "name": "class_hash", + "type": "core::starknet::class_hash::ClassHash" + } + ], + "outputs": [], + "state_mutability": "external" + }, + { + "type": "function", + "name": "register_model", + "inputs": [ + { + "name": "namespace", + "type": "core::byte_array::ByteArray" + }, + { + "name": "class_hash", + "type": "core::starknet::class_hash::ClassHash" + } + ], + "outputs": [], + "state_mutability": "external" + }, + { + "type": "function", + "name": "register_contract", + "inputs": [ + { + "name": "salt", + "type": "core::felt252" + }, + { + "name": "namespace", + "type": "core::byte_array::ByteArray" + }, + { + "name": "class_hash", + "type": "core::starknet::class_hash::ClassHash" + } + ], + "outputs": [ + { + "type": "core::starknet::contract_address::ContractAddress" + } + ], + "state_mutability": "external" + }, + { + "type": "function", + "name": "register_library", + "inputs": [ + { + "name": "namespace", + "type": "core::byte_array::ByteArray" + }, + { + "name": "class_hash", + "type": "core::starknet::class_hash::ClassHash" + }, + { + "name": "name", + "type": "core::byte_array::ByteArray" + }, + { + "name": "version", + "type": "core::byte_array::ByteArray" + } + ], + "outputs": [ + { + "type": "core::starknet::class_hash::ClassHash" + } + ], + "state_mutability": "external" + }, + { + "type": "function", + "name": "init_contract", + "inputs": [ + { + "name": "selector", + "type": "core::felt252" + }, + { + "name": "init_calldata", + "type": "core::array::Span::" + } + ], + "outputs": [], + "state_mutability": "external" + }, + { + "type": "function", + "name": "upgrade_event", + "inputs": [ + { + "name": "namespace", + "type": "core::byte_array::ByteArray" + }, + { + "name": "class_hash", + "type": "core::starknet::class_hash::ClassHash" + } + ], + "outputs": [], + "state_mutability": "external" + }, + { + "type": "function", + "name": "upgrade_model", + "inputs": [ + { + "name": "namespace", + "type": "core::byte_array::ByteArray" + }, + { + "name": "class_hash", + "type": "core::starknet::class_hash::ClassHash" + } + ], + "outputs": [], + "state_mutability": "external" + }, + { + "type": "function", + "name": "upgrade_contract", + "inputs": [ + { + "name": "namespace", + "type": "core::byte_array::ByteArray" + }, + { + "name": "class_hash", + "type": "core::starknet::class_hash::ClassHash" + } + ], + "outputs": [ + { + "type": "core::starknet::class_hash::ClassHash" + } + ], + "state_mutability": "external" + }, + { + "type": "function", + "name": "emit_event", + "inputs": [ + { + "name": "event_selector", + "type": "core::felt252" + }, + { + "name": "keys", + "type": "core::array::Span::" + }, + { + "name": "values", + "type": "core::array::Span::" + } + ], + "outputs": [], + "state_mutability": "external" + }, + { + "type": "function", + "name": "emit_events", + "inputs": [ + { + "name": "event_selector", + "type": "core::felt252" + }, + { + "name": "keys", + "type": "core::array::Span::>" + }, + { + "name": "values", + "type": "core::array::Span::>" + } + ], + "outputs": [], + "state_mutability": "external" + }, + { + "type": "function", + "name": "entity", + "inputs": [ + { + "name": "model_selector", + "type": "core::felt252" + }, + { + "name": "index", + "type": "dojo::model::definition::ModelIndex" + }, + { + "name": "layout", + "type": "dojo::meta::layout::Layout" + } + ], + "outputs": [ + { + "type": "core::array::Span::" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "entities", + "inputs": [ + { + "name": "model_selector", + "type": "core::felt252" + }, + { + "name": "indexes", + "type": "core::array::Span::" + }, + { + "name": "layout", + "type": "dojo::meta::layout::Layout" + } + ], + "outputs": [ + { + "type": "core::array::Span::>" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "set_entity", + "inputs": [ + { + "name": "model_selector", + "type": "core::felt252" + }, + { + "name": "index", + "type": "dojo::model::definition::ModelIndex" + }, + { + "name": "values", + "type": "core::array::Span::" + }, + { + "name": "layout", + "type": "dojo::meta::layout::Layout" + } + ], + "outputs": [], + "state_mutability": "external" + }, + { + "type": "function", + "name": "set_entities", + "inputs": [ + { + "name": "model_selector", + "type": "core::felt252" + }, + { + "name": "indexes", + "type": "core::array::Span::" + }, + { + "name": "values", + "type": "core::array::Span::>" + }, + { + "name": "layout", + "type": "dojo::meta::layout::Layout" + } + ], + "outputs": [], + "state_mutability": "external" + }, + { + "type": "function", + "name": "delete_entity", + "inputs": [ + { + "name": "model_selector", + "type": "core::felt252" + }, + { + "name": "index", + "type": "dojo::model::definition::ModelIndex" + }, + { + "name": "layout", + "type": "dojo::meta::layout::Layout" + } + ], + "outputs": [], + "state_mutability": "external" + }, + { + "type": "function", + "name": "delete_entities", + "inputs": [ + { + "name": "model_selector", + "type": "core::felt252" + }, + { + "name": "indexes", + "type": "core::array::Span::" + }, + { + "name": "layout", + "type": "dojo::meta::layout::Layout" + } + ], + "outputs": [], + "state_mutability": "external" + }, + { + "type": "function", + "name": "is_owner", + "inputs": [ + { + "name": "resource", + "type": "core::felt252" + }, + { + "name": "address", + "type": "core::starknet::contract_address::ContractAddress" + } + ], + "outputs": [ + { + "type": "core::bool" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "grant_owner", + "inputs": [ + { + "name": "resource", + "type": "core::felt252" + }, + { + "name": "address", + "type": "core::starknet::contract_address::ContractAddress" + } + ], + "outputs": [], + "state_mutability": "external" + }, + { + "type": "function", + "name": "revoke_owner", + "inputs": [ + { + "name": "resource", + "type": "core::felt252" + }, + { + "name": "address", + "type": "core::starknet::contract_address::ContractAddress" + } + ], + "outputs": [], + "state_mutability": "external" + }, + { + "type": "function", + "name": "owners_count", + "inputs": [ + { + "name": "resource", + "type": "core::felt252" + } + ], + "outputs": [ + { + "type": "core::integer::u64" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "is_writer", + "inputs": [ + { + "name": "resource", + "type": "core::felt252" + }, + { + "name": "contract", + "type": "core::starknet::contract_address::ContractAddress" + } + ], + "outputs": [ + { + "type": "core::bool" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "grant_writer", + "inputs": [ + { + "name": "resource", + "type": "core::felt252" + }, + { + "name": "contract", + "type": "core::starknet::contract_address::ContractAddress" + } + ], + "outputs": [], + "state_mutability": "external" + }, + { + "type": "function", + "name": "revoke_writer", + "inputs": [ + { + "name": "resource", + "type": "core::felt252" + }, + { + "name": "contract", + "type": "core::starknet::contract_address::ContractAddress" + } + ], + "outputs": [], + "state_mutability": "external" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::<(core::felt252, dojo::meta::introspect::Ty)>", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::<(core::felt252, dojo::meta::introspect::Ty)>" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::<(core::integer::u8, core::integer::u128)>", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::<(core::integer::u8, core::integer::u128)>" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::>", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::>" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "struct", + "name": "core::byte_array::ByteArray", + "members": [ + { + "name": "data", + "type": "core::array::Array::" + }, + { + "name": "pending_word", + "type": "core::felt252" + }, + { + "name": "pending_word_len", + "type": "core::integer::u32" + } + ] + }, + { + "type": "struct", + "name": "dojo_starter::models::DirectionsAvailable", + "members": [ + { + "name": "player", + "type": "core::starknet::contract_address::ContractAddress" + }, + { + "name": "directions", + "type": "core::array::Array::" + } + ] + }, + { + "type": "struct", + "name": "dojo_starter::models::DirectionsAvailableValue", + "members": [ + { + "name": "directions", + "type": "core::array::Array::" + } + ] + }, + { + "type": "struct", + "name": "dojo_starter::models::Moves", + "members": [ + { + "name": "player", + "type": "core::starknet::contract_address::ContractAddress" + }, + { + "name": "remaining", + "type": "core::integer::u8" + }, + { + "name": "last_direction", + "type": "core::option::Option::" + }, + { + "name": "can_move", + "type": "core::bool" + } + ] + }, + { + "type": "struct", + "name": "dojo_starter::models::MovesValue", + "members": [ + { + "name": "remaining", + "type": "core::integer::u8" + }, + { + "name": "last_direction", + "type": "core::option::Option::" + }, + { + "name": "can_move", + "type": "core::bool" + } + ] + }, + { + "type": "struct", + "name": "dojo_starter::models::Position", + "members": [ + { + "name": "player", + "type": "core::starknet::contract_address::ContractAddress" + }, + { + "name": "vec", + "type": "dojo_starter::models::Vec2" + } + ] + }, + { + "type": "struct", + "name": "dojo_starter::models::PositionCount", + "members": [ + { + "name": "identity", + "type": "core::starknet::contract_address::ContractAddress" + }, + { + "name": "position", + "type": "core::array::Span::<(core::integer::u8, core::integer::u128)>" + } + ] + }, + { + "type": "struct", + "name": "dojo_starter::models::PositionCountValue", + "members": [ + { + "name": "position", + "type": "core::array::Span::<(core::integer::u8, core::integer::u128)>" + } + ] + }, + { + "type": "struct", + "name": "dojo_starter::models::PositionValue", + "members": [ + { + "name": "vec", + "type": "dojo_starter::models::Vec2" + } + ] + }, + { + "type": "struct", + "name": "dojo_starter::models::Vec2", + "members": [ + { + "name": "x", + "type": "core::integer::u32" + }, + { + "name": "y", + "type": "core::integer::u32" + } + ] + }, + { + "type": "struct", + "name": "dojo_starter::systems::actions::actions::Moved", + "members": [ + { + "name": "player", + "type": "core::starknet::contract_address::ContractAddress" + }, + { + "name": "direction", + "type": "dojo_starter::models::Direction" + } + ] + }, + { + "type": "struct", + "name": "dojo_starter::systems::actions::actions::MovedValue", + "members": [ + { + "name": "direction", + "type": "dojo_starter::models::Direction" + } + ] + }, + { + "type": "struct", + "name": "dojo::event::event::EventDef", + "members": [ + { + "name": "name", + "type": "core::byte_array::ByteArray" + }, + { + "name": "layout", + "type": "dojo::meta::layout::Layout" + }, + { + "name": "schema", + "type": "dojo::meta::introspect::Struct" + } + ] + }, + { + "type": "struct", + "name": "dojo::meta::introspect::Enum", + "members": [ + { + "name": "name", + "type": "core::felt252" + }, + { + "name": "attrs", + "type": "core::array::Span::" + }, + { + "name": "children", + "type": "core::array::Span::<(core::felt252, dojo::meta::introspect::Ty)>" + } + ] + }, + { + "type": "struct", + "name": "dojo::meta::introspect::Member", + "members": [ + { + "name": "name", + "type": "core::felt252" + }, + { + "name": "attrs", + "type": "core::array::Span::" + }, + { + "name": "ty", + "type": "dojo::meta::introspect::Ty" + } + ] + }, + { + "type": "struct", + "name": "dojo::meta::introspect::Struct", + "members": [ + { + "name": "name", + "type": "core::felt252" + }, + { + "name": "attrs", + "type": "core::array::Span::" + }, + { + "name": "children", + "type": "core::array::Span::" + } + ] + }, + { + "type": "struct", + "name": "dojo::meta::layout::FieldLayout", + "members": [ + { + "name": "selector", + "type": "core::felt252" + }, + { + "name": "layout", + "type": "dojo::meta::layout::Layout" + } + ] + }, + { + "type": "struct", + "name": "dojo::model::definition::ModelDef", + "members": [ + { + "name": "name", + "type": "core::byte_array::ByteArray" + }, + { + "name": "layout", + "type": "dojo::meta::layout::Layout" + }, + { + "name": "schema", + "type": "dojo::meta::introspect::Struct" + }, + { + "name": "packed_size", + "type": "core::option::Option::" + }, + { + "name": "unpacked_size", + "type": "core::option::Option::" + } + ] + }, + { + "type": "struct", + "name": "dojo::model::metadata::ResourceMetadata", + "members": [ + { + "name": "resource_id", + "type": "core::felt252" + }, + { + "name": "metadata_uri", + "type": "core::byte_array::ByteArray" + }, + { + "name": "metadata_hash", + "type": "core::felt252" + } + ] + }, + { + "type": "struct", + "name": "dojo::world::iworld::IWorldDispatcher", + "members": [ + { + "name": "contract_address", + "type": "core::starknet::contract_address::ContractAddress" + } + ] + } + ], + "manifest": { + "world": { + "class_hash": "0x685ed02eefa98fe7e208aa295042e9bbad8029b0d3d6f0ba2b32546efe0a1f9", + "address": "0x58565b92f55fb07b53940b4b7eea3df2ac2878210e5c7a4c68201e8c511a546", + "seed": "dojo_starter", + "name": "Dojo starter", + "entrypoints": [ + "uuid", + "set_metadata", + "register_namespace", + "register_event", + "register_model", + "register_contract", + "register_library", + "init_contract", + "upgrade_event", + "upgrade_model", + "upgrade_contract", + "emit_event", + "emit_events", + "set_entity", + "set_entities", + "delete_entity", + "delete_entities", + "grant_owner", + "revoke_owner", + "grant_writer", + "revoke_writer", + "upgrade" + ], + "abi": [ + { + "type": "impl", + "name": "World", + "interface_name": "dojo::world::iworld::IWorld" + }, + { + "type": "struct", + "name": "core::byte_array::ByteArray", + "members": [ + { + "name": "data", + "type": "core::array::Array::" + }, + { + "name": "pending_word", + "type": "core::felt252" + }, + { + "name": "pending_word_len", + "type": "core::integer::u32" + } + ] + }, + { + "type": "enum", + "name": "dojo::world::resource::Resource", + "variants": [ + { + "name": "Model", + "type": "(core::starknet::contract_address::ContractAddress, core::felt252)" + }, + { + "name": "Event", + "type": "(core::starknet::contract_address::ContractAddress, core::felt252)" + }, + { + "name": "Contract", + "type": "(core::starknet::contract_address::ContractAddress, core::felt252)" + }, + { + "name": "Namespace", + "type": "core::byte_array::ByteArray" + }, + { + "name": "World", + "type": "()" + }, + { + "name": "Unregistered", + "type": "()" + }, + { + "name": "Library", + "type": "(core::starknet::class_hash::ClassHash, core::felt252)" + } + ] + }, + { + "type": "struct", + "name": "dojo::model::metadata::ResourceMetadata", + "members": [ + { + "name": "resource_id", + "type": "core::felt252" + }, + { + "name": "metadata_uri", + "type": "core::byte_array::ByteArray" + }, + { + "name": "metadata_hash", + "type": "core::felt252" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::>", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::>" + } + ] + }, + { + "type": "enum", + "name": "dojo::model::definition::ModelIndex", + "variants": [ + { + "name": "Keys", + "type": "core::array::Span::" + }, + { + "name": "Id", + "type": "core::felt252" + }, + { + "name": "MemberId", + "type": "(core::felt252, core::felt252)" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "struct", + "name": "dojo::meta::layout::FieldLayout", + "members": [ + { + "name": "selector", + "type": "core::felt252" + }, + { + "name": "layout", + "type": "dojo::meta::layout::Layout" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "enum", + "name": "dojo::meta::layout::Layout", + "variants": [ + { + "name": "Fixed", + "type": "core::array::Span::" + }, + { + "name": "Struct", + "type": "core::array::Span::" + }, + { + "name": "Tuple", + "type": "core::array::Span::" + }, + { + "name": "Array", + "type": "core::array::Span::" + }, + { + "name": "ByteArray", + "type": "()" + }, + { + "name": "Enum", + "type": "core::array::Span::" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "enum", + "name": "core::bool", + "variants": [ + { + "name": "False", + "type": "()" + }, + { + "name": "True", + "type": "()" + } + ] + }, + { + "type": "interface", + "name": "dojo::world::iworld::IWorld", + "items": [ + { + "type": "function", + "name": "resource", + "inputs": [ + { + "name": "selector", + "type": "core::felt252" + } + ], + "outputs": [ + { + "type": "dojo::world::resource::Resource" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "uuid", + "inputs": [], + "outputs": [ + { + "type": "core::integer::u32" + } + ], + "state_mutability": "external" + }, + { + "type": "function", + "name": "metadata", + "inputs": [ + { + "name": "resource_selector", + "type": "core::felt252" + } + ], + "outputs": [ + { + "type": "dojo::model::metadata::ResourceMetadata" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "set_metadata", + "inputs": [ + { + "name": "metadata", + "type": "dojo::model::metadata::ResourceMetadata" + } + ], + "outputs": [], + "state_mutability": "external" + }, + { + "type": "function", + "name": "register_namespace", + "inputs": [ + { + "name": "namespace", + "type": "core::byte_array::ByteArray" + } + ], + "outputs": [], + "state_mutability": "external" + }, + { + "type": "function", + "name": "register_event", + "inputs": [ + { + "name": "namespace", + "type": "core::byte_array::ByteArray" + }, + { + "name": "class_hash", + "type": "core::starknet::class_hash::ClassHash" + } + ], + "outputs": [], + "state_mutability": "external" + }, + { + "type": "function", + "name": "register_model", + "inputs": [ + { + "name": "namespace", + "type": "core::byte_array::ByteArray" + }, + { + "name": "class_hash", + "type": "core::starknet::class_hash::ClassHash" + } + ], + "outputs": [], + "state_mutability": "external" + }, + { + "type": "function", + "name": "register_contract", + "inputs": [ + { + "name": "salt", + "type": "core::felt252" + }, + { + "name": "namespace", + "type": "core::byte_array::ByteArray" + }, + { + "name": "class_hash", + "type": "core::starknet::class_hash::ClassHash" + } + ], + "outputs": [ + { + "type": "core::starknet::contract_address::ContractAddress" + } + ], + "state_mutability": "external" + }, + { + "type": "function", + "name": "register_library", + "inputs": [ + { + "name": "namespace", + "type": "core::byte_array::ByteArray" + }, + { + "name": "class_hash", + "type": "core::starknet::class_hash::ClassHash" + }, + { + "name": "name", + "type": "core::byte_array::ByteArray" + }, + { + "name": "version", + "type": "core::byte_array::ByteArray" + } + ], + "outputs": [ + { + "type": "core::starknet::class_hash::ClassHash" + } + ], + "state_mutability": "external" + }, + { + "type": "function", + "name": "init_contract", + "inputs": [ + { + "name": "selector", + "type": "core::felt252" + }, + { + "name": "init_calldata", + "type": "core::array::Span::" + } + ], + "outputs": [], + "state_mutability": "external" + }, + { + "type": "function", + "name": "upgrade_event", + "inputs": [ + { + "name": "namespace", + "type": "core::byte_array::ByteArray" + }, + { + "name": "class_hash", + "type": "core::starknet::class_hash::ClassHash" + } + ], + "outputs": [], + "state_mutability": "external" + }, + { + "type": "function", + "name": "upgrade_model", + "inputs": [ + { + "name": "namespace", + "type": "core::byte_array::ByteArray" + }, + { + "name": "class_hash", + "type": "core::starknet::class_hash::ClassHash" + } + ], + "outputs": [], + "state_mutability": "external" + }, + { + "type": "function", + "name": "upgrade_contract", + "inputs": [ + { + "name": "namespace", + "type": "core::byte_array::ByteArray" + }, + { + "name": "class_hash", + "type": "core::starknet::class_hash::ClassHash" + } + ], + "outputs": [ + { + "type": "core::starknet::class_hash::ClassHash" + } + ], + "state_mutability": "external" + }, + { + "type": "function", + "name": "emit_event", + "inputs": [ + { + "name": "event_selector", + "type": "core::felt252" + }, + { + "name": "keys", + "type": "core::array::Span::" + }, + { + "name": "values", + "type": "core::array::Span::" + } + ], + "outputs": [], + "state_mutability": "external" + }, + { + "type": "function", + "name": "emit_events", + "inputs": [ + { + "name": "event_selector", + "type": "core::felt252" + }, + { + "name": "keys", + "type": "core::array::Span::>" + }, + { + "name": "values", + "type": "core::array::Span::>" + } + ], + "outputs": [], + "state_mutability": "external" + }, + { + "type": "function", + "name": "entity", + "inputs": [ + { + "name": "model_selector", + "type": "core::felt252" + }, + { + "name": "index", + "type": "dojo::model::definition::ModelIndex" + }, + { + "name": "layout", + "type": "dojo::meta::layout::Layout" + } + ], + "outputs": [ + { + "type": "core::array::Span::" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "entities", + "inputs": [ + { + "name": "model_selector", + "type": "core::felt252" + }, + { + "name": "indexes", + "type": "core::array::Span::" + }, + { + "name": "layout", + "type": "dojo::meta::layout::Layout" + } + ], + "outputs": [ + { + "type": "core::array::Span::>" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "set_entity", + "inputs": [ + { + "name": "model_selector", + "type": "core::felt252" + }, + { + "name": "index", + "type": "dojo::model::definition::ModelIndex" + }, + { + "name": "values", + "type": "core::array::Span::" + }, + { + "name": "layout", + "type": "dojo::meta::layout::Layout" + } + ], + "outputs": [], + "state_mutability": "external" + }, + { + "type": "function", + "name": "set_entities", + "inputs": [ + { + "name": "model_selector", + "type": "core::felt252" + }, + { + "name": "indexes", + "type": "core::array::Span::" + }, + { + "name": "values", + "type": "core::array::Span::>" + }, + { + "name": "layout", + "type": "dojo::meta::layout::Layout" + } + ], + "outputs": [], + "state_mutability": "external" + }, + { + "type": "function", + "name": "delete_entity", + "inputs": [ + { + "name": "model_selector", + "type": "core::felt252" + }, + { + "name": "index", + "type": "dojo::model::definition::ModelIndex" + }, + { + "name": "layout", + "type": "dojo::meta::layout::Layout" + } + ], + "outputs": [], + "state_mutability": "external" + }, + { + "type": "function", + "name": "delete_entities", + "inputs": [ + { + "name": "model_selector", + "type": "core::felt252" + }, + { + "name": "indexes", + "type": "core::array::Span::" + }, + { + "name": "layout", + "type": "dojo::meta::layout::Layout" + } + ], + "outputs": [], + "state_mutability": "external" + }, + { + "type": "function", + "name": "is_owner", + "inputs": [ + { + "name": "resource", + "type": "core::felt252" + }, + { + "name": "address", + "type": "core::starknet::contract_address::ContractAddress" + } + ], + "outputs": [ + { + "type": "core::bool" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "grant_owner", + "inputs": [ + { + "name": "resource", + "type": "core::felt252" + }, + { + "name": "address", + "type": "core::starknet::contract_address::ContractAddress" + } + ], + "outputs": [], + "state_mutability": "external" + }, + { + "type": "function", + "name": "revoke_owner", + "inputs": [ + { + "name": "resource", + "type": "core::felt252" + }, + { + "name": "address", + "type": "core::starknet::contract_address::ContractAddress" + } + ], + "outputs": [], + "state_mutability": "external" + }, + { + "type": "function", + "name": "owners_count", + "inputs": [ + { + "name": "resource", + "type": "core::felt252" + } + ], + "outputs": [ + { + "type": "core::integer::u64" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "is_writer", + "inputs": [ + { + "name": "resource", + "type": "core::felt252" + }, + { + "name": "contract", + "type": "core::starknet::contract_address::ContractAddress" + } + ], + "outputs": [ + { + "type": "core::bool" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "grant_writer", + "inputs": [ + { + "name": "resource", + "type": "core::felt252" + }, + { + "name": "contract", + "type": "core::starknet::contract_address::ContractAddress" + } + ], + "outputs": [], + "state_mutability": "external" + }, + { + "type": "function", + "name": "revoke_writer", + "inputs": [ + { + "name": "resource", + "type": "core::felt252" + }, + { + "name": "contract", + "type": "core::starknet::contract_address::ContractAddress" + } + ], + "outputs": [], + "state_mutability": "external" + } + ] + }, + { + "type": "impl", + "name": "UpgradeableWorld", + "interface_name": "dojo::world::iworld::IUpgradeableWorld" + }, + { + "type": "interface", + "name": "dojo::world::iworld::IUpgradeableWorld", + "items": [ + { + "type": "function", + "name": "upgrade", + "inputs": [ + { + "name": "new_class_hash", + "type": "core::starknet::class_hash::ClassHash" + } + ], + "outputs": [], + "state_mutability": "external" + } + ] + }, + { + "type": "constructor", + "name": "constructor", + "inputs": [ + { + "name": "world_class_hash", + "type": "core::starknet::class_hash::ClassHash" + } + ] + }, + { + "type": "event", + "name": "dojo::world::world_contract::world::WorldSpawned", + "kind": "struct", + "members": [ + { + "name": "creator", + "type": "core::starknet::contract_address::ContractAddress", + "kind": "data" + }, + { + "name": "class_hash", + "type": "core::starknet::class_hash::ClassHash", + "kind": "data" + } + ] + }, + { + "type": "event", + "name": "dojo::world::world_contract::world::WorldUpgraded", + "kind": "struct", + "members": [ + { + "name": "class_hash", + "type": "core::starknet::class_hash::ClassHash", + "kind": "data" + } + ] + }, + { + "type": "event", + "name": "dojo::world::world_contract::world::NamespaceRegistered", + "kind": "struct", + "members": [ + { + "name": "namespace", + "type": "core::byte_array::ByteArray", + "kind": "key" + }, + { + "name": "hash", + "type": "core::felt252", + "kind": "data" + } + ] + }, + { + "type": "event", + "name": "dojo::world::world_contract::world::ModelRegistered", + "kind": "struct", + "members": [ + { + "name": "name", + "type": "core::byte_array::ByteArray", + "kind": "key" + }, + { + "name": "namespace", + "type": "core::byte_array::ByteArray", + "kind": "key" + }, + { + "name": "class_hash", + "type": "core::starknet::class_hash::ClassHash", + "kind": "data" + }, + { + "name": "address", + "type": "core::starknet::contract_address::ContractAddress", + "kind": "data" + } + ] + }, + { + "type": "event", + "name": "dojo::world::world_contract::world::EventRegistered", + "kind": "struct", + "members": [ + { + "name": "name", + "type": "core::byte_array::ByteArray", + "kind": "key" + }, + { + "name": "namespace", + "type": "core::byte_array::ByteArray", + "kind": "key" + }, + { + "name": "class_hash", + "type": "core::starknet::class_hash::ClassHash", + "kind": "data" + }, + { + "name": "address", + "type": "core::starknet::contract_address::ContractAddress", + "kind": "data" + } + ] + }, + { + "type": "event", + "name": "dojo::world::world_contract::world::ContractRegistered", + "kind": "struct", + "members": [ + { + "name": "name", + "type": "core::byte_array::ByteArray", + "kind": "key" + }, + { + "name": "namespace", + "type": "core::byte_array::ByteArray", + "kind": "key" + }, + { + "name": "address", + "type": "core::starknet::contract_address::ContractAddress", + "kind": "data" + }, + { + "name": "class_hash", + "type": "core::starknet::class_hash::ClassHash", + "kind": "data" + }, + { + "name": "salt", + "type": "core::felt252", + "kind": "data" + } + ] + }, + { + "type": "event", + "name": "dojo::world::world_contract::world::ModelUpgraded", + "kind": "struct", + "members": [ + { + "name": "selector", + "type": "core::felt252", + "kind": "key" + }, + { + "name": "class_hash", + "type": "core::starknet::class_hash::ClassHash", + "kind": "data" + }, + { + "name": "address", + "type": "core::starknet::contract_address::ContractAddress", + "kind": "data" + }, + { + "name": "prev_address", + "type": "core::starknet::contract_address::ContractAddress", + "kind": "data" + } + ] + }, + { + "type": "event", + "name": "dojo::world::world_contract::world::EventUpgraded", + "kind": "struct", + "members": [ + { + "name": "selector", + "type": "core::felt252", + "kind": "key" + }, + { + "name": "class_hash", + "type": "core::starknet::class_hash::ClassHash", + "kind": "data" + }, + { + "name": "address", + "type": "core::starknet::contract_address::ContractAddress", + "kind": "data" + }, + { + "name": "prev_address", + "type": "core::starknet::contract_address::ContractAddress", + "kind": "data" + } + ] + }, + { + "type": "event", + "name": "dojo::world::world_contract::world::ContractUpgraded", + "kind": "struct", + "members": [ + { + "name": "selector", + "type": "core::felt252", + "kind": "key" + }, + { + "name": "class_hash", + "type": "core::starknet::class_hash::ClassHash", + "kind": "data" + } + ] + }, + { + "type": "event", + "name": "dojo::world::world_contract::world::ContractInitialized", + "kind": "struct", + "members": [ + { + "name": "selector", + "type": "core::felt252", + "kind": "key" + }, + { + "name": "init_calldata", + "type": "core::array::Span::", + "kind": "data" + } + ] + }, + { + "type": "event", + "name": "dojo::world::world_contract::world::LibraryRegistered", + "kind": "struct", + "members": [ + { + "name": "name", + "type": "core::byte_array::ByteArray", + "kind": "key" + }, + { + "name": "namespace", + "type": "core::byte_array::ByteArray", + "kind": "key" + }, + { + "name": "class_hash", + "type": "core::starknet::class_hash::ClassHash", + "kind": "data" + } + ] + }, + { + "type": "event", + "name": "dojo::world::world_contract::world::EventEmitted", + "kind": "struct", + "members": [ + { + "name": "selector", + "type": "core::felt252", + "kind": "key" + }, + { + "name": "system_address", + "type": "core::starknet::contract_address::ContractAddress", + "kind": "key" + }, + { + "name": "keys", + "type": "core::array::Span::", + "kind": "data" + }, + { + "name": "values", + "type": "core::array::Span::", + "kind": "data" + } + ] + }, + { + "type": "event", + "name": "dojo::world::world_contract::world::MetadataUpdate", + "kind": "struct", + "members": [ + { + "name": "resource", + "type": "core::felt252", + "kind": "key" + }, + { + "name": "uri", + "type": "core::byte_array::ByteArray", + "kind": "data" + }, + { + "name": "hash", + "type": "core::felt252", + "kind": "data" + } + ] + }, + { + "type": "event", + "name": "dojo::world::world_contract::world::StoreSetRecord", + "kind": "struct", + "members": [ + { + "name": "selector", + "type": "core::felt252", + "kind": "key" + }, + { + "name": "entity_id", + "type": "core::felt252", + "kind": "key" + }, + { + "name": "keys", + "type": "core::array::Span::", + "kind": "data" + }, + { + "name": "values", + "type": "core::array::Span::", + "kind": "data" + } + ] + }, + { + "type": "event", + "name": "dojo::world::world_contract::world::StoreUpdateRecord", + "kind": "struct", + "members": [ + { + "name": "selector", + "type": "core::felt252", + "kind": "key" + }, + { + "name": "entity_id", + "type": "core::felt252", + "kind": "key" + }, + { + "name": "values", + "type": "core::array::Span::", + "kind": "data" + } + ] + }, + { + "type": "event", + "name": "dojo::world::world_contract::world::StoreUpdateMember", + "kind": "struct", + "members": [ + { + "name": "selector", + "type": "core::felt252", + "kind": "key" + }, + { + "name": "entity_id", + "type": "core::felt252", + "kind": "key" + }, + { + "name": "member_selector", + "type": "core::felt252", + "kind": "key" + }, + { + "name": "values", + "type": "core::array::Span::", + "kind": "data" + } + ] + }, + { + "type": "event", + "name": "dojo::world::world_contract::world::StoreDelRecord", + "kind": "struct", + "members": [ + { + "name": "selector", + "type": "core::felt252", + "kind": "key" + }, + { + "name": "entity_id", + "type": "core::felt252", + "kind": "key" + } + ] + }, + { + "type": "event", + "name": "dojo::world::world_contract::world::WriterUpdated", + "kind": "struct", + "members": [ + { + "name": "resource", + "type": "core::felt252", + "kind": "key" + }, + { + "name": "contract", + "type": "core::starknet::contract_address::ContractAddress", + "kind": "key" + }, + { + "name": "value", + "type": "core::bool", + "kind": "data" + } + ] + }, + { + "type": "event", + "name": "dojo::world::world_contract::world::OwnerUpdated", + "kind": "struct", + "members": [ + { + "name": "resource", + "type": "core::felt252", + "kind": "key" + }, + { + "name": "contract", + "type": "core::starknet::contract_address::ContractAddress", + "kind": "key" + }, + { + "name": "value", + "type": "core::bool", + "kind": "data" + } + ] + }, + { + "type": "event", + "name": "dojo::world::world_contract::world::Event", + "kind": "enum", + "variants": [ + { + "name": "WorldSpawned", + "type": "dojo::world::world_contract::world::WorldSpawned", + "kind": "nested" + }, + { + "name": "WorldUpgraded", + "type": "dojo::world::world_contract::world::WorldUpgraded", + "kind": "nested" + }, + { + "name": "NamespaceRegistered", + "type": "dojo::world::world_contract::world::NamespaceRegistered", + "kind": "nested" + }, + { + "name": "ModelRegistered", + "type": "dojo::world::world_contract::world::ModelRegistered", + "kind": "nested" + }, + { + "name": "EventRegistered", + "type": "dojo::world::world_contract::world::EventRegistered", + "kind": "nested" + }, + { + "name": "ContractRegistered", + "type": "dojo::world::world_contract::world::ContractRegistered", + "kind": "nested" + }, + { + "name": "ModelUpgraded", + "type": "dojo::world::world_contract::world::ModelUpgraded", + "kind": "nested" + }, + { + "name": "EventUpgraded", + "type": "dojo::world::world_contract::world::EventUpgraded", + "kind": "nested" + }, + { + "name": "ContractUpgraded", + "type": "dojo::world::world_contract::world::ContractUpgraded", + "kind": "nested" + }, + { + "name": "ContractInitialized", + "type": "dojo::world::world_contract::world::ContractInitialized", + "kind": "nested" + }, + { + "name": "LibraryRegistered", + "type": "dojo::world::world_contract::world::LibraryRegistered", + "kind": "nested" + }, + { + "name": "EventEmitted", + "type": "dojo::world::world_contract::world::EventEmitted", + "kind": "nested" + }, + { + "name": "MetadataUpdate", + "type": "dojo::world::world_contract::world::MetadataUpdate", + "kind": "nested" + }, + { + "name": "StoreSetRecord", + "type": "dojo::world::world_contract::world::StoreSetRecord", + "kind": "nested" + }, + { + "name": "StoreUpdateRecord", + "type": "dojo::world::world_contract::world::StoreUpdateRecord", + "kind": "nested" + }, + { + "name": "StoreUpdateMember", + "type": "dojo::world::world_contract::world::StoreUpdateMember", + "kind": "nested" + }, + { + "name": "StoreDelRecord", + "type": "dojo::world::world_contract::world::StoreDelRecord", + "kind": "nested" + }, + { + "name": "WriterUpdated", + "type": "dojo::world::world_contract::world::WriterUpdated", + "kind": "nested" + }, + { + "name": "OwnerUpdated", + "type": "dojo::world::world_contract::world::OwnerUpdated", + "kind": "nested" + } + ] + } + ] + }, + "contracts": [ + { + "address": "0x49f9b281bb08aea6d745f28cf31dd529348b04a21d9a5ae1ef19197665c02da", + "class_hash": "0x28059bba1d3a76ca9ee42d2b4fdabb41604cd6fbd95e1e33b220c6e8060b1eb", + "abi": [ + { + "type": "impl", + "name": "actions__ContractImpl", + "interface_name": "dojo::contract::interface::IContract" + }, + { + "type": "interface", + "name": "dojo::contract::interface::IContract", + "items": [] + }, + { + "type": "impl", + "name": "actions__DeployedContractImpl", + "interface_name": "dojo::meta::interface::IDeployedResource" + }, + { + "type": "struct", + "name": "core::byte_array::ByteArray", + "members": [ + { + "name": "data", + "type": "core::array::Array::" + }, + { + "name": "pending_word", + "type": "core::felt252" + }, + { + "name": "pending_word_len", + "type": "core::integer::u32" + } + ] + }, + { + "type": "interface", + "name": "dojo::meta::interface::IDeployedResource", + "items": [ + { + "type": "function", + "name": "dojo_name", + "inputs": [], + "outputs": [ + { + "type": "core::byte_array::ByteArray" + } + ], + "state_mutability": "view" + } + ] + }, + { + "type": "impl", + "name": "ActionsImpl", + "interface_name": "dojo_starter::systems::actions::IActions" + }, + { + "type": "enum", + "name": "dojo_starter::models::Direction", + "variants": [ + { + "name": "Left", + "type": "()" + }, + { + "name": "Right", + "type": "()" + }, + { + "name": "Up", + "type": "()" + }, + { + "name": "Down", + "type": "()" + } + ] + }, + { + "type": "interface", + "name": "dojo_starter::systems::actions::IActions", + "items": [ + { + "type": "function", + "name": "spawn", + "inputs": [], + "outputs": [], + "state_mutability": "external" + }, + { + "type": "function", + "name": "move", + "inputs": [ + { + "name": "direction", + "type": "dojo_starter::models::Direction" + } + ], + "outputs": [], + "state_mutability": "external" + } + ] + }, + { + "type": "function", + "name": "dojo_init", + "inputs": [], + "outputs": [], + "state_mutability": "view" + }, + { + "type": "impl", + "name": "WorldProviderImpl", + "interface_name": "dojo::contract::components::world_provider::IWorldProvider" + }, + { + "type": "struct", + "name": "dojo::world::iworld::IWorldDispatcher", + "members": [ + { + "name": "contract_address", + "type": "core::starknet::contract_address::ContractAddress" + } + ] + }, + { + "type": "interface", + "name": "dojo::contract::components::world_provider::IWorldProvider", + "items": [ + { + "type": "function", + "name": "world_dispatcher", + "inputs": [], + "outputs": [ + { + "type": "dojo::world::iworld::IWorldDispatcher" + } + ], + "state_mutability": "view" + } + ] + }, + { + "type": "impl", + "name": "UpgradeableImpl", + "interface_name": "dojo::contract::components::upgradeable::IUpgradeable" + }, + { + "type": "interface", + "name": "dojo::contract::components::upgradeable::IUpgradeable", + "items": [ + { + "type": "function", + "name": "upgrade", + "inputs": [ + { + "name": "new_class_hash", + "type": "core::starknet::class_hash::ClassHash" + } + ], + "outputs": [], + "state_mutability": "external" + } + ] + }, + { + "type": "constructor", + "name": "constructor", + "inputs": [] + }, + { + "type": "event", + "name": "dojo::contract::components::upgradeable::upgradeable_cpt::Upgraded", + "kind": "struct", + "members": [ + { + "name": "class_hash", + "type": "core::starknet::class_hash::ClassHash", + "kind": "data" + } + ] + }, + { + "type": "event", + "name": "dojo::contract::components::upgradeable::upgradeable_cpt::Event", + "kind": "enum", + "variants": [ + { + "name": "Upgraded", + "type": "dojo::contract::components::upgradeable::upgradeable_cpt::Upgraded", + "kind": "nested" + } + ] + }, + { + "type": "event", + "name": "dojo::contract::components::world_provider::world_provider_cpt::Event", + "kind": "enum", + "variants": [] + }, + { + "type": "event", + "name": "dojo_starter::systems::actions::actions::Event", + "kind": "enum", + "variants": [ + { + "name": "UpgradeableEvent", + "type": "dojo::contract::components::upgradeable::upgradeable_cpt::Event", + "kind": "nested" + }, + { + "name": "WorldProviderEvent", + "type": "dojo::contract::components::world_provider::world_provider_cpt::Event", + "kind": "nested" + } + ] + } + ], + "init_calldata": [], + "tag": "dojo_starter-actions", + "selector": "0x7a1c71029f2d0b38e3ac89b09931d08b6e48417e079c289ff19a8698d0cba33", + "systems": ["spawn", "move", "upgrade"] + } + ], + "models": [ + { + "members": [], + "class_hash": "0x2e99a114233093bc3ffbebd3772d7e3bb4089810e35989e14b399dceca393d0", + "tag": "dojo_starter-DirectionsAvailable", + "selector": "0x77844f1facb51e60e546a9832d56c6bd04fa23be4fd5b57290caae5e9a3c1e4" + }, + { + "members": [], + "class_hash": "0x526723ade660d893ae0f7a5c756c97664fa94ef8cae34b078a032f59a62840", + "tag": "dojo_starter-Moves", + "selector": "0x2a29373f1af8348bd366a990eb3a342ef2cbe5e85160539eaca3441a673f468" + }, + { + "members": [], + "class_hash": "0x18b0c5c5c7d2574023d174ac2326cff5e8c2ba62672bc032803bed54515fb58", + "tag": "dojo_starter-Position", + "selector": "0x2ac8b4c190f7031b9fc44312e6b047a1dce0b3f2957c33a935ca7846a46dd5b" + }, + { + "members": [], + "class_hash": "0x4518971c1abf10a6c1c40f8f72fc34816dee4752d66f0f2b9d29a62f4fb3310", + "tag": "dojo_starter-PositionCount", + "selector": "0x44e8e8c3aea54e97e01563cacc08abb4a8ce8c468cd4d3a332bca12bfc2290d" + } + ] + } +} diff --git a/examples/example-vite-react-sdk/src/dojo_starter_dev.ts b/examples/example-vite-react-sdk/src/dojo_starter_dev.ts new file mode 100644 index 00000000..3d6024db --- /dev/null +++ b/examples/example-vite-react-sdk/src/dojo_starter_dev.ts @@ -0,0 +1,3665 @@ +// This file is auto-generated from compiled-abi.json +// Do not edit manually + +export const compiledAbi = { + abi: [ + { + type: "constructor", + name: "constructor", + inputs: [ + { + name: "world_class_hash", + type: "core::starknet::class_hash::ClassHash", + }, + ], + }, + { + type: "enum", + name: "core::bool", + variants: [ + { + name: "False", + type: "()", + }, + { + name: "True", + type: "()", + }, + ], + }, + { + type: "enum", + name: "core::option::Option::", + variants: [ + { + name: "Some", + type: "core::integer::u32", + }, + { + name: "None", + type: "()", + }, + ], + }, + { + type: "enum", + name: "core::option::Option::", + variants: [ + { + name: "Some", + type: "dojo_starter::models::Direction", + }, + { + name: "None", + type: "()", + }, + ], + }, + { + type: "enum", + name: "dojo_starter::models::Direction", + variants: [ + { + name: "Left", + type: "()", + }, + { + name: "Right", + type: "()", + }, + { + name: "Up", + type: "()", + }, + { + name: "Down", + type: "()", + }, + ], + }, + { + type: "enum", + name: "dojo::meta::introspect::Ty", + variants: [ + { + name: "Primitive", + type: "core::felt252", + }, + { + name: "Struct", + type: "dojo::meta::introspect::Struct", + }, + { + name: "Enum", + type: "dojo::meta::introspect::Enum", + }, + { + name: "Tuple", + type: "core::array::Span::", + }, + { + name: "Array", + type: "core::array::Span::", + }, + { + name: "ByteArray", + type: "()", + }, + ], + }, + { + type: "enum", + name: "dojo::meta::layout::Layout", + variants: [ + { + name: "Fixed", + type: "core::array::Span::", + }, + { + name: "Struct", + type: "core::array::Span::", + }, + { + name: "Tuple", + type: "core::array::Span::", + }, + { + name: "Array", + type: "core::array::Span::", + }, + { + name: "ByteArray", + type: "()", + }, + { + name: "Enum", + type: "core::array::Span::", + }, + ], + }, + { + type: "enum", + name: "dojo::model::definition::ModelIndex", + variants: [ + { + name: "Keys", + type: "core::array::Span::", + }, + { + name: "Id", + type: "core::felt252", + }, + { + name: "MemberId", + type: "(core::felt252, core::felt252)", + }, + ], + }, + { + type: "enum", + name: "dojo::world::resource::Resource", + variants: [ + { + name: "Model", + type: "(core::starknet::contract_address::ContractAddress, core::felt252)", + }, + { + name: "Event", + type: "(core::starknet::contract_address::ContractAddress, core::felt252)", + }, + { + name: "Contract", + type: "(core::starknet::contract_address::ContractAddress, core::felt252)", + }, + { + name: "Namespace", + type: "core::byte_array::ByteArray", + }, + { + name: "World", + type: "()", + }, + { + name: "Unregistered", + type: "()", + }, + { + name: "Library", + type: "(core::starknet::class_hash::ClassHash, core::felt252)", + }, + ], + }, + { + type: "event", + name: "dojo_starter::models::m_DirectionsAvailable::Event", + kind: "enum", + variants: [], + }, + { + type: "event", + name: "dojo_starter::models::m_Moves::Event", + kind: "enum", + variants: [], + }, + { + type: "event", + name: "dojo_starter::models::m_Position::Event", + kind: "enum", + variants: [], + }, + { + type: "event", + name: "dojo_starter::models::m_PositionCount::Event", + kind: "enum", + variants: [], + }, + { + type: "event", + name: "dojo_starter::systems::actions::actions::e_Moved::Event", + kind: "enum", + variants: [], + }, + { + type: "event", + name: "dojo_starter::systems::actions::actions::Event", + kind: "enum", + variants: [ + { + name: "UpgradeableEvent", + type: "dojo::contract::components::upgradeable::upgradeable_cpt::Event", + kind: "nested", + }, + { + name: "WorldProviderEvent", + type: "dojo::contract::components::world_provider::world_provider_cpt::Event", + kind: "nested", + }, + ], + }, + { + type: "event", + name: "dojo::contract::components::upgradeable::upgradeable_cpt::Event", + kind: "enum", + variants: [ + { + name: "Upgraded", + type: "dojo::contract::components::upgradeable::upgradeable_cpt::Upgraded", + kind: "nested", + }, + ], + }, + { + type: "event", + name: "dojo::contract::components::upgradeable::upgradeable_cpt::Upgraded", + kind: "struct", + members: [ + { + name: "class_hash", + type: "core::starknet::class_hash::ClassHash", + kind: "data", + }, + ], + }, + { + type: "event", + name: "dojo::contract::components::world_provider::world_provider_cpt::Event", + kind: "enum", + variants: [], + }, + { + type: "event", + name: "dojo::world::world_contract::world::ContractInitialized", + kind: "struct", + members: [ + { + name: "selector", + type: "core::felt252", + kind: "key", + }, + { + name: "init_calldata", + type: "core::array::Span::", + kind: "data", + }, + ], + }, + { + type: "event", + name: "dojo::world::world_contract::world::ContractRegistered", + kind: "struct", + members: [ + { + name: "name", + type: "core::byte_array::ByteArray", + kind: "key", + }, + { + name: "namespace", + type: "core::byte_array::ByteArray", + kind: "key", + }, + { + name: "address", + type: "core::starknet::contract_address::ContractAddress", + kind: "data", + }, + { + name: "class_hash", + type: "core::starknet::class_hash::ClassHash", + kind: "data", + }, + { + name: "salt", + type: "core::felt252", + kind: "data", + }, + ], + }, + { + type: "event", + name: "dojo::world::world_contract::world::ContractUpgraded", + kind: "struct", + members: [ + { + name: "selector", + type: "core::felt252", + kind: "key", + }, + { + name: "class_hash", + type: "core::starknet::class_hash::ClassHash", + kind: "data", + }, + ], + }, + { + type: "event", + name: "dojo::world::world_contract::world::Event", + kind: "enum", + variants: [ + { + name: "WorldSpawned", + type: "dojo::world::world_contract::world::WorldSpawned", + kind: "nested", + }, + { + name: "WorldUpgraded", + type: "dojo::world::world_contract::world::WorldUpgraded", + kind: "nested", + }, + { + name: "NamespaceRegistered", + type: "dojo::world::world_contract::world::NamespaceRegistered", + kind: "nested", + }, + { + name: "ModelRegistered", + type: "dojo::world::world_contract::world::ModelRegistered", + kind: "nested", + }, + { + name: "EventRegistered", + type: "dojo::world::world_contract::world::EventRegistered", + kind: "nested", + }, + { + name: "ContractRegistered", + type: "dojo::world::world_contract::world::ContractRegistered", + kind: "nested", + }, + { + name: "ModelUpgraded", + type: "dojo::world::world_contract::world::ModelUpgraded", + kind: "nested", + }, + { + name: "EventUpgraded", + type: "dojo::world::world_contract::world::EventUpgraded", + kind: "nested", + }, + { + name: "ContractUpgraded", + type: "dojo::world::world_contract::world::ContractUpgraded", + kind: "nested", + }, + { + name: "ContractInitialized", + type: "dojo::world::world_contract::world::ContractInitialized", + kind: "nested", + }, + { + name: "LibraryRegistered", + type: "dojo::world::world_contract::world::LibraryRegistered", + kind: "nested", + }, + { + name: "EventEmitted", + type: "dojo::world::world_contract::world::EventEmitted", + kind: "nested", + }, + { + name: "MetadataUpdate", + type: "dojo::world::world_contract::world::MetadataUpdate", + kind: "nested", + }, + { + name: "StoreSetRecord", + type: "dojo::world::world_contract::world::StoreSetRecord", + kind: "nested", + }, + { + name: "StoreUpdateRecord", + type: "dojo::world::world_contract::world::StoreUpdateRecord", + kind: "nested", + }, + { + name: "StoreUpdateMember", + type: "dojo::world::world_contract::world::StoreUpdateMember", + kind: "nested", + }, + { + name: "StoreDelRecord", + type: "dojo::world::world_contract::world::StoreDelRecord", + kind: "nested", + }, + { + name: "WriterUpdated", + type: "dojo::world::world_contract::world::WriterUpdated", + kind: "nested", + }, + { + name: "OwnerUpdated", + type: "dojo::world::world_contract::world::OwnerUpdated", + kind: "nested", + }, + ], + }, + { + type: "event", + name: "dojo::world::world_contract::world::EventEmitted", + kind: "struct", + members: [ + { + name: "selector", + type: "core::felt252", + kind: "key", + }, + { + name: "system_address", + type: "core::starknet::contract_address::ContractAddress", + kind: "key", + }, + { + name: "keys", + type: "core::array::Span::", + kind: "data", + }, + { + name: "values", + type: "core::array::Span::", + kind: "data", + }, + ], + }, + { + type: "event", + name: "dojo::world::world_contract::world::EventRegistered", + kind: "struct", + members: [ + { + name: "name", + type: "core::byte_array::ByteArray", + kind: "key", + }, + { + name: "namespace", + type: "core::byte_array::ByteArray", + kind: "key", + }, + { + name: "class_hash", + type: "core::starknet::class_hash::ClassHash", + kind: "data", + }, + { + name: "address", + type: "core::starknet::contract_address::ContractAddress", + kind: "data", + }, + ], + }, + { + type: "event", + name: "dojo::world::world_contract::world::EventUpgraded", + kind: "struct", + members: [ + { + name: "selector", + type: "core::felt252", + kind: "key", + }, + { + name: "class_hash", + type: "core::starknet::class_hash::ClassHash", + kind: "data", + }, + { + name: "address", + type: "core::starknet::contract_address::ContractAddress", + kind: "data", + }, + { + name: "prev_address", + type: "core::starknet::contract_address::ContractAddress", + kind: "data", + }, + ], + }, + { + type: "event", + name: "dojo::world::world_contract::world::LibraryRegistered", + kind: "struct", + members: [ + { + name: "name", + type: "core::byte_array::ByteArray", + kind: "key", + }, + { + name: "namespace", + type: "core::byte_array::ByteArray", + kind: "key", + }, + { + name: "class_hash", + type: "core::starknet::class_hash::ClassHash", + kind: "data", + }, + ], + }, + { + type: "event", + name: "dojo::world::world_contract::world::MetadataUpdate", + kind: "struct", + members: [ + { + name: "resource", + type: "core::felt252", + kind: "key", + }, + { + name: "uri", + type: "core::byte_array::ByteArray", + kind: "data", + }, + { + name: "hash", + type: "core::felt252", + kind: "data", + }, + ], + }, + { + type: "event", + name: "dojo::world::world_contract::world::ModelRegistered", + kind: "struct", + members: [ + { + name: "name", + type: "core::byte_array::ByteArray", + kind: "key", + }, + { + name: "namespace", + type: "core::byte_array::ByteArray", + kind: "key", + }, + { + name: "class_hash", + type: "core::starknet::class_hash::ClassHash", + kind: "data", + }, + { + name: "address", + type: "core::starknet::contract_address::ContractAddress", + kind: "data", + }, + ], + }, + { + type: "event", + name: "dojo::world::world_contract::world::ModelUpgraded", + kind: "struct", + members: [ + { + name: "selector", + type: "core::felt252", + kind: "key", + }, + { + name: "class_hash", + type: "core::starknet::class_hash::ClassHash", + kind: "data", + }, + { + name: "address", + type: "core::starknet::contract_address::ContractAddress", + kind: "data", + }, + { + name: "prev_address", + type: "core::starknet::contract_address::ContractAddress", + kind: "data", + }, + ], + }, + { + type: "event", + name: "dojo::world::world_contract::world::NamespaceRegistered", + kind: "struct", + members: [ + { + name: "namespace", + type: "core::byte_array::ByteArray", + kind: "key", + }, + { + name: "hash", + type: "core::felt252", + kind: "data", + }, + ], + }, + { + type: "event", + name: "dojo::world::world_contract::world::OwnerUpdated", + kind: "struct", + members: [ + { + name: "resource", + type: "core::felt252", + kind: "key", + }, + { + name: "contract", + type: "core::starknet::contract_address::ContractAddress", + kind: "key", + }, + { + name: "value", + type: "core::bool", + kind: "data", + }, + ], + }, + { + type: "event", + name: "dojo::world::world_contract::world::StoreDelRecord", + kind: "struct", + members: [ + { + name: "selector", + type: "core::felt252", + kind: "key", + }, + { + name: "entity_id", + type: "core::felt252", + kind: "key", + }, + ], + }, + { + type: "event", + name: "dojo::world::world_contract::world::StoreSetRecord", + kind: "struct", + members: [ + { + name: "selector", + type: "core::felt252", + kind: "key", + }, + { + name: "entity_id", + type: "core::felt252", + kind: "key", + }, + { + name: "keys", + type: "core::array::Span::", + kind: "data", + }, + { + name: "values", + type: "core::array::Span::", + kind: "data", + }, + ], + }, + { + type: "event", + name: "dojo::world::world_contract::world::StoreUpdateMember", + kind: "struct", + members: [ + { + name: "selector", + type: "core::felt252", + kind: "key", + }, + { + name: "entity_id", + type: "core::felt252", + kind: "key", + }, + { + name: "member_selector", + type: "core::felt252", + kind: "key", + }, + { + name: "values", + type: "core::array::Span::", + kind: "data", + }, + ], + }, + { + type: "event", + name: "dojo::world::world_contract::world::StoreUpdateRecord", + kind: "struct", + members: [ + { + name: "selector", + type: "core::felt252", + kind: "key", + }, + { + name: "entity_id", + type: "core::felt252", + kind: "key", + }, + { + name: "values", + type: "core::array::Span::", + kind: "data", + }, + ], + }, + { + type: "event", + name: "dojo::world::world_contract::world::WorldSpawned", + kind: "struct", + members: [ + { + name: "creator", + type: "core::starknet::contract_address::ContractAddress", + kind: "data", + }, + { + name: "class_hash", + type: "core::starknet::class_hash::ClassHash", + kind: "data", + }, + ], + }, + { + type: "event", + name: "dojo::world::world_contract::world::WorldUpgraded", + kind: "struct", + members: [ + { + name: "class_hash", + type: "core::starknet::class_hash::ClassHash", + kind: "data", + }, + ], + }, + { + type: "event", + name: "dojo::world::world_contract::world::WriterUpdated", + kind: "struct", + members: [ + { + name: "resource", + type: "core::felt252", + kind: "key", + }, + { + name: "contract", + type: "core::starknet::contract_address::ContractAddress", + kind: "key", + }, + { + name: "value", + type: "core::bool", + kind: "data", + }, + ], + }, + { + type: "function", + name: "dojo_init", + inputs: [], + outputs: [], + state_mutability: "view", + }, + { + type: "function", + name: "ensure_abi", + inputs: [ + { + name: "model", + type: "dojo_starter::models::Position", + }, + ], + outputs: [], + state_mutability: "view", + }, + { + type: "function", + name: "ensure_unique", + inputs: [], + outputs: [], + state_mutability: "view", + }, + { + type: "function", + name: "ensure_values", + inputs: [ + { + name: "value", + type: "dojo_starter::models::PositionValue", + }, + ], + outputs: [], + state_mutability: "view", + }, + { + type: "impl", + name: "actions__ContractImpl", + interface_name: "dojo::contract::interface::IContract", + }, + { + type: "impl", + name: "actions__DeployedContractImpl", + interface_name: "dojo::meta::interface::IDeployedResource", + }, + { + type: "impl", + name: "ActionsImpl", + interface_name: "dojo_starter::systems::actions::IActions", + }, + { + type: "impl", + name: "DirectionsAvailable__DojoDeployedModelImpl", + interface_name: "dojo::meta::interface::IDeployedResource", + }, + { + type: "impl", + name: "DirectionsAvailable__DojoModelImpl", + interface_name: "dojo::model::interface::IModel", + }, + { + type: "impl", + name: "DirectionsAvailable__DojoStoredModelImpl", + interface_name: "dojo::meta::interface::IStoredResource", + }, + { + type: "impl", + name: "Moved__DeployedEventImpl", + interface_name: "dojo::meta::interface::IDeployedResource", + }, + { + type: "impl", + name: "Moved__EventImpl", + interface_name: "dojo::event::interface::IEvent", + }, + { + type: "impl", + name: "Moved__StoredEventImpl", + interface_name: "dojo::meta::interface::IStoredResource", + }, + { + type: "impl", + name: "Moves__DojoDeployedModelImpl", + interface_name: "dojo::meta::interface::IDeployedResource", + }, + { + type: "impl", + name: "Moves__DojoModelImpl", + interface_name: "dojo::model::interface::IModel", + }, + { + type: "impl", + name: "Moves__DojoStoredModelImpl", + interface_name: "dojo::meta::interface::IStoredResource", + }, + { + type: "impl", + name: "Position__DojoDeployedModelImpl", + interface_name: "dojo::meta::interface::IDeployedResource", + }, + { + type: "impl", + name: "Position__DojoModelImpl", + interface_name: "dojo::model::interface::IModel", + }, + { + type: "impl", + name: "Position__DojoStoredModelImpl", + interface_name: "dojo::meta::interface::IStoredResource", + }, + { + type: "impl", + name: "PositionCount__DojoDeployedModelImpl", + interface_name: "dojo::meta::interface::IDeployedResource", + }, + { + type: "impl", + name: "PositionCount__DojoModelImpl", + interface_name: "dojo::model::interface::IModel", + }, + { + type: "impl", + name: "PositionCount__DojoStoredModelImpl", + interface_name: "dojo::meta::interface::IStoredResource", + }, + { + type: "impl", + name: "UpgradeableImpl", + interface_name: + "dojo::contract::components::upgradeable::IUpgradeable", + }, + { + type: "impl", + name: "UpgradeableWorld", + interface_name: "dojo::world::iworld::IUpgradeableWorld", + }, + { + type: "impl", + name: "World", + interface_name: "dojo::world::iworld::IWorld", + }, + { + type: "impl", + name: "WorldProviderImpl", + interface_name: + "dojo::contract::components::world_provider::IWorldProvider", + }, + { + type: "interface", + name: "dojo_starter::systems::actions::IActions", + items: [ + { + type: "function", + name: "spawn", + inputs: [], + outputs: [], + state_mutability: "external", + }, + { + type: "function", + name: "move", + inputs: [ + { + name: "direction", + type: "dojo_starter::models::Direction", + }, + ], + outputs: [], + state_mutability: "external", + }, + ], + }, + { + type: "interface", + name: "dojo::contract::components::upgradeable::IUpgradeable", + items: [ + { + type: "function", + name: "upgrade", + inputs: [ + { + name: "new_class_hash", + type: "core::starknet::class_hash::ClassHash", + }, + ], + outputs: [], + state_mutability: "external", + }, + ], + }, + { + type: "interface", + name: "dojo::contract::components::world_provider::IWorldProvider", + items: [ + { + type: "function", + name: "world_dispatcher", + inputs: [], + outputs: [ + { + type: "dojo::world::iworld::IWorldDispatcher", + }, + ], + state_mutability: "view", + }, + ], + }, + { + type: "interface", + name: "dojo::contract::interface::IContract", + items: [], + }, + { + type: "interface", + name: "dojo::event::interface::IEvent", + items: [ + { + type: "function", + name: "definition", + inputs: [], + outputs: [ + { + type: "dojo::event::event::EventDef", + }, + ], + state_mutability: "view", + }, + ], + }, + { + type: "interface", + name: "dojo::meta::interface::IDeployedResource", + items: [ + { + type: "function", + name: "dojo_name", + inputs: [], + outputs: [ + { + type: "core::byte_array::ByteArray", + }, + ], + state_mutability: "view", + }, + ], + }, + { + type: "interface", + name: "dojo::meta::interface::IStoredResource", + items: [ + { + type: "function", + name: "layout", + inputs: [], + outputs: [ + { + type: "dojo::meta::layout::Layout", + }, + ], + state_mutability: "view", + }, + { + type: "function", + name: "schema", + inputs: [], + outputs: [ + { + type: "dojo::meta::introspect::Struct", + }, + ], + state_mutability: "view", + }, + ], + }, + { + type: "interface", + name: "dojo::model::interface::IModel", + items: [ + { + type: "function", + name: "unpacked_size", + inputs: [], + outputs: [ + { + type: "core::option::Option::", + }, + ], + state_mutability: "view", + }, + { + type: "function", + name: "packed_size", + inputs: [], + outputs: [ + { + type: "core::option::Option::", + }, + ], + state_mutability: "view", + }, + { + type: "function", + name: "definition", + inputs: [], + outputs: [ + { + type: "dojo::model::definition::ModelDef", + }, + ], + state_mutability: "view", + }, + ], + }, + { + type: "interface", + name: "dojo::world::iworld::IUpgradeableWorld", + items: [ + { + type: "function", + name: "upgrade", + inputs: [ + { + name: "new_class_hash", + type: "core::starknet::class_hash::ClassHash", + }, + ], + outputs: [], + state_mutability: "external", + }, + ], + }, + { + type: "interface", + name: "dojo::world::iworld::IWorld", + items: [ + { + type: "function", + name: "resource", + inputs: [ + { + name: "selector", + type: "core::felt252", + }, + ], + outputs: [ + { + type: "dojo::world::resource::Resource", + }, + ], + state_mutability: "view", + }, + { + type: "function", + name: "uuid", + inputs: [], + outputs: [ + { + type: "core::integer::u32", + }, + ], + state_mutability: "external", + }, + { + type: "function", + name: "metadata", + inputs: [ + { + name: "resource_selector", + type: "core::felt252", + }, + ], + outputs: [ + { + type: "dojo::model::metadata::ResourceMetadata", + }, + ], + state_mutability: "view", + }, + { + type: "function", + name: "set_metadata", + inputs: [ + { + name: "metadata", + type: "dojo::model::metadata::ResourceMetadata", + }, + ], + outputs: [], + state_mutability: "external", + }, + { + type: "function", + name: "register_namespace", + inputs: [ + { + name: "namespace", + type: "core::byte_array::ByteArray", + }, + ], + outputs: [], + state_mutability: "external", + }, + { + type: "function", + name: "register_event", + inputs: [ + { + name: "namespace", + type: "core::byte_array::ByteArray", + }, + { + name: "class_hash", + type: "core::starknet::class_hash::ClassHash", + }, + ], + outputs: [], + state_mutability: "external", + }, + { + type: "function", + name: "register_model", + inputs: [ + { + name: "namespace", + type: "core::byte_array::ByteArray", + }, + { + name: "class_hash", + type: "core::starknet::class_hash::ClassHash", + }, + ], + outputs: [], + state_mutability: "external", + }, + { + type: "function", + name: "register_contract", + inputs: [ + { + name: "salt", + type: "core::felt252", + }, + { + name: "namespace", + type: "core::byte_array::ByteArray", + }, + { + name: "class_hash", + type: "core::starknet::class_hash::ClassHash", + }, + ], + outputs: [ + { + type: "core::starknet::contract_address::ContractAddress", + }, + ], + state_mutability: "external", + }, + { + type: "function", + name: "register_library", + inputs: [ + { + name: "namespace", + type: "core::byte_array::ByteArray", + }, + { + name: "class_hash", + type: "core::starknet::class_hash::ClassHash", + }, + { + name: "name", + type: "core::byte_array::ByteArray", + }, + { + name: "version", + type: "core::byte_array::ByteArray", + }, + ], + outputs: [ + { + type: "core::starknet::class_hash::ClassHash", + }, + ], + state_mutability: "external", + }, + { + type: "function", + name: "init_contract", + inputs: [ + { + name: "selector", + type: "core::felt252", + }, + { + name: "init_calldata", + type: "core::array::Span::", + }, + ], + outputs: [], + state_mutability: "external", + }, + { + type: "function", + name: "upgrade_event", + inputs: [ + { + name: "namespace", + type: "core::byte_array::ByteArray", + }, + { + name: "class_hash", + type: "core::starknet::class_hash::ClassHash", + }, + ], + outputs: [], + state_mutability: "external", + }, + { + type: "function", + name: "upgrade_model", + inputs: [ + { + name: "namespace", + type: "core::byte_array::ByteArray", + }, + { + name: "class_hash", + type: "core::starknet::class_hash::ClassHash", + }, + ], + outputs: [], + state_mutability: "external", + }, + { + type: "function", + name: "upgrade_contract", + inputs: [ + { + name: "namespace", + type: "core::byte_array::ByteArray", + }, + { + name: "class_hash", + type: "core::starknet::class_hash::ClassHash", + }, + ], + outputs: [ + { + type: "core::starknet::class_hash::ClassHash", + }, + ], + state_mutability: "external", + }, + { + type: "function", + name: "emit_event", + inputs: [ + { + name: "event_selector", + type: "core::felt252", + }, + { + name: "keys", + type: "core::array::Span::", + }, + { + name: "values", + type: "core::array::Span::", + }, + ], + outputs: [], + state_mutability: "external", + }, + { + type: "function", + name: "emit_events", + inputs: [ + { + name: "event_selector", + type: "core::felt252", + }, + { + name: "keys", + type: "core::array::Span::>", + }, + { + name: "values", + type: "core::array::Span::>", + }, + ], + outputs: [], + state_mutability: "external", + }, + { + type: "function", + name: "entity", + inputs: [ + { + name: "model_selector", + type: "core::felt252", + }, + { + name: "index", + type: "dojo::model::definition::ModelIndex", + }, + { + name: "layout", + type: "dojo::meta::layout::Layout", + }, + ], + outputs: [ + { + type: "core::array::Span::", + }, + ], + state_mutability: "view", + }, + { + type: "function", + name: "entities", + inputs: [ + { + name: "model_selector", + type: "core::felt252", + }, + { + name: "indexes", + type: "core::array::Span::", + }, + { + name: "layout", + type: "dojo::meta::layout::Layout", + }, + ], + outputs: [ + { + type: "core::array::Span::>", + }, + ], + state_mutability: "view", + }, + { + type: "function", + name: "set_entity", + inputs: [ + { + name: "model_selector", + type: "core::felt252", + }, + { + name: "index", + type: "dojo::model::definition::ModelIndex", + }, + { + name: "values", + type: "core::array::Span::", + }, + { + name: "layout", + type: "dojo::meta::layout::Layout", + }, + ], + outputs: [], + state_mutability: "external", + }, + { + type: "function", + name: "set_entities", + inputs: [ + { + name: "model_selector", + type: "core::felt252", + }, + { + name: "indexes", + type: "core::array::Span::", + }, + { + name: "values", + type: "core::array::Span::>", + }, + { + name: "layout", + type: "dojo::meta::layout::Layout", + }, + ], + outputs: [], + state_mutability: "external", + }, + { + type: "function", + name: "delete_entity", + inputs: [ + { + name: "model_selector", + type: "core::felt252", + }, + { + name: "index", + type: "dojo::model::definition::ModelIndex", + }, + { + name: "layout", + type: "dojo::meta::layout::Layout", + }, + ], + outputs: [], + state_mutability: "external", + }, + { + type: "function", + name: "delete_entities", + inputs: [ + { + name: "model_selector", + type: "core::felt252", + }, + { + name: "indexes", + type: "core::array::Span::", + }, + { + name: "layout", + type: "dojo::meta::layout::Layout", + }, + ], + outputs: [], + state_mutability: "external", + }, + { + type: "function", + name: "is_owner", + inputs: [ + { + name: "resource", + type: "core::felt252", + }, + { + name: "address", + type: "core::starknet::contract_address::ContractAddress", + }, + ], + outputs: [ + { + type: "core::bool", + }, + ], + state_mutability: "view", + }, + { + type: "function", + name: "grant_owner", + inputs: [ + { + name: "resource", + type: "core::felt252", + }, + { + name: "address", + type: "core::starknet::contract_address::ContractAddress", + }, + ], + outputs: [], + state_mutability: "external", + }, + { + type: "function", + name: "revoke_owner", + inputs: [ + { + name: "resource", + type: "core::felt252", + }, + { + name: "address", + type: "core::starknet::contract_address::ContractAddress", + }, + ], + outputs: [], + state_mutability: "external", + }, + { + type: "function", + name: "owners_count", + inputs: [ + { + name: "resource", + type: "core::felt252", + }, + ], + outputs: [ + { + type: "core::integer::u64", + }, + ], + state_mutability: "view", + }, + { + type: "function", + name: "is_writer", + inputs: [ + { + name: "resource", + type: "core::felt252", + }, + { + name: "contract", + type: "core::starknet::contract_address::ContractAddress", + }, + ], + outputs: [ + { + type: "core::bool", + }, + ], + state_mutability: "view", + }, + { + type: "function", + name: "grant_writer", + inputs: [ + { + name: "resource", + type: "core::felt252", + }, + { + name: "contract", + type: "core::starknet::contract_address::ContractAddress", + }, + ], + outputs: [], + state_mutability: "external", + }, + { + type: "function", + name: "revoke_writer", + inputs: [ + { + name: "resource", + type: "core::felt252", + }, + { + name: "contract", + type: "core::starknet::contract_address::ContractAddress", + }, + ], + outputs: [], + state_mutability: "external", + }, + ], + }, + { + type: "struct", + name: "core::array::Span::<(core::felt252, dojo::meta::introspect::Ty)>", + members: [ + { + name: "snapshot", + type: "@core::array::Array::<(core::felt252, dojo::meta::introspect::Ty)>", + }, + ], + }, + { + type: "struct", + name: "core::array::Span::<(core::integer::u8, core::integer::u128)>", + members: [ + { + name: "snapshot", + type: "@core::array::Array::<(core::integer::u8, core::integer::u128)>", + }, + ], + }, + { + type: "struct", + name: "core::array::Span::>", + members: [ + { + name: "snapshot", + type: "@core::array::Array::>", + }, + ], + }, + { + type: "struct", + name: "core::array::Span::", + members: [ + { + name: "snapshot", + type: "@core::array::Array::", + }, + ], + }, + { + type: "struct", + name: "core::array::Span::", + members: [ + { + name: "snapshot", + type: "@core::array::Array::", + }, + ], + }, + { + type: "struct", + name: "core::array::Span::", + members: [ + { + name: "snapshot", + type: "@core::array::Array::", + }, + ], + }, + { + type: "struct", + name: "core::array::Span::", + members: [ + { + name: "snapshot", + type: "@core::array::Array::", + }, + ], + }, + { + type: "struct", + name: "core::array::Span::", + members: [ + { + name: "snapshot", + type: "@core::array::Array::", + }, + ], + }, + { + type: "struct", + name: "core::array::Span::", + members: [ + { + name: "snapshot", + type: "@core::array::Array::", + }, + ], + }, + { + type: "struct", + name: "core::array::Span::", + members: [ + { + name: "snapshot", + type: "@core::array::Array::", + }, + ], + }, + { + type: "struct", + name: "core::byte_array::ByteArray", + members: [ + { + name: "data", + type: "core::array::Array::", + }, + { + name: "pending_word", + type: "core::felt252", + }, + { + name: "pending_word_len", + type: "core::integer::u32", + }, + ], + }, + { + type: "struct", + name: "dojo_starter::models::DirectionsAvailable", + members: [ + { + name: "player", + type: "core::starknet::contract_address::ContractAddress", + }, + { + name: "directions", + type: "core::array::Array::", + }, + ], + }, + { + type: "struct", + name: "dojo_starter::models::DirectionsAvailableValue", + members: [ + { + name: "directions", + type: "core::array::Array::", + }, + ], + }, + { + type: "struct", + name: "dojo_starter::models::Moves", + members: [ + { + name: "player", + type: "core::starknet::contract_address::ContractAddress", + }, + { + name: "remaining", + type: "core::integer::u8", + }, + { + name: "last_direction", + type: "core::option::Option::", + }, + { + name: "can_move", + type: "core::bool", + }, + ], + }, + { + type: "struct", + name: "dojo_starter::models::MovesValue", + members: [ + { + name: "remaining", + type: "core::integer::u8", + }, + { + name: "last_direction", + type: "core::option::Option::", + }, + { + name: "can_move", + type: "core::bool", + }, + ], + }, + { + type: "struct", + name: "dojo_starter::models::Position", + members: [ + { + name: "player", + type: "core::starknet::contract_address::ContractAddress", + }, + { + name: "vec", + type: "dojo_starter::models::Vec2", + }, + ], + }, + { + type: "struct", + name: "dojo_starter::models::PositionCount", + members: [ + { + name: "identity", + type: "core::starknet::contract_address::ContractAddress", + }, + { + name: "position", + type: "core::array::Span::<(core::integer::u8, core::integer::u128)>", + }, + ], + }, + { + type: "struct", + name: "dojo_starter::models::PositionCountValue", + members: [ + { + name: "position", + type: "core::array::Span::<(core::integer::u8, core::integer::u128)>", + }, + ], + }, + { + type: "struct", + name: "dojo_starter::models::PositionValue", + members: [ + { + name: "vec", + type: "dojo_starter::models::Vec2", + }, + ], + }, + { + type: "struct", + name: "dojo_starter::models::Vec2", + members: [ + { + name: "x", + type: "core::integer::u32", + }, + { + name: "y", + type: "core::integer::u32", + }, + ], + }, + { + type: "struct", + name: "dojo_starter::systems::actions::actions::Moved", + members: [ + { + name: "player", + type: "core::starknet::contract_address::ContractAddress", + }, + { + name: "direction", + type: "dojo_starter::models::Direction", + }, + ], + }, + { + type: "struct", + name: "dojo_starter::systems::actions::actions::MovedValue", + members: [ + { + name: "direction", + type: "dojo_starter::models::Direction", + }, + ], + }, + { + type: "struct", + name: "dojo::event::event::EventDef", + members: [ + { + name: "name", + type: "core::byte_array::ByteArray", + }, + { + name: "layout", + type: "dojo::meta::layout::Layout", + }, + { + name: "schema", + type: "dojo::meta::introspect::Struct", + }, + ], + }, + { + type: "struct", + name: "dojo::meta::introspect::Enum", + members: [ + { + name: "name", + type: "core::felt252", + }, + { + name: "attrs", + type: "core::array::Span::", + }, + { + name: "children", + type: "core::array::Span::<(core::felt252, dojo::meta::introspect::Ty)>", + }, + ], + }, + { + type: "struct", + name: "dojo::meta::introspect::Member", + members: [ + { + name: "name", + type: "core::felt252", + }, + { + name: "attrs", + type: "core::array::Span::", + }, + { + name: "ty", + type: "dojo::meta::introspect::Ty", + }, + ], + }, + { + type: "struct", + name: "dojo::meta::introspect::Struct", + members: [ + { + name: "name", + type: "core::felt252", + }, + { + name: "attrs", + type: "core::array::Span::", + }, + { + name: "children", + type: "core::array::Span::", + }, + ], + }, + { + type: "struct", + name: "dojo::meta::layout::FieldLayout", + members: [ + { + name: "selector", + type: "core::felt252", + }, + { + name: "layout", + type: "dojo::meta::layout::Layout", + }, + ], + }, + { + type: "struct", + name: "dojo::model::definition::ModelDef", + members: [ + { + name: "name", + type: "core::byte_array::ByteArray", + }, + { + name: "layout", + type: "dojo::meta::layout::Layout", + }, + { + name: "schema", + type: "dojo::meta::introspect::Struct", + }, + { + name: "packed_size", + type: "core::option::Option::", + }, + { + name: "unpacked_size", + type: "core::option::Option::", + }, + ], + }, + { + type: "struct", + name: "dojo::model::metadata::ResourceMetadata", + members: [ + { + name: "resource_id", + type: "core::felt252", + }, + { + name: "metadata_uri", + type: "core::byte_array::ByteArray", + }, + { + name: "metadata_hash", + type: "core::felt252", + }, + ], + }, + { + type: "struct", + name: "dojo::world::iworld::IWorldDispatcher", + members: [ + { + name: "contract_address", + type: "core::starknet::contract_address::ContractAddress", + }, + ], + }, + ], + manifest: { + world: { + class_hash: + "0x685ed02eefa98fe7e208aa295042e9bbad8029b0d3d6f0ba2b32546efe0a1f9", + address: + "0x58565b92f55fb07b53940b4b7eea3df2ac2878210e5c7a4c68201e8c511a546", + seed: "dojo_starter", + name: "Dojo starter", + entrypoints: [ + "uuid", + "set_metadata", + "register_namespace", + "register_event", + "register_model", + "register_contract", + "register_library", + "init_contract", + "upgrade_event", + "upgrade_model", + "upgrade_contract", + "emit_event", + "emit_events", + "set_entity", + "set_entities", + "delete_entity", + "delete_entities", + "grant_owner", + "revoke_owner", + "grant_writer", + "revoke_writer", + "upgrade", + ], + abi: [ + { + type: "impl", + name: "World", + interface_name: "dojo::world::iworld::IWorld", + }, + { + type: "struct", + name: "core::byte_array::ByteArray", + members: [ + { + name: "data", + type: "core::array::Array::", + }, + { + name: "pending_word", + type: "core::felt252", + }, + { + name: "pending_word_len", + type: "core::integer::u32", + }, + ], + }, + { + type: "enum", + name: "dojo::world::resource::Resource", + variants: [ + { + name: "Model", + type: "(core::starknet::contract_address::ContractAddress, core::felt252)", + }, + { + name: "Event", + type: "(core::starknet::contract_address::ContractAddress, core::felt252)", + }, + { + name: "Contract", + type: "(core::starknet::contract_address::ContractAddress, core::felt252)", + }, + { + name: "Namespace", + type: "core::byte_array::ByteArray", + }, + { + name: "World", + type: "()", + }, + { + name: "Unregistered", + type: "()", + }, + { + name: "Library", + type: "(core::starknet::class_hash::ClassHash, core::felt252)", + }, + ], + }, + { + type: "struct", + name: "dojo::model::metadata::ResourceMetadata", + members: [ + { + name: "resource_id", + type: "core::felt252", + }, + { + name: "metadata_uri", + type: "core::byte_array::ByteArray", + }, + { + name: "metadata_hash", + type: "core::felt252", + }, + ], + }, + { + type: "struct", + name: "core::array::Span::", + members: [ + { + name: "snapshot", + type: "@core::array::Array::", + }, + ], + }, + { + type: "struct", + name: "core::array::Span::>", + members: [ + { + name: "snapshot", + type: "@core::array::Array::>", + }, + ], + }, + { + type: "enum", + name: "dojo::model::definition::ModelIndex", + variants: [ + { + name: "Keys", + type: "core::array::Span::", + }, + { + name: "Id", + type: "core::felt252", + }, + { + name: "MemberId", + type: "(core::felt252, core::felt252)", + }, + ], + }, + { + type: "struct", + name: "core::array::Span::", + members: [ + { + name: "snapshot", + type: "@core::array::Array::", + }, + ], + }, + { + type: "struct", + name: "dojo::meta::layout::FieldLayout", + members: [ + { + name: "selector", + type: "core::felt252", + }, + { + name: "layout", + type: "dojo::meta::layout::Layout", + }, + ], + }, + { + type: "struct", + name: "core::array::Span::", + members: [ + { + name: "snapshot", + type: "@core::array::Array::", + }, + ], + }, + { + type: "struct", + name: "core::array::Span::", + members: [ + { + name: "snapshot", + type: "@core::array::Array::", + }, + ], + }, + { + type: "enum", + name: "dojo::meta::layout::Layout", + variants: [ + { + name: "Fixed", + type: "core::array::Span::", + }, + { + name: "Struct", + type: "core::array::Span::", + }, + { + name: "Tuple", + type: "core::array::Span::", + }, + { + name: "Array", + type: "core::array::Span::", + }, + { + name: "ByteArray", + type: "()", + }, + { + name: "Enum", + type: "core::array::Span::", + }, + ], + }, + { + type: "struct", + name: "core::array::Span::", + members: [ + { + name: "snapshot", + type: "@core::array::Array::", + }, + ], + }, + { + type: "enum", + name: "core::bool", + variants: [ + { + name: "False", + type: "()", + }, + { + name: "True", + type: "()", + }, + ], + }, + { + type: "interface", + name: "dojo::world::iworld::IWorld", + items: [ + { + type: "function", + name: "resource", + inputs: [ + { + name: "selector", + type: "core::felt252", + }, + ], + outputs: [ + { + type: "dojo::world::resource::Resource", + }, + ], + state_mutability: "view", + }, + { + type: "function", + name: "uuid", + inputs: [], + outputs: [ + { + type: "core::integer::u32", + }, + ], + state_mutability: "external", + }, + { + type: "function", + name: "metadata", + inputs: [ + { + name: "resource_selector", + type: "core::felt252", + }, + ], + outputs: [ + { + type: "dojo::model::metadata::ResourceMetadata", + }, + ], + state_mutability: "view", + }, + { + type: "function", + name: "set_metadata", + inputs: [ + { + name: "metadata", + type: "dojo::model::metadata::ResourceMetadata", + }, + ], + outputs: [], + state_mutability: "external", + }, + { + type: "function", + name: "register_namespace", + inputs: [ + { + name: "namespace", + type: "core::byte_array::ByteArray", + }, + ], + outputs: [], + state_mutability: "external", + }, + { + type: "function", + name: "register_event", + inputs: [ + { + name: "namespace", + type: "core::byte_array::ByteArray", + }, + { + name: "class_hash", + type: "core::starknet::class_hash::ClassHash", + }, + ], + outputs: [], + state_mutability: "external", + }, + { + type: "function", + name: "register_model", + inputs: [ + { + name: "namespace", + type: "core::byte_array::ByteArray", + }, + { + name: "class_hash", + type: "core::starknet::class_hash::ClassHash", + }, + ], + outputs: [], + state_mutability: "external", + }, + { + type: "function", + name: "register_contract", + inputs: [ + { + name: "salt", + type: "core::felt252", + }, + { + name: "namespace", + type: "core::byte_array::ByteArray", + }, + { + name: "class_hash", + type: "core::starknet::class_hash::ClassHash", + }, + ], + outputs: [ + { + type: "core::starknet::contract_address::ContractAddress", + }, + ], + state_mutability: "external", + }, + { + type: "function", + name: "register_library", + inputs: [ + { + name: "namespace", + type: "core::byte_array::ByteArray", + }, + { + name: "class_hash", + type: "core::starknet::class_hash::ClassHash", + }, + { + name: "name", + type: "core::byte_array::ByteArray", + }, + { + name: "version", + type: "core::byte_array::ByteArray", + }, + ], + outputs: [ + { + type: "core::starknet::class_hash::ClassHash", + }, + ], + state_mutability: "external", + }, + { + type: "function", + name: "init_contract", + inputs: [ + { + name: "selector", + type: "core::felt252", + }, + { + name: "init_calldata", + type: "core::array::Span::", + }, + ], + outputs: [], + state_mutability: "external", + }, + { + type: "function", + name: "upgrade_event", + inputs: [ + { + name: "namespace", + type: "core::byte_array::ByteArray", + }, + { + name: "class_hash", + type: "core::starknet::class_hash::ClassHash", + }, + ], + outputs: [], + state_mutability: "external", + }, + { + type: "function", + name: "upgrade_model", + inputs: [ + { + name: "namespace", + type: "core::byte_array::ByteArray", + }, + { + name: "class_hash", + type: "core::starknet::class_hash::ClassHash", + }, + ], + outputs: [], + state_mutability: "external", + }, + { + type: "function", + name: "upgrade_contract", + inputs: [ + { + name: "namespace", + type: "core::byte_array::ByteArray", + }, + { + name: "class_hash", + type: "core::starknet::class_hash::ClassHash", + }, + ], + outputs: [ + { + type: "core::starknet::class_hash::ClassHash", + }, + ], + state_mutability: "external", + }, + { + type: "function", + name: "emit_event", + inputs: [ + { + name: "event_selector", + type: "core::felt252", + }, + { + name: "keys", + type: "core::array::Span::", + }, + { + name: "values", + type: "core::array::Span::", + }, + ], + outputs: [], + state_mutability: "external", + }, + { + type: "function", + name: "emit_events", + inputs: [ + { + name: "event_selector", + type: "core::felt252", + }, + { + name: "keys", + type: "core::array::Span::>", + }, + { + name: "values", + type: "core::array::Span::>", + }, + ], + outputs: [], + state_mutability: "external", + }, + { + type: "function", + name: "entity", + inputs: [ + { + name: "model_selector", + type: "core::felt252", + }, + { + name: "index", + type: "dojo::model::definition::ModelIndex", + }, + { + name: "layout", + type: "dojo::meta::layout::Layout", + }, + ], + outputs: [ + { + type: "core::array::Span::", + }, + ], + state_mutability: "view", + }, + { + type: "function", + name: "entities", + inputs: [ + { + name: "model_selector", + type: "core::felt252", + }, + { + name: "indexes", + type: "core::array::Span::", + }, + { + name: "layout", + type: "dojo::meta::layout::Layout", + }, + ], + outputs: [ + { + type: "core::array::Span::>", + }, + ], + state_mutability: "view", + }, + { + type: "function", + name: "set_entity", + inputs: [ + { + name: "model_selector", + type: "core::felt252", + }, + { + name: "index", + type: "dojo::model::definition::ModelIndex", + }, + { + name: "values", + type: "core::array::Span::", + }, + { + name: "layout", + type: "dojo::meta::layout::Layout", + }, + ], + outputs: [], + state_mutability: "external", + }, + { + type: "function", + name: "set_entities", + inputs: [ + { + name: "model_selector", + type: "core::felt252", + }, + { + name: "indexes", + type: "core::array::Span::", + }, + { + name: "values", + type: "core::array::Span::>", + }, + { + name: "layout", + type: "dojo::meta::layout::Layout", + }, + ], + outputs: [], + state_mutability: "external", + }, + { + type: "function", + name: "delete_entity", + inputs: [ + { + name: "model_selector", + type: "core::felt252", + }, + { + name: "index", + type: "dojo::model::definition::ModelIndex", + }, + { + name: "layout", + type: "dojo::meta::layout::Layout", + }, + ], + outputs: [], + state_mutability: "external", + }, + { + type: "function", + name: "delete_entities", + inputs: [ + { + name: "model_selector", + type: "core::felt252", + }, + { + name: "indexes", + type: "core::array::Span::", + }, + { + name: "layout", + type: "dojo::meta::layout::Layout", + }, + ], + outputs: [], + state_mutability: "external", + }, + { + type: "function", + name: "is_owner", + inputs: [ + { + name: "resource", + type: "core::felt252", + }, + { + name: "address", + type: "core::starknet::contract_address::ContractAddress", + }, + ], + outputs: [ + { + type: "core::bool", + }, + ], + state_mutability: "view", + }, + { + type: "function", + name: "grant_owner", + inputs: [ + { + name: "resource", + type: "core::felt252", + }, + { + name: "address", + type: "core::starknet::contract_address::ContractAddress", + }, + ], + outputs: [], + state_mutability: "external", + }, + { + type: "function", + name: "revoke_owner", + inputs: [ + { + name: "resource", + type: "core::felt252", + }, + { + name: "address", + type: "core::starknet::contract_address::ContractAddress", + }, + ], + outputs: [], + state_mutability: "external", + }, + { + type: "function", + name: "owners_count", + inputs: [ + { + name: "resource", + type: "core::felt252", + }, + ], + outputs: [ + { + type: "core::integer::u64", + }, + ], + state_mutability: "view", + }, + { + type: "function", + name: "is_writer", + inputs: [ + { + name: "resource", + type: "core::felt252", + }, + { + name: "contract", + type: "core::starknet::contract_address::ContractAddress", + }, + ], + outputs: [ + { + type: "core::bool", + }, + ], + state_mutability: "view", + }, + { + type: "function", + name: "grant_writer", + inputs: [ + { + name: "resource", + type: "core::felt252", + }, + { + name: "contract", + type: "core::starknet::contract_address::ContractAddress", + }, + ], + outputs: [], + state_mutability: "external", + }, + { + type: "function", + name: "revoke_writer", + inputs: [ + { + name: "resource", + type: "core::felt252", + }, + { + name: "contract", + type: "core::starknet::contract_address::ContractAddress", + }, + ], + outputs: [], + state_mutability: "external", + }, + ], + }, + { + type: "impl", + name: "UpgradeableWorld", + interface_name: "dojo::world::iworld::IUpgradeableWorld", + }, + { + type: "interface", + name: "dojo::world::iworld::IUpgradeableWorld", + items: [ + { + type: "function", + name: "upgrade", + inputs: [ + { + name: "new_class_hash", + type: "core::starknet::class_hash::ClassHash", + }, + ], + outputs: [], + state_mutability: "external", + }, + ], + }, + { + type: "constructor", + name: "constructor", + inputs: [ + { + name: "world_class_hash", + type: "core::starknet::class_hash::ClassHash", + }, + ], + }, + { + type: "event", + name: "dojo::world::world_contract::world::WorldSpawned", + kind: "struct", + members: [ + { + name: "creator", + type: "core::starknet::contract_address::ContractAddress", + kind: "data", + }, + { + name: "class_hash", + type: "core::starknet::class_hash::ClassHash", + kind: "data", + }, + ], + }, + { + type: "event", + name: "dojo::world::world_contract::world::WorldUpgraded", + kind: "struct", + members: [ + { + name: "class_hash", + type: "core::starknet::class_hash::ClassHash", + kind: "data", + }, + ], + }, + { + type: "event", + name: "dojo::world::world_contract::world::NamespaceRegistered", + kind: "struct", + members: [ + { + name: "namespace", + type: "core::byte_array::ByteArray", + kind: "key", + }, + { + name: "hash", + type: "core::felt252", + kind: "data", + }, + ], + }, + { + type: "event", + name: "dojo::world::world_contract::world::ModelRegistered", + kind: "struct", + members: [ + { + name: "name", + type: "core::byte_array::ByteArray", + kind: "key", + }, + { + name: "namespace", + type: "core::byte_array::ByteArray", + kind: "key", + }, + { + name: "class_hash", + type: "core::starknet::class_hash::ClassHash", + kind: "data", + }, + { + name: "address", + type: "core::starknet::contract_address::ContractAddress", + kind: "data", + }, + ], + }, + { + type: "event", + name: "dojo::world::world_contract::world::EventRegistered", + kind: "struct", + members: [ + { + name: "name", + type: "core::byte_array::ByteArray", + kind: "key", + }, + { + name: "namespace", + type: "core::byte_array::ByteArray", + kind: "key", + }, + { + name: "class_hash", + type: "core::starknet::class_hash::ClassHash", + kind: "data", + }, + { + name: "address", + type: "core::starknet::contract_address::ContractAddress", + kind: "data", + }, + ], + }, + { + type: "event", + name: "dojo::world::world_contract::world::ContractRegistered", + kind: "struct", + members: [ + { + name: "name", + type: "core::byte_array::ByteArray", + kind: "key", + }, + { + name: "namespace", + type: "core::byte_array::ByteArray", + kind: "key", + }, + { + name: "address", + type: "core::starknet::contract_address::ContractAddress", + kind: "data", + }, + { + name: "class_hash", + type: "core::starknet::class_hash::ClassHash", + kind: "data", + }, + { + name: "salt", + type: "core::felt252", + kind: "data", + }, + ], + }, + { + type: "event", + name: "dojo::world::world_contract::world::ModelUpgraded", + kind: "struct", + members: [ + { + name: "selector", + type: "core::felt252", + kind: "key", + }, + { + name: "class_hash", + type: "core::starknet::class_hash::ClassHash", + kind: "data", + }, + { + name: "address", + type: "core::starknet::contract_address::ContractAddress", + kind: "data", + }, + { + name: "prev_address", + type: "core::starknet::contract_address::ContractAddress", + kind: "data", + }, + ], + }, + { + type: "event", + name: "dojo::world::world_contract::world::EventUpgraded", + kind: "struct", + members: [ + { + name: "selector", + type: "core::felt252", + kind: "key", + }, + { + name: "class_hash", + type: "core::starknet::class_hash::ClassHash", + kind: "data", + }, + { + name: "address", + type: "core::starknet::contract_address::ContractAddress", + kind: "data", + }, + { + name: "prev_address", + type: "core::starknet::contract_address::ContractAddress", + kind: "data", + }, + ], + }, + { + type: "event", + name: "dojo::world::world_contract::world::ContractUpgraded", + kind: "struct", + members: [ + { + name: "selector", + type: "core::felt252", + kind: "key", + }, + { + name: "class_hash", + type: "core::starknet::class_hash::ClassHash", + kind: "data", + }, + ], + }, + { + type: "event", + name: "dojo::world::world_contract::world::ContractInitialized", + kind: "struct", + members: [ + { + name: "selector", + type: "core::felt252", + kind: "key", + }, + { + name: "init_calldata", + type: "core::array::Span::", + kind: "data", + }, + ], + }, + { + type: "event", + name: "dojo::world::world_contract::world::LibraryRegistered", + kind: "struct", + members: [ + { + name: "name", + type: "core::byte_array::ByteArray", + kind: "key", + }, + { + name: "namespace", + type: "core::byte_array::ByteArray", + kind: "key", + }, + { + name: "class_hash", + type: "core::starknet::class_hash::ClassHash", + kind: "data", + }, + ], + }, + { + type: "event", + name: "dojo::world::world_contract::world::EventEmitted", + kind: "struct", + members: [ + { + name: "selector", + type: "core::felt252", + kind: "key", + }, + { + name: "system_address", + type: "core::starknet::contract_address::ContractAddress", + kind: "key", + }, + { + name: "keys", + type: "core::array::Span::", + kind: "data", + }, + { + name: "values", + type: "core::array::Span::", + kind: "data", + }, + ], + }, + { + type: "event", + name: "dojo::world::world_contract::world::MetadataUpdate", + kind: "struct", + members: [ + { + name: "resource", + type: "core::felt252", + kind: "key", + }, + { + name: "uri", + type: "core::byte_array::ByteArray", + kind: "data", + }, + { + name: "hash", + type: "core::felt252", + kind: "data", + }, + ], + }, + { + type: "event", + name: "dojo::world::world_contract::world::StoreSetRecord", + kind: "struct", + members: [ + { + name: "selector", + type: "core::felt252", + kind: "key", + }, + { + name: "entity_id", + type: "core::felt252", + kind: "key", + }, + { + name: "keys", + type: "core::array::Span::", + kind: "data", + }, + { + name: "values", + type: "core::array::Span::", + kind: "data", + }, + ], + }, + { + type: "event", + name: "dojo::world::world_contract::world::StoreUpdateRecord", + kind: "struct", + members: [ + { + name: "selector", + type: "core::felt252", + kind: "key", + }, + { + name: "entity_id", + type: "core::felt252", + kind: "key", + }, + { + name: "values", + type: "core::array::Span::", + kind: "data", + }, + ], + }, + { + type: "event", + name: "dojo::world::world_contract::world::StoreUpdateMember", + kind: "struct", + members: [ + { + name: "selector", + type: "core::felt252", + kind: "key", + }, + { + name: "entity_id", + type: "core::felt252", + kind: "key", + }, + { + name: "member_selector", + type: "core::felt252", + kind: "key", + }, + { + name: "values", + type: "core::array::Span::", + kind: "data", + }, + ], + }, + { + type: "event", + name: "dojo::world::world_contract::world::StoreDelRecord", + kind: "struct", + members: [ + { + name: "selector", + type: "core::felt252", + kind: "key", + }, + { + name: "entity_id", + type: "core::felt252", + kind: "key", + }, + ], + }, + { + type: "event", + name: "dojo::world::world_contract::world::WriterUpdated", + kind: "struct", + members: [ + { + name: "resource", + type: "core::felt252", + kind: "key", + }, + { + name: "contract", + type: "core::starknet::contract_address::ContractAddress", + kind: "key", + }, + { + name: "value", + type: "core::bool", + kind: "data", + }, + ], + }, + { + type: "event", + name: "dojo::world::world_contract::world::OwnerUpdated", + kind: "struct", + members: [ + { + name: "resource", + type: "core::felt252", + kind: "key", + }, + { + name: "contract", + type: "core::starknet::contract_address::ContractAddress", + kind: "key", + }, + { + name: "value", + type: "core::bool", + kind: "data", + }, + ], + }, + { + type: "event", + name: "dojo::world::world_contract::world::Event", + kind: "enum", + variants: [ + { + name: "WorldSpawned", + type: "dojo::world::world_contract::world::WorldSpawned", + kind: "nested", + }, + { + name: "WorldUpgraded", + type: "dojo::world::world_contract::world::WorldUpgraded", + kind: "nested", + }, + { + name: "NamespaceRegistered", + type: "dojo::world::world_contract::world::NamespaceRegistered", + kind: "nested", + }, + { + name: "ModelRegistered", + type: "dojo::world::world_contract::world::ModelRegistered", + kind: "nested", + }, + { + name: "EventRegistered", + type: "dojo::world::world_contract::world::EventRegistered", + kind: "nested", + }, + { + name: "ContractRegistered", + type: "dojo::world::world_contract::world::ContractRegistered", + kind: "nested", + }, + { + name: "ModelUpgraded", + type: "dojo::world::world_contract::world::ModelUpgraded", + kind: "nested", + }, + { + name: "EventUpgraded", + type: "dojo::world::world_contract::world::EventUpgraded", + kind: "nested", + }, + { + name: "ContractUpgraded", + type: "dojo::world::world_contract::world::ContractUpgraded", + kind: "nested", + }, + { + name: "ContractInitialized", + type: "dojo::world::world_contract::world::ContractInitialized", + kind: "nested", + }, + { + name: "LibraryRegistered", + type: "dojo::world::world_contract::world::LibraryRegistered", + kind: "nested", + }, + { + name: "EventEmitted", + type: "dojo::world::world_contract::world::EventEmitted", + kind: "nested", + }, + { + name: "MetadataUpdate", + type: "dojo::world::world_contract::world::MetadataUpdate", + kind: "nested", + }, + { + name: "StoreSetRecord", + type: "dojo::world::world_contract::world::StoreSetRecord", + kind: "nested", + }, + { + name: "StoreUpdateRecord", + type: "dojo::world::world_contract::world::StoreUpdateRecord", + kind: "nested", + }, + { + name: "StoreUpdateMember", + type: "dojo::world::world_contract::world::StoreUpdateMember", + kind: "nested", + }, + { + name: "StoreDelRecord", + type: "dojo::world::world_contract::world::StoreDelRecord", + kind: "nested", + }, + { + name: "WriterUpdated", + type: "dojo::world::world_contract::world::WriterUpdated", + kind: "nested", + }, + { + name: "OwnerUpdated", + type: "dojo::world::world_contract::world::OwnerUpdated", + kind: "nested", + }, + ], + }, + ], + }, + contracts: [ + { + address: + "0x49f9b281bb08aea6d745f28cf31dd529348b04a21d9a5ae1ef19197665c02da", + class_hash: + "0x28059bba1d3a76ca9ee42d2b4fdabb41604cd6fbd95e1e33b220c6e8060b1eb", + abi: [ + { + type: "impl", + name: "actions__ContractImpl", + interface_name: "dojo::contract::interface::IContract", + }, + { + type: "interface", + name: "dojo::contract::interface::IContract", + items: [], + }, + { + type: "impl", + name: "actions__DeployedContractImpl", + interface_name: + "dojo::meta::interface::IDeployedResource", + }, + { + type: "struct", + name: "core::byte_array::ByteArray", + members: [ + { + name: "data", + type: "core::array::Array::", + }, + { + name: "pending_word", + type: "core::felt252", + }, + { + name: "pending_word_len", + type: "core::integer::u32", + }, + ], + }, + { + type: "interface", + name: "dojo::meta::interface::IDeployedResource", + items: [ + { + type: "function", + name: "dojo_name", + inputs: [], + outputs: [ + { + type: "core::byte_array::ByteArray", + }, + ], + state_mutability: "view", + }, + ], + }, + { + type: "impl", + name: "ActionsImpl", + interface_name: + "dojo_starter::systems::actions::IActions", + }, + { + type: "enum", + name: "dojo_starter::models::Direction", + variants: [ + { + name: "Left", + type: "()", + }, + { + name: "Right", + type: "()", + }, + { + name: "Up", + type: "()", + }, + { + name: "Down", + type: "()", + }, + ], + }, + { + type: "interface", + name: "dojo_starter::systems::actions::IActions", + items: [ + { + type: "function", + name: "spawn", + inputs: [], + outputs: [], + state_mutability: "external", + }, + { + type: "function", + name: "move", + inputs: [ + { + name: "direction", + type: "dojo_starter::models::Direction", + }, + ], + outputs: [], + state_mutability: "external", + }, + ], + }, + { + type: "function", + name: "dojo_init", + inputs: [], + outputs: [], + state_mutability: "view", + }, + { + type: "impl", + name: "WorldProviderImpl", + interface_name: + "dojo::contract::components::world_provider::IWorldProvider", + }, + { + type: "struct", + name: "dojo::world::iworld::IWorldDispatcher", + members: [ + { + name: "contract_address", + type: "core::starknet::contract_address::ContractAddress", + }, + ], + }, + { + type: "interface", + name: "dojo::contract::components::world_provider::IWorldProvider", + items: [ + { + type: "function", + name: "world_dispatcher", + inputs: [], + outputs: [ + { + type: "dojo::world::iworld::IWorldDispatcher", + }, + ], + state_mutability: "view", + }, + ], + }, + { + type: "impl", + name: "UpgradeableImpl", + interface_name: + "dojo::contract::components::upgradeable::IUpgradeable", + }, + { + type: "interface", + name: "dojo::contract::components::upgradeable::IUpgradeable", + items: [ + { + type: "function", + name: "upgrade", + inputs: [ + { + name: "new_class_hash", + type: "core::starknet::class_hash::ClassHash", + }, + ], + outputs: [], + state_mutability: "external", + }, + ], + }, + { + type: "constructor", + name: "constructor", + inputs: [], + }, + { + type: "event", + name: "dojo::contract::components::upgradeable::upgradeable_cpt::Upgraded", + kind: "struct", + members: [ + { + name: "class_hash", + type: "core::starknet::class_hash::ClassHash", + kind: "data", + }, + ], + }, + { + type: "event", + name: "dojo::contract::components::upgradeable::upgradeable_cpt::Event", + kind: "enum", + variants: [ + { + name: "Upgraded", + type: "dojo::contract::components::upgradeable::upgradeable_cpt::Upgraded", + kind: "nested", + }, + ], + }, + { + type: "event", + name: "dojo::contract::components::world_provider::world_provider_cpt::Event", + kind: "enum", + variants: [], + }, + { + type: "event", + name: "dojo_starter::systems::actions::actions::Event", + kind: "enum", + variants: [ + { + name: "UpgradeableEvent", + type: "dojo::contract::components::upgradeable::upgradeable_cpt::Event", + kind: "nested", + }, + { + name: "WorldProviderEvent", + type: "dojo::contract::components::world_provider::world_provider_cpt::Event", + kind: "nested", + }, + ], + }, + ], + init_calldata: [], + tag: "dojo_starter-actions", + selector: + "0x7a1c71029f2d0b38e3ac89b09931d08b6e48417e079c289ff19a8698d0cba33", + systems: ["spawn", "move", "upgrade"], + }, + ], + models: [ + { + members: [], + class_hash: + "0x2e99a114233093bc3ffbebd3772d7e3bb4089810e35989e14b399dceca393d0", + tag: "dojo_starter-DirectionsAvailable", + selector: + "0x77844f1facb51e60e546a9832d56c6bd04fa23be4fd5b57290caae5e9a3c1e4", + }, + { + members: [], + class_hash: + "0x526723ade660d893ae0f7a5c756c97664fa94ef8cae34b078a032f59a62840", + tag: "dojo_starter-Moves", + selector: + "0x2a29373f1af8348bd366a990eb3a342ef2cbe5e85160539eaca3441a673f468", + }, + { + members: [], + class_hash: + "0x18b0c5c5c7d2574023d174ac2326cff5e8c2ba62672bc032803bed54515fb58", + tag: "dojo_starter-Position", + selector: + "0x2ac8b4c190f7031b9fc44312e6b047a1dce0b3f2957c33a935ca7846a46dd5b", + }, + { + members: [], + class_hash: + "0x4518971c1abf10a6c1c40f8f72fc34816dee4752d66f0f2b9d29a62f4fb3310", + tag: "dojo_starter-PositionCount", + selector: + "0x44e8e8c3aea54e97e01563cacc08abb4a8ce8c468cd4d3a332bca12bfc2290d", + }, + ], + }, +} as const; + +export type CompiledAbi = typeof compiledAbi; diff --git a/examples/example-vite-react-sdk/src/types.ts b/examples/example-vite-react-sdk/src/types.ts new file mode 100644 index 00000000..4a83ba5b --- /dev/null +++ b/examples/example-vite-react-sdk/src/types.ts @@ -0,0 +1,14 @@ +// Compile this file using +// DOJO_ROOT="path/to/dojo-starter" bunx @dojoengine/core --output ./dojo_starter_dev.json --generate-types +import { DojoProvider, ExtractAbiTypes } from "@dojoengine/core"; +import { compiledAbi } from "./dojo_starter_dev"; +import { dojoConfig } from "../dojoConfig"; + +type DojoStarterAbi = ExtractAbiTypes; +type DojoStarterActions = + DojoStarterAbi["interfaces"]["dojo_starter::systems::actions::IActions"]; + +export const dojoProvider = new DojoProvider( + dojoConfig.manifest, + dojoConfig.rpcUrl +); diff --git a/examples/example-vite-react-sdk/src/useSystemCalls.ts b/examples/example-vite-react-sdk/src/useSystemCalls.ts index acd90645..5a9cc6ef 100644 --- a/examples/example-vite-react-sdk/src/useSystemCalls.ts +++ b/examples/example-vite-react-sdk/src/useSystemCalls.ts @@ -2,6 +2,7 @@ import { useDojoSDK } from "@dojoengine/sdk/react"; import { getEntityIdFromKeys } from "@dojoengine/utils"; import { useAccount } from "@starknet-react/core"; import { v4 as uuidv4 } from "uuid"; +import { dojoProvider } from "./types"; /** * Custom hook to handle system calls and state management in the Dojo application. @@ -11,7 +12,7 @@ import { v4 as uuidv4 } from "uuid"; * - spawn: Function to spawn a new entity with initial moves */ export const useSystemCalls = () => { - const { useDojoStore, client } = useDojoSDK(); + const { useDojoStore } = useDojoSDK(); const state = useDojoStore((state) => state); const { account } = useAccount(); @@ -50,7 +51,8 @@ export const useSystemCalls = () => { try { // Execute the spawn action from the client - await client.actions.spawn(account!); + // await client.actions.spawn(account!); + await dojoProvider.spawn(account!); // Wait for the entity to be updated with the new state await state.waitForEntityChange(entityId, (entity) => { diff --git a/examples/example-vite-react-sdk/tsconfig.app.tsbuildinfo b/examples/example-vite-react-sdk/tsconfig.app.tsbuildinfo index 9378bbd0..706aa67b 100644 --- a/examples/example-vite-react-sdk/tsconfig.app.tsbuildinfo +++ b/examples/example-vite-react-sdk/tsconfig.app.tsbuildinfo @@ -1 +1 @@ -{"root":["./src/app.tsx","./src/events.tsx","./src/historical-events.tsx","./src/main.tsx","./src/starknet-provider.tsx","./src/usesystemcalls.ts","./src/vite-env.d.ts","./src/wallet-account.tsx","./src/typescript/contracts.gen.ts","./src/typescript/models.gen.ts"],"version":"5.9.2"} \ No newline at end of file +{"root":["./src/app.tsx","./src/dojo_starter_dev.ts","./src/events.tsx","./src/historical-events.tsx","./src/main.tsx","./src/starknet-provider.tsx","./src/types.ts","./src/usesystemcalls.ts","./src/vite-env.d.ts","./src/wallet-account.tsx","./src/typescript/contracts.gen.ts","./src/typescript/models.gen.ts"],"version":"5.9.2"} \ No newline at end of file diff --git a/packages/core/src/provider/DojoProvider.ts b/packages/core/src/provider/DojoProvider.ts index c685db1b..6c4d5f19 100644 --- a/packages/core/src/provider/DojoProvider.ts +++ b/packages/core/src/provider/DojoProvider.ts @@ -19,17 +19,70 @@ import { type DojoCall, WorldEntryPoints } from "../types"; import { getContractByName, parseDojoCall } from "../utils"; import { Provider } from "./provider"; +type DojoActionInputs = Fn extends { inputs: infer Inputs } + ? keyof Inputs extends never + ? undefined + : Inputs + : undefined; + +type ActionSignature = { + inputs: object; + outputs: unknown; +}; + +export type DojoActionInterface = Record; + +type UnionToIntersection = ( + U extends unknown + ? (k: U) => void + : never +) extends (k: infer I) => void + ? I + : never; + +type EnsureActionInterface = T extends object + ? { + [K in keyof T]: T[K] extends ActionSignature ? T[K] : never; + } extends T + ? { [K in keyof T]: T[K] } + : never + : never; + +type ExtractActionUnion = Actions extends ReadonlyArray + ? EnsureActionInterface + : EnsureActionInterface; + +type NormalizeActions = EnsureActionInterface< + UnionToIntersection> +> extends infer Result + ? Result extends never + ? Record + : Result + : Record; + +type DojoActionMethod = DojoActionInputs extends undefined + ? (account: Account | AccountInterface) => Promise + : ( + account: Account | AccountInterface, + args: DojoActionInputs + ) => Promise; + +type DojoActionMethodMap = { + [K in keyof NormalizeActions & string]: DojoActionMethod< + NormalizeActions[K] + >; +}; + +type ActionMethodImplementation = ( + account: Account | AccountInterface, + args?: Record +) => Promise; + /** - * DojoProvider: The DojoProvider is an execution provider for dojo worlds. It allows you to easily interact with a dojo world via the Starknet.js library. - * ```ts - * import { DojoProvider } from "@dojoengine/core"; - * - * const provider = new DojoProvider( - * manifest - * ); - * ``` + * Core runtime implementation for the Dojo provider. Prefer using the exported `DojoProvider` + * constructor which augments this base instance with strongly typed action methods. */ -export class DojoProvider extends Provider { +class DojoProviderBase extends Provider { public provider: RpcProvider; public contract: Contract; public manifest: any; @@ -58,6 +111,8 @@ export class DojoProvider extends Provider { }); this.manifest = manifest; this.logger = new ConsoleLogger({ level: logLevel }); + + this.initializeActionMethods(); } /** @@ -270,4 +325,109 @@ export class DojoProvider extends Provider { ); } } + + private initializeActionMethods(): void { + if (!this.manifest?.contracts) { + return; + } + + const host = this as unknown as Record< + string, + ActionMethodImplementation + >; + + for (const contract of this.manifest.contracts as Array) { + if ( + !contract?.systems?.length || + typeof contract.tag !== "string" + ) { + continue; + } + + const names = this.parseContractTag(contract.tag); + if (!names) { + continue; + } + + const abiItems = Array.isArray(contract.abi) ? contract.abi : []; + + for (const systemName of contract.systems as Array) { + if (systemName in host) { + continue; + } + + const interfaceAbi = abiItems.find( + (item: any) => + item?.type === "interface" && + item?.items.find( + (i: any) => + i?.type === "function" && i?.name === systemName + ) + ); + + if (!interfaceAbi) { + continue; + } + const functionAbi = interfaceAbi.items.find( + (i: any) => i?.type === "function" && i?.name === systemName + ); + if (!functionAbi) { + continue; + } + + const expectsArgs = Array.isArray(functionAbi.inputs) + ? functionAbi.inputs.length > 0 + : false; + + host[systemName] = async ( + account: Account | AccountInterface, + args?: Record + ) => { + if (expectsArgs && args === undefined) { + throw new Error( + `Missing arguments for action "${systemName}"` + ); + } + + return this.execute( + account, + { + contractName: names.contractName, + entrypoint: systemName, + calldata: (args ?? []) as unknown as ArgsOrCalldata, + }, + names.namespace + ); + }; + } + } + } + + private parseContractTag( + tag: string + ): { namespace: string; contractName: string } | null { + const separatorIndex = tag.lastIndexOf("-"); + if (separatorIndex === -1) { + return null; + } + + return { + namespace: tag.slice(0, separatorIndex), + contractName: tag.slice(separatorIndex + 1), + }; + } } + +export type DojoProviderInstance = DojoProviderBase & + DojoActionMethodMap; + +export type DojoProvider = DojoProviderInstance; + +type DojoProviderConstructor = new ( + manifest?: any, + url?: string, + logLevel?: LogLevel +) => DojoProvider; + +export const DojoProvider = + DojoProviderBase as unknown as DojoProviderConstructor; diff --git a/packages/core/src/types/README.md b/packages/core/src/types/README.md index 15a4a39e..ec5c3308 100644 --- a/packages/core/src/types/README.md +++ b/packages/core/src/types/README.md @@ -48,13 +48,19 @@ type ModelPath = ModelPathFromAbi; // e.g. "dojo_starter-Pos ## Extracted type groups - **`structs`** – Cairo structs mapped to TypeScript objects with nested references resolved. -- **`enums`** – Cairo enums with both the variant union (`type`) and a `variants` object. +- **`enums`** – Cairo enums with a `CairoCustomEnum` instance type (or `CairoOption` for `core::option::Option`), a `variantNames` union, and a strongly typed `variants` map. - **`interfaces`** – Contract interfaces keyed by fully qualified name with typed function signatures. - **`models`** – Dojo models grouped by namespace; the shape aligns with `SchemaType` used throughout the SDK. - **`actions`** – System action interfaces grouped by namespace, preserving typed inputs and outputs. ```ts -type Direction = Abi["enums"]["dojo_starter::models::Direction"]["type"]; // "Up" | "Down" | ... +type Direction = Abi["enums"]["dojo_starter::models::Direction"]; +type DirectionValue = Direction["type"]; // CairoCustomEnum +type DirectionVariants = Direction["variantNames"]; // "Up" | "Down" | ... + +type OptionalDirection = + Abi["enums"]["core::option::Option::"]; +type OptionalDirectionValue = OptionalDirection["type"]; // CairoOption type Actions = Abi["actions"]["dojo_starter"]["IActions"]; type SpawnInputs = Actions["spawn"]["inputs"]; // { entity: Position; ... } diff --git a/packages/core/src/types/example-usage.ts b/packages/core/src/types/example-usage.ts index d18df207..88ae8e21 100644 --- a/packages/core/src/types/example-usage.ts +++ b/packages/core/src/types/example-usage.ts @@ -1,3 +1,4 @@ +import { DojoProvider } from "../provider"; import { ExtractAbiTypes, ModelsFromAbi, @@ -6,8 +7,15 @@ import { } from "./index"; // Solution 1: Import the generated TypeScript file instead -// import { compiledAbi } from "../../../../worlds/dojo-starter/compiled-abi"; -import { compiledAbi } from "./nums_dev"; +import { compiledAbi } from "../../../../worlds/dojo-starter/compiled-abi"; +import { + Account, + CairoCustomEnum, + CairoOption, + CairoOptionVariant, + ETransactionVersion, + ProviderInterface, +} from "starknet"; // Extract ABI types from the TypeScript version (this works!) type MyAbi = ExtractAbiTypes; @@ -33,6 +41,38 @@ type MyAbiStructs = MyAbi["structs"]; type MyAbiEnums = MyAbi["enums"]; type MyAbiFunctions = MyAbi["functions"]; type MyAbiInterfaces = MyAbi["interfaces"]; +type OptionnalNumber = MyAbiEnums["core::option::Option::"]; +const e = new CairoOption(CairoOptionVariant.Some, 12); + +type DojoStarterActions = + MyAbiInterfaces["dojo_starter::systems::actions::IActions"]; +type WorldActions = MyAbiInterfaces["dojo::world::iworld::IWorld"]; + +const provider = new DojoProvider<[DojoStarterActions, WorldActions]>( + compiledAbi +); +const account = new Account({ + provider: provider as unknown as ProviderInterface, + address: "0x0", + signer: "0x0", + cairoVersion: "1", + transactionVersion: ETransactionVersion.V3, +}); + +provider.spawn(account); +provider.move(account, { + direction: new CairoCustomEnum({ Left: "()" }), +}); +provider.register_contract(account, { + salt: "", + class_hash: "class_hash", + namespace: "dojo_starter", +}); +provider.delete_entities(account, { + model_selector: "test", + indexes: new CairoCustomEnum({ Id: "()" }), + layout: new CairoCustomEnum({ Fixed: "()" }), +}); // Now you can use the extracted types type Vec2 = Schema["dojo_starter"]["Vec2"]; @@ -46,10 +86,22 @@ type PositionCount = Schema["dojo_starter"]["PositionCount"]; type Direction = MyAbi["enums"]["dojo_starter::models::Direction"]; // Direction will be: { // variants: { None: void; Up: void; Down: void; Left: void; Right: void }; -// type: "None" | "Up" | "Down" | "Left" | "Right"; +// variantNames: "None" | "Up" | "Down" | "Left" | "Right"; +// type: CairoCustomEnum; // } -type DirectionType = Direction["type"]; // Union type: "None" | "Up" | "Down" | "Left" | "Right" -type DirectionVariants = Direction["variants"]; // Object with variant names as keys +type DirectionValue = Direction["type"]; // CairoCustomEnum +type DirectionVariantNames = Direction["variantNames"]; // "None" | "Up" | "Down" | "Left" | "Right" +type DirectionVariantMap = Direction["variants"]; // Object with variant names as keys + +type OptionalDirection = + MyAbi["enums"]["core::option::Option::"]; +type OptionalDirectionValue = OptionalDirection["type"]; // CairoOption +const od: OptionalDirectionValue = new CairoOption(CairoOptionVariant.None); + +const maybeDirection: OptionalDirectionValue = new CairoOption( + CairoOptionVariant.Some, + new CairoCustomEnum({ Up: "()" }) +); // Interface types - access interface functions type IWorld = MyAbi["interfaces"]["dojo::world::iworld::IWorld"]; diff --git a/packages/core/src/types/index.test.ts b/packages/core/src/types/index.test.ts index 94ad1d52..8ff8fc7a 100644 --- a/packages/core/src/types/index.test.ts +++ b/packages/core/src/types/index.test.ts @@ -1,4 +1,5 @@ import { describe, it, expectTypeOf } from "vitest"; +import { CairoCustomEnum, CairoOption } from "starknet"; import { ExtractAbiTypes, ModelPathFromAbi, @@ -37,6 +38,22 @@ const sampleAbi = { { name: "Right", type: "()" }, ], }, + { + type: "enum", + name: "core::option::Option::", + variants: [ + { name: "Some", type: "demo::models::Direction" }, + { name: "None", type: "()" }, + ], + }, + { + type: "enum", + name: "core::option::Option::", + variants: [ + { name: "Some", type: "core::integer::u32" }, + { name: "None", type: "()" }, + ], + }, { type: "function", name: "move", @@ -96,9 +113,43 @@ describe("ExtractAbiTypes", () => { }); it("exposes enums and actions with typed members", () => { + type DirectionEnum = Extracted["enums"]["demo::models::Direction"]; + + expectTypeOf().toMatchTypeOf(); + expectTypeOf().toMatchTypeOf(); + + expectTypeOf().toEqualTypeOf< + "Up" | "Down" | "Left" | "Right" + >(); + expectTypeOf().toEqualTypeOf< + "Up" | "Down" | "Left" | "Right" + >(); + + type OptionalDirection = + Extracted["enums"]["core::option::Option::"]; + + expectTypeOf().toEqualTypeOf< + CairoOption + >(); + expectTypeOf().toEqualTypeOf< + "Some" | "None" + >(); + expectTypeOf().toEqualTypeOf< + DirectionEnum["type"] + >(); + expectTypeOf< + OptionalDirection["variants"]["None"] + >().toEqualTypeOf(); + + type OptionalScore = + Extracted["enums"]["core::option::Option::"]; + + expectTypeOf().toEqualTypeOf< + CairoOption + >(); expectTypeOf< - Extracted["enums"]["demo::models::Direction"]["type"] - >().toEqualTypeOf<"Up" | "Down" | "Left" | "Right">(); + OptionalScore["variants"]["Some"] + >().toEqualTypeOf(); type Actions = ActionsFromAbi; expectTypeOf().toEqualTypeOf<"demo">(); @@ -113,7 +164,7 @@ describe("ExtractAbiTypes", () => { expectTypeOf().toEqualTypeOf<{ entity: ModelsFromAbi["demo"]["Position"]; - direction: "Up" | "Down" | "Left" | "Right"; + direction: DirectionEnum["type"]; }>(); expectTypeOf().toEqualTypeOf(); }); diff --git a/packages/core/src/types/index.ts b/packages/core/src/types/index.ts index 49ac9cc0..bf32975f 100644 --- a/packages/core/src/types/index.ts +++ b/packages/core/src/types/index.ts @@ -1,4 +1,4 @@ -import { Calldata, RawArgs } from "starknet"; +import { Calldata, CairoCustomEnum, CairoOption, RawArgs } from "starknet"; /** * Enumeration representing various entry points or functions available in the World. @@ -325,11 +325,14 @@ type ExtractEnumNames = Extract< { type: "enum"; name: string } >["name"]; -/** - * Extract just the type union of an enum by name - * This is used for type mapping in function parameters - */ -type ExtractEnumType< +type CairoEnumVariantMap< + Variants extends readonly { name: string; type: string }[], + ABI extends readonly any[], +> = { + [P in Variants[number] as P["name"]]: MapCairoType; +}; + +type ExtractEnumVariants< Name extends string, ABI extends readonly any[], > = FindFirstEnumByName extends { @@ -338,10 +341,28 @@ type ExtractEnumType< variants: infer V; } ? V extends readonly { name: string; type: string }[] - ? V[number]["name"] + ? CairoEnumVariantMap : never : never; +/** + * Extract just the type union of an enum by name + * This is used for type mapping in function parameters + */ +type ExtractEnumType< + Name extends string, + ABI extends readonly any[], +> = ExtractEnumVariants extends infer VariantMap + ? [VariantMap] extends [never] + ? never + : Name extends `core::option::Option::<${infer Inner}>` + ? CairoOption> + : CairoCustomEnum & { + readonly __variantMap?: VariantMap; + readonly __variantNames?: keyof VariantMap & string; + } + : never; + /** * Helper type to extract enums from ABI */ @@ -356,13 +377,9 @@ type ExtractEnums = { } ? V extends readonly { name: string; type: string }[] ? { - variants: { - [P in V[number] as P["name"]]: MapCairoType< - P["type"], - ABI - >; - }; - type: V[number]["name"]; + variants: CairoEnumVariantMap; + type: ExtractEnumType; + variantNames: V[number]["name"]; } : never : never; diff --git a/packages/sdk/.gitignore b/packages/sdk/.gitignore index 04556eee..71c7aa36 100644 --- a/packages/sdk/.gitignore +++ b/packages/sdk/.gitignore @@ -1,3 +1,4 @@ node_modules dist tsup.node.bundled_* +tsup.web.bundled_* diff --git a/packages/sdk/src/web/execute.ts b/packages/sdk/src/web/execute.ts index 08da5a8c..6bb7aac3 100644 --- a/packages/sdk/src/web/execute.ts +++ b/packages/sdk/src/web/execute.ts @@ -1,4 +1,4 @@ -import { type AccountInterface, Contract } from "starknet"; +import { type AccountInterface, CairoCustomEnum, Contract } from "starknet"; type AbiType = | "felt" @@ -27,7 +27,7 @@ interface TypeMapping { "core::array::Array": string[]; "core::array::Array": bigint[]; // Add custom type mappings here - "dojo_starter::models::Direction": "Left" | "Right" | "Up" | "Down"; + "dojo_starter::models::Direction": CairoCustomEnum; } type MapAbiType = T extends keyof TypeMapping @@ -180,7 +180,9 @@ export function createWorldProxy( // // Usage example // async function useWorld() { // await world.actions.spawn({}); -// await world.actions.move({ direction: "Left" }); +// await world.actions.move({ +// direction: new CairoCustomEnum({ Left: "()" }), +// }); // // TypeScript will catch these errors: // // @ts-expect-error diff --git a/packages/sdk/src/web/react/provider.tsx b/packages/sdk/src/web/react/provider.tsx index 2a0454f7..7d10cb72 100644 --- a/packages/sdk/src/web/react/provider.tsx +++ b/packages/sdk/src/web/react/provider.tsx @@ -24,7 +24,7 @@ export interface DojoContextType< /** SDK client instance **/ sdk: SDK; /** The Dojo provider */ - provider: DojoProvider; + provider: typeof DojoProvider; /** The dojo zustand store */ useDojoStore: DojoStoreHook; }