/// <summary> /// Retrieves the receipt from the network matching the transaction /// id. Will wait for the disposition of the receipt to be known. /// </summary> /// <param name="transaction"> /// Transaction identifier of the receipt. /// </param> /// <param name="pending"> /// Flag indicating to return the pending or "scheduled" version of /// the transaction. If set to true, the network will look for /// the receipt of an executed pending transaction. The TxID is /// the ID of the tranaction that "created" the pending (scheduled) /// transaction. /// </param> /// <param name="configure"> /// Optional callback method providing an opportunity to modify /// the execution configuration for just this method call. /// It is executed prior to submitting the request to the network. /// </param> /// <returns> /// The receipt matching the transaction id, if found and marked /// sucessfull, otherwise a <see cref="TransactionException"/> is /// not found or returns an error status. /// </returns> /// <exception cref="TransactionException">If the network has no record of the transaction or request has invalid or had missing data.</exception> public async Task <TransactionReceipt> GetReceiptAsync(TxId transaction, Action <IContext>?configure = null) { await using var context = CreateChildContext(configure); var transactionId = new TransactionID(transaction); var receipt = await context.GetReceiptAsync(transactionId).ConfigureAwait(false); var result = new NetworkResult { TransactionID = transactionId, Receipt = receipt }; if (receipt.Status != ResponseCodeEnum.Success) { throw new TransactionException($"Unable to retreive receipt, status: {receipt.Status}", result); } return(result.ToReceipt()); }
/// <summary> /// Internal constructor for cases where a NetworkResult exists. /// </summary> internal TransactionException(string message, NetworkResult result) : base(message) { Receipt = result.ToReceipt(); }