feat: Upgrade alloy to "1.0.6"
Took 18 minutes
This commit is contained in:
1298
Cargo.lock
generated
1298
Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
10
Cargo.toml
10
Cargo.toml
@@ -28,19 +28,17 @@ thiserror = "1.0.69"
|
||||
tokio = { version = "1.38.0", features = ["full"] }
|
||||
chrono = "0.4.39"
|
||||
clap = { version = "4.5.3", features = ["derive"] }
|
||||
|
||||
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-primitives = { version = "0.8.9", optional = true }
|
||||
tycho-common = ">0.66.4"
|
||||
once_cell = "1.20.2"
|
||||
tycho-common = ">0.66.4"
|
||||
|
||||
alloy = { version = "1.0.6", features = ["providers", "rpc-types-eth", "eip712", "signer-local", "node-bindings"], optional = true }
|
||||
|
||||
[dev-dependencies]
|
||||
rstest = "0.24.0"
|
||||
|
||||
[features]
|
||||
default = ["evm"]
|
||||
evm = ["alloy", "alloy-sol-types", "alloy-primitives"]
|
||||
evm = ["alloy"]
|
||||
fork-tests = []
|
||||
|
||||
[profile.bench]
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use std::io::{self, Read};
|
||||
|
||||
use alloy_sol_types::SolValue;
|
||||
use alloy::sol_types::SolValue;
|
||||
use clap::{Parser, Subcommand};
|
||||
use tycho_common::{hex_bytes::Bytes, models::Chain};
|
||||
use tycho_execution::encoding::{
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
use std::{str::FromStr, sync::Arc};
|
||||
|
||||
use alloy::{
|
||||
core::sol,
|
||||
primitives::{aliases::U48, Address, Bytes as AlloyBytes, TxKind, U160, U256},
|
||||
providers::{Provider, RootProvider},
|
||||
providers::Provider,
|
||||
rpc::types::{TransactionInput, TransactionRequest},
|
||||
transports::BoxTransport,
|
||||
sol_types::SolValue,
|
||||
};
|
||||
use alloy_sol_types::{sol, SolValue};
|
||||
use chrono::Utc;
|
||||
use num_bigint::BigUint;
|
||||
use tokio::{
|
||||
@@ -19,7 +19,7 @@ use crate::encoding::{
|
||||
errors::EncodingError,
|
||||
evm::{
|
||||
encoding_utils::encode_input,
|
||||
utils::{biguint_to_u256, bytes_to_address, get_client, get_runtime},
|
||||
utils::{biguint_to_u256, bytes_to_address, get_client, get_runtime, EVMProvider},
|
||||
},
|
||||
models,
|
||||
};
|
||||
@@ -29,7 +29,7 @@ use crate::encoding::{
|
||||
#[derive(Clone)]
|
||||
pub struct Permit2 {
|
||||
address: Address,
|
||||
client: Arc<RootProvider<BoxTransport>>,
|
||||
client: EVMProvider,
|
||||
runtime_handle: Handle,
|
||||
// Store the runtime to prevent it from being dropped before use.
|
||||
// This is required since tycho-execution does not have a pre-existing runtime.
|
||||
@@ -132,16 +132,15 @@ impl Permit2 {
|
||||
|
||||
let output = block_in_place(|| {
|
||||
self.runtime_handle
|
||||
.block_on(async { self.client.call(&tx).await })
|
||||
.block_on(async { self.client.call(tx).await })
|
||||
});
|
||||
match output {
|
||||
Ok(response) => {
|
||||
let allowance: Allowance =
|
||||
Allowance::abi_decode(&response, true).map_err(|_| {
|
||||
EncodingError::FatalError(
|
||||
"Failed to decode response for permit2 allowance".to_string(),
|
||||
)
|
||||
})?;
|
||||
let allowance: Allowance = Allowance::abi_decode(&response).map_err(|_| {
|
||||
EncodingError::FatalError(
|
||||
"Failed to decode response for permit2 allowance".to_string(),
|
||||
)
|
||||
})?;
|
||||
Ok(allowance)
|
||||
}
|
||||
Err(err) => Err(EncodingError::RecoverableError(format!(
|
||||
@@ -183,8 +182,10 @@ impl Permit2 {
|
||||
mod tests {
|
||||
use std::str::FromStr;
|
||||
|
||||
use alloy::signers::local::PrivateKeySigner;
|
||||
use alloy_primitives::{Uint, B256};
|
||||
use alloy::{
|
||||
primitives::{Uint, B256},
|
||||
signers::local::PrivateKeySigner,
|
||||
};
|
||||
use num_bigint::BigUint;
|
||||
use tycho_common::models::Chain as TychoCommonChain;
|
||||
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
use std::sync::Arc;
|
||||
|
||||
use alloy::{
|
||||
providers::{Provider, RootProvider},
|
||||
primitives::{Address, Bytes, TxKind, U256},
|
||||
providers::Provider,
|
||||
rpc::types::{TransactionInput, TransactionRequest},
|
||||
transports::BoxTransport,
|
||||
sol_types::SolValue,
|
||||
};
|
||||
use alloy_primitives::{Address, Bytes, TxKind, U256};
|
||||
use alloy_sol_types::SolValue;
|
||||
use tokio::{
|
||||
runtime::{Handle, Runtime},
|
||||
task::block_in_place,
|
||||
@@ -16,13 +15,13 @@ use crate::encoding::{
|
||||
errors::EncodingError,
|
||||
evm::{
|
||||
encoding_utils::encode_input,
|
||||
utils::{get_client, get_runtime},
|
||||
utils::{get_client, get_runtime, EVMProvider},
|
||||
},
|
||||
};
|
||||
|
||||
/// A manager for checking if an approval is needed for interacting with a certain spender.
|
||||
pub struct ProtocolApprovalsManager {
|
||||
client: Arc<RootProvider<BoxTransport>>,
|
||||
client: EVMProvider,
|
||||
runtime_handle: Handle,
|
||||
// Store the runtime to prevent it from being dropped before use.
|
||||
// This is required since tycho-execution does not have a pre-existing runtime.
|
||||
@@ -56,11 +55,11 @@ impl ProtocolApprovalsManager {
|
||||
|
||||
let output = block_in_place(|| {
|
||||
self.runtime_handle
|
||||
.block_on(async { self.client.call(&tx).await })
|
||||
.block_on(async { self.client.call(tx).await })
|
||||
});
|
||||
match output {
|
||||
Ok(response) => {
|
||||
let allowance: U256 = U256::abi_decode(&response, true).map_err(|_| {
|
||||
let allowance: U256 = U256::abi_decode(&response).map_err(|_| {
|
||||
EncodingError::FatalError("Failed to decode response for allowance".to_string())
|
||||
})?;
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
use std::{collections::HashMap, str::FromStr};
|
||||
|
||||
use alloy::signers::local::PrivateKeySigner;
|
||||
use alloy_primitives::B256;
|
||||
use alloy::{primitives::B256, signers::local::PrivateKeySigner};
|
||||
use tycho_common::{models::Chain as TychoCommonChain, Bytes};
|
||||
|
||||
use crate::encoding::{
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
use std::str::FromStr;
|
||||
|
||||
use alloy::{
|
||||
primitives::U256,
|
||||
primitives::{Address, Keccak256, U256},
|
||||
signers::{local::PrivateKeySigner, Signature, SignerSync},
|
||||
sol_types::{eip712_domain, SolStruct, SolValue},
|
||||
};
|
||||
use alloy_primitives::{Address, Keccak256};
|
||||
use alloy_sol_types::{eip712_domain, SolStruct, SolValue};
|
||||
use num_bigint::BigUint;
|
||||
use tycho_common::Bytes;
|
||||
|
||||
|
||||
@@ -73,7 +73,7 @@ pub fn group_swaps(swaps: Vec<Swap>) -> Vec<SwapGroup> {
|
||||
mod tests {
|
||||
use std::str::FromStr;
|
||||
|
||||
use alloy_primitives::hex;
|
||||
use alloy::primitives::hex;
|
||||
use tycho_common::{models::protocol::ProtocolComponent, Bytes};
|
||||
|
||||
use super::*;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use std::{collections::HashSet, str::FromStr};
|
||||
|
||||
use alloy_primitives::{aliases::U24, U8};
|
||||
use alloy::primitives::{aliases::U24, U8};
|
||||
use tycho_common::Bytes;
|
||||
|
||||
use crate::encoding::{
|
||||
@@ -510,8 +510,7 @@ impl StrategyEncoder for SplitSwapStrategyEncoder {
|
||||
mod tests {
|
||||
use std::{collections::HashMap, str::FromStr};
|
||||
|
||||
use alloy::hex::encode;
|
||||
use alloy_primitives::hex;
|
||||
use alloy::{hex::encode, primitives::hex};
|
||||
use num_bigint::{BigInt, BigUint};
|
||||
use tycho_common::{
|
||||
models::{protocol::ProtocolComponent, Chain as TychoCommonChain},
|
||||
|
||||
@@ -111,7 +111,7 @@ impl TransferOptimization {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use alloy_primitives::hex;
|
||||
use alloy::primitives::hex;
|
||||
use rstest::rstest;
|
||||
use tycho_common::models::protocol::ProtocolComponent;
|
||||
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
use std::{collections::HashMap, str::FromStr};
|
||||
|
||||
use alloy_primitives::{Address, Bytes as AlloyBytes, U8};
|
||||
use alloy_sol_types::SolValue;
|
||||
use alloy::{
|
||||
primitives::{Address, Bytes as AlloyBytes, U8},
|
||||
sol_types::SolValue,
|
||||
};
|
||||
use serde_json::from_str;
|
||||
use tycho_common::Bytes;
|
||||
|
||||
|
||||
@@ -1221,9 +1221,12 @@ mod tests {
|
||||
mod integration {
|
||||
use std::{collections::HashMap, str::FromStr};
|
||||
|
||||
use alloy::{hex::encode, signers::local::PrivateKeySigner};
|
||||
use alloy_primitives::{hex, Address, B256, U256};
|
||||
use alloy_sol_types::SolValue;
|
||||
use alloy::{
|
||||
hex::encode,
|
||||
primitives::{hex, Address, B256, U256},
|
||||
signers::local::PrivateKeySigner,
|
||||
sol_types::SolValue,
|
||||
};
|
||||
use num_bigint::{BigInt, BigUint};
|
||||
use tycho_common::{models::protocol::ProtocolComponent, Bytes};
|
||||
|
||||
|
||||
@@ -6,11 +6,13 @@ use std::{
|
||||
};
|
||||
|
||||
use alloy::{
|
||||
providers::{ProviderBuilder, RootProvider},
|
||||
transports::BoxTransport,
|
||||
primitives::{aliases::U24, Address, U256, U8},
|
||||
providers::{
|
||||
fillers::{BlobGasFiller, ChainIdFiller, FillProvider, GasFiller, JoinFill, NonceFiller},
|
||||
ProviderBuilder, RootProvider,
|
||||
},
|
||||
sol_types::SolValue,
|
||||
};
|
||||
use alloy_primitives::{aliases::U24, Address, U256, U8};
|
||||
use alloy_sol_types::SolValue;
|
||||
use num_bigint::BigUint;
|
||||
use once_cell::sync::Lazy;
|
||||
use tokio::runtime::{Handle, Runtime};
|
||||
@@ -88,13 +90,23 @@ pub fn get_runtime() -> Result<(Handle, Option<Arc<Runtime>>), EncodingError> {
|
||||
}
|
||||
}
|
||||
|
||||
pub type EVMProvider = Arc<
|
||||
FillProvider<
|
||||
JoinFill<
|
||||
alloy::providers::Identity,
|
||||
JoinFill<GasFiller, JoinFill<BlobGasFiller, JoinFill<NonceFiller, ChainIdFiller>>>,
|
||||
>,
|
||||
RootProvider,
|
||||
>,
|
||||
>;
|
||||
|
||||
/// Gets the client used for interacting with the EVM-compatible network.
|
||||
pub async fn get_client() -> Result<Arc<RootProvider<BoxTransport>>, EncodingError> {
|
||||
pub async fn get_client() -> Result<EVMProvider, EncodingError> {
|
||||
dotenv::dotenv().ok();
|
||||
let eth_rpc_url = env::var("RPC_URL")
|
||||
.map_err(|_| EncodingError::FatalError("Missing RPC_URL in environment".to_string()))?;
|
||||
let client = ProviderBuilder::new()
|
||||
.on_builtin(ð_rpc_url)
|
||||
.connect(ð_rpc_url)
|
||||
.await
|
||||
.map_err(|_| EncodingError::FatalError("Failed to build provider".to_string()))?;
|
||||
Ok(Arc::new(client))
|
||||
|
||||
Reference in New Issue
Block a user