Add Monero to currencies enum
This commit is contained in:
parent
ea4d15da48
commit
8df8fd3c8c
2 changed files with 6 additions and 2 deletions
|
@ -398,10 +398,9 @@ pub async fn search_profile_by_did(
|
|||
let rows = if let Some(currency) = did.currency() {
|
||||
// If currency is Ethereum,
|
||||
// search over extra fields must be case insensitive.
|
||||
#[allow(unreachable_patterns)]
|
||||
let value_op = match currency {
|
||||
Currency::Ethereum => "ILIKE",
|
||||
_ => "LIKE",
|
||||
Currency::Monero => "LIKE",
|
||||
};
|
||||
// This query does not scan user_account.wallet_address because
|
||||
// login addresses are private.
|
||||
|
|
|
@ -8,12 +8,14 @@ use super::caip2::ChainId;
|
|||
#[derive(Debug, PartialEq)]
|
||||
pub enum Currency {
|
||||
Ethereum,
|
||||
Monero,
|
||||
}
|
||||
|
||||
impl Currency {
|
||||
fn code(&self) -> String {
|
||||
match self {
|
||||
Self::Ethereum => "ETH",
|
||||
Self::Monero => "XMR",
|
||||
}.to_string()
|
||||
}
|
||||
|
||||
|
@ -29,6 +31,7 @@ impl Currency {
|
|||
pub fn normalize_address(&self, address: &str) -> String {
|
||||
match self {
|
||||
Self::Ethereum => address.to_lowercase(),
|
||||
Self::Monero => address.to_string(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -37,6 +40,7 @@ impl From<&Currency> for ChainId {
|
|||
fn from(value: &Currency) -> Self {
|
||||
let (namespace, reference) = match value {
|
||||
Currency::Ethereum => ("eip155", "1"),
|
||||
Currency::Monero => unimplemented!(),
|
||||
};
|
||||
Self {
|
||||
namespace: namespace.to_string(),
|
||||
|
@ -72,6 +76,7 @@ pub fn validate_wallet_address(
|
|||
return Err(ValidationError("address is not lowercase"));
|
||||
};
|
||||
},
|
||||
Currency::Monero => (), // no validation
|
||||
};
|
||||
Ok(())
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue