Skip to content

Commit

Permalink
chore: refactor magic strings (#52)
Browse files Browse the repository at this point in the history
  • Loading branch information
chris13524 authored Dec 20, 2023
1 parent 9957258 commit 0e8b36a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 3 additions & 1 deletion relay_rpc/src/auth/cacao/header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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),
}
}
Expand Down
4 changes: 3 additions & 1 deletion relay_rpc/src/auth/cacao/signature.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -12,7 +14,7 @@ pub struct Signature {
impl Signature {
pub fn verify(&self, cacao: &Cacao) -> Result<bool, CacaoError> {
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),
}
Expand Down

0 comments on commit 0e8b36a

Please sign in to comment.