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
914 changes: 745 additions & 169 deletions Cargo.lock

Large diffs are not rendered by default.

17 changes: 9 additions & 8 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
[package]
edition = "2021"
name = "dojo-c"
version = "1.5.7"
version = "1.6.0-alpha.0"

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

[dependencies]
dojo-world = { git = "https://github.com/dojoengine/dojo", rev = "4145801" }
dojo-types = { git = "https://github.com/dojoengine/dojo", rev = "4145801" }
torii-proto = { git = "https://github.com/dojoengine/torii", rev = "07ca961fa81c069b75c5a149984ddf65443e7dae" }
torii-client = { git = "https://github.com/dojoengine/torii", rev = "07ca961fa81c069b75c5a149984ddf65443e7dae" }
torii-grpc-client = { git = "https://github.com/dojoengine/torii", rev = "07ca961fa81c069b75c5a149984ddf65443e7dae" }
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", rev = "0e89d04" }
torii-client = { git = "https://github.com/dojoengine/torii", rev = "0e89d04" }
torii-grpc-client = { git = "https://github.com/dojoengine/torii", rev = "0e89d04" }

starknet = "0.13.0"
starknet = "0.14.0"
starknet-crypto = "0.7.2"
starknet-types-core = { version = "0.1.6", features = ["arbitrary"] }

Expand All @@ -30,7 +30,7 @@ wasm-bindgen = "0.2.92"
stream-cancel = "0.8.2"
cainome = { git = "https://github.com/cartridge-gg/cainome", tag = "v0.3.2" }
lazy_static = "1.5.0"
account_sdk = { git = "https://github.com/cartridge-gg/controller", rev = "dbbe0353d64de743739d425f8aab91ca3ac0e16f" }
account_sdk = { git = "https://github.com/cartridge-gg/controller", rev = "05fe96f4" }

serde-wasm-bindgen = "0.6.3"
wasm-bindgen-futures = "0.4.39"
Expand All @@ -48,6 +48,7 @@ instant = { version = "0.1.13", features = ["wasm-bindgen"] }
gloo-timers = { version = "0.3.0", features = ["futures"] }
num-bigint = "0.4.6"
num-traits = "0.2.19"
chrono = "0.4.41"

[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
axum = "0.8.1"
Expand Down
3 changes: 1 addition & 2 deletions dojo.h
Original file line number Diff line number Diff line change
Expand Up @@ -729,8 +729,7 @@ typedef struct Entity {
} Entity;

typedef struct OrderBy {
const char *model;
const char *member;
const char *field;
enum OrderDirection direction;
} OrderBy;

Expand Down
3 changes: 1 addition & 2 deletions dojo.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -181,8 +181,7 @@ struct Entity {
};

struct OrderBy {
const char *model;
const char *member;
const char *field;
OrderDirection direction;
};

Expand Down
3 changes: 1 addition & 2 deletions dojo.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -460,8 +460,7 @@ cdef extern from *:
CArrayStruct models;

cdef struct OrderBy:
const char *model;
const char *member;
const char *field;
OrderDirection direction;

cdef enum COptionFieldElement_Tag:
Expand Down
5 changes: 3 additions & 2 deletions src/c/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ use account_sdk::account::session::account::SessionAccount;
use account_sdk::account::session::hash::Session;
use account_sdk::provider::{CartridgeJsonRpcProvider, CartridgeProvider};
use account_sdk::signers::Signer;
use account_sdk::utils::time::get_current_timestamp;
use axum::extract::State;
use axum::http::{header, HeaderValue, Method, StatusCode};
use axum::response::IntoResponse;
Expand All @@ -26,6 +25,7 @@ use axum::Router;
use base64::engine::general_purpose::STANDARD as BASE64;
use base64::Engine as _;
use cainome::cairo_serde::{self, ByteArray, CairoSerde};
use chrono::Utc;
use crypto_bigint::U256;
use directories::ProjectDirs;
use dojo_world::contracts::naming::compute_selector_from_tag;
Expand Down Expand Up @@ -629,7 +629,7 @@ pub unsafe extern "C" fn controller_execute_from_outside(
let caller = OutsideExecutionCaller::Any;
let calls = unsafe { std::slice::from_raw_parts(calldata, calldata_len).to_vec() };
let calls = calls.into_iter().map(|c| c.into()).collect::<Vec<starknet::core::types::Call>>();
let now = get_current_timestamp();
let now = Utc::now().timestamp() as u64;
let outside_execution = OutsideExecutionV3 {
caller: caller.into(),
execute_after: 0_u64,
Expand All @@ -652,6 +652,7 @@ pub unsafe extern "C" fn controller_execute_from_outside(
OutsideExecution::V3(outside_execution),
(*controller).account.address(),
signed.signature,
None,
)) {
Ok(res) => res,
Err(e) => {
Expand Down
9 changes: 3 additions & 6 deletions src/c/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -532,16 +532,14 @@ impl From<torii_proto::PaginationDirection> for PaginationDirection {
#[derive(Clone, Debug)]
#[repr(C)]
pub struct OrderBy {
pub model: *const c_char,
pub member: *const c_char,
pub field: *const c_char,
pub direction: OrderDirection,
}

impl From<OrderBy> for torii_proto::OrderBy {
fn from(val: OrderBy) -> Self {
torii_proto::OrderBy {
model: unsafe { CStr::from_ptr(val.model).to_string_lossy().to_string() },
member: unsafe { CStr::from_ptr(val.member).to_string_lossy().to_string() },
field: unsafe { CStr::from_ptr(val.field).to_string_lossy().to_string() },
direction: val.direction.into(),
}
}
Expand All @@ -550,8 +548,7 @@ impl From<OrderBy> for torii_proto::OrderBy {
impl From<torii_proto::OrderBy> for OrderBy {
fn from(val: torii_proto::OrderBy) -> Self {
OrderBy {
model: CString::new(val.model.clone()).unwrap().into_raw(),
member: CString::new(val.member.clone()).unwrap().into_raw(),
field: CString::new(val.field.clone()).unwrap().into_raw(),
direction: val.direction.into(),
}
}
Expand Down
9 changes: 2 additions & 7 deletions src/wasm/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -389,18 +389,13 @@ impl From<PaginationDirection> for torii_proto::PaginationDirection {
#[derive(Tsify, Serialize, Deserialize, Debug)]
#[tsify(into_wasm_abi, from_wasm_abi)]
pub struct OrderBy {
pub model: String,
pub member: String,
pub field: String,
pub direction: OrderDirection,
}

impl From<OrderBy> for torii_proto::OrderBy {
fn from(value: OrderBy) -> Self {
Self {
model: value.model.clone(),
member: value.member.clone(),
direction: value.direction.into(),
}
Self { field: value.field.clone(), direction: value.direction.into() }
}
}

Expand Down
Loading