Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[sozo] generate JSON manifest #1694

Merged
merged 9 commits into from
Mar 25, 2024
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@ output.txt
**/katana-logs
crates/benches/bench_results.txt
**/generated
.vscode/settings.json
glihm marked this conversation as resolved.
Show resolved Hide resolved
29 changes: 29 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"version": "2.0.0",
"tasks": [
{
"type": "cargo",
"command": "build",
"problemMatcher": [
"$rustc"
],
"group": "build",
"label": "rust: cargo build"
},
{
"type": "cargo",
"command": "build",
"problemMatcher": [
"$rustc"
],
"group": "build",
"label": "sozo release",
"args": [
"-r",
"-p",
"sozo"
]
}
]
}

4 changes: 2 additions & 2 deletions crates/dojo-lang/src/compiler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use cairo_lang_utils::UpcastMut;
use camino::Utf8PathBuf;
use convert_case::{Case, Casing};
use dojo_world::manifest::{
Class, ComputedValueEntrypoint, DojoContract, DojoModel, Manifest, ManifestMethods,
AbiFormat, Class, ComputedValueEntrypoint, DojoContract, DojoModel, Manifest, ManifestMethods,
BASE_CONTRACT_NAME, WORLD_CONTRACT_NAME,
};
use itertools::Itertools;
Expand Down Expand Up @@ -451,7 +451,7 @@ where
let relative_abi_path = relative_abis_dir.join(name.clone()).with_extension("json");

if abi.is_some() {
manifest.inner.set_abi(Some(relative_abi_path.clone()));
manifest.inner.set_abi(Some(AbiFormat::Path(relative_abi_path.clone())));
}

let manifest_toml = toml::to_string_pretty(&manifest)?;
Expand Down
68 changes: 53 additions & 15 deletions crates/dojo-world/src/manifest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
pub members: Vec<Member>,
#[serde_as(as = "UfeHex")]
pub class_hash: FieldElement,
pub abi: Option<Utf8PathBuf>,
pub abi: Option<AbiFormat>,
}

/// System input ABI.
Expand Down Expand Up @@ -110,6 +110,26 @@
pub model: Option<String>,
}

/// Format of the ABI into the manifest file.
#[serde_as]
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
#[serde(untagged)]
pub enum AbiFormat {
/// Only a relative path to the ABI file is stored.
Path(Utf8PathBuf),
/// The full ABI is embedded as a string.
Embed(String),
}

impl AbiFormat {
pub fn to_path(&self) -> Option<&Utf8PathBuf> {
match self {
AbiFormat::Path(p) => Some(p),
AbiFormat::Embed(_) => None,

Check warning on line 128 in crates/dojo-world/src/manifest.rs

View check run for this annotation

Codecov / codecov/patch

crates/dojo-world/src/manifest.rs#L125-L128

Added lines #L125 - L128 were not covered by tests
}
}

Check warning on line 130 in crates/dojo-world/src/manifest.rs

View check run for this annotation

Codecov / codecov/patch

crates/dojo-world/src/manifest.rs#L130

Added line #L130 was not covered by tests
}

#[serde_as]
#[derive(Clone, Default, Debug, Serialize, Deserialize, PartialEq)]
#[serde(tag = "kind")]
Expand All @@ -118,7 +138,7 @@
pub address: Option<FieldElement>,
#[serde_as(as = "UfeHex")]
pub class_hash: FieldElement,
pub abi: Option<Utf8PathBuf>,
pub abi: Option<AbiFormat>,
pub reads: Vec<String>,
pub writes: Vec<String>,
pub computed: Vec<ComputedValueEntrypoint>,
Expand Down Expand Up @@ -151,7 +171,7 @@
pub struct Class {
#[serde_as(as = "UfeHex")]
pub class_hash: FieldElement,
pub abi: Option<Utf8PathBuf>,
pub abi: Option<AbiFormat>,
}

#[serde_as]
Expand All @@ -160,7 +180,7 @@
pub struct Contract {
#[serde_as(as = "UfeHex")]
pub class_hash: FieldElement,
pub abi: Option<Utf8PathBuf>,
pub abi: Option<AbiFormat>,
#[serde_as(as = "Option<UfeHex>")]
pub address: Option<FieldElement>,
#[serde_as(as = "Option<UfeHex>")]
Expand Down Expand Up @@ -236,8 +256,8 @@

pub trait ManifestMethods {
type OverlayType;
fn abi(&self) -> Option<&Utf8PathBuf>;
fn set_abi(&mut self, abi: Option<Utf8PathBuf>);
fn abi(&self) -> Option<&AbiFormat>;
fn set_abi(&mut self, abi: Option<AbiFormat>);
fn class_hash(&self) -> &FieldElement;
fn set_class_hash(&mut self, class_hash: FieldElement);

Expand Down Expand Up @@ -300,7 +320,7 @@
self.world.inner.seed = previous.world.inner.seed;
}

pub fn write_to_path(&self, path: &Utf8PathBuf) -> Result<()> {
pub fn write_to_path_toml(&self, path: &Utf8PathBuf) -> Result<()> {
fs::create_dir_all(path.parent().unwrap())?;

let deployed_manifest = toml::to_string_pretty(&self)?;
Expand All @@ -309,6 +329,24 @@
Ok(())
}

pub fn write_to_path_json(&self, path: &Utf8PathBuf, manifest_dir: &Utf8PathBuf) -> Result<()> {
fs::create_dir_all(path.parent().unwrap())?;

Check warning on line 333 in crates/dojo-world/src/manifest.rs

View check run for this annotation

Codecov / codecov/patch

crates/dojo-world/src/manifest.rs#L333

Added line #L333 was not covered by tests

// Embedding ABIs into the manifest.
let mut manifest_with_abis = self.clone();
for contract in &mut manifest_with_abis.contracts {
if let Some(AbiFormat::Path(abi_path)) = &contract.inner.abi {
let abi_content = fs::read_to_string(manifest_dir.join(abi_path))?;
contract.inner.abi = Some(AbiFormat::Embed(abi_content));
}

Check warning on line 341 in crates/dojo-world/src/manifest.rs

View check run for this annotation

Codecov / codecov/patch

crates/dojo-world/src/manifest.rs#L336-L341

Added lines #L336 - L341 were not covered by tests
}

let deployed_manifest = serde_json::to_string(&manifest_with_abis)?;
fs::write(path, deployed_manifest)?;

Check warning on line 345 in crates/dojo-world/src/manifest.rs

View check run for this annotation

Codecov / codecov/patch

crates/dojo-world/src/manifest.rs#L344-L345

Added lines #L344 - L345 were not covered by tests

Ok(())
}

Check warning on line 348 in crates/dojo-world/src/manifest.rs

View check run for this annotation

Codecov / codecov/patch

crates/dojo-world/src/manifest.rs#L347-L348

Added lines #L347 - L348 were not covered by tests

/// Construct a manifest of a remote World.
///
/// # Arguments
Expand Down Expand Up @@ -628,11 +666,11 @@
impl ManifestMethods for DojoContract {
type OverlayType = OverlayDojoContract;

fn abi(&self) -> Option<&Utf8PathBuf> {
fn abi(&self) -> Option<&AbiFormat> {
self.abi.as_ref()
}

fn set_abi(&mut self, abi: Option<Utf8PathBuf>) {
fn set_abi(&mut self, abi: Option<AbiFormat>) {
self.abi = abi;
}

Expand All @@ -657,11 +695,11 @@
impl ManifestMethods for DojoModel {
type OverlayType = OverlayDojoModel;

fn abi(&self) -> Option<&Utf8PathBuf> {
fn abi(&self) -> Option<&AbiFormat> {

Check warning on line 698 in crates/dojo-world/src/manifest.rs

View check run for this annotation

Codecov / codecov/patch

crates/dojo-world/src/manifest.rs#L698

Added line #L698 was not covered by tests
self.abi.as_ref()
}

fn set_abi(&mut self, abi: Option<Utf8PathBuf>) {
fn set_abi(&mut self, abi: Option<AbiFormat>) {

Check warning on line 702 in crates/dojo-world/src/manifest.rs

View check run for this annotation

Codecov / codecov/patch

crates/dojo-world/src/manifest.rs#L702

Added line #L702 was not covered by tests
self.abi = abi;
}

Expand All @@ -679,11 +717,11 @@
impl ManifestMethods for Contract {
type OverlayType = OverlayContract;

fn abi(&self) -> Option<&Utf8PathBuf> {
fn abi(&self) -> Option<&AbiFormat> {

Check warning on line 720 in crates/dojo-world/src/manifest.rs

View check run for this annotation

Codecov / codecov/patch

crates/dojo-world/src/manifest.rs#L720

Added line #L720 was not covered by tests
self.abi.as_ref()
}

fn set_abi(&mut self, abi: Option<Utf8PathBuf>) {
fn set_abi(&mut self, abi: Option<AbiFormat>) {

Check warning on line 724 in crates/dojo-world/src/manifest.rs

View check run for this annotation

Codecov / codecov/patch

crates/dojo-world/src/manifest.rs#L724

Added line #L724 was not covered by tests
self.abi = abi;
}

Expand All @@ -701,11 +739,11 @@
impl ManifestMethods for Class {
type OverlayType = OverlayClass;

fn abi(&self) -> Option<&Utf8PathBuf> {
fn abi(&self) -> Option<&AbiFormat> {

Check warning on line 742 in crates/dojo-world/src/manifest.rs

View check run for this annotation

Codecov / codecov/patch

crates/dojo-world/src/manifest.rs#L742

Added line #L742 was not covered by tests
self.abi.as_ref()
}

fn set_abi(&mut self, abi: Option<Utf8PathBuf>) {
fn set_abi(&mut self, abi: Option<AbiFormat>) {

Check warning on line 746 in crates/dojo-world/src/manifest.rs

View check run for this annotation

Codecov / codecov/patch

crates/dojo-world/src/manifest.rs#L746

Added line #L746 was not covered by tests
self.abi = abi;
}

Expand Down
6 changes: 3 additions & 3 deletions crates/sozo/ops/src/events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use cainome::parser::tokens::{CompositeInner, CompositeInnerKind, CoreBasic, Tok
use cainome::parser::AbiParser;
use camino::Utf8PathBuf;
use dojo_lang::compiler::{DEPLOYMENTS_DIR, MANIFESTS_DIR};
use dojo_world::manifest::{DeploymentManifest, ManifestMethods};
use dojo_world::manifest::{AbiFormat, DeploymentManifest, ManifestMethods};
use starknet::core::types::{BlockId, EventFilter, FieldElement};
use starknet::core::utils::{parse_cairo_short_string, starknet_keccak};
use starknet::providers::jsonrpc::HttpTransport;
Expand Down Expand Up @@ -104,14 +104,14 @@ fn extract_events(
let mut events_map = HashMap::new();

for contract in &manifest.contracts {
if let Some(abi_path) = contract.inner.abi() {
if let Some(AbiFormat::Path(abi_path)) = contract.inner.abi() {
let full_abi_path = manifest_dir.join(abi_path);
process_abi(&mut events_map, &full_abi_path)?;
}
}

for model in &manifest.contracts {
if let Some(abi_path) = model.inner.abi() {
if let Some(AbiFormat::Path(abi_path)) = model.inner.abi() {
let full_abi_path = manifest_dir.join(abi_path);
process_abi(&mut events_map, &full_abi_path)?;
}
Expand Down
23 changes: 13 additions & 10 deletions crates/sozo/ops/src/migration/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
use dojo_world::contracts::cairo_utils;
use dojo_world::contracts::world::WorldContract;
use dojo_world::manifest::{
AbstractManifestError, BaseManifest, DeploymentManifest, DojoContract, Manifest,
AbiFormat, AbstractManifestError, BaseManifest, DeploymentManifest, DojoContract, Manifest,
ManifestMethods, OverlayManifest,
};
use dojo_world::metadata::dojo_metadata_from_workspace;
Expand Down Expand Up @@ -133,6 +133,10 @@
Ok(())
}

fn build_deployed_path(manifest_dir: &Utf8PathBuf, chain_id: &str, extension: &str) -> Utf8PathBuf {
manifest_dir.join(MANIFESTS_DIR).join(DEPLOYMENTS_DIR).join(chain_id).with_extension(extension)
}

Check warning on line 138 in crates/sozo/ops/src/migration/mod.rs

View check run for this annotation

Codecov / codecov/patch

crates/sozo/ops/src/migration/mod.rs#L136-L138

Added lines #L136 - L138 were not covered by tests

async fn update_manifests_and_abis(
ws: &Workspace<'_>,
local_manifest: BaseManifest,
Expand All @@ -145,11 +149,8 @@
let ui = ws.config().ui();
ui.print("\n✨ Updating manifests...");

let deployed_path = manifest_dir
.join(MANIFESTS_DIR)
.join(DEPLOYMENTS_DIR)
.join(chain_id)
.with_extension("toml");
let deployed_path = build_deployed_path(manifest_dir, chain_id, "toml");
let deployed_path_json = build_deployed_path(manifest_dir, chain_id, "json");

Check warning on line 153 in crates/sozo/ops/src/migration/mod.rs

View check run for this annotation

Codecov / codecov/patch

crates/sozo/ops/src/migration/mod.rs#L152-L153

Added lines #L152 - L153 were not covered by tests
glihm marked this conversation as resolved.
Show resolved Hide resolved

let mut local_manifest: DeploymentManifest = local_manifest.into();

Expand Down Expand Up @@ -185,7 +186,8 @@
// local_manifest
update_manifest_abis(&mut local_manifest, manifest_dir, chain_id).await;

local_manifest.write_to_path(&deployed_path)?;
local_manifest.write_to_path_toml(&deployed_path)?;
local_manifest.write_to_path_json(&deployed_path_json, manifest_dir)?;

Check warning on line 190 in crates/sozo/ops/src/migration/mod.rs

View check run for this annotation

Codecov / codecov/patch

crates/sozo/ops/src/migration/mod.rs#L189-L190

Added lines #L189 - L190 were not covered by tests
ui.print("\n✨ Done.");

Ok(())
Expand All @@ -204,8 +206,9 @@
where
T: ManifestMethods,
{
// unwraps in call to abi is safe because we always write abis for DojoContracts
let base_relative_path = manifest.inner.abi().unwrap();
// unwraps in call to abi is safe because we always write abis for DojoContracts as relative
// path.
let base_relative_path = manifest.inner.abi().unwrap().to_path().unwrap();

Check warning on line 211 in crates/sozo/ops/src/migration/mod.rs

View check run for this annotation

Codecov / codecov/patch

crates/sozo/ops/src/migration/mod.rs#L209-L211

Added lines #L209 - L211 were not covered by tests
let deployed_relative_path =
Utf8PathBuf::new().join(ABIS_DIR).join(DEPLOYMENTS_DIR).join(chain_id).join(
base_relative_path
Expand All @@ -220,7 +223,7 @@
.await
.expect("Failed to create folder");
fs::copy(full_base_path, full_deployed_path).await.expect("Failed to copy abi file");
manifest.inner.set_abi(Some(deployed_relative_path));
manifest.inner.set_abi(Some(AbiFormat::Path(deployed_relative_path)));

Check warning on line 226 in crates/sozo/ops/src/migration/mod.rs

View check run for this annotation

Codecov / codecov/patch

crates/sozo/ops/src/migration/mod.rs#L226

Added line #L226 was not covered by tests
}

for contract in local_manifest.contracts.iter_mut() {
Expand Down
2 changes: 1 addition & 1 deletion examples/spawn-and-move/abis/base/contracts/actions.json
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@
{
"name": "player",
"type": "core::starknet::contract_address::ContractAddress",
"kind": "data"
"kind": "key"
glihm marked this conversation as resolved.
Show resolved Hide resolved
},
{
"name": "direction",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@
{
"name": "player",
"type": "core::starknet::contract_address::ContractAddress",
"kind": "data"
"kind": "key"
},
{
"name": "direction",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
kind = "DojoContract"
class_hash = "0xd43bce39922ec3857da231e3bb5c365c29f837c6dce322e4d61dfae83a4c18"
class_hash = "0x2a3b1c5473dfb9fd1be08b94fae201b30b4e63ed8caed996476cc4ad44cadb2"
abi = "abis/base/contracts/actions.json"
reads = []
writes = []
Expand Down
13 changes: 13 additions & 0 deletions examples/spawn-and-move/manifests/base/models/moved.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
kind = "DojoModel"
class_hash = "0x52659850f9939482810d9f6b468b91dc99e0b7fa42c2016cf12833ec06ce911"
name = "dojo_examples::actions::actions::moved"

[[members]]
name = "player"
type = "ContractAddress"
key = true

[[members]]
name = "direction"
type = "Direction"
key = false
1 change: 1 addition & 0 deletions examples/spawn-and-move/manifests/deployments/KATANA.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"world":{"kind":"Contract","class_hash":"0x799bc4e9da10bfb3dd88e6f223c9cfbf7745435cd14f5d69675ea448e578cd","abi":null,"address":"0x1385f25d20a724edc9c7b3bd9636c59af64cbaf9fcd12f33b3af96b2452f295","transaction_hash":"0x6afefdcc49b3563a4f3657900ba71e9f9356861b15b942a73f2018f046a1048","block_number":3,"seed":"dojo_examples","name":"dojo::world::world"},"base":{"kind":"Class","class_hash":"0x679177a2cb757694ac4f326d01052ff0963eac0bc2a17116a2b87badcdf6f76","abi":null,"name":"dojo::base::base"},"contracts":[{"kind":"DojoContract","address":"0x3539c9b89b08095ba914653fb0f20e55d4b172a415beade611bc260b346d0f7","class_hash":"0x2a3b1c5473dfb9fd1be08b94fae201b30b4e63ed8caed996476cc4ad44cadb2","abi":"[\n {\n \"type\": \"impl\",\n \"name\": \"DojoResourceProviderImpl\",\n \"interface_name\": \"dojo::world::IDojoResourceProvider\"\n },\n {\n \"type\": \"interface\",\n \"name\": \"dojo::world::IDojoResourceProvider\",\n \"items\": [\n {\n \"type\": \"function\",\n \"name\": \"dojo_resource\",\n \"inputs\": [],\n \"outputs\": [\n {\n \"type\": \"core::felt252\"\n }\n ],\n \"state_mutability\": \"view\"\n }\n ]\n },\n {\n \"type\": \"impl\",\n \"name\": \"WorldProviderImpl\",\n \"interface_name\": \"dojo::world::IWorldProvider\"\n },\n {\n \"type\": \"struct\",\n \"name\": \"dojo::world::IWorldDispatcher\",\n \"members\": [\n {\n \"name\": \"contract_address\",\n \"type\": \"core::starknet::contract_address::ContractAddress\"\n }\n ]\n },\n {\n \"type\": \"interface\",\n \"name\": \"dojo::world::IWorldProvider\",\n \"items\": [\n {\n \"type\": \"function\",\n \"name\": \"world\",\n \"inputs\": [],\n \"outputs\": [\n {\n \"type\": \"dojo::world::IWorldDispatcher\"\n }\n ],\n \"state_mutability\": \"view\"\n }\n ]\n },\n {\n \"type\": \"impl\",\n \"name\": \"ActionsComputedImpl\",\n \"interface_name\": \"dojo_examples::actions::IActionsComputed\"\n },\n {\n \"type\": \"struct\",\n \"name\": \"dojo_examples::models::Vec2\",\n \"members\": [\n {\n \"name\": \"x\",\n \"type\": \"core::integer::u32\"\n },\n {\n \"name\": \"y\",\n \"type\": \"core::integer::u32\"\n }\n ]\n },\n {\n \"type\": \"struct\",\n \"name\": \"dojo_examples::models::Position\",\n \"members\": [\n {\n \"name\": \"player\",\n \"type\": \"core::starknet::contract_address::ContractAddress\"\n },\n {\n \"name\": \"vec\",\n \"type\": \"dojo_examples::models::Vec2\"\n }\n ]\n },\n {\n \"type\": \"interface\",\n \"name\": \"dojo_examples::actions::IActionsComputed\",\n \"items\": [\n {\n \"type\": \"function\",\n \"name\": \"tile_terrain\",\n \"inputs\": [\n {\n \"name\": \"vec\",\n \"type\": \"dojo_examples::models::Vec2\"\n }\n ],\n \"outputs\": [\n {\n \"type\": \"core::felt252\"\n }\n ],\n \"state_mutability\": \"view\"\n },\n {\n \"type\": \"function\",\n \"name\": \"quadrant\",\n \"inputs\": [\n {\n \"name\": \"pos\",\n \"type\": \"dojo_examples::models::Position\"\n }\n ],\n \"outputs\": [\n {\n \"type\": \"core::integer::u8\"\n }\n ],\n \"state_mutability\": \"view\"\n }\n ]\n },\n {\n \"type\": \"impl\",\n \"name\": \"ActionsImpl\",\n \"interface_name\": \"dojo_examples::actions::IActions\"\n },\n {\n \"type\": \"enum\",\n \"name\": \"dojo_examples::models::Direction\",\n \"variants\": [\n {\n \"name\": \"None\",\n \"type\": \"()\"\n },\n {\n \"name\": \"Left\",\n \"type\": \"()\"\n },\n {\n \"name\": \"Right\",\n \"type\": \"()\"\n },\n {\n \"name\": \"Up\",\n \"type\": \"()\"\n },\n {\n \"name\": \"Down\",\n \"type\": \"()\"\n }\n ]\n },\n {\n \"type\": \"interface\",\n \"name\": \"dojo_examples::actions::IActions\",\n \"items\": [\n {\n \"type\": \"function\",\n \"name\": \"spawn\",\n \"inputs\": [],\n \"outputs\": [],\n \"state_mutability\": \"view\"\n },\n {\n \"type\": \"function\",\n \"name\": \"move\",\n \"inputs\": [\n {\n \"name\": \"direction\",\n \"type\": \"dojo_examples::models::Direction\"\n }\n ],\n \"outputs\": [],\n \"state_mutability\": \"view\"\n }\n ]\n },\n {\n \"type\": \"impl\",\n \"name\": \"UpgradableImpl\",\n \"interface_name\": \"dojo::components::upgradeable::IUpgradeable\"\n },\n {\n \"type\": \"interface\",\n \"name\": \"dojo::components::upgradeable::IUpgradeable\",\n \"items\": [\n {\n \"type\": \"function\",\n \"name\": \"upgrade\",\n \"inputs\": [\n {\n \"name\": \"new_class_hash\",\n \"type\": \"core::starknet::class_hash::ClassHash\"\n }\n ],\n \"outputs\": [],\n \"state_mutability\": \"external\"\n }\n ]\n },\n {\n \"type\": \"event\",\n \"name\": \"dojo::components::upgradeable::upgradeable::Upgraded\",\n \"kind\": \"struct\",\n \"members\": [\n {\n \"name\": \"class_hash\",\n \"type\": \"core::starknet::class_hash::ClassHash\",\n \"kind\": \"data\"\n }\n ]\n },\n {\n \"type\": \"event\",\n \"name\": \"dojo::components::upgradeable::upgradeable::Event\",\n \"kind\": \"enum\",\n \"variants\": [\n {\n \"name\": \"Upgraded\",\n \"type\": \"dojo::components::upgradeable::upgradeable::Upgraded\",\n \"kind\": \"nested\"\n }\n ]\n },\n {\n \"type\": \"event\",\n \"name\": \"dojo_examples::actions::actions::Moved\",\n \"kind\": \"struct\",\n \"members\": [\n {\n \"name\": \"player\",\n \"type\": \"core::starknet::contract_address::ContractAddress\",\n \"kind\": \"key\"\n },\n {\n \"name\": \"direction\",\n \"type\": \"dojo_examples::models::Direction\",\n \"kind\": \"data\"\n }\n ]\n },\n {\n \"type\": \"event\",\n \"name\": \"dojo_examples::actions::actions::Event\",\n \"kind\": \"enum\",\n \"variants\": [\n {\n \"name\": \"UpgradeableEvent\",\n \"type\": \"dojo::components::upgradeable::upgradeable::Event\",\n \"kind\": \"nested\"\n },\n {\n \"name\": \"Moved\",\n \"type\": \"dojo_examples::actions::actions::Moved\",\n \"kind\": \"nested\"\n }\n ]\n }\n]","reads":["Moves","Position"],"writes":[],"computed":[],"name":"dojo_examples::actions::actions"}],"models":[{"kind":"DojoModel","members":[{"name":"player","type":"ContractAddress","key":true},{"name":"direction","type":"Direction","key":false}],"class_hash":"0x52659850f9939482810d9f6b468b91dc99e0b7fa42c2016cf12833ec06ce911","abi":null,"name":"dojo_examples::actions::actions::moved"},{"kind":"DojoModel","members":[{"name":"player","type":"ContractAddress","key":true},{"name":"remaining","type":"u8","key":false},{"name":"last_direction","type":"Direction","key":false}],"class_hash":"0x511fbd833938f5c4b743eea1e67605a125d7ff60e8a09e8dc227ad2fb59ca54","abi":null,"name":"dojo_examples::models::moves"},{"kind":"DojoModel","members":[{"name":"player","type":"ContractAddress","key":true},{"name":"vec","type":"Vec2","key":false}],"class_hash":"0xb33ae053213ccb2a57967ffc4411901f3efab24781ca867adcd0b90f2fece5","abi":null,"name":"dojo_examples::models::position"}]}
glihm marked this conversation as resolved.
Show resolved Hide resolved
22 changes: 20 additions & 2 deletions examples/spawn-and-move/manifests/deployments/KATANA.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,31 @@ name = "dojo::base::base"
[[contracts]]
kind = "DojoContract"
address = "0x3539c9b89b08095ba914653fb0f20e55d4b172a415beade611bc260b346d0f7"
class_hash = "0xd43bce39922ec3857da231e3bb5c365c29f837c6dce322e4d61dfae83a4c18"
class_hash = "0x2a3b1c5473dfb9fd1be08b94fae201b30b4e63ed8caed996476cc4ad44cadb2"
abi = "abis/deployments/KATANA/contracts/actions.json"
reads = []
reads = [
"Moves",
"Position",
]
writes = []
computed = []
name = "dojo_examples::actions::actions"

[[models]]
kind = "DojoModel"
class_hash = "0x52659850f9939482810d9f6b468b91dc99e0b7fa42c2016cf12833ec06ce911"
name = "dojo_examples::actions::actions::moved"

[[models.members]]
name = "player"
type = "ContractAddress"
key = true

[[models.members]]
name = "direction"
type = "Direction"
key = false

[[models]]
kind = "DojoModel"
class_hash = "0x511fbd833938f5c4b743eea1e67605a125d7ff60e8a09e8dc227ad2fb59ca54"
Expand Down
Loading