@getalby/lightning-tools
Version:
Collection of helpful building blocks and tools to develop Bitcoin Lightning web apps
1 lines • 2.03 kB
Source Map (JSON)
{"version":3,"file":"podcasting2.cjs","sources":["../../src/podcasting2/boostagrams.ts"],"sourcesContent":["import { WebLNProvider } from \"@webbtc/webln-types\";\nimport { BoostArguments, BoostOptions, WeblnBoostParams } from \"./types\";\n\nexport const sendBoostagram = async (\n args: BoostArguments,\n options?: BoostOptions,\n) => {\n const { boost } = args;\n if (!options) {\n options = {};\n }\n const webln: WebLNProvider = options.webln || globalThis.webln;\n\n if (!webln) {\n throw new Error(\"WebLN not available\");\n }\n if (!webln.keysend) {\n throw new Error(\"Keysend not available in current WebLN provider\");\n }\n\n const amount = args.amount || Math.floor(boost.value_msat / 1000);\n\n const weblnParams: WeblnBoostParams = {\n destination: args.destination,\n amount: amount,\n customRecords: {\n \"7629169\": JSON.stringify(boost),\n },\n };\n if (args.customKey && args.customValue) {\n weblnParams.customRecords[args.customKey] = args.customValue;\n }\n await webln.enable();\n const response = await webln.keysend(weblnParams);\n return response;\n};\n"],"names":[],"mappings":";;AAGO,MAAM,cAAc,GAAG,OAC5B,IAAoB,EACpB,OAAsB,KACpB;AACF,IAAA,MAAM,EAAE,KAAK,EAAE,GAAG,IAAI;IACtB,IAAI,CAAC,OAAO,EAAE;QACZ,OAAO,GAAG,EAAE;IACd;IACA,MAAM,KAAK,GAAkB,OAAO,CAAC,KAAK,IAAI,UAAU,CAAC,KAAK;IAE9D,IAAI,CAAC,KAAK,EAAE;AACV,QAAA,MAAM,IAAI,KAAK,CAAC,qBAAqB,CAAC;IACxC;AACA,IAAA,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE;AAClB,QAAA,MAAM,IAAI,KAAK,CAAC,iDAAiD,CAAC;IACpE;AAEA,IAAA,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,IAAI,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,UAAU,GAAG,IAAI,CAAC;AAEjE,IAAA,MAAM,WAAW,GAAqB;QACpC,WAAW,EAAE,IAAI,CAAC,WAAW;AAC7B,QAAA,MAAM,EAAE,MAAM;AACd,QAAA,aAAa,EAAE;AACb,YAAA,SAAS,EAAE,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC;AACjC,SAAA;KACF;IACD,IAAI,IAAI,CAAC,SAAS,IAAI,IAAI,CAAC,WAAW,EAAE;QACtC,WAAW,CAAC,aAAa,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,IAAI,CAAC,WAAW;IAC9D;AACA,IAAA,MAAM,KAAK,CAAC,MAAM,EAAE;IACpB,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,OAAO,CAAC,WAAW,CAAC;AACjD,IAAA,OAAO,QAAQ;AACjB;;;;"}