From 9ccce259b9d978db762021e0d85d15875cd0a335 Mon Sep 17 00:00:00 2001 From: Chris Smith Date: Sun, 17 Dec 2023 09:28:43 +0900 Subject: [PATCH 1/2] chore: refactor magic strings --- Cargo.toml | 2 +- relay_rpc/src/auth/cacao/header.rs | 4 +++- relay_rpc/src/auth/cacao/signature.rs | 4 +++- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 8b29593..d46528f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -20,7 +20,7 @@ rpc = ["dep:relay_rpc"] [dependencies] relay_client = { path = "./relay_client", optional = true } -relay_rpc = { path = "./relay_rpc", optional = true } +relay_rpc = { path = "./relay_rpc", optional = true, features = ["cacao"] } [dev-dependencies] anyhow = "1" diff --git a/relay_rpc/src/auth/cacao/header.rs b/relay_rpc/src/auth/cacao/header.rs index 4389d5a..fb9823b 100644 --- a/relay_rpc/src/auth/cacao/header.rs +++ b/relay_rpc/src/auth/cacao/header.rs @@ -3,6 +3,8 @@ use { serde::{Deserialize, Serialize}, }; +pub const EIP4361: &str = "eip4361"; + #[derive(Clone, Debug, PartialEq, Eq, Deserialize, Serialize, Hash)] pub struct Header { pub t: String, @@ -11,7 +13,7 @@ pub struct Header { impl Header { pub fn validate(&self) -> Result<(), CacaoError> { match self.t.as_str() { - "eip4361" => Ok(()), + EIP4361 => Ok(()), _ => Err(CacaoError::Header), } } diff --git a/relay_rpc/src/auth/cacao/signature.rs b/relay_rpc/src/auth/cacao/signature.rs index 2854ad6..90aad4f 100644 --- a/relay_rpc/src/auth/cacao/signature.rs +++ b/relay_rpc/src/auth/cacao/signature.rs @@ -3,6 +3,8 @@ use { serde::{Deserialize, Serialize}, }; +pub const EIP191: &str = "eip191"; + #[derive(Clone, Debug, PartialEq, Eq, Deserialize, Serialize, Hash)] pub struct Signature { pub t: String, @@ -12,7 +14,7 @@ pub struct Signature { impl Signature { pub fn verify(&self, cacao: &Cacao) -> Result { match self.t.as_str() { - "eip191" => Eip191.verify(&cacao.s.s, &cacao.p.address()?, &cacao.siwe_message()?), + EIP191 => Eip191.verify(&cacao.s.s, &cacao.p.address()?, &cacao.siwe_message()?), // "eip1271" => Eip1271.verify(), TODO: How to accces our RPC? _ => Err(CacaoError::UnsupportedSignature), } From ca207d140ddb631bfc674bc8603eaaa3996a4605 Mon Sep 17 00:00:00 2001 From: Chris Smith Date: Sun, 17 Dec 2023 20:35:17 +0900 Subject: [PATCH 2/2] chore: revert feature add --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index d46528f..8b29593 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -20,7 +20,7 @@ rpc = ["dep:relay_rpc"] [dependencies] relay_client = { path = "./relay_client", optional = true } -relay_rpc = { path = "./relay_rpc", optional = true, features = ["cacao"] } +relay_rpc = { path = "./relay_rpc", optional = true } [dev-dependencies] anyhow = "1"