Skip to content

Commit

Permalink
feat(alby): adjust alby type #632
Browse files Browse the repository at this point in the history
  • Loading branch information
escapedcat committed Jul 18, 2023
1 parent 7ee6358 commit e25525b
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 7 deletions.
11 changes: 10 additions & 1 deletion src/globals.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
declare global {
// for more detailed type-info see:
// https://github.com/getAlby/lightning-browser-extension/blob/master/src/extension/providers/alby/index.ts#L3
interface Window {
alby?: any;
alby?: {
enable: () => Promise<{ enabled: boolean }>;
addAccount: (params: {
name: string;
connector: string;
config: Record<string, unknown>;
}) => Promise<{ success: boolean }>;
};
}
}

Expand Down
9 changes: 6 additions & 3 deletions src/pages/Apps/AppCardAlby.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,17 @@ export const AppCard: FC<Props> = ({ appInfo, onOpenDetails }) => {

const { lnd_admin_macaroon, lnd_rest_onion } = resp.data;

if (!window.alby) {
const albyProvider = window.alby;

if (!albyProvider) {
toast.error(t(`appInfo.${id}.action.connection.hint`));
return;
}

try {
await window.alby.enable();
await albyProvider.enable();

const result = await window.alby.addAccount({
const result = await albyProvider.addAccount({
name: "⚡️ Raspiblitz",
connector: "lnd",
config: {
Expand Down
9 changes: 6 additions & 3 deletions src/pages/Apps/AppInfoAlby.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,17 @@ export const AppInfo: FC<Props> = ({ app, onClose }) => {

const { lnd_admin_macaroon, lnd_rest_onion } = resp.data;

if (!window.alby) {
const albyProvider = window.alby;

if (!albyProvider) {
toast.error(t(`appInfo.${id}.action.connection.hint`));
return;
}

try {
await window.alby.enable();
await albyProvider.enable();

const result = await window.alby.addAccount({
const result = await albyProvider.addAccount({
name: "⚡️ Raspiblitz",
connector: "lnd",
config: {
Expand Down

0 comments on commit e25525b

Please sign in to comment.