mirror of
https://github.com/BlueWallet/BlueWallet.git
synced 2025-01-18 21:35:21 +01:00
REF: Proper file/dir structure for context providers
This commit is contained in:
parent
a2fbbecce5
commit
3ee765d237
3
App.tsx
3
App.tsx
@ -4,13 +4,12 @@ import { NavigationContainer } from '@react-navigation/native';
|
||||
import React from 'react';
|
||||
import { useColorScheme } from 'react-native';
|
||||
import { SafeAreaProvider } from 'react-native-safe-area-context';
|
||||
|
||||
import { BlueStorageProvider } from './blue_modules/storage-context';
|
||||
import { LargeScreenProvider } from './components/Context/LargeScreenProvider';
|
||||
import { SettingsProvider } from './components/Context/SettingsContext';
|
||||
import { BlueDarkTheme, BlueDefaultTheme } from './components/themes';
|
||||
import MasterView from './navigation/MasterView';
|
||||
import { navigationRef } from './NavigationService';
|
||||
import { BlueStorageProvider } from './components/Context/BlueStorageContext';
|
||||
|
||||
const App = () => {
|
||||
const colorScheme = useColorScheme();
|
||||
|
@ -9,13 +9,13 @@ import BlueClipboard from '../blue_modules/clipboard';
|
||||
import { updateExchangeRate } from '../blue_modules/currency';
|
||||
import triggerHapticFeedback, { HapticFeedbackTypes } from '../blue_modules/hapticFeedback';
|
||||
import Notifications from '../blue_modules/notifications';
|
||||
import { useStorage } from '../blue_modules/storage-context';
|
||||
import { LightningCustodianWallet } from '../class';
|
||||
import DeeplinkSchemaMatch from '../class/deeplink-schema-match';
|
||||
import loc from '../loc';
|
||||
import { Chain } from '../models/bitcoinUnits';
|
||||
import { navigationRef } from '../NavigationService';
|
||||
import ActionSheet from '../screen/ActionSheet';
|
||||
import { useStorage } from '../hooks/context/useStorage';
|
||||
|
||||
const MenuElements = lazy(() => import('../components/MenuElements'));
|
||||
const DeviceQuickActions = lazy(() => import('../components/DeviceQuickActions'));
|
||||
|
@ -1,15 +1,14 @@
|
||||
import React, { createContext, useCallback, useContext, useEffect, useMemo, useRef, useState } from 'react';
|
||||
import React, { createContext, useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
||||
import { InteractionManager } from 'react-native';
|
||||
|
||||
import A from '../blue_modules/analytics';
|
||||
import Notifications from '../blue_modules/notifications';
|
||||
import { BlueApp as BlueAppClass, LegacyWallet, TCounterpartyMetadata, TTXMetadata, WatchOnlyWallet } from '../class';
|
||||
import type { TWallet } from '../class/wallets/types';
|
||||
import presentAlert from '../components/Alert';
|
||||
import loc from '../loc';
|
||||
import * as BlueElectrum from './BlueElectrum';
|
||||
import triggerHapticFeedback, { HapticFeedbackTypes } from './hapticFeedback';
|
||||
import { startAndDecrypt } from './start-and-decrypt';
|
||||
import A from '../../blue_modules/analytics';
|
||||
import Notifications from '../../blue_modules/notifications';
|
||||
import { BlueApp as BlueAppClass, LegacyWallet, TCounterpartyMetadata, TTXMetadata, WatchOnlyWallet } from '../../class';
|
||||
import type { TWallet } from '../../class/wallets/types';
|
||||
import presentAlert from '../../components/Alert';
|
||||
import loc from '../../loc';
|
||||
import * as BlueElectrum from '../../blue_modules/BlueElectrum';
|
||||
import triggerHapticFeedback, { HapticFeedbackTypes } from '../../blue_modules/hapticFeedback';
|
||||
import { startAndDecrypt } from '../../blue_modules/start-and-decrypt';
|
||||
|
||||
const BlueApp = BlueAppClass.getInstance();
|
||||
|
||||
@ -305,5 +304,3 @@ export const BlueStorageProvider = ({ children }: { children: React.ReactNode })
|
||||
|
||||
return <BlueStorageContext.Provider value={value}>{children}</BlueStorageContext.Provider>;
|
||||
};
|
||||
|
||||
export const useStorage = () => useContext(BlueStorageContext);
|
@ -1,10 +1,8 @@
|
||||
import { useAsyncStorage } from '@react-native-async-storage/async-storage';
|
||||
import React, { createContext, useCallback, useContext, useEffect, useMemo, useState } from 'react';
|
||||
import React, { createContext, useCallback, useEffect, useMemo, useState } from 'react';
|
||||
import DefaultPreference from 'react-native-default-preference';
|
||||
|
||||
import BlueClipboard from '../../blue_modules/clipboard';
|
||||
import { getPreferredCurrency, GROUP_IO_BLUEWALLET, initCurrencyDaemon } from '../../blue_modules/currency';
|
||||
import { useStorage } from '../../blue_modules/storage-context';
|
||||
import { clearUseURv1, isURv1Enabled, setUseURv1 } from '../../blue_modules/ur';
|
||||
import { BlueApp } from '../../class';
|
||||
import { saveLanguage, STORAGE_KEY } from '../../loc';
|
||||
@ -13,6 +11,7 @@ import { getEnabled as getIsDeviceQuickActionsEnabled, setEnabled as setIsDevice
|
||||
import presentAlert from '../Alert';
|
||||
import { getIsHandOffUseEnabled, setIsHandOffUseEnabled } from '../HandOffComponent';
|
||||
import { isBalanceDisplayAllowed, setBalanceDisplayAllowed } from '../WidgetCommunication';
|
||||
import { useStorage } from '../../hooks/context/useStorage';
|
||||
|
||||
interface SettingsContextType {
|
||||
preferredFiatCurrency: TFiatUnit;
|
||||
@ -86,7 +85,6 @@ export const SettingsProvider: React.FC<{ children: React.ReactNode }> = ({ chil
|
||||
|
||||
const advancedModeStorage = useAsyncStorage(BlueApp.ADVANCED_MODE_ENABLED);
|
||||
const languageStorage = useAsyncStorage(STORAGE_KEY);
|
||||
|
||||
const { walletsInitialized } = useStorage();
|
||||
|
||||
useEffect(() => {
|
||||
@ -282,6 +280,4 @@ export const SettingsProvider: React.FC<{ children: React.ReactNode }> = ({ chil
|
||||
);
|
||||
|
||||
return <SettingsContext.Provider value={value}>{children}</SettingsContext.Provider>;
|
||||
};
|
||||
|
||||
export const useSettings = () => useContext(SettingsContext);
|
||||
};
|
@ -32,7 +32,7 @@ export async function getEnabled(): Promise<boolean> {
|
||||
}
|
||||
|
||||
function DeviceQuickActions() {
|
||||
const { wallets, walletsInitialized, isStorageEncrypted, addWallet, saveToDisk, setSharedCosigner } = useContext(BlueStorageContext);
|
||||
const { wallets, walletsInitialized, isStorageEncrypted, addWallet, saveToDisk, setSharedCosigner } = useStorage();
|
||||
const { preferredFiatCurrency, isQuickActionsEnabled } = useSettings();
|
||||
|
||||
const { isViewAllWalletsEnabled, getSelectedDefaultWallet } = useOnAppLaunch();
|
||||
|
@ -1,7 +1,6 @@
|
||||
import { CommonActions } from '@react-navigation/native';
|
||||
import { useCallback, useContext, useEffect } from 'react';
|
||||
import { NativeEventEmitter, NativeModules, Platform } from 'react-native';
|
||||
|
||||
import { BlueStorageContext } from '../blue_modules/storage-context';
|
||||
import * as NavigationService from '../NavigationService';
|
||||
|
||||
@ -12,7 +11,7 @@ EventEmitter on the native side should receive a payload and rebuild menus.
|
||||
|
||||
const eventEmitter = Platform.OS === 'ios' || Platform.OS === 'macos' ? new NativeEventEmitter(NativeModules.EventEmitter) : undefined;
|
||||
const MenuElements = () => {
|
||||
const { walletsInitialized, reloadTransactionsMenuActionFunction } = useContext(BlueStorageContext);
|
||||
const { walletsInitialized, reloadTransactionsMenuActionFunction } = useStorage();
|
||||
|
||||
// BlueWallet -> Settings
|
||||
const openSettings = useCallback(() => {
|
||||
|
@ -1,8 +1,7 @@
|
||||
import React, { useCallback, useContext, useEffect, useMemo, useRef, useState } from 'react';
|
||||
import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
||||
import AsyncStorage from '@react-native-async-storage/async-storage';
|
||||
import Clipboard from '@react-native-clipboard/clipboard';
|
||||
import { Linking, StyleSheet, View } from 'react-native';
|
||||
import { BlueStorageContext } from '../blue_modules/storage-context';
|
||||
import Lnurl from '../class/lnurl';
|
||||
import { LightningTransaction, Transaction } from '../class/wallets/types';
|
||||
import TransactionExpiredIcon from '../components/icons/TransactionExpiredIcon';
|
||||
@ -22,6 +21,7 @@ import { Action, ToolTipMenuProps } from './types';
|
||||
import { useExtendedNavigation } from '../hooks/useExtendedNavigation';
|
||||
import { NativeStackNavigationProp } from '@react-navigation/native-stack';
|
||||
import { DetailViewStackParamList } from '../navigation/DetailViewStackParamList';
|
||||
import { useStorage } from '../hooks/context/useStorage';
|
||||
|
||||
interface TransactionListItemProps {
|
||||
itemPriceUnit: BitcoinUnit;
|
||||
@ -36,7 +36,7 @@ export const TransactionListItem: React.FC<TransactionListItemProps> = React.mem
|
||||
const { colors } = useTheme();
|
||||
const { navigate } = useExtendedNavigation<NavigationProps>();
|
||||
const menuRef = useRef<ToolTipMenuProps>();
|
||||
const { txMetadata, counterpartyMetadata, wallets } = useContext(BlueStorageContext);
|
||||
const { txMetadata, counterpartyMetadata, wallets } = useStorage();
|
||||
const { preferredFiatCurrency, language } = useSettings();
|
||||
const containerStyle = useMemo(
|
||||
() => ({
|
||||
|
@ -157,7 +157,7 @@ const iStyles = StyleSheet.create({
|
||||
export const WalletCarouselItem = React.memo(({ item, _, onPress, handleLongPress, isSelectedWallet, customStyle }) => {
|
||||
const scaleValue = new Animated.Value(1.0);
|
||||
const { colors } = useTheme();
|
||||
const { walletTransactionUpdateStatus } = useContext(BlueStorageContext);
|
||||
const { walletTransactionUpdateStatus } = useStorage();
|
||||
const { width } = useWindowDimensions();
|
||||
const itemWidth = width * 0.82 > 375 ? 375 : width * 0.82;
|
||||
const isLargeScreen = useIsLargeScreen();
|
||||
|
@ -17,7 +17,7 @@ import { FiatUnit } from '../models/fiatUnit';
|
||||
import { useSettings } from './Context/SettingsContext';
|
||||
|
||||
function WatchConnectivity() {
|
||||
const { walletsInitialized, wallets, fetchWalletTransactions, saveToDisk, txMetadata } = useContext(BlueStorageContext);
|
||||
const { walletsInitialized, wallets, fetchWalletTransactions, saveToDisk, txMetadata } = useStorage();
|
||||
const { preferredFiatCurrency } = useSettings();
|
||||
const isReachable = useReachability();
|
||||
const isInstalled = useInstalled(); // true | false
|
||||
|
@ -62,7 +62,7 @@ const allWalletsBalanceAndTransactionTime = async (
|
||||
};
|
||||
|
||||
const WidgetCommunication: React.FC = () => {
|
||||
const { wallets, walletsInitialized } = useContext(BlueStorageContext);
|
||||
const { wallets, walletsInitialized } = useStorage();
|
||||
const { isWidgetBalanceDisplayAllowed } = useSettings();
|
||||
|
||||
useEffect(() => {
|
||||
|
@ -5,7 +5,6 @@ import { StyleSheet, Text, View } from 'react-native';
|
||||
import { ListItem } from 'react-native-elements';
|
||||
import Share from 'react-native-share';
|
||||
import triggerHapticFeedback, { HapticFeedbackTypes } from '../../blue_modules/hapticFeedback';
|
||||
import { useStorage } from '../../blue_modules/storage-context';
|
||||
import confirm from '../../helpers/confirm';
|
||||
import { useBiometrics } from '../../hooks/useBiometrics';
|
||||
import loc, { formatBalance } from '../../loc';
|
||||
@ -18,6 +17,7 @@ import { Action, ToolTipMenuProps } from '../types';
|
||||
import { AddressTypeBadge } from './AddressTypeBadge';
|
||||
import { NativeStackNavigationProp } from '@react-navigation/native-stack';
|
||||
import { DetailViewStackParamList } from '../../navigation/DetailViewStackParamList';
|
||||
import { useStorage } from '../../hooks/context/useStorage';
|
||||
|
||||
interface AddressItemProps {
|
||||
// todo: fix `any` after addresses.js is converted to the church of holy typescript
|
||||
|
4
hooks/context/useSettings.ts
Normal file
4
hooks/context/useSettings.ts
Normal file
@ -0,0 +1,4 @@
|
||||
import { useContext } from 'react';
|
||||
import { SettingsContext } from '../../components/Context/SettingsContext';
|
||||
|
||||
export const useSettings = () => useContext(SettingsContext);
|
4
hooks/context/useStorage.ts
Normal file
4
hooks/context/useStorage.ts
Normal file
@ -0,0 +1,4 @@
|
||||
import { useContext } from 'react';
|
||||
import { BlueStorageContext } from '../../components/Context/BlueStorageContext';
|
||||
|
||||
export const useStorage = () => useStorage();
|
@ -5,7 +5,7 @@ import { TWallet } from '../class/wallets/types';
|
||||
|
||||
const useOnAppLaunch = () => {
|
||||
const STORAGE_KEY = 'ONAPP_LAUNCH_SELECTED_DEFAULT_WALLET_KEY';
|
||||
const { wallets } = useContext(BlueStorageContext);
|
||||
const { wallets } = useStorage();
|
||||
|
||||
const getSelectedDefaultWallet = useCallback(async (): Promise<string | undefined> => {
|
||||
let selectedWallet: TWallet | undefined;
|
||||
|
@ -38,7 +38,7 @@ function reducer(state: State, action: Action): State {
|
||||
|
||||
// Component
|
||||
const PlausibleDeniability: React.FC = () => {
|
||||
const { cachedPassword, isPasswordInUse, createFakeStorage, resetWallets } = useContext(BlueStorageContext);
|
||||
const { cachedPassword, isPasswordInUse, createFakeStorage, resetWallets } = useStorage();
|
||||
const [state, dispatch] = useReducer(reducer, initialState);
|
||||
const navigation = useNavigation<NativeStackNavigationProp<Record<string, object | undefined>>>();
|
||||
|
||||
|
@ -34,7 +34,7 @@ type LdkInfoRouteProps = RouteProp<
|
||||
|
||||
const LdkInfo = () => {
|
||||
const { walletID } = useRoute<LdkInfoRouteProps>().params;
|
||||
const { wallets } = useContext(BlueStorageContext);
|
||||
const { wallets } = useStorage();
|
||||
const refreshDataInterval = useRef<NodeJS.Timer>();
|
||||
const sectionList = useRef<SectionList | null>();
|
||||
const wallet = wallets.find(w => w.getID() === walletID) as LightningLdkWallet;
|
||||
|
@ -34,7 +34,7 @@ import { BitcoinUnit, Chain } from '../../models/bitcoinUnits';
|
||||
import * as NavigationService from '../../NavigationService';
|
||||
|
||||
const LNDCreateInvoice = () => {
|
||||
const { wallets, saveToDisk, setSelectedWalletID } = useContext(BlueStorageContext);
|
||||
const { wallets, saveToDisk, setSelectedWalletID } = useStorage();
|
||||
const { walletID, uri } = useRoute().params;
|
||||
const wallet = useRef(wallets.find(item => item.getID() === walletID) || wallets.find(item => item.chain === Chain.OFFCHAIN));
|
||||
const createInvoiceRef = useRef();
|
||||
|
@ -14,7 +14,7 @@ import loc from '../../loc';
|
||||
|
||||
const LNDViewAdditionalInvoiceInformation = () => {
|
||||
const { walletID } = useRoute().params;
|
||||
const { wallets } = useContext(BlueStorageContext);
|
||||
const { wallets } = useStorage();
|
||||
const wallet = wallets.find(w => w.getID() === walletID);
|
||||
const [walletInfo, setWalletInfo] = useState();
|
||||
const { colors } = useTheme();
|
||||
|
@ -19,7 +19,7 @@ import LNDCreateInvoice from './lndCreateInvoice';
|
||||
|
||||
const LNDViewInvoice = () => {
|
||||
const { invoice, walletID } = useRoute().params;
|
||||
const { wallets, setSelectedWalletID, fetchAndSaveWalletTransactions } = useContext(BlueStorageContext);
|
||||
const { wallets, setSelectedWalletID, fetchAndSaveWalletTransactions } = useStorage();
|
||||
const wallet = wallets.find(w => w.getID() === walletID);
|
||||
const { colors, closeImage } = useTheme();
|
||||
const { goBack, navigate, setParams, setOptions, getParent } = useNavigation();
|
||||
|
@ -24,7 +24,7 @@ const AuthState = {
|
||||
};
|
||||
|
||||
const LnurlAuth = () => {
|
||||
const { wallets } = useContext(BlueStorageContext);
|
||||
const { wallets } = useStorage();
|
||||
const { name } = useRoute();
|
||||
const { walletID, lnurl } = useRoute().params;
|
||||
const wallet = useMemo(() => wallets.find(w => w.getID() === walletID), [wallets, walletID]);
|
||||
|
@ -35,7 +35,7 @@ import { SuccessView } from '../send/success';
|
||||
|
||||
const ReceiveDetails = () => {
|
||||
const { walletID, address } = useRoute().params;
|
||||
const { wallets, saveToDisk, sleep, isElectrumDisabled, fetchAndSaveWalletTransactions } = useContext(BlueStorageContext);
|
||||
const { wallets, saveToDisk, sleep, isElectrumDisabled, fetchAndSaveWalletTransactions } = useStorage();
|
||||
const wallet = wallets.find(w => w.getID() === walletID);
|
||||
const [customLabel, setCustomLabel] = useState();
|
||||
const [customAmount, setCustomAmount] = useState();
|
||||
|
@ -66,7 +66,7 @@ type ConfirmRouteProp = RouteProp<SendDetailsStackParamList, 'Confirm'>;
|
||||
type ConfirmNavigationProp = NativeStackNavigationProp<SendDetailsStackParamList, 'Confirm'>;
|
||||
|
||||
const Confirm: React.FC = () => {
|
||||
const { wallets, fetchAndSaveWalletTransactions, counterpartyMetadata, isElectrumDisabled } = useContext(BlueStorageContext);
|
||||
const { wallets, fetchAndSaveWalletTransactions, counterpartyMetadata, isElectrumDisabled } = useStorage();
|
||||
const { isBiometricUseCapableAndEnabled, unlockWithBiometrics } = useBiometrics();
|
||||
const navigation = useExtendedNavigation<ConfirmNavigationProp>();
|
||||
const route = useRoute<ConfirmRouteProp>(); // Get the route and its params
|
||||
|
@ -62,7 +62,7 @@ const OutputList = ({
|
||||
onDeSelect,
|
||||
}) => {
|
||||
const { colors } = useTheme();
|
||||
const { txMetadata } = useContext(BlueStorageContext);
|
||||
const { txMetadata } = useStorage();
|
||||
const memo = oMemo || txMetadata[txid]?.memo || '';
|
||||
const color = `#${txid.substring(0, 6)}`;
|
||||
const amount = formatBalance(value, balanceUnit, true);
|
||||
@ -124,7 +124,7 @@ OutputList.propTypes = {
|
||||
|
||||
const OutputModal = ({ item: { address, txid, value, vout, confirmations = 0 }, balanceUnit = BitcoinUnit.BTC, oMemo }) => {
|
||||
const { colors } = useTheme();
|
||||
const { txMetadata } = useContext(BlueStorageContext);
|
||||
const { txMetadata } = useStorage();
|
||||
const memo = oMemo || txMetadata[txid]?.memo || '';
|
||||
const fullId = `${txid}:${vout}`;
|
||||
const color = `#${txid.substring(0, 6)}`;
|
||||
@ -198,7 +198,7 @@ const mStyles = StyleSheet.create({
|
||||
|
||||
const OutputModalContent = ({ output, wallet, onUseCoin, frozen, setFrozen }) => {
|
||||
const { colors } = useTheme();
|
||||
const { txMetadata, saveToDisk } = useContext(BlueStorageContext);
|
||||
const { txMetadata, saveToDisk } = useStorage();
|
||||
const [memo, setMemo] = useState(wallet.getUTXOMetadata(output.txid, output.vout).memo || txMetadata[output.txid]?.memo || '');
|
||||
const onMemoChange = value => setMemo(value);
|
||||
const switchValue = useMemo(() => ({ value: frozen, onValueChange: value => setFrozen(value) }), [frozen, setFrozen]);
|
||||
@ -256,7 +256,7 @@ const CoinControl = () => {
|
||||
const navigation = useNavigation();
|
||||
const { width } = useWindowDimensions();
|
||||
const { walletID, onUTXOChoose } = useRoute().params;
|
||||
const { wallets, saveToDisk, sleep } = useContext(BlueStorageContext);
|
||||
const { wallets, saveToDisk, sleep } = useStorage();
|
||||
const wallet = wallets.find(w => w.getID() === walletID);
|
||||
// sort by height ascending, txid , vout ascending
|
||||
const utxo = wallet.getUtxo(true).sort((a, b) => a.height - b.height || a.txid.localeCompare(b.txid) || a.vout - b.vout);
|
||||
|
@ -75,7 +75,7 @@ type NavigationProps = NativeStackNavigationProp<SendDetailsStackParamList, 'Sen
|
||||
type RouteProps = RouteProp<SendDetailsStackParamList, 'SendDetails'>;
|
||||
|
||||
const SendDetails = () => {
|
||||
const { wallets, setSelectedWalletID, sleep, txMetadata, saveToDisk } = useContext(BlueStorageContext);
|
||||
const { wallets, setSelectedWalletID, sleep, txMetadata, saveToDisk } = useStorage();
|
||||
const navigation = useExtendedNavigation<NavigationProps>();
|
||||
const route = useRoute<RouteProps>();
|
||||
const name = route.name;
|
||||
|
@ -20,7 +20,7 @@ const shortenAddress = addr => {
|
||||
};
|
||||
|
||||
const PsbtMultisig = () => {
|
||||
const { wallets } = useContext(BlueStorageContext);
|
||||
const { wallets } = useStorage();
|
||||
const { navigate, setParams } = useNavigation();
|
||||
const { colors } = useTheme();
|
||||
const [flatListHeight, setFlatListHeight] = useState(0);
|
||||
|
@ -22,7 +22,7 @@ enum SettingsPrivacySection {
|
||||
|
||||
const SettingsPrivacy: React.FC = () => {
|
||||
const { colors } = useTheme();
|
||||
const { isStorageEncrypted } = useContext(BlueStorageContext);
|
||||
const { isStorageEncrypted } = useStorage();
|
||||
const {
|
||||
isDoNotTrackEnabled,
|
||||
setDoNotTrackStorage,
|
||||
|
@ -22,7 +22,7 @@ const About = () => {
|
||||
const { navigate } = useNavigation();
|
||||
const { colors } = useTheme();
|
||||
const { width, height } = useWindowDimensions();
|
||||
const { isElectrumDisabled } = useContext(BlueStorageContext);
|
||||
const { isElectrumDisabled } = useStorage();
|
||||
const styles = StyleSheet.create({
|
||||
copyToClipboard: {
|
||||
justifyContent: 'center',
|
||||
|
@ -69,7 +69,7 @@ type NavigationProps = NativeStackNavigationProp<DetailViewStackParamList, 'Tran
|
||||
const TransactionDetails = () => {
|
||||
const { setOptions, navigate } = useExtendedNavigation<NavigationProps>();
|
||||
const { hash, walletID } = useRoute<TransactionDetailsProps['route']>().params;
|
||||
const { saveToDisk, txMetadata, counterpartyMetadata, wallets, getTransactions } = useContext(BlueStorageContext);
|
||||
const { saveToDisk, txMetadata, counterpartyMetadata, wallets, getTransactions } = useStorage();
|
||||
const [from, setFrom] = useState<string[]>([]);
|
||||
const [to, setTo] = useState<string[]>([]);
|
||||
const [isLoading, setIsLoading] = useState(true);
|
||||
|
@ -84,7 +84,7 @@ const DrawerList: React.FC<DrawerListProps> = memo(({ navigation }) => {
|
||||
|
||||
const [state, dispatch] = useReducer(walletReducer, initialState);
|
||||
const walletsCarousel = useRef<FlatList<TWallet>>(null);
|
||||
const { wallets, selectedWalletID } = useContext(BlueStorageContext);
|
||||
const { wallets, selectedWalletID } = useStorage();
|
||||
const { colors } = useTheme();
|
||||
const isFocused = useIsFocused();
|
||||
|
||||
|
@ -65,7 +65,7 @@ const ExportMultisigCoordinationSetup: React.FC = () => {
|
||||
const { isLoading, isShareButtonTapped, qrCodeContents } = state;
|
||||
const { params } = useRoute<RouteProp<RootStackParamList, 'ExportMultisigCoordinationSetup'>>();
|
||||
const walletID = params.walletID;
|
||||
const { wallets } = useContext(BlueStorageContext);
|
||||
const { wallets } = useStorage();
|
||||
const wallet: TWallet | undefined = wallets.find(w => w.getID() === walletID);
|
||||
const dynamicQRCode = useRef<any>();
|
||||
const { colors } = useTheme();
|
||||
|
@ -44,7 +44,7 @@ import loc from '../../loc';
|
||||
const staticCache = {};
|
||||
|
||||
const WalletsAddMultisigStep2 = () => {
|
||||
const { addWallet, saveToDisk, isElectrumDisabled, sleep, currentSharedCosigner, setSharedCosigner } = useContext(BlueStorageContext);
|
||||
const { addWallet, saveToDisk, isElectrumDisabled, sleep, currentSharedCosigner, setSharedCosigner } = useStorage();
|
||||
const { isAdvancedModeEnabled } = useSettings();
|
||||
const { colors } = useTheme();
|
||||
|
||||
|
@ -59,7 +59,7 @@ const WalletAddresses = () => {
|
||||
|
||||
const [currentTab, setCurrentTab] = useState(TABS.EXTERNAL);
|
||||
|
||||
const { wallets } = useContext(BlueStorageContext);
|
||||
const { wallets } = useStorage();
|
||||
|
||||
const { walletID } = useRoute().params;
|
||||
|
||||
|
@ -14,7 +14,7 @@ import usePrivacy from '../../hooks/usePrivacy';
|
||||
import loc from '../../loc';
|
||||
|
||||
const WalletExport = () => {
|
||||
const { wallets, saveToDisk } = useContext(BlueStorageContext);
|
||||
const { wallets, saveToDisk } = useStorage();
|
||||
const { walletID } = useRoute().params;
|
||||
const [isLoading, setIsLoading] = useState(true);
|
||||
const { goBack } = useNavigation();
|
||||
|
@ -27,7 +27,7 @@ const ImportCustomDerivationPath = () => {
|
||||
const route = useRoute();
|
||||
const importText = route.params.importText;
|
||||
const password = route.params.password;
|
||||
const { addAndSaveWallet } = useContext(BlueStorageContext);
|
||||
const { addAndSaveWallet } = useStorage();
|
||||
const [path, setPath] = useState("m/84'/0'/0'");
|
||||
const [wallets, setWallets] = useState({});
|
||||
const [used, setUsed] = useState({});
|
||||
|
@ -22,7 +22,7 @@ const ImportWalletDiscovery = () => {
|
||||
const route = useRoute();
|
||||
const { importText, askPassphrase, searchAccounts } = route.params;
|
||||
const task = useRef();
|
||||
const { addAndSaveWallet } = useContext(BlueStorageContext);
|
||||
const { addAndSaveWallet } = useStorage();
|
||||
const [loading, setLoading] = useState(true);
|
||||
const [wallets, setWallets] = useState([]);
|
||||
const [password, setPassword] = useState();
|
||||
|
@ -17,7 +17,7 @@ const WalletsImportWallet = () => {
|
||||
const [importText, setImportText] = useState();
|
||||
const [walletType, setWalletType] = useState();
|
||||
const [passphrase, setPassphrase] = useState();
|
||||
const { addAndSaveWallet } = useContext(BlueStorageContext);
|
||||
const { addAndSaveWallet } = useStorage();
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
root: {
|
||||
|
@ -15,7 +15,7 @@ import loc from '../../loc';
|
||||
|
||||
const LdkViewLogs = () => {
|
||||
const { colors } = useTheme();
|
||||
const { wallets } = useContext(BlueStorageContext);
|
||||
const { wallets } = useStorage();
|
||||
const { walletID } = useRoute().params;
|
||||
/** @type {LightningLdkWallet} */
|
||||
const wallet = wallets.find(w => w.getID() === walletID);
|
||||
|
@ -13,7 +13,7 @@ import usePrivacy from '../../hooks/usePrivacy';
|
||||
import loc from '../../loc';
|
||||
|
||||
const PleaseBackupLNDHub = () => {
|
||||
const { wallets } = useContext(BlueStorageContext);
|
||||
const { wallets } = useStorage();
|
||||
const { walletID } = useRoute().params;
|
||||
const wallet = wallets.find(w => w.getID() === walletID);
|
||||
const navigation = useNavigation();
|
||||
|
@ -13,7 +13,7 @@ import usePrivacy from '../../hooks/usePrivacy';
|
||||
import loc from '../../loc';
|
||||
|
||||
const PleaseBackupLdk = () => {
|
||||
const { wallets } = useContext(BlueStorageContext);
|
||||
const { wallets } = useStorage();
|
||||
const { walletID } = useRoute().params;
|
||||
/** @type {LightningLdkWallet} */
|
||||
const wallet = wallets.find(w => w.getID() === walletID);
|
||||
|
@ -22,7 +22,7 @@ const styles = StyleSheet.create({
|
||||
const ReorderWallets = () => {
|
||||
const sortableList = useRef();
|
||||
const { colors } = useTheme();
|
||||
const { wallets, setWalletsWithNewOrder } = useContext(BlueStorageContext);
|
||||
const { wallets, setWalletsWithNewOrder } = useStorage();
|
||||
const colorScheme = useColorScheme();
|
||||
const { navigate, setOptions } = useExtendedNavigation();
|
||||
const [searchQuery, setSearchQuery] = useState('');
|
||||
|
@ -18,7 +18,7 @@ const SelectWallet = () => {
|
||||
const { chainType, onWalletSelect, availableWallets, noWalletExplanationText, onChainRequireSend = false } = useRoute().params;
|
||||
const [isLoading, setIsLoading] = useState(true);
|
||||
const { pop, navigate, setOptions, getParent } = useNavigation();
|
||||
const { wallets } = useContext(BlueStorageContext);
|
||||
const { wallets } = useStorage();
|
||||
const { colors, closeImage } = useTheme();
|
||||
const isModal = useNavigationState(state => state.routes.length) === 1;
|
||||
let data = !onChainRequireSend
|
||||
|
@ -25,7 +25,7 @@ import loc from '../../loc';
|
||||
|
||||
const SignVerify = () => {
|
||||
const { colors } = useTheme();
|
||||
const { wallets, sleep } = useContext(BlueStorageContext);
|
||||
const { wallets, sleep } = useStorage();
|
||||
const { params } = useRoute();
|
||||
const [isKeyboardVisible, setIsKeyboardVisible] = useState(false);
|
||||
const [address, setAddress] = useState(params.address ?? '');
|
||||
|
@ -1,9 +1,7 @@
|
||||
import { NavigationProp, RouteProp, useFocusEffect, useNavigation, useRoute } from '@react-navigation/native';
|
||||
import React, { useCallback, useContext, useEffect, useRef, useState } from 'react';
|
||||
import React, { useCallback, useEffect, useRef, useState } from 'react';
|
||||
import { ActivityIndicator, InteractionManager, View } from 'react-native';
|
||||
import Share from 'react-native-share';
|
||||
|
||||
import { BlueStorageContext } from '../../blue_modules/storage-context';
|
||||
import { BlueSpacing20, BlueText } from '../../BlueComponents';
|
||||
import Button from '../../components/Button';
|
||||
import CopyTextToClipboard from '../../components/CopyTextToClipboard';
|
||||
@ -13,6 +11,7 @@ import SafeArea from '../../components/SafeArea';
|
||||
import usePrivacy from '../../hooks/usePrivacy';
|
||||
import loc from '../../loc';
|
||||
import { styles, useDynamicStyles } from './xpub.styles';
|
||||
import { useStorage } from '../../hooks/context/useStorage';
|
||||
|
||||
type WalletXpubRouteProp = RouteProp<{ params: { walletID: string; xpub: string } }, 'params'>;
|
||||
export type RootStackParamList = {
|
||||
@ -23,7 +22,7 @@ export type RootStackParamList = {
|
||||
};
|
||||
|
||||
const WalletXpub: React.FC = () => {
|
||||
const { wallets } = useContext(BlueStorageContext);
|
||||
const { wallets } = useStorage();
|
||||
const route = useRoute<WalletXpubRouteProp>();
|
||||
const { walletID, xpub } = route.params;
|
||||
const wallet = wallets.find(w => w.getID() === walletID);
|
||||
|
Loading…
Reference in New Issue
Block a user