Skip to content

Commit

Permalink
refactor: replace dto::Chain with models::Chain
Browse files Browse the repository at this point in the history
  • Loading branch information
royvardhan committed Feb 25, 2025
1 parent 25a1ee4 commit 2bc2665
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion examples/price_printer/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use clap::Parser;
use futures::{future::select_all, StreamExt};
use tokio::{sync::mpsc, task::JoinHandle};
use tycho_client::feed::component_tracker::ComponentFilter;
use tycho_core::dto::Chain;
use tycho_core::models::Chain;
use tycho_simulation::{
evm::{
engine_db::tycho_db::PreCachedDB,
Expand Down
2 changes: 1 addition & 1 deletion examples/price_printer/utils.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use tracing_subscriber::{fmt, EnvFilter};
use tycho_core::dto::Chain;
use tycho_core::models::Chain;

pub fn setup_tracing() {
let writer = tracing_appender::rolling::daily("logs", "price_printer.log");
Expand Down
2 changes: 1 addition & 1 deletion examples/quickstart/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use tycho_simulation::{
models::Token,
protocol::models::BlockUpdate,
tycho_client::feed::component_tracker::ComponentFilter,
tycho_core::dto::Chain,
tycho_core::models::Chain,
utils::load_all_tokens,
};

Expand Down
4 changes: 2 additions & 2 deletions src/evm/stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use tycho_client::{
feed::{component_tracker::ComponentFilter, synchronizer::ComponentWithState},
stream::{StreamError, TychoStreamBuilder},
};
use tycho_core::{dto::Chain, Bytes};
use tycho_core::{models::Chain, Bytes};

use crate::{
evm::decoder::{StreamDecodeError, TychoStreamDecoder},
Expand Down Expand Up @@ -56,7 +56,7 @@ impl ProtocolStreamBuilder {
pub fn new(tycho_url: &str, chain: Chain) -> Self {
Self {
decoder: TychoStreamDecoder::new(),
stream_builder: TychoStreamBuilder::new(tycho_url, chain),
stream_builder: TychoStreamBuilder::new(tycho_url, chain.into()),
}
}

Expand Down
6 changes: 3 additions & 3 deletions src/evm/tycho_models.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use std::{collections::HashMap, fmt::Display};
use alloy_primitives::{Address, B256, U256};
use chrono::{NaiveDateTime, Utc};
use serde::{Deserialize, Serialize};
pub use tycho_core::dto::{Chain, ChangeType};
pub use tycho_core::{dto::ChangeType, models::Chain};
use uuid::Uuid;

use super::engine_db::simulation_db::BlockHeader;
Expand Down Expand Up @@ -138,7 +138,7 @@ impl AccountUpdate {
impl From<tycho_core::dto::AccountUpdate> for AccountUpdate {
fn from(value: tycho_core::dto::AccountUpdate) -> Self {
Self {
chain: value.chain,
chain: value.chain.into(),
address: Address::from_slice(&value.address[..20]), // Convert address field to Address
slots: u256_num::map_slots_to_u256(value.slots),
balance: value
Expand Down Expand Up @@ -260,7 +260,7 @@ impl std::fmt::Debug for ResponseAccount {
impl From<tycho_core::dto::ResponseAccount> for ResponseAccount {
fn from(value: tycho_core::dto::ResponseAccount) -> Self {
Self {
chain: value.chain,
chain: value.chain.into(),
address: Address::from_slice(&value.address[..20]), // Convert address field to Address
title: value.title.clone(),
slots: u256_num::map_slots_to_u256(value.slots),
Expand Down
6 changes: 3 additions & 3 deletions src/protocol/models.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ use std::{collections::HashMap, default::Default, future::Future};
use chrono::NaiveDateTime;
use num_bigint::BigUint;
use tycho_client::feed::Header;
use tycho_core::{dto::Chain, Bytes};
use tycho_core::{models::Chain, Bytes};

use super::state::ProtocolSim;
use crate::models::Token;
Expand Down Expand Up @@ -93,7 +93,7 @@ impl ProtocolComponent {
id.clone(),
core_model.protocol_system,
core_model.protocol_type_name,
core_model.chain,
core_model.chain.into(),
tokens,
core_model.contract_ids,
core_model.static_attributes,
Expand All @@ -109,7 +109,7 @@ impl From<ProtocolComponent> for tycho_core::dto::ProtocolComponent {
id: hex::encode(component.id),
protocol_system: component.protocol_system,
protocol_type_name: component.protocol_type_name,
chain: component.chain,
chain: component.chain.into(),
tokens: component
.tokens
.into_iter()
Expand Down
4 changes: 2 additions & 2 deletions src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use std::collections::HashMap;

use tracing::info;
use tycho_client::{rpc::RPCClient, HttpRPCClient};
use tycho_core::{dto::Chain, Bytes};
use tycho_core::{models::Chain, Bytes};

use crate::{models::Token, protocol::errors::SimulationError};

Expand Down Expand Up @@ -66,7 +66,7 @@ pub async fn load_all_tokens(
#[allow(clippy::mutable_key_type)]
rpc_client
.get_all_tokens(
chain,
chain.into(),
min_quality.or(Some(100)),
max_days_since_last_trade.or(default_min_days
.get(&chain)
Expand Down

0 comments on commit 2bc2665

Please sign in to comment.