Move address_to_string to ethereum::utils module
This commit is contained in:
parent
c0837bbf77
commit
0d6807e5a2
3 changed files with 9 additions and 8 deletions
|
@ -4,6 +4,7 @@ use siwe::Message;
|
|||
use web3::types::H160;
|
||||
|
||||
use crate::errors::ValidationError;
|
||||
use super::utils::address_to_string;
|
||||
|
||||
/// Verifies EIP-4361 signature and returns wallet address
|
||||
pub fn verify_eip4361_signature(
|
||||
|
@ -30,7 +31,7 @@ pub fn verify_eip4361_signature(
|
|||
return Err(ValidationError("message shouldn't have expiration time"));
|
||||
};
|
||||
// Return wallet address in lower case
|
||||
let wallet_address = format!("{:#x}", H160(message.address));
|
||||
let wallet_address = address_to_string(H160(message.address));
|
||||
Ok(wallet_address)
|
||||
}
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@ use web3::{
|
|||
contract::Contract,
|
||||
ethabi::RawLog,
|
||||
transports::Http,
|
||||
types::{Address, BlockId, BlockNumber, FilterBuilder, U256},
|
||||
types::{BlockId, BlockNumber, FilterBuilder, U256},
|
||||
};
|
||||
|
||||
use crate::config::BlockchainConfig;
|
||||
|
@ -25,12 +25,7 @@ use crate::models::users::queries::get_user_by_wallet_address;
|
|||
use crate::models::users::types::WALLET_CURRENCY_CODE;
|
||||
use super::errors::EthereumError;
|
||||
use super::signatures::{sign_contract_call, CallArgs, SignatureData};
|
||||
use super::utils::parse_address;
|
||||
|
||||
/// Converts address object to lowercase hex string
|
||||
fn address_to_string(address: Address) -> String {
|
||||
format!("{:#x}", address)
|
||||
}
|
||||
use super::utils::{address_to_string, parse_address};
|
||||
|
||||
fn u256_to_date(value: U256) -> Result<DateTime<Utc>, ConversionError> {
|
||||
let timestamp: i64 = value.try_into().map_err(|_| ConversionError)?;
|
||||
|
|
|
@ -45,6 +45,11 @@ pub fn parse_address(address: &str) -> Result<Address, AddressError> {
|
|||
Address::from_str(address).map_err(|_| AddressError)
|
||||
}
|
||||
|
||||
/// Converts address object to lowercase hex string
|
||||
pub fn address_to_string(address: Address) -> String {
|
||||
format!("{:#x}", address)
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
|
Loading…
Reference in a new issue