Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
16 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
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ import { shallow } from 'enzyme';
import { ApprovalTypes } from '../../../core/RPCMethods/RPCMethodMiddleware';
import SwitchChainApproval from './SwitchChainApproval';
import { networkSwitched } from '../../../actions/onboardNetwork';
// eslint-disable-next-line import/no-namespace
import * as networks from '../../../util/networks';
import {
Caip25CaveatType,
Caip25EndowmentPermissionName,
Expand Down Expand Up @@ -102,9 +100,6 @@ const mockApprovalRequestData = {
describe('SwitchChainApproval', () => {
beforeEach(() => {
jest.clearAllMocks();
jest
.spyOn(networks, 'isRemoveGlobalNetworkSelectorEnabled')
.mockReturnValue(false);
});

it('renders', () => {
Expand Down Expand Up @@ -166,11 +161,7 @@ describe('SwitchChainApproval', () => {
});
});

it('calls selectNetwork when remove global network selector are enabled', () => {
jest
.spyOn(networks, 'isRemoveGlobalNetworkSelectorEnabled')
.mockReturnValue(true);

it('calls selectNetwork when confirm is pressed', () => {
mockApprovalRequest({
type: ApprovalTypes.SWITCH_ETHEREUM_CHAIN,
requestData: mockApprovalRequestData,
Expand All @@ -187,25 +178,4 @@ describe('SwitchChainApproval', () => {
networkStatus: true,
});
});

it('does not call selectNetwork when remove global network selector is disabled', () => {
jest
.spyOn(networks, 'isRemoveGlobalNetworkSelectorEnabled')
.mockReturnValue(false);

mockApprovalRequest({
type: ApprovalTypes.SWITCH_ETHEREUM_CHAIN,
requestData: mockApprovalRequestData,
});

const wrapper = shallow(<SwitchChainApproval />);
wrapper.find('SwitchCustomNetwork').simulate('confirm');

expect(mockSelectNetwork).not.toHaveBeenCalled();
expect(networkSwitched).toHaveBeenCalledTimes(1);
expect(networkSwitched).toHaveBeenCalledWith({
networkUrl: URL_MOCK,
networkStatus: true,
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import ApprovalModal from '../ApprovalModal';
import SwitchCustomNetwork from '../../UI/SwitchCustomNetwork';
import { networkSwitched } from '../../../actions/onboardNetwork';
import { useDispatch, useSelector } from 'react-redux';
import { isRemoveGlobalNetworkSelectorEnabled } from '../../../util/networks';
import {
NetworkType,
useNetworksByNamespace,
Expand Down Expand Up @@ -54,9 +53,7 @@ const SwitchChainApproval = () => {
defaultOnConfirm();

// If remove global network selector is enabled should set network filter
if (isRemoveGlobalNetworkSelectorEnabled()) {
selectNetwork(chainId);
}
selectNetwork(chainId);

dispatch(
networkSwitched({
Expand Down
64 changes: 43 additions & 21 deletions app/components/Nav/Main/MainNavigator.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ import ContactForm from '../../Views/Settings/Contacts/ContactForm';
import ActivityView from '../../Views/ActivityView';
import RewardsNavigator from '../../UI/Rewards/RewardsNavigator';
import TrendingView from '../../Views/TrendingView/TrendingView';
import SitesListView from '../../Views/TrendingView/SitesListView';
import SwapsAmountView from '../../UI/Swaps';
import SwapsQuotesView from '../../UI/Swaps/QuotesView';
import CollectiblesDetails from '../../UI/CollectibleModal';
import OptinMetrics from '../../UI/OptinMetrics';

Expand Down Expand Up @@ -131,6 +132,8 @@ import {
TOKEN,
} from '../../Views/AddAsset/AddAsset.constants';
import { strings } from '../../../../locales/i18n';
import SitesFullView from '../../Views/SitesFullView/SitesFullView';
import BrowserWrapper from '../../Views/TrendingView/components/BrowserWrapper/BrowserWrapper';
import BridgeView from '../../UI/Bridge/Views/BridgeView';

const Stack = createStackNavigator();
Expand Down Expand Up @@ -291,26 +294,6 @@ const TrendingHome = () => (
component={TrendingView}
options={{ headerShown: false }}
/>
<Stack.Screen
name={Routes.SITES_LIST_VIEW}
component={SitesListView}
options={{
headerShown: false,
animationEnabled: true,
cardStyleInterpolator: ({ current, layouts }) => ({
cardStyle: {
transform: [
{
translateX: current.progress.interpolate({
inputRange: [0, 1],
outputRange: [layouts.screen.width, 0],
}),
},
],
},
}),
}}
/>
</Stack.Navigator>
);

Expand Down Expand Up @@ -967,6 +950,26 @@ const MainNavigator = () => {
}}
/>
<Stack.Screen name="Home" component={HomeTabs} />
<Stack.Screen
name="TrendingBrowser"
component={BrowserWrapper}
options={{
headerShown: false,
animationEnabled: true,
cardStyleInterpolator: ({ current, layouts }) => ({
cardStyle: {
transform: [
{
translateX: current.progress.interpolate({
inputRange: [0, 1],
outputRange: [layouts.screen.width, 0],
}),
},
],
},
}),
}}
/>
<Stack.Screen
name={Routes.WALLET.TOKENS_FULL_VIEW}
component={TokensFullView}
Expand Down Expand Up @@ -1030,6 +1033,25 @@ const MainNavigator = () => {
}),
}}
/>
<Stack.Screen
name={Routes.SITES_FULL_VIEW}
component={SitesFullView}
options={{
animationEnabled: true,
cardStyleInterpolator: ({ current, layouts }) => ({
cardStyle: {
transform: [
{
translateX: current.progress.interpolate({
inputRange: [0, 1],
outputRange: [layouts.screen.width, 0],
}),
},
],
},
}),
}}
/>
<Stack.Screen name="Webview" component={Webview} />
<Stack.Screen name="SendView" component={SendView} />
<Stack.Screen
Expand Down
21 changes: 21 additions & 0 deletions app/components/Nav/Main/__snapshots__/MainNavigator.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,17 @@ exports[`MainNavigator matches rendered snapshot 1`] = `
component={[Function]}
name="Home"
/>
<Screen
component={[Function]}
name="TrendingBrowser"
options={
{
"animationEnabled": true,
"cardStyleInterpolator": [Function],
"headerShown": false,
}
}
/>
<Screen
component={[Function]}
name="TokensFullView"
Expand Down Expand Up @@ -86,6 +97,16 @@ exports[`MainNavigator matches rendered snapshot 1`] = `
}
}
/>
<Screen
component={[Function]}
name="SitesFullView"
options={
{
"animationEnabled": true,
"cardStyleInterpolator": [Function],
}
}
/>
<Screen
component={[Function]}
name="Webview"
Expand Down
5 changes: 3 additions & 2 deletions app/components/UI/Bridge/hooks/useAssetMetadata/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { handleFetch } from '@metamask/controller-utils';
import {
formatAddressToCaipReference,
formatChainIdToHex,
isNonEvmChainId,
} from '@metamask/bridge-controller';

const TOKEN_API_V3_BASE_URL = 'https://tokens.api.cx.metamask.io/v3';
Expand Down Expand Up @@ -103,8 +104,8 @@ export const fetchAssetMetadata = async (
assetId,
};

// Solana
if (chainId === MultichainNetwork.Solana && assetId) {
// non-EVM
if (isNonEvmChainId(chainId) && assetId) {
const { assetReference } = parseCaipAssetType(assetId);
return {
...commonFields,
Expand Down
Loading
Loading