Skip to content

Commit

Permalink
fix: lowercase addresses
Browse files Browse the repository at this point in the history
  • Loading branch information
Elyniss committed Feb 9, 2024
1 parent cf06689 commit 21da085
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ build = "build.rs"

[dependencies]
wc = { git = "https://github.com/WalletConnect/utils-rs.git", tag = "v0.7.0", features = ["geoip", "geoblock"] }
relay_rpc = { git = "https://github.com/WalletConnect/WalletConnectRust.git", tag = "v0.26.0", features = ["cacao"] }
relay_rpc = { git = "https://github.com/WalletConnect/WalletConnectRust.git", tag = "v0.26.1", features = ["cacao"] }

aws-config = "0.56"
aws-sdk-s3 = "0.31"
Expand Down
36 changes: 32 additions & 4 deletions src/stores/keys.rs
Original file line number Diff line number Diff line change
Expand Up @@ -180,10 +180,38 @@ impl KeysPersistentStorage for MongoPersistentStorage {

match MongoKeys::find_one_and_update(&self.db, filter, update, None).await? {
Some(_) => Ok(()),
None => Err(StoreError::NotFound(
"Account".to_string(),
account.to_string(),
)),
None => {

// TODO: This is a temporary fix to handle the case where the account is not found becuase we lowercased it
return if(!account.starts_with("eip155")){
Err(StoreError::NotFound(
"Account".to_string(),
account.to_string(),
))
} else {

let lowercase_account = account.to_lowercase();
let filter = doc! {
"account": &lowercase_account,
};

let update = doc! {
"$pull": {
"identities" : {
"identity_key": &identity_key,
}
}
};

match MongoKeys::find_one_and_update(&self.db, filter, update, None).await? {
Some(_) => Ok(()),
None => Err(StoreError::NotFound(
"Account".to_string(),
lowercase_account.to_string(),
)),
}
}
}
}
}

Expand Down

0 comments on commit 21da085

Please sign in to comment.