Skip to content

Commit

Permalink
tsc: fix stores
Browse files Browse the repository at this point in the history
  • Loading branch information
kaloudis committed Oct 3, 2024
1 parent 6dd2a9b commit bae14c1
Show file tree
Hide file tree
Showing 11 changed files with 1,840 additions and 18 deletions.
2 changes: 1 addition & 1 deletion models/OpenChannelRequest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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[];
Expand Down
2 changes: 1 addition & 1 deletion stores/ActivityStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
1 change: 1 addition & 0 deletions stores/AlertStore.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { action, reaction, observable } from 'mobx';
// @ts-ignore:next-line
import Ping from 'react-native-ping';

import SettingsStore from './SettingsStore';
Expand Down
8 changes: 4 additions & 4 deletions stores/BalanceStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
);
Expand Down Expand Up @@ -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 =
Expand Down
3 changes: 2 additions & 1 deletion stores/ChannelBackupStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
14 changes: 7 additions & 7 deletions stores/ChannelsStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -303,8 +303,8 @@ export default class ChannelsStore {
enrichChannels = async (
channels: Array<Channel>,
setPendingHtlcs?: boolean
) => {
if (channels.length === 0) return;
): Promise<Channel[]> => {
if (channels.length === 0) return [];

const channelsWithMissingAliases = channels?.filter(
(c) => c.channelId != null && this.aliasesById[c.channelId] == null
Expand Down Expand Up @@ -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;

Expand Down
4 changes: 3 additions & 1 deletion stores/LightningAddressStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -761,7 +761,7 @@ export default class LightningAddressStore {
}
]);

events.map((event) => {
events.map((event: any) => {
attestationEvents[event.id] = event;
});

Expand Down Expand Up @@ -937,13 +937,15 @@ 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
});
}

if (Platform.OS === 'ios') {
// @ts-ignore:next-line
Notifications.postLocalNotification({
title,
body,
Expand Down
3 changes: 3 additions & 0 deletions stores/LnurlPayStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion stores/TransactionsStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
10 changes: 8 additions & 2 deletions stores/UnitsStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ interface ValueDisplayProps {
plural?: boolean;
rtl?: boolean;
space?: boolean;
error?: boolean;
error?: string;
}

export default class UnitsStore {
Expand Down Expand Up @@ -118,6 +118,8 @@ export default class UnitsStore {

if (!fiatEntry?.rate) {
return {
amount: 'Disabled',
unit: 'fiat',
error: 'Rate for selected currency not available'
};
}
Expand All @@ -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'
};
}
}
};
Expand Down
Loading

0 comments on commit bae14c1

Please sign in to comment.