Skip to content

Commit

Permalink
fix: update dojo rev (#80)
Browse files Browse the repository at this point in the history
Co-authored-by: Nasr <[email protected]>
  • Loading branch information
glihm and Larkooo authored Dec 24, 2024
1 parent eb1dc03 commit b906351
Show file tree
Hide file tree
Showing 7 changed files with 86 additions and 19 deletions.
28 changes: 14 additions & 14 deletions Cargo.lock

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

10 changes: 5 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ crate-type = ["cdylib", "rlib", "staticlib"]


[dependencies]
dojo-world = { git = "https://github.com/dojoengine/dojo", rev = "b0e9367" }
dojo-types = { git = "https://github.com/dojoengine/dojo", rev = "b0e9367"}
torii-client = { git = "https://github.com/dojoengine/dojo", rev = "b0e9367" }
dojo-world = { git = "https://github.com/dojoengine/dojo", rev = "02557aee098cb5abf6431665c6af8d0588b64128" }
dojo-types = { git = "https://github.com/dojoengine/dojo", rev = "02557aee098cb5abf6431665c6af8d0588b64128"}
torii-client = { git = "https://github.com/dojoengine/dojo", rev = "02557aee098cb5abf6431665c6af8d0588b64128" }
torii-grpc = { git = "https://github.com/dojoengine/dojo", features = [
"client",
], rev = "b0e9367" }
torii-relay = { git = "https://github.com/dojoengine/dojo", rev = "b0e9367" }
], rev = "02557aee098cb5abf6431665c6af8d0588b64128" }
torii-relay = { git = "https://github.com/dojoengine/dojo", rev = "02557aee098cb5abf6431665c6af8d0588b64128" }

starknet = "0.12.0"
starknet-crypto = "0.7.2"
Expand Down
11 changes: 11 additions & 0 deletions dojo.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ typedef enum ComparisonOperator {
Gte,
Lt,
Lte,
In,
NotIn,
} ComparisonOperator;

typedef enum LogicalOperator {
Expand Down Expand Up @@ -300,9 +302,15 @@ typedef struct KeysClause {
struct CArrayc_char models;
} KeysClause;

typedef struct CArrayMemberValue {
struct MemberValue *data;
uintptr_t data_len;
} CArrayMemberValue;

typedef enum MemberValue_Tag {
Primitive,
String,
List,
} MemberValue_Tag;

typedef struct MemberValue {
Expand All @@ -314,6 +322,9 @@ typedef struct MemberValue {
struct {
const char *string;
};
struct {
struct CArrayMemberValue list;
};
};
} MemberValue;

Expand Down
19 changes: 19 additions & 0 deletions dojo.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ enum class ComparisonOperator {
Gte,
Lt,
Lte,
In,
NotIn,
};

enum class LogicalOperator {
Expand Down Expand Up @@ -601,6 +603,7 @@ struct MemberValue {
enum class Tag {
Primitive,
String,
List,
};

struct Primitive_Body {
Expand All @@ -611,10 +614,15 @@ struct MemberValue {
const char *_0;
};

struct List_Body {
CArray<MemberValue> _0;
};

Tag tag;
union {
Primitive_Body primitive;
String_Body string;
List_Body list;
};

static MemberValue Primitive(const Primitive &_0) {
Expand All @@ -638,6 +646,17 @@ struct MemberValue {
bool IsString() const {
return tag == Tag::String;
}

static MemberValue List(const CArray<MemberValue> &_0) {
MemberValue result;
::new (&result.list._0) (CArray<MemberValue>)(_0);
result.tag = Tag::List;
return result;
}

bool IsList() const {
return tag == Tag::List;
}
};

struct MemberClause {
Expand Down
8 changes: 8 additions & 0 deletions dojo.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ cdef extern from *:
Gte,
Lt,
Lte,
In,
NotIn,

cdef enum LogicalOperator:
And,
Expand Down Expand Up @@ -198,14 +200,20 @@ cdef extern from *:
PatternMatching pattern_matching;
CArrayc_char models;

cdef struct CArrayMemberValue:
MemberValue *data;
uintptr_t data_len;

cdef enum MemberValue_Tag:
Primitive,
String,
List,

cdef struct MemberValue:
MemberValue_Tag tag;
Primitive primitive;
const char *string;
CArrayMemberValue list;

cdef struct MemberClause:
const char *model;
Expand Down
19 changes: 19 additions & 0 deletions src/c/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,7 @@ pub struct ModelKeysClause {
pub enum MemberValue {
Primitive(Primitive),
String(*const c_char),
List(CArray<MemberValue>),
}

impl From<&MemberValue> for torii_grpc::types::MemberValue {
Expand All @@ -435,6 +436,14 @@ impl From<&MemberValue> for torii_grpc::types::MemberValue {
MemberValue::String(string) => torii_grpc::types::MemberValue::String(unsafe {
CStr::from_ptr(*string).to_string_lossy().to_string()
}),
MemberValue::List(list) => {
let values: Vec<MemberValue> = list.into();
let values = values
.iter()
.map(|v| v.into())
.collect::<Vec<torii_grpc::types::MemberValue>>();
torii_grpc::types::MemberValue::List(values)
}
}
}
}
Expand All @@ -448,6 +457,10 @@ impl From<&torii_grpc::types::MemberValue> for MemberValue {
torii_grpc::types::MemberValue::String(string) => {
MemberValue::String(CString::new(string.clone()).unwrap().into_raw())
}
torii_grpc::types::MemberValue::List(list) => {
let values = list.iter().map(|v| v.into()).collect::<Vec<MemberValue>>();
MemberValue::List(values.into())
}
}
}
}
Expand Down Expand Up @@ -484,6 +497,8 @@ pub enum ComparisonOperator {
Gte,
Lt,
Lte,
In,
NotIn,
}

#[derive(Clone, Debug)]
Expand Down Expand Up @@ -1155,6 +1170,8 @@ impl From<&ComparisonOperator> for torii_grpc::types::ComparisonOperator {
ComparisonOperator::Gte => torii_grpc::types::ComparisonOperator::Gte,
ComparisonOperator::Lt => torii_grpc::types::ComparisonOperator::Lt,
ComparisonOperator::Lte => torii_grpc::types::ComparisonOperator::Lte,
ComparisonOperator::In => torii_grpc::types::ComparisonOperator::In,
ComparisonOperator::NotIn => torii_grpc::types::ComparisonOperator::NotIn,
}
}
}
Expand All @@ -1168,6 +1185,8 @@ impl From<&torii_grpc::types::ComparisonOperator> for ComparisonOperator {
torii_grpc::types::ComparisonOperator::Gte => ComparisonOperator::Gte,
torii_grpc::types::ComparisonOperator::Lt => ComparisonOperator::Lt,
torii_grpc::types::ComparisonOperator::Lte => ComparisonOperator::Lte,
torii_grpc::types::ComparisonOperator::In => ComparisonOperator::In,
torii_grpc::types::ComparisonOperator::NotIn => ComparisonOperator::NotIn,
}
}
}
Expand Down
10 changes: 10 additions & 0 deletions src/wasm/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -421,6 +421,7 @@ pub struct KeysClause {
pub enum MemberValue {
Primitive(Primitive),
String(String),
List(Vec<MemberValue>),
}

impl From<&MemberValue> for torii_grpc::types::MemberValue {
Expand All @@ -430,6 +431,11 @@ impl From<&MemberValue> for torii_grpc::types::MemberValue {
torii_grpc::types::MemberValue::Primitive(primitive.into())
}
MemberValue::String(string) => torii_grpc::types::MemberValue::String(string.clone()),
MemberValue::List(list) => {
let values =
list.iter().map(|v| v.into()).collect::<Vec<torii_grpc::types::MemberValue>>();
torii_grpc::types::MemberValue::List(values)
}
}
}
}
Expand Down Expand Up @@ -528,6 +534,8 @@ pub enum ComparisonOperator {
Gte,
Lt,
Lte,
In,
NotIn,
}

impl From<&ComparisonOperator> for torii_grpc::types::ComparisonOperator {
Expand All @@ -539,6 +547,8 @@ impl From<&ComparisonOperator> for torii_grpc::types::ComparisonOperator {
ComparisonOperator::Gte => Self::Gte,
ComparisonOperator::Lt => Self::Lt,
ComparisonOperator::Lte => Self::Lte,
ComparisonOperator::In => Self::In,
ComparisonOperator::NotIn => Self::NotIn,
}
}
}
Expand Down

0 comments on commit b906351

Please sign in to comment.