From 087fdd27f3683a1deb9376b7a72aa608e6fd8e6a Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Thu, 12 Sep 2019 15:25:47 -0700 Subject: remove babel and eslint --- lib/createLnrpc.js | 40 +++++++++++++++++++--------------------- 1 file changed, 19 insertions(+), 21 deletions(-) (limited to 'lib') diff --git a/lib/createLnrpc.js b/lib/createLnrpc.js index 16a59b3c..661440bb 100644 --- a/lib/createLnrpc.js +++ b/lib/createLnrpc.js @@ -1,13 +1,11 @@ -import fs from 'fs' -import grpc from 'grpc' -import createLnrpc from 'lnrpc' -import {promisify} from 'util' +const fs = require("fs"); +const grpc = require("grpc"); +const createLnrpc = require("lnrpc"); +const { promisify } = require("util"); -export default async ({ server, tls, macaroon, channelpeers }) => { - const lnrpc = await createLnrpc({ server, tls }) - lnrpc.meta = new grpc.Metadata() - lnrpc.meta.add('macaroon', fs.readFileSync(macaroon).toString('hex')) - lnrpc.channelpeers = channelpeers +module.exports = async ({ server, tls, macaroon, channelpeers }) => { + const lnrpc = await createLnrpc({ server, tls, macaroonPath: macaroon }); + lnrpc.channelpeers = channelpeers; // Resolve proxy instance return new Proxy(lnrpc, { @@ -18,26 +16,26 @@ export default async ({ server, tls, macaroon, channelpeers }) => { * @return {Promise} {Any} */ get(target, key) { - const method = target[key] + const method = target[key]; - if (typeof key === 'string' && typeof method === 'function') { - const streaming = key.match(/openChannel$|sendPayment|subscribe.*/) - let fn + if (typeof key === "string" && typeof method === "function") { + const streaming = key.match(/openChannel$|sendPayment|subscribe.*/); + let fn; if (streaming) { - if (key === 'sendPayment') { - fn = params => method.call(lnrpc, target.meta, params) + if (key === "sendPayment") { + fn = params => method.call(lnrpc, target.meta, params); } else { - fn = params => method.call(lnrpc, params, target.meta) - } + fn = params => method.call(lnrpc, params, target.meta); + } } else { - fn = params => promisify(method).call(lnrpc, params, target.meta) - } + fn = params => promisify(method).call(lnrpc, params, target.meta); + } - return fn + return fn; } return target[key]; // forward } }); -} +}; -- cgit v1.2.3