TypeScript check

This commit is contained in:
Evan Kaloudis
2021-03-07 13:02:48 -05:00
parent a272ced2b7
commit f66ac84994
14 changed files with 56 additions and 54 deletions
+1 -3
View File
@@ -343,14 +343,12 @@ export default class Eclair {
let lastDay = 0,
lastWeek = 0,
lastMonth = 0,
allTimes = 0;
lastMonth = 0;
const now = new Date().getTime() / 1000;
const oneDayAgo = now - 60 * 60 * 24;
const oneWeekAgo = now - 60 * 60 * 24 * 7;
for (let i = relayed.length - 1; i >= 0; i--) {
const relay = relayed[i];
allTimes += relay.amountIn - relay.amountOut;
if (relay.timestamp > oneDayAgo) {
lastDay += relay.amountIn - relay.amountOut;
lastWeek += relay.amountIn - relay.amountOut;
-1
View File
@@ -2,7 +2,6 @@ import bolt11 from 'bolt11';
import LND from './LND';
import LoginRequest from './../models/LoginRequest';
import { DEFAULT_LNDHUB } from './../utils/AddressUtils';
export default class LndHub extends LND {
getHeaders = (accessToken: string) => {
+1 -1
View File
@@ -262,7 +262,7 @@ export default class Spark {
channel_fees: listpeers.peers
.filter(({ channels }: any) => channels && channels.length)
.filter(
({ channels: [{ short_channel_id }] }) =>
({ channels: [{ short_channel_id }] }: any) =>
channelsMap[short_channel_id]
)
.map(
+11 -22
View File
@@ -12,7 +12,6 @@ import {
TouchableOpacity
} from 'react-native';
import { Avatar, ListItem } from 'react-native-elements';
import { remove } from 'lodash';
import { inject, observer } from 'mobx-react';
import { localeString } from './../utils/LocaleUtils';
import Identicon from 'identicon.js';
@@ -20,7 +19,7 @@ const hash = require('object-hash');
import stores from './../stores/Stores';
import ChannelsStore from './../stores/ChannelsStore';
import Channel from './../model/Channel';
import Channel from './../models/Channel';
import UnitsStore from './../stores/UnitsStore';
import BalanceSlider from './../components/BalanceSlider';
@@ -40,10 +39,9 @@ interface ChannelPickerProps {
interface ChannelPickerState {
status: string;
channelSelected: Channel;
channelSelected: Channel | null;
valueSet: string;
showChannelModal: boolean;
setBalance: number;
}
const ChannelIcon = (balanceImage: string) => (
@@ -71,7 +69,7 @@ export default class ChannelPicker extends React.Component<
> {
state = {
status: 'unselected',
channelSelected: {},
channelSelected: null,
valueSet: '',
showChannelModal: false
};
@@ -79,23 +77,18 @@ export default class ChannelPicker extends React.Component<
openPicker() {
stores.channelsStore.getChannels();
this.setState({
channelSelected: {},
channelSelected: null,
showChannelModal: true
});
}
clearSelection() {
this.setState({
channelSelected: {},
channelSelected: null,
valueSet: ''
});
}
displayValues(): string {
const { channelSelected } = this.state;
return channelSelected.channelId;
}
toggleItem(item: any) {
this.setState({ channelSelected: item });
}
@@ -108,19 +101,13 @@ export default class ChannelPicker extends React.Component<
ChannelsStore,
UnitsStore
} = this.props;
const {
channelSelected,
channelSet,
showChannelModal,
valueSet
} = this.state;
const { channelSelected, showChannelModal, valueSet } = this.state;
const SettingsStore = stores.settingsStore;
const { channels, nodes, loading, getChannels } = ChannelsStore;
const { getAmount, units } = UnitsStore;
const { settings } = SettingsStore;
const { theme, lurkerMode } = settings;
let channelPicked = channelSelected;
const pickerValuesAndroid: Array<any> = [];
const pickerValuesIOS: Array<string> = ['Cancel'];
VALUES.forEach((value: { key: string; value: string }) => {
@@ -330,7 +317,7 @@ export default class ChannelPicker extends React.Component<
onPress={() => {
const {
channelSelected
} = this.state;
}: any = this.state;
const displayName =
channelSelected.alias ||
@@ -342,8 +329,10 @@ export default class ChannelPicker extends React.Component<
channelSelected
.remote_pubkey
].alias) ||
channelSelected.remote_pubkey ||
channelSelected.channelId;
(channelSelected &&
channelSelected.remote_pubkey) ||
(channelSelected &&
channelSelected.channelId);
this.setState({
showChannelModal: false,
+14 -12
View File
@@ -237,20 +237,22 @@ export default class UTXOPicker extends React.Component<
this.toggleItem(item)
}
titleStyle={{
color:
channelSelected === item
? 'orange'
: theme === 'dark'
? 'white'
: 'black'
color: utxosPicked.includes(
`${item.txid}:${item.output}`
)
? 'orange'
: theme === 'dark'
? 'white'
: 'black'
}}
subtitleStyle={{
color:
channelSelected === item
? 'orange'
: theme === 'dark'
? 'gray'
: '#8a8999'
color: utxosPicked.includes(
`${item.txid}:${item.output}`
)
? 'orange'
: theme === 'dark'
? 'gray'
: '#8a8999'
}}
/>
)}
+1
View File
@@ -1,3 +1,4 @@
// @ts-nocheck
export default class BaseModel {
constructor(data?: any) {
Object.keys(data).forEach((field: any) => {
+5 -5
View File
@@ -97,11 +97,11 @@ export default class TransactionsStore {
payment_request?: string | null,
amount?: string | null,
pubkey?: string | null,
max_parts?: string,
timeout_seconds?: string,
fee_limit_sat?: string,
outgoing_chan_ids?: Array<string>,
last_hop_pubkey?: string
max_parts?: string | null,
timeout_seconds?: string | null,
fee_limit_sat?: string | null,
outgoing_chan_ids?: Array<string> | null,
last_hop_pubkey?: string | null
) => {
this.loading = true;
this.error_msg = null;
+1
View File
@@ -15,6 +15,7 @@
"strict": true,
"target": "esnext",
"strictPropertyInitialization": false,
"skipLibCheck": true,
"baseUrl": "./",
"paths": {
"*" : ["typings/*"]
+2 -2
View File
@@ -12,13 +12,13 @@ describe('VersionUtils', () => {
expect(VersionUtils.parseVersion('v11.3-beta-2')).toEqual({
coreVersion: 11,
mainVersion: 3,
minorVersion: null,
minorVersion: 0,
releaseVersion: 'beta-2'
});
expect(VersionUtils.parseVersion('V11.4')).toEqual({
coreVersion: 11,
mainVersion: 4,
minorVersion: null,
minorVersion: 0,
releaseVersion: null
});
expect(VersionUtils.parseVersion('v0.0.2')).toEqual({
+3 -3
View File
@@ -7,9 +7,9 @@ class VersionUtils {
const [coreVersion, mainVersion, minorVersion] = noPrefix.split('.');
return {
coreVersion: coreVersion ? Number(coreVersion) : null,
mainVersion: mainVersion ? Number(mainVersion) : null,
minorVersion: minorVersion ? Number(minorVersion) : null,
coreVersion: coreVersion ? Number(coreVersion) : 0,
mainVersion: mainVersion ? Number(mainVersion) : 0,
minorVersion: minorVersion ? Number(minorVersion) : 0,
releaseVersion
};
};
+1 -1
View File
@@ -8,7 +8,7 @@ const { nodeInfoStore, invoicesStore } = stores;
export default async function(data: string): Promise<any> {
const { nodeInfo } = nodeInfoStore;
const { isTestNet, isRegTest } = nodeInfo;
const { value, amount } = AddressUtils.processSendAddress(data);
const { value, amount }: any = AddressUtils.processSendAddress(data);
if (AddressUtils.isValidBitcoinAddress(value, isTestNet || isRegTest)) {
return [
+1 -1
View File
@@ -12,7 +12,7 @@ import {
import { Button } from 'react-native-elements';
import { inject, observer } from 'mobx-react';
import UrlUtils from './../utils/UrlUtils';
import { DEFAULT_LNDHUB } from './../backends/LndHub';
import { DEFAULT_LNDHUB } from './../utils/AddressUtils';
import DropdownSetting from './../components/DropdownSetting';
import SettingsStore, {
DEFAULT_LOCALE,
+14 -1
View File
@@ -15,6 +15,7 @@ import { localeString } from './../utils/LocaleUtils';
import InvoicesStore from './../stores/InvoicesStore';
import TransactionsStore from './../stores/TransactionsStore';
import UnitsStore from './../stores/UnitsStore';
import ChannelsStore from './../stores/ChannelsStore';
import SettingsStore from './../stores/SettingsStore';
import RESTUtils from './../utils/RESTUtils';
@@ -26,6 +27,7 @@ interface InvoiceProps {
InvoicesStore: InvoicesStore;
TransactionsStore: TransactionsStore;
UnitsStore: UnitsStore;
ChannelsStore: ChannelsStore;
SettingsStore: SettingsStore;
}
@@ -40,7 +42,13 @@ interface InvoiceState {
lastHopPubkey: string | null;
}
@inject('InvoicesStore', 'TransactionsStore', 'UnitsStore', 'SettingsStore')
@inject(
'InvoicesStore',
'TransactionsStore',
'UnitsStore',
'ChannelsStore',
'SettingsStore'
)
@observer
export default class PaymentRequest extends React.Component<
InvoiceProps,
@@ -62,6 +70,7 @@ export default class PaymentRequest extends React.Component<
TransactionsStore,
InvoicesStore,
UnitsStore,
ChannelsStore,
SettingsStore,
navigation
} = this.props;
@@ -484,6 +493,8 @@ export default class PaymentRequest extends React.Component<
})
}
title="First Hop"
ChannelsStore={ChannelsStore}
UnitsStore={UnitsStore}
/>
}
{
@@ -496,6 +507,8 @@ export default class PaymentRequest extends React.Component<
})
}
title="Last Hop"
ChannelsStore={ChannelsStore}
UnitsStore={UnitsStore}
/>
}
</>
+1 -2
View File
@@ -15,9 +15,8 @@ import {
} from 'react-native';
import { Button, CheckBox, Header, Icon } from 'react-native-elements';
import { inject, observer } from 'mobx-react';
import AddressUtils from './../../utils/AddressUtils';
import AddressUtils, { DEFAULT_LNDHUB } from './../../utils/AddressUtils';
import LndConnectUtils from './../../utils/LndConnectUtils';
import { DEFAULT_LNDHUB } from './../../backends/LndHub';
import { localeString } from './../../utils/LocaleUtils';
import CollapsedQR from './../../components/CollapsedQR';
import SettingsStore from './../../stores/SettingsStore';