Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(torii-grpc): world class hash #2307

Merged
merged 3 commits into from
Aug 16, 2024
Merged
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
1 change: 0 additions & 1 deletion crates/dojo-types/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ pub mod system;
#[derive(Debug, Clone, Serialize, Default)]
pub struct WorldMetadata {
pub world_address: Felt,
pub world_class_hash: Felt,
pub models: HashMap<Felt, ModelMetadata>,
}

Expand Down
6 changes: 0 additions & 6 deletions crates/torii/core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,4 @@ pub mod utils;
pub struct World {
#[sqlx(try_from = "String")]
world_address: SQLFelt,
#[sqlx(try_from = "String")]
world_class_hash: SQLFelt,
#[sqlx(try_from = "String")]
executor_address: SQLFelt,
#[sqlx(try_from = "String")]
executor_class_hash: SQLFelt,
}
2 changes: 1 addition & 1 deletion crates/torii/core/src/sql.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ use sqlx::{Pool, Row, Sqlite};
use starknet::core::types::{Event, Felt, InvokeTransaction, Transaction};
use starknet_crypto::poseidon_hash_many;

use super::World;
use crate::model::ModelSQLReader;
use crate::query_queue::{Argument, QueryQueue};
use crate::simple_broker::SimpleBroker;
Expand All @@ -22,6 +21,7 @@ use crate::types::{
Model as ModelRegistered,
};
use crate::utils::{must_utc_datetime_from_timestamp, utc_dt_string_from_timestamp};
use crate::World;

type IsEventMessage = bool;
type IsStoreUpdateMember = bool;
Expand Down
2 changes: 0 additions & 2 deletions crates/torii/grpc/proto/types.proto
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ import "schema.proto";
message WorldMetadata {
// The hex-encoded address of the world.
string world_address = 1;
// The hex-encoded class hash of the world.
string world_class_hash = 2;
// A list of metadata for all registered components in the world.
repeated ModelMetadata models = 5;
}
Expand Down
6 changes: 3 additions & 3 deletions crates/torii/grpc/src/server/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,8 @@

impl DojoWorld {
pub async fn metadata(&self) -> Result<proto::types::WorldMetadata, Error> {
let (world_address, world_class_hash): (String, String) = sqlx::query_as(&format!(
"SELECT world_address, world_class_hash FROM worlds WHERE id = '{:#x}'",
let world_address = sqlx::query_scalar(&format!(
"SELECT world_address FROM worlds WHERE id = '{:#x}'",

Check warning on line 135 in crates/torii/grpc/src/server/mod.rs

View check run for this annotation

Codecov / codecov/patch

crates/torii/grpc/src/server/mod.rs#L134-L135

Added lines #L134 - L135 were not covered by tests
self.world_address
))
.fetch_one(&self.pool)
Expand Down Expand Up @@ -175,7 +175,7 @@
});
}

Ok(proto::types::WorldMetadata { world_address, world_class_hash, models: models_metadata })
Ok(proto::types::WorldMetadata { world_address, models: models_metadata })

Check warning on line 178 in crates/torii/grpc/src/server/mod.rs

View check run for this annotation

Codecov / codecov/patch

crates/torii/grpc/src/server/mod.rs#L178

Added line #L178 was not covered by tests
}

async fn entities_all(
Expand Down
1 change: 0 additions & 1 deletion crates/torii/grpc/src/types/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,6 @@ impl TryFrom<proto::types::WorldMetadata> for dojo_types::WorldMetadata {
Ok(dojo_types::WorldMetadata {
models,
world_address: Felt::from_str(&value.world_address)?,
world_class_hash: Felt::from_str(&value.world_class_hash)?,
})
}
}
Expand Down
Loading