From 2a92d2b2c6321a5e3dcad250b7d00c462a452efa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Pawelec?= Date: Thu, 19 Sep 2024 13:56:20 +0200 Subject: [PATCH] fix deposit pre validation for non persisted account. --- CHANGELOG.md | 1 + .../DepositPreValidationQuerier.cs | 19 ++++++++++++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a420ec2a2..139ea1566 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -30,6 +30,7 @@ Release built: _not released yet_ ### Bug fixes - Added missing `total_count` property to `/state/validators/list` response. +- Fix `/transaction/account-deposit-pre-validation` for uninstantiated pre-allocated accounts. It no longer returns error with code 404 `Entity not found`. ### API Changes - Restored previously removed `total_count` property to `/state/key-value-store/keys` endpoint. diff --git a/src/RadixDlt.NetworkGateway.PostgresIntegration/Services/AccountDepositSettings/DepositPreValidationQuerier.cs b/src/RadixDlt.NetworkGateway.PostgresIntegration/Services/AccountDepositSettings/DepositPreValidationQuerier.cs index 92edb72b2..c29e9c8b4 100644 --- a/src/RadixDlt.NetworkGateway.PostgresIntegration/Services/AccountDepositSettings/DepositPreValidationQuerier.cs +++ b/src/RadixDlt.NetworkGateway.PostgresIntegration/Services/AccountDepositSettings/DepositPreValidationQuerier.cs @@ -110,8 +110,25 @@ public DepositPreValidationQuerier( CancellationToken token = default ) { - var accountEntity = await _entityQuerier.GetNonVirtualEntity(_dbContext, accountAddress, ledgerState, token); var xrdResourceAddress = (await _networkConfigurationProvider.GetNetworkConfiguration(token)).WellKnownAddresses.Xrd; + var accountEntity = await _entityQuerier.GetEntity(accountAddress, ledgerState, token); + if (accountEntity is VirtualAccountComponentEntity) + { + var resourceItems = resourceAddresses + .Select( + resourceAddress => new GatewayModel.AccountDepositPreValidationDecidingFactorsResourceSpecificDetailsItem( + resourceAddress, + false, + resourceAddress == xrdResourceAddress)) + .ToList(); + + return new GatewayModel.AccountDepositPreValidationDecidingFactors( + badgeResourceAddress.HasValue ? false : null, + AccountDefaultDepositRule.Accept.ToGatewayModel(), + resourceItems + ); + } + var addressesToResolve = resourceAddresses.ToList(); if (badgeResourceAddress.HasValue) {