Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: update redux-toolkit #1413

Merged
merged 3 commits into from
Dec 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions __tests__/backups.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ import {
performWidgetsRestore,
} from '../src/store/actions/backup';
import {
dispatch,
getActivityStore,
getBlocktankStore,
getDispatch,
getMetaDataStore,
getSettingsStore,
getWidgetsStore,
Expand Down Expand Up @@ -274,7 +274,6 @@ describe('Remote backups', () => {
});

it('Backups and restores Blocktank orders', async () => {
const dispatch = getDispatch();
addPaidBlocktankOrder({ orderId: 'id', txid: 'txid' });
dispatch({
type: actions.UPDATE_BLOCKTANK_ORDER,
Expand Down
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
"@react-navigation/native": "6.1.9",
"@react-navigation/native-stack": "6.9.17",
"@react-navigation/stack": "6.3.20",
"@reduxjs/toolkit": "1.9.7",
"@reduxjs/toolkit": "2.0.1",
"@sayem314/react-native-keep-awake": "1.2.2",
"@shopify/react-native-skia": "0.1.225",
"@synonymdev/blocktank-client": "0.0.50",
Expand Down Expand Up @@ -122,11 +122,11 @@
"react-native-tcp-socket": "5.6.2",
"react-native-toast-message": "2.1.7",
"react-native-zip-archive": "6.1.0",
"react-redux": "8.1.3",
"redux": "4.2.1",
"react-redux": "9.0.2",
"redux": "5.0.0",
"redux-logger": "3.0.6",
"redux-persist": "6.0.0",
"redux-thunk": "2.4.2",
"redux-thunk": "3.1.0",
"rn-android-keyboard-adjust": "2.1.2",
"rn-electrum-client": "github:synonymdev/react-native-electrum-client#a32a292d4e4918a04d280137e24e5961c74c543f",
"rn-qr-generator": "1.3.1",
Expand Down Expand Up @@ -156,7 +156,7 @@
"@types/mime": "^3.0.3",
"@types/react": "^18.2.7",
"@types/react-native-dotenv": "^0.2.1",
"@types/redux-logger": "^3.0.11",
"@types/redux-logger": "^3.0.12",
"@types/styled-components-react-native": "^5.2.4",
"@types/url-parse": "^1.4.10",
"@types/uuid": "^9.0.6",
Expand Down
8 changes: 4 additions & 4 deletions src/screens/Lightning/Introduction.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { useBalance } from '../../hooks/wallet';
import { isGeoBlockedSelector } from '../../store/reselect/user';
import { TRANSACTION_DEFAULTS } from '../../utils/wallet/constants';
import type { LightningScreenProps } from '../../navigation/types';
import { lightningSelector } from '../../store/reselect/lightning';
import { accountVersionSelector } from '../../store/reselect/lightning';
import { showToast } from '../../utils/notifications';

const imageSrc = require('../../assets/illustrations/lightning.png');
Expand All @@ -23,7 +23,7 @@ const Introduction = ({
const { t } = useTranslation('lightning');
const { onchainBalance } = useBalance();
const isGeoBlocked = useSelector(isGeoBlockedSelector);
const lightning = useSelector(lightningSelector);
const accountVersion = useSelector(accountVersionSelector);

const txt = useMemo(
() => t(isGeoBlocked ? 'int_blocked' : 'int_text'),
Expand Down Expand Up @@ -71,7 +71,7 @@ const Introduction = ({
disabled={isDisabled}
testID="QuickSetupButton"
onPress={(): void => {
if (lightning.accountVersion < 2) {
if (accountVersion < 2) {
showToast({
type: 'error',
title: t('migrating_ldk_title'),
Expand All @@ -91,7 +91,7 @@ const Introduction = ({
disabled={isDisabled}
testID="CustomSetupButton"
onPress={(): void => {
if (lightning.accountVersion < 2) {
if (accountVersion < 2) {
showToast({
type: 'error',
title: t('migrating_ldk_title'),
Expand Down
6 changes: 3 additions & 3 deletions src/screens/Settings/DevSettings/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import { resetSettingsStore, wipeApp } from '../../../store/actions/settings';
import { getStore, getWalletStore } from '../../../store/helpers';
import { resetMetaStore } from '../../../store/actions/metadata';
import { warningsSelector } from '../../../store/reselect/checks';
import { lightningSelector } from '../../../store/reselect/lightning';
import { accountVersionSelector } from '../../../store/reselect/lightning';
import {
addressTypeSelector,
selectedNetworkSelector,
Expand Down Expand Up @@ -60,7 +60,7 @@ const DevSettings = ({
const selectedWallet = useSelector(selectedWalletSelector);
const selectedNetwork = useSelector(selectedNetworkSelector);
const addressType = useSelector(addressTypeSelector);
const lightning = useSelector(lightningSelector);
const accountVersion = useSelector(accountVersionSelector);
const warnings = useSelector((state) => {
return warningsSelector(state, selectedWallet, selectedNetwork);
});
Expand Down Expand Up @@ -226,7 +226,7 @@ const DevSettings = ({
title: 'LDK Account Migration',
data: [
{
title: `LDK Account Version: ${lightning.accountVersion}`,
title: `LDK Account Version: ${accountVersion}`,
type: EItemType.textButton,
value: '',
testID: 'LDKAccountVersion',
Expand Down
8 changes: 4 additions & 4 deletions src/screens/Settings/Lightning/Channels.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ import {
} from '../../../store/reselect/wallet';
import {
closedChannelsSelector,
lightningSelector,
accountVersionSelector,
openChannelsSelector,
pendingChannelsSelector,
} from '../../../store/reselect/lightning';
Expand Down Expand Up @@ -240,7 +240,7 @@ const Channels = ({
const selectedWallet = useSelector(selectedWalletSelector);
const selectedNetwork = useSelector(selectedNetworkSelector);
const enableDevOptions = useSelector(enableDevOptionsSelector);
const lightning = useSelector(lightningSelector);
const accountVersion = useSelector(accountVersionSelector);

const blocktankOrders = useSelector(blocktankOrdersSelector);
const paidOrders = useSelector(blocktankPaidOrdersSelector);
Expand All @@ -259,7 +259,7 @@ const Channels = ({
const pendingConnections = [...pendingOrders, ...pendingChannels];

const handleAdd = useCallback((): void => {
if (lightning.accountVersion < 2) {
if (accountVersion < 2) {
showToast({
type: 'error',
title: t('migrating_ldk_title'),
Expand All @@ -274,7 +274,7 @@ const Channels = ({

// TODO: Update this view once we enable creating channels with nodes other than Blocktank.
// navigation.navigate('LightningAddConnection');
}, [lightning.accountVersion, navigation, t]);
}, [accountVersion, navigation, t]);

const handleExportLogs = useCallback(async (): Promise<void> => {
const result = await zipLogs();
Expand Down
8 changes: 4 additions & 4 deletions src/screens/Wallets/Receive/ReceiveDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ import { DEFAULT_CHANNEL_DURATION } from '../../Lightning/CustomConfirm';
import { blocktankInfoSelector } from '../../../store/reselect/blocktank';
import { isGeoBlockedSelector } from '../../../store/reselect/user';
import { useLightningBalance } from '../../../hooks/lightning';
import { lightningSelector } from '../../../store/reselect/lightning';
import { accountVersionSelector } from '../../../store/reselect/lightning';

const imageSrc = require('../../../assets/illustrations/coin-stack-4.png');

Expand All @@ -68,7 +68,7 @@ const ReceiveDetails = ({
const blocktank = useSelector(blocktankInfoSelector);
const lightningBalance = useLightningBalance(false);
const isGeoBlocked = useSelector(isGeoBlockedSelector);
const lightning = useSelector(lightningSelector);
const accountVersion = useSelector(accountVersionSelector);

const { maxChannelSizeSat } = blocktank.options;

Expand All @@ -85,7 +85,7 @@ const ReceiveDetails = ({
!enableInstant ||
isGeoBlocked ||
lightningBalance.remoteBalance >= invoice.amount ||
lightning.accountVersion < 2
accountVersion < 2
) {
return;
}
Expand Down Expand Up @@ -116,7 +116,7 @@ const ReceiveDetails = ({
invoice.amount,
invoice.message,
isGeoBlocked,
lightning.accountVersion,
accountVersion,
lightningBalance.remoteBalance,
navigation,
]);
Expand Down
10 changes: 5 additions & 5 deletions src/screens/Wallets/Receive/ReceiveQR.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ import {
import { receiveSelector } from '../../../store/reselect/receive';
import { ReceiveScreenProps } from '../../../navigation/types';
import { isGeoBlockedSelector } from '../../../store/reselect/user';
import { lightningSelector } from '../../../store/reselect/lightning';
import { accountVersionSelector } from '../../../store/reselect/lightning';

type Slide = () => ReactElement;

Expand All @@ -84,7 +84,7 @@ const ReceiveQR = ({
const selectedNetwork = useSelector(selectedNetworkSelector);
const addressType = useSelector(addressTypeSelector);
const isGeoBlocked = useSelector(isGeoBlockedSelector);
const lightning = useSelector(lightningSelector);
const accountVersion = useSelector(accountVersionSelector);
const { id, amount, message, tags, jitOrder } = useSelector(receiveSelector);
const lightningBalance = useLightningBalance(false);
const receiveNavigationIsOpen = useSelector((state) =>
Expand Down Expand Up @@ -113,7 +113,7 @@ const ReceiveQR = ({
!receiveNavigationIsOpen ||
!lightningBalance.remoteBalance ||
lightningBalance.remoteBalance < amount ||
lightning.accountVersion < 2
accountVersion < 2
) {
return;
}
Expand Down Expand Up @@ -313,11 +313,11 @@ const ReceiveQR = ({
const qrSize = Math.min(qrMaxWidth, qrMaxHeight);

const displayReceiveInstantlySwitch = useMemo((): boolean => {
if (lightning.accountVersion < 2) {
if (accountVersion < 2) {
return false;
}
return !(isGeoBlocked && !lightningBalance.remoteBalance);
}, [isGeoBlocked, lightning.accountVersion, lightningBalance.remoteBalance]);
}, [isGeoBlocked, accountVersion, lightningBalance.remoteBalance]);

const QrIcon = useCallback((): ReactElement => {
return (
Expand Down
6 changes: 3 additions & 3 deletions src/screens/Wallets/WalletsDetail/BitcoinBreakdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { TransferIcon, SavingsIcon, CoinsIcon } from '../../../styles/icons';
import { useBalance } from '../../../hooks/wallet';
import { RootNavigationProp } from '../../../navigation/types';
import { isGeoBlockedSelector } from '../../../store/reselect/user';
import { lightningSelector } from '../../../store/reselect/lightning';
import { accountVersionSelector } from '../../../store/reselect/lightning';
import { showToast } from '../../../utils/notifications';
import { openChannelIdsSelector } from '../../../store/reselect/lightning';
import NetworkRow from './NetworkRow';
Expand All @@ -18,7 +18,7 @@ const BitcoinBreakdown = (): ReactElement => {
const { t } = useTranslation('wallet');
const navigation = useNavigation<RootNavigationProp>();
const isGeoBlocked = useSelector(isGeoBlockedSelector);
const lightning = useSelector(lightningSelector);
const accountVersion = useSelector(accountVersionSelector);
const openChannelIds = useSelector(openChannelIdsSelector);
const {
onchainBalance,
Expand All @@ -31,7 +31,7 @@ const BitcoinBreakdown = (): ReactElement => {
const isTransferToSavings = openChannelIds.length === 0;

const onRebalancePress = (): void => {
if (lightning.accountVersion < 2) {
if (accountVersion < 2) {
showToast({
type: 'error',
title: t('migrating_ldk_title'),
Expand Down
4 changes: 1 addition & 3 deletions src/store/actions/activity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
IActivityItem,
TLightningActivityItem,
} from '../types/activity';
import { getBlocktankStore, getDispatch } from '../helpers';
import { getBlocktankStore, dispatch } from '../helpers';
import { onChainTransactionToActivityItem } from '../../utils/activity';
import { getCurrentWallet } from '../../utils/wallet';
import { formatBoostedActivityItems } from '../../utils/boost';
Expand All @@ -17,8 +17,6 @@ import { checkPendingCJitEntries } from './blocktank';
import { getLightningChannels } from '../../utils/lightning';
import { updateSettings } from './settings';

const dispatch = getDispatch();

/**
* Adds the provided activity item to the activity list.
* @param {IActivityItem} activityItem
Expand Down
4 changes: 1 addition & 3 deletions src/store/actions/backup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { err, ok, Result } from '@synonymdev/result';
import lm, { ldk, ENetworks, TLdkData } from '@synonymdev/react-native-ldk';

import actions from './actions';
import { getBackupStore, getDispatch } from '../helpers';
import { getBackupStore, dispatch } from '../helpers';
import {
EBackupCategories,
fetchBackup,
Expand Down Expand Up @@ -47,8 +47,6 @@ import {
__BACKUPS_SERVER_PUBKEY__,
} from '../../constants/env';

const dispatch = getDispatch();

/**
* Triggers a full remote backup
* @return {Promise<Result<string>>}
Expand Down
4 changes: 1 addition & 3 deletions src/store/actions/blocktank.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { err, ok, Result } from '@synonymdev/result';
import actions from './actions';
import { resetSendTransaction, updateSendTransaction } from './wallet';
import { setLightningSettingUpStep } from './user';
import { getBlocktankStore, getDispatch, getWalletStore } from '../helpers';
import { getBlocktankStore, getWalletStore, dispatch } from '../helpers';
import * as blocktank from '../../utils/blocktank';
import {
createOrder,
Expand Down Expand Up @@ -42,8 +42,6 @@ import {
} from '@synonymdev/blocktank-lsp-http-client';
import { CJitStateEnum } from '@synonymdev/blocktank-lsp-http-client/dist/shared/CJitStateEnum';

const dispatch = getDispatch();

/**
* Retrieves & updates the status of stored orders that may have changed.
* @returns {Promise<Result<string>>}
Expand Down
4 changes: 1 addition & 3 deletions src/store/actions/checks.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
import actions from './actions';
import { getDispatch } from '../helpers';
import { dispatch } from '../helpers';
import { TWalletName } from '../types/wallet';
import { getSelectedNetwork, getSelectedWallet } from '../../utils/wallet';
import { TAvailableNetworks } from '../../utils/networks';
import { TStorageWarning } from '../types/checks';
import { getWarnings } from '../../utils/checks';

const dispatch = getDispatch();

/**
* Adds a single warning.
* @param {TStorageWarning} warning
Expand Down
4 changes: 1 addition & 3 deletions src/store/actions/fees.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
import { ok, err, Result } from '@synonymdev/result';

import actions from './actions';
import { getDispatch, getFeesStore } from '../helpers';
import { dispatch, getFeesStore } from '../helpers';
import { getFeeEstimates } from '../../utils/wallet/transactions';
import { TAvailableNetworks } from '../../utils/networks';
import { IOnchainFees } from '../types/fees';

const dispatch = getDispatch();

export const REFRESH_INTERVAL = 60 * 30; // in seconds, 30 minutes

export const updateOnchainFeeEstimates = async ({
Expand Down
4 changes: 1 addition & 3 deletions src/store/actions/lightning.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { TChannel, TInvoice } from '@synonymdev/react-native-ldk';
import { getLNURLParams, lnurlChannel } from '@synonymdev/react-native-lnurl';

import actions from './actions';
import { getDispatch, getLightningStore, getMetaDataStore } from '../helpers';
import { dispatch, getLightningStore, getMetaDataStore } from '../helpers';
import { TAvailableNetworks } from '../../utils/networks';
import { getActivityItemById } from '../../utils/activity';
import { getSelectedNetwork, getSelectedWallet } from '../../utils/wallet';
Expand All @@ -29,8 +29,6 @@ import {
import { EPaymentType, TWalletName } from '../types/wallet';
import { EActivityType, TLightningActivityItem } from '../types/activity';

const dispatch = getDispatch();

/**
* Attempts to update the node id for the given wallet and network.
* @param {string} nodeId
Expand Down
4 changes: 1 addition & 3 deletions src/store/actions/metadata.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
import { ok, Result } from '@synonymdev/result';
import actions from './actions';
import { getDispatch, getMetaDataStore } from '../helpers';
import { dispatch, getMetaDataStore } from '../helpers';
import { getCurrentWallet } from '../../utils/wallet';
import { EPaymentType } from '../types/wallet';
import { IMetadata } from '../types/metadata';

const dispatch = getDispatch();

/*
* This action updates transactions tags
*/
Expand Down
4 changes: 1 addition & 3 deletions src/store/actions/receive.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import { ok, Result } from '@synonymdev/result';
import { ICJitEntry } from '@synonymdev/blocktank-lsp-http-client';
import actions from './actions';
import { getDispatch } from '../helpers';

const dispatch = getDispatch();
import { dispatch } from '../helpers';

export const updateInvoice = (payload: {
amount?: number;
Expand Down
Loading
Loading