Skip to content

Commit

Permalink
chore: fix CI
Browse files Browse the repository at this point in the history
  • Loading branch information
chris13524 committed Sep 19, 2024
1 parent e21b18d commit 97f0807
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 27 deletions.
1 change: 1 addition & 0 deletions relay_rpc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ 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
8 changes: 6 additions & 2 deletions relay_rpc/src/auth/cacao.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,14 @@ pub enum CacaoError {
Verification,

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

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

impl From<std::fmt::Error> for CacaoError {
Expand Down
30 changes: 15 additions & 15 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::providers::{network::Ethereum, Provider, ReqwestProvider},
alloy::rpc::types::{TransactionInput, TransactionRequest},
alloy::{sol, sol_types::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)
.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
2 changes: 1 addition & 1 deletion relay_rpc/src/auth/cacao/signature/eip191.rs
Original file line number Diff line number Diff line change
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
23 changes: 16 additions & 7 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::providers::{network::Ethereum, Provider, ReqwestProvider},
alloy::rpc::types::{TransactionInput, TransactionRequest},
alloy::{sol, sol_types::SolConstructor},
alloy::{
primitives::Address,
providers::{network::Ethereum, Provider, ReqwestProvider},
rpc::types::{TransactionInput, TransactionRequest},
sol,
sol_types::SolConstructor,
},
url::Url,
};

Expand Down Expand Up @@ -73,12 +76,18 @@ mod test {
crate::auth::cacao::signature::{
strip_hex_prefix,
test_helpers::{
deploy_contract, message_hash, sign_message, spawn_anvil, CREATE2_CONTRACT,
deploy_contract,
message_hash,
sign_message,
spawn_anvil,
CREATE2_CONTRACT,
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
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 97f0807

Please sign in to comment.