public async Task <EthereumResponse <EstimationResponse> > EstimateCashOutAsync(Guid id, string sign, IAsset asset, string fromAddress, string toAddress, decimal amount) { var response = await _ethereumApi.ApiExchangeEstimateCashoutGasPostAsync(new TransferModel { Amount = EthServiceHelpers.ConvertToContract(amount, asset.MultiplierPower, asset.Accuracy), CoinAdapterAddress = asset.AssetAddress, ToAddress = toAddress, FromAddress = fromAddress, Id = id, Sign = sign }); var error = response as ApiException; if (error != null) { return(new EthereumResponse <EstimationResponse> { Error = new ErrorResponse { Code = error.Error.Code, Message = error.Error.Message } }); } EstimatedGasModel res = response as EstimatedGasModel; if (res != null) { return(new EthereumResponse <EstimationResponse> { Result = new EstimationResponse { GasAmount = res.EstimatedGas, IsAllowed = res.IsAllowed.Value } }); } throw new Exception("Unknown response"); }
/// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='model'> /// </param> public static object ApiExchangeEstimateCashoutGasPost(this IEthereumApi operations, TransferModel model = default(TransferModel)) { return(operations.ApiExchangeEstimateCashoutGasPostAsync(model).GetAwaiter().GetResult()); }