Skip to content
Open
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
9 changes: 9 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
repos:
- repo: local
hooks:
- id: clippy
name: cargo clippy (workspace)
entry: bash -lc './scripts/clippy.sh'
language: system
pass_filenames: false
always_run: true
58 changes: 58 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,64 @@ license-file = "LICENSE"
repository = "https://github.com/dojoengine/torii"
version = "1.8.12"

[workspace.lints.clippy]
# Enable pedantic lints for stricter code quality
pedantic = { level = "warn", priority = -1 }

# Pedantic overrides - these are too noisy or don't fit this codebase
missing_errors_doc = "allow"
missing_panics_doc = "allow"
must_use_candidate = "allow"
doc_markdown = "allow"
similar_names = "allow"
too_many_lines = "allow"
module_name_repetitions = "allow"
struct_excessive_bools = "allow"
fn_params_excessive_bools = "allow"
items_after_statements = "allow"
uninlined_format_args = "allow"
return_self_not_must_use = "allow"
# Cast lints - many false positives where values are known to be in range
cast_possible_truncation = "allow"
cast_sign_loss = "allow"
cast_precision_loss = "allow"
cast_possible_wrap = "allow"
default_trait_access = "allow"
match_same_arms = "allow"
unused_async = "allow"
manual_let_else = "allow"
used_underscore_binding = "allow"
ref_option_ref = "allow"
ref_option = "allow"
format_push_string = "allow"
case_sensitive_file_extension_comparisons = "allow"
unnecessary_wraps = "allow"
needless_pass_by_value = "allow"
trivially_copy_pass_by_ref = "allow"
no_effect_underscore_binding = "allow"
redundant_closure_for_method_calls = "allow"

# Panic safety - deny any operations that could panic
unwrap_used = "deny"
expect_used = "deny"
panic = "deny"

# Prohibit all allow attributes - no exceptions
allow_attributes = "deny"

# Allow large error types
result_large_err = "allow"

# No debug macros in production code
dbg_macro = "deny"
# No incomplete code markers
todo = "deny"
unimplemented = "deny"

# Use tracing instead of println/eprintln in library code
print_stdout = "deny"
print_stderr = "deny"

[profile.performance]
codegen-units = 1
incremental = false
Expand Down
3 changes: 3 additions & 0 deletions bin/torii/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ edition.workspace = true
name = "torii"
version.workspace = true

[lints]
workspace = true

[dependencies]
torii-cli.workspace = true
torii-runner.workspace = true
Expand Down
3 changes: 3 additions & 0 deletions crates/adigraphmap/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ name = "torii-adigraphmap"
repository.workspace = true
version.workspace = true

[lints]
workspace = true

[dependencies]
petgraph = "0.6"
thiserror.workspace = true
Expand Down
3 changes: 3 additions & 0 deletions crates/broker/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ name = "torii-broker"
version.workspace = true
edition.workspace = true

[lints]
workspace = true

[dependencies]
dashmap = "6.0"
futures-channel = "0.3"
Expand Down
3 changes: 3 additions & 0 deletions crates/cache/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ edition.workspace = true
repository.workspace = true
version.workspace = true

[lints]
workspace = true

[dependencies]
async-trait.workspace = true
dashmap.workspace = true
Expand Down
3 changes: 3 additions & 0 deletions crates/cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ name = "torii-cli"
repository.workspace = true
version.workspace = true

[lints]
workspace = true

[dependencies]
anyhow.workspace = true
camino.workspace = true
Expand Down
3 changes: 3 additions & 0 deletions crates/client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ version.workspace = true

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[lints]
workspace = true

[dependencies]
async-trait.workspace = true
crypto-bigint.workspace = true
Expand Down
3 changes: 3 additions & 0 deletions crates/controllers/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ edition.workspace = true
repository.workspace = true
version.workspace = true

[lints]
workspace = true

[dependencies]
chrono.workspace = true
reqwest.workspace = true
Expand Down
3 changes: 3 additions & 0 deletions crates/graphql/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ version.workspace = true

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[lints]
workspace = true

[dependencies]
anyhow.workspace = true
async-graphql = { version = "7.0.11", features = [ "chrono", "dynamic-schema" ] }
Expand Down
3 changes: 3 additions & 0 deletions crates/grpc/client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ name = "torii-grpc-client"
repository.workspace = true
version.workspace = true

[lints]
workspace = true

[dependencies]
futures.workspace = true
futures-util.workspace = true
Expand Down
3 changes: 3 additions & 0 deletions crates/grpc/server/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ name = "torii-grpc-server"
repository.workspace = true
version.workspace = true

[lints]
workspace = true

[dependencies]
dojo-types.workspace = true
futures.workspace = true
Expand Down
9 changes: 7 additions & 2 deletions crates/grpc/server/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -188,10 +188,13 @@ impl<P: Provider + Sync> DojoWorld<P> {

let mut worlds = HashMap::<Felt, Vec<proto::types::Model>>::new();
for model in models {
let proto_model: proto::types::Model = model
.try_into()
.map_err(|e| anyhow!("Failed to serialize model: {}", e))?;
worlds
.entry(model.world_address)
.or_default()
.push(model.into())
.push(proto_model);
}

Ok(worlds
Expand All @@ -218,7 +221,9 @@ impl<P: Provider + Sync> DojoWorld<P> {
.await
.map_err(|e| anyhow!("Failed to get model from cache: {}", e))?;

Ok(model.into())
Ok(model
.try_into()
.map_err(|e| anyhow!("Failed to serialize model: {}", e))?)
}
}

Expand Down
3 changes: 3 additions & 0 deletions crates/indexer/engine/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ version.workspace = true

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[lints]
workspace = true

[dependencies]
anyhow.workspace = true
async-recursion = "1.0.5"
Expand Down
3 changes: 3 additions & 0 deletions crates/indexer/fetcher/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ version.workspace = true

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[lints]
workspace = true

[dependencies]
anyhow.workspace = true
async-recursion = "1.0.5"
Expand Down
3 changes: 3 additions & 0 deletions crates/libp2p/client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ version.workspace = true

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[lints]
workspace = true

[dependencies]
futures.workspace = true
serde.workspace = true
Expand Down
4 changes: 3 additions & 1 deletion crates/libp2p/relay/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ version.workspace = true

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[lints]
workspace = true

[dependencies]
futures.workspace = true
serde.workspace = true
Expand Down Expand Up @@ -35,4 +38,3 @@ katana-runner.workspace = true
tempfile.workspace = true
tokio.workspace = true
tracing-subscriber.workspace = true

3 changes: 3 additions & 0 deletions crates/math/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,8 @@ edition.workspace = true
repository.workspace = true
version.workspace = true

[lints]
workspace = true

[dependencies]
starknet.workspace = true
3 changes: 3 additions & 0 deletions crates/mcp/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ version.workspace = true

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[lints]
workspace = true

[dependencies]
serde.workspace = true
serde_json.workspace = true
Expand Down
3 changes: 3 additions & 0 deletions crates/messaging/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ name = "torii-messaging"
repository.workspace = true
version.workspace = true

[lints]
workspace = true

[dependencies]
anyhow.workspace = true
async-trait.workspace = true
Expand Down
3 changes: 3 additions & 0 deletions crates/processors/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ license.workspace = true
repository.workspace = true
version.workspace = true

[lints]
workspace = true

[dependencies]
dojo-world.workspace = true
dojo-types.workspace = true
Expand Down
3 changes: 3 additions & 0 deletions crates/proto/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ name = "torii-proto"
repository.workspace = true
version.workspace = true

[lints]
workspace = true

[target.'cfg(target_arch = "wasm32")'.dependencies]
wasm-prost.workspace = true
wasm-tonic.workspace = true
Expand Down
22 changes: 11 additions & 11 deletions crates/proto/build.rs
Original file line number Diff line number Diff line change
@@ -1,31 +1,31 @@
use std::io::Write;
use std::path::PathBuf;

fn main() -> Result<(), Box<dyn std::error::Error>> {
let out_dir =
PathBuf::from(std::env::var("OUT_DIR").expect("OUT_DIR environment variable not set"));
let target = std::env::var("TARGET").expect("TARGET environment variable not set");
let feature_client = std::env::var("CARGO_FEATURE_CLIENT");
let feature_server = std::env::var("CARGO_FEATURE_SERVER");
let out_dir = PathBuf::from(std::env::var("OUT_DIR")?);
let target = std::env::var("TARGET")?;
let feature_client = std::env::var("CARGO_FEATURE_CLIENT").is_ok();
let feature_server = std::env::var("CARGO_FEATURE_SERVER").is_ok();

if target.contains("wasm32") {
if feature_server.is_ok() {
panic!("feature `server` is not supported on target `{target}`");
if feature_server {
return Err(format!("feature `server` is not supported on target `{target}`").into());
}

wasm_tonic_build::configure()
.build_server(false)
.build_client(feature_client.is_ok())
.build_client(feature_client)
.file_descriptor_set_path(out_dir.join("world_descriptor.bin"))
.compile_protos(&["proto/world.proto"], &["proto"])?;
} else {
tonic_build::configure()
.build_server(feature_server.is_ok())
.build_client(feature_client.is_ok())
.build_server(feature_server)
.build_client(feature_client)
.file_descriptor_set_path(out_dir.join("world_descriptor.bin"))
.compile(&["proto/world.proto"], &["proto"])?;
}

println!("cargo:rerun-if-changed=proto");
std::io::stdout().write_all(b"cargo:rerun-if-changed=proto\n")?;

Ok(())
}
Loading
Loading