Skip to content

Commit

Permalink
rebase changes
Browse files Browse the repository at this point in the history
  • Loading branch information
tarrencev authored and broody committed Nov 10, 2023
1 parent 76e31b3 commit e5b32cc
Show file tree
Hide file tree
Showing 5 changed files with 72 additions and 1 deletion.
6 changes: 5 additions & 1 deletion crates/torii/client/src/client/subscription.rs
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,11 @@ impl SubscriptionService {
let storage_entries = diff.storage_diffs.into_iter().find_map(|d| {
let expected = self.world_metadata.read().world_address;
let current = d.address;
if current == expected { Some(d.storage_entries) } else { None }
if current == expected {
Some(d.storage_entries)
} else {
None
}
});

let Some(entries) = storage_entries else {
Expand Down
1 change: 1 addition & 0 deletions crates/torii/core/src/error.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use dojo_types::schema::QueryError;
use starknet::core::types::{FromByteSliceError, FromStrError};
use starknet::core::utils::CairoShortStringToFeltError;

Expand Down
1 change: 1 addition & 0 deletions crates/torii/grpc/src/server/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
pub mod error;
pub mod logger;
pub mod query;
pub mod subscription;

use std::future::Future;
Expand Down
64 changes: 64 additions & 0 deletions crates/torii/grpc/src/server/query.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
use serde::{Deserialize, Serialize};
use starknet_crypto::FieldElement;

#[derive(Debug, thiserror::Error)]
pub enum QueryError {
#[error("unsupported query")]
UnsupportedQuery,
}

#[derive(Debug, Serialize, Deserialize, PartialEq, Hash, Eq, Clone)]
pub struct Query {
pub model: String,
pub clause: Clause,
}

#[derive(Debug, Serialize, Deserialize, PartialEq, Hash, Eq, Clone)]
pub enum Clause {
Keys(KeysClause),
Attribute(AttributeClause),
Composite(CompositeClause),
}

#[derive(Debug, Serialize, Deserialize, PartialEq, Hash, Eq, Clone)]
pub struct KeysClause {
pub keys: Vec<FieldElement>,
}

#[derive(Debug, Serialize, Deserialize, PartialEq, Hash, Eq, Clone)]
pub struct AttributeClause {
pub attribute: String,
pub operator: ComparisonOperator,
pub value: Value,
}

#[derive(Debug, Serialize, Deserialize, PartialEq, Hash, Eq, Clone)]
pub struct CompositeClause {
pub operator: LogicalOperator,
pub clauses: Vec<Clause>,
}

#[derive(Debug, Serialize, Deserialize, PartialEq, Hash, Eq, Clone)]
pub enum LogicalOperator {
And,
Or,
}

#[derive(Debug, Serialize, Deserialize, PartialEq, Hash, Eq, Clone)]
pub enum ComparisonOperator {
Eq,
Neq,
Gt,
Gte,
Lt,
Lte,
}

#[derive(Debug, Serialize, Deserialize, PartialEq, Hash, Eq, Clone)]
pub enum Value {
String(String),
Int(i64),
UInt(u64),
Bool(bool),
Bytes(Vec<u8>),
}
1 change: 1 addition & 0 deletions crates/torii/grpc/src/server/subscription.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use std::future::Future;
use std::sync::Arc;
use std::task::Poll;

use dojo_types::schema::EntityQuery;
use futures_util::future::BoxFuture;
use futures_util::FutureExt;
use rand::Rng;
Expand Down

0 comments on commit e5b32cc

Please sign in to comment.