Skip to content

Commit

Permalink
Merge branch 'main' into feat/stake-884-add-more-mobile-pooled-stakin…
Browse files Browse the repository at this point in the history
…g-events
  • Loading branch information
Matt561 authored Jan 6, 2025
2 parents 3dd0def + d0942f5 commit 662ad38
Show file tree
Hide file tree
Showing 162 changed files with 5,252 additions and 3,343 deletions.
1 change: 1 addition & 0 deletions .depcheckrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ ignores:
- '@react-native-community/slider'
- 'patch-package'
- '@lavamoat/allow-scripts'
- '@lavamoat/git-safe-dependencies'
- 'babel-plugin-inline-import'
# This is used on the patch for TokenRatesController of Assets controllers, for we to be able to use the last version of it
- cockatiel
Expand Down
1 change: 1 addition & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ module.exports = {
{
files: [
'app/components/UI/Name/**/*.{js,ts,tsx}',
'app/components/UI/SimulationDetails/**/*.{js,ts,tsx}',
'app/components/hooks/DisplayName/**/*.{js,ts,tsx}'
],
rules: {
Expand Down
13 changes: 12 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,17 @@ jobs:
echo "Duplicate dependencies detected; run 'yarn deduplicate' to remove them"
exit 1
fi
git-safe-dependencies:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version-file: '.nvmrc'
cache: yarn
- run: yarn setup --node
- name: Run @lavamoat/git-safe-dependencies
run: yarn git-safe-dependencies
scripts:
runs-on: ubuntu-20.04
strategy:
Expand Down Expand Up @@ -323,4 +334,4 @@ jobs:
else
echo "All jobs passed step skipped. Block PR."
exit 1
fi
fi
5 changes: 4 additions & 1 deletion .js.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,10 @@ export MM_ENABLE_SETTINGS_PAGE_DEV_OPTIONS="true"
# Per dapp selected network (Amon Hen) feature flag
export MM_PER_DAPP_SELECTED_NETWORK=""

export MM_CHAIN_PERMISSIONS=""
# Multichain permissions now set to true in production via the CI
# MM_MULTICHAIN_V1_ENABLED is the UI, and MM_CHAIN_PERMISSIONS is the engine
export MM_MULTICHAIN_V1_ENABLED="true"
export MM_CHAIN_PERMISSIONS="true"

# Multichain feature flag specific to UI changes
export MM_MULTICHAIN_V1_ENABLED=""
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

## Current Main Branch

## 7.37.1 - Dec 16, 2024
### Fixed
- [#12577](https://github.com/MetaMask/metamask-mobile/pull/12577): chore: bump {gas-fee,network,selected-network,notification-services,profile-sync,signature}-controller (#12577)
- [#12694](https://github.com/MetaMask/metamask-mobile/pull/12694): fix: small refactoring of the latest migration script + add a new migration case (#12694)
- [#12664](https://github.com/MetaMask/metamask-mobile/pull/12664): fix: mark transactions as failed for cancelled / unknown smart transactions (#12664)

## 7.37.0 - Nov 28, 2024
### Added
- [#12091](https://github.com/MetaMask/metamask-mobile/pull/12091): feat: 2020 Add a performance test for iOS in Bitrise (#12091)
Expand Down
4 changes: 2 additions & 2 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,8 @@ android {
applicationId "io.metamask"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionName "7.37.0"
versionCode 1512
versionName "7.37.1"
versionCode 1520
testBuildType System.getProperty('testBuildType', 'debug')
missingDimensionStrategy 'react-native-camera', 'general'
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
Expand Down
2 changes: 1 addition & 1 deletion app/actions/notification/helpers/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
mmStorage,
getAllUUIDs,
} from '../../../util/notifications';
import { UserStorage } from '@metamask/notification-services-controller/dist/NotificationServicesController/types/user-storage/index.cjs';
import type { UserStorage } from '@metamask/notification-services-controller/notification-services';

export type MarkAsReadNotificationsParam = Pick<
Notification,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ exports[`BottomSheetHeader should render snapshot correctly 1`] = `
<View
style={
{
"alignItems": "center",
"backgroundColor": "#ffffff",
"flexDirection": "row",
"padding": 16,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ const styleSheet = (params: {
{
backgroundColor: theme.colors.background.default,
flexDirection: 'row',
alignItems: 'center',
} as ViewStyle,
style,
) as ViewStyle,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ exports[`HeaderBase should render snapshot correctly 1`] = `
<View
style={
{
"alignItems": "center",
"backgroundColor": "#ffffff",
"flexDirection": "row",
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,26 @@ import { ApprovalTypes } from '../../../core/RPCMethods/RPCMethodMiddleware';
import { ApprovalRequest } from '@metamask/approval-controller';
import SwitchChainApproval from './SwitchChainApproval';
import { networkSwitched } from '../../../actions/onboardNetwork';
// eslint-disable-next-line import/no-namespace
import * as networks from '../../../util/networks';
import Engine from '../../../core/Engine';
const { PreferencesController } = Engine.context;

jest.mock('../../Views/confirmations/hooks/useApprovalRequest');
jest.mock('../../../actions/onboardNetwork');

jest.mock('../../../core/Engine', () => ({
context: {
PreferencesController: {
setTokenNetworkFilter: jest.fn(),
},
},
}));

jest.mock('react-redux', () => ({
...jest.requireActual('react-redux'),
useDispatch: () => jest.fn(),
useSelector: jest.fn(),
}));

const URL_MOCK = 'test.com';
Expand All @@ -32,6 +45,7 @@ const mockApprovalRequest = (approvalRequest?: ApprovalRequest<any>) => {
describe('SwitchChainApproval', () => {
beforeEach(() => {
jest.resetAllMocks();
jest.spyOn(networks, 'isPortfolioViewEnabled').mockReturnValue(false);
});

it('renders', () => {
Expand Down Expand Up @@ -81,4 +95,29 @@ describe('SwitchChainApproval', () => {
networkStatus: true,
});
});

it('invokes network switched on confirm when portfolio view is enabled', () => {
jest.spyOn(networks, 'isPortfolioViewEnabled').mockReturnValue(true);
const tokenNetworkFilterSpy = jest.spyOn(
PreferencesController,
'setTokenNetworkFilter',
);
mockApprovalRequest({
type: ApprovalTypes.SWITCH_ETHEREUM_CHAIN,
requestData: {
rpcUrl: URL_MOCK,
},
} as ApprovalRequest<{
rpcUrl: string;
}>);

const wrapper = shallow(<SwitchChainApproval />);
wrapper.find('SwitchCustomNetwork').simulate('confirm');
expect(tokenNetworkFilterSpy).toHaveBeenCalledTimes(1);
expect(networkSwitched).toHaveBeenCalledTimes(1);
expect(networkSwitched).toHaveBeenCalledWith({
networkUrl: URL_MOCK,
networkStatus: true,
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@ import { ApprovalTypes } from '../../../core/RPCMethods/RPCMethodMiddleware';
import ApprovalModal from '../ApprovalModal';
import SwitchCustomNetwork from '../../UI/SwitchCustomNetwork';
import { networkSwitched } from '../../../actions/onboardNetwork';
import { useDispatch } from 'react-redux';
import { useDispatch, useSelector } from 'react-redux';
import Engine from '../../../core/Engine';
import { selectIsAllNetworks } from '../../../selectors/networkController';
import { selectTokenNetworkFilter } from '../../../selectors/preferencesController';
import { isPortfolioViewEnabled } from '../../../util/networks';

const SwitchChainApproval = () => {
const {
Expand All @@ -15,17 +19,34 @@ const SwitchChainApproval = () => {
} = useApprovalRequest();

const dispatch = useDispatch();
const isAllNetworks = useSelector(selectIsAllNetworks);
const tokenNetworkFilter = useSelector(selectTokenNetworkFilter);

const onConfirm = useCallback(() => {
defaultOnConfirm();

// If portfolio view is enabled should set network filter
if (isPortfolioViewEnabled()) {
const { PreferencesController } = Engine.context;
PreferencesController.setTokenNetworkFilter({
...(isAllNetworks ? tokenNetworkFilter : {}),
[approvalRequest?.requestData?.chainId]: true,
});
}

dispatch(
networkSwitched({
networkUrl: approvalRequest?.requestData?.rpcUrl,
networkStatus: true,
}),
);
}, [approvalRequest, defaultOnConfirm, dispatch]);
}, [
approvalRequest,
defaultOnConfirm,
dispatch,
isAllNetworks,
tokenNetworkFilter,
]);

if (approvalRequest?.type !== ApprovalTypes.SWITCH_ETHEREUM_CHAIN)
return null;
Expand Down
21 changes: 19 additions & 2 deletions app/components/UI/ApprovalTagUrl/ApprovalTagUrl.test.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import React from 'react';
import renderWithProvider from '../../../util/test/renderWithProvider';
import ApprovalTagUrl from './ApprovalTagUrl';
import ApprovalTagUrl, { APPROVAL_TAG_URL_ORIGIN_PILL } from './ApprovalTagUrl';
import { backgroundState } from '../../../util/test/initial-root-state';
import { INTERNAL_ORIGINS } from '../../../constants/transaction';

const ADDRESS_MOCK = '0x1234567890abcdef1234567890abcdef12345678';
const DOMAIN_MOCK = 'metamask.github.io';

const mockInitialState = {
settings: {},
engine: {
Expand All @@ -19,7 +21,7 @@ const mockInitialState = {

describe('ApprovalTagUrl', () => {
it('renders correctly', () => {
const { toJSON } = renderWithProvider(
const { toJSON, getByTestId } = renderWithProvider(
<ApprovalTagUrl
from={ADDRESS_MOCK}
origin={DOMAIN_MOCK}
Expand All @@ -30,5 +32,20 @@ describe('ApprovalTagUrl', () => {
);

expect(toJSON()).toMatchSnapshot();
expect(getByTestId(APPROVAL_TAG_URL_ORIGIN_PILL)).toBeDefined();
});

it('does not render when origin is an internal origin', () => {
const { queryByTestId } = renderWithProvider(
<ApprovalTagUrl
from={ADDRESS_MOCK}
origin={INTERNAL_ORIGINS[0]}
url={`https://${INTERNAL_ORIGINS[0]}`}
sdkDappMetadata={{ url: '', icon: '' }}
/>,
{ state: mockInitialState },
);

expect(queryByTestId(APPROVAL_TAG_URL_ORIGIN_PILL)).toBeNull();
});
});
5 changes: 4 additions & 1 deletion app/components/UI/ApprovalTagUrl/ApprovalTagUrl.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { selectAccountsByChainId } from '../../../selectors/accountTrackerContro
import { getHost, prefixUrlWithProtocol } from '../../../util/browser';
import useFavicon from '../../hooks/useFavicon/useFavicon';
import stylesheet from './ApprovalTagUrl.styles';
import { INTERNAL_ORIGINS } from '../../../constants/transaction';

const { ORIGIN_DEEPLINK, ORIGIN_QR_CODE } = AppConstants.DEEPLINKS;
export const APPROVAL_TAG_URL_ORIGIN_PILL = 'APPROVAL_TAG_URL_ORIGIN_PILL';
Expand Down Expand Up @@ -76,7 +77,9 @@ const ApprovalTagUrl = ({
uri: '',
};

if (origin && !isOriginDeepLink) {
const showOrigin = origin && !isOriginDeepLink && !INTERNAL_ORIGINS.includes(origin);

if (showOrigin) {
return (
<TagUrl
testID={APPROVAL_TAG_URL_ORIGIN_PILL}
Expand Down
46 changes: 8 additions & 38 deletions app/components/UI/NavbarTitle/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,45 +14,19 @@ import { selectProviderConfig } from '../../../selectors/networkController';
import { withMetricsAwareness } from '../../../components/hooks/useMetrics';
import Text, {
TextVariant,
TextColor,
} from '../../../component-library/components/Texts/Text';

const createStyles = (colors) =>
StyleSheet.create({
wrapper: {
justifyContent: 'center',
alignItems: 'center',
flex: 1,
},
network: {
flexDirection: 'row',
alignItems: 'center',
},
networkName: {
fontSize: 11,
color: colors.text.alternative,
...fontStyles.normal,
},
networkIcon: {
width: 5,
height: 5,
borderRadius: 100,
marginRight: 5,
},
title: {
fontSize: scale(14),
...fontStyles.normal,
color: colors.text.default,
},
children: {
...fontStyles.normal,
color: colors.text.default,
fontWeight: 'bold',
},
otherNetworkIcon: {
backgroundColor: importedColors.transparent,
borderColor: colors.border.default,
borderWidth: 1,
},
});

/**
Expand Down Expand Up @@ -163,26 +137,22 @@ class NavbarTitle extends PureComponent {
activeOpacity={this.props.disableNetwork ? 1 : 0.2}
>
{title ? (
<Text numberOfLines={1} style={styles.title}>
<Text numberOfLines={1} variant={TextVariant.BodyMDBold}>
{realTitle}
</Text>
) : null}
{typeof children === 'string' ? (
<Text variant={TextVariant.HeadingMD} style={styles.children}>
{strings(children)}
</Text>
<Text variant={TextVariant.BodyMDBold}>{strings(children)}</Text>
) : (
children
)}
{showSelectedNetwork ? (
<View style={styles.network}>
<View
style={[
styles.networkIcon,
color ? { backgroundColor: color } : styles.otherNetworkIcon,
]}
/>
<Text numberOfLines={1} style={styles.networkName}>
<Text
numberOfLines={1}
variant={TextVariant.BodySM}
color={TextColor.Alternative}
>
{name}
</Text>
</View>
Expand Down
Loading

0 comments on commit 662ad38

Please sign in to comment.