From 6e802de7a94205fa864c9a0f83a65240181b494d Mon Sep 17 00:00:00 2001 From: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Mon, 5 Sep 2022 16:34:39 -0400 Subject: [PATCH 1/3] Replace @react-native-community/async-storage for @react-native-async-storage/async-storage --- .../async-storage.js | 1 + app/components/Nav/App/index.js | 2 +- .../UI/WhatsNewModal/WhatsNewModal.tsx | 2 +- app/components/Views/ChoosePassword/index.js | 2 +- app/components/Views/ExtensionSync/index.tsx | 2 +- app/components/Views/ImportFromSeed/index.js | 2 +- app/components/Views/Login/index.js | 2 +- .../Views/ManualBackupStep3/index.js | 2 +- app/components/Views/Onboarding/index.js | 2 +- app/components/Views/ResetPassword/index.js | 2 +- .../Views/RevealPrivateCredential/index.js | 2 +- .../Views/Settings/SecuritySettings/index.js | 2 +- .../Views/WalletConnectSessions/index.js | 2 +- app/components/hooks/useDeleteWallet.ts | 2 +- app/core/Engine.js | 2 +- app/core/NotificationManager.js | 2 +- app/core/SecureKeychain.js | 2 +- app/core/WalletConnect.js | 2 +- app/store/index.js | 2 +- .../authentication/checkIfUsingRememberMe.ts | 2 +- app/util/onboarding/index.ts | 2 +- app/util/testSetup.js | 7 +++-- ios/Podfile.lock | 8 ++--- locales/i18n.js | 2 +- package.json | 2 +- yarn.lock | 30 +++++++++---------- 26 files changed, 47 insertions(+), 43 deletions(-) create mode 100644 app/__mocks__/@react-native-async-storage/async-storage.js diff --git a/app/__mocks__/@react-native-async-storage/async-storage.js b/app/__mocks__/@react-native-async-storage/async-storage.js new file mode 100644 index 00000000000..dad97c781f2 --- /dev/null +++ b/app/__mocks__/@react-native-async-storage/async-storage.js @@ -0,0 +1 @@ +export default from '@react-native-async-storage/async-storage/jest/async-storage-mock'; diff --git a/app/components/Nav/App/index.js b/app/components/Nav/App/index.js index 2c6efdc9677..fba7de8fe9d 100644 --- a/app/components/Nav/App/index.js +++ b/app/components/Nav/App/index.js @@ -8,7 +8,7 @@ import React, { import { NavigationContainer, CommonActions } from '@react-navigation/native'; import { Animated, Linking } from 'react-native'; import { createStackNavigator } from '@react-navigation/stack'; -import AsyncStorage from '@react-native-community/async-storage'; +import AsyncStorage from '@react-native-async-storage/async-storage'; import Login from '../../Views/Login'; import QRScanner from '../../Views/QRScanner'; import Onboarding from '../../Views/Onboarding'; diff --git a/app/components/UI/WhatsNewModal/WhatsNewModal.tsx b/app/components/UI/WhatsNewModal/WhatsNewModal.tsx index 5fd2f4ae521..08f0f069d80 100644 --- a/app/components/UI/WhatsNewModal/WhatsNewModal.tsx +++ b/app/components/UI/WhatsNewModal/WhatsNewModal.tsx @@ -13,7 +13,7 @@ import { fontStyles } from '../../../styles/common'; import Icon from 'react-native-vector-icons/FontAwesome'; import { strings } from '../../../../locales/i18n'; import Device from '../../../util/device'; -import AsyncStorage from '@react-native-community/async-storage'; +import AsyncStorage from '@react-native-async-storage/async-storage'; import { CURRENT_APP_VERSION, WHATS_NEW_APP_VERSION_SEEN, diff --git a/app/components/Views/ChoosePassword/index.js b/app/components/Views/ChoosePassword/index.js index 9954b6c7803..fd7c7a3ba65 100644 --- a/app/components/Views/ChoosePassword/index.js +++ b/app/components/Views/ChoosePassword/index.js @@ -13,7 +13,7 @@ import { } from 'react-native'; import CheckBox from '@react-native-community/checkbox'; import { KeyboardAwareScrollView } from 'react-native-keyboard-aware-scroll-view'; -import AsyncStorage from '@react-native-community/async-storage'; +import AsyncStorage from '@react-native-async-storage/async-storage'; import { connect } from 'react-redux'; import { logIn, diff --git a/app/components/Views/ExtensionSync/index.tsx b/app/components/Views/ExtensionSync/index.tsx index 3e490522370..83fe1f0e915 100644 --- a/app/components/Views/ExtensionSync/index.tsx +++ b/app/components/Views/ExtensionSync/index.tsx @@ -28,7 +28,7 @@ import { NEXT_MAKER_REMINDER, TRUE, } from '../../../constants/storage'; -import AsyncStorage from '@react-native-community/async-storage'; +import AsyncStorage from '@react-native-async-storage/async-storage'; import SecureKeychain from '../../../core/SecureKeychain'; import Device from '../../../util/device'; import AppConstants from '../../../core/AppConstants'; diff --git a/app/components/Views/ImportFromSeed/index.js b/app/components/Views/ImportFromSeed/index.js index a6d25a8884d..34ac10e258a 100644 --- a/app/components/Views/ImportFromSeed/index.js +++ b/app/components/Views/ImportFromSeed/index.js @@ -12,7 +12,7 @@ import { InteractionManager, Platform, } from 'react-native'; -import AsyncStorage from '@react-native-community/async-storage'; +import AsyncStorage from '@react-native-async-storage/async-storage'; import { KeyboardAwareScrollView } from 'react-native-keyboard-aware-scroll-view'; import { getOnboardingNavbarOptions } from '../../UI/Navbar'; import { connect } from 'react-redux'; diff --git a/app/components/Views/Login/index.js b/app/components/Views/Login/index.js index 120284c2ab4..6a53489f02d 100644 --- a/app/components/Views/Login/index.js +++ b/app/components/Views/Login/index.js @@ -11,7 +11,7 @@ import { InteractionManager, BackHandler, } from 'react-native'; -import AsyncStorage from '@react-native-community/async-storage'; +import AsyncStorage from '@react-native-async-storage/async-storage'; import { KeyboardAwareScrollView } from 'react-native-keyboard-aware-scroll-view'; import Button from 'react-native-button'; import Engine from '../../../core/Engine'; diff --git a/app/components/Views/ManualBackupStep3/index.js b/app/components/Views/ManualBackupStep3/index.js index 68f1867f5cd..6106f021748 100644 --- a/app/components/Views/ManualBackupStep3/index.js +++ b/app/components/Views/ManualBackupStep3/index.js @@ -13,7 +13,7 @@ import { connect } from 'react-redux'; import PropTypes from 'prop-types'; import { fontStyles } from '../../../styles/common'; import Emoji from 'react-native-emoji'; -import AsyncStorage from '@react-native-community/async-storage'; +import AsyncStorage from '@react-native-async-storage/async-storage'; import OnboardingProgress from '../../UI/OnboardingProgress'; import ActionView from '../../UI/ActionView'; import { strings } from '../../../../locales/i18n'; diff --git a/app/components/Views/Onboarding/index.js b/app/components/Views/Onboarding/index.js index e6b2eefec11..6287ed026c5 100644 --- a/app/components/Views/Onboarding/index.js +++ b/app/components/Views/Onboarding/index.js @@ -11,7 +11,7 @@ import { Image, InteractionManager, } from 'react-native'; -import AsyncStorage from '@react-native-community/async-storage'; +import AsyncStorage from '@react-native-async-storage/async-storage'; import StyledButton from '../../UI/StyledButton'; import { fontStyles, diff --git a/app/components/Views/ResetPassword/index.js b/app/components/Views/ResetPassword/index.js index b575d8db99d..b9e35ebaa5b 100644 --- a/app/components/Views/ResetPassword/index.js +++ b/app/components/Views/ResetPassword/index.js @@ -15,7 +15,7 @@ import { } from 'react-native'; import CheckBox from '@react-native-community/checkbox'; import { KeyboardAwareScrollView } from 'react-native-keyboard-aware-scroll-view'; -import AsyncStorage from '@react-native-community/async-storage'; +import AsyncStorage from '@react-native-async-storage/async-storage'; import { connect } from 'react-redux'; import { passwordSet, diff --git a/app/components/Views/RevealPrivateCredential/index.js b/app/components/Views/RevealPrivateCredential/index.js index 737fbfc702d..047934f9fbb 100644 --- a/app/components/Views/RevealPrivateCredential/index.js +++ b/app/components/Views/RevealPrivateCredential/index.js @@ -12,7 +12,7 @@ import { Linking, Platform, } from 'react-native'; -import AsyncStorage from '@react-native-community/async-storage'; +import AsyncStorage from '@react-native-async-storage/async-storage'; import PropTypes from 'prop-types'; import QRCode from 'react-native-qrcode-svg'; import ScrollableTabView, { diff --git a/app/components/Views/Settings/SecuritySettings/index.js b/app/components/Views/Settings/SecuritySettings/index.js index 98999929f9e..f4a00dbc84e 100644 --- a/app/components/Views/Settings/SecuritySettings/index.js +++ b/app/components/Views/Settings/SecuritySettings/index.js @@ -13,7 +13,7 @@ import { InteractionManager, Linking, } from 'react-native'; -import AsyncStorage from '@react-native-community/async-storage'; +import AsyncStorage from '@react-native-async-storage/async-storage'; import { connect } from 'react-redux'; import { MAINNET } from '../../../../constants/network'; import ActionModal from '../../../UI/ActionModal'; diff --git a/app/components/Views/WalletConnectSessions/index.js b/app/components/Views/WalletConnectSessions/index.js index 45a7248645d..267276f0211 100644 --- a/app/components/Views/WalletConnectSessions/index.js +++ b/app/components/Views/WalletConnectSessions/index.js @@ -12,7 +12,7 @@ import { fontStyles } from '../../../styles/common'; import { strings } from '../../../../locales/i18n'; import { getNavigationOptionsTitle } from '../../UI/Navbar'; import WebsiteIcon from '../../UI/WebsiteIcon'; -import AsyncStorage from '@react-native-community/async-storage'; +import AsyncStorage from '@react-native-async-storage/async-storage'; import ActionSheet from 'react-native-actionsheet'; import WalletConnect from '../../../core/WalletConnect'; import Logger from '../../../util/Logger'; diff --git a/app/components/hooks/useDeleteWallet.ts b/app/components/hooks/useDeleteWallet.ts index 5bb42d0021d..c675d8d2b68 100644 --- a/app/components/hooks/useDeleteWallet.ts +++ b/app/components/hooks/useDeleteWallet.ts @@ -1,5 +1,5 @@ import { useCallback } from 'react'; -import AsyncStorage from '@react-native-community/async-storage'; +import AsyncStorage from '@react-native-async-storage/async-storage'; import Engine from '../../core/Engine'; import Logger from '../../util/Logger'; import { EXISTING_USER } from '../../constants/storage'; diff --git a/app/core/Engine.js b/app/core/Engine.js index 294e02dd0e4..2c6543640d6 100644 --- a/app/core/Engine.js +++ b/app/core/Engine.js @@ -26,7 +26,7 @@ import { ApprovalController, } from '@metamask/controllers'; import SwapsController, { swapsUtils } from '@metamask/swaps-controller'; -import AsyncStorage from '@react-native-community/async-storage'; +import AsyncStorage from '@react-native-async-storage/async-storage'; import { MetaMaskKeyring as QRHardwareKeyring } from '@keystonehq/metamask-airgapped-keyring'; import Encryptor from './Encryptor'; import { toChecksumAddress } from 'ethereumjs-util'; diff --git a/app/core/NotificationManager.js b/app/core/NotificationManager.js index c65c71540ef..5d1a9629eff 100644 --- a/app/core/NotificationManager.js +++ b/app/core/NotificationManager.js @@ -7,7 +7,7 @@ import { hexToBN, renderFromWei } from '../util/number'; import Device from '../util/device'; import { strings } from '../../locales/i18n'; import { Alert, AppState } from 'react-native'; -import AsyncStorage from '@react-native-community/async-storage'; +import AsyncStorage from '@react-native-async-storage/async-storage'; import AppConstants from './AppConstants'; import { PUSH_NOTIFICATIONS_PROMPT_COUNT, diff --git a/app/core/SecureKeychain.js b/app/core/SecureKeychain.js index 8c87c1b7741..ef369187ab7 100644 --- a/app/core/SecureKeychain.js +++ b/app/core/SecureKeychain.js @@ -1,7 +1,7 @@ import * as Keychain from 'react-native-keychain'; // eslint-disable-line import/no-namespace import Encryptor from './Encryptor'; import { strings } from '../../locales/i18n'; -import AsyncStorage from '@react-native-community/async-storage'; +import AsyncStorage from '@react-native-async-storage/async-storage'; import { Platform } from 'react-native'; import { BIOMETRY_CHOICE, diff --git a/app/core/WalletConnect.js b/app/core/WalletConnect.js index 97f643727ea..809b8c82e5b 100644 --- a/app/core/WalletConnect.js +++ b/app/core/WalletConnect.js @@ -4,7 +4,7 @@ import Engine from './Engine'; import Logger from '../util/Logger'; // eslint-disable-next-line import/no-nodejs-modules import { EventEmitter } from 'events'; -import AsyncStorage from '@react-native-community/async-storage'; +import AsyncStorage from '@react-native-async-storage/async-storage'; import { CLIENT_OPTIONS, WALLET_CONNECT_ORIGIN } from '../util/walletconnect'; import { WALLETCONNECT_SESSIONS } from '../constants/storage'; import { WalletDevice } from '@metamask/controllers/'; diff --git a/app/store/index.js b/app/store/index.js index 5bfcc4e9b6b..7d9f1d6e302 100644 --- a/app/store/index.js +++ b/app/store/index.js @@ -5,7 +5,7 @@ import { createMigrate, createTransform, } from 'redux-persist'; -import AsyncStorage from '@react-native-community/async-storage'; +import AsyncStorage from '@react-native-async-storage/async-storage'; import FilesystemStorage from 'redux-persist-filesystem-storage'; import autoMergeLevel2 from 'redux-persist/lib/stateReconciler/autoMergeLevel2'; import rootReducer from '../reducers'; diff --git a/app/util/authentication/checkIfUsingRememberMe.ts b/app/util/authentication/checkIfUsingRememberMe.ts index e4ec5f12ce0..22fbce8edc8 100644 --- a/app/util/authentication/checkIfUsingRememberMe.ts +++ b/app/util/authentication/checkIfUsingRememberMe.ts @@ -1,7 +1,7 @@ /* eslint-disable import/prefer-default-export */ import SecureKeychain from '../../core/SecureKeychain'; import Engine from '../../core/Engine'; -import AsyncStorage from '@react-native-community/async-storage'; +import AsyncStorage from '@react-native-async-storage/async-storage'; import { BIOMETRY_CHOICE, PASSCODE_CHOICE, diff --git a/app/util/onboarding/index.ts b/app/util/onboarding/index.ts index 28f73c2cd31..57ea52233a8 100644 --- a/app/util/onboarding/index.ts +++ b/app/util/onboarding/index.ts @@ -1,5 +1,5 @@ /* eslint-disable import/prefer-default-export */ -import AsyncStorage from '@react-native-community/async-storage'; +import AsyncStorage from '@react-native-async-storage/async-storage'; import compareVersions from 'compare-versions'; import { WHATS_NEW_APP_VERSION_SEEN, diff --git a/app/util/testSetup.js b/app/util/testSetup.js index e2bccb4edc2..623bbbd4416 100644 --- a/app/util/testSetup.js +++ b/app/util/testSetup.js @@ -4,7 +4,7 @@ import Engine from '../core/Engine'; import NotificationManager from '../core/NotificationManager'; import { NativeModules } from 'react-native'; -import mockAsyncStorage from '../../node_modules/@react-native-community/async-storage/jest/async-storage-mock'; +import mockRNAsyncStorage from '@react-native-async-storage/async-storage/jest/async-storage-mock'; import mockClipboard from '@react-native-clipboard/clipboard/jest/clipboard-mock.js'; /* eslint-disable import/no-namespace */ import * as themeUtils from './theme'; @@ -118,7 +118,10 @@ jest.mock('react-native-reanimated', () => require('react-native-reanimated/mock'), ); jest.mock('react-native-background-timer', () => 'RNBackgroundTimer'); -jest.mock('@react-native-community/async-storage', () => mockAsyncStorage); +jest.mock( + '@react-native-async-storage/async-storage', + () => mockRNAsyncStorage, +); jest.mock('@react-native-cookies/cookies', () => 'RNCookies'); NativeModules.RNGestureHandlerModule = { diff --git a/ios/Podfile.lock b/ios/Podfile.lock index 3572ae07b03..131ff1e4eb9 100644 --- a/ios/Podfile.lock +++ b/ios/Podfile.lock @@ -408,7 +408,7 @@ PODS: - React - rn-fetch-blob (0.12.0): - React-Core - - RNCAsyncStorage (1.12.1): + - RNCAsyncStorage (1.17.10): - React-Core - RNCCheckbox (0.5.12): - React-Core @@ -560,7 +560,7 @@ DEPENDENCIES: - ReactCommon/turbomodule/core (from `../node_modules/react-native/ReactCommon`) - "ReactNativePayments (from `../node_modules/@exodus/react-native-payments/lib/ios`)" - rn-fetch-blob (from `../node_modules/rn-fetch-blob`) - - "RNCAsyncStorage (from `../node_modules/@react-native-community/async-storage`)" + - "RNCAsyncStorage (from `../node_modules/@react-native-async-storage/async-storage`)" - "RNCCheckbox (from `../node_modules/@react-native-community/checkbox`)" - "RNCClipboard (from `../node_modules/@react-native-clipboard/clipboard`)" - "RNCMaskedView (from `../node_modules/@react-native-masked-view/masked-view`)" @@ -706,7 +706,7 @@ EXTERNAL SOURCES: rn-fetch-blob: :path: "../node_modules/rn-fetch-blob" RNCAsyncStorage: - :path: "../node_modules/@react-native-community/async-storage" + :path: "../node_modules/@react-native-async-storage/async-storage" RNCCheckbox: :path: "../node_modules/@react-native-community/checkbox" RNCClipboard: @@ -815,7 +815,7 @@ SPEC CHECKSUMS: ReactCommon: 9bac022ab71596f2b0fde1268272543184c63971 ReactNativePayments: a4e3ac915256a4e759c8a04338b558494a63a0f5 rn-fetch-blob: f065bb7ab7fb48dd002629f8bdcb0336602d3cba - RNCAsyncStorage: b03032fdbdb725bea0bd9e5ec5a7272865ae7398 + RNCAsyncStorage: 0c357f3156fcb16c8589ede67cc036330b6698ca RNCCheckbox: ed1b4ca295475b41e7251ebae046360a703b6eb5 RNCClipboard: ddd4d291537f1667209c9c405aaa4307297e252e RNCMaskedView: c298b644a10c0c142055b3ae24d83879ecb13ccd diff --git a/locales/i18n.js b/locales/i18n.js index bf98f124d27..3c063cb24e1 100644 --- a/locales/i18n.js +++ b/locales/i18n.js @@ -1,5 +1,5 @@ import ReactNative from 'react-native'; -import AsyncStorage from '@react-native-community/async-storage'; +import AsyncStorage from '@react-native-async-storage/async-storage'; import I18n from 'react-native-i18n'; // eslint-disable-next-line import/no-nodejs-modules import { EventEmitter } from 'events'; diff --git a/package.json b/package.json index 9c76ed71797..13790c52e8c 100644 --- a/package.json +++ b/package.json @@ -118,8 +118,8 @@ "@metamask/etherscan-link": "^2.0.0", "@metamask/swaps-controller": "^6.6.0", "@ngraveio/bc-ur": "^1.1.6", + "@react-native-async-storage/async-storage": "1.17.10", "@react-native-clipboard/clipboard": "^1.8.4", - "@react-native-community/async-storage": "1.12.1", "@react-native-community/blur": "^3.6.0", "@react-native-community/checkbox": "^0.5.12", "@react-native-community/netinfo": "6.0.0", diff --git a/yarn.lock b/yarn.lock index c0d91bbc6ab..8aba84f0d9d 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2929,18 +2929,18 @@ prop-types "^15.6.1" react-lifecycles-compat "^3.0.4" +"@react-native-async-storage/async-storage@1.17.10": + version "1.17.10" + resolved "https://registry.yarnpkg.com/@react-native-async-storage/async-storage/-/async-storage-1.17.10.tgz#8d6a4771912be8454a9e215eebd469b1b8e2e638" + integrity sha512-KrR021BmBLsA0TT1AAsfH16bHYy0MSbhdAeBAqpriak3GS1T2alFcdTUvn13p0ZW6FKRD6Bd3ryU2zhU/IYYJQ== + dependencies: + merge-options "^3.0.4" + "@react-native-clipboard/clipboard@^1.8.4": version "1.8.4" resolved "https://registry.yarnpkg.com/@react-native-clipboard/clipboard/-/clipboard-1.8.4.tgz#4bc1fb00643688e489d8220cd635844ab5c066f9" integrity sha512-poFq3RvXzkbXcqoQNssbZ+aNbCRzBFAWkR9QL7u9xNMgsyWZtk7d16JQoaBo8D2E+kKi+/9JOiVQzA5w+9N67w== -"@react-native-community/async-storage@1.12.1": - version "1.12.1" - resolved "https://registry.yarnpkg.com/@react-native-community/async-storage/-/async-storage-1.12.1.tgz#25f821b4f6b13abe005ad67e47c6f1cee9f27b24" - integrity sha512-70WGaH3PKYASi4BThuEEKMkyAgE9k7VytBqmgPRx3MzJx9/MkspwqJGmn3QLCgHLIFUgF1pit2mWICbRJ3T3lg== - dependencies: - deep-assign "^3.0.0" - "@react-native-community/blur@^3.6.0": version "3.6.0" resolved "https://registry.yarnpkg.com/@react-native-community/blur/-/blur-3.6.0.tgz#31c9e0f2770519c9b5c4f99418f192246f0d4db8" @@ -6798,13 +6798,6 @@ dedent@^0.7.0: resolved "https://registry.yarnpkg.com/dedent/-/dedent-0.7.0.tgz#2495ddbaf6eb874abb0e1be9df22d2e5a544326c" integrity sha1-JJXduvbrh0q7Dhvp3yLS5aVEMmw= -deep-assign@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/deep-assign/-/deep-assign-3.0.0.tgz#c8e4c4d401cba25550a2f0f486a2e75bc5f219a2" - integrity sha512-YX2i9XjJ7h5q/aQ/IM9PEwEnDqETAIYbggmdDB3HLTlSgo1CxPsj6pvhPG68rq6SVE0+p+6Ywsm5fTYNrYtBWw== - dependencies: - is-obj "^1.0.0" - deep-equal@*: version "2.0.5" resolved "https://registry.yarnpkg.com/deep-equal/-/deep-equal-2.0.5.tgz#55cd2fe326d83f9cbf7261ef0e060b3f724c5cb9" @@ -10369,7 +10362,7 @@ is-number@^7.0.0: resolved "https://registry.yarnpkg.com/is-number/-/is-number-7.0.0.tgz#7535345b896734d5f80c4d06c50955527a14f12b" integrity sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng== -is-obj@^1.0.0, is-obj@^1.0.1: +is-obj@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/is-obj/-/is-obj-1.0.1.tgz#3e4729ac1f5fde025cd7d83a896dab9f4f67db0f" integrity sha1-PkcprB9f3gJc19g6iW2rn09n2w8= @@ -11969,6 +11962,13 @@ memoizerific@^1.11.3: dependencies: map-or-similar "^1.5.0" +merge-options@^3.0.4: + version "3.0.4" + resolved "https://registry.yarnpkg.com/merge-options/-/merge-options-3.0.4.tgz#84709c2aa2a4b24c1981f66c179fe5565cc6dbb7" + integrity sha512-2Sug1+knBjkaMsMgf1ctR1Ujx+Ayku4EdJN4Z+C2+JzoeF7A3OZ9KM2GY0CpQS51NR61LTurMJrRKPhSs3ZRTQ== + dependencies: + is-plain-obj "^2.1.0" + merge-stream@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/merge-stream/-/merge-stream-2.0.0.tgz#52823629a14dd00c9770fb6ad47dc6310f2c1f60" From eaed575d9492cdc919c4762dd1a15b623ebc744a Mon Sep 17 00:00:00 2001 From: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Thu, 8 Sep 2022 20:08:36 -0400 Subject: [PATCH 2/3] Fix test --- app/components/hooks/DeleteWallet/useDeleteWallet.test.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/components/hooks/DeleteWallet/useDeleteWallet.test.tsx b/app/components/hooks/DeleteWallet/useDeleteWallet.test.tsx index 7d6a435fca6..f9294c53145 100644 --- a/app/components/hooks/DeleteWallet/useDeleteWallet.test.tsx +++ b/app/components/hooks/DeleteWallet/useDeleteWallet.test.tsx @@ -1,5 +1,5 @@ import { renderHook } from '@testing-library/react-hooks'; -import AsyncStorage from '@react-native-community/async-storage'; +import AsyncStorage from '@react-native-async-storage/async-storage'; import useDeleteWallet from './useDeleteWallet'; import Engine from '../../../core/Engine'; From 125a3355ba1306be22c74b1bf1001c5a566ccdc1 Mon Sep 17 00:00:00 2001 From: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Fri, 9 Sep 2022 09:56:08 -0400 Subject: [PATCH 3/3] Remove react-native-community/async-storage mock --- .../@react-native-community/async-storage.js | 112 ------------------ 1 file changed, 112 deletions(-) delete mode 100644 app/__mocks__/@react-native-community/async-storage.js diff --git a/app/__mocks__/@react-native-community/async-storage.js b/app/__mocks__/@react-native-community/async-storage.js deleted file mode 100644 index 1811e2aa87c..00000000000 --- a/app/__mocks__/@react-native-community/async-storage.js +++ /dev/null @@ -1,112 +0,0 @@ -const _isObject = (obj) => typeof obj === 'object' && !Array.isArray(obj); -const _deepMergeInto = (oldObject, newObject) => { - const newKeys = Object.keys(newObject); - const mergedObject = oldObject; - - newKeys.forEach((key) => { - const oldValue = mergedObject[key]; - const newValue = newObject[key]; - - if (_isObject(oldValue) && _isObject(newValue)) { - mergedObject[key] = _deepMergeInto(oldValue, newValue); - } else { - mergedObject[key] = newValue; - } - }); - - return mergedObject; -}; - -const asMock = { - __INTERNAL_MOCK_STORAGE__: {}, - - setItem: async (key, value, callback) => { - const setResult = await asMock.multiSet([[key, value]], undefined); - - callback && callback(setResult); - return setResult; - }, - - getItem: async (key, callback) => { - const getResult = await asMock.multiGet([key], undefined); - - const result = getResult[0] ? getResult[0][1] : null; - - callback && callback(null, result); - return result; - }, - - removeItem: (key, callback) => asMock.multiRemove([key], callback), - mergeItem: (key, value, callback) => - asMock.multiMerge([[key, value]], callback), - - clear: _clear, - getAllKeys: _getAllKeys, - flushGetRequests: () => null, - - multiGet: _multiGet, - multiSet: _multiSet, - multiRemove: _multiRemove, - multiMerge: _multiMerge, -}; - -async function _multiSet(keyValuePairs, callback) { - keyValuePairs.forEach((keyValue) => { - const key = keyValue[0]; - - asMock.__INTERNAL_MOCK_STORAGE__[key] = keyValue[1]; - }); - callback && callback(null); - return null; -} - -async function _multiGet(keys, callback) { - const values = keys.map((key) => [ - key, - asMock.__INTERNAL_MOCK_STORAGE__[key] || null, - ]); - callback && callback(null, values); - - return values; -} - -async function _multiRemove(keys, callback) { - keys.forEach((key) => { - if (asMock.__INTERNAL_MOCK_STORAGE__[key]) { - delete asMock.__INTERNAL_MOCK_STORAGE__[key]; - } - }); - - callback && callback(null); - return null; -} - -async function _clear(callback) { - asMock.__INTERNAL_MOCK_STORAGE__ = {}; - - callback && callback(null); - - return null; -} - -async function _getAllKeys() { - return Object.keys(asMock.__INTERNAL_MOCK_STORAGE__); -} - -async function _multiMerge(keyValuePairs, callback) { - keyValuePairs.forEach((keyValue) => { - const key = keyValue[0]; - const value = JSON.parse(keyValue[1]); - - const oldValue = JSON.parse(asMock.__INTERNAL_MOCK_STORAGE__[key]); - - asMock.__INTERNAL_MOCK_STORAGE__[key] = JSON.stringify( - _deepMergeInto(oldValue, value), - ); - }); - - callback && callback(null); - return null; -} - -export default asMock;