Skip to content

Commit fb3c4df

Browse files
authored
Merge pull request #2535 from synonymdev/fix/various-fixes
fix: various fixes
2 parents 9ee08d6 + cf173ff commit fb3c4df

File tree

10 files changed

+51
-24
lines changed

10 files changed

+51
-24
lines changed

src/hooks/useWeatherWidget.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { __E2E__ } from '../constants/env';
33
import { widgetsCache } from '../storage/widgets-cache';
44
import { refreshOnchainFeeEstimates } from '../store/utils/fees';
55
import { getDisplayValues, getFiatDisplayValues } from '../utils/displayValues';
6+
import { useCurrency } from './displayValues';
67

78
type TBlockFeeRates = {
89
avgHeight: number;
@@ -107,6 +108,7 @@ const calculateCondition = (
107108
};
108109

109110
const useWeatherWidget = (): TWidgetState => {
111+
const { fiatTicker } = useCurrency();
110112
const [state, setState] = useState<TWidgetState>(() => {
111113
const cached = getCachedData();
112114
return cached
@@ -145,7 +147,7 @@ const useWeatherWidget = (): TWidgetState => {
145147

146148
// Total fee based on average native segwit transaction of 140 vBytes
147149
const avgFee = fees.normal * VBYTES_SIZE;
148-
const dv = getDisplayValues({ satoshis: avgFee });
150+
const dv = getDisplayValues({ satoshis: avgFee, currency: fiatTicker });
149151
const currentFee = `${dv.fiatSymbol} ${dv.fiatFormatted}`;
150152
const data = { condition, currentFee, nextBlockFee: fees.fast };
151153

@@ -170,7 +172,7 @@ const useWeatherWidget = (): TWidgetState => {
170172
clearInterval(interval);
171173
abortController.abort();
172174
};
173-
}, []);
175+
}, [fiatTicker]);
174176

175177
return state;
176178
};

src/screens/Settings/AddressViewer/index.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -257,11 +257,11 @@ const AddressViewer = (): ReactElement => {
257257
);
258258
// The private key of the currently selected address to display qrcode data for.
259259
const [privateKey, setPrivateKey] = useState<string | undefined>(undefined);
260-
// Available array of UTXO's after checking for a balance.
260+
// Available array of UTXOs after checking for a balance.
261261
const [utxos, setUtxos] = useState<IUtxo[] | undefined>();
262-
// Total balance of available UTXO's after checking for a balance.
262+
// Total balance of available UTXOs after checking for a balance.
263263
const [totalBalance, setTotalBalance] = useState(0);
264-
// An array of UTXO's that are currently selected for spending.
264+
// An array of UTXOs that are currently selected for spending.
265265
const [selectedUtxos, setSelectedUtxos] = useState<IUtxo[]>([]);
266266
const [searchTxt, setSearchTxt] = useState('');
267267
// Addresses filtered from a search query in onSearch.
@@ -615,7 +615,7 @@ const AddressViewer = (): ReactElement => {
615615
);
616616

617617
/**
618-
* This method will gather all selected UTXO's and setup an on-chain transaction.
618+
* This method will gather all selected UTXOs and setup an on-chain transaction.
619619
* The on-chain transaction will retrieve and include the app's receiving address by default.
620620
* Finally, this method will prompt the sendNavigation modal to appear for the user to finalize and confirm the transaction.
621621
*/
@@ -735,7 +735,7 @@ const AddressViewer = (): ReactElement => {
735735
}, [getMoreAddresses]);
736736

737737
/**
738-
* Retrieves the balance and UTXO's associated with all addresses of each type.
738+
* Retrieves the balance and UTXOs associated with all addresses of each type.
739739
*/
740740
const onCheckBalance = useCallback(async (): Promise<void> => {
741741
setIsCheckingBalances(true);

src/screens/Settings/DevSettings/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ const DevSettings = ({
178178
onPress: widgetsCache.clear,
179179
},
180180
{
181-
title: "Clear UTXO's",
181+
title: 'Clear UTXOs',
182182
type: EItemType.button,
183183
onPress: clearUtxos,
184184
},

src/screens/Wallets/Send/CoinSelection.tsx

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
import { BottomSheetScrollView } from '@gorhom/bottom-sheet';
22
import React, { ReactElement, memo, useMemo, useState } from 'react';
33
import { useTranslation } from 'react-i18next';
4-
import { StyleSheet, View } from 'react-native';
4+
import { ScrollView, StyleSheet, View } from 'react-native';
55

66
import BottomSheetNavigationHeader from '../../../components/BottomSheetNavigationHeader';
77
import GradientView from '../../../components/GradientView';
88
import SafeAreaInset from '../../../components/SafeAreaInset';
99
import Switch from '../../../components/Switch';
1010
import Tag from '../../../components/Tag';
1111
import Button from '../../../components/buttons/Button';
12-
import { ScrollView } from '../../../styles/components';
1312
import { BodyMSB, BodySSB, Caption13Up, Subtitle } from '../../../styles/text';
1413

1514
import { IUtxo } from 'beignet';
@@ -34,7 +33,7 @@ import {
3433
} from '../../../utils/wallet/transactions';
3534

3635
/**
37-
* Some UTXO's may contain the same tx_hash.
36+
* Some UTXOs may contain the same tx_hash.
3837
* So we include the tx_pos to ensure we can quickly distinguish.
3938
* @param {IUtxo} utxo
4039
* @return string
@@ -65,9 +64,9 @@ const UtxoRow = ({
6564

6665
{tags && (
6766
<ScrollView
67+
style={styles.coinTagsScroll}
6868
horizontal={true}
69-
centerContent={true}
70-
style={styles.coinTagsScroll}>
69+
centerContent={true}>
7170
{tags.map((t) => (
7271
<Tag style={styles.tag} key={t} value={t} />
7372
))}
@@ -94,7 +93,7 @@ const CoinSelection = ({
9493
return transaction.inputs;
9594
}, [transaction.inputs]);
9695

97-
//Combine known utxo's with current transaction inputs in the event we're using utxo's from the address viewer.
96+
//Combine known UTXOs with current transaction inputs in the event we're using UTXOs from the address viewer.
9897
const combinedUtxos = useMemo(() => {
9998
const combined: IUtxo[] = [...utxos, ...inputs];
10099

src/store/utils/ui.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,14 @@ export const showSheet = <Id extends keyof SheetsParamList>(
1919
): void => {
2020
const [id, params] = args;
2121
const sheetRef = getSheetRefOutsideComponent(id);
22-
sheetRef.current?.present(params);
22+
23+
if (!sheetRef.current) {
24+
// sheetRef not ready, try again after a short wait
25+
// NOTE: needed for deeplinks when app is closed
26+
setTimeout(() => showSheet(...args), 100);
27+
} else {
28+
sheetRef.current?.present(params);
29+
}
2330
};
2431

2532
export const closeSheet = async (id: SheetId): Promise<void> => {

src/utils/i18n/locales/en/settings.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -430,31 +430,31 @@
430430
"string": "Smallest First"
431431
},
432432
"cs_max_description": {
433-
"string": "Sort by and use smallest UTXO first. Potentially higher fee, but hides your largest UTXO's."
433+
"string": "Sort by and use smallest UTXO first. Potentially higher fee, but hides your largest UTXOs."
434434
},
435435
"cs_min": {
436436
"string": "Largest First"
437437
},
438438
"cs_min_description": {
439-
"string": "Sort by and use largest UTXO first. Potentially lower fee, but reveals your largest UTXO's."
439+
"string": "Sort by and use largest UTXO first. Potentially lower fee, but reveals your largest UTXOs."
440440
},
441441
"cs_consolidate": {
442442
"string": "Consolidate"
443443
},
444444
"cs_consolidate_description": {
445-
"string": "Use all available UTXO's regardless of the amount being sent. Use this method when fees are low in order to reduce fees in future transactions."
445+
"string": "Use all available UTXOs regardless of the amount being sent. Use this method when fees are low in order to reduce fees in future transactions."
446446
},
447447
"cs_first_in_first_out": {
448448
"string": "First-In First-Out"
449449
},
450450
"cs_first_in_first_out_description": {
451-
"string": "Use older UTXO's first (by block height)."
451+
"string": "Use older UTXOs first (by block height)."
452452
},
453453
"cs_last_in_last_out": {
454454
"string": "Last-In Last-Out"
455455
},
456456
"cs_last_in_last_out_description": {
457-
"string": "Use newer UTXO's first (by block height)."
457+
"string": "Use newer UTXOs first (by block height)."
458458
},
459459
"payment_preference": {
460460
"string": "Payment Preference"

src/utils/i18n/locales/en/wallet.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@
228228
"string": "Please increase your send amount to proceed."
229229
},
230230
"send_coin_selection_output_to_small_description": {
231-
"string": "Please remove UTXO's or increase your send amount to proceed."
231+
"string": "Please remove UTXOs or increase your send amount to proceed."
232232
},
233233
"send_fee_error_min": {
234234
"string": "Unable to decrease the fee any further."

src/utils/lightning/index.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1151,6 +1151,23 @@ export const waitForLdk = async (): Promise<void> => {
11511151
});
11521152
};
11531153

1154+
export const waitForLdkChannels = async (): Promise<void> => {
1155+
await tryNTimes({
1156+
toTry: async () => {
1157+
const channelsResult = await ldk.listUsableChannels();
1158+
if (channelsResult.isOk()) {
1159+
if (channelsResult.value.length > 0) {
1160+
return ok(channelsResult.value);
1161+
}
1162+
return err('no channels ready');
1163+
}
1164+
return err('error getting channels');
1165+
},
1166+
times: 5,
1167+
interval: 1000,
1168+
});
1169+
};
1170+
11541171
/**
11551172
* Returns the current LDK node id.
11561173
* @returns {Promise<Result<string>>}
@@ -1579,6 +1596,8 @@ export const payLightningInvoice = async ({
15791596
amount?: number;
15801597
}): Promise<Result<string>> => {
15811598
try {
1599+
await waitForLdkChannels();
1600+
15821601
const addPeersResponse = await addPeers();
15831602
if (addPeersResponse.isErr()) {
15841603
return err(addPeersResponse.error.message);

src/utils/wallet/electrum.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ export const isConnectedElectrum = async (): Promise<boolean> => {
4141
};
4242

4343
/**
44-
* Formats a provided array of addresses a returns their UTXO's & balances.
44+
* Formats a provided array of addresses a returns their UTXOs & balances.
4545
* @param {IAddress[]} allAddresses
4646
* @returns {Promise<Result<IGetUtxosResponse>>}
4747
*/
@@ -58,7 +58,7 @@ export const getAddressUtxos = async ({
5858
};
5959

6060
/**
61-
* Queries Electrum to return the available UTXO's and balance of the provided addresses.
61+
* Queries Electrum to return the available UTXOs and balance of the provided addresses.
6262
* @param {TUnspentAddressScriptHashData} addresses
6363
*/
6464
export const listUnspentAddressScriptHashes = async ({

src/utils/wallet/transactions.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ import {
4040
} from './index';
4141

4242
/*
43-
* Attempt to estimate the current fee for a given wallet and its UTXO's
43+
* Attempt to estimate the current fee for a given wallet and its UTXOs
4444
*/
4545
export const getTotalFee = ({
4646
satsPerByte,

0 commit comments

Comments
 (0)