public async Task <IActionResult> AddObservation([Required] string address) { if (!_balanceService.IsAddressValid(address)) { return(BadRequest(ErrorResponse.Create("Invalid parameter").AddModelError("address", "Address must be valid"))); } var exists = await _balanceService.IsBalanceObservedAsync(address); if (exists) { return(new StatusCodeResult(StatusCodes.Status409Conflict)); } await _balanceService.AddBalanceObservationAsync(address); return(Ok()); }
public async Task <IActionResult> AddObservation([Required] string address) { if (!_balanceService.IsAddressValid(address, out var hasExtension)) { return(BadRequest(ErrorResponse.Create("Invalid parameter").AddModelError("address", "Address must be valid"))); } if (!_balanceService.IsDepositBaseAddress(address)) { return(BadRequest(ErrorResponse.Create("Invalid parameter").AddModelError("address", $"Address must match configured deposit base address. expected={_balanceService.GetDepositBaseAddress()}"))); } if (!hasExtension) { return(BadRequest(ErrorResponse.Create("Invalid parameter").AddModelError("address", "Address must have public address extension"))); } var exists = await _balanceService.IsBalanceObservedAsync(address); if (exists) { return(new StatusCodeResult(StatusCodes.Status409Conflict)); } await _balanceService.AddBalanceObservationAsync(address); return(Ok()); }