diff --git a/backends/Eclair.ts b/backends/Eclair.ts index 39297aab1..477f95e9d 100644 --- a/backends/Eclair.ts +++ b/backends/Eclair.ts @@ -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; diff --git a/backends/LndHub.ts b/backends/LndHub.ts index 7d4b4bb4e..998413981 100644 --- a/backends/LndHub.ts +++ b/backends/LndHub.ts @@ -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) => { diff --git a/backends/Spark.ts b/backends/Spark.ts index b3ca702aa..4f55dc637 100644 --- a/backends/Spark.ts +++ b/backends/Spark.ts @@ -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( diff --git a/components/HopPicker.tsx b/components/HopPicker.tsx index fbc50ca80..8bd7eac5d 100644 --- a/components/HopPicker.tsx +++ b/components/HopPicker.tsx @@ -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 = []; const pickerValuesIOS: Array = ['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, diff --git a/components/UTXOPicker.tsx b/components/UTXOPicker.tsx index cad5586b0..3779311a6 100644 --- a/components/UTXOPicker.tsx +++ b/components/UTXOPicker.tsx @@ -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' }} /> )} diff --git a/models/BaseModel.ts b/models/BaseModel.ts index 1dcb304ef..27a632969 100644 --- a/models/BaseModel.ts +++ b/models/BaseModel.ts @@ -1,3 +1,4 @@ +// @ts-nocheck export default class BaseModel { constructor(data?: any) { Object.keys(data).forEach((field: any) => { diff --git a/stores/TransactionsStore.ts b/stores/TransactionsStore.ts index 92926c457..1c5d748b3 100644 --- a/stores/TransactionsStore.ts +++ b/stores/TransactionsStore.ts @@ -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, - last_hop_pubkey?: string + max_parts?: string | null, + timeout_seconds?: string | null, + fee_limit_sat?: string | null, + outgoing_chan_ids?: Array | null, + last_hop_pubkey?: string | null ) => { this.loading = true; this.error_msg = null; diff --git a/tsconfig.json b/tsconfig.json index 6aaf5f9cf..7e1f163c6 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -15,6 +15,7 @@ "strict": true, "target": "esnext", "strictPropertyInitialization": false, + "skipLibCheck": true, "baseUrl": "./", "paths": { "*" : ["typings/*"] diff --git a/utils/VersionUtils.test.ts b/utils/VersionUtils.test.ts index b53c592c6..d0c627651 100644 --- a/utils/VersionUtils.test.ts +++ b/utils/VersionUtils.test.ts @@ -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({ diff --git a/utils/VersionUtils.ts b/utils/VersionUtils.ts index dddc039ce..8a4f0e3d2 100644 --- a/utils/VersionUtils.ts +++ b/utils/VersionUtils.ts @@ -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 }; }; diff --git a/utils/handleAnything.ts b/utils/handleAnything.ts index 13c647f08..2a9cf5aba 100644 --- a/utils/handleAnything.ts +++ b/utils/handleAnything.ts @@ -8,7 +8,7 @@ const { nodeInfoStore, invoicesStore } = stores; export default async function(data: string): Promise { 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 [ diff --git a/views/Onboarding.tsx b/views/Onboarding.tsx index edd7a4ddf..737738aa0 100644 --- a/views/Onboarding.tsx +++ b/views/Onboarding.tsx @@ -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, diff --git a/views/PaymentRequest.tsx b/views/PaymentRequest.tsx index 04646041c..ae3a9260a 100644 --- a/views/PaymentRequest.tsx +++ b/views/PaymentRequest.tsx @@ -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} /> } diff --git a/views/Settings/AddEditNode.tsx b/views/Settings/AddEditNode.tsx index 1f4ac7133..c66cd9ed3 100644 --- a/views/Settings/AddEditNode.tsx +++ b/views/Settings/AddEditNode.tsx @@ -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';