Skip to content

Commit

Permalink
add internal_updated_at field to query
Browse files Browse the repository at this point in the history
  • Loading branch information
edisontim committed Dec 14, 2024
1 parent d67776b commit dcf0358
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 15 deletions.
14 changes: 7 additions & 7 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 = "180c6d2" }
dojo-types = { git = "https://github.com/dojoengine/dojo", rev = "180c6d2" }
torii-client = { git = "https://github.com/dojoengine/dojo", rev = "180c6d2" }
dojo-world = { git = "https://github.com/dojoengine/dojo", rev = "85df91a80b2a63c0bed98a209be2744581859449" }
dojo-types = { git = "https://github.com/dojoengine/dojo", rev = "85df91a80b2a63c0bed98a209be2744581859449" }
torii-client = { git = "https://github.com/dojoengine/dojo", rev = "85df91a80b2a63c0bed98a209be2744581859449" }
torii-grpc = { git = "https://github.com/dojoengine/dojo", features = [
"client",
], rev = "180c6d2" }
torii-relay = { git = "https://github.com/dojoengine/dojo", rev = "180c6d2" }
], rev = "85df91a80b2a63c0bed98a209be2744581859449" }
torii-relay = { git = "https://github.com/dojoengine/dojo", rev = "85df91a80b2a63c0bed98a209be2744581859449" }

starknet = "0.12.0"
starknet-crypto = "0.7.2"
Expand Down
1 change: 1 addition & 0 deletions dojo.h
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,7 @@ typedef struct Query {
bool dont_include_hashed_keys;
struct CArrayOrderBy order_by;
struct CArrayc_char entity_models;
uint64_t internal_updated_at;
} 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 @@ -725,6 +725,7 @@ struct Query {
bool dont_include_hashed_keys;
CArray<OrderBy> order_by;
CArray<const char*> entity_models;
uint64_t internal_updated_at;
};

struct ModelMetadata {
Expand Down
1 change: 1 addition & 0 deletions dojo.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,7 @@ cdef extern from *:
bool dont_include_hashed_keys;
CArrayOrderBy order_by;
CArrayc_char entity_models;
uint64_t internal_updated_at;

cdef struct CArrayFieldElement:
FieldElement *data;
Expand Down
7 changes: 6 additions & 1 deletion src/c/types.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::ffi::{CStr, CString, c_char};
use std::ffi::{c_char, CStr, CString};

use starknet::core::utils::get_selector_from_name;
use torii_client::client::Client;
Expand Down Expand Up @@ -326,6 +326,7 @@ pub struct Query {
pub dont_include_hashed_keys: bool,
pub order_by: CArray<OrderBy>,
pub entity_models: CArray<*const c_char>,
pub internal_updated_at: u64,
}

#[derive(Clone, Debug)]
Expand Down Expand Up @@ -895,6 +896,7 @@ impl From<&Query> for torii_grpc::types::Query {
dont_include_hashed_keys: val.dont_include_hashed_keys,
order_by,
entity_models,
internal_updated_at: val.internal_updated_at,
}
}
COption::None => torii_grpc::types::Query {
Expand All @@ -904,6 +906,7 @@ impl From<&Query> for torii_grpc::types::Query {
dont_include_hashed_keys: val.dont_include_hashed_keys,
order_by,
entity_models,
internal_updated_at: val.internal_updated_at,
},
}
}
Expand All @@ -924,6 +927,7 @@ impl From<&torii_grpc::types::Query> for Query {
dont_include_hashed_keys: val.dont_include_hashed_keys,
order_by: order_by.into(),
entity_models,
internal_updated_at: val.internal_updated_at,
}
}
Option::None => Query {
Expand All @@ -933,6 +937,7 @@ impl From<&torii_grpc::types::Query> for Query {
dont_include_hashed_keys: val.dont_include_hashed_keys,
order_by: order_by.into(),
entity_models,
internal_updated_at: val.internal_updated_at,
},
}
}
Expand Down
3 changes: 2 additions & 1 deletion src/wasm/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -676,7 +676,7 @@ impl ToriiClient {
/// # Returns
/// Result containing paginated entities or error
#[wasm_bindgen(js_name = getAllEntities)]
pub async fn get_all_entities(&self, limit: u32, offset: u32) -> Result<Entities, JsValue> {
pub async fn get_all_entities(&self, limit: u32, offset: u32, internal_updated_at: u64) -> Result<Entities, JsValue> {
#[cfg(feature = "console-error-panic")]
console_error_panic_hook::set_once();

Expand All @@ -689,6 +689,7 @@ impl ToriiClient {
dont_include_hashed_keys: false,
order_by: vec![],
entity_models: vec![],
internal_updated_at,
})
.await;

Expand Down
4 changes: 3 additions & 1 deletion src/wasm/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use serde_wasm_bindgen::to_value;
use starknet::core::types::FunctionCall;
use starknet::core::utils::get_selector_from_name;
use starknet_crypto::Felt;
use tsify_next::{Tsify, declare};
use tsify_next::{declare, Tsify};
use wasm_bindgen::prelude::*;

use super::utils::parse_ty_as_json_str;
Expand Down Expand Up @@ -302,6 +302,7 @@ pub struct Query {
pub dont_include_hashed_keys: bool,
pub order_by: Vec<OrderBy>,
pub entity_models: Vec<String>,
pub internal_updated_at: u64,
}

#[derive(Tsify, Serialize, Deserialize, Debug)]
Expand Down Expand Up @@ -347,6 +348,7 @@ impl From<&Query> for torii_grpc::types::Query {
dont_include_hashed_keys: value.dont_include_hashed_keys,
order_by: value.order_by.iter().map(|o| o.into()).collect(),
entity_models: value.entity_models.iter().map(|m| m.to_string()).collect(),
internal_updated_at: value.internal_updated_at,
}
}
}
Expand Down

0 comments on commit dcf0358

Please sign in to comment.