public async Task <IActionResult> GetHashWithIdAsync([FromBody] BaseCoinRequestParametersModel model) { if (!ModelState.IsValid) { throw new ClientSideException(ExceptionType.WrongParams, JsonConvert.SerializeObject(ModelState.Errors())); } var guid = Guid.NewGuid(); //IdCheckResult idCheckResult = await _exchangeContractService.CheckId(guid); var amount = BigInteger.Parse(model.Amount); byte[] hash; try { hash = _hashCalculator.GetHash(guid, model.CoinAdapterAddress, _addressUtil.ConvertToChecksumAddress(model.FromAddress), _addressUtil.ConvertToChecksumAddress(model.ToAddress), amount); } catch (Exception e) { await _logger.WriteErrorAsync("HashController", "GetHashWithIdAsync", JsonConvert.SerializeObject(model), e, DateTime.UtcNow); throw; } return(Ok(new HashResponseWithId { HashHex = hash.ToHex(), OperationId = guid })); }
/// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='model'> /// </param> /// <param name='cancellationToken'> /// The cancellation token. /// </param> public static async Task <object> ApiHashCalculateAndGetIdPostAsync(this IEthereumApi operations, BaseCoinRequestParametersModel model = default(BaseCoinRequestParametersModel), CancellationToken cancellationToken = default(CancellationToken)) { using (var _result = await operations.ApiHashCalculateAndGetIdPostWithHttpMessagesAsync(model, null, cancellationToken).ConfigureAwait(false)) { return(_result.Body); } }
/// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='model'> /// </param> public static object ApiHashCalculateAndGetIdPost(this IEthereumApi operations, BaseCoinRequestParametersModel model = default(BaseCoinRequestParametersModel)) { return(operations.ApiHashCalculateAndGetIdPostAsync(model).GetAwaiter().GetResult()); }