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

feat(torii): sync from master torii #2851

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
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: 1 addition & 0 deletions bin/torii/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ 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_grpc::client::WorldClient;
use torii_server::proxy::Proxy;
use tracing::{error, info};
use tracing_subscriber::{fmt, EnvFilter};
Expand Down
31 changes: 31 additions & 0 deletions crates/torii/cli/src/options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@
use std::str::FromStr;

use anyhow::Context;
use dojo_utils::parse::parse_url;
use serde::ser::SerializeSeq;
use serde::{Deserialize, Serialize};
use starknet::core::types::Felt;
use torii_core::types::{Contract, ContractType};
use url::Url;

pub const DEFAULT_HTTP_ADDR: IpAddr = IpAddr::V4(Ipv4Addr::LOCALHOST);
pub const DEFAULT_HTTP_PORT: u16 = 8080;
Expand All @@ -20,6 +22,9 @@
pub const DEFAULT_RELAY_WEBRTC_PORT: u16 = 9091;
pub const DEFAULT_RELAY_WEBSOCKET_PORT: u16 = 9092;

pub const DEFAULT_REPLICA_ENTITIES: bool = true;
pub const DEFAULT_REPLICA_EVENT_MESSAGES: bool = true;

#[derive(Debug, clap::Args, Clone, Serialize, Deserialize, PartialEq)]
#[command(next_help_heading = "Relay options")]
pub struct RelayOptions {
Expand Down Expand Up @@ -317,6 +322,32 @@
}
}

#[derive(Debug, clap::Args, Clone, Serialize, Deserialize, PartialEq)]

Check warning on line 325 in crates/torii/cli/src/options.rs

View check run for this annotation

Codecov / codecov/patch

crates/torii/cli/src/options.rs#L325

Added line #L325 was not covered by tests
#[command(next_help_heading = "Replica options")]
pub struct ReplicaOptions {
/// The master torii URL to connect to
#[arg(long, value_name = "URL", value_parser = parse_url)]
pub master_torii: Option<Url>,

/// If this replica should sync entity updates
#[arg(long, default_value_t = DEFAULT_REPLICA_ENTITIES)]
pub entities: bool,

Check warning on line 334 in crates/torii/cli/src/options.rs

View check run for this annotation

Codecov / codecov/patch

crates/torii/cli/src/options.rs#L333-L334

Added lines #L333 - L334 were not covered by tests

/// If this replica should sync event messages
#[arg(long, default_value_t = DEFAULT_REPLICA_EVENT_MESSAGES)]
pub event_messages: bool,

Check warning on line 338 in crates/torii/cli/src/options.rs

View check run for this annotation

Codecov / codecov/patch

crates/torii/cli/src/options.rs#L337-L338

Added lines #L337 - L338 were not covered by tests
}

impl Default for ReplicaOptions {
fn default() -> Self {
Self {
master_torii: None,
entities: DEFAULT_REPLICA_ENTITIES,
event_messages: DEFAULT_REPLICA_EVENT_MESSAGES,
}
}

Check warning on line 348 in crates/torii/cli/src/options.rs

View check run for this annotation

Codecov / codecov/patch

crates/torii/cli/src/options.rs#L342-L348

Added lines #L342 - L348 were not covered by tests
}

// Parses clap cli argument which is expected to be in the format:
// - erc_type:address:start_block
// - address:start_block (erc_type defaults to ERC20)
Expand Down
Loading