robosats/frontend/src/utils/webln.ts

21 lines
483 B
TypeScript

import { requestProvider, type WeblnProvider } from 'webln';
const getWebln = async (): Promise<WeblnProvider> => {
const resultPromise = new Promise<WeblnProvider>(async (resolve, reject) => {
try {
const webln = await requestProvider();
if (webln) {
webln.enable();
resolve(webln);
}
} catch (err) {
console.log("Coulnd't connect to Webln");
reject();
}
});
return await resultPromise;
};
export default getWebln;