コード例 #1
0
        public async Task <EthereumResponse <OperationResponse> > SendTransferWithChangeAsync(decimal change, string signFrom, Guid id, IAsset asset, string fromAddress,
                                                                                              string toAddress, decimal amount)
        {
            var response = await _ethereumApi.ApiExchangeTransferWithChangePostAsync(new TransferWithChangeModel
            {
                Change             = EthServiceHelpers.ConvertToContract(change, asset.MultiplierPower, asset.Accuracy),
                Amount             = EthServiceHelpers.ConvertToContract(amount, asset.MultiplierPower, asset.Accuracy),
                SignFrom           = signFrom,
                CoinAdapterAddress = asset.AssetAddress,
                ToAddress          = toAddress,
                FromAddress        = fromAddress,
                Id = id
            });

            var error = response as ApiException;

            if (error != null)
            {
                return(new EthereumResponse <OperationResponse>
                {
                    Error = new ErrorResponse {
                        Code = error.Error.Code, Message = error.Error.Message
                    }
                });
            }

            var res = response as OperationIdResponse;

            if (res != null)
            {
                return(new EthereumResponse <OperationResponse> {
                    Result = new OperationResponse {
                        OperationId = res.OperationId
                    }
                });
            }

            throw new Exception("Unknown response");
        }
コード例 #2
0
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='model'>
 /// </param>
 public static object ApiExchangeTransferWithChangePost(this IEthereumApi operations, TransferWithChangeModel model = default(TransferWithChangeModel))
 {
     return(operations.ApiExchangeTransferWithChangePostAsync(model).GetAwaiter().GetResult());
 }