Skip to content

Commit

Permalink
fix: bump alloy to latest (#83)
Browse files Browse the repository at this point in the history
  • Loading branch information
chris13524 authored Sep 20, 2024
1 parent d17f94b commit 51e984e
Show file tree
Hide file tree
Showing 7 changed files with 52 additions and 61 deletions.
23 changes: 3 additions & 20 deletions relay_rpc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -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"
Expand Down
10 changes: 7 additions & 3 deletions relay_rpc/src/auth/cacao.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -52,10 +52,14 @@ pub enum CacaoError {
Verification,

#[error("Internal EIP-1271 resolution error: {0}")]
Eip1271Internal(alloy_json_rpc::RpcError<alloy_transport::TransportErrorKind, Box<RawValue>>),
Eip1271Internal(
alloy::rpc::json_rpc::RpcError<alloy::transports::TransportErrorKind, Box<RawValue>>,
),

#[error("Internal EIP-6492 resolution error: {0}")]
Eip6492Internal(alloy_json_rpc::RpcError<alloy_transport::TransportErrorKind, Box<RawValue>>),
Eip6492Internal(
alloy::rpc::json_rpc::RpcError<alloy::transports::TransportErrorKind, Box<RawValue>>,
),
}

impl From<std::fmt::Error> for CacaoError {
Expand Down
32 changes: 16 additions & 16 deletions relay_rpc/src/auth/cacao/signature/eip1271.rs
Original file line number Diff line number Diff line change
@@ -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,
};

Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -81,7 +81,7 @@ mod test {
EIP1271_MOCK_CONTRACT,
},
},
alloy_primitives::address,
alloy::primitives::address,
k256::ecdsa::SigningKey,
sha3::{Digest, Keccak256},
};
Expand Down
4 changes: 2 additions & 2 deletions relay_rpc/src/auth/cacao/signature/eip191.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use {
super::CacaoError,
crate::auth::cacao::signature::strip_hex_prefix,
alloy_primitives::Address,
alloy::primitives::Address,
sha3::{Digest, Keccak256},
};

Expand Down Expand Up @@ -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,
};

Expand Down
36 changes: 19 additions & 17 deletions relay_rpc/src/auth/cacao/signature/eip6492.rs
Original file line number Diff line number Diff line change
@@ -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,
};

Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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,
};

Expand Down
2 changes: 1 addition & 1 deletion relay_rpc/src/auth/cacao/signature/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
6 changes: 4 additions & 2 deletions relay_rpc/src/auth/cacao/signature/test_helpers.rs
Original file line number Diff line number Diff line change
@@ -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,
Expand Down

0 comments on commit 51e984e

Please sign in to comment.