From df75ea4432618c0b9f304dd79f94de2b2c4dbf37 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABtan=20Renaudeau?= Date: Fri, 15 Jun 2018 08:53:27 +0200 Subject: [PATCH] Fix LibcoreBridge to not validate if amount=0 --- src/bridge/LibcoreBridge.js | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/bridge/LibcoreBridge.js b/src/bridge/LibcoreBridge.js index 45321d7e..b3ee7ff9 100644 --- a/src/bridge/LibcoreBridge.js +++ b/src/bridge/LibcoreBridge.js @@ -48,7 +48,7 @@ const EditAdvancedOptions = ({ onChange, value }: EditProps) => ( const recipientValidLRU = LRU({ max: 100 }) -const isRecipientValid = (currency, recipient): Promise => { +const isRecipientValid = (currency, recipient) => { const key = `${currency.id}_${recipient}` let promise = recipientValidLRU.get(key) if (promise) return promise @@ -172,14 +172,18 @@ const LibcoreBridge: WalletBridge = { isValidTransaction: (a, t) => (t.amount > 0 && t.recipient && true) || false, canBeSpent: (a, t) => - getFees(a, t) - .then(fees => fees !== null) - .catch(() => false), + !t.amount + ? Promise.resolve(true) + : getFees(a, t) + .then(fees => fees !== null) + .catch(() => false), getTotalSpent: (a, t) => - getFees(a, t) - .then(totalFees => t.amount + (totalFees || 0)) - .catch(() => 0), + !t.amount + ? Promise.resolve(0) + : getFees(a, t) + .then(totalFees => t.amount + (totalFees || 0)) + .catch(() => 0), getMaxAmount: (a, t) => getFees(a, t)