Skip to content

Commit 29f8a6a

Browse files
committed
Added return types as needed throughout lightning-manager.ts.
Fixed temp linting warnings in helpers.ts. Added return type to getDefaultLdkStorageShape method in helpers.ts.
1 parent d730970 commit 29f8a6a

File tree

2 files changed

+11
-8
lines changed

2 files changed

+11
-8
lines changed

src/lightning-manager.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ import {
3535
TLdkPeersData,
3636
TPeer,
3737
DefaultTransactionDataShape,
38+
TTransactionData,
3839
} from './utils/types';
3940
import { dummyRandomSeed } from './utils/regtest-dev-tools';
4041
import { getDefaultLdkStorageShape } from './utils/helpers';
@@ -71,10 +72,10 @@ class LightningManager {
7172
height: 0,
7273
});
7374
seed: string = '';
74-
getItem: TStorage = () => null;
75-
setItem: TStorage = () => null;
76-
getTransactionData: TGetTransactionData = async () =>
77-
DefaultTransactionDataShape;
75+
getItem: TStorage = (): null => null;
76+
setItem: TStorage = (): null => null;
77+
getTransactionData: TGetTransactionData =
78+
async (): Promise<TTransactionData> => DefaultTransactionDataShape;
7879
network: ENetworks = ENetworks.regtest;
7980

8081
constructor() {
@@ -496,7 +497,7 @@ class LightningManager {
496497
//LDK events
497498

498499
private onRegisterTx(res: TRegisterTxEvent): void {
499-
(async () => {
500+
(async (): Promise<void> => {
500501
// Set new/unconfirmed transaction.
501502
const filterRes = await Promise.all(
502503
this.watchTxs.filter((watchTx) => {

src/utils/helpers.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { DefaultLdkDataShape } from './types';
1+
import { DefaultLdkDataShape, TLdkStorage } from './types';
22

33
/**
44
* Convert string to bytes
@@ -66,7 +66,9 @@ export const btoa = (input: string): string => {
6666

6767
for (
6868
let block = 0, charCode, i = 0, map = chars;
69+
// eslint-disable-next-line no-bitwise
6970
str.charAt(i | 0) || ((map = '='), i % 1);
71+
// eslint-disable-next-line no-bitwise
7072
output += map.charAt(63 & (block >> (8 - (i % 1) * 8)))
7173
) {
7274
charCode = str.charCodeAt((i += 3 / 4));
@@ -76,14 +78,14 @@ export const btoa = (input: string): string => {
7678
"'btoa' failed: The string to be encoded contains characters outside of the Latin1 range.",
7779
);
7880
}
79-
81+
// eslint-disable-next-line no-bitwise
8082
block = (block << 8) | charCode;
8183
}
8284

8385
return output;
8486
};
8587

86-
export const getDefaultLdkStorageShape = (seed: string) => {
88+
export const getDefaultLdkStorageShape = (seed: string): TLdkStorage => {
8789
return {
8890
[seed]: DefaultLdkDataShape,
8991
};

0 commit comments

Comments
 (0)