Merge pull request #1709 from stackernews/fix-client-pending-forwards-paid
Fix pending forwards considered paid by client
This commit is contained in:
		
						commit
						0e765d4179
					
				@ -232,9 +232,15 @@ export function useAct ({ query = ACT_MUTATION, ...options } = {}) {
 | 
			
		||||
  // because the mutation name we use varies,
 | 
			
		||||
  // we need to extract the result/invoice from the response
 | 
			
		||||
  const getPaidActionResult = data => Object.values(data)[0]
 | 
			
		||||
  const wallets = useSendWallets()
 | 
			
		||||
 | 
			
		||||
  const [act] = usePaidMutation(query, {
 | 
			
		||||
    waitFor: inv => inv?.satsReceived > 0,
 | 
			
		||||
    waitFor: inv =>
 | 
			
		||||
      // if we have attached wallets, we might be paying a wrapped invoice in which case we need to make sure
 | 
			
		||||
      // we don't prematurely consider the payment as successful (important for receiver fallbacks)
 | 
			
		||||
      wallets.length > 0
 | 
			
		||||
        ? inv?.actionState === 'PAID'
 | 
			
		||||
        : inv?.satsReceived > 0,
 | 
			
		||||
    ...options,
 | 
			
		||||
    update: (cache, { data }) => {
 | 
			
		||||
      const response = getPaidActionResult(data)
 | 
			
		||||
 | 
			
		||||
@ -23,12 +23,12 @@ export default function useInvoice () {
 | 
			
		||||
      throw new InvoiceExpiredError(data.invoice)
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    const failed = cancelled || actionError
 | 
			
		||||
 | 
			
		||||
    if (failed && (forwardStatus && forwardStatus !== 'CONFIRMED')) {
 | 
			
		||||
    const failedForward = forwardStatus && forwardStatus !== 'CONFIRMED'
 | 
			
		||||
    if (failedForward) {
 | 
			
		||||
      throw new WalletReceiverError(data.invoice)
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    const failed = cancelled || actionError
 | 
			
		||||
    if (failed) {
 | 
			
		||||
      throw new InvoiceCanceledError(data.invoice, actionError)
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user