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,868 changes: 1,049 additions & 819 deletions Cargo.lock

Large diffs are not rendered by default.

24 changes: 12 additions & 12 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
[package]
edition = "2021"
name = "dojo-c"
version = "1.6.1"
version = "1.6.0"

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

[dependencies]
dojo-world = { git = "https://github.com/dojoengine/dojo", rev = "054623b" }
dojo-types = { git = "https://github.com/dojoengine/dojo", rev = "054623b" }
torii-proto = { git = "https://github.com/dojoengine/torii", tag = "v1.6.1" }
torii-client = { git = "https://github.com/dojoengine/torii", tag = "v1.6.1" }
torii-grpc-client = { git = "https://github.com/dojoengine/torii", tag = "v1.6.1" }
dojo-world = { git = "https://github.com/dojoengine/dojo", branch = "primitive-from-sql" }
dojo-types = { git = "https://github.com/dojoengine/dojo", branch = "primitive-from-sql" }
torii-proto = { git = "https://github.com/dojoengine/torii", tag = "v1.7.0-alpha.2" }
torii-client = { git = "https://github.com/dojoengine/torii", tag = "v1.7.0-alpha.2" }
torii-grpc-client = { git = "https://github.com/dojoengine/torii", tag = "v1.7.0-alpha.2" }

starknet = "0.14.0"
starknet-crypto = "0.7.2"
starknet-types-core = { version = "0.1.6", features = ["arbitrary"] }
starknet = "0.17.0-rc.2"
starknet-crypto = "0.7.4"
starknet-types-core = { version = "0.1.9", features = ["arbitrary"] }

parking_lot = "0.12.1"
tokio = { version = "1.39.2", default-features = false, features = ["rt"] }
Expand All @@ -28,9 +28,9 @@ futures = "0.3.30"
futures-channel = "0.3.30"
wasm-bindgen = "0.2.92"
stream-cancel = "0.8.2"
cainome = { git = "https://github.com/cartridge-gg/cainome", tag = "v0.3.2" }
cainome = { git = "https://github.com/cartridge-gg/cainome", rev = "7d60de1" }
lazy_static = "1.5.0"
account_sdk = { git = "https://github.com/cartridge-gg/controller", rev = "05fe96f4" }
account_sdk = { git = "https://github.com/cartridge-gg/controller-rs", rev = "242e7bd" }

serde-wasm-bindgen = "0.6.3"
wasm-bindgen-futures = "0.4.39"
Expand Down Expand Up @@ -70,4 +70,4 @@ base64 = "0.22.1"
cbindgen = { git = "https://github.com/masnagam/cbindgen", branch = "fix-issue-43" }

[patch.crates-io]
crunchy = { git = "https://github.com/nmathewson/crunchy", branch = "cross-compilation-fix" }
crunchy = { git = "https://github.com/nmathewson/crunchy", branch = "cross-compilation-fix" }
12 changes: 11 additions & 1 deletion dojo.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ struct EnumOption;

typedef enum BlockTag {
Latest,
Pending,
PreConfirmed,
} BlockTag;

typedef enum CallType {
Expand Down Expand Up @@ -907,12 +907,18 @@ typedef struct CArrayTy {
uintptr_t data_len;
} CArrayTy;

typedef struct FixedSizeArray {
struct CArrayTy array;
uint32_t size;
} FixedSizeArray;

typedef enum Ty_Tag {
Primitive_,
Struct_,
Enum_,
Tuple_,
Array_,
FixedSizeArray_,
ByteArray,
} Ty_Tag;

Expand All @@ -934,6 +940,9 @@ typedef struct Ty {
struct {
struct CArrayTy array;
};
struct {
struct FixedSizeArray fixed_size_array;
};
struct {
const char *byte_array;
};
Expand All @@ -950,6 +959,7 @@ typedef struct Model {
struct FieldElement class_hash;
struct FieldElement contract_address;
const char *layout;
bool use_legacy_store;
} Model;

typedef struct TransactionCall {
Expand Down
25 changes: 24 additions & 1 deletion dojo.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ struct Account;

enum class BlockTag {
Latest,
Pending,
PreConfirmed,
};

enum class CallType {
Expand Down Expand Up @@ -666,13 +666,19 @@ struct Enum {
CArray<EnumOption> options;
};

struct FixedSizeArray {
CArray<Ty> array;
uint32_t size;
};

struct Ty {
enum class Tag {
Primitive_,
Struct_,
Enum_,
Tuple_,
Array_,
FixedSizeArray_,
ByteArray,
};

Expand All @@ -696,6 +702,10 @@ struct Ty {
CArray<Ty> _0;
};

struct FixedSizeArray__Body {
FixedSizeArray _0;
};

struct ByteArray_Body {
const char *_0;
};
Expand All @@ -707,6 +717,7 @@ struct Ty {
Enum__Body enum_;
Tuple__Body tuple;
Array__Body array;
FixedSizeArray__Body fixed_size_array;
ByteArray_Body byte_array;
};

Expand Down Expand Up @@ -765,6 +776,17 @@ struct Ty {
return tag == Tag::Array_;
}

static Ty FixedSizeArray_(const FixedSizeArray &_0) {
Ty result;
::new (&result.fixed_size_array._0) (FixedSizeArray)(_0);
result.tag = Tag::FixedSizeArray_;
return result;
}

bool IsFixedSizeArray_() const {
return tag == Tag::FixedSizeArray_;
}

static Ty ByteArray(const char *const &_0) {
Ty result;
::new (&result.byte_array._0) (const char*)(_0);
Expand All @@ -787,6 +809,7 @@ struct Model {
FieldElement class_hash;
FieldElement contract_address;
const char *layout;
bool use_legacy_store;
};

struct World {
Expand Down
9 changes: 8 additions & 1 deletion dojo.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ cdef extern from *:

cdef enum BlockTag:
Latest,
Pending,
PreConfirmed,

cdef enum CallType:
Execute,
Expand Down Expand Up @@ -587,12 +587,17 @@ cdef extern from *:
Ty *data;
uintptr_t data_len;

cdef struct FixedSizeArray:
CArrayTy array;
uint32_t size;

cdef enum Ty_Tag:
Primitive_,
Struct_,
Enum_,
Tuple_,
Array_,
FixedSizeArray_,
ByteArray,

cdef struct Ty:
Expand All @@ -602,6 +607,7 @@ cdef extern from *:
Enum enum_;
CArrayTy tuple;
CArrayTy array;
FixedSizeArray fixed_size_array;
const char *byte_array;

cdef struct Model:
Expand All @@ -614,6 +620,7 @@ cdef extern from *:
FieldElement class_hash;
FieldElement contract_address;
const char *layout;
bool use_legacy_store;

cdef struct TransactionCall:
FieldElement contract_address;
Expand Down
2 changes: 1 addition & 1 deletion rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
[toolchain]
channel = "1.85.0"
channel = "1.87.0"
22 changes: 20 additions & 2 deletions src/c/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ pub enum BlockId {
#[repr(C)]
pub enum BlockTag {
Latest,
Pending,
PreConfirmed,
}

impl From<BlockId> for starknet::core::types::BlockId {
Expand All @@ -298,7 +298,7 @@ impl From<BlockTag> for starknet::core::types::BlockTag {
fn from(val: BlockTag) -> Self {
match val {
BlockTag::Latest => starknet::core::types::BlockTag::Latest,
BlockTag::Pending => starknet::core::types::BlockTag::Pending,
BlockTag::PreConfirmed => starknet::core::types::BlockTag::PreConfirmed,
}
}
}
Expand Down Expand Up @@ -941,6 +941,13 @@ impl From<torii_proto::ValueType> for ValueType {
}
}

#[derive(Clone, Debug)]
#[repr(C)]
pub struct FixedSizeArray {
pub array: CArray<Ty>,
pub size: u32,
}

#[derive(Clone, Debug)]
#[repr(C)]
#[allow(clippy::enum_variant_names)]
Expand All @@ -950,6 +957,7 @@ pub enum Ty {
Enum_(Enum),
Tuple_(CArray<Ty>),
Array_(CArray<Ty>),
FixedSizeArray_(FixedSizeArray),
ByteArray(*const c_char),
}

Expand All @@ -965,6 +973,9 @@ impl From<dojo_types::schema::Ty> for Ty {
dojo_types::schema::Ty::Enum(enum_) => Ty::Enum_(enum_.into()),
dojo_types::schema::Ty::Tuple(tuple) => Ty::Tuple_(tuple.into()),
dojo_types::schema::Ty::Array(array) => Ty::Array_(array.into()),
dojo_types::schema::Ty::FixedSizeArray((ty, size)) => {
Ty::FixedSizeArray_(FixedSizeArray { array: ty.into(), size })
}
dojo_types::schema::Ty::ByteArray(array) => {
let array = CString::new(array.clone()).unwrap().into_raw();
Ty::ByteArray(array)
Expand All @@ -983,6 +994,10 @@ impl From<Ty> for dojo_types::schema::Ty {
Ty::Enum_(enum_) => dojo_types::schema::Ty::Enum(enum_.into()),
Ty::Tuple_(tuple) => dojo_types::schema::Ty::Tuple(tuple.into()),
Ty::Array_(array) => dojo_types::schema::Ty::Array(array.into()),
Ty::FixedSizeArray_(fixed_size_array) => dojo_types::schema::Ty::FixedSizeArray((
fixed_size_array.array.into(),
fixed_size_array.size,
)),
Ty::ByteArray(array) => {
let array = unsafe { CStr::from_ptr(array).to_string_lossy().to_string() };
dojo_types::schema::Ty::ByteArray(array)
Expand Down Expand Up @@ -1456,6 +1471,7 @@ pub struct Model {
pub class_hash: FieldElement,
pub contract_address: FieldElement,
pub layout: *const c_char,
pub use_legacy_store: bool,
}

impl From<torii_proto::Model> for Model {
Expand All @@ -1473,6 +1489,7 @@ impl From<torii_proto::Model> for Model {
class_hash: value.class_hash.into(),
contract_address: value.contract_address.into(),
layout,
use_legacy_store: value.use_legacy_store,
}
}
}
Expand All @@ -1494,6 +1511,7 @@ impl From<Model> for torii_proto::Model {
class_hash: value.class_hash.into(),
contract_address: value.contract_address.into(),
layout,
use_legacy_store: value.use_legacy_store,
}
}
}
Expand Down
19 changes: 14 additions & 5 deletions src/wasm/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -401,16 +401,25 @@ pub struct ClientConfig {
#[derive(Tsify, Serialize, Deserialize, Debug)]
#[tsify(into_wasm_abi, from_wasm_abi, hashmap_as_object)]
pub struct Ty {
#[tsify(type = r#""primitive" | "struct" | "enum" | "array" | "tuple" | "bytearray""#)]
#[tsify(
type = r#""primitive" | "struct" | "enum" | "array" | "tuple" | "bytearray" | "fixed_size_array""#
)]
pub r#type: String,
pub type_name: String,
#[serde(with = "serde_wasm_bindgen::preserve")]
#[tsify(type = "boolean | number | string | Ty | Record<string, Ty> | Array<Ty> | { option: \
string, value: Ty } | null")]
#[tsify(type = "boolean | number | string | Ty | Record<string, Ty> | Array<Ty> | EnumValue \
| FixedSizeArray | null")]
pub value: JsValue,
pub key: bool,
}

#[derive(Tsify, Serialize, Deserialize, Debug)]
#[tsify(into_wasm_abi, from_wasm_abi)]
pub struct FixedSizeArray {
pub array: Vec<Ty>,
pub size: u32,
}

#[derive(Tsify, Serialize, Deserialize, Debug)]
#[tsify(into_wasm_abi, from_wasm_abi)]
pub struct EnumValue {
Expand Down Expand Up @@ -511,14 +520,14 @@ impl From<Call> for FunctionCall {
#[tsify(into_wasm_abi, from_wasm_abi)]
pub enum BlockTag {
Latest,
Pending,
PreConfirmed,
}

impl From<BlockTag> for starknet::core::types::BlockTag {
fn from(value: BlockTag) -> Self {
match value {
BlockTag::Latest => starknet::core::types::BlockTag::Latest,
BlockTag::Pending => starknet::core::types::BlockTag::Pending,
BlockTag::PreConfirmed => starknet::core::types::BlockTag::PreConfirmed,
}
}
}
Expand Down
Loading
Loading