From dcf0358848ca52a0bdf0d0e896b532c44d73789b Mon Sep 17 00:00:00 2001 From: tedison Date: Sat, 14 Dec 2024 17:28:53 -0500 Subject: [PATCH 1/2] add internal_updated_at field to query --- Cargo.lock | 14 +++++++------- Cargo.toml | 10 +++++----- dojo.h | 1 + dojo.hpp | 1 + dojo.pyx | 1 + src/c/types.rs | 7 ++++++- src/wasm/mod.rs | 3 ++- src/wasm/types.rs | 4 +++- 8 files changed, 26 insertions(+), 15 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 65d7475..0851031 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1687,7 +1687,7 @@ dependencies = [ [[package]] name = "dojo-types" version = "1.0.7" -source = "git+https://github.com/dojoengine/dojo?rev=180c6d2#180c6d21132f58436c356d5d7585cee1fbce4ece" +source = "git+https://github.com/dojoengine/dojo?rev=85df91a80b2a63c0bed98a209be2744581859449#85df91a80b2a63c0bed98a209be2744581859449" dependencies = [ "anyhow", "cainome 0.4.8", @@ -1709,7 +1709,7 @@ dependencies = [ [[package]] name = "dojo-utils" version = "1.0.7" -source = "git+https://github.com/dojoengine/dojo?rev=180c6d2#180c6d21132f58436c356d5d7585cee1fbce4ece" +source = "git+https://github.com/dojoengine/dojo?rev=85df91a80b2a63c0bed98a209be2744581859449#85df91a80b2a63c0bed98a209be2744581859449" dependencies = [ "anyhow", "colored_json", @@ -1726,7 +1726,7 @@ dependencies = [ [[package]] name = "dojo-world" version = "1.0.7" -source = "git+https://github.com/dojoengine/dojo?rev=180c6d2#180c6d21132f58436c356d5d7585cee1fbce4ece" +source = "git+https://github.com/dojoengine/dojo?rev=85df91a80b2a63c0bed98a209be2744581859449#85df91a80b2a63c0bed98a209be2744581859449" dependencies = [ "anyhow", "async-trait", @@ -7181,7 +7181,7 @@ dependencies = [ [[package]] name = "torii-client" version = "1.0.7" -source = "git+https://github.com/dojoengine/dojo?rev=180c6d2#180c6d21132f58436c356d5d7585cee1fbce4ece" +source = "git+https://github.com/dojoengine/dojo?rev=85df91a80b2a63c0bed98a209be2744581859449#85df91a80b2a63c0bed98a209be2744581859449" dependencies = [ "async-trait", "crypto-bigint", @@ -7209,7 +7209,7 @@ dependencies = [ [[package]] name = "torii-core" version = "1.0.7" -source = "git+https://github.com/dojoengine/dojo?rev=180c6d2#180c6d21132f58436c356d5d7585cee1fbce4ece" +source = "git+https://github.com/dojoengine/dojo?rev=85df91a80b2a63c0bed98a209be2744581859449#85df91a80b2a63c0bed98a209be2744581859449" dependencies = [ "anyhow", "async-trait", @@ -7244,7 +7244,7 @@ dependencies = [ [[package]] name = "torii-grpc" version = "1.0.7" -source = "git+https://github.com/dojoengine/dojo?rev=180c6d2#180c6d21132f58436c356d5d7585cee1fbce4ece" +source = "git+https://github.com/dojoengine/dojo?rev=85df91a80b2a63c0bed98a209be2744581859449#85df91a80b2a63c0bed98a209be2744581859449" dependencies = [ "crypto-bigint", "dojo-types", @@ -7283,7 +7283,7 @@ dependencies = [ [[package]] name = "torii-relay" version = "1.0.7" -source = "git+https://github.com/dojoengine/dojo?rev=180c6d2#180c6d21132f58436c356d5d7585cee1fbce4ece" +source = "git+https://github.com/dojoengine/dojo?rev=85df91a80b2a63c0bed98a209be2744581859449#85df91a80b2a63c0bed98a209be2744581859449" dependencies = [ "anyhow", "cainome 0.4.8", diff --git a/Cargo.toml b/Cargo.toml index 6be855a..c0c3731 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -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" diff --git a/dojo.h b/dojo.h index 5dd1e95..abd907c 100644 --- a/dojo.h +++ b/dojo.h @@ -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 { diff --git a/dojo.hpp b/dojo.hpp index 05029eb..0746545 100644 --- a/dojo.hpp +++ b/dojo.hpp @@ -725,6 +725,7 @@ struct Query { bool dont_include_hashed_keys; CArray order_by; CArray entity_models; + uint64_t internal_updated_at; }; struct ModelMetadata { diff --git a/dojo.pyx b/dojo.pyx index b6ff749..851b3be 100644 --- a/dojo.pyx +++ b/dojo.pyx @@ -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; diff --git a/src/c/types.rs b/src/c/types.rs index 9a381f0..efabaf1 100644 --- a/src/c/types.rs +++ b/src/c/types.rs @@ -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; @@ -326,6 +326,7 @@ pub struct Query { pub dont_include_hashed_keys: bool, pub order_by: CArray, pub entity_models: CArray<*const c_char>, + pub internal_updated_at: u64, } #[derive(Clone, Debug)] @@ -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 { @@ -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, }, } } @@ -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 { @@ -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, }, } } diff --git a/src/wasm/mod.rs b/src/wasm/mod.rs index 85f376d..1acc201 100644 --- a/src/wasm/mod.rs +++ b/src/wasm/mod.rs @@ -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 { + pub async fn get_all_entities(&self, limit: u32, offset: u32, internal_updated_at: u64) -> Result { #[cfg(feature = "console-error-panic")] console_error_panic_hook::set_once(); @@ -689,6 +689,7 @@ impl ToriiClient { dont_include_hashed_keys: false, order_by: vec![], entity_models: vec![], + internal_updated_at, }) .await; diff --git a/src/wasm/types.rs b/src/wasm/types.rs index 75dcbfe..323b20d 100644 --- a/src/wasm/types.rs +++ b/src/wasm/types.rs @@ -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; @@ -302,6 +302,7 @@ pub struct Query { pub dont_include_hashed_keys: bool, pub order_by: Vec, pub entity_models: Vec, + pub internal_updated_at: u64, } #[derive(Tsify, Serialize, Deserialize, Debug)] @@ -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, } } } From 861ef4c9b378cc80ca9c01305e298e4858dcc782 Mon Sep 17 00:00:00 2001 From: tedison Date: Sat, 14 Dec 2024 18:10:37 -0500 Subject: [PATCH 2/2] fmt --- src/c/types.rs | 2 +- src/wasm/mod.rs | 4 ++-- src/wasm/types.rs | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/c/types.rs b/src/c/types.rs index efabaf1..d588701 100644 --- a/src/c/types.rs +++ b/src/c/types.rs @@ -1,4 +1,4 @@ -use std::ffi::{c_char, CStr, CString}; +use std::ffi::{CStr, CString, c_char}; use starknet::core::utils::get_selector_from_name; use torii_client::client::Client; diff --git a/src/wasm/mod.rs b/src/wasm/mod.rs index 1acc201..2e996af 100644 --- a/src/wasm/mod.rs +++ b/src/wasm/mod.rs @@ -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, internal_updated_at: u64) -> Result { + pub async fn get_all_entities(&self, limit: u32, offset: u32) -> Result { #[cfg(feature = "console-error-panic")] console_error_panic_hook::set_once(); @@ -689,7 +689,7 @@ impl ToriiClient { dont_include_hashed_keys: false, order_by: vec![], entity_models: vec![], - internal_updated_at, + internal_updated_at: 0, }) .await; diff --git a/src/wasm/types.rs b/src/wasm/types.rs index 323b20d..ed58925 100644 --- a/src/wasm/types.rs +++ b/src/wasm/types.rs @@ -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::{declare, Tsify}; +use tsify_next::{Tsify, declare}; use wasm_bindgen::prelude::*; use super::utils::parse_ty_as_json_str;