Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
gruve-p committed Aug 4, 2023
2 parents 5b361a2 + ac4926b commit 380e2cf
Show file tree
Hide file tree
Showing 88 changed files with 410 additions and 433 deletions.
2 changes: 1 addition & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"plugin:react-hooks/recommended",
"plugin:react/recommended",
"plugin:@typescript-eslint/recommended",
// "@react-native-community", // TODO: try to enable
"@react-native-community",
"plugin:prettier/recommended" // removes all eslint rules that can mess up with prettier
],
"rules": {
Expand Down
9 changes: 5 additions & 4 deletions App.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@ import {
} from 'react-native';
import { NavigationContainer, CommonActions } from '@react-navigation/native';
import { SafeAreaProvider } from 'react-native-safe-area-context';
import ReactNativeHapticFeedback from 'react-native-haptic-feedback';

import { navigationRef } from './NavigationService';
import * as NavigationService from './NavigationService';
import ReactNativeHapticFeedback from 'react-native-haptic-feedback';
import { Chain } from './models/bitcoinUnits';
import OnAppLaunch from './class/on-app-launch';
import DeeplinkSchemaMatch from './class/deeplink-schema-match';
Expand Down Expand Up @@ -153,7 +154,7 @@ const App = () => {

const popInitialAction = async data => {
if (data) {
const wallet = wallets.find(wallet => wallet.getID() === data.userInfo.url.split('wallet/')[1]);
const wallet = wallets.find(w => w.getID() === data.userInfo.url.split('wallet/')[1]);
NavigationService.dispatch(
CommonActions.navigate({
name: 'WalletTransactions',
Expand All @@ -174,7 +175,7 @@ const App = () => {
const isViewAllWalletsEnabled = await OnAppLaunch.isViewAllWalletsEnabled();
if (!isViewAllWalletsEnabled) {
const selectedDefaultWallet = await OnAppLaunch.getSelectedDefaultWallet();
const wallet = wallets.find(wallet => wallet.getID() === selectedDefaultWallet.getID());
const wallet = wallets.find(w => w.getID() === selectedDefaultWallet.getID());
if (wallet) {
NavigationService.dispatch(
CommonActions.navigate({
Expand All @@ -193,7 +194,7 @@ const App = () => {
};

const walletQuickActions = data => {
const wallet = wallets.find(wallet => wallet.getID() === data.userInfo.url.split('wallet/')[1]);
const wallet = wallets.find(w => w.getID() === data.userInfo.url.split('wallet/')[1]);
NavigationService.dispatch(
CommonActions.navigate({
name: 'WalletTransactions',
Expand Down
10 changes: 5 additions & 5 deletions BlueApp.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ let usedBucketNum = false;
let savingInProgress = 0; // its both a flag and a counter of attempts to write to disk
const prompt = require('./helpers/prompt');
const currency = require('./blue_modules/currency');
const BlueElectrum = require('./blue_modules/BlueElectrum'); // eslint-disable-line @typescript-eslint/no-unused-vars
const BlueElectrum = require('./blue_modules/BlueElectrum');
BlueElectrum.connectMain();

class AppStorage {
Expand Down Expand Up @@ -399,8 +399,8 @@ class AppStorage {
let lndhub = false;
try {
lndhub = await AsyncStorage.getItem(AppStorage.LNDHUB);
} catch (Error) {
console.warn(Error);
} catch (error) {
console.warn(error);
}

if (unserializedWallet.baseURI) {
Expand Down Expand Up @@ -543,7 +543,7 @@ class AppStorage {
{
walletid: id,
internal: false,
index: parseInt(index),
index: parseInt(index, 10),
tx: JSON.stringify(tx),
},
Realm.UpdateMode.Modified,
Expand All @@ -559,7 +559,7 @@ class AppStorage {
{
walletid: id,
internal: true,
index: parseInt(index),
index: parseInt(index, 10),
tx: JSON.stringify(tx),
},
Realm.UpdateMode.Modified,
Expand Down
2 changes: 1 addition & 1 deletion BlueComponents.js
Original file line number Diff line number Diff line change
Expand Up @@ -797,7 +797,7 @@ export class BlueReplaceFeeSuggestions extends Component {
paddingLeft: 5,
}}
onFocus={() => this.onCustomFeeTextChange(this.state.customFeeValue)}
defaultValue={`${this.props.transactionMinimum}`}
defaultValue={this.props.transactionMinimum}
placeholder={loc.send.fee_satvbyte}
placeholderTextColor="#81868e"
inputAccessoryViewID={BlueDismissKeyboardInputAccessory.InputAccessoryViewID}
Expand Down
16 changes: 9 additions & 7 deletions Navigation.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import React, { useCallback, useMemo } from 'react';
import { createNativeStackNavigator } from 'react-native-screens/native-stack';
import { createDrawerNavigator } from '@react-navigation/drawer';
import { Platform, useWindowDimensions, Dimensions, I18nManager } from 'react-native';
Expand Down Expand Up @@ -340,23 +340,25 @@ const ReorderWalletsStackRoot = () => {
};

const Drawer = createDrawerNavigator();
function DrawerRoot() {
const DrawerRoot = () => {
const dimensions = useWindowDimensions();
const isLargeScreen =
Platform.OS === 'android' ? isTablet() : (dimensions.width >= Dimensions.get('screen').width / 2 && isTablet()) || isDesktop;
const drawerStyle = { width: isLargeScreen ? 320 : '0%' };
const isLargeScreen = useMemo(() => {
return Platform.OS === 'android' ? isTablet() : (dimensions.width >= Dimensions.get('screen').width / 2 && isTablet()) || isDesktop;
}, [dimensions.width]);
const drawerStyle = useMemo(() => ({ width: isLargeScreen ? 320 : '0%' }), [isLargeScreen]);
const drawerContent = useCallback(props => (isLargeScreen ? <DrawerList {...props} /> : null), [isLargeScreen]);

return (
<Drawer.Navigator
drawerStyle={drawerStyle}
drawerType={isLargeScreen ? 'permanent' : null}
drawerContent={props => (isLargeScreen ? <DrawerList {...props} /> : null)}
drawerContent={drawerContent}
drawerPosition={I18nManager.isRTL ? 'right' : 'left'}
>
<Drawer.Screen name="Navigation" component={Navigation} options={{ headerShown: false, gestureEnabled: false }} />
</Drawer.Navigator>
);
}
};

const ReceiveDetailsStack = createNativeStackNavigator();
const ReceiveDetailsStackRoot = () => {
Expand Down
1 change: 0 additions & 1 deletion NavigationService.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable no-unused-expressions */
import * as React from 'react';

export const navigationRef = React.createRef();
Expand Down
7 changes: 3 additions & 4 deletions UnlockWith.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,17 +44,16 @@ const UnlockWith = () => {
const colorScheme = useColorScheme();

const initialRender = async () => {
let biometricType = false;
let bt = false;
if (await Biometric.isBiometricUseCapableAndEnabled()) {
biometricType = await Biometric.biometricType();
bt = await Biometric.biometricType();
}

setBiometricType(biometricType);
setBiometricType(bt);
};

useEffect(() => {
initialRender();
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);

const successfullyAuthenticated = () => {
Expand Down
5 changes: 2 additions & 3 deletions WatchConnectivity.ios.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ function WatchConnectivity() {
console.log(e);
}
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [preferredFiatCurrency, walletsInitialized, isReachable, isInstalled]);

const handleMessages = (message, reply) => {
Expand Down Expand Up @@ -159,7 +158,7 @@ function WatchConnectivity() {
type = 'pendingConfirmation';
} else if (transaction.type === 'user_invoice' || transaction.type === 'payment_request') {
const currentDate = new Date();
const now = (currentDate.getTime() / 1000) | 0;
const now = (currentDate.getTime() / 1000) | 0; // eslint-disable-line no-bitwise
const invoiceExpiration = transaction.timestamp + transaction.expire_time;

if (invoiceExpiration > now) {
Expand All @@ -179,7 +178,7 @@ function WatchConnectivity() {
if (transaction.type === 'user_invoice' || transaction.type === 'payment_request') {
amount = isNaN(transaction.value) ? '0' : amount;
const currentDate = new Date();
const now = (currentDate.getTime() / 1000) | 0;
const now = (currentDate.getTime() / 1000) | 0; // eslint-disable-line no-bitwise
const invoiceExpiration = transaction.timestamp + transaction.expire_time;

if (invoiceExpiration > now) {
Expand Down
6 changes: 3 additions & 3 deletions blue_modules/BlueElectrum.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export type ElectrumTransaction = {

type MempoolTransaction = {
height: 0;
tx_hash: string; // eslint-disable-line camelcase
tx_hash: string;
fee: number;
};

Expand All @@ -67,7 +67,7 @@ export function multiGetTransactionByTxid(txIds: string[], batchsize: number, ve

export type MultiGetBalanceResponse = {
balance: number;
unconfirmed_balance: number; // eslint-disable-line camelcase
unconfirmed_balance: number;
addresses: Record<string, { confirmed: number; unconfirmed: number }>;
};

Expand All @@ -80,7 +80,7 @@ export function getMempoolTransactionsByAddress(address: string): Promise<Mempoo
export function estimateCurrentBlockheight(): number;

export type ElectrumHistory = {
tx_hash: string; // eslint-disable-line camelcase
tx_hash: string;
height: number;
address: string;
};
Expand Down
20 changes: 10 additions & 10 deletions blue_modules/BlueElectrum.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,18 +106,18 @@ let latestBlockheightTimestamp = false;
const txhashHeightCache = {};

async function isDisabled() {
let isDisabled;
let result;
try {
const savedValue = await AsyncStorage.getItem(ELECTRUM_CONNECTION_DISABLED);
if (savedValue === null) {
isDisabled = false;
result = false;
} else {
isDisabled = savedValue;
result = savedValue;
}
} catch {
isDisabled = false;
result = false;
}
return !!isDisabled;
return !!result;
}

async function setDisabled(disabled = true) {
Expand Down Expand Up @@ -340,7 +340,7 @@ async function getSavedPeer() {
*
* @returns {Promise<{tcp: number, host: string}>}
*/
// eslint-disable-next-line
// eslint-disable-next-line @typescript-eslint/no-unused-vars
async function getRandomDynamicPeer() {
try {
let peers = JSON.parse(await AsyncStorage.getItem(storageKey));
Expand Down Expand Up @@ -710,8 +710,8 @@ module.exports.multiGetTransactionByTxid = async function (txids, batchsize, ver
let tx = await mainClient.blockchainTransaction_get(txid, false);
tx = txhexToElectrumTransaction(tx);
results.push({ result: tx, param: txid });
} catch (_) {
console.log(_);
} catch (error) {
console.log(error);
}
}
} else {
Expand All @@ -726,8 +726,8 @@ module.exports.multiGetTransactionByTxid = async function (txids, batchsize, ver
tx = txhexToElectrumTransaction(tx);
}
results.push({ result: tx, param: txid });
} catch (_) {
console.log(_);
} catch (error) {
console.log(error);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion blue_modules/currency.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ async function updateExchangeRate() {
} catch (Err) {
console.log('Error encountered when attempting to update exchange rate...');
console.warn(Err.message);
const rate = JSON.parse(await AsyncStorage.getItem(EXCHANGE_RATES_STORAGE_KEY));
rate = JSON.parse(await AsyncStorage.getItem(EXCHANGE_RATES_STORAGE_KEY));
rate.LAST_UPDATED_ERROR = true;
exchangeRates.LAST_UPDATED_ERROR = true;
await AsyncStorage.setItem(EXCHANGE_RATES_STORAGE_KEY, JSON.stringify(rate));
Expand Down
10 changes: 5 additions & 5 deletions blue_modules/environment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,19 @@ export async function setIsTorDaemonDisabled(disabled: boolean = true): Promise<
}

export async function isTorDaemonDisabled(): Promise<boolean> {
let isTorDaemonDisabled: boolean;
let result: boolean;
try {
const savedValue = await AsyncStorage.getItem(IS_TOR_DAEMON_DISABLED);
if (savedValue === null) {
isTorDaemonDisabled = false;
result = false;
} else {
isTorDaemonDisabled = savedValue === '1';
result = savedValue === '1';
}
} catch {
isTorDaemonDisabled = true;
result = true;
}

return isTorDaemonDisabled;
return result;
}

export const isHandset: boolean = getDeviceType() === 'Handset';
Expand Down
4 changes: 2 additions & 2 deletions blue_modules/fs.js
Original file line number Diff line number Diff line change
Expand Up @@ -185,8 +185,8 @@ const showFilePickerAndReadFile = async function () {

if (res?.type === DocumentPicker.types.images || res?.type?.startsWith('image/')) {
return new Promise(resolve => {
const uri = res.uri.toString().replace('file://', '');
LocalQRCode.decode(decodeURI(uri), (error, result) => {
const uri2 = res.uri.toString().replace('file://', '');
LocalQRCode.decode(decodeURI(uri2), (error, result) => {
if (!error) {
resolve({ data: result, uri: decodeURI(res.uri) });
} else {
Expand Down
2 changes: 1 addition & 1 deletion blue_modules/notifications.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ function Notifications(props) {

// if user is staring at the app when he receives the notification we process it instantly
// so app refetches related wallet
if (payload.foreground) props.onProcessNotifications(); // eslint-disable-line react/prop-types
if (payload.foreground) props.onProcessNotifications();
},

// (optional) Called when Registered Action is pressed and invokeApp is false, if true onNotification will be called (Android)
Expand Down
5 changes: 2 additions & 3 deletions blue_modules/storage-context.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable react/prop-types */
import React, { createContext, useEffect, useState } from 'react';
import { Alert } from 'react-native';
import ReactNativeHapticFeedback from 'react-native-haptic-feedback';
Expand Down Expand Up @@ -108,8 +107,8 @@ export const BlueStorageProvider = ({ children }) => {
setWallets(BlueApp.getWallets());
};

const setWalletsWithNewOrder = wallets => {
BlueApp.wallets = wallets;
const setWalletsWithNewOrder = wlts => {
BlueApp.wallets = wlts;
saveToDisk();
};

Expand Down
4 changes: 2 additions & 2 deletions class/azteco.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Frisbee from 'frisbee';
import url from 'url';
import URL from 'url';

export default class Azteco {
/**
Expand Down Expand Up @@ -29,7 +29,7 @@ export default class Azteco {
}

static getParamsFromUrl(u) {
const urlObject = url.parse(u, true); // eslint-disable-line n/no-deprecated-api
const urlObject = URL.parse(u, true); // eslint-disable-line n/no-deprecated-api
return {
uri: u,
c1: urlObject.query.c1,
Expand Down
Loading

0 comments on commit 380e2cf

Please sign in to comment.