Skip to content

Commit

Permalink
Merge pull request #2460 from shubhamkmr04/shubham/tsc-fixes-2nd
Browse files Browse the repository at this point in the history
Views: Fix typescript
  • Loading branch information
kaloudis authored Oct 21, 2024
2 parents a0f69ac + 9712aad commit 269030c
Show file tree
Hide file tree
Showing 98 changed files with 710 additions and 640 deletions.
2 changes: 1 addition & 1 deletion components/AmountInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ interface AmountInputProps {
onAmountChange: (amount: string, satAmount: string | number) => void;
amount?: string;
locked?: boolean;
title: string;
title?: string;
hideConversion?: boolean;
hideUnitChangeButton?: boolean;
FiatStore?: FiatStore;
Expand Down
4 changes: 2 additions & 2 deletions components/Channels/ChannelItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ import { themeColor } from './../../utils/ThemeUtils';

import Stores from '../../stores/Stores';

import ClockIcon from '../../assets/images/SVG/Clock.svg';
import HourglassIcon from '../../assets/images/SVG/Hourglass.svg';
const ClockIcon = require('../../assets/images/SVG/Clock.svg');
const HourglassIcon = require('../../assets/images/SVG/Hourglass.svg');
import { localeString } from './../../utils/LocaleUtils';

export function ChannelItem({
Expand Down
28 changes: 15 additions & 13 deletions components/Conversion.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ import { themeColor } from '../utils/ThemeUtils';
import ClockIcon from '../assets/images/SVG/Clock.svg';

interface ConversionProps {
amount: string | number;
sats: string | number;
satsPending: string | number;
FiatStore: FiatStore;
UnitsStore: UnitsStore;
SettingsStore: SettingsStore;
amount?: string | number;
sats?: string | number;
satsPending?: string | number;
FiatStore?: FiatStore;
UnitsStore?: UnitsStore;
SettingsStore?: SettingsStore;
sensitive?: boolean;
}

Expand Down Expand Up @@ -56,8 +56,8 @@ export default class Conversion extends React.Component<
sensitive
} = this.props;
const { showRate } = this.state;
const { units } = UnitsStore;
const { settings } = SettingsStore;
const { units } = UnitsStore!;
const { settings } = SettingsStore!;
const { fiatEnabled } = settings;

const { getRate }: any = FiatStore;
Expand All @@ -66,7 +66,9 @@ export default class Conversion extends React.Component<
if (sats) {
satAmount = sats;
} else {
satAmount = Number.isNaN(Number(amount)) ? 0 : getSatAmount(amount);
satAmount = Number.isNaN(Number(amount))
? 0
: getSatAmount(amount ?? 0);
}

if (!fiatEnabled || (!amount && !sats)) return;
Expand All @@ -89,7 +91,7 @@ export default class Conversion extends React.Component<
<>
<Text style={{ color: themeColor('secondaryText') }}>
{` | ${getRate(
this.props.UnitsStore.units === 'sats'
this.props.UnitsStore?.units === 'sats'
)}`}
</Text>
</>
Expand Down Expand Up @@ -129,7 +131,7 @@ export default class Conversion extends React.Component<
<>
<Text style={{ color: themeColor('secondaryText') }}>
{` | ${getRate(
this.props.UnitsStore.units === 'sats'
this.props.UnitsStore?.units === 'sats'
)}`}
</Text>
</>
Expand All @@ -144,7 +146,7 @@ export default class Conversion extends React.Component<
{units === 'fiat' && (
<TouchableOpacity
onPress={() => this.toggleShowRate()}
disabled={FiatStore.loading}
disabled={FiatStore?.loading}
>
{satsPending ? (
<ConversionPendingDisplay
Expand All @@ -162,7 +164,7 @@ export default class Conversion extends React.Component<
{units !== 'fiat' && (
<TouchableOpacity
onPress={() => this.toggleShowRate()}
disabled={FiatStore.loading}
disabled={FiatStore?.loading}
>
{satsPending ? (
<ConversionPendingDisplay
Expand Down
2 changes: 1 addition & 1 deletion components/DropdownSetting.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import CaretDown from './../assets/images/SVG/Caret Down.svg';
import { localeString } from './../utils/LocaleUtils';

interface DropdownSettingProps {
title: string;
title?: string;
selectedValue: string | number;
onValueChange: (value: any) => void;
values: Array<any>;
Expand Down
16 changes: 8 additions & 8 deletions components/FeeBreakdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,18 @@ import Amount from './Amount';
import KeyValue from './KeyValue';

interface FeeBreakdownProps {
ChannelsStore: ChannelsStore;
NodeInfoStore: NodeInfoStore;
channelId: string;
ChannelsStore?: ChannelsStore;
NodeInfoStore?: NodeInfoStore;
channelId: string | any;
channelPoint: string;
peerDisplay?: string;
peerDisplay?: string | any;
initiator?: boolean;
isActive?: boolean;
isClosed?: boolean;
total_satoshis_received?: string;
total_satoshis_sent?: string;
commit_weight?: number;
commit_fee?: number;
commit_weight?: number | string;
commit_fee?: number | string;
csv_delay?: number;
label?: string;
}
Expand Down Expand Up @@ -59,8 +59,8 @@ export default class FeeBreakdown extends React.Component<
csv_delay,
label
} = this.props;
const { loading, chanInfo } = ChannelsStore;
const { nodeInfo, testnet } = NodeInfoStore;
const { loading, chanInfo } = ChannelsStore!;
const { nodeInfo, testnet } = NodeInfoStore!;
const { nodeId } = nodeInfo;

let localPolicy, remotePolicy;
Expand Down
4 changes: 2 additions & 2 deletions components/HopPicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ interface ChannelPickerProps {
onCancel?: () => void;
ChannelsStore: ChannelsStore;
UnitsStore: UnitsStore;
containerStyle: ViewStyle;
clearOnTap: boolean;
containerStyle?: ViewStyle;
clearOnTap?: boolean;
selectionMode?: 'single' | 'multiple';
selectedChannels?: Channel[];
}
Expand Down
24 changes: 13 additions & 11 deletions components/LSPS1OrderResponse.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,17 @@ import { ChannelItem } from './Channels/ChannelItem';
interface LSPS1OrderResponseProps {
navigation: any;
orderResponse: any;
InvoicesStore: InvoicesStore;
NodeInfoStore: NodeInfoStore;
FiatStore: FiatStore;
InvoicesStore?: InvoicesStore;
NodeInfoStore?: NodeInfoStore;
FiatStore?: FiatStore;
orderView: boolean;
}

@inject('InvoicesStore', 'NodeInfoStore', 'FiatStore')
@observer
export default class LSPS1OrderResponse extends React.Component<
LSPS1OrderResponseProps,
null
{}
> {
render() {
const {
Expand All @@ -42,7 +42,7 @@ export default class LSPS1OrderResponse extends React.Component<
orderView,
navigation
} = this.props;
const { testnet } = NodeInfoStore;
const { testnet } = NodeInfoStore!;
const payment = orderResponse?.payment;
const channel = orderResponse?.channel;
return (
Expand Down Expand Up @@ -108,7 +108,7 @@ export default class LSPS1OrderResponse extends React.Component<
keyValue={localeString(
'views.LSPS1.channelExpiryBlocks'
)}
value={FiatStore.numberWithCommas(
value={FiatStore!.numberWithCommas(
orderResponse?.channel_expiry_blocks
)}
/>
Expand Down Expand Up @@ -460,11 +460,13 @@ export default class LSPS1OrderResponse extends React.Component<
paddingVertical: 20
}}
onPress={() => {
InvoicesStore.getPayReq(
payment.bolt11?.invoice ||
payment.lightning_invoice ||
payment.bolt11_invoice
)
InvoicesStore!
.getPayReq(
payment.bolt11
?.invoice ||
payment.lightning_invoice ||
payment.bolt11_invoice
)
.then(() => {
navigation.navigate(
'PaymentRequest',
Expand Down
24 changes: 13 additions & 11 deletions components/LayerBalances/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,16 @@ import BackendUtils from '../../utils/BackendUtils';
import { localeString } from '../../utils/LocaleUtils';
import { themeColor } from '../../utils/ThemeUtils';

import EyeClosed from '../../assets/images/SVG/eye_closed.svg';
import EyeOpened from '../../assets/images/SVG/eye_opened.svg';
const EyeClosed = require('../../assets/images/SVG/eye_closed.svg');
const EyeOpened = require('../../assets/images/SVG/eye_opened.svg');
import OnChainSvg from '../../assets/images/SVG/DynamicSVG/OnChainSvg';
import LightningSvg from '../../assets/images/SVG/DynamicSVG/LightningSvg';
import MatiSvg from '../../assets/images/SVG/DynamicSVG/MatiSvg';

interface LayerBalancesProps {
BalanceStore: BalanceStore;
UTXOsStore: UTXOsStore;
UnitsStore: UnitsStore;
BalanceStore?: BalanceStore;
UTXOsStore?: UTXOsStore;
UnitsStore?: UnitsStore;
navigation: StackNavigationProp<any, any>;
onRefresh?: any;
value?: string;
Expand All @@ -48,6 +48,7 @@ interface LayerBalancesProps {
locked?: boolean;
consolidated?: boolean;
editMode?: boolean;
refreshing?: boolean;
}

// To toggle LTR/RTL change to `true`
Expand Down Expand Up @@ -169,7 +170,7 @@ const SwipeableRow = ({
item: DataRow;
index: number;
navigation: StackNavigationProp<any, any>;
// selectMode: boolean; // not used for now
// selectMode: boolean; // not used for no
value?: string;
amount?: string;
lightning?: string;
Expand Down Expand Up @@ -268,14 +269,15 @@ export default class LayerBalances extends Component<LayerBalancesProps, {}> {
onRefresh,
locked,
consolidated,
editMode
editMode,
refreshing
} = this.props;

const { totalBlockchainBalance, lightningBalance } = BalanceStore;
const { totalBlockchainBalance, lightningBalance } = BalanceStore!;

const otherAccounts = editMode
? this.props.UTXOsStore.accounts
: this.props.UTXOsStore.accounts.filter(
? this.props.UTXOsStore?.accounts
: this.props.UTXOsStore?.accounts.filter(
(item: any) => !item.hidden
);

Expand Down Expand Up @@ -364,7 +366,7 @@ export default class LayerBalances extends Component<LayerBalancesProps, {}> {
keyExtractor={(_item, index) => `message ${index}`}
style={{ marginTop: 20 }}
onRefresh={() => onRefresh()}
refreshing={false}
refreshing={refreshing}
/>
</View>
);
Expand Down
2 changes: 1 addition & 1 deletion components/ModalBox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ const styles = StyleSheet.create({
});

interface ModalBoxProps {
isOpen: boolean;
isOpen?: boolean;
isDisabled?: boolean;
startOpen: boolean;
backdropPressToClose?: boolean;
Expand Down
6 changes: 3 additions & 3 deletions components/Text.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ import { themeColor } from './../utils/ThemeUtils';
import ModalStore from '../stores/ModalStore';

interface TextProps {
ModalStore: ModalStore;
ModalStore?: ModalStore;
style?: TextStyle;
children: string;
children?: string;
infoText?: string | Array<string>;
infoLink?: string;
infoNav?: string;
Expand All @@ -22,7 +22,7 @@ export default class ZeusText extends React.Component<TextProps, {}> {
render() {
const { children, style, infoText, infoLink, infoNav, ModalStore } =
this.props;
const { toggleInfoModal } = ModalStore;
const { toggleInfoModal } = ModalStore!;

const CoreText = () => (
<Row>
Expand Down
3 changes: 2 additions & 1 deletion components/TextInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,15 @@ interface TextInputProps {
multiline?: boolean;
autoFocus?: boolean;
secureTextEntry?: boolean;
prefix?: string;
prefix?: string | number;
prefixStyle?: any;
suffix?: string;
toggleUnits?: any;
onPressIn?: any;
right?: number;
ref?: React.Ref<TextInputRN>;
error?: boolean;
onFocus?: any;
}

const TextInput = React.forwardRef<TextInputRN, TextInputProps>(
Expand Down
8 changes: 4 additions & 4 deletions components/UnitToggle.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import SettingsStore from '../stores/SettingsStore';
import { themeColor } from '../utils/ThemeUtils';

interface UnitToggleProps {
UnitsStore: UnitsStore;
SettingsStore: SettingsStore;
UnitsStore?: UnitsStore;
SettingsStore?: SettingsStore;
onToggle?: () => void;
}

Expand All @@ -19,8 +19,8 @@ interface UnitToggleProps {
export default class UnitToggle extends React.Component<UnitToggleProps, {}> {
render() {
const { UnitsStore, SettingsStore, onToggle } = this.props;
const { changeUnits, units } = UnitsStore;
const { settings } = SettingsStore;
const { changeUnits, units } = UnitsStore!;
const { settings } = SettingsStore!;
const { fiat } = settings;

return (
Expand Down
6 changes: 3 additions & 3 deletions components/WalletHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -204,9 +204,9 @@ interface WalletHeaderProps {
PosStore?: PosStore;
SyncStore?: SyncStore;
navigation: StackNavigationProp<any, any>;
loading: boolean;
title: string;
channels: boolean;
loading?: boolean;
title?: string;
channels?: boolean;
toggle?: () => void;
}

Expand Down
1 change: 1 addition & 0 deletions locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -830,6 +830,7 @@
"views.Settings.Seed.dangerousText1": "Do you want to copy your 24 word seed to your clipboard?",
"views.Settings.Seed.dangerousText2": "This is DANGEROUS. Your seed may be read by other applications that you open. Proceed with caution.",
"views.Settings.Seed.dangerousButton": "Dangerously copy seed to clipboard",
"views.Settings.SeedRecovery.title": "Wallet recovery",
"views.Settings.EmbeddedNode.title": "Embedded node",
"views.Settings.EmbeddedNode.Pathfinding.title": "Pathfinding",
"views.Settings.EmbeddedNode.Peers.addPeer": "Add peer",
Expand Down
12 changes: 12 additions & 0 deletions models/Channel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,18 @@ export default class Channel extends BaseModel {
fee_per_kw: string;
total_satoshis_received: string;
pending_htlcs: Array<HTLC>;
pendingOpen: any;
pendingClose: any;
forceClose: any;
closing: any;
blocks_til_maturity: any;
chain_hash: string;
closeHeight: any;
closing_tx_hash: string;
closing_txid: string;
closeType: any;
settled_balance: any;
time_locked_balance: any;
num_updates: string;
@observable
active: boolean;
Expand Down
2 changes: 1 addition & 1 deletion models/TransactionRequest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export default interface TransactionRequest {
spend_unconfirmed?: boolean;
send_all?: boolean;
account?: string;
additional_outputs: Array<AdditionalOutput>;
additional_outputs?: Array<AdditionalOutput>;
outpoints?: Array<OutPoint>;
}

Expand Down
Loading

0 comments on commit 269030c

Please sign in to comment.