Skip to content

Commit 0e8b36a

Browse files
authored
chore: refactor magic strings (#52)
1 parent 9957258 commit 0e8b36a

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

relay_rpc/src/auth/cacao/header.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ use {
33
serde::{Deserialize, Serialize},
44
};
55

6+
pub const EIP4361: &str = "eip4361";
7+
68
#[derive(Clone, Debug, PartialEq, Eq, Deserialize, Serialize, Hash)]
79
pub struct Header {
810
pub t: String,
@@ -11,7 +13,7 @@ pub struct Header {
1113
impl Header {
1214
pub fn validate(&self) -> Result<(), CacaoError> {
1315
match self.t.as_str() {
14-
"eip4361" => Ok(()),
16+
EIP4361 => Ok(()),
1517
_ => Err(CacaoError::Header),
1618
}
1719
}

relay_rpc/src/auth/cacao/signature.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ use {
33
serde::{Deserialize, Serialize},
44
};
55

6+
pub const EIP191: &str = "eip191";
7+
68
#[derive(Clone, Debug, PartialEq, Eq, Deserialize, Serialize, Hash)]
79
pub struct Signature {
810
pub t: String,
@@ -12,7 +14,7 @@ pub struct Signature {
1214
impl Signature {
1315
pub fn verify(&self, cacao: &Cacao) -> Result<bool, CacaoError> {
1416
match self.t.as_str() {
15-
"eip191" => Eip191.verify(&cacao.s.s, &cacao.p.address()?, &cacao.siwe_message()?),
17+
EIP191 => Eip191.verify(&cacao.s.s, &cacao.p.address()?, &cacao.siwe_message()?),
1618
// "eip1271" => Eip1271.verify(), TODO: How to accces our RPC?
1719
_ => Err(CacaoError::UnsupportedSignature),
1820
}

0 commit comments

Comments
 (0)