From d02eee46fb91d32a5a505a81b68444993ef14200 Mon Sep 17 00:00:00 2001 From: Daniel Lugo Date: Mon, 22 Feb 2021 13:43:14 -0400 Subject: [PATCH] upgrade shock-common --- package.json | 2 +- services/gunDB/contact-api/actions.js | 16 +++++++++++----- services/gunDB/contact-api/jobs/onOrders.js | 20 ++++++++++---------- yarn.lock | 20 ++++++++++---------- 4 files changed, 32 insertions(+), 26 deletions(-) diff --git a/package.json b/package.json index 4539a8f6..bcbf2dfd 100644 --- a/package.json +++ b/package.json @@ -52,7 +52,7 @@ "request-promise": "^4.2.6", "response-time": "^2.3.2", "shelljs": "^0.8.2", - "shock-common": "30.0.0", + "shock-common": "latest", "socket.io": "2.1.1", "text-encoding": "^0.7.0", "tingodb": "^0.6.1", diff --git a/services/gunDB/contact-api/actions.js b/services/gunDB/contact-api/actions.js index 14fd4bf1..5a904599 100644 --- a/services/gunDB/contact-api/actions.js +++ b/services/gunDB/contact-api/actions.js @@ -942,7 +942,7 @@ const sendSpontaneousPayment = async ( amount, memo, feeLimit, - opts = { type: 'user' } + opts = { type: 'spontaneousPayment' } ) => { try { const SEA = require('../Mediator').mySEA @@ -967,8 +967,8 @@ const sendSpontaneousPayment = async ( targetType: opts.type } - if (opts.type === 'post') { - order.postID = opts.postID + if (opts.type === 'tip') { + order.ackInfo = opts.postID } logger.info(JSON.stringify(order)) @@ -1079,10 +1079,16 @@ const sendSpontaneousPayment = async ( await writeCoordinate(payment.payment_hash, { id: payment.payment_hash, type: (() => { - if (opts.type === 'post') { + if (opts.type === 'tip') { return 'tip' - } else if (opts.type === 'user') { + } else if (opts.type === 'spontaneousPayment') { return 'spontaneousPayment' + } else if (opts.type === 'contentReveal') { + return 'other' // TODO + } else if (opts.type === 'other') { + return 'other' // TODO + } else if (opts.type === 'torrentSeed') { + return 'other' // TODO } // ensures we handle all possible types /** @type {never} */ diff --git a/services/gunDB/contact-api/jobs/onOrders.js b/services/gunDB/contact-api/jobs/onOrders.js index 430c6e5f..08eb4e5c 100644 --- a/services/gunDB/contact-api/jobs/onOrders.js +++ b/services/gunDB/contact-api/jobs/onOrders.js @@ -185,10 +185,10 @@ const listenerForAddr = (addr, SEA) => async (order, orderID) => { // invoices should be settled right away so we can rely on this single // subscription instead of life-long all invoices subscription - if (order.targetType === 'post') { - const { postID } = order - if (!Common.isPopulatedString(postID)) { - throw new TypeError(`postID not a a populated string`) + if (order.targetType === 'tip') { + const { ackInfo } = order + if (!Common.isPopulatedString(ackInfo)) { + throw new TypeError(`ackInfo(postID) not a a populated string`) } } @@ -210,7 +210,7 @@ const listenerForAddr = (addr, SEA) => async (order, orderID) => { toLndPub: await myLNDPub() } - if (order.targetType === 'post') { + if (order.targetType === 'tip') { coord.type = 'tip' } else { coord.type = 'spontaneousPayment' @@ -221,11 +221,11 @@ const listenerForAddr = (addr, SEA) => async (order, orderID) => { */ const onData = invoice => { if (invoice.settled) { - if (order.targetType === 'post') { + if (order.targetType === 'tip') { getUser() .get('postToTipCount') // CAST: Checked above. - .get(/** @type {string} */ (order.postID)) + .get(/** @type {string} */ (order.ackInfo)) .set(null) // each item in the set is a tip } @@ -237,13 +237,13 @@ const listenerForAddr = (addr, SEA) => async (order, orderID) => { stream.on('data', onData) stream.on('status', (/** @type {any} */ status) => { - logger.info(`Post tip, post: ${order.postID}, invoice status:`, status) + logger.info(`Post tip, post: ${order.ackInfo}, invoice status:`, status) }) stream.on('end', () => { - logger.warn(`Post tip, post: ${order.postID}, invoice stream ended`) + logger.warn(`Post tip, post: ${order.ackInfo}, invoice stream ended`) }) stream.on('error', (/** @type {any} */ e) => { - logger.warn(`Post tip, post: ${order.postID}, error:`, e) + logger.warn(`Post tip, post: ${order.ackInfo}, error:`, e) }) } catch (err) { logger.error( diff --git a/yarn.lock b/yarn.lock index 8e497962..9c1755a2 100644 --- a/yarn.lock +++ b/yarn.lock @@ -183,9 +183,9 @@ "@babel/helper-plugin-utils" "^7.0.0" "@babel/runtime@^7.6.3": - version "7.11.2" - resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.11.2.tgz#f549c13c754cc40b87644b9fa9f09a6a95fe0736" - integrity sha512-TeWkU52so0mPtDcaCTxNBI/IHiz0pZgr8VEFqXFtZWpYD08ZB6FaSwVAS8MKRQAP3bYKiVjwysOJgMFY28o6Tw== + version "7.12.18" + resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.12.18.tgz#af137bd7e7d9705a412b3caaf991fe6aaa97831b" + integrity sha512-BogPQ7ciE6SYAUPtlm9tWbgI9+2AgqSam6QivMgXgAT+fKbgppaj4ZX15MHeLC1PVF5sNk70huBu20XxWOs8Cg== dependencies: regenerator-runtime "^0.13.4" @@ -5113,9 +5113,9 @@ normalize-path@^3.0.0: integrity sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA== normalizr@^3.6.0: - version "3.6.0" - resolved "https://registry.yarnpkg.com/normalizr/-/normalizr-3.6.0.tgz#b8bbc4546ffe43c1c2200503041642915fcd3e1c" - integrity sha512-25cd8DiDu+pL46KIaxtVVvvEPjGacJgv0yUg950evr62dQ/ks2JO1kf7+Vi5/rMFjaSTSTls7aCnmRlUSljtiA== + version "3.6.1" + resolved "https://registry.yarnpkg.com/normalizr/-/normalizr-3.6.1.tgz#d367ab840e031ff382141b8d81ce279292ff69fe" + integrity sha512-8iEmqXmPtll8PwbEFrbPoDxVw7MKnNvt3PZzR2Xvq9nggEEOgBlNICPXYzyZ4w4AkHUzCU998mdatER3n2VaMA== npm-bundled@^1.0.1: version "1.0.6" @@ -6287,10 +6287,10 @@ shellwords@^0.1.1: resolved "https://registry.yarnpkg.com/shellwords/-/shellwords-0.1.1.tgz#d6b9181c1a48d397324c84871efbcfc73fc0654b" integrity sha512-vFwSUfQvqybiICwZY5+DAWIPLKsWO31Q91JSKl3UYv+K5c2QRPzn0qzec6QPu1Qc9eHYItiP3NdJqNVqetYAww== -shock-common@30.0.0: - version "30.0.0" - resolved "https://registry.yarnpkg.com/shock-common/-/shock-common-30.0.0.tgz#86ee39d076fe48adf551265c55e012ab3201c8e9" - integrity sha512-GgXCNOyk/iu0FBbYcfqOy7obX4RdEn3Q4y8R970CQVk7PvxYt0nZeQwKWe49esKb2B3JL1LOF/yJ7jg7tGze3w== +shock-common@latest: + version "31.1.0" + resolved "https://registry.yarnpkg.com/shock-common/-/shock-common-31.1.0.tgz#9c8f25d0d405a9a9c52849c2d96452c5ddd17267" + integrity sha512-1490v3gTY5ZNEB/Lelfix+6bI4mfFE8hVrtN4ijz0aj/Cl1ZP5ATKdYO+hffReI+4yDaPSAAWd/HYk9b497Kxw== dependencies: immer "^6.0.6" lodash "^4.17.19"