Skip to content

Commit

Permalink
refactor(torii): fragment into different modules (#2856)
Browse files Browse the repository at this point in the history
* refactor: start fragmenting torii

* engine and qslite

* use torii_sqlite in engine

* rename to indexer

* move tests to indexer

* update all crates to use new fragmented torii

* fmt

* sotre update member

* add back tests

* fmt
  • Loading branch information
Larkooo authored Jan 8, 2025
1 parent eb65d81 commit baf0ce9
Show file tree
Hide file tree
Showing 71 changed files with 425 additions and 333 deletions.
132 changes: 88 additions & 44 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,8 @@ katana-trie = { path = "crates/katana/trie" }
# torii
torii-cli = { path = "crates/torii/cli" }
torii-client = { path = "crates/torii/client" }
torii-core = { path = "crates/torii/core" }
torii-indexer = { path = "crates/torii/indexer" }
torii-sqlite = { path = "crates/torii/sqlite" }
torii-graphql = { path = "crates/torii/graphql" }
torii-grpc = { path = "crates/torii/grpc" }
torii-relay = { path = "crates/torii/libp2p" }
Expand Down
3 changes: 2 additions & 1 deletion bin/torii/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ tokio-util = "0.7.7"
tokio.workspace = true
toml.workspace = true
torii-cli.workspace = true
torii-core.workspace = true
torii-indexer.workspace = true
torii-sqlite.workspace = true
torii-graphql.workspace = true
torii-grpc = { workspace = true, features = [ "server" ] }
torii-relay.workspace = true
Expand Down
16 changes: 8 additions & 8 deletions bin/torii/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,15 @@ use tempfile::{NamedTempFile, TempDir};
use tokio::sync::broadcast;
use tokio::sync::broadcast::Sender;
use tokio_stream::StreamExt;
use torii_core::engine::{Engine, EngineConfig, IndexingFlags, Processors};
use torii_core::executor::Executor;
use torii_core::processors::store_transaction::StoreTransactionProcessor;
use torii_core::processors::EventProcessorConfig;
use torii_core::simple_broker::SimpleBroker;
use torii_core::sql::cache::ModelCache;
use torii_core::sql::Sql;
use torii_core::types::{Contract, ContractType, Model};
use torii_indexer::engine::{Engine, EngineConfig, IndexingFlags, Processors};
use torii_indexer::processors::store_transaction::StoreTransactionProcessor;
use torii_indexer::processors::EventProcessorConfig;
use torii_server::proxy::Proxy;
use torii_sqlite::cache::ModelCache;
use torii_sqlite::executor::Executor;
use torii_sqlite::simple_broker::SimpleBroker;
use torii_sqlite::types::{Contract, ContractType, Model};
use torii_sqlite::Sql;
use tracing::{error, info};
use tracing_subscriber::{fmt, EnvFilter};
use url::form_urlencoded;
Expand Down
2 changes: 1 addition & 1 deletion crates/torii/cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ dojo-utils.workspace = true
serde.workspace = true
starknet.workspace = true
toml.workspace = true
torii-core.workspace = true
torii-sqlite.workspace = true
url.workspace = true

[dev-dependencies]
Expand Down
2 changes: 1 addition & 1 deletion crates/torii/cli/src/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ mod test {
use std::net::{IpAddr, Ipv4Addr};
use std::str::FromStr;

use torii_core::types::{Contract, ContractType};
use torii_sqlite::types::{Contract, ContractType};

use super::*;

Expand Down
2 changes: 1 addition & 1 deletion crates/torii/cli/src/options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use anyhow::Context;
use serde::ser::SerializeSeq;
use serde::{Deserialize, Serialize};
use starknet::core::types::Felt;
use torii_core::types::{Contract, ContractType};
use torii_sqlite::types::{Contract, ContractType};

pub const DEFAULT_HTTP_ADDR: IpAddr = IpAddr::V4(Ipv4Addr::LOCALHOST);
pub const DEFAULT_HTTP_PORT: u16 = 8080;
Expand Down
12 changes: 0 additions & 12 deletions crates/torii/core/src/lib.rs

This file was deleted.

82 changes: 0 additions & 82 deletions crates/torii/core/src/utils.rs

This file was deleted.

3 changes: 2 additions & 1 deletion crates/torii/graphql/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ strum_macros.workspace = true
thiserror.workspace = true
tokio.workspace = true
tokio-stream = "0.1.11"
torii-core.workspace = true
torii-sqlite.workspace = true
torii-indexer.workspace = true
tracing.workspace = true
url.workspace = true
warp.workspace = true
Expand Down
4 changes: 2 additions & 2 deletions crates/torii/graphql/src/object/entity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ use dojo_types::naming::get_tag;
use dojo_types::schema::Ty;
use sqlx::{Pool, Sqlite};
use tokio_stream::StreamExt;
use torii_core::simple_broker::SimpleBroker;
use torii_core::types::Entity;
use torii_sqlite::simple_broker::SimpleBroker;
use torii_sqlite::types::Entity;

use super::inputs::keys_input::keys_argument;
use super::{BasicObject, ResolvableObject, TypeMapping, ValueMapping};
Expand Down
4 changes: 2 additions & 2 deletions crates/torii/graphql/src/object/erc/token_balance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ use serde::Deserialize;
use sqlx::sqlite::SqliteRow;
use sqlx::{FromRow, Pool, Row, Sqlite, SqliteConnection};
use starknet_crypto::Felt;
use torii_core::constants::TOKEN_BALANCE_TABLE;
use torii_core::sql::utils::felt_to_sql_string;
use torii_sqlite::constants::TOKEN_BALANCE_TABLE;
use torii_sqlite::utils::felt_to_sql_string;
use tracing::warn;

use super::erc_token::{Erc20Token, ErcTokenType};
Expand Down
Loading

0 comments on commit baf0ce9

Please sign in to comment.