示例#1
0
        /// <inheritdoc />
        public async Task <TransactionBuildingResult> BuildTransactionWithManyInputsAsync(Guid operationId, IEnumerable <BuildingTransactionInput> inputs, string toAddress, BlockchainAsset asset)
        {
            ValidateOperationIdIsNotEmpty(operationId);
            // ReSharper disable once PossibleMultipleEnumeration
            ValidateInputsNotNull(inputs);
            ValidateToAddressIsNotEmpty(toAddress);
            ValidateAssetIsNotNull(asset);

            try
            {
                var apiResponse = await _runner.RunWithRetriesAsync(() => _api.BuildTransactionWithManyInputsAsync(
                                                                        new BuildTransactionWithManyInputsRequest
                {
                    OperationId = operationId,
                    // ReSharper disable once PossibleMultipleEnumeration
                    Inputs = inputs
                             .Select(i => i.ToContract(asset.Accuracy))
                             .ToArray(),
                    ToAddress = toAddress,
                    AssetId   = asset.AssetId
                }));

                return(new TransactionBuildingResult(apiResponse));
            }
            catch (ErrorResponseException ex) when(ex.StatusCode == HttpStatusCode.NotImplemented)
            {
                throw new NotSupportedException("Operation is not supported by the blockchain. See GetCapabilitiesAsync", ex);
            }
            catch (ErrorResponseException ex) when(ex.StatusCode == HttpStatusCode.Conflict)
            {
                throw new TransactionAlreadyBroadcastedException(ex);
            }
        }