Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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,116 changes: 547 additions & 569 deletions Cargo.lock

Large diffs are not rendered by default.

19 changes: 11 additions & 8 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,29 +1,31 @@
[package]
edition = "2021"
name = "dojo-c"
version = "1.0.0-alpha.15"
version = "1.0.0-alpha.17"

[lib]
crate-type = ["cdylib", "rlib", "staticlib"]

[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
dojo-world = { git = "https://github.com/dojoengine/dojo", rev = "d039c6d46f819edc3f2161c0520b8c8fecec0092", features = ["metadata"]}
dojo-world = { git = "https://github.com/dojoengine/dojo", tag = "v1.0.0-alpha.17", features = [
"metadata",
] }

[dependencies]
dojo-types = { git = "https://github.com/dojoengine/dojo", rev = "d039c6d46f819edc3f2161c0520b8c8fecec0092" }
torii-client = { git = "https://github.com/dojoengine/dojo", rev = "d039c6d46f819edc3f2161c0520b8c8fecec0092" }
dojo-types = { git = "https://github.com/dojoengine/dojo", tag = "v1.0.0-alpha.17" }
torii-client = { git = "https://github.com/dojoengine/dojo", tag = "v1.0.0-alpha.17" }
torii-grpc = { git = "https://github.com/dojoengine/dojo", features = [
"client",
], rev = "d039c6d46f819edc3f2161c0520b8c8fecec0092" }
torii-relay = { git = "https://github.com/dojoengine/dojo", rev = "d039c6d46f819edc3f2161c0520b8c8fecec0092" }
], tag = "v1.0.0-alpha.17" }
torii-relay = { git = "https://github.com/dojoengine/dojo", tag = "v1.0.0-alpha.17" }

starknet = "0.11.0"
starknet-crypto = "0.7.2"

parking_lot = "0.12.1"
tokio = { version = "1.39.2", default-features = false, features = ["rt"] }
url = "2.5.0"
anyhow = "1.0.76"
anyhow = "1.0.89"
serde = { version = "1.0.193", features = ["derive"] }
serde_json = "1.0.115"
tokio-stream = "0.1.14"
Expand All @@ -35,7 +37,8 @@ cainome = { git = "https://github.com/cartridge-gg/cainome", tag = "v0.3.2" }

# WASM
[target.'cfg(target_arch = "wasm32")'.dependencies]
dojo-world = { git = "https://github.com/dojoengine/dojo", rev = "d039c6d46f819edc3f2161c0520b8c8fecec0092", features = []}
dojo-world = { git = "https://github.com/dojoengine/dojo", tag = "v1.0.0-alpha.17", features = [
] }
serde-wasm-bindgen = "0.6.3"
wasm-bindgen-futures = "0.4.39"
js-sys = "0.3.70"
Expand Down
1 change: 1 addition & 0 deletions dojo.h
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,7 @@ typedef struct Query {
uint32_t limit;
uint32_t offset;
struct COptionClause clause;
bool dont_include_hashed_keys;
} Query;

typedef struct CArrayFieldElement {
Expand Down
1 change: 1 addition & 0 deletions dojo.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -719,6 +719,7 @@ struct Query {
uint32_t limit;
uint32_t offset;
COption<Clause> clause;
bool dont_include_hashed_keys;
};

struct ModelMetadata {
Expand Down
1 change: 1 addition & 0 deletions dojo.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,7 @@ cdef extern from *:
uint32_t limit;
uint32_t offset;
COptionClause clause;
bool dont_include_hashed_keys;

cdef struct CArrayFieldElement:
FieldElement *data;
Expand Down
17 changes: 15 additions & 2 deletions src/c/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,7 @@ pub struct Query {
pub limit: u32,
pub offset: u32,
pub clause: COption<Clause>,
pub dont_include_hashed_keys: bool,
}

#[derive(Clone, Debug)]
Expand Down Expand Up @@ -761,12 +762,14 @@ impl From<&Query> for torii_grpc::types::Query {
limit: val.limit,
offset: val.offset,
clause: Option::Some(clause),
dont_include_hashed_keys: val.dont_include_hashed_keys,
}
}
COption::None => torii_grpc::types::Query {
limit: val.limit,
offset: val.offset,
clause: Option::None,
dont_include_hashed_keys: val.dont_include_hashed_keys,
},
}
}
Expand All @@ -777,9 +780,19 @@ impl From<&torii_grpc::types::Query> for Query {
match &val.clause {
Option::Some(clause) => {
let clause = (&clause.clone()).into();
Query { limit: val.limit, offset: val.offset, clause: COption::Some(clause) }
Query {
limit: val.limit,
offset: val.offset,
clause: COption::Some(clause),
dont_include_hashed_keys: val.dont_include_hashed_keys,
}
}
Option::None => Query { limit: val.limit, offset: val.offset, clause: COption::None },
Option::None => Query {
limit: val.limit,
offset: val.offset,
clause: COption::None,
dont_include_hashed_keys: val.dont_include_hashed_keys,
},
}
}
}
Expand Down
11 changes: 9 additions & 2 deletions src/wasm/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -436,8 +436,15 @@ impl ToriiClient {
#[cfg(feature = "console-error-panic")]
console_error_panic_hook::set_once();

let results =
self.inner.entities(torii_grpc::types::Query { limit, offset, clause: None }).await;
let results = self
.inner
.entities(torii_grpc::types::Query {
limit,
offset,
clause: None,
dont_include_hashed_keys: false,
})
.await;

match results {
Ok(entities) => Ok((&entities).into()),
Expand Down
19 changes: 18 additions & 1 deletion src/wasm/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,22 @@ pub struct Entities(pub HashMap<String, Entity>);

impl From<&Vec<torii_grpc::types::schema::Entity>> for Entities {
fn from(value: &Vec<torii_grpc::types::schema::Entity>) -> Self {
Self(value.iter().map(|e| (format!("{:#x}", e.hashed_keys), e.into())).collect())
Self(
value
.iter()
.enumerate()
.map(|(i, e)| {
(
if e.hashed_keys != Felt::ZERO {
format!("{:#x}", e.hashed_keys)
} else {
format!("{:#x}", i)
},
e.into(),
)
})
.collect(),
)
}
}

Expand Down Expand Up @@ -208,6 +223,7 @@ pub struct Query {
pub limit: u32,
pub offset: u32,
pub clause: Option<Clause>,
pub dont_include_hashed_keys: bool,
}

impl From<&Query> for torii_grpc::types::Query {
Expand All @@ -216,6 +232,7 @@ impl From<&Query> for torii_grpc::types::Query {
limit: value.limit,
offset: value.offset,
clause: value.clause.as_ref().map(|c| c.into()),
dont_include_hashed_keys: value.dont_include_hashed_keys,
}
}
}
Expand Down
Loading