From eb21456645373179549c702a1bc61f0114720937 Mon Sep 17 00:00:00 2001 From: Sindre Sorhus Date: Mon, 27 Aug 2018 17:59:47 +0700 Subject: [PATCH] Ignore cancel events for swaps that are in progress Workaround for https://github.com/jl777/SuperNET/issues/956 --- app/renderer/swap-db.js | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/app/renderer/swap-db.js b/app/renderer/swap-db.js index a7bb200ff9..8d29e3bdc0 100644 --- a/app/renderer/swap-db.js +++ b/app/renderer/swap-db.js @@ -219,15 +219,20 @@ class SwapDB { } if (message.method === 'failed') { - swap.status = 'failed'; - swap.progress = 1; - - // TODO: Add error messages once we have errors documented - // https://github.com/atomiclabs/hyperdex/issues/180 - swap.error = { - code: message.error, - message: `Error Code: ${message.error}`, - }; + // This check is to ignore cancel events when the trade is no longer pending + // It's most likely caused by this mm bug + // https://github.com/jl777/SuperNET/issues/956 + if (!(swap.status !== 'pending' && [-9998, -9997].includes(message.error))) { + swap.status = 'failed'; + swap.progress = 1; + + // TODO: Add error messages once we have errors documented + // https://github.com/atomiclabs/hyperdex/issues/180 + swap.error = { + code: message.error, + message: `Error Code: ${message.error}`, + }; + } } });