Skip to content

Commit

Permalink
Merge branch 'main' into 3053-integrate-nft-api-to-display-names-for-…
Browse files Browse the repository at this point in the history
…nfts-within-simulations-on-mobile
  • Loading branch information
OGPoyraz authored Nov 5, 2024
2 parents 99ff5a9 + d8dd6a8 commit 26e42ea
Show file tree
Hide file tree
Showing 31 changed files with 1,146 additions and 231 deletions.
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
20.14.0
20.17.0
13 changes: 10 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,24 @@

## Current Main Branch

## 7.33.1 - Oct 29, 2024
## 7.33.2 - Nov 1, 2024
### Fixed
- [#10952](https://github.com/MetaMask/metamask-mobile/pull/10952): refactor(ramp): update ramp copy (#10952)

## 7.33.2 - Oct 29, 2024
### Fixed
- [#12073](https://github.com/MetaMask/metamask-mobile/pull/12073): feat: Simulation re-trigger (#12073)

## 7.33.0 - Oct 17, 2024
## 7.33.0 - Oct 3, 2024
### Added
- [#11507](https://github.com/MetaMask/metamask-mobile/pull/11507): feat: 10550 Re-introduce test for measuring cold app start + JS bundle load time (#11507)
- [#11347](https://github.com/MetaMask/metamask-mobile/pull/11347): "chore: revert ""feat: react native fast crypto for notifications"" (#11347)"
- [#11318](https://github.com/MetaMask/metamask-mobile/pull/11318): feat: app event manager and attribution id parameters (#11318)
- [#11445](https://github.com/MetaMask/metamask-mobile/pull/11445): feat: add the abilty to hide the disconnect all button as well as showing and hiding the accounts row when necessary (#11445)
- [#11386](https://github.com/MetaMask/metamask-mobile/pull/11386): feat(3299): add tracking to network switching and confirmation (#11386)
- [#11379](https://github.com/MetaMask/metamask-mobile/pull/11379): refactor: rename the feature flag since it had a typo (#11379)
- [#11239](https://github.com/MetaMask/metamask-mobile/pull/11239): feat(2739): permission summary view gets the ability to disconnect all (#11239)
- [#11382](https://github.com/MetaMask/metamask-mobile/pull/11382): chore(runway): cherry-pick feat: app event manager and attribution id parameters (#11382)
- [#11497](https://github.com/MetaMask/metamask-mobile/pull/11497): feat: simple key-> value component for text value type (#11497)
- [#11478](https://github.com/MetaMask/metamask-mobile/pull/11478): feat: adding title to confirmation page (#11478)
- [#11477](https://github.com/MetaMask/metamask-mobile/pull/11477): feat: adding footer section to confirmation page (#11477)
Expand All @@ -24,7 +31,7 @@
- [#11399](https://github.com/MetaMask/metamask-mobile/pull/11399): feat: add learn more modal component for staking (#11399)
- [#11261](https://github.com/MetaMask/metamask-mobile/pull/11261): feat: STAKE-822 build your balance component (#11261)
- [#11294](https://github.com/MetaMask/metamask-mobile/pull/11294): feat: added KeyValueRow to component-library/components-temp (#11294)
- [#11185](https://github.com/MetaMask/metamask-mobile/pull/11185): feat: display ""Snaps (Beta)"" decorator tag in accounts list (#11185)
- [#11185](https://github.com/MetaMask/metamask-mobile/pull/11185): "feat: display ""Snaps (Beta)"" decorator tag in accounts list (#11185)"
- [#10829](https://github.com/MetaMask/metamask-mobile/pull/10829): feat: Eth snap keyring (#10829)
- [#11455](https://github.com/MetaMask/metamask-mobile/pull/11455): feat: bootstrap a reset notifications feat (#11455)
- [#11466](https://github.com/MetaMask/metamask-mobile/pull/11466): feat: add support for external links (#11466)
Expand Down
4 changes: 2 additions & 2 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,8 @@ android {
applicationId "io.metamask"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionName "7.33.1"
versionCode 1471
versionName "7.33.2"
versionCode 1474
testBuildType System.getProperty('testBuildType', 'debug')
missingDimensionStrategy 'react-native-camera', 'general'
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
Expand Down
5 changes: 5 additions & 0 deletions app/components/Nav/App/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ import NftOptions from '../../../components/Views/NftOptions';
import ShowTokenIdSheet from '../../../components/Views/ShowTokenIdSheet';
import OriginSpamModal from '../../Views/OriginSpamModal/OriginSpamModal';
import { isNetworkUiRedesignEnabled } from '../../../util/networks/isNetworkUiRedesignEnabled';
import ChangeInSimulationModal from '../../Views/ChangeInSimulationModal/ChangeInSimulationModal';
import TooltipModal from '../../../components/Views/TooltipModal';
///: BEGIN:ONLY_INCLUDE_IF(preinstalled-snaps,external-snaps)
import { SnapsExecutionWebView } from '../../../lib/snaps';
Expand Down Expand Up @@ -502,6 +503,10 @@ const RootModalFlow = () => (
name={Routes.SHEET.ORIGIN_SPAM_MODAL}
component={OriginSpamModal}
/>
<Stack.Screen
name={Routes.SHEET.CHANGE_IN_SIMULATION_MODAL}
component={ChangeInSimulationModal}
/>
<Stack.Screen name={Routes.SHEET.TOOLTIP_MODAL} component={TooltipModal} />
</Stack.Navigator>
);
Expand Down
7 changes: 6 additions & 1 deletion app/components/UI/Stake/hooks/usePoolStakedClaim/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import { PooledStake, PooledStakingContract } from '@metamask/stake-sdk';
import { useStakeContext } from '../useStakeContext';
import trackErrorAsAnalytics from '../../../../../util/metrics/TrackError/trackErrorAsAnalytics';
import { WalletDevice } from '@metamask/transaction-controller';
import {
TransactionType,
WalletDevice,
} from '@metamask/transaction-controller';
import { addTransaction } from '../../../../../util/transaction-controller';
import { ORIGIN_METAMASK } from '@metamask/controller-utils';
import {
Expand Down Expand Up @@ -42,6 +45,7 @@ const attemptMultiCallClaimTransaction = async (
return addTransaction(txParams, {
deviceConfirmedOn: WalletDevice.MM_MOBILE,
origin: ORIGIN_METAMASK,
type: TransactionType.stakingClaim,
});
};

Expand Down Expand Up @@ -84,6 +88,7 @@ const attemptSingleClaimTransaction = async (
return addTransaction(txParams, {
deviceConfirmedOn: WalletDevice.MM_MOBILE,
origin: ORIGIN_METAMASK,
type: TransactionType.stakingClaim,
});
};

Expand Down
2 changes: 2 additions & 0 deletions app/components/UI/Stake/hooks/usePoolStakedDeposit/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { ChainId, PooledStakingContract } from '@metamask/stake-sdk';
import {
TransactionParams,
TransactionType,
WalletDevice,
} from '@metamask/transaction-controller';
import { ORIGIN_METAMASK, toHex } from '@metamask/controller-utils';
Expand Down Expand Up @@ -63,6 +64,7 @@ const attemptDepositTransaction =
return await addTransaction(txParams, {
deviceConfirmedOn: WalletDevice.MM_MOBILE,
origin: ORIGIN_METAMASK,
type: TransactionType.stakingDeposit,
});
} catch (e) {
const errorMessage = (e as Error).message;
Expand Down
2 changes: 2 additions & 0 deletions app/components/UI/Stake/hooks/usePoolStakedUnstake/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { PooledStakingContract, ChainId } from '@metamask/stake-sdk';
import { useStakeContext } from '../useStakeContext';
import {
TransactionParams,
TransactionType,
WalletDevice,
} from '@metamask/transaction-controller';
import { addTransaction } from '../../../../../util/transaction-controller';
Expand Down Expand Up @@ -50,6 +51,7 @@ const attemptUnstakeTransaction =
return await addTransaction(txParams, {
deviceConfirmedOn: WalletDevice.MM_MOBILE,
origin: ORIGIN_METAMASK,
type: TransactionType.stakingUnstake,
});
} catch (e) {
const errorMessage = (e as Error).message;
Expand Down
4 changes: 2 additions & 2 deletions app/components/UI/Tokens/index.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jest.mock('../../../core/Engine', () => ({
refresh: jest.fn(() => Promise.resolve()),
},
CurrencyRateController: {
startPollingByNetworkClientId: jest.fn(() => Promise.resolve()),
startPolling: jest.fn(() => Promise.resolve()),
},
TokenRatesController: {
updateExchangeRates: jest.fn(() => Promise.resolve()),
Expand Down Expand Up @@ -356,7 +356,7 @@ describe('Tokens', () => {
Engine.context.AccountTrackerController.refresh,
).toHaveBeenCalled();
expect(
Engine.context.CurrencyRateController.startPollingByNetworkClientId,
Engine.context.CurrencyRateController.startPolling,
).toHaveBeenCalled();
expect(
Engine.context.TokenRatesController.updateExchangeRates,
Expand Down
4 changes: 3 additions & 1 deletion app/components/UI/Tokens/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,9 @@ const Tokens: React.FC<TokensI> = ({ tokens }) => {
const actions = [
TokenDetectionController.detectTokens(),
AccountTrackerController.refresh(),
CurrencyRateController.startPollingByNetworkClientId(networkClientId),
CurrencyRateController.startPolling({
networkClientId,
}),
TokenRatesController.updateExchangeRates(),
];
await Promise.all(actions).catch((error) => {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
import React from 'react';
import { fireEvent } from '@testing-library/react-native';

import renderWithProvider, {
DeepPartial,
} from '../../../util/test/renderWithProvider';
import { backgroundState } from '../../../util/test/initial-root-state';
import ChangeInSimulationModal, {
PROCEED_BUTTON_TEST_ID,
REJECT_BUTTON_TEST_ID,
} from './ChangeInSimulationModal';
import { RootState } from '../../../reducers';

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

jest.mock(
'../../../component-library/components/BottomSheets/BottomSheet',
() =>
({ children }: { children: React.ReactElement }) =>
<>{children}</>,
);

const NAVIGATION_PARAMS_MOCK = {
params: {
onProceed: jest.fn(),
onReject: jest.fn(),
},
};

const mockInitialState: DeepPartial<RootState> = {
engine: {
backgroundState: {
...backgroundState,
},
},
};

describe('ChangeInSimulationModal', () => {
beforeEach(() => {
jest.clearAllMocks();
});

it('render matches snapshot', () => {
const { toJSON } = renderWithProvider(
<ChangeInSimulationModal route={NAVIGATION_PARAMS_MOCK} />,
{
state: mockInitialState,
},
);
expect(toJSON()).toMatchSnapshot();
});

it('calls onProceed and onReject callbacks', () => {
const mockOnReject = jest.fn();
const mockOnProceed = jest.fn();
const wrapper = renderWithProvider(
<ChangeInSimulationModal
route={{ params: { onProceed: mockOnProceed, onReject: mockOnReject } }}
/>,
{
state: mockInitialState,
},
);
fireEvent.press(wrapper.getByTestId(PROCEED_BUTTON_TEST_ID));
expect(mockOnProceed).toHaveBeenCalledTimes(1);

fireEvent.press(wrapper.getByTestId(REJECT_BUTTON_TEST_ID));
expect(mockOnReject).toHaveBeenCalledTimes(1);
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
import React, { useCallback, useRef } from 'react';
import { StyleSheet, View } from 'react-native';
import { strings } from '../../../../locales/i18n';
import BottomSheet, {
BottomSheetRef,
} from '../../../component-library/components/BottomSheets/BottomSheet';
import Button from '../../../component-library/components/Buttons/Button/Button';
import Icon, {
IconSize,
IconName,
IconColor,
} from '../../../component-library/components/Icons/Icon';
import {
ButtonSize,
ButtonVariants,
ButtonWidthTypes,
} from '../../../component-library/components/Buttons/Button';
import SheetHeader from '../../../component-library/components/Sheet/SheetHeader';
import Text from '../../../component-library/components/Texts/Text';

export const PROCEED_BUTTON_TEST_ID = 'proceed-button';
export const REJECT_BUTTON_TEST_ID = 'reject-button';

const createStyles = () =>
StyleSheet.create({
buttonsWrapper: {
alignSelf: 'stretch',
flexDirection: 'column',
gap: 16,
paddingTop: 24,
},
wrapper: {
alignItems: 'center',
padding: 16,
},
description: {
textAlign: 'center',
},
});

const ChangeInSimulationModal = ({
route,
}: {
route: { params: { onProceed: () => void; onReject: () => void } };
}) => {
const styles = createStyles();
const sheetRef = useRef<BottomSheetRef>(null);
const { onProceed, onReject } = route.params;

const handleProceed = useCallback(() => {
sheetRef.current?.onCloseBottomSheet();
onProceed();
}, [onProceed, sheetRef]);

const handleReject = useCallback(() => {
sheetRef.current?.onCloseBottomSheet();
onReject();
}, [onReject, sheetRef]);

return (
<BottomSheet ref={sheetRef}>
<View style={styles.wrapper}>
<Icon
color={IconColor.Error}
name={IconName.Warning}
size={IconSize.Xl}
/>
<SheetHeader title={strings('change_in_simulation_modal.title')} />
<Text>{strings('change_in_simulation_modal.description')}</Text>
<View style={styles.buttonsWrapper}>
<Button
label={strings('change_in_simulation_modal.reject')}
onPress={handleReject}
size={ButtonSize.Lg}
testID={REJECT_BUTTON_TEST_ID}
variant={ButtonVariants.Primary}
width={ButtonWidthTypes.Full}
/>
<Button
label={strings('change_in_simulation_modal.proceed')}
onPress={handleProceed}
size={ButtonSize.Lg}
testID={PROCEED_BUTTON_TEST_ID}
variant={ButtonVariants.Secondary}
width={ButtonWidthTypes.Full}
/>
</View>
</View>
</BottomSheet>
);
};

export default ChangeInSimulationModal;
Loading

0 comments on commit 26e42ea

Please sign in to comment.