Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
remybar committed Nov 25, 2024
1 parent bc50d9e commit c12b8b6
Show file tree
Hide file tree
Showing 70 changed files with 2,843 additions and 172 deletions.
31 changes: 29 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ members = [
"bin/torii",
"crates/dojo/bindgen",
"crates/dojo/core",
# TODO: to be removed but still used by some tools like LS
"crates/dojo/lang",
"crates/dojo/macros",
"crates/dojo/test-utils",
"crates/dojo/types",
"crates/dojo/utils",
Expand Down Expand Up @@ -77,7 +79,9 @@ dojo-metrics = { path = "crates/metrics" }
# dojo-lang
dojo-bindgen = { path = "crates/dojo/bindgen" }
dojo-core = { path = "crates/dojo/core" }
# TODO: to be removed
dojo-lang = { path = "crates/dojo/lang" }
dojo-macros = { path = "crates/dojo/macros" }
dojo-test-utils = { path = "crates/dojo/test-utils" }
dojo-types = { path = "crates/dojo/types" }
dojo-world = { path = "crates/dojo/world" }
Expand Down
1 change: 0 additions & 1 deletion bin/sozo/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ clap.workspace = true
clap-verbosity-flag.workspace = true
colored.workspace = true
dojo-bindgen.workspace = true
dojo-lang.workspace = true
dojo-types.workspace = true
dojo-utils.workspace = true
dojo-world.workspace = true
Expand Down
2 changes: 0 additions & 2 deletions bin/sozo/src/commands/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ use cairo_lang_test_plugin::{test_plugin_suite, TestsCompilationConfig};
use cairo_lang_test_runner::{CompiledTestRunner, RunProfilerConfig, TestCompiler, TestRunConfig};
use cairo_lang_utils::ordered_hash_map::OrderedHashMap;
use clap::Args;
use dojo_lang::dojo_plugin_suite;
use itertools::Itertools;
use scarb::compiler::{
CairoCompilationUnit, CompilationUnit, CompilationUnitAttributes, ContractSelector,
Expand Down Expand Up @@ -197,7 +196,6 @@ pub(crate) fn build_root_database(unit: &CairoCompilationUnit) -> Result<RootDat
b.with_cfg(CfgSet::from_iter([Cfg::name("test"), Cfg::kv("target", "test")]));

b.with_plugin_suite(test_plugin_suite());
b.with_plugin_suite(dojo_plugin_suite());
b.with_plugin_suite(starknet_plugin_suite());

b.build()
Expand Down
8 changes: 4 additions & 4 deletions crates/benches/contracts/src/models/character.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use starknet::{ContractAddress, get_caller_address};

// TODO import all this when complex benchmarks are merged
#[derive(Introspect, Copy, Drop, Serde)]
#[dojo::model]
#[dojo_model]
struct Character {
#[key]
caller: ContractAddress,
Expand Down Expand Up @@ -49,7 +49,7 @@ struct Sword {
}

#[derive(Introspect, Copy, Drop, Serde)]
#[dojo::model]
#[dojo_model]
struct Case {
#[key]
owner: ContractAddress,
Expand All @@ -58,9 +58,9 @@ struct Case {
}

#[derive(Introspect, Copy, Drop, Serde)]
#[dojo::model]
#[dojo_model]
struct Alias {
#[key]
player: ContractAddress,
name: felt252,
}
}
2 changes: 1 addition & 1 deletion crates/benches/contracts/src/models/moves.cairo
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use starknet::ContractAddress;

#[derive(Introspect, Drop, Serde)]
#[dojo::model]
#[dojo_model]
struct Moves {
#[key]
player: ContractAddress,
Expand Down
2 changes: 1 addition & 1 deletion crates/benches/contracts/src/models/position.cairo
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use starknet::ContractAddress;

#[derive(Introspect, Copy, Drop, Serde)]
#[dojo::model]
#[dojo_model]
struct Position {
#[key]
player: ContractAddress,
Expand Down
2 changes: 1 addition & 1 deletion crates/benches/contracts/src/systems/actions.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ trait IActions<TContractState> {
}

// dojo decorator
#[dojo::contract]
#[dojo_contract]
mod actions {
use super::IActions;

Expand Down
9 changes: 5 additions & 4 deletions crates/dojo/core-cairo-test/Scarb.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,19 @@ version = 1

[[package]]
name = "dojo"
version = "1.0.0-rc.0"
version = "1.0.1"
dependencies = [
"dojo_plugin",
"dojo_macros",
]

[[package]]
name = "dojo_cairo_test"
version = "1.0.0-rc.0"
dependencies = [
"dojo",
"dojo_macros",
]

[[package]]
name = "dojo_plugin"
version = "2.8.4"
name = "dojo_macros"
version = "0.1.0"
1 change: 1 addition & 0 deletions crates/dojo/core-cairo-test/Scarb.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@ dojo = { path = "../core" }

[dev-dependencies]
cairo_test = "=2.8.4"
dojo_macros = { path = "../macros" }

[lib]
6 changes: 3 additions & 3 deletions crates/dojo/core-cairo-test/src/tests/benchmarks.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use crate::world::{spawn_test_world, NamespaceDef, TestResource};
use crate::utils::GasCounterTrait;

#[derive(Drop, Serde)]
#[dojo::model]
#[dojo_model]
struct CaseNotPacked {
#[key]
pub owner: ContractAddress,
Expand All @@ -29,7 +29,7 @@ struct CaseNotPacked {
}

#[derive(Drop, Serde)]
#[dojo::model]
#[dojo_model]
struct ComplexModel {
#[key]
pub game_id: u128,
Expand Down Expand Up @@ -205,7 +205,7 @@ fn bench_simple_struct() {
}

#[derive(Copy, Drop, Serde, IntrospectPacked)]
#[dojo::model]
#[dojo_model]
struct PositionWithQuaterions {
#[key]
id: felt252,
Expand Down
2 changes: 1 addition & 1 deletion crates/dojo/core-cairo-test/src/tests/contract.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ pub mod contract_invalid_upgrade {
}
}

#[dojo::contract]
#[dojo_contract]
mod test_contract {}

#[starknet::interface]
Expand Down
2 changes: 1 addition & 1 deletion crates/dojo/core-cairo-test/src/tests/event/event.cairo
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#[derive(Drop, Serde)]
#[dojo::event]
#[dojo_event]
struct FooEvent {
#[key]
k1: u8,
Expand Down
10 changes: 5 additions & 5 deletions crates/dojo/core-cairo-test/src/tests/helpers/event.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ struct FooBaseEvent {
}

#[derive(Copy, Drop, Serde, Debug)]
#[dojo::event]
#[dojo_event]
pub struct FooEventBadLayoutType {
#[key]
pub caller: ContractAddress,
Expand All @@ -28,7 +28,7 @@ pub struct FooEventBadLayoutType {
}

#[derive(Copy, Drop, Serde, Debug)]
#[dojo::event]
#[dojo_event]
struct FooEventMemberRemoved {
#[key]
pub caller: ContractAddress,
Expand All @@ -37,7 +37,7 @@ struct FooEventMemberRemoved {
}

#[derive(Copy, Drop, Serde, Debug)]
#[dojo::event]
#[dojo_event]
struct FooEventMemberAddedButRemoved {
#[key]
pub caller: ContractAddress,
Expand All @@ -46,7 +46,7 @@ struct FooEventMemberAddedButRemoved {
}

#[derive(Copy, Drop, Serde, Debug)]
#[dojo::event]
#[dojo_event]
struct FooEventMemberAddedButMoved {
#[key]
pub caller: ContractAddress,
Expand All @@ -55,7 +55,7 @@ struct FooEventMemberAddedButMoved {
}

#[derive(Copy, Drop, Serde, Debug)]
#[dojo::event]
#[dojo_event]
struct FooEventMemberAdded {
#[key]
pub caller: ContractAddress,
Expand Down
18 changes: 9 additions & 9 deletions crates/dojo/core-cairo-test/src/tests/helpers/helpers.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ use crate::world::{
pub const DOJO_NSH: felt252 = 0x309e09669bc1fdc1dd6563a7ef862aa6227c97d099d08cc7b81bad58a7443fa;

#[derive(Copy, Drop, Serde, Debug)]
#[dojo::event]
#[dojo_event]
pub struct SimpleEvent {
#[key]
pub id: u32,
pub data: (felt252, felt252),
}

#[derive(Copy, Drop, Serde, Debug)]
#[dojo::model]
#[dojo_model]
pub struct Foo {
#[key]
pub caller: ContractAddress,
Expand All @@ -27,7 +27,7 @@ pub struct Foo {
}

#[derive(Drop, Serde, Debug)]
#[dojo::model]
#[dojo_model]
pub struct NotCopiable {
#[key]
pub caller: ContractAddress,
Expand Down Expand Up @@ -87,7 +87,7 @@ pub trait IFooSetter<T> {
fn set_foo(ref self: T, a: felt252, b: u128);
}

#[dojo::contract]
#[dojo_contract]
pub mod foo_setter {
use super::{Foo, IFooSetter};
use dojo::model::ModelStorage;
Expand All @@ -101,10 +101,10 @@ pub mod foo_setter {
}
}

#[dojo::contract]
#[dojo_contract]
pub mod test_contract {}

#[dojo::contract]
#[dojo_contract]
pub mod test_contract_with_dojo_init_args {
fn dojo_init(ref self: ContractState, arg1: felt252) {
let _a = arg1;
Expand All @@ -118,7 +118,7 @@ pub struct Sword {
}

#[derive(IntrospectPacked, Copy, Drop, Serde)]
#[dojo::model]
#[dojo_model]
pub struct Case {
#[key]
pub owner: ContractAddress,
Expand All @@ -127,7 +127,7 @@ pub struct Case {
}

#[derive(IntrospectPacked, Copy, Drop, Serde)]
#[dojo::model]
#[dojo_model]
pub struct Character {
#[key]
pub caller: ContractAddress,
Expand Down Expand Up @@ -173,7 +173,7 @@ pub trait Ibar<TContractState> {
fn delete_foo(self: @TContractState);
}

#[dojo::contract]
#[dojo_contract]
pub mod bar {
use core::traits::Into;
use starknet::{get_caller_address};
Expand Down
Loading

0 comments on commit c12b8b6

Please sign in to comment.