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: #12184 MVP split engine file #12366

Merged
merged 24 commits into from
Nov 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
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
9 changes: 6 additions & 3 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@ app/component-library/ @MetaMask/design-system-engineers

# Platform Team
patches/ @MetaMask/mobile-platform
app/core/Engine.ts @MetaMask/mobile-platform
app/core/Engine.test.js @MetaMask/mobile-platform
app/core/Engine/Engine.ts @MetaMask/mobile-platform
app/core/Engine/Engine.test.ts @MetaMask/mobile-platform
app/core/Engine/index.ts @MetaMask/mobile-platform
app/core/Engine/types.ts @MetaMask/mobile-platform
app/core/Analytics/ @MetaMask/mobile-platform
app/util/metrics/ @MetaMask/mobile-platform
app/components/hooks/useMetrics/ @MetaMask/mobile-platform
Expand Down Expand Up @@ -41,7 +43,8 @@ app/reducers/sdk @MetaMask/sdk-devs @MetaMask/mobile-platform
app/util/walletconnect.js @MetaMask/sdk-devs @MetaMask/mobile-platform

# Accounts Team
app/core/Encryptor/ @MetaMask/accounts-engineers
app/core/Encryptor/ @MetaMask/accounts-engineers
app/core/Engine/controller/AccountsController @MetaMask/accounts-engineers

# Swaps Team
app/components/UI/Swaps @MetaMask/swaps-engineers @MetaMask/mobile-platform
Expand Down
2 changes: 1 addition & 1 deletion app/components/Nav/Main/index.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { MetaMetricsEvents } from '../../hooks/useMetrics';
import { renderHookWithProvider } from '../../../util/test/renderWithProvider';
import Engine from '../../../core/Engine';

jest.mock('../../../core/Engine.ts', () => ({
jest.mock('../../../core/Engine', () => ({
controllerMessenger: {
subscribeOnceIf: jest.fn(),
},
Expand Down
2 changes: 1 addition & 1 deletion app/components/UI/AccountOverview/index.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {

const mockedEngine = Engine;

jest.mock('../../../core/Engine.ts', () => {
jest.mock('../../../core/Engine', () => {
const { MOCK_ACCOUNTS_CONTROLLER_STATE: mockAccountsControllerState } =
jest.requireActual('../../../util/test/accountsControllerTestUtils');
return {
Expand Down
2 changes: 1 addition & 1 deletion app/components/UI/AssetSearch/index.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { backgroundState } from '../../../util/test/initial-root-state';
import Engine from '../../../core/Engine';
const mockedEngine = Engine;

jest.mock('../../../core/Engine.ts', () => ({
jest.mock('../../../core/Engine', () => ({
init: () => mockedEngine.init({}),
context: {
KeyringController: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ const initialState = {
};

jest.mock('../../../core/Engine', () => ({
...jest.requireActual('../../../core/Engine'),
context: {
PreferencesController: {
selectedAddress: `0xC4966c0D659D99699BFD7EB54D8fafEE40e4a756`,
Expand Down
2 changes: 1 addition & 1 deletion app/components/Views/Asset/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const mockInitialState = {
},
};

jest.mock('../../../core/Engine.ts', () => {
jest.mock('../../../core/Engine', () => {
const {
MOCK_ADDRESS_1,
} = require('../../../util/test/accountsControllerTestUtils');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jest.mock('../../../../util/dappTransactions', () => ({
handleGetGasLimit: jest.fn(),
}));

jest.mock('../../../../core/Engine.ts', () => ({
jest.mock('../../../../core/Engine', () => ({
rejectPendingApproval: jest.fn(),
context: {
KeyringController: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jest.mock('../../../../../core/GasPolling/GasPolling', () => ({
stopGasPolling: jest.fn().mockResolvedValue(null),
}));

jest.mock('../../../../../core/Engine.ts', () => ({
jest.mock('../../../../../core/Engine', () => ({
controllerMessenger: {
tryUnsubscribe: jest.fn(),
subscribe: jest.fn(),
Expand Down Expand Up @@ -59,7 +59,8 @@ const routeMock = {
};
const hideModalMock = jest.fn();

const renderComponent = ({ store }: { store: Store }) => render(
const renderComponent = ({ store }: { store: Store }) =>
render(
<Provider store={store}>
<ThemeContext.Provider value={mockTheme}>
<NavigationContainer>
Expand Down
39 changes: 21 additions & 18 deletions app/core/Engine.test.ts → app/core/Engine/Engine.test.ts
Original file line number Diff line number Diff line change
@@ -1,27 +1,24 @@
import Engine, {
Engine as EngineClass,
EngineState,
TransactionEventPayload,
} from './Engine';
import { backgroundState } from '../util/test/initial-root-state';
import Engine, { Engine as EngineClass } from './Engine';
import { EngineState, TransactionEventPayload } from './types';
import { backgroundState } from '../../util/test/initial-root-state';
import { zeroAddress } from 'ethereumjs-util';
import { createMockAccountsControllerState } from '../util/test/accountsControllerTestUtils';
import { mockNetworkState } from '../util/test/network';
import MetaMetrics from './Analytics/MetaMetrics';
import { store } from '../store';
import { MetaMetricsEvents } from './Analytics';
import { createMockAccountsControllerState } from '../../util/test/accountsControllerTestUtils';
import { mockNetworkState } from '../../util/test/network';
import MetaMetrics from '../Analytics/MetaMetrics';
import { store } from '../../store';
import { MetaMetricsEvents } from '../Analytics';
import { NetworkState } from '@metamask/network-controller';
import { Hex } from '@metamask/utils';
import { MarketDataDetails } from '../components/UI/Tokens';
import { MarketDataDetails } from '../../components/UI/Tokens';
import { TransactionMeta } from '@metamask/transaction-controller';
import { RootState } from '../reducers';
import { MetricsEventBuilder } from './Analytics/MetricsEventBuilder';
import { RootState } from '../../reducers';
import { MetricsEventBuilder } from '../Analytics/MetricsEventBuilder';

jest.unmock('./Engine');
jest.mock('../store', () => ({
jest.mock('../../store', () => ({
store: { getState: jest.fn(() => ({ engine: {} })) },
}));
jest.mock('../selectors/smartTransactionsController', () => ({
jest.mock('../../selectors/smartTransactionsController', () => ({
selectShouldUseSmartTransaction: jest.fn().mockReturnValue(false),
}));

Expand Down Expand Up @@ -276,11 +273,17 @@ describe('Engine', () => {
AccountTrackerController: {
accountsByChainId: {
[chainId]: {
[selectedAddress]: { balance: (ethBalance * 1e18).toString(), stakedBalance: (stakedEthBalance * 1e18).toString() },
[selectedAddress]: {
balance: (ethBalance * 1e18).toString(),
stakedBalance: (stakedEthBalance * 1e18).toString(),
},
},
},
accounts: {
[selectedAddress]: { balance: (ethBalance * 1e18).toString(), stakedBalance: (stakedEthBalance * 1e18).toString() },
[selectedAddress]: {
balance: (ethBalance * 1e18).toString(),
stakedBalance: (stakedEthBalance * 1e18).toString(),
},
},
},
TokensController: {
Expand Down
Loading
Loading