public async Task <EthereumResponse <EthereumTransaction> > GetNewTxHashAndIdAsync(IAsset asset, string fromAddress, string toAddress, decimal amount) { var response = await _ethereumApi.ApiHashCalculateAndGetIdPostAsync(new BaseCoinRequestParametersModel { Amount = EthServiceHelpers.ConvertToContract(amount, asset.MultiplierPower, asset.Accuracy), CoinAdapterAddress = asset.AssetAddress, FromAddress = fromAddress, ToAddress = toAddress }); var error = response as ApiException; if (error != null) { return(new EthereumResponse <EthereumTransaction> { Error = new ErrorResponse { Code = error.Error.Code, Message = error.Error.Message } }); } var res = response as HashResponseWithId; if (res != null) { return(new EthereumResponse <EthereumTransaction> { Result = new EthereumTransaction { Hash = res.HashHex, OperationId = res.OperationId.GetValueOrDefault() } }); } throw new Exception("Unknown response"); }
/// <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()); }