Skip to content

Commit

Permalink
Typescript Typedef for NativeModule LndMobile
Browse files Browse the repository at this point in the history
  • Loading branch information
hsjoberg committed Dec 3, 2020
1 parent be86cb2 commit 8047ffa
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 7 deletions.
6 changes: 0 additions & 6 deletions android/app/src/main/java/com/blixtwallet/LndMobile.java
Original file line number Diff line number Diff line change
Expand Up @@ -289,12 +289,6 @@ public void checkLndProcessExist(Promise promise) {
promise.resolve(false);
}


@ReactMethod
public void deadPromise(Promise promise) {

}

@ReactMethod
public void init(Promise promise) {
if (!lndMobileServiceBound) {
Expand Down
48 changes: 48 additions & 0 deletions src/lndmobile/LndMobile.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
export enum ELndMobileStatusCodes {
STATUS_SERVICE_BOUND = 1,
STATUS_PROCESS_STARTED = 2,
STATUS_WALLET_UNLOCKED = 4,
}

export interface ILndMobile {
// General
init(): Promise<void>;
checkLndMobileServiceConnected(): Promise<boolean>;
sendPongToLndMobileservice(): Promise<{ data: string }>;
checkStatus(): Promise<ELndMobileStatusCodes>;
writeConfigFile(): Promise<string>;
startLnd(torEnabled: boolean): Promise<{ data: string }>
stopLnd(): Promise<{ data: string }>;
initWallet(seed: string[], password: string, recoveryWindow: number, channelBackupsBase64: string | null): Promise<{ data: string }>;
unlockWallet(password: string): Promise<{ data: string }>
killLnd(): Promise<boolean>;
restartApp(): void;
saveChannelsBackup(base64Backups: string): Promise<string>;
log(level: "v" | "d" | "i" | "w" | "e", tag: string, msg: string): void;
saveLogs(): Promise<string>;
copyLndLog(): Promise<string>;
tailLog(numberOfLines: number): Promise<string>;
getTorEnabled(): Promise<boolean>;
observeLndLogFile(): Promise<boolean>;
DEBUG_getWalletPasswordFromKeychain(): Promise<string>;

// Send gRPC LND API request
sendCommand(method: string, base64Payload: string): Promise<{ data: string }>;
sendStreamCommand(method: string, base64Payload: string, streamOnlyOnce: boolean): Promise<"done">;

// Android-specific
getIntentStringData(): Promise<string | null>;
getIntentNfcData(): Promise<string | null>;
DEBUG_deleteWallet(): Promise<boolean>;
DEBUG_deleteDatafolder(): Promise<null>;
DEBUG_listProcesses(): Promise<string>;
checkLndProcessExist(): Promise<boolean>;
deleteTLSCerts(): Promise<boolean>;
unbindLndMobileService(): Promise<void>; // TODO(hsjoberg): function looks broken
}

declare module "react-native" {
interface NativeModulesStatic {
LndMobile: ILndMobile;
}
}
2 changes: 1 addition & 1 deletion src/lndmobile/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export enum ELndMobileStatusCodes {
STATUS_WALLET_UNLOCKED = 4,
}

export const checkStatus = async (): Promise<number> => {
export const checkStatus = async (): Promise<ELndMobileStatusCodes> => {
return await LndMobile.checkStatus();
};

Expand Down

0 comments on commit 8047ffa

Please sign in to comment.