public async Task TryClaimRefundAsync(DepositDetails deposit, Address refundTo) { var now = (ulong)_blockchainBridge.Head.Timestamp; if (!deposit.CanClaimRefund(now)) { return; } var depositId = deposit.Deposit.Id; var transactionHash = deposit.ClaimedRefundTransactionHash; if (transactionHash is null) { var provider = deposit.DataAsset.Provider.Address; var refundClaim = new RefundClaim(depositId, deposit.DataAsset.Id, deposit.Deposit.Units, deposit.Deposit.Value, deposit.Deposit.ExpiryTime, deposit.Pepper, provider, refundTo); transactionHash = _refundService.ClaimRefund(refundTo, refundClaim); deposit.SetClaimedRefundTransactionHash(transactionHash); await _depositRepository.UpdateAsync(deposit); if (_logger.IsInfo) { _logger.Info($"Claimed a refund for deposit: '{depositId}', transaction hash: '{transactionHash}' (awaits a confirmation)."); } } await TryConfirmClaimAsync(deposit, string.Empty); }
public void Setup() { Prepare(); _claimedRefundTransactionHash = TestItem.KeccakA; _refundService = Substitute.For <IRefundService>(); _refundService.ClaimRefund(Arg.Any <Address>(), Arg.Any <RefundClaim>()) .Returns(_claimedRefundTransactionHash); _refundService.ClaimEarlyRefund(Arg.Any <Address>(), Arg.Any <EarlyRefundClaim>()) .Returns(_claimedRefundTransactionHash); _depositRepository = Substitute.For <IDepositDetailsRepository>(); _transactionVerifier = Substitute.For <ITransactionVerifier>(); _transactionVerifier.Verify(Arg.Any <TxReceipt>()).Returns(new TransactionVerifierResult(true, 1, 1)); _refundClaimant = new RefundClaimant(_refundService, _bridge, _depositRepository, _transactionVerifier, LimboLogs.Instance); }