From 51e984e512de13aae634a3e49cd00072c1a6dd6a Mon Sep 17 00:00:00 2001 From: Chris Smith <1979423+chris13524@users.noreply.github.com> Date: Fri, 20 Sep 2024 10:20:02 -0700 Subject: [PATCH] fix: bump alloy to latest (#83) --- relay_rpc/Cargo.toml | 23 ++---------- relay_rpc/src/auth/cacao.rs | 10 ++++-- relay_rpc/src/auth/cacao/signature/eip1271.rs | 32 ++++++++--------- relay_rpc/src/auth/cacao/signature/eip191.rs | 4 +-- relay_rpc/src/auth/cacao/signature/eip6492.rs | 36 ++++++++++--------- relay_rpc/src/auth/cacao/signature/mod.rs | 2 +- .../src/auth/cacao/signature/test_helpers.rs | 6 ++-- 7 files changed, 52 insertions(+), 61 deletions(-) diff --git a/relay_rpc/Cargo.toml b/relay_rpc/Cargo.toml index c9ff0d7..c3206d1 100644 --- a/relay_rpc/Cargo.toml +++ b/relay_rpc/Cargo.toml @@ -8,16 +8,7 @@ license = "Apache-2.0" cacao = [ "dep:k256", "dep:sha3", - "dep:alloy-provider", - "dep:alloy-transport", - "dep:alloy-transport-http", - "dep:alloy-rpc-types", - "dep:alloy-json-rpc", - "dep:alloy-json-abi", - "dep:alloy-sol-types", - "dep:alloy-primitives", - "dep:alloy-node-bindings", - "dep:alloy-contract" + "dep:alloy" ] [dependencies] @@ -46,20 +37,12 @@ k256 = { version = "0.13", optional = true } sha3 = { version = "0.10", optional = true } sha2 = { version = "0.10.6" } url = "2" -alloy-provider = { git = "https://github.com/alloy-rs/alloy.git", rev = "d68a6b7", optional = true } -alloy-transport = { git = "https://github.com/alloy-rs/alloy.git", rev = "d68a6b7", optional = true } -alloy-transport-http = { git = "https://github.com/alloy-rs/alloy.git", rev = "d68a6b7", optional = true } -alloy-rpc-types = { git = "https://github.com/alloy-rs/alloy.git", rev = "d68a6b7", optional = true } -alloy-json-rpc = { git = "https://github.com/alloy-rs/alloy.git", rev = "d68a6b7", optional = true } -alloy-node-bindings = { git = "https://github.com/alloy-rs/alloy.git", rev = "d68a6b7", optional = true } -alloy-contract = { git = "https://github.com/alloy-rs/alloy.git", rev = "d68a6b7", optional = true } -alloy-json-abi = { version = "0.7.0", optional = true } -alloy-sol-types = { version = "0.7.0", optional = true } -alloy-primitives = { version = "0.7.0", optional = true } +alloy = { version = "0.3.6", optional = true, features = ["json-rpc", "provider-http", "contract", "rpc-types-eth"] } strum = { version = "0.26", features = ["strum_macros", "derive"] } [dev-dependencies] tokio = { version = "1.35.1", features = ["test-util", "macros"] } +alloy = { version = "0.3.6", features = ["node-bindings"] } [build-dependencies] serde_json = "1.0" diff --git a/relay_rpc/src/auth/cacao.rs b/relay_rpc/src/auth/cacao.rs index 179077f..470a74a 100644 --- a/relay_rpc/src/auth/cacao.rs +++ b/relay_rpc/src/auth/cacao.rs @@ -4,7 +4,7 @@ use { payload::Payload, signature::{get_rpc_url::GetRpcUrl, Signature}, }, - alloy_primitives::hex::FromHexError, + alloy::primitives::hex::FromHexError, core::fmt::Debug, serde::{Deserialize, Serialize}, serde_json::value::RawValue, @@ -52,10 +52,14 @@ pub enum CacaoError { Verification, #[error("Internal EIP-1271 resolution error: {0}")] - Eip1271Internal(alloy_json_rpc::RpcError>), + Eip1271Internal( + alloy::rpc::json_rpc::RpcError>, + ), #[error("Internal EIP-6492 resolution error: {0}")] - Eip6492Internal(alloy_json_rpc::RpcError>), + Eip6492Internal( + alloy::rpc::json_rpc::RpcError>, + ), } impl From for CacaoError { diff --git a/relay_rpc/src/auth/cacao/signature/eip1271.rs b/relay_rpc/src/auth/cacao/signature/eip1271.rs index 6deddf7..4e5f1c8 100644 --- a/relay_rpc/src/auth/cacao/signature/eip1271.rs +++ b/relay_rpc/src/auth/cacao/signature/eip1271.rs @@ -1,9 +1,12 @@ use { super::CacaoError, - alloy_primitives::Address, - alloy_provider::{network::Ethereum, Provider, ReqwestProvider}, - alloy_rpc_types::{TransactionInput, TransactionRequest}, - alloy_sol_types::{sol, SolCall}, + alloy::{ + primitives::Address, + providers::{network::Ethereum, Provider, ReqwestProvider}, + rpc::types::{TransactionInput, TransactionRequest}, + sol, + sol_types::SolCall, + }, url::Url, }; @@ -39,20 +42,17 @@ pub async fn verify_eip1271( .into(), )); - let result = provider - .call(&call_request, Default::default()) - .await - .map_err(|e| { - if let Some(error_response) = e.as_error_resp() { - if error_response.message.starts_with("execution reverted:") { - CacaoError::Verification - } else { - CacaoError::Eip1271Internal(e) - } + let result = provider.call(&call_request).await.map_err(|e| { + if let Some(error_response) = e.as_error_resp() { + if error_response.message.starts_with("execution reverted:") { + CacaoError::Verification } else { CacaoError::Eip1271Internal(e) } - })?; + } else { + CacaoError::Eip1271Internal(e) + } + })?; let magic = result.get(..4); if let Some(magic) = magic { @@ -81,7 +81,7 @@ mod test { EIP1271_MOCK_CONTRACT, }, }, - alloy_primitives::address, + alloy::primitives::address, k256::ecdsa::SigningKey, sha3::{Digest, Keccak256}, }; diff --git a/relay_rpc/src/auth/cacao/signature/eip191.rs b/relay_rpc/src/auth/cacao/signature/eip191.rs index 2287ef5..ba30394 100644 --- a/relay_rpc/src/auth/cacao/signature/eip191.rs +++ b/relay_rpc/src/auth/cacao/signature/eip191.rs @@ -1,7 +1,7 @@ use { super::CacaoError, crate::auth::cacao::signature::strip_hex_prefix, - alloy_primitives::Address, + alloy::primitives::Address, sha3::{Digest, Keccak256}, }; @@ -58,7 +58,7 @@ mod tests { eip191::verify_eip191, test_helpers::{message_hash_internal, sign_message}, }, - alloy_primitives::Address, + alloy::primitives::Address, k256::ecdsa::SigningKey, }; diff --git a/relay_rpc/src/auth/cacao/signature/eip6492.rs b/relay_rpc/src/auth/cacao/signature/eip6492.rs index 0fc5117..3a08b67 100644 --- a/relay_rpc/src/auth/cacao/signature/eip6492.rs +++ b/relay_rpc/src/auth/cacao/signature/eip6492.rs @@ -1,9 +1,12 @@ use { crate::auth::cacao::CacaoError, - alloy_primitives::Address, - alloy_provider::{network::Ethereum, Provider, ReqwestProvider}, - alloy_rpc_types::{TransactionInput, TransactionRequest}, - alloy_sol_types::{sol, SolConstructor}, + alloy::{ + primitives::Address, + providers::{network::Ethereum, Provider, ReqwestProvider}, + rpc::types::{TransactionInput, TransactionRequest}, + sol, + sol_types::SolConstructor, + }, url::Url, }; @@ -42,20 +45,17 @@ pub async fn verify_eip6492( let transaction_request = TransactionRequest::default().input(TransactionInput::new(bytes.into())); - let result = provider - .call(&transaction_request, Default::default()) - .await - .map_err(|e| { - if let Some(error_response) = e.as_error_resp() { - if error_response.message == "execution reverted" { - CacaoError::Verification - } else { - CacaoError::Eip6492Internal(e) - } + let result = provider.call(&transaction_request).await.map_err(|e| { + if let Some(error_response) = e.as_error_resp() { + if error_response.message == "execution reverted" { + CacaoError::Verification } else { CacaoError::Eip6492Internal(e) } - })?; + } else { + CacaoError::Eip6492Internal(e) + } + })?; let magic = result.first(); if let Some(magic) = magic { @@ -84,8 +84,10 @@ mod test { EIP1271_MOCK_CONTRACT, }, }, - alloy_primitives::{address, b256, Uint}, - alloy_sol_types::{SolCall, SolValue}, + alloy::{ + primitives::{address, b256, Uint}, + sol_types::{SolCall, SolValue}, + }, k256::ecdsa::SigningKey, }; diff --git a/relay_rpc/src/auth/cacao/signature/mod.rs b/relay_rpc/src/auth/cacao/signature/mod.rs index 4eb0ae1..2732460 100644 --- a/relay_rpc/src/auth/cacao/signature/mod.rs +++ b/relay_rpc/src/auth/cacao/signature/mod.rs @@ -6,7 +6,7 @@ use { get_rpc_url::GetRpcUrl, }, super::{Cacao, CacaoError}, - alloy_primitives::Address, + alloy::primitives::Address, serde::{Deserialize, Serialize}, sha3::{Digest, Keccak256}, std::str::FromStr, diff --git a/relay_rpc/src/auth/cacao/signature/test_helpers.rs b/relay_rpc/src/auth/cacao/signature/test_helpers.rs index f7f305c..4f54209 100644 --- a/relay_rpc/src/auth/cacao/signature/test_helpers.rs +++ b/relay_rpc/src/auth/cacao/signature/test_helpers.rs @@ -1,7 +1,9 @@ use { super::eip191::eip191_bytes, - alloy_node_bindings::{Anvil, AnvilInstance}, - alloy_primitives::Address, + alloy::{ + node_bindings::{Anvil, AnvilInstance}, + primitives::Address, + }, k256::ecdsa::SigningKey, regex::Regex, sha2::Digest,