From f8b3b5fc17b0dd66eeeff0649587c2a42a952461 Mon Sep 17 00:00:00 2001 From: Amin Latifi Date: Mon, 11 Dec 2023 17:07:51 +0330 Subject: [PATCH] Save non-evm user wallet address capitalization --- src/repositories/userRepository.ts | 8 ++++++-- src/services/authorizationServices.ts | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/repositories/userRepository.ts b/src/repositories/userRepository.ts index 7e074598e..93c553b36 100644 --- a/src/repositories/userRepository.ts +++ b/src/repositories/userRepository.ts @@ -3,6 +3,7 @@ import { SegmentAnalyticsSingleton } from '../services/segment/segmentAnalyticsS import { Donation } from '../entities/donation'; import { Reaction } from '../entities/reaction'; import { PowerBoosting } from '../entities/powerBoosting'; +import { ethers } from 'ethers'; export const findAdminUserByEmail = async ( email: string, @@ -69,10 +70,13 @@ export const findAllUsers = async (params: { }; export const createUserWithPublicAddress = async ( - walletAddress: string, + _walletAddress: string, ): Promise => { + const walletAddress = ethers.utils.isAddress(_walletAddress) + ? _walletAddress.toLocaleLowerCase() + : _walletAddress; const user = await User.create({ - walletAddress: walletAddress.toLowerCase(), + walletAddress, loginType: 'wallet', segmentIdentified: true, }).save(); diff --git a/src/services/authorizationServices.ts b/src/services/authorizationServices.ts index 1f765ae82..49fac286d 100644 --- a/src/services/authorizationServices.ts +++ b/src/services/authorizationServices.ts @@ -109,7 +109,7 @@ export const validateAuthMicroserviceJwt = async ( }, ); - const userAddress = result.data.publicAddress.toLowerCase(); + const userAddress = result.data.publicAddress; user = await findUserByWalletAddress(userAddress); if (!user) {