private async Task HandleWalletUnlinkedAsync(string[] topics, string data) { var publicAccountUnlinkedDto = _blockchainEventDecoder.DecodePublicAccountUnlinkedEvent(topics, data); var linkRequest = await _requestsRepository.GetByPrivateAddressAsync(publicAccountUnlinkedDto.PrivateAddress); if (linkRequest != null) { await _pushNotificationsPublisher.PublishWalletUnlinkingSuccessfulAsync(linkRequest.CustomerId); await _requestsRepository.DeleteByIdAsync(linkRequest.CustomerId); } else { _log.Error(message: "Wallet linking request has not been deleted upon confirmation from blockchain", context: new { publicAccountUnlinkedDto.PrivateAddress, publicAccountUnlinkedDto.PublicAddress }); } await _statusChangeCompletedPublisher.PublishAsync(new WalletLinkingStatusChangeCompletedEvent { CustomerId = linkRequest?.CustomerId, PrivateAddress = publicAccountUnlinkedDto.PrivateAddress, PublicAddress = null, EventId = Guid.NewGuid().ToString(), Fee = linkRequest?.Fee ?? 0 }); _log.Info("Wallet has been unlinked and confirmed in private blockchain", context: publicAccountUnlinkedDto.ToJson()); }
public async Task HandleAsync(string privateAddress, string publicAddress) { var linkingRequest = await _requestsRepository.GetByPrivateAddressAsync(privateAddress); if (string.IsNullOrEmpty(publicAddress)) { // it was unlink operation _log.Error(message: "Wallet unlinking operation failed", context: new { privateAddress }); if (linkingRequest != null) { await _pushNotificationsPublisher.PublishWalletUnlinkingUnsuccessfulAsync(linkingRequest.CustomerId); } } else { // it was link operation _log.Error(message: "Wallet linking operation failed", context: new { privateAddress, publicAddress }); if (linkingRequest != null) { await _requestsRepository.DeleteByIdAsync(linkingRequest.CustomerId); await _pushNotificationsPublisher.PublishWalletLinkingUnsuccessfulAsync(linkingRequest.CustomerId); _log.Info("The linking request has been deleted because the corresponding transaction failed", context: linkingRequest.ToJson()); } } await _failurePublisher.PublishAsync(new WalletLinkingStatusChangeFailedEvent { CustomerId = linkingRequest?.CustomerId, PrivateAddress = privateAddress, PublicAddress = publicAddress, Fee = linkingRequest?.Fee ?? 0, EventId = Guid.NewGuid().ToString() }); }