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

feat: #870 - Slice Storage Engine #8081

Merged
merged 44 commits into from
Dec 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
e7f3b64
feat: fixing nesting persistance in engine
MarioAslau Nov 25, 2023
12a28ab
feat: remove createAction to trigger reducer
MarioAslau Nov 25, 2023
fbac67d
feat: individual persistance on engine
MarioAslau Nov 28, 2023
c56d43c
feat: code cleanup & settings persistance
MarioAslau Dec 1, 2023
f8479a2
feat: persisting settings reducer
MarioAslau Dec 5, 2023
6537c08
feat: presisted brower reducer
MarioAslau Dec 5, 2023
8e9faa5
feat: privacy persisted
MarioAslau Dec 5, 2023
62f8558
feat: moved boomkmarks reducer in redux folder
MarioAslau Dec 5, 2023
f4e5719
feat: onboarding & user persistance & alert
MarioAslau Dec 6, 2023
c38aaa1
feat: wizard
MarioAslau Dec 6, 2023
440fe09
feat: networkSelector
MarioAslau Dec 6, 2023
0fe6d61
feat: modal persisted
MarioAslau Dec 6, 2023
9653e18
feat: signatureRequest
MarioAslau Dec 6, 2023
be55be0
feat: Security
MarioAslau Dec 6, 2023
5b848f3
feat: swaps persistance
MarioAslau Dec 6, 2023
cc184d4
feat: moved remaining reducers in slices folder
MarioAslau Dec 6, 2023
ff571f6
feat: notification persistance
MarioAslau Dec 6, 2023
9056564
feat: collectibles favorites persist
MarioAslau Dec 6, 2023
ac2ac00
feat: fiat order persist
MarioAslau Dec 6, 2023
58d5092
feat: cleanup & adjusting root persist
MarioAslau Dec 7, 2023
f8db915
feat: PR cleanup
MarioAslau Dec 8, 2023
0ffd76c
feat: fix TS errors & cleanup
MarioAslau Dec 12, 2023
c8e379e
feat: revert to only splitting controller persistance
MarioAslau Dec 12, 2023
a72c010
feat: changes cleanup
MarioAslau Dec 12, 2023
ea6b035
feat: clean spacing
MarioAslau Dec 12, 2023
e3198e2
Merge branch 'main' into feat/870-slice-storage-enginePR
MarioAslau Dec 12, 2023
7ff06c2
feat: pod fix
MarioAslau Dec 12, 2023
b16136c
feat: addressing PR comments part 1
MarioAslau Dec 13, 2023
b321022
feat: pbxproj reverting changes
MarioAslau Dec 13, 2023
059e0fc
feat: deduplicate
MarioAslau Dec 13, 2023
766f93a
Merge branch 'main' into feat/870-slice-storage-enginePR
MarioAslau Dec 13, 2023
19d752f
feat: fix tsc error
MarioAslau Dec 13, 2023
480b50c
feat: PR Comments addressed
MarioAslau Dec 14, 2023
6bbc736
feat: tests
MarioAslau Dec 14, 2023
f51694e
feat: consoles update
MarioAslau Dec 14, 2023
38bcc08
feat: removed unit test test case as RTK is no longer implemented in …
MarioAslau Dec 15, 2023
86275be
Merge branch 'main' into feat/870-slice-storage-enginePR
MarioAslau Dec 15, 2023
fbb4502
Merge branch 'main' into feat/870-slice-storage-enginePR
Cal-L Dec 18, 2023
935aa44
Merge branch 'main' into feat/870-slice-storage-enginePR
Cal-L Dec 18, 2023
ae141ea
feat: update logging key
MarioAslau Dec 18, 2023
5a72dbc
Merge branch 'feat/870-slice-storage-enginePR' of https://github.com/…
MarioAslau Dec 18, 2023
e142d1e
feat: update logging messages
MarioAslau Dec 18, 2023
962e2ee
feat: blackList -> denyList
MarioAslau Dec 19, 2023
203f089
Merge branch 'main' into feat/870-slice-storage-enginePR
MarioAslau Dec 19, 2023
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
108 changes: 1 addition & 107 deletions app/components/UI/DrawerView/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import {
StyleSheet,
Text,
InteractionManager,
Platform,
} from 'react-native';
import PropTypes from 'prop-types';
import { connect } from 'react-redux';
Expand All @@ -28,7 +27,6 @@ import { strings } from '../../../../locales/i18n';
import Modal from 'react-native-modal';
import {
toggleInfoNetworkModal,
toggleNetworkModal,
toggleReceiveModal,
} from '../../../actions/modals';
import { showAlert } from '../../../actions/alert';
Expand All @@ -49,7 +47,6 @@ import { getEther } from '../../../util/transactions';
import { newAssetTransaction } from '../../../actions/transaction';
import { protectWalletModalVisible } from '../../../actions/user';
import DeeplinkManager from '../../../core/DeeplinkManager/SharedDeeplinkManager';
import SettingsNotification from '../SettingsNotification';
import { RPC } from '../../../constants/network';
import { findRouteNameFromNavigatorState } from '../../../util/general';
import AnalyticsV2 from '../../../util/analyticsV2';
Expand All @@ -59,7 +56,6 @@ import {
} from '../../../util/ENSUtils';
import ClipboardManager from '../../../core/ClipboardManager';
import { collectiblesSelector } from '../../../reducers/collectibles';
import { getCurrentRoute } from '../../../reducers/navigation';
import { ScrollView } from 'react-native-gesture-handler';
import { isZero } from '../../../util/lodash';
import { Authentication } from '../../../core/';
Expand All @@ -71,7 +67,6 @@ import {
} from '../../../actions/onboardNetwork';
import Routes from '../../../constants/navigation/Routes';
import { scale } from 'react-native-size-matters';
import generateTestId from '../../../../wdio/utils/generateTestId';
import { DRAWER_VIEW_LOCK_TEXT_ID } from '../../../../wdio/screen-objects/testIDs/Screens/DrawerView.testIds';
import {
selectNetworkConfigurations,
Expand Down Expand Up @@ -362,10 +357,6 @@ class DrawerView extends PureComponent {
* List of keyrings
*/
keyrings: PropTypes.array,
/**
* Action that toggles the network modal
*/
toggleNetworkModal: PropTypes.func,
/**
* Action that toggles the receive modal
*/
Expand All @@ -374,10 +365,6 @@ class DrawerView extends PureComponent {
* Action that shows the global alert
*/
showAlert: PropTypes.func.isRequired,
/**
* Boolean that determines the status of the networks modal
*/
networkModalVisible: PropTypes.bool.isRequired,
/**
* Boolean that determines the status of the receive modal
*/
Expand All @@ -390,10 +377,6 @@ class DrawerView extends PureComponent {
* Boolean that determines if the user has set a password before
*/
passwordSet: PropTypes.bool,
/**
* Wizard onboarding state
*/
wizard: PropTypes.object,
/**
* Current provider ticker
*/
Expand Down Expand Up @@ -427,18 +410,11 @@ class DrawerView extends PureComponent {
* Callback to close drawer
*/
onCloseDrawer: PropTypes.func,
/**
* Latest navigation route
*/
currentRoute: PropTypes.string,

/**
* handles action for onboarding to a network
*/
onboardNetworkAction: PropTypes.func,
/**
* returns switched network state
*/
switchedNetwork: PropTypes.object,
/**
* updates when network is switched
*/
Expand Down Expand Up @@ -1000,8 +976,6 @@ class DrawerView extends PureComponent {
identities,
selectedAddress,
currentCurrency,
seedphraseBackedUp,
currentRoute,
navigation,
infoNetworkModalVisible,
} = this.props;
Expand Down Expand Up @@ -1118,81 +1092,6 @@ class DrawerView extends PureComponent {
</View>
</StyledButton>
</View>
<View style={styles.menu}>
MarioAslau marked this conversation as resolved.
Show resolved Hide resolved
{this.getSections().map(
(section, i) =>
section?.length > 0 && (
<View
key={`section_${i}`}
style={[
styles.menuSection,
i === 0 ? styles.noTopBorder : null,
]}
>
{section
.filter((item) => {
if (!item) return undefined;
const { name = undefined } = item;
if (
name &&
name.toLowerCase().indexOf('etherscan') !== -1
) {
const type = providerConfig?.type;
return (
(type && this.hasBlockExplorer(type)) || undefined
);
}
return true;
})
.map((item, j) => (
<TouchableOpacity
key={`item_${i}_${j}`}
style={[
styles.menuItem,
item.routeNames &&
item.routeNames.includes(currentRoute)
? styles.selectedRoute
: null,
]}
ref={
item.name === strings('drawer.browser') &&
this.browserSectionRef
}
onPress={() => item.action()} // eslint-disable-line
>
{item.icon
? item.routeNames &&
item.routeNames.includes(currentRoute)
? item.selectedIcon
: item.icon
: null}
<Text
style={[
styles.menuItemName,
!item.icon ? styles.noIcon : null,
item.routeNames &&
item.routeNames.includes(currentRoute)
? styles.selectedName
: null,
]}
{...generateTestId(Platform, item.testID)}
numberOfLines={1}
>
{item.name}
</Text>
{!seedphraseBackedUp && item.warning ? (
<SettingsNotification isNotification isWarning>
<Text style={styles.menuItemWarningText}>
{item.warning}
</Text>
</SettingsNotification>
) : null}
</TouchableOpacity>
))}
</View>
),
)}
</View>
</ScrollView>

<Modal
Expand Down Expand Up @@ -1243,22 +1142,17 @@ const mapStateToProps = (state) => ({
networkConfigurations: selectNetworkConfigurations(state),
currentCurrency: selectCurrentCurrency(state),
keyrings: state.engine.backgroundState.KeyringController.keyrings,
networkModalVisible: state.modals.networkModalVisible,
receiveModalVisible: state.modals.receiveModalVisible,
infoNetworkModalVisible: state.modals.infoNetworkModalVisible,
passwordSet: state.user.passwordSet,
wizard: state.wizard,
ticker: selectTicker(state),
tokens: selectTokens(state),
tokenBalances: selectContractBalances(state),
collectibles: collectiblesSelector(state),
seedphraseBackedUp: state.user.seedphraseBackedUp,
currentRoute: getCurrentRoute(state),
switchedNetwork: state.networkOnboarded.switchedNetwork,
});

const mapDispatchToProps = (dispatch) => ({
toggleNetworkModal: () => dispatch(toggleNetworkModal()),
toggleReceiveModal: () => dispatch(toggleReceiveModal()),
showAlert: (config) => dispatch(showAlert(config)),
newAssetTransaction: (selectedAsset) =>
Expand Down
19 changes: 15 additions & 4 deletions app/core/EngineService/EngineService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@ interface InitializeEngineResult {
error?: string;
}

const UPDATE_BG_STATE_KEY = 'UPDATE_BG_STATE';
const INIT_BG_STATE_KEY = 'INIT_BG_STATE';
const UPDATE_BG_STATE_KEY = (controllerName: string) =>
`UPDATE_BG_STATE_${controllerName}`;
const INIT_BG_STATE_KEY = (controllerName: string) =>
`INIT_BG_STATE_${controllerName}`;
class EngineService {
private engineInitialized = false;

Expand Down Expand Up @@ -102,15 +104,24 @@ class EngineService {

engine?.datamodel?.subscribe?.(() => {
if (!this.engineInitialized) {
store.dispatch({ type: INIT_BG_STATE_KEY });
controllers.forEach((controller) => {
const { name } = controller;
store.dispatch({
type: INIT_BG_STATE_KEY(name),
payload: { key: name },
});
});
this.engineInitialized = true;
}
});

controllers.forEach((controller) => {
const { name, key = undefined } = controller;
const update_bg_state_cb = () => {
store.dispatch({ type: UPDATE_BG_STATE_KEY, payload: { key: name } });
store.dispatch({
type: UPDATE_BG_STATE_KEY(name),
payload: { key: name },
});
};
if (key) {
engine.controllerMessenger.subscribe(key, update_bg_state_cb);
Expand Down
51 changes: 0 additions & 51 deletions app/core/redux/slices/engine/engineReducer.test.tsx

This file was deleted.

39 changes: 0 additions & 39 deletions app/core/redux/slices/engine/index.ts

This file was deleted.

6 changes: 3 additions & 3 deletions app/reducers/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import bookmarksReducer from './bookmarks';
import browserReducer from './browser';
import engineReducer from '../core/redux/slices/engine';
import engineReducer from '../redux/slices/engine';
import privacyReducer from './privacy';
import modalsReducer from './modals';
import settingsReducer from './settings';
Expand All @@ -11,11 +11,11 @@ import wizardReducer from './wizard';
import onboardingReducer from './onboarding';
import fiatOrders from './fiatOrders';
import swapsReducer from './swaps';
import navigationReducer from './navigation';
import signatureRequestReducer from './signatureRequest';
import notificationReducer from './notification';
import infuraAvailabilityReducer from './infuraAvailability';
import collectiblesReducer from './collectibles';
import navigationReducer from './navigation';
import networkOnboardReducer from './networkSelector';
import securityReducer from './security';
import { combineReducers, Reducer } from 'redux';
Expand Down Expand Up @@ -83,11 +83,11 @@ const rootReducer = combineReducers<RootState, any>({
wizard: wizardReducer,
onboarding: onboardingReducer,
notification: notificationReducer,
navigation: navigationReducer,
signatureRequest: signatureRequestReducer,
swaps: swapsReducer,
fiatOrders,
infuraAvailability: infuraAvailabilityReducer,
navigation: navigationReducer,
networkOnboarded: networkOnboardReducer,
security: securityReducer,
experimentalSettings: experimentalSettingsReducer,
Expand Down
3 changes: 0 additions & 3 deletions app/reducers/navigation/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,5 @@ const navigationReducer = (state = initialState, action: any = {}) => {
/**
* Selectors
*/
export const getCurrentRoute = (state: any) => state.navigation.currentRoute;
export const getCurrentBottomNavRoute = (state: any) =>
state.navigation.currentBottomNavRoute;

export default navigationReducer;
Loading
Loading