From e734d7ade6ef8c103119fa4eb6d9908be605ef2e Mon Sep 17 00:00:00 2001 From: Edward-BXS Date: Sun, 29 Sep 2024 19:34:51 +0800 Subject: [PATCH 1/6] email opt --- .../CAAccount/IAppleZkProvider.cs | 2 + .../CAAccount/Provider/AppleZkProvider.cs | 15 ++++++ .../Verifier/VerifierAppService.cs | 10 +++- .../Verifier/VerifierServerClient.cs | 51 ++++++++++++++++++- 4 files changed, 75 insertions(+), 3 deletions(-) diff --git a/src/CAServer.Application.Contracts/CAAccount/IAppleZkProvider.cs b/src/CAServer.Application.Contracts/CAAccount/IAppleZkProvider.cs index 348bde96d..b89fb6d51 100644 --- a/src/CAServer.Application.Contracts/CAAccount/IAppleZkProvider.cs +++ b/src/CAServer.Application.Contracts/CAAccount/IAppleZkProvider.cs @@ -6,4 +6,6 @@ namespace CAServer.CAAccount; public interface IAppleZkProvider { public Task SaveGuardianUserBeforeZkLoginAsync(VerifiedZkLoginRequestDto requestDto); + + public Task GetAppleUserExtraInfo(string accessToken); } \ No newline at end of file diff --git a/src/CAServer.Application/CAAccount/Provider/AppleZkProvider.cs b/src/CAServer.Application/CAAccount/Provider/AppleZkProvider.cs index ecee3eea6..c318e3b21 100644 --- a/src/CAServer.Application/CAAccount/Provider/AppleZkProvider.cs +++ b/src/CAServer.Application/CAAccount/Provider/AppleZkProvider.cs @@ -202,4 +202,19 @@ private static AppleUserExtraInfo GetUserInfoFromToken(SecurityToken validatedTo return userInfo; } + + public async Task GetAppleUserExtraInfo(string accessToken) + { + SecurityToken securityToken; + try + { + securityToken = await ValidateTokenAsync(accessToken); + } + catch (Exception e) + { + _logger.LogError(e, "GetAppleUserExtraInfo ValidateTokenAsync failed"); + return null; + } + return GetUserInfoFromToken(securityToken); + } } \ No newline at end of file diff --git a/src/CAServer.Application/Verifier/VerifierAppService.cs b/src/CAServer.Application/Verifier/VerifierAppService.cs index 18053e171..48a2242e6 100644 --- a/src/CAServer.Application/Verifier/VerifierAppService.cs +++ b/src/CAServer.Application/Verifier/VerifierAppService.cs @@ -10,6 +10,7 @@ using AElf.Types; using CAServer.AccountValidator; using CAServer.AppleVerify; +using CAServer.CAAccount; using CAServer.CAAccount.Dtos; using CAServer.CAAccount.Provider; using CAServer.Cache; @@ -63,6 +64,7 @@ public class VerifierAppService : CAServerAppService, IVerifierAppService private readonly ICAAccountProvider _accountProvider; private readonly SendVerifierCodeRequestLimitOptions _sendVerifierCodeRequestLimitOption; private readonly IdentityUserManager _userManager; + private readonly IAppleZkProvider _appleZkProvider; private const string SendVerifierCodeInterfaceRequestCountCacheKey = "SendVerifierCodeInterfaceRequestCountCacheKey"; @@ -79,7 +81,8 @@ public VerifierAppService(IEnumerable accountValidator, IObje ICacheProvider cacheProvider, IContractProvider contractProvider, IHttpClientService httpClientService, IDistributedCache distributedCache, ICAAccountProvider accountProvider, - IdentityUserManager userManager) + IdentityUserManager userManager, + IAppleZkProvider appleZkProvider) { _accountValidator = accountValidator; _objectMapper = objectMapper; @@ -96,6 +99,7 @@ public VerifierAppService(IEnumerable accountValidator, IObje _distributedCache = distributedCache; _accountProvider = accountProvider; _userManager = userManager; + _appleZkProvider = appleZkProvider; } public async Task SendVerificationRequestAsync(SendVerificationRequestInput input) @@ -272,7 +276,9 @@ public async Task VerifyAppleTokenAsync(VerifyTokenReq { var userId = GetAppleUserId(requestDto.AccessToken); var hashInfo = await GetSaltAndHashAsync(userId); - await AppendSecondaryEmailInfo(requestDto, hashInfo.Item1, userId, GuardianIdentifierType.Apple); + var userExtraInfo = await _appleZkProvider.GetAppleUserExtraInfo(requestDto.AccessToken); + var guardianIdentifier = userExtraInfo == null || userExtraInfo.IsPrivateEmail ? string.Empty : userExtraInfo?.Email; + await AppendSecondaryEmailInfo(requestDto, hashInfo.Item1, guardianIdentifier, GuardianIdentifierType.Apple); var response = await _verifierServerClient.VerifyAppleTokenAsync(requestDto, hashInfo.Item1, hashInfo.Item2); if (!response.Success) diff --git a/src/CAServer.Application/Verifier/VerifierServerClient.cs b/src/CAServer.Application/Verifier/VerifierServerClient.cs index f55cc6203..421e481cb 100644 --- a/src/CAServer.Application/Verifier/VerifierServerClient.cs +++ b/src/CAServer.Application/Verifier/VerifierServerClient.cs @@ -14,6 +14,10 @@ using CAServer.Options; using CAServer.Security.Dtos; using CAServer.Settings; +using CAServer.Tokens; +using CAServer.Tokens.Cache; +using CAServer.Tokens.Dtos; +using CAServer.Tokens.Provider; using CAServer.Verifier.Dtos; using CAVerifierServer.Account; using Microsoft.Extensions.Logging; @@ -23,6 +27,7 @@ using Portkey.Contracts.CA; using Volo.Abp; using Volo.Abp.DependencyInjection; +using Volo.Abp.ObjectMapping; namespace CAServer.Verifier; @@ -36,13 +41,17 @@ public class VerifierServerClient : IDisposable, IVerifierServerClient, ISinglet private readonly ChainOptions _chainOptions; private readonly IIpInfoAppService _ipInfoAppService; private readonly IContractProvider _contractProvider; + private readonly ITokenProvider _tokenProvider; + private readonly ITokenCacheProvider _tokenCacheProvider; + private readonly IObjectMapper _objectMapper; public VerifierServerClient(IOptionsSnapshot adaptableVariableOptions, IGetVerifierServerProvider getVerifierServerProvider, ILogger logger, IHttpClientFactory httpClientFactory, IAccelerateManagerProvider accelerateManagerProvider, IOptions chainOptions, IIpInfoAppService ipInfoAppService, - IContractProvider contractProvider) + IContractProvider contractProvider, ITokenProvider tokenProvider, + ITokenCacheProvider tokenCacheProvider, IObjectMapper objectMapper) { _getVerifierServerProvider = getVerifierServerProvider; _logger = logger; @@ -52,6 +61,9 @@ public VerifierServerClient(IOptionsSnapshot adaptable _ipInfoAppService = ipInfoAppService; _chainOptions = chainOptions.Value; _contractProvider = contractProvider; + _tokenProvider = tokenProvider; + _tokenCacheProvider = tokenCacheProvider; + _objectMapper = objectMapper; } private bool _disposed; @@ -379,6 +391,12 @@ private async Task> GetResultAsync(VerifyTokenRequestDto SingleLimit = GetDetailDesc(input.OperationDetails, "singleLimit"), DailyLimit = GetDetailDesc(input.OperationDetails, "dailyLimit") }; + var handledByDecimal = await AmountHandler(input.ChainId, showOperationDetails.Amount, showOperationDetails.Token); + _logger.LogInformation("AmountHandler outer chainId:{0} symbol:{1} result:{2}", input.ChainId, showOperationDetails.Token, handledByDecimal); + if (!handledByDecimal.IsNullOrEmpty()) + { + showOperationDetails.Amount = handledByDecimal; + } var showOperationDetailsJson = JsonConvert.SerializeObject(showOperationDetails); var result = await GetResultFromVerifierAsync(url, input.AccessToken, identifierHash, salt, input.OperationType, @@ -388,6 +406,37 @@ private async Task> GetResultAsync(VerifyTokenRequestDto return result; } + private async Task AmountHandler(string chainId, string amount, string symbol) + { + if (amount.IsNullOrEmpty()) + { + return string.Empty; + } + + var tokenInfoDto = await GetTokenInfoAsync(chainId, symbol); + _logger.LogInformation("AmountHandler chainId:{0} symbol:{1} result:{2}", chainId, symbol, JsonConvert.SerializeObject(tokenInfoDto)); + return CalculationHelper.GetAmountInUsd(amount, tokenInfoDto.Decimals); + } + private async Task GetTokenInfoAsync(string chainId, string symbol) + { + IndexerTokens dto = null; + try + { + dto = await _tokenProvider.GetTokenInfosAsync(chainId, symbol.Trim().ToUpper(), string.Empty, 0, 1); + } + catch (Exception e) + { + _logger.LogError(e, "_tokenProvider GetTokenInfosAsync failed"); + } + var tokenInfo = dto?.TokenInfo?.FirstOrDefault(); + if (tokenInfo == null) + { + return await _tokenCacheProvider.GetTokenInfoAsync(chainId, symbol, TokenType.Token); + } + + return _objectMapper.Map(tokenInfo); + } + private async Task> GetResultFromVerifierAsync(string url, string accessToken, string identifierHash, string salt, OperationType verifierCodeOperationType, string chainId, string operationDetails, string secondaryEmail, string showOperationDetails) From 6de06b6f470a6cb3213e2b20102f1a44e637cf19 Mon Sep 17 00:00:00 2001 From: Edward-BXS Date: Sun, 29 Sep 2024 21:07:16 +0800 Subject: [PATCH 2/6] fix email bug --- .../CAAccount/Provider/AppleZkProvider.cs | 2 +- .../Verifier/VerifierServerClient.cs | 32 +++++++++++++------ 2 files changed, 23 insertions(+), 11 deletions(-) diff --git a/src/CAServer.Application/CAAccount/Provider/AppleZkProvider.cs b/src/CAServer.Application/CAAccount/Provider/AppleZkProvider.cs index c318e3b21..eac4681fa 100644 --- a/src/CAServer.Application/CAAccount/Provider/AppleZkProvider.cs +++ b/src/CAServer.Application/CAAccount/Provider/AppleZkProvider.cs @@ -73,7 +73,7 @@ public async Task SaveGuardianUserBeforeZkLoginAsync(VerifiedZkLoginRequ CaHash = requestDto.CaHash, TargetChainId = requestDto.TargetChainId }; - var guardianIdentifier = userInfo.Email.IsNullOrEmpty() ? userInfo.Id : userInfo.Email; + var guardianIdentifier = userInfo.IsPrivateEmail || userInfo.Email.IsNullOrEmpty() ? string.Empty : userInfo.Email; await _guardianUserProvider.AppendSecondaryEmailInfo(verifyTokenRequestDto, hashInfo.Item1, guardianIdentifier, GuardianIdentifierType.Apple); var response = await _verifierServerClient.VerifyAppleTokenAsync(verifyTokenRequestDto, hashInfo.Item1, hashInfo.Item2); diff --git a/src/CAServer.Application/Verifier/VerifierServerClient.cs b/src/CAServer.Application/Verifier/VerifierServerClient.cs index 421e481cb..e51e59ce0 100644 --- a/src/CAServer.Application/Verifier/VerifierServerClient.cs +++ b/src/CAServer.Application/Verifier/VerifierServerClient.cs @@ -391,12 +391,8 @@ private async Task> GetResultAsync(VerifyTokenRequestDto SingleLimit = GetDetailDesc(input.OperationDetails, "singleLimit"), DailyLimit = GetDetailDesc(input.OperationDetails, "dailyLimit") }; - var handledByDecimal = await AmountHandler(input.ChainId, showOperationDetails.Amount, showOperationDetails.Token); - _logger.LogInformation("AmountHandler outer chainId:{0} symbol:{1} result:{2}", input.ChainId, showOperationDetails.Token, handledByDecimal); - if (!handledByDecimal.IsNullOrEmpty()) - { - showOperationDetails.Amount = handledByDecimal; - } + await AmountHandler(showOperationDetails, input.ChainId, symbol:showOperationDetails.Token, + amount:showOperationDetails.Amount, singleLimit:showOperationDetails.SingleLimit, dailyLimit:showOperationDetails.DailyLimit); var showOperationDetailsJson = JsonConvert.SerializeObject(showOperationDetails); var result = await GetResultFromVerifierAsync(url, input.AccessToken, identifierHash, salt, input.OperationType, @@ -406,16 +402,32 @@ private async Task> GetResultAsync(VerifyTokenRequestDto return result; } - private async Task AmountHandler(string chainId, string amount, string symbol) + private async Task AmountHandler(ShowOperationDetailsDto showOperationDetailsDto, + string chainId, string symbol, string amount, string singleLimit, string dailyLimit) { - if (amount.IsNullOrEmpty()) + if (chainId.IsNullOrEmpty() || symbol.IsNullOrEmpty()) { - return string.Empty; + return ; } + if (amount.IsNullOrEmpty() && singleLimit.IsNullOrEmpty() && dailyLimit.IsNullOrEmpty()) + { + return; + } var tokenInfoDto = await GetTokenInfoAsync(chainId, symbol); _logger.LogInformation("AmountHandler chainId:{0} symbol:{1} result:{2}", chainId, symbol, JsonConvert.SerializeObject(tokenInfoDto)); - return CalculationHelper.GetAmountInUsd(amount, tokenInfoDto.Decimals); + if (!amount.IsNullOrEmpty()) + { + showOperationDetailsDto.Amount = CalculationHelper.GetAmountInUsd(amount, tokenInfoDto.Decimals); + } + if (!singleLimit.IsNullOrEmpty()) + { + showOperationDetailsDto.SingleLimit = CalculationHelper.GetAmountInUsd(singleLimit, tokenInfoDto.Decimals); + } + if (!dailyLimit.IsNullOrEmpty()) + { + showOperationDetailsDto.DailyLimit = CalculationHelper.GetAmountInUsd(dailyLimit, tokenInfoDto.Decimals); + } } private async Task GetTokenInfoAsync(string chainId, string symbol) { From 438c06dd1a514a7b32e82eb1447abedf3ba89ade Mon Sep 17 00:00:00 2001 From: Edward-BXS Date: Sun, 29 Sep 2024 21:22:16 +0800 Subject: [PATCH 3/6] fix2 --- src/CAServer.Application/CAAccount/Provider/AppleZkProvider.cs | 2 +- src/CAServer.Application/Verifier/VerifierAppService.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/CAServer.Application/CAAccount/Provider/AppleZkProvider.cs b/src/CAServer.Application/CAAccount/Provider/AppleZkProvider.cs index eac4681fa..bd8ee4bd7 100644 --- a/src/CAServer.Application/CAAccount/Provider/AppleZkProvider.cs +++ b/src/CAServer.Application/CAAccount/Provider/AppleZkProvider.cs @@ -73,7 +73,7 @@ public async Task SaveGuardianUserBeforeZkLoginAsync(VerifiedZkLoginRequ CaHash = requestDto.CaHash, TargetChainId = requestDto.TargetChainId }; - var guardianIdentifier = userInfo.IsPrivateEmail || userInfo.Email.IsNullOrEmpty() ? string.Empty : userInfo.Email; + var guardianIdentifier = userInfo.Email.IsNullOrEmpty() ? string.Empty : userInfo.Email; await _guardianUserProvider.AppendSecondaryEmailInfo(verifyTokenRequestDto, hashInfo.Item1, guardianIdentifier, GuardianIdentifierType.Apple); var response = await _verifierServerClient.VerifyAppleTokenAsync(verifyTokenRequestDto, hashInfo.Item1, hashInfo.Item2); diff --git a/src/CAServer.Application/Verifier/VerifierAppService.cs b/src/CAServer.Application/Verifier/VerifierAppService.cs index 48a2242e6..cf4066efd 100644 --- a/src/CAServer.Application/Verifier/VerifierAppService.cs +++ b/src/CAServer.Application/Verifier/VerifierAppService.cs @@ -277,7 +277,7 @@ public async Task VerifyAppleTokenAsync(VerifyTokenReq var userId = GetAppleUserId(requestDto.AccessToken); var hashInfo = await GetSaltAndHashAsync(userId); var userExtraInfo = await _appleZkProvider.GetAppleUserExtraInfo(requestDto.AccessToken); - var guardianIdentifier = userExtraInfo == null || userExtraInfo.IsPrivateEmail ? string.Empty : userExtraInfo?.Email; + var guardianIdentifier = userExtraInfo == null || userExtraInfo.Email.IsNullOrEmpty() ? string.Empty : userExtraInfo?.Email; await AppendSecondaryEmailInfo(requestDto, hashInfo.Item1, guardianIdentifier, GuardianIdentifierType.Apple); var response = await _verifierServerClient.VerifyAppleTokenAsync(requestDto, hashInfo.Item1, hashInfo.Item2); From 051ca67f0f96663d9c312904edaed6910c0e2831 Mon Sep 17 00:00:00 2001 From: Edward-BXS Date: Sun, 29 Sep 2024 22:49:32 +0800 Subject: [PATCH 4/6] fix3 --- .../Verifier/VerifierServerClient.cs | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/CAServer.Application/Verifier/VerifierServerClient.cs b/src/CAServer.Application/Verifier/VerifierServerClient.cs index e51e59ce0..f5969b980 100644 --- a/src/CAServer.Application/Verifier/VerifierServerClient.cs +++ b/src/CAServer.Application/Verifier/VerifierServerClient.cs @@ -391,8 +391,9 @@ private async Task> GetResultAsync(VerifyTokenRequestDto SingleLimit = GetDetailDesc(input.OperationDetails, "singleLimit"), DailyLimit = GetDetailDesc(input.OperationDetails, "dailyLimit") }; - await AmountHandler(showOperationDetails, input.ChainId, symbol:showOperationDetails.Token, + await AmountHandler(showOperationDetails, input.OperationType, chainId:input.ChainId, symbol:showOperationDetails.Token, amount:showOperationDetails.Amount, singleLimit:showOperationDetails.SingleLimit, dailyLimit:showOperationDetails.DailyLimit); + showOperationDetails.ToAddress = ToAddressHandler(showOperationDetails.ToAddress); var showOperationDetailsJson = JsonConvert.SerializeObject(showOperationDetails); var result = await GetResultFromVerifierAsync(url, input.AccessToken, identifierHash, salt, input.OperationType, @@ -402,10 +403,21 @@ await AmountHandler(showOperationDetails, input.ChainId, symbol:showOperationDet return result; } - private async Task AmountHandler(ShowOperationDetailsDto showOperationDetailsDto, + private string ToAddressHandler(string toAddress) + { + if (toAddress.IsNullOrEmpty()) + { + return string.Empty; + } + + var length = toAddress.Length / 2; + return toAddress.Substring(0, length) + "\n" + toAddress.Substring(length); + } + + private async Task AmountHandler(ShowOperationDetailsDto showOperationDetailsDto, OperationType operationType, string chainId, string symbol, string amount, string singleLimit, string dailyLimit) { - if (chainId.IsNullOrEmpty() || symbol.IsNullOrEmpty()) + if (chainId.IsNullOrEmpty() || symbol.IsNullOrEmpty() || OperationType.GuardianApproveTransfer.Equals(operationType)) { return ; } From 71115b030862944027a8b97739260a130c6a14a7 Mon Sep 17 00:00:00 2001 From: Edward-BXS Date: Mon, 30 Sep 2024 10:11:03 +0800 Subject: [PATCH 5/6] guardians account filter --- .../CAAccount/Provider/GoogleZkProvider.cs | 2 +- src/CAServer.Application/Verifier/VerifierAppService.cs | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/CAServer.Application/CAAccount/Provider/GoogleZkProvider.cs b/src/CAServer.Application/CAAccount/Provider/GoogleZkProvider.cs index 206483e0a..8afdea40a 100644 --- a/src/CAServer.Application/CAAccount/Provider/GoogleZkProvider.cs +++ b/src/CAServer.Application/CAAccount/Provider/GoogleZkProvider.cs @@ -63,7 +63,7 @@ public async Task SaveGuardianUserBeforeZkLoginAsync(VerifiedZkLoginRequ CaHash = requestDto.CaHash, TargetChainId = requestDto.TargetChainId }; - var guardianIdentifier = userInfo.Email.IsNullOrEmpty() ? userInfo.Id : userInfo.Email; + var guardianIdentifier = userInfo.Email.IsNullOrEmpty() ? string.Empty : userInfo.Email; await _guardianUserProvider.AppendSecondaryEmailInfo(verifyTokenRequestDto, hashInfo.Item1, guardianIdentifier, GuardianIdentifierType.Google); var response = await _verifierServerClient.VerifyGoogleTokenAsync(verifyTokenRequestDto, hashInfo.Item1, hashInfo.Item2); diff --git a/src/CAServer.Application/Verifier/VerifierAppService.cs b/src/CAServer.Application/Verifier/VerifierAppService.cs index cf4066efd..3affcf8ee 100644 --- a/src/CAServer.Application/Verifier/VerifierAppService.cs +++ b/src/CAServer.Application/Verifier/VerifierAppService.cs @@ -326,7 +326,7 @@ public async Task VerifyTwitterTokenAsync(VerifyTokenR await StatisticTwitterAsync(userId); var hashInfo = await GetSaltAndHashAsync(userId); - await AppendSecondaryEmailInfo(requestDto, hashInfo.Item1, userId, GuardianIdentifierType.Twitter); + await AppendSecondaryEmailInfo(requestDto, hashInfo.Item1, string.Empty, GuardianIdentifierType.Twitter); var response = await _verifierServerClient.VerifyTwitterTokenAsync(requestDto, hashInfo.Item1, hashInfo.Item2); if (!response.Success) @@ -462,7 +462,7 @@ public async Task VerifyTelegramTokenAsync(VerifyToken var userId = GetTelegramUserId(requestDto.AccessToken); _logger.LogDebug("TeleGram userid is {uid}",userId); var hashInfo = await GetSaltAndHashAsync(userId); - await AppendSecondaryEmailInfo(requestDto, hashInfo.Item1, userId, GuardianIdentifierType.Telegram); + await AppendSecondaryEmailInfo(requestDto, hashInfo.Item1, string.Empty, GuardianIdentifierType.Telegram); var response = await _verifierServerClient.VerifyTelegramTokenAsync(requestDto, hashInfo.Item1, hashInfo.Item2); if (!response.Success) @@ -508,7 +508,7 @@ public async Task VerifyFacebookTokenAsync(VerifyToken { var facebookUser = await GetFacebookUserInfoAsync(requestDto); var userSaltAndHash = await GetSaltAndHashAsync(facebookUser.Id); - var guardianIdentifier = facebookUser.Email.IsNullOrEmpty() ? facebookUser.Id : facebookUser.Email; + var guardianIdentifier = facebookUser.Email.IsNullOrEmpty() ? string.Empty : facebookUser.Email; await AppendSecondaryEmailInfo(requestDto, userSaltAndHash.Item1, guardianIdentifier, GuardianIdentifierType.Facebook); requestDto.SecondaryEmail = facebookUser.Email.IsNullOrEmpty() ? requestDto.SecondaryEmail : facebookUser.Email; var response = From 159154da0e65cd0d1676fc5e2d61b10d9ccf4884 Mon Sep 17 00:00:00 2001 From: Edward-BXS Date: Mon, 30 Sep 2024 10:46:46 +0800 Subject: [PATCH 6/6] remove useless logs --- .../Verifier/VerifierServerClient.cs | 24 ++++++------------- 1 file changed, 7 insertions(+), 17 deletions(-) diff --git a/src/CAServer.Application/Verifier/VerifierServerClient.cs b/src/CAServer.Application/Verifier/VerifierServerClient.cs index f5969b980..6e7106d4c 100644 --- a/src/CAServer.Application/Verifier/VerifierServerClient.cs +++ b/src/CAServer.Application/Verifier/VerifierServerClient.cs @@ -393,7 +393,7 @@ private async Task> GetResultAsync(VerifyTokenRequestDto }; await AmountHandler(showOperationDetails, input.OperationType, chainId:input.ChainId, symbol:showOperationDetails.Token, amount:showOperationDetails.Amount, singleLimit:showOperationDetails.SingleLimit, dailyLimit:showOperationDetails.DailyLimit); - showOperationDetails.ToAddress = ToAddressHandler(showOperationDetails.ToAddress); + ToAddressHandler(showOperationDetails, showOperationDetails.ToAddress); var showOperationDetailsJson = JsonConvert.SerializeObject(showOperationDetails); var result = await GetResultFromVerifierAsync(url, input.AccessToken, identifierHash, salt, input.OperationType, @@ -403,15 +403,15 @@ await AmountHandler(showOperationDetails, input.OperationType, chainId:input.Cha return result; } - private string ToAddressHandler(string toAddress) + private static void ToAddressHandler(ShowOperationDetailsDto showOperationDetails, string toAddress) { if (toAddress.IsNullOrEmpty()) { - return string.Empty; + return ; } var length = toAddress.Length / 2; - return toAddress.Substring(0, length) + "\n" + toAddress.Substring(length); + showOperationDetails.ToAddress = string.Concat(toAddress.AsSpan(0, length), "\n", toAddress.AsSpan(length)); } private async Task AmountHandler(ShowOperationDetailsDto showOperationDetailsDto, OperationType operationType, @@ -427,19 +427,9 @@ private async Task AmountHandler(ShowOperationDetailsDto showOperationDetailsDto return; } var tokenInfoDto = await GetTokenInfoAsync(chainId, symbol); - _logger.LogInformation("AmountHandler chainId:{0} symbol:{1} result:{2}", chainId, symbol, JsonConvert.SerializeObject(tokenInfoDto)); - if (!amount.IsNullOrEmpty()) - { - showOperationDetailsDto.Amount = CalculationHelper.GetAmountInUsd(amount, tokenInfoDto.Decimals); - } - if (!singleLimit.IsNullOrEmpty()) - { - showOperationDetailsDto.SingleLimit = CalculationHelper.GetAmountInUsd(singleLimit, tokenInfoDto.Decimals); - } - if (!dailyLimit.IsNullOrEmpty()) - { - showOperationDetailsDto.DailyLimit = CalculationHelper.GetAmountInUsd(dailyLimit, tokenInfoDto.Decimals); - } + showOperationDetailsDto.Amount = CalculationHelper.GetAmountInUsd(amount, tokenInfoDto.Decimals); + showOperationDetailsDto.SingleLimit = CalculationHelper.GetAmountInUsd(singleLimit, tokenInfoDto.Decimals); + showOperationDetailsDto.DailyLimit = CalculationHelper.GetAmountInUsd(dailyLimit, tokenInfoDto.Decimals); } private async Task GetTokenInfoAsync(string chainId, string symbol) {