diff --git a/services/gunDB/contact-api/actions.js b/services/gunDB/contact-api/actions.js index 08d69974..821c44e9 100644 --- a/services/gunDB/contact-api/actions.js +++ b/services/gunDB/contact-api/actions.js @@ -957,7 +957,6 @@ const sendPayment = async (to, amount, memo) => { // eslint-disable-next-line init-declarations let timeoutID - /** @type {string} */ const invoice = await Promise.race([ Utils.tryAndWait( gun => @@ -979,6 +978,13 @@ const sendPayment = async (to, amount, memo) => { }) ]) + if (typeof invoice !== 'string') { + throw new Error( + 'received invoice not an string, isntead got: ' + + JSON.stringify(invoice) + ) + } + const decInvoice = await SEA.decrypt(invoice, ourSecret) logger.info('decoded invoice: ' + decInvoice) diff --git a/services/gunDB/contact-api/jobs/onOrders.js b/services/gunDB/contact-api/jobs/onOrders.js index 0dc81390..ca05579d 100644 --- a/services/gunDB/contact-api/jobs/onOrders.js +++ b/services/gunDB/contact-api/jobs/onOrders.js @@ -49,23 +49,10 @@ const listenerForAddr = (addr, SEA) => async (order, orderID) => { )} -- addr: ${addr}` ) - let hasRetried = false - - const alreadyAnswered = Utils.tryAndWait( - (_, user) => - user - .get(Key.ORDER_TO_RESPONSE) - .get(orderID) - .then(), - v => { - // only retry once, because of the timeout - if (hasRetried) { - return false - } - hasRetried = true - return typeof v === 'undefined' - } - ) + const alreadyAnswered = getUser() + .get(Key.ORDER_TO_RESPONSE) + .get(orderID) + .then() if (alreadyAnswered) { return