Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: refactor magic strings #52

Merged
merged 2 commits into from
Dec 20, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"] }
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we want optional features to be on by default?

We should probably get rid of the root crate altogether, as it doesn't make sense to use it most of the time. It only makes configuring features harder.

Copy link
Member Author

@chris13524 chris13524 Dec 17, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just build wasn't building this feature/module so I wasn't able to test it and my IDE wasn't triggering on errors. So this seemed to fix that. I thought this affected CI as well, but looks like cargo build --workspace --all-features will check this (as CI is configured to).

Going to revert to avoid confusion as CI is already catching any potential issues.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure why we have the root crate like this, it doesn't seem like we use walletconnect_sdk anywhere. Maybe it's for the examples?


[dev-dependencies]
anyhow = "1"
Expand Down
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
Loading