Skip to content

Commit

Permalink
Use synchronous implementation for RadixAddressValidator
Browse files Browse the repository at this point in the history
  • Loading branch information
krzlabrdx committed Jan 15, 2024
1 parent 729bb25 commit f0e138e
Showing 1 changed file with 2 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -74,23 +74,20 @@ public sealed class RadixAddressValidator : AbstractValidator<string>
{
public RadixAddressValidator(INetworkConfigurationProvider networkConfigurationProvider)
{
// TODO:
//Has to be sync.
RuleFor(x => x)
.CustomAsync(async (address, context, token) =>
.Custom((address, context) =>
{
context.MessageFormatter.AppendArgument("PropertyName", context.PropertyPath);

try
{
var networkHrpSuffix = (await networkConfigurationProvider.GetNetworkConfiguration(token)).HrpSuffix;
var networkHrpSuffix = networkConfigurationProvider.GetNetworkConfiguration().GetAwaiter().GetResult().HrpSuffix;
var decodedAddress = RadixAddressCodec.Decode(address);

if (!decodedAddress.Hrp.EndsWith(networkHrpSuffix, StringComparison.OrdinalIgnoreCase))
{
context.MessageFormatter.AppendArgument("networkHrpSuffix", networkHrpSuffix);
context.AddFailure("'{PropertyName}' doesn't belong to this network. Expected network Hrp suffix: {networkHrpSuffix}");
return;
}
}
catch (AddressException)
Expand Down

0 comments on commit f0e138e

Please sign in to comment.