From 39557b19558382a1ffd6857131f853e9a0e81cf6 Mon Sep 17 00:00:00 2001 From: Evan Kaloudis Date: Thu, 3 Oct 2024 14:12:20 -0400 Subject: [PATCH 1/9] deps: resolutions for @types/react @types/react-native --- package.json | 5 ++--- yarn.lock | 25 ++++++------------------- 2 files changed, 8 insertions(+), 22 deletions(-) diff --git a/package.json b/package.json index f86e1eb05..5c4c9ec3e 100644 --- a/package.json +++ b/package.json @@ -170,8 +170,6 @@ "@types/lodash": "4.14.198", "@types/object-hash": "1.3.4", "@types/pako": "2.0.3", - "@types/react": "18.2.21", - "@types/react-native": "0.73.0", "@types/react-native-vector-icons": "6.4.14", "@types/react-test-renderer": "18.0.2", "@types/sha.js": "2.4.1", @@ -199,7 +197,8 @@ "typescript": "4.8.4" }, "resolutions": { - "@types/react": "18.2.21" + "@types/react": "18.3.11", + "@types/react-native": "0.73.0" }, "react-native": { "zlib": "browserify-zlib", diff --git a/yarn.lock b/yarn.lock index d05b4c35c..a15f5c25d 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1694,7 +1694,7 @@ tslib "~2.2.0" "@lightninglabs/lnc-core@file:zeus_modules/@lightninglabs/lnc-core": - version "0.3.1-alpha" + version "0.3.2-alpha" "@ngraveio/bc-ur@1.1.12": version "1.1.12" @@ -2958,20 +2958,13 @@ "@types/react" "*" "@types/react-native" "^0.70" -"@types/react-native@*", "@types/react-native@0.73.0": +"@types/react-native@*", "@types/react-native@0.73.0", "@types/react-native@^0.70": version "0.73.0" resolved "https://registry.yarnpkg.com/@types/react-native/-/react-native-0.73.0.tgz#b316be230745779814caa533360262140b0f5984" integrity sha512-6ZRPQrYM72qYKGWidEttRe6M5DZBEV5F+MHMHqd4TTYx0tfkcdrUFGdef6CCxY0jXU7wldvd/zA/b0A/kTeJmA== dependencies: react-native "*" -"@types/react-native@^0.70": - version "0.70.19" - resolved "https://registry.yarnpkg.com/@types/react-native/-/react-native-0.70.19.tgz#b4e651dcf7f49c69ff3a4c3072584cad93155582" - integrity sha512-c6WbyCgWTBgKKMESj/8b4w+zWcZSsCforson7UdXtXMecG3MxCinYi6ihhrHVPyUrVzORsvEzK8zg32z4pK6Sg== - dependencies: - "@types/react" "*" - "@types/react-test-renderer@18.0.2": version "18.0.2" resolved "https://registry.yarnpkg.com/@types/react-test-renderer/-/react-test-renderer-18.0.2.tgz#44243977eec18ab8cda88d8977437f47a0d3fdbe" @@ -2979,20 +2972,14 @@ dependencies: "@types/react" "*" -"@types/react@*", "@types/react@18.2.21": - version "18.2.21" - resolved "https://registry.yarnpkg.com/@types/react/-/react-18.2.21.tgz#774c37fd01b522d0b91aed04811b58e4e0514ed9" - integrity sha512-neFKG/sBAwGxHgXiIxnbm3/AAVQ/cMRS93hvBpg8xYRbeQSPVABp9U2bRnPf0iI4+Ucdv3plSxKK+3CW2ENJxA== +"@types/react@*", "@types/react@18.3.11": + version "18.3.11" + resolved "https://registry.yarnpkg.com/@types/react/-/react-18.3.11.tgz#9d530601ff843ee0d7030d4227ea4360236bd537" + integrity sha512-r6QZ069rFTjrEYgFdOck1gK7FLVsgJE7tTz0pQBczlBNUhBNk0MQH4UbnFSwjpQLMkLzgqvBBa+qGpLje16eTQ== dependencies: "@types/prop-types" "*" - "@types/scheduler" "*" csstype "^3.0.2" -"@types/scheduler@*": - version "0.23.0" - resolved "https://registry.yarnpkg.com/@types/scheduler/-/scheduler-0.23.0.tgz#0a6655b3e2708eaabca00b7372fafd7a792a7b09" - integrity sha512-YIoDCTH3Af6XM5VuwGG/QL/CJqga1Zm3NkU3HZ4ZHK2fRMPYP1VczsTUqtsf43PH/iJNVlPHAo2oWX7BSdB2Hw== - "@types/semver@^7.3.12", "@types/semver@^7.5.0": version "7.5.8" resolved "https://registry.yarnpkg.com/@types/semver/-/semver-7.5.8.tgz#8268a8c57a3e4abd25c165ecd36237db7948a55e" From 3a74e32e7724113ddded513fdf12dc125d62b12a Mon Sep 17 00:00:00 2001 From: Evan Kaloudis Date: Thu, 3 Oct 2024 14:45:06 -0400 Subject: [PATCH 2/9] tsc: fix components Co-authored-by: shubham --- components/Amount.tsx | 8 +- components/AmountInput.tsx | 5 +- components/Button.tsx | 4 +- components/Channels/ChannelItem.tsx | 9 +- components/Channels/ChannelsFilter.tsx | 25 +- components/Channels/ChannelsHeader.tsx | 10 +- components/CopyBox.tsx | 2 +- components/DropdownSetting.tsx | 2 +- components/Header.tsx | 11 +- components/HopPicker.tsx | 2 +- .../LayerBalances/LightningSwipeableRow.tsx | 17 +- .../LayerBalances/OnchainSwipeableRow.tsx | 11 +- components/LayerBalances/index.tsx | 9 +- components/LightningIndicator.tsx | 2 +- components/ModalBox.tsx | 196 +++++++++--- components/Modals/AlertModal.tsx | 2 +- components/NodeIdenticon.tsx | 1 + components/OnchainFeeInput.tsx | 2 +- components/PaymentPath.tsx | 43 ++- components/SuccessErrorMessage.tsx | 2 +- components/SwipeButton.tsx | 30 +- components/TextInput.tsx | 289 +++++++++--------- components/WalletHeader.tsx | 6 +- components/text/Body.tsx | 9 +- stores/UnitsStore.ts | 1 + 25 files changed, 433 insertions(+), 265 deletions(-) diff --git a/components/Amount.tsx b/components/Amount.tsx index 9b8242b3d..5dfc49b74 100644 --- a/components/Amount.tsx +++ b/components/Amount.tsx @@ -36,6 +36,10 @@ interface AmountDisplayProps { accessibilityLabel?: string; } +interface FiatSymbolProps { + accessible?: boolean; +} + function AmountDisplay({ amount, unit, @@ -75,7 +79,7 @@ function AmountDisplay({ ); - const FiatSymbol = () => ( + const FiatSymbol: React.FC = ({ accessible }) => ( { const rate = fiat && fiatRates && fiatEntry ? fiatEntry.rate : 0; - let satAmount: string | number; + let satAmount: string | number = 0; switch (units) { case 'sats': satAmount = value; @@ -68,6 +68,9 @@ const getSatAmount = (amount: string | number) => { .toFixed(0) : 0; break; + default: + satAmount = 0; + break; } return satAmount; diff --git a/components/Button.tsx b/components/Button.tsx index 0c6030fe3..4fe505b9a 100644 --- a/components/Button.tsx +++ b/components/Button.tsx @@ -90,12 +90,12 @@ function Button(props: ButtonProps) { : warning ? themeColor('delete') : themeColor('text'), - ...buttonStyle + ...(buttonStyle as object) }} titleStyle={ titleStyle ? { - ...titleStyle, + ...(titleStyle as object), textTransform: noUppercase ? 'none' : 'uppercase', fontFamily: 'PPNeueMontreal-Book' } diff --git a/components/Channels/ChannelItem.tsx b/components/Channels/ChannelItem.tsx index 05a526fd9..50af0d411 100644 --- a/components/Channels/ChannelItem.tsx +++ b/components/Channels/ChannelItem.tsx @@ -33,8 +33,8 @@ export function ChannelItem({ }: { title?: string; secondTitle?: string; - inbound: number; - outbound: number; + inbound: string | number; + outbound: string | number; largestTotal?: number; status?: Status; pendingHTLCs?: boolean; @@ -79,7 +79,10 @@ export function ChannelItem({ } bold={selected} > - {PrivacyUtils.sensitiveValue(title)} + {`${ + typeof title === 'string' && + PrivacyUtils.sensitiveValue(title) + }`} )} diff --git a/components/Channels/ChannelsFilter.tsx b/components/Channels/ChannelsFilter.tsx index 9d90c12bc..0e7635736 100644 --- a/components/Channels/ChannelsFilter.tsx +++ b/components/Channels/ChannelsFilter.tsx @@ -102,20 +102,21 @@ const getChannelsSortKeys = (closed?: boolean) => { }; interface ChannelsFilterProps { - width?: string | number; + width?: number; } const ChannelsFilter = (props: ChannelsFilterProps) => { const { channelsStore } = stores; const { search, setSort, channelsType } = channelsStore; const windowWidth = Dimensions.get('window').width; + return ( - channelsStore!.setSearch(value) + onChangeText={(value?: string) => + channelsStore!.setSearch(value ?? '') } value={search} inputStyle={{ @@ -124,7 +125,7 @@ const ChannelsFilter = (props: ChannelsFilterProps) => { }} placeholderTextColor={themeColor('secondaryText')} containerStyle={{ - backgroundColor: null, + backgroundColor: 'transparent', borderTopWidth: 0, borderBottomWidth: 0, width: props.width || windowWidth - 55 @@ -134,6 +135,22 @@ const ChannelsFilter = (props: ChannelsFilterProps) => { backgroundColor: themeColor('secondary') }} autoCapitalize="none" + platform="default" + showLoading={false} + round={false} + lightTheme={false} + loadingProps={{}} + onClear={() => channelsStore!.setSearch('')} + onFocus={() => {}} + onBlur={() => {}} + onCancel={() => { + channelsStore!.setSearch(''); + }} + cancelButtonTitle="Cancel" + cancelButtonProps={{}} + searchIcon={{ name: 'search', type: 'font-awesome' }} + clearIcon={{ name: 'close', type: 'font-awesome' }} + showCancel={true} /> { diff --git a/components/Channels/ChannelsHeader.tsx b/components/Channels/ChannelsHeader.tsx index a5c21378c..4a45b672f 100644 --- a/components/Channels/ChannelsHeader.tsx +++ b/components/Channels/ChannelsHeader.tsx @@ -9,13 +9,19 @@ import { Spacer } from '../layout/Spacer'; import Amount from '../Amount'; import { localeString } from '../../utils/LocaleUtils'; +interface ChannelsHeaderProps { + totalInbound: number; + totalOutbound: number; + totalOffline: number; +} + function TotalRow({ kind, amount, color }: { kind: string; - amount: number; + amount: number | string; color: string; }) { return ( @@ -39,7 +45,7 @@ function TotalRow({ ); } -export function ChannelsHeader(props) { +export function ChannelsHeader(props: ChannelsHeaderProps) { const { totalInbound, totalOutbound, totalOffline } = props; return ( diff --git a/components/CopyBox.tsx b/components/CopyBox.tsx index 7664c79bf..a9de8b836 100644 --- a/components/CopyBox.tsx +++ b/components/CopyBox.tsx @@ -34,7 +34,7 @@ function CopyBox(props: CopyBoxProps) { : themeColor('background') }} onPress={() => { - Clipboard.setString(URL); + Clipboard.setString(URL || ''); setCopied(true); setCurrentTheme('light'); setTimeout(function () { diff --git a/components/DropdownSetting.tsx b/components/DropdownSetting.tsx index eff4f1382..9dbd4ac23 100644 --- a/components/DropdownSetting.tsx +++ b/components/DropdownSetting.tsx @@ -14,7 +14,7 @@ import { localeString } from './../utils/LocaleUtils'; interface DropdownSettingProps { title: string; - selectedValue: string | boolean; + selectedValue: string | number; onValueChange: (value: any) => void; values: Array; disabled?: boolean; diff --git a/components/Header.tsx b/components/Header.tsx index d8915e3e5..173cb66eb 100644 --- a/components/Header.tsx +++ b/components/Header.tsx @@ -1,10 +1,5 @@ import React from 'react'; -import { - StyleProp, - TextStyle, - ViewStyle, - TouchableOpacity -} from 'react-native'; +import { StyleProp, ViewStyle, TouchableOpacity } from 'react-native'; import { Header, TextProps } from 'react-native-elements'; import { IconObject } from 'react-native-elements/dist/icons/Icon'; @@ -19,7 +14,7 @@ interface HeaderIcon extends IconObject { icon?: string; text?: string; color?: string; - style?: StyleProp; + style?: StyleProp; } interface HeaderProps { @@ -31,7 +26,7 @@ interface HeaderProps { | 'Close'; centerComponent?: React.ReactElement<{}> | TextProps | HeaderIcon; rightComponent?: React.ReactElement<{}> | TextProps | HeaderIcon; - containerStyle?: ViewStyle; + containerStyle?: ViewStyle | any; placement?: 'left' | 'center' | 'right' | undefined; navigation?: StackNavigationProp; onBack?: () => void; diff --git a/components/HopPicker.tsx b/components/HopPicker.tsx index 3c10a1d28..a2d4e0c37 100644 --- a/components/HopPicker.tsx +++ b/components/HopPicker.tsx @@ -226,7 +226,7 @@ export default class ChannelPicker extends React.Component< )} - + ) => { const transTranslateX = progress.interpolate({ inputRange: [0.25, 1], @@ -130,7 +131,9 @@ export default class LightningSwipeableRow extends Component< ); }; - private renderActions = (progress: Animated.AnimatedInterpolation) => { + private renderActions = ( + progress: Animated.AnimatedInterpolation + ) => { const width = BackendUtils.supportsRouting() && BackendUtils.supportsLightningSends() && @@ -185,11 +188,15 @@ export default class LightningSwipeableRow extends Component< }; private close = () => { - this.swipeableRow.close(); + if (this.swipeableRow) { + this.swipeableRow.close(); + } }; private open = () => { - this.swipeableRow.openLeft(); + if (this.swipeableRow) { + this.swipeableRow.openLeft(); + } }; private fetchLnInvoice = () => { @@ -245,7 +252,7 @@ export default class LightningSwipeableRow extends Component< ); }); } else { - invoicesStore.getPayReq(this.props.lightning); + invoicesStore.getPayReq(lightning ?? ''); this.props.navigation.navigate('PaymentRequest', {}); } }; diff --git a/components/LayerBalances/OnchainSwipeableRow.tsx b/components/LayerBalances/OnchainSwipeableRow.tsx index f55095aa7..22ab3f70e 100644 --- a/components/LayerBalances/OnchainSwipeableRow.tsx +++ b/components/LayerBalances/OnchainSwipeableRow.tsx @@ -26,6 +26,7 @@ interface OnchainSwipeableRowProps { locked?: boolean; account?: string; hidden?: boolean; + children?: React.ReactNode; } export default class OnchainSwipeableRow extends Component< @@ -35,7 +36,7 @@ export default class OnchainSwipeableRow extends Component< private renderAction = ( text: string, x: number, - progress: Animated.AnimatedInterpolation + progress: Animated.AnimatedInterpolation ) => { const { account, navigation } = this.props; const transTranslateX = progress.interpolate({ @@ -120,7 +121,9 @@ export default class OnchainSwipeableRow extends Component< ); }; - private renderActions = (progress: Animated.AnimatedInterpolation) => ( + private renderActions = ( + progress: Animated.AnimatedInterpolation + ) => ( { - this.swipeableRow.close(); + if (this.swipeableRow) this.swipeableRow.close(); }; private open = () => { - this.swipeableRow.openLeft(); + if (this.swipeableRow) this.swipeableRow.openLeft(); }; private sendToAddress = () => { diff --git a/components/LayerBalances/index.tsx b/components/LayerBalances/index.tsx index 2842c8ca6..11bb8188a 100644 --- a/components/LayerBalances/index.tsx +++ b/components/LayerBalances/index.tsx @@ -58,7 +58,7 @@ type DataRow = { subtitle?: string; balance: string | number; // TODO check if exists - count: number; + count?: number; watchOnly?: boolean; hidden?: boolean; }; @@ -147,7 +147,7 @@ const Row = ({ item }: { item: DataRow }) => { color: themeColor('buttonText') }} > - {`+${item.count - 1}`} + {item.count && `+${item.count - 1}`} )} @@ -169,7 +169,7 @@ const SwipeableRow = ({ item: DataRow; index: number; navigation: StackNavigationProp; - selectMode: boolean; + // selectMode: boolean; // not used for now value?: string; amount?: string; lightning?: string; @@ -326,7 +326,8 @@ export default class LayerBalances extends Component { if (Object.keys(otherAccounts).length > 1 && consolidated) { DATA.push({ layer: localeString('components.LayerBalances.moreAccounts'), - count: Object.keys(otherAccounts).length + count: Object.keys(otherAccounts).length, + balance: 0 }); } diff --git a/components/LightningIndicator.tsx b/components/LightningIndicator.tsx index 8536bec00..dab16a2aa 100644 --- a/components/LightningIndicator.tsx +++ b/components/LightningIndicator.tsx @@ -1,7 +1,7 @@ import * as React from 'react'; import { Image } from 'react-native'; -import Loading from './../assets/images/GIF/Loading.gif'; +const Loading = require('../assets/images/GIF/Loading.gif'); interface LightningIndicatorProps { size?: number; diff --git a/components/ModalBox.tsx b/components/ModalBox.tsx index a851441ed..cc4d72595 100644 --- a/components/ModalBox.tsx +++ b/components/ModalBox.tsx @@ -14,7 +14,10 @@ import { BackHandler, Platform, Modal, - Keyboard + Keyboard, + ViewStyle, + StyleProp, + LayoutChangeEvent } from 'react-native'; const { @@ -40,7 +43,59 @@ const styles = StyleSheet.create({ } }); -export default class ModalBox extends React.PureComponent { +interface ModalBoxProps { + isOpen: boolean; + isDisabled?: boolean; + startOpen: boolean; + backdropPressToClose?: boolean; + swipeToClose?: boolean; + swipeThreshold?: number; + swipeArea?: number; + position?: string; + entry?: string; + backdrop?: boolean; + backdropOpacity?: number; + backdropColor?: string; + backdropContent?: React.ReactNode; + animationDuration?: number; + backButtonClose?: boolean; + easing?: (value: number) => number; + coverScreen?: boolean; + keyboardTopOffset?: number; + onClosed?: () => void; + onOpened?: () => void; + onClosingState?: (state: boolean) => void; + style?: StyleProp; + children?: React.ReactNode; + useNativeDriver?: boolean; + onLayout?: (event: LayoutChangeEvent) => void; +} + +interface ModalBoxState { + position: Animated.Value; + backdropOpacity: Animated.Value; + isOpen: boolean; + isAnimateClose: boolean; + isAnimateOpen: boolean; + swipeToClose: boolean; + height: number; + width: number; + containerHeight: number; + containerWidth: number; + isInitialized: boolean; + keyboardOffset: number; + pan: any; + isAnimateBackdrop: boolean; + animBackdrop?: Animated.CompositeAnimation; + animOpen?: Animated.CompositeAnimation; + animClose?: Animated.CompositeAnimation; + positionDest?: number; +} + +export default class ModalBox extends React.PureComponent< + ModalBoxProps, + ModalBoxState +> { static propTypes = { isOpen: PropTypes.bool, isDisabled: PropTypes.bool, @@ -62,7 +117,8 @@ export default class ModalBox extends React.PureComponent { keyboardTopOffset: PropTypes.number, onClosed: PropTypes.func, onOpened: PropTypes.func, - onClosingState: PropTypes.func + onClosingState: PropTypes.func, + children: PropTypes.node }; static defaultProps = { @@ -83,7 +139,10 @@ export default class ModalBox extends React.PureComponent { useNativeDriver: true }; - constructor(props: any) { + subscriptions: any[] = []; + onViewLayoutCalculated: (() => void) | null; // Can be either a function or null + + constructor(props: ModalBoxProps) { super(props); this.onBackPress = this.onBackPress.bind(this); @@ -113,7 +172,7 @@ export default class ModalBox extends React.PureComponent { this.state = { position, backdropOpacity: new Animated.Value(0), - isOpen: props.startOpen, + isOpen: props.startOpen || false, isAnimateClose: false, isAnimateOpen: false, swipeToClose: false, @@ -123,7 +182,12 @@ export default class ModalBox extends React.PureComponent { containerWidth: SCREEN_WIDTH, isInitialized: false, keyboardOffset: 0, - pan: this.createPanResponder(position) + pan: this.createPanResponder(position), + isAnimateBackdrop: false, + animBackdrop: undefined, + animOpen: undefined, + animClose: undefined, + positionDest: undefined }; // Needed for iOS because the keyboard covers the screen @@ -206,18 +270,18 @@ export default class ModalBox extends React.PureComponent { toValue: 1, duration: this.props.animationDuration, easing: this.props.easing, - useNativeDriver: this.props.useNativeDriver - }).start(() => { + useNativeDriver: this.props.useNativeDriver ?? true + }); + + this.setState({ animBackdrop }); + + animBackdrop.start(() => { this.setState({ - isAnimateBackdrop: false, - animBackdrop + isAnimateBackdrop: false }); }); } - /* - * Close animation for the backdrop, will fade out - */ animateBackdropClose() { if (this.state.isAnimateBackdrop && this.state.animBackdrop) { this.state.animBackdrop.stop(); @@ -228,11 +292,14 @@ export default class ModalBox extends React.PureComponent { toValue: 0, duration: this.props.animationDuration, easing: this.props.easing, - useNativeDriver: this.props.useNativeDriver - }).start(() => { + useNativeDriver: this.props.useNativeDriver ?? true + }); + + this.setState({ animBackdrop }); + + animBackdrop.start(() => { this.setState({ - isAnimateBackdrop: false, - animBackdrop + isAnimateBackdrop: false }); }); } @@ -265,27 +332,38 @@ export default class ModalBox extends React.PureComponent { requestAnimationFrame(() => { // Detecting modal position let positionDest = this.calculateModalPosition( - this.state.containerHeight - this.state.keyboardOffset, - this.state.containerWidth + this.state.containerHeight - this.state.keyboardOffset ); if ( this.state.keyboardOffset && - positionDest < this.props.keyboardTopOffset + positionDest !== undefined && + positionDest < (this.props.keyboardTopOffset ?? 0) ) { - positionDest = this.props.keyboardTopOffset; + positionDest = this.props.keyboardTopOffset ?? 0; } + + // Fallback for undefined positionDest + positionDest = positionDest ?? 0; + const animOpen = Animated.timing(this.state.position, { toValue: positionDest, duration: this.props.animationDuration, easing: this.props.easing, - useNativeDriver: this.props.useNativeDriver - }).start(() => { + useNativeDriver: this.props.useNativeDriver ?? true + }); + + this.setState({ animOpen }); + + animOpen.start(() => { this.setState({ isAnimateOpen: false, animOpen, positionDest }); - if (this.props.onOpened) this.props.onOpened(); + + if (this.props.onOpened) { + this.props.onOpened(); + } }); }); } @@ -324,9 +402,10 @@ export default class ModalBox extends React.PureComponent { : this.state.containerHeight, duration: this.props.animationDuration, easing: this.props.easing, - useNativeDriver: this.props.useNativeDriver - }).start(() => { - // Keyboard.dismiss(); // make this optional. Easily user defined in .onClosed() callback + useNativeDriver: this.props.useNativeDriver ?? true + }); + // Keyboard.dismiss(); // make this optional. Easily user defined in .onClosed() callback + animClose.start(() => { this.setState( { isAnimateClose: false, @@ -341,8 +420,8 @@ export default class ModalBox extends React.PureComponent { ); } ); - if (this.props.onClosed) this.props.onClosed(); }); + if (this.props.onClosed) this.props.onClosed(); } ); } @@ -370,14 +449,22 @@ export default class ModalBox extends React.PureComponent { createPanResponder(position: any) { let closingState = false; let inSwipeArea = false; + const { + swipeThreshold = 50, + entry, + swipeToClose, + isDisabled, + swipeArea, + onClosingState + } = this.props; const onPanStart = (evt: any) => { if ( - !this.props.swipeToClose || - this.props.isDisabled || - (this.props.swipeArea && - evt.nativeEvent.pageY - this.state.positionDest > - this.props.swipeArea) + !swipeToClose || + isDisabled || + (swipeArea && + this.state.positionDest != undefined && + evt.nativeEvent.pageY - this.state.positionDest > swipeArea) ) { inSwipeArea = false; return false; @@ -392,26 +479,25 @@ export default class ModalBox extends React.PureComponent { const onPanMove = (evt: any, state: any) => { const newClosingState = - this.props.entry === 'top' - ? -state.dy > this.props.swipeThreshold - : state.dy > this.props.swipeThreshold; - if (this.props.entry === 'top' ? state.dy > 0 : state.dy < 0) - return; - if (newClosingState != closingState && this.props.onClosingState) - this.props.onClosingState(newClosingState); + entry === 'top' + ? -state.dy > swipeThreshold + : state.dy > swipeThreshold; + if (entry === 'top' ? state.dy > 0 : state.dy < 0) return; + if (newClosingState != closingState && onClosingState) + onClosingState(newClosingState); closingState = newClosingState; state.customY = state.dy + this.state.positionDest; animEvt(evt, state); }; - const onPanRelease = (evt: any, state: any) => { + const onPanRelease = (_evt: any, state: any) => { if (!inSwipeArea) return; inSwipeArea = false; if ( - this.props.entry === 'top' - ? -state.dy > this.props.swipeThreshold - : state.dy > this.props.swipeThreshold + entry === 'top' + ? -state.dy > swipeThreshold + : state.dy > swipeThreshold ) { this.close(); } else if (!this.state.isOpen) { @@ -435,7 +521,10 @@ export default class ModalBox extends React.PureComponent { const width = evt.nativeEvent.layout.width; // If the dimensions are still the same we're done - const newState = {}; + const newState: { height: number; width: number } = { + height, + width + }; if (height !== this.state.height) newState.height = height; if (width !== this.state.width) newState.width = width; this.setState(newState); @@ -481,7 +570,7 @@ export default class ModalBox extends React.PureComponent { backdrop = ( } = this.props; const size = { height: this.state.containerHeight, width: this.state.containerWidth }; const offsetX = (this.state.containerWidth - this.state.width) / 2; + const customHeightStyle = + style && + typeof style === 'object' && + 'height' in style && + style.height + ? { height: (style.height as number) * FONT_SCALE } + : undefined; + return ( { ); }); - const ref = createRef(); + const ref = createRef(); return ( { ? PrivacyUtils.sensitiveValue( aliasMap.get(hop.pubKey) ) - : hop.node.length >= 66 + : typeof hop.node === 'string' && + hop.node.length >= 66 ? `${ - PrivacyUtils.sensitiveValue( + typeof PrivacyUtils.sensitiveValue( hop.node - ).slice(0, 14) + - '...' + - PrivacyUtils.sensitiveValue( + ) === 'string' + ? ( + PrivacyUtils.sensitiveValue( + hop.node + ) as string + ).slice(0, 14) + : '' + }...${ + typeof PrivacyUtils.sensitiveValue( hop.node - ).slice(-14) + ) === 'string' + ? ( + PrivacyUtils.sensitiveValue( + hop.node + ) as string + ).slice(-14) + : '' }` - : PrivacyUtils.sensitiveValue(hop.node) + : typeof PrivacyUtils.sensitiveValue( + hop.node + ) === 'string' + ? PrivacyUtils.sensitiveValue(hop.node) + : '' }`} )} @@ -247,13 +264,13 @@ export default class PaymentPath extends React.Component< path.forEach((hop) => { const displayName = aliasMap.get(hop.pubKey) || hop.node; title += ', '; + const sensitiveDisplayName = + PrivacyUtils.sensitiveValue(displayName); title += - displayName.length >= 66 - ? `${PrivacyUtils.sensitiveValue(displayName).slice( - 0, - 6 - )}...` - : PrivacyUtils.sensitiveValue(displayName); + typeof sensitiveDisplayName === 'string' && + sensitiveDisplayName.length >= 66 + ? `${(sensitiveDisplayName as string).slice(0, 6)}...` + : sensitiveDisplayName ?? ''; }); if (enhancedPath.length > 1) { hops.push( diff --git a/components/SuccessErrorMessage.tsx b/components/SuccessErrorMessage.tsx index b59bdd386..c7b1d1737 100644 --- a/components/SuccessErrorMessage.tsx +++ b/components/SuccessErrorMessage.tsx @@ -20,7 +20,7 @@ const Message = ({ onPress }: MessageProps) => { const [isDismissed, setDismissed] = useState(false); - if (isDismissed) return; + if (isDismissed) return <>; return onPress ? ( = ({ extrapolate: 'clamp' }); + const [offset, setOffset] = useState(0); + const panResponder = useRef( PanResponder.create({ onStartShouldSetPanResponder: () => true, onPanResponderGrant: () => { - pan.setOffset(pan._value); + pan.setOffset(offset); pan.setValue(0); }, - onPanResponderMove: (e, gesture) => { + onPanResponderMove: (_e, gesture) => { const newValue = gesture.dx; if (newValue >= 0 && newValue <= maxTranslation) { pan.setValue(newValue); } }, onPanResponderRelease: ( - e: GestureResponderEvent, + _e: GestureResponderEvent, gesture: PanResponderGestureState ) => { - if (gesture.dx > maxTranslation * 0.95) { + const finalValue = + gesture.dx > maxTranslation * 0.95 ? maxTranslation : 0; + if (finalValue === maxTranslation) { onSwipeSuccess(); - Animated.spring(pan, { - toValue: maxTranslation, - useNativeDriver: false - }).start(); - } else { - Animated.spring(pan, { - toValue: 0, - useNativeDriver: false - }).start(); } + + Animated.spring(pan, { + toValue: finalValue, + useNativeDriver: false + }).start(() => { + setOffset(finalValue); + }); } }) ).current; diff --git a/components/TextInput.tsx b/components/TextInput.tsx index 728819cc4..adaeab29b 100644 --- a/components/TextInput.tsx +++ b/components/TextInput.tsx @@ -1,5 +1,6 @@ import * as React from 'react'; import { + KeyboardTypeOptions, StyleProp, StyleSheet, Text, @@ -20,8 +21,8 @@ interface TextInputProps { textInputStyle?: StyleProp; placeholderTextColor?: string; locked?: boolean; - keyboardType?: string; - autoCapitalize?: string; + keyboardType?: KeyboardTypeOptions; + autoCapitalize?: 'none' | 'sentences' | 'words' | 'characters'; autoCorrect?: boolean; multiline?: boolean; autoFocus?: boolean; @@ -36,152 +37,154 @@ interface TextInputProps { error?: boolean; } -const TextInput: React.FC = ( - { - placeholder, - value, - onChangeText, - numberOfLines, - style, - textInputStyle, - placeholderTextColor, - locked, - keyboardType, - autoCapitalize, - autoCorrect, - multiline, - autoFocus, - secureTextEntry, - prefix, - prefixStyle, - suffix, - toggleUnits, - onPressIn, - right, - error - }, - ref -) => { - const defaultStyle = numberOfLines - ? { - paddingTop: 10 - } - : multiline - ? {} - : { - height: 60 - }; +const TextInput = React.forwardRef( + ( + { + placeholder, + value, + onChangeText, + numberOfLines, + style, + textInputStyle, + placeholderTextColor, + locked, + keyboardType, + autoCapitalize, + autoCorrect, + multiline, + autoFocus, + secureTextEntry, + prefix, + prefixStyle, + suffix, + toggleUnits, + onPressIn, + right, + error + }, + ref + ) => { + const defaultStyle = numberOfLines + ? { + paddingTop: 10 + } + : multiline + ? {} + : { + height: 60 + }; - const Prefix = () => ( - - {prefix} - - ); + const Prefix = () => ( + + {prefix} + + ); - const Suffix = () => ( - - {suffix} - - ); + const Suffix = () => ( + + {suffix} + + ); - return ( - - {prefix ? ( - toggleUnits ? ( - toggleUnits && toggleUnits()} - > - - - ) : ( - - ) - ) : null} - - {suffix ? ( - toggleUnits ? ( - toggleUnits && toggleUnits()} - > + > + {prefix ? ( + toggleUnits ? ( + toggleUnits && toggleUnits()} + > + + + ) : ( + + ) + ) : null} + + {suffix ? ( + toggleUnits ? ( + toggleUnits && toggleUnits()} + > + + + ) : ( - - ) : ( - - ) - ) : null} - - ); -}; + ) + ) : null} + + ); + } +); const styles = StyleSheet.create({ wrapper: { @@ -205,4 +208,4 @@ const styles = StyleSheet.create({ } }); -export default React.forwardRef(TextInput); +export default TextInput; diff --git a/components/WalletHeader.tsx b/components/WalletHeader.tsx index ad8fe2bef..0f8237dc7 100644 --- a/components/WalletHeader.tsx +++ b/components/WalletHeader.tsx @@ -406,7 +406,7 @@ export default class WalletHeader extends React.Component< const AlertButton = () => ( ModalStore.toggleAlertModal(true)} + onPress={() => ModalStore?.toggleAlertModal(true)} accessibilityLabel={localeString('general.search')} > )} - {!loading && AlertStore.hasError && } + {!loading && AlertStore?.hasError && ( + + )} {posEnabled === PosEnabled.Disabled && ( diff --git a/components/text/Body.tsx b/components/text/Body.tsx index 3ca651df8..a49bb6cad 100644 --- a/components/text/Body.tsx +++ b/components/text/Body.tsx @@ -25,7 +25,14 @@ export function Body({ // These should only be keys available on the theme // TODO: enforce this with some global ThemeKey enum? colorOverride?: string; - color?: 'text' | 'success' | 'warning' | 'highlight' | 'secondaryText'; + color?: + | 'text' + | 'success' + | 'warning' + | 'highlight' + | 'secondaryText' + | 'outbound' + | 'inbound'; children: React.ReactNode; accessible?: boolean; accessibilityLabel?: string; diff --git a/stores/UnitsStore.ts b/stores/UnitsStore.ts index 9be68fe87..38b733408 100644 --- a/stores/UnitsStore.ts +++ b/stores/UnitsStore.ts @@ -20,6 +20,7 @@ interface ValueDisplayProps { plural?: boolean; rtl?: boolean; space?: boolean; + error?: boolean; } export default class UnitsStore { From fc6217e8f39d4a88549b066277792063deda4589 Mon Sep 17 00:00:00 2001 From: Evan Kaloudis Date: Thu, 3 Oct 2024 15:09:31 -0400 Subject: [PATCH 3/9] tsc: fix assets --- assets/images/SVG/DynamicSVG/AddressSvg.tsx | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/assets/images/SVG/DynamicSVG/AddressSvg.tsx b/assets/images/SVG/DynamicSVG/AddressSvg.tsx index 5ac54345f..71d54e32f 100644 --- a/assets/images/SVG/DynamicSVG/AddressSvg.tsx +++ b/assets/images/SVG/DynamicSVG/AddressSvg.tsx @@ -1,5 +1,5 @@ import React from 'react'; -import { Svg, Circle, Path } from 'react-native-svg'; +import { Svg, Circle, Path, Linecap, Linejoin } from 'react-native-svg'; import { themeColor } from '../../../../utils/ThemeUtils'; export default function AddressSvg({ circle = true, selected = false }) { @@ -18,7 +18,13 @@ export default function AddressSvg({ circle = true, selected = false }) { fill: themeColor('background') }; - const pathProps = { + const pathProps: { + d: string; + stroke: string; + strokeLinecap: Linecap; + strokeLinejoin: Linejoin; + strokeWidth: string; + } = { d: 'M29 25C29 27.209 27.209 29 25 29 22.791 29 21 27.209 21 25 21 22.791 22.791 21 25 21 27.209 21 29 22.791 29 25ZM29 25V26.5C29 27.881 30.119 29 31.5 29V29C32.881 29 34 27.881 34 26.5V25C34 20.029 29.971 16 25 16 20.029 16 16 20.029 16 25 16 29.971 20.029 34 25 34H29', stroke: selected ? themeColor('background') : themeColor('bolt'), strokeLinecap: 'round', From e4e33461ec2ac8ae3a9542df0d0a17d12d4fb89c Mon Sep 17 00:00:00 2001 From: Evan Kaloudis Date: Thu, 3 Oct 2024 15:13:36 -0400 Subject: [PATCH 4/9] tsconfig: ignore zeus_modules --- tsconfig.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tsconfig.json b/tsconfig.json index 6c66cfd0b..6675f9f1c 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -21,6 +21,6 @@ "*" : ["typings/*"] } }, - "exclude": ["node_modules"], + "exclude": ["node_modules", "zeus_modules"], "include": ["**/*.ts", "**/*.tsx"] } From 35f114c4a24ce6a3b2af4ccfe8b9d42e3f7bbe5b Mon Sep 17 00:00:00 2001 From: Evan Kaloudis Date: Thu, 3 Oct 2024 15:27:10 -0400 Subject: [PATCH 5/9] tsc: fix models --- models/Channel.ts | 2 +- models/ChannelInfo.ts | 8 ++++---- models/ClosedChannel.ts | 3 --- models/Invoice.ts | 4 +++- models/Payment.ts | 25 ++++++++++++------------- models/Transaction.ts | 4 ++-- 6 files changed, 22 insertions(+), 24 deletions(-) diff --git a/models/Channel.ts b/models/Channel.ts index e4b04faef..9a18679ef 100644 --- a/models/Channel.ts +++ b/models/Channel.ts @@ -121,7 +121,7 @@ export default class Channel extends BaseModel { @computed public get remotePubkey(): string { - return this.remote_pubkey || this.remote_node_pub; + return this.remote_pubkey || this.remote_node_pub || ''; } @computed diff --git a/models/ChannelInfo.ts b/models/ChannelInfo.ts index b75c0398f..199806cc2 100644 --- a/models/ChannelInfo.ts +++ b/models/ChannelInfo.ts @@ -28,22 +28,22 @@ export default class ChannelInfo extends BaseModel { node_2_policy?: RoutingPolicy; @computed - public get node1Policy(): RoutingPolicy { + public get node1Policy(): RoutingPolicy | undefined { return this.node_1_policy || this.node1_policy; } @computed - public get node2Policy(): RoutingPolicy { + public get node2Policy(): RoutingPolicy | undefined { return this.node_2_policy || this.node2_policy; } @computed public get node1Pub(): string { - return this.node_1_pub || this.node1_pub; + return this.node_1_pub || this.node1_pub || ''; } @computed public get node2Pub(): string { - return this.node_2_pub || this.node2_pub; + return this.node_2_pub || this.node2_pub || ''; } } diff --git a/models/ClosedChannel.ts b/models/ClosedChannel.ts index a1f0ce469..51c81626f 100644 --- a/models/ClosedChannel.ts +++ b/models/ClosedChannel.ts @@ -9,10 +9,7 @@ export default class ClosedChannel extends Channel { settled_balance: string; time_lock_balance: string; close_time: number; - open_initiator: any; - close_initiator: any; resolutions: any; - remote_node_pub: string; close_type: string; closing_txid: string; diff --git a/models/Invoice.ts b/models/Invoice.ts index e7f4d5569..fda762a0e 100644 --- a/models/Invoice.ts +++ b/models/Invoice.ts @@ -77,6 +77,8 @@ export default class Invoice extends BaseModel { public millisatoshis?: string; public pay_req?: string; + public amount_received_msat?: string | number; + public formattedOriginalTimeUntilExpiry: string; public formattedTimeUntilExpiry: string; @@ -143,7 +145,7 @@ export default class Invoice extends BaseModel { } @computed public get getPaymentRequest(): string { - return this.bolt11 || this.payment_request || this.pay_req; + return this.bolt11 || this.payment_request || this.pay_req || ''; } // return amount in satoshis diff --git a/models/Payment.ts b/models/Payment.ts index 94da08d31..487411864 100644 --- a/models/Payment.ts +++ b/models/Payment.ts @@ -10,6 +10,11 @@ import Bolt11Utils from '../utils/Bolt11Utils'; import Base64Utils from '../utils/Base64Utils'; import { lnrpc } from '../proto/lightning'; +interface preimageBuffer { + data: Array; + type: string; +} + export default class Payment extends BaseModel { private payment_hash: string | { data: number[]; type: string }; // object if lndhub creation_date?: string; @@ -32,7 +37,7 @@ export default class Payment extends BaseModel { msatoshi?: string; created_at?: string; timestamp?: string; - preimage: string; + preimage: any | preimageBuffer; bolt11?: string; htlcs?: Array; nodes?: any; @@ -93,19 +98,13 @@ export default class Payment extends BaseModel { } @computed public get getPreimage(): string { - if (this.preimage) { - if (this.preimage?.type === 'Buffer') { - this.preimage = Base64Utils.bytesToHex(this.preimage.data); - } - return this.preimage; - } - if (this.payment_preimage) { - if (this.payment_preimage?.type === 'Buffer') { - this.payment_preimage = Base64Utils.bytesToHex( - this.payment_preimage.data - ); + const preimage = this.preimage || this.payment_preimage; + if (preimage) { + if (typeof preimage !== 'string' && preimage.data) { + return Base64Utils.bytesToHex(preimage.data); + } else if (typeof preimage === 'string') { + return preimage; } - return this.payment_preimage; } return ''; } diff --git a/models/Transaction.ts b/models/Transaction.ts index 77d19594d..9d0b3dcd0 100644 --- a/models/Transaction.ts +++ b/models/Transaction.ts @@ -108,9 +108,9 @@ export default class Transaction extends BaseModel { : new BigNumber(amount).plus(this.getFee).toString(); } - @computed public get getBlockHeight(): string | boolean { + @computed public get getBlockHeight(): string { const block_height = this.blockheight || this.block_height; - return block_height ? block_height.toString() : false; + return block_height ? block_height.toString() : ''; } @computed public get tx(): string { From e8a68719beb6430a67aa26276afa9e5400fca290 Mon Sep 17 00:00:00 2001 From: Evan Kaloudis Date: Thu, 3 Oct 2024 15:38:49 -0400 Subject: [PATCH 6/9] tsc: fix utils --- stores/LightningAddressStore.ts | 1 + stores/LnurlPayStore.ts | 1 + utils/DataFormatUtils.ts | 6 +++--- utils/ErrorUtils.test.ts | 8 ++++---- utils/EventListenerUtils.ts | 6 ++++-- utils/LndMobileUtils.ts | 8 ++++++-- utils/NFCUtils.ts | 4 ++-- utils/UrlUtils.ts | 7 ++++--- utils/handleAnything.ts | 1 + views/NostrContacts.tsx | 1 + 10 files changed, 27 insertions(+), 16 deletions(-) diff --git a/stores/LightningAddressStore.ts b/stores/LightningAddressStore.ts index 9c610ba5f..231c245c3 100644 --- a/stores/LightningAddressStore.ts +++ b/stores/LightningAddressStore.ts @@ -10,6 +10,7 @@ import { io } from 'socket.io-client'; import { schnorr } from '@noble/curves/secp256k1'; import { bytesToHex } from '@noble/hashes/utils'; import hashjs from 'hash.js'; +// @ts-ignore:next-line import { getPublicKey, relayInit } from 'nostr-tools'; const bip39 = require('bip39'); diff --git a/stores/LnurlPayStore.ts b/stores/LnurlPayStore.ts index 2b21435a8..788b30dea 100644 --- a/stores/LnurlPayStore.ts +++ b/stores/LnurlPayStore.ts @@ -9,6 +9,7 @@ import { finishEvent, generatePrivateKey, getPublicKey, + // @ts-ignore:next-line relayInit } from 'nostr-tools'; diff --git a/utils/DataFormatUtils.ts b/utils/DataFormatUtils.ts index 23076065c..08aba00e5 100644 --- a/utils/DataFormatUtils.ts +++ b/utils/DataFormatUtils.ts @@ -4,9 +4,9 @@ import isObject from 'lodash/isObject'; import transform from 'lodash/transform'; // change responses from camel-case to snake-case -const snakeize = (obj) => - transform(obj, (acc, value, key, target) => { - const snakeKey = isArray(target) ? key : snakeCase(key); +const snakeize = (obj: any) => + transform(obj, (acc: any, value, key, target) => { + const snakeKey = isArray(target) ? key : snakeCase(key.toString()); acc[snakeKey] = isObject(value) ? snakeize(value) : value; }); diff --git a/utils/ErrorUtils.test.ts b/utils/ErrorUtils.test.ts index b9daec985..d0711c42f 100644 --- a/utils/ErrorUtils.test.ts +++ b/utils/ErrorUtils.test.ts @@ -104,15 +104,15 @@ describe('ErrorUtils', () => { }); it('Return string if error is sent as a string', () => { - expect(errorToUserFriendly('Payment timed out', false)).toEqual( - 'Payment timed out' - ); + expect( + errorToUserFriendly(new Error('Payment timed out'), false) + ).toEqual('Payment timed out'); }); it('Handles PascalCased LSP error messages', () => { expect( errorToUserFriendly( - 'ChannelExpiryBlocksTooHighInCreateOrderRequest', + new Error('ChannelExpiryBlocksTooHighInCreateOrderRequest'), false ) ).toEqual('Channel expiry blocks too high in create order request'); diff --git a/utils/EventListenerUtils.ts b/utils/EventListenerUtils.ts index 893bc6f71..8ebff9ebc 100644 --- a/utils/EventListenerUtils.ts +++ b/utils/EventListenerUtils.ts @@ -8,9 +8,11 @@ import { export const LndMobileEventEmitter = Platform.OS == 'android' ? DeviceEventEmitter - : new NativeEventEmitter(NativeModules.LndMobile); + : // @ts-ignore:next-line + new NativeEventEmitter(NativeModules.LndMobile); export const LndMobileToolsEventEmitter = Platform.OS == 'android' ? DeviceEventEmitter - : new NativeEventEmitter(NativeModules.LndMobileTools); + : // @ts-ignore:next-line + new NativeEventEmitter(NativeModules.LndMobileTools); diff --git a/utils/LndMobileUtils.ts b/utils/LndMobileUtils.ts index ef3fa3ae2..0c2ba1475 100644 --- a/utils/LndMobileUtils.ts +++ b/utils/LndMobileUtils.ts @@ -8,6 +8,8 @@ import DeviceInfo from 'react-native-device-info'; import { generateSecureRandom } from 'react-native-securerandom'; import NetInfo from '@react-native-community/netinfo'; + +// @ts-ignore:next-line import Ping from 'react-native-ping'; import Log from '../lndmobile/log'; @@ -46,12 +48,14 @@ const NEUTRINO_PERSISTENT_FILTER_THRESHOLD = 400000000; export const LndMobileEventEmitter = Platform.OS == 'android' ? DeviceEventEmitter - : new NativeEventEmitter(NativeModules.LndMobile); + : // @ts-ignore:next-line + new NativeEventEmitter(NativeModules.LndMobile); export const LndMobileToolsEventEmitter = Platform.OS == 'android' ? DeviceEventEmitter - : new NativeEventEmitter(NativeModules.LndMobileTools); + : // @ts-ignore:next-line + new NativeEventEmitter(NativeModules.LndMobileTools); export function checkLndStreamErrorResponse( name: string, diff --git a/utils/NFCUtils.ts b/utils/NFCUtils.ts index aad411c7d..61dc95461 100644 --- a/utils/NFCUtils.ts +++ b/utils/NFCUtils.ts @@ -5,9 +5,9 @@ class NFCUtils { let str = ''; for (let index = 0; index < count; ) { - const ch = data[index++]; + let ch = data[index++]; if (ch & 0x80) { - const extra = extraByteMap[(ch >> 3) & 0x07]; + let extra = extraByteMap[(ch >> 3) & 0x07]; if (!(ch & 0x40) || !extra || index + extra > count) { return null; } diff --git a/utils/UrlUtils.ts b/utils/UrlUtils.ts index 6f3a767ab..213977bca 100644 --- a/utils/UrlUtils.ts +++ b/utils/UrlUtils.ts @@ -9,9 +9,10 @@ const goToBlockExplorer = ( const { settings } = stores.settingsStore; const { privacy } = settings; const custom = privacy && privacy.defaultBlockExplorer === 'Custom'; - const host = custom - ? privacy.customBlockExplorer - : (privacy && privacy.defaultBlockExplorer) || 'mempool.space'; + const host = + custom && privacy.customBlockExplorer + ? privacy.customBlockExplorer + : (privacy && privacy.defaultBlockExplorer) || 'mempool.space'; const network = stores.nodeInfoStore.nodeInfo.isTestNet || testnet ? 'testnet/' : ''; diff --git a/utils/handleAnything.ts b/utils/handleAnything.ts index a82823e7a..32eb754a4 100644 --- a/utils/handleAnything.ts +++ b/utils/handleAnything.ts @@ -12,6 +12,7 @@ import BackendUtils from './BackendUtils'; // Nostr import { DEFAULT_NOSTR_RELAYS } from '../stores/SettingsStore'; +// @ts-ignore:next-line import { relayInit, nip05, nip19 } from 'nostr-tools'; import ContactUtils from './ContactUtils'; diff --git a/views/NostrContacts.tsx b/views/NostrContacts.tsx index 03c0fe4f9..393a85ac9 100644 --- a/views/NostrContacts.tsx +++ b/views/NostrContacts.tsx @@ -12,6 +12,7 @@ import { import { inject, observer } from 'mobx-react'; import { CheckBox, Icon } from 'react-native-elements'; import EncryptedStorage from 'react-native-encrypted-storage'; +// @ts-ignore:next-line import { relayInit, nip05, nip19 } from 'nostr-tools'; import { StackNavigationProp } from '@react-navigation/stack'; From c380fe81f4bd00b39d6c20d45fdcdfe2b04e66eb Mon Sep 17 00:00:00 2001 From: Evan Kaloudis Date: Thu, 3 Oct 2024 15:41:38 -0400 Subject: [PATCH 7/9] tsc: fix PushNotificationManager --- PushNotificationManager.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/PushNotificationManager.tsx b/PushNotificationManager.tsx index 323de0246..0eaf5576e 100644 --- a/PushNotificationManager.tsx +++ b/PushNotificationManager.tsx @@ -3,7 +3,7 @@ import { Alert, Platform, View } from 'react-native'; import { Notifications } from 'react-native-notifications'; import stores from './stores/Stores'; -export default class PushNotificationManager extends React.Component { +export default class PushNotificationManager extends React.Component { componentDidMount() { if (Platform.OS === 'ios') Notifications.ios.setBadgeCount(0); this.registerDevice(); @@ -70,7 +70,7 @@ export default class PushNotificationManager extends React.Component { ); Notifications.events().registerNotificationReceivedBackground( - (notification, completion) => { + (notification, completion: any) => { console.log('Notification Received - Background', notification); // Calling completion on iOS with `alert: true` will present the native iOS inApp notification. completion({ alert: true, sound: true, badge: false }); From 6dd2a9bf7ab759c7fc810e9e68c6f4a8f738c5b5 Mon Sep 17 00:00:00 2001 From: Evan Kaloudis Date: Thu, 3 Oct 2024 15:43:56 -0400 Subject: [PATCH 8/9] tsc: fix check-styles --- check-styles.test.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/check-styles.test.ts b/check-styles.test.ts index 0620d99d4..caaeb4f1e 100644 --- a/check-styles.test.ts +++ b/check-styles.test.ts @@ -11,13 +11,14 @@ describe('static style sheets', () => { const tsxFiles = dirs.flatMap((dir) => fs .readdirSync(dir, { recursive: dir !== '.' }) + // @ts-ignore:next-line .filter( - (file) => + (file: any) => typeof file === 'string' && !file.startsWith('node_modules/') && file.toLowerCase().endsWith('.tsx') ) - .map((file) => path.join(dir, file as string)) + .map((file: any) => path.join(dir, file as string)) ); const regExp = new RegExp( /\n[^\s][^\n]+StyleSheet\.create\(\{.*themeColor\(/, From 19af3147fa6a3f70c53d761a53d6a1cdff04f837 Mon Sep 17 00:00:00 2001 From: Evan Kaloudis Date: Thu, 3 Oct 2024 16:22:29 -0400 Subject: [PATCH 9/9] tsc: fix stores --- models/OpenChannelRequest.ts | 2 +- stores/ActivityStore.ts | 2 +- stores/AlertStore.ts | 1 + stores/BalanceStore.ts | 8 ++++---- stores/ChannelBackupStore.ts | 3 ++- stores/ChannelsStore.ts | 14 +++++++------- stores/LightningAddressStore.ts | 4 +++- stores/LnurlPayStore.ts | 3 +++ stores/TransactionsStore.ts | 4 +++- stores/UnitsStore.ts | 10 ++++++++-- 10 files changed, 33 insertions(+), 18 deletions(-) diff --git a/models/OpenChannelRequest.ts b/models/OpenChannelRequest.ts index e9a68c58d..8ea8a22b0 100644 --- a/models/OpenChannelRequest.ts +++ b/models/OpenChannelRequest.ts @@ -20,7 +20,7 @@ export default class OpenChannelRequest extends BaseModel { public private?: boolean; public min_htlc_msat?: string; public local_funding_amount: string; - public host: string; + public host?: string; public id?: string; public satoshis?: string; public utxos?: string[]; diff --git a/stores/ActivityStore.ts b/stores/ActivityStore.ts index af7d501b2..03a83c1f5 100644 --- a/stores/ActivityStore.ts +++ b/stores/ActivityStore.ts @@ -212,7 +212,7 @@ export default class ActivityStore { } @action - public setFilters = async (filters: Filter, locale: string | undefined) => { + public setFilters = async (filters: Filter, locale?: string) => { this.loading = true; this.filters = filters; this.filteredActivity = ActivityFilterUtils.filterActivities( diff --git a/stores/AlertStore.ts b/stores/AlertStore.ts index 0f2935a21..3a9947e9a 100644 --- a/stores/AlertStore.ts +++ b/stores/AlertStore.ts @@ -1,4 +1,5 @@ import { action, reaction, observable } from 'mobx'; +// @ts-ignore:next-line import Ping from 'react-native-ping'; import SettingsStore from './SettingsStore'; diff --git a/stores/BalanceStore.ts b/stores/BalanceStore.ts index 266c270ff..9c5ef432a 100644 --- a/stores/BalanceStore.ts +++ b/stores/BalanceStore.ts @@ -25,8 +25,8 @@ export default class BalanceStore { () => this.settingsStore.settings, () => { if (this.settingsStore.hasCredentials()) { - this.getBlockchainBalance(); - this.getLightningBalance(); + this.getBlockchainBalance(false, false); + this.getLightningBalance(false); } } ); @@ -147,8 +147,8 @@ export default class BalanceStore { @action public getCombinedBalance = async (reset: boolean = false) => { if (reset) this.reset(); - const lightning = await this.getLightningBalance(); - const onChain = await this.getBlockchainBalance(); + const lightning = await this.getLightningBalance(false); + const onChain = await this.getBlockchainBalance(false, false); // LN this.pendingOpenBalance = diff --git a/stores/ChannelBackupStore.ts b/stores/ChannelBackupStore.ts index f0c7ae7af..8f2ae72a9 100644 --- a/stores/ChannelBackupStore.ts +++ b/stores/ChannelBackupStore.ts @@ -325,7 +325,8 @@ export default class ChannelBackupStore { if (time) { const ONE_HOUR = 60 * 60 * 1000; /* ms */ const THREE_DAYS = 36 * ONE_HOUR; - const olderThanThreeDays = new Date() - new Date(time) > THREE_DAYS; + const olderThanThreeDays = + Number(new Date()) - Number(new Date(time)) > THREE_DAYS; if (olderThanThreeDays) this.backupChannels(); } if (!time && !status) this.backupChannels(); diff --git a/stores/ChannelsStore.ts b/stores/ChannelsStore.ts index 224e9a779..bb37072c5 100644 --- a/stores/ChannelsStore.ts +++ b/stores/ChannelsStore.ts @@ -23,12 +23,12 @@ interface ChannelInfoIndex { interface PendingHTLC { incoming: boolean; - amount: number; + amount: number | string; hash_lock: string; expiration_height: number; - htlc_index: number; - forwarding_channel: number; - forwarding_htlc_index: number; + htlc_index?: number; + forwarding_channel?: number; + forwarding_htlc_index?: number; } export enum ChannelsType { @@ -303,8 +303,8 @@ export default class ChannelsStore { enrichChannels = async ( channels: Array, setPendingHtlcs?: boolean - ) => { - if (channels.length === 0) return; + ): Promise => { + if (channels.length === 0) return []; const channelsWithMissingAliases = channels?.filter( (c) => c.channelId != null && this.aliasesById[c.channelId] == null @@ -498,7 +498,7 @@ export default class ChannelsStore { ) { // c-lightning, eclair urlParams = [channelId, forceClose]; - } else { + } else if (channelPoint) { // lnd const { funding_txid_str, output_index } = channelPoint; diff --git a/stores/LightningAddressStore.ts b/stores/LightningAddressStore.ts index 231c245c3..7910f6040 100644 --- a/stores/LightningAddressStore.ts +++ b/stores/LightningAddressStore.ts @@ -761,7 +761,7 @@ export default class LightningAddressStore { } ]); - events.map((event) => { + events.map((event: any) => { attestationEvents[event.id] = event; }); @@ -937,6 +937,7 @@ export default class LightningAddressStore { const title = 'ZEUS Pay payment received!'; const body = `Payment of ${value_commas} sats automatically accepted`; if (Platform.OS === 'android') { + // @ts-ignore:next-line Notifications.postLocalNotification({ title, body @@ -944,6 +945,7 @@ export default class LightningAddressStore { } if (Platform.OS === 'ios') { + // @ts-ignore:next-line Notifications.postLocalNotification({ title, body, diff --git a/stores/LnurlPayStore.ts b/stores/LnurlPayStore.ts index 788b30dea..79345621d 100644 --- a/stores/LnurlPayStore.ts +++ b/stores/LnurlPayStore.ts @@ -6,8 +6,11 @@ import { hexToBytes } from '@noble/hashes/utils'; import hashjs from 'hash.js'; import { nip19, + // @ts-ignore:next-line finishEvent, + // @ts-ignore:next-line generatePrivateKey, + // @ts-ignore:next-line getPublicKey, // @ts-ignore:next-line relayInit diff --git a/stores/TransactionsStore.ts b/stores/TransactionsStore.ts index 587f24099..577e37ba0 100644 --- a/stores/TransactionsStore.ts +++ b/stores/TransactionsStore.ts @@ -529,7 +529,9 @@ export default class TransactionsStore { this.payment_error = (implementation === 'embedded-lnd' ? errorToUserFriendly( - lnrpc.PaymentFailureReason[result.failure_reason] + new Error( + lnrpc.PaymentFailureReason[result.failure_reason] + ) ) : errorToUserFriendly(result.failure_reason)) || errorToUserFriendly(result.payment_error); diff --git a/stores/UnitsStore.ts b/stores/UnitsStore.ts index 38b733408..abc6a7ea5 100644 --- a/stores/UnitsStore.ts +++ b/stores/UnitsStore.ts @@ -20,7 +20,7 @@ interface ValueDisplayProps { plural?: boolean; rtl?: boolean; space?: boolean; - error?: boolean; + error?: string; } export default class UnitsStore { @@ -118,6 +118,8 @@ export default class UnitsStore { if (!fiatEntry?.rate) { return { + amount: 'Disabled', + unit: 'fiat', error: 'Rate for selected currency not available' }; } @@ -142,7 +144,11 @@ export default class UnitsStore { space }; } else { - return { error: 'Error fetching fiat rates' }; + return { + amount: 'Disabled', + unit: 'fiat', + error: 'Error fetching fiat rates' + }; } } };