feat: switch to @webbtc/webln-types

This commit is contained in:
Kieran 2023-05-19 15:41:01 +01:00
parent 6b4a5bd047
commit fc662f3267
Signed by: Kieran
GPG Key ID: DE71CEB3925BE941
4 changed files with 9 additions and 51 deletions

View File

@ -1,3 +1,5 @@
/// <reference types="@webbtc/webln-types" />
declare module "*.jpg" {
const value: unknown;
export default value;

View File

@ -85,6 +85,7 @@
"@types/react-dom": "^18.0.10",
"@types/webscopeio__react-textarea-autocomplete": "^4.7.2",
"@types/webtorrent": "^0.109.3",
"@webbtc/webln-types": "^1.0.10",
"@webpack-cli/generators": "^3.0.4",
"@webscopeio/react-textarea-autocomplete": "^4.9.2",
"babel-loader": "^9.1.2",

View File

@ -14,56 +14,6 @@ import {
} from "Wallet";
import { barrierQueue, processWorkQueue, WorkQueueItem } from "WorkQueue";
interface SendPaymentResponse {
paymentHash?: string;
preimage: string;
route?: {
total_amt: number;
total_fees: number;
};
}
interface RequestInvoiceArgs {
amount?: string | number;
defaultAmount?: string | number;
minimumAmount?: string | number;
maximumAmount?: string | number;
defaultMemo?: string;
}
interface RequestInvoiceResponse {
paymentRequest: string;
}
interface GetInfoResponse {
node: {
alias: string;
pubkey: string;
color?: string;
};
}
interface SignMessageResponse {
message: string;
signature: string;
}
interface WebLN {
enabled: boolean;
getInfo(): Promise<GetInfoResponse>;
enable(): Promise<void>;
makeInvoice(args: RequestInvoiceArgs): Promise<RequestInvoiceResponse>;
signMessage(message: string): Promise<SignMessageResponse>;
verifyMessage(signature: string, message: string): Promise<void>;
sendPayment: (pr: string) => Promise<SendPaymentResponse>;
}
declare global {
interface Window {
webln?: WebLN;
}
}
const WebLNQueue: Array<WorkQueueItem> = [];
processWorkQueue(WebLNQueue);
@ -111,7 +61,7 @@ export class WebLNWallet implements LNWallet {
}
async login(): Promise<boolean> {
if (window.webln && !window.webln.enabled) {
if (window.webln) {
await window.webln.enable();
}
return true;

View File

@ -2829,6 +2829,11 @@
"@webassemblyjs/ast" "1.11.6"
"@xtuc/long" "4.2.2"
"@webbtc/webln-types@^1.0.10":
version "1.0.10"
resolved "https://registry.yarnpkg.com/@webbtc/webln-types/-/webln-types-1.0.10.tgz#03e41779df6ba9bdca57635ca6b5a70c7233c8c6"
integrity sha512-Cy9+uNqvRct3yHB+bs5hJ3idf4VEmnyKxwMpe1/lWpOXbbdi/h7GgAB1JMsnblwN74QKSBEnOPvURoA+RAG9qg==
"@webpack-cli/configtest@^2.1.0":
version "2.1.0"
resolved "https://registry.npmjs.org/@webpack-cli/configtest/-/configtest-2.1.0.tgz"