mirror of
https://github.com/RoboSats/robosats.git
synced 2024-12-16 04:16:24 +00:00
19 lines
447 B
TypeScript
19 lines
447 B
TypeScript
|
import { requestProvider, WeblnProvider } from "webln";
|
||
|
|
||
|
export 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 resultPromise
|
||
|
}
|