Merge pull request #136 from propeller-heads/ah/switch-to-tycho-commons

feat: switch to tycho commons
This commit is contained in:
Alan Höng
2025-03-27 17:00:38 +01:00
committed by GitHub
16 changed files with 58 additions and 26 deletions

30
.github/workflows/release.yaml vendored Normal file
View File

@@ -0,0 +1,30 @@
name: Release
on:
workflow_dispatch:
inputs: { }
release:
types: [ created, prereleased ]
permissions:
id-token: write
contents: write
jobs:
publish-crate:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
- name: Push to crates.io
run: |
cargo publish --locked --verbose --token ${{ secrets.CRATESIO_REGISTRY_TOKEN }}
# we can't use the action because it errors on github dependencies in any workspace crate
# - uses: katyo/publish-crates@v2
# with:
# path: "./tycho-common"
# registry-token: ${{ secrets.CRATESIO_REGISTRY_TOKEN }}

9
Cargo.lock generated
View File

@@ -4316,9 +4316,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b"
[[package]] [[package]]
name = "tycho-core" name = "tycho-common"
version = "0.61.1" version = "0.63.1"
source = "git+https://github.com/propeller-heads/tycho-indexer.git?tag=0.61.1#aae2c11bffe9ae5e436adc019b769438fa038272" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "57c64749b24bdb5de6050c37ea91420a67a5fe606247fdb29f2e812dac30b42e"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"async-trait", "async-trait",
@@ -4358,7 +4359,7 @@ dependencies = [
"serde_json", "serde_json",
"thiserror 1.0.69", "thiserror 1.0.69",
"tokio", "tokio",
"tycho-core", "tycho-common",
] ]
[[package]] [[package]]

View File

@@ -24,7 +24,7 @@ clap = { version = "4.5.3", features = ["derive"] }
alloy = { version = "0.9.2", features = ["providers", "rpc-types-eth", "eip712", "signer-local"], optional = true } alloy = { version = "0.9.2", features = ["providers", "rpc-types-eth", "eip712", "signer-local"], optional = true }
alloy-sol-types = { version = "0.8.14", optional = true } alloy-sol-types = { version = "0.8.14", optional = true }
alloy-primitives = { version = "0.8.9", optional = true } alloy-primitives = { version = "0.8.9", optional = true }
tycho-core = { git = "https://github.com/propeller-heads/tycho-indexer.git", package = "tycho-core", tag = "0.61.1" } tycho-common = "0.63.1"
once_cell = "1.20.2" once_cell = "1.20.2"
[dev-dependencies] [dev-dependencies]

View File

@@ -1,7 +1,7 @@
use std::str::FromStr; use std::str::FromStr;
use num_bigint::BigUint; use num_bigint::BigUint;
use tycho_core::{ use tycho_common::{
models::{protocol::ProtocolComponent, Chain}, models::{protocol::ProtocolComponent, Chain},
Bytes, Bytes,
}; };

View File

@@ -1,7 +1,7 @@
use std::io::{self, Read}; use std::io::{self, Read};
use clap::{Parser, Subcommand}; use clap::{Parser, Subcommand};
use tycho_core::models::Chain; use tycho_common::models::Chain;
use tycho_execution::encoding::{ use tycho_execution::encoding::{
evm::encoder_builder::EVMEncoderBuilder, models::Solution, tycho_encoder::TychoEncoder, evm::encoder_builder::EVMEncoderBuilder, models::Solution, tycho_encoder::TychoEncoder,
}; };

View File

@@ -15,7 +15,7 @@ use tokio::{
runtime::{Handle, Runtime}, runtime::{Handle, Runtime},
task::block_in_place, task::block_in_place,
}; };
use tycho_core::Bytes; use tycho_common::Bytes;
use crate::encoding::{ use crate::encoding::{
errors::EncodingError, errors::EncodingError,
@@ -175,7 +175,7 @@ mod tests {
use alloy_primitives::Uint; use alloy_primitives::Uint;
use num_bigint::BigUint; use num_bigint::BigUint;
use tycho_core::models::Chain as TychoCoreChain; use tycho_common::models::Chain as TychoCoreChain;
use super::*; use super::*;

View File

@@ -1,4 +1,4 @@
use tycho_core::models::Chain; use tycho_common::models::Chain;
use crate::encoding::{ use crate::encoding::{
errors::EncodingError, errors::EncodingError,

View File

@@ -1,4 +1,4 @@
use tycho_core::Bytes; use tycho_common::Bytes;
use crate::encoding::{evm::constants::GROUPABLE_PROTOCOLS, models::Swap}; use crate::encoding::{evm::constants::GROUPABLE_PROTOCOLS, models::Swap};
@@ -74,7 +74,7 @@ mod tests {
use std::str::FromStr; use std::str::FromStr;
use alloy_primitives::hex; use alloy_primitives::hex;
use tycho_core::{models::protocol::ProtocolComponent, Bytes}; use tycho_common::{models::protocol::ProtocolComponent, Bytes};
use super::*; use super::*;
use crate::encoding::models::Swap; use crate::encoding::models::Swap;

View File

@@ -2,7 +2,7 @@ use std::{collections::HashSet, str::FromStr};
use alloy_primitives::{aliases::U24, U256, U8}; use alloy_primitives::{aliases::U24, U256, U8};
use alloy_sol_types::SolValue; use alloy_sol_types::SolValue;
use tycho_core::Bytes; use tycho_common::Bytes;
use crate::encoding::{ use crate::encoding::{
errors::EncodingError, errors::EncodingError,
@@ -80,7 +80,7 @@ pub struct SplitSwapStrategyEncoder {
impl SplitSwapStrategyEncoder { impl SplitSwapStrategyEncoder {
pub fn new( pub fn new(
blockchain: tycho_core::models::Chain, blockchain: tycho_common::models::Chain,
swap_encoder_registry: SwapEncoderRegistry, swap_encoder_registry: SwapEncoderRegistry,
swapper_pk: Option<String>, swapper_pk: Option<String>,
) -> Result<Self, EncodingError> { ) -> Result<Self, EncodingError> {
@@ -341,7 +341,7 @@ mod tests {
use alloy_primitives::hex; use alloy_primitives::hex;
use num_bigint::{BigInt, BigUint}; use num_bigint::{BigInt, BigUint};
use rstest::rstest; use rstest::rstest;
use tycho_core::{ use tycho_common::{
models::{protocol::ProtocolComponent, Chain as TychoCoreChain}, models::{protocol::ProtocolComponent, Chain as TychoCoreChain},
Bytes, Bytes,
}; };

View File

@@ -1,6 +1,6 @@
use std::collections::{HashMap, HashSet, VecDeque}; use std::collections::{HashMap, HashSet, VecDeque};
use tycho_core::Bytes; use tycho_common::Bytes;
use crate::encoding::{ use crate::encoding::{
errors::EncodingError, errors::EncodingError,
@@ -203,7 +203,7 @@ mod tests {
use num_bigint::BigUint; use num_bigint::BigUint;
use rstest::rstest; use rstest::rstest;
use tycho_core::{models::protocol::ProtocolComponent, Bytes}; use tycho_common::{models::protocol::ProtocolComponent, Bytes};
use super::*; use super::*;
use crate::encoding::models::Swap; use crate::encoding::models::Swap;

View File

@@ -19,7 +19,7 @@ impl SwapEncoderRegistry {
/// executors' addresses in the file at the given path. /// executors' addresses in the file at the given path.
pub fn new( pub fn new(
executors_file_path: Option<String>, executors_file_path: Option<String>,
blockchain: tycho_core::models::Chain, blockchain: tycho_common::models::Chain,
) -> Result<Self, EncodingError> { ) -> Result<Self, EncodingError> {
let chain = Chain::from(blockchain); let chain = Chain::from(blockchain);
let config_str = if let Some(ref path) = executors_file_path { let config_str = if let Some(ref path) = executors_file_path {

View File

@@ -2,7 +2,7 @@ use std::str::FromStr;
use alloy_primitives::{Address, Bytes as AlloyBytes}; use alloy_primitives::{Address, Bytes as AlloyBytes};
use alloy_sol_types::SolValue; use alloy_sol_types::SolValue;
use tycho_core::Bytes; use tycho_common::Bytes;
use crate::encoding::{ use crate::encoding::{
errors::EncodingError, errors::EncodingError,
@@ -264,7 +264,7 @@ mod tests {
use alloy::hex::encode; use alloy::hex::encode;
use num_bigint::BigInt; use num_bigint::BigInt;
use tycho_core::{models::protocol::ProtocolComponent, Bytes}; use tycho_common::{models::protocol::ProtocolComponent, Bytes};
use super::*; use super::*;

View File

@@ -1,7 +1,7 @@
use std::collections::HashSet; use std::collections::HashSet;
use num_bigint::BigUint; use num_bigint::BigUint;
use tycho_core::Bytes; use tycho_common::Bytes;
use crate::encoding::{ use crate::encoding::{
errors::EncodingError, errors::EncodingError,
@@ -34,7 +34,7 @@ impl Clone for EVMTychoEncoder {
impl EVMTychoEncoder { impl EVMTychoEncoder {
pub fn new( pub fn new(
chain: tycho_core::models::Chain, chain: tycho_common::models::Chain,
strategy_encoder: Box<dyn StrategyEncoder>, strategy_encoder: Box<dyn StrategyEncoder>,
) -> Result<Self, EncodingError> { ) -> Result<Self, EncodingError> {
let chain: Chain = Chain::from(chain); let chain: Chain = Chain::from(chain);
@@ -177,7 +177,7 @@ impl TychoEncoder for EVMTychoEncoder {
mod tests { mod tests {
use std::str::FromStr; use std::str::FromStr;
use tycho_core::models::{protocol::ProtocolComponent, Chain as TychoCoreChain}; use tycho_common::models::{protocol::ProtocolComponent, Chain as TychoCoreChain};
use super::*; use super::*;
use crate::encoding::{ use crate::encoding::{

View File

@@ -3,7 +3,7 @@ use std::{cmp::max, sync::Arc};
use alloy_primitives::{aliases::U24, keccak256, Address, FixedBytes, Keccak256, U256, U8}; use alloy_primitives::{aliases::U24, keccak256, Address, FixedBytes, Keccak256, U256, U8};
use num_bigint::BigUint; use num_bigint::BigUint;
use tokio::runtime::{Handle, Runtime}; use tokio::runtime::{Handle, Runtime};
use tycho_core::Bytes; use tycho_common::Bytes;
use crate::encoding::{ use crate::encoding::{
errors::EncodingError, errors::EncodingError,

View File

@@ -1,7 +1,7 @@
use hex; use hex;
use num_bigint::BigUint; use num_bigint::BigUint;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use tycho_core::{ use tycho_common::{
models::{protocol::ProtocolComponent, Chain as TychoCoreChain}, models::{protocol::ProtocolComponent, Chain as TychoCoreChain},
Bytes, Bytes,
}; };
@@ -130,6 +130,7 @@ impl From<TychoCoreChain> for Chain {
TychoCoreChain::Arbitrum => Chain { id: 42161, name: chain.to_string() }, TychoCoreChain::Arbitrum => Chain { id: 42161, name: chain.to_string() },
TychoCoreChain::Starknet => Chain { id: 0, name: chain.to_string() }, TychoCoreChain::Starknet => Chain { id: 0, name: chain.to_string() },
TychoCoreChain::Base => Chain { id: 8453, name: chain.to_string() }, TychoCoreChain::Base => Chain { id: 8453, name: chain.to_string() },
TychoCoreChain::Unichain => Chain { id: 130, name: chain.to_string() },
} }
} }
} }

View File

@@ -1,4 +1,4 @@
use tycho_core::Bytes; use tycho_common::Bytes;
use crate::encoding::{errors::EncodingError, models::Solution, swap_encoder::SwapEncoder}; use crate::encoding::{errors::EncodingError, models::Solution, swap_encoder::SwapEncoder};