mirror of
https://github.com/RoboSats/robosats.git
synced 2024-12-15 20:06:24 +00:00
21 lines
483 B
TypeScript
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;
|