Skip to content

Commit

Permalink
Remove PORTFOLIO_VIEW feature flag
Browse files Browse the repository at this point in the history
  • Loading branch information
darkwing committed Mar 7, 2025
1 parent 5535411 commit dae3926
Show file tree
Hide file tree
Showing 20 changed files with 129 additions and 291 deletions.
2 changes: 0 additions & 2 deletions builds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -295,8 +295,6 @@ env:
- BARAD_DUR: ''
# Determines if feature flagged Chain permissions
- CHAIN_PERMISSIONS: ''
# Determines if Portfolio View UI should be shown
- PORTFOLIO_VIEW: 'true'
# Enables use of test gas fee flow to debug gas fee estimation
- TEST_GAS_FEE_FLOWS: false
# Temporary mechanism to enable security alerts API prior to release
Expand Down
4 changes: 0 additions & 4 deletions test/e2e/tests/multichain/aggregated-balances.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,6 @@ const NETWORK_NAME_SEPOLIA = 'Sepolia';
const SEPOLIA_NATIVE_TOKEN = 'SepoliaETH';

describe('Multichain Aggregated Balances', function (this: Suite) {
if (!process.env.PORTFOLIO_VIEW) {
return;
}

it('shows correct aggregated balance when "Current Network" is selected', async function () {
await withFixtures(
{
Expand Down
4 changes: 0 additions & 4 deletions test/e2e/tests/multichain/asset-list.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,6 @@ function buildFixtures(title: string, chainId: number = 1337) {
}

describe('Multichain Asset List', function (this: Suite) {
if (!process.env.PORTFOLIO_VIEW) {
return;
}

it('persists the preferred asset list preference when changing networks', async function () {
await withFixtures(
buildFixtures(this.test?.fullTitle() as string),
Expand Down
93 changes: 37 additions & 56 deletions test/e2e/tests/privacy/polling.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -280,38 +280,21 @@ describe('Account Tracker API polling', function () {
);

// TODO: expecting the length of infuraJsonRpcRequests would be more accurate
if (process.env.PORTFOLIO_VIEW) {
const ethCallInfuraRequests = infuraJsonRpcRequests.filter(
(obj) =>
obj.method === 'eth_call' &&
(obj.params as unknown[])?.[1] === '3',
);
const ethCallInfuraRequests = infuraJsonRpcRequests.filter(
(obj) =>
obj.method === 'eth_call' && (obj.params as unknown[])?.[1] === '3',
);

const ethGetBalanceInfuraRequests = infuraJsonRpcRequests.filter(
(obj) =>
obj.method === 'eth_getBalance' &&
(obj.params as unknown[])?.[1] === '3',
);
const ethGetBalanceInfuraRequests = infuraJsonRpcRequests.filter(
(obj) =>
obj.method === 'eth_getBalance' &&
(obj.params as unknown[])?.[1] === '3',
);

// We will call eth_getBalance for Sepolia and Linea Sepolia because multicall is not available for them
expect(ethGetBalanceInfuraRequests.length).toEqual(2);
// We will call eth_call for linea mainnet and mainnet
expect(ethCallInfuraRequests.length).toEqual(2);
} else {
expect(
infuraJsonRpcRequests.some(
(obj) => obj.method === 'eth_blockNumber',
),
).toBeTruthy();
expect(
infuraJsonRpcRequests.some(
(obj) => obj.method === 'eth_getBlockByNumber',
),
).toBeTruthy();
expect(
infuraJsonRpcRequests.some((obj) => obj.method === 'eth_call'),
).toBeTruthy();
}
// We will call eth_getBalance for Sepolia and Linea Sepolia because multicall is not available for them
expect(ethGetBalanceInfuraRequests.length).toEqual(2);
// We will call eth_call for linea mainnet and mainnet
expect(ethCallInfuraRequests.length).toEqual(2);
},
);
});
Expand Down Expand Up @@ -350,32 +333,30 @@ describe('Token Detection', function () {
];
}
it('should make calls to account api as expected', async function () {
if (process.env.PORTFOLIO_VIEW) {
await withFixtures(
{
fixtures: new FixtureBuilder()
.withNetworkControllerOnMainnet()
.withPreferencesControllerShowNativeTokenAsMainBalanceDisabled()
.build(),
title: this.test?.fullTitle(),
testSpecificMock: mockAccountApiForPortfolioView,
},
async ({ driver, mockedEndpoint: mockedEndpoints }) => {
await loginWithoutBalanceValidation(driver);
const homepage = new HomePage(driver);
await homepage.check_pageIsLoaded();
await driver.delay(DELAY_UNTIL_NEXT_POLL);
await withFixtures(
{
fixtures: new FixtureBuilder()
.withNetworkControllerOnMainnet()
.withPreferencesControllerShowNativeTokenAsMainBalanceDisabled()
.build(),
title: this.test?.fullTitle(),
testSpecificMock: mockAccountApiForPortfolioView,
},
async ({ driver, mockedEndpoint: mockedEndpoints }) => {
await loginWithoutBalanceValidation(driver);
const homepage = new HomePage(driver);
await homepage.check_pageIsLoaded();
await driver.delay(DELAY_UNTIL_NEXT_POLL);

for (const single of mockedEndpoints) {
const requests = await single.getSeenRequests();
assert.equal(
requests.length,
1,
`${single} should make requests after onboarding`,
);
}
},
);
}
for (const single of mockedEndpoints) {
const requests = await single.getSeenRequests();
assert.equal(
requests.length,
1,
`${single} should make requests after onboarding`,
);
}
},
);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,7 @@ const AssetListControlBar = ({ showTokensLinks }: AssetListControlBarProps) => {
// We need to set the default filter for all users to be all included networks, rather than defaulting to empty object
// This effect is to unblock and derisk in the short-term
useEffect(() => {
if (
process.env.PORTFOLIO_VIEW &&
Object.keys(tokenNetworkFilter).length === 0
) {
if (Object.keys(tokenNetworkFilter).length === 0) {
dispatch(setTokenNetworkFilter(allOpts));
} else {
dispatch(setTokenNetworkFilter({ [currentNetwork.chainId]: true }));
Expand Down Expand Up @@ -176,13 +173,11 @@ const AssetListControlBar = ({ showTokensLinks }: AssetListControlBarProps) => {
<Box
display={Display.Flex}
justifyContent={
process.env.PORTFOLIO_VIEW && isEvmNetwork
? JustifyContent.spaceBetween
: JustifyContent.flexEnd
isEvmNetwork ? JustifyContent.spaceBetween : JustifyContent.flexEnd
}
>
{/* TODO: Remove isEvmNetwork check when we are ready to show the network filter in all networks including non-EVM */}
{process.env.PORTFOLIO_VIEW && isEvmNetwork ? (
{isEvmNetwork ? (
<ButtonBase
data-testid="sort-by-networks"
variant={TextVariant.bodyMdMedium}
Expand Down
12 changes: 5 additions & 7 deletions ui/components/app/assets/hooks/useNetworkFilter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,12 @@ const useNetworkFilter = () => {
const networkFilter = useSelector(getTokenNetworkFilter);

useEffect(() => {
if (process.env.PORTFOLIO_VIEW) {
const allNetworkFilters = Object.fromEntries(
Object.keys(allNetworks).map((chainId) => [chainId, true]),
);
const allNetworkFilters = Object.fromEntries(
Object.keys(allNetworks).map((chainId) => [chainId, true]),
);

if (Object.keys(networkFilter).length > 1) {
dispatch(setTokenNetworkFilter(allNetworkFilters));
}
if (Object.keys(networkFilter).length > 1) {
dispatch(setTokenNetworkFilter(allNetworkFilters));
}
}, [Object.keys(allNetworks).length, networkFilter, dispatch]);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@ import { NetworkConfiguration } from '@metamask/network-controller';
import { Token } from '../types';
import { importAllDetectedTokens } from './importAllDetectedTokens';

describe('importAllDetectedTokens with PORTFOLIO_VIEW true', () => {
describe('importAllDetectedTokens', () => {
let addImportedTokensMock: jest.Mock;
let trackTokenAddedEventMock: jest.Mock;

beforeEach(() => {
process.env.PORTFOLIO_VIEW = 'true';
addImportedTokensMock = jest.fn(() => Promise.resolve());
trackTokenAddedEventMock = jest.fn();
});
Expand Down
2 changes: 1 addition & 1 deletion ui/components/app/assets/util/importAllDetectedTokens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export const importAllDetectedTokens = async (
trackTokenAddedEvent: (importedToken: Token, chainId: string) => void,
) => {
// TODO add event for MetaMetricsEventName.TokenAdded
if (process.env.PORTFOLIO_VIEW && !isOnCurrentNetwork) {
if (!isOnCurrentNetwork) {
const importPromises = Object.entries(detectedTokensMultichain).map(
async ([networkId, tokens]) => {
const chainConfig = allNetworks[networkId];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import {
MetaMetricsEventName,
MetaMetricsTokenEventSource,
} from '../../../../../shared/constants/metametrics';
import { getCurrentChainId } from '../../../../../shared/modules/selectors/networks';
import {
getAllDetectedTokensForSelectedAddress,
getCurrentNetwork,
Expand All @@ -34,8 +33,6 @@ const DetectedTokenSelectionPopover = ({
const t = useI18nContext();
const trackEvent = useContext(MetaMetricsContext);

const chainId = useSelector(getCurrentChainId);

const detectedTokens = useSelector(getDetectedTokensInCurrentNetwork);
const isTokenNetworkFilterEqualCurrentNetwork = useSelector(
getIsTokenNetworkFilterEqualCurrentNetwork,
Expand All @@ -48,13 +45,12 @@ const DetectedTokenSelectionPopover = ({
);

const totalTokens = useMemo(() => {
return process.env.PORTFOLIO_VIEW &&
!isTokenNetworkFilterEqualCurrentNetwork
? Object.values(detectedTokensMultichain).reduce(
return isTokenNetworkFilterEqualCurrentNetwork
? detectedTokens.length
: Object.values(detectedTokensMultichain).reduce(
(count, tokenArray) => count + tokenArray.length,
0,
)
: detectedTokens.length;
);
}, [
detectedTokensMultichain,
detectedTokens,
Expand All @@ -77,9 +73,7 @@ const DetectedTokenSelectionPopover = ({
properties: {
source_connection_method: MetaMetricsTokenEventSource.Detected,
tokens: eventTokensDetails,
...(process.env.PORTFOLIO_VIEW
? { chain_ids: chainIds }
: { chain_id: chainId }),
...{ chain_ids: chainIds },
},
});
};
Expand Down Expand Up @@ -119,8 +113,21 @@ const DetectedTokenSelectionPopover = ({
onClose={onClose}
footer={footer}
>
{process.env.PORTFOLIO_VIEW &&
!isTokenNetworkFilterEqualCurrentNetwork ? (
{isTokenNetworkFilterEqualCurrentNetwork ? (
<Box margin={3}>
{detectedTokens.map((token, index) => {
return (
<DetectedTokenDetails
key={index}
token={token}
handleTokenSelection={handleTokenSelection}
tokensListDetected={tokensListDetected}
chainId={currentNetwork.chainId}
/>
);
})}
</Box>
) : (
<Box margin={3}>
{Object.entries(detectedTokensMultichain).map(
([networkId, tokens]) => {
Expand All @@ -136,20 +143,6 @@ const DetectedTokenSelectionPopover = ({
},
)}
</Box>
) : (
<Box margin={3}>
{detectedTokens.map((token, index) => {
return (
<DetectedTokenDetails
key={index}
token={token}
handleTokenSelection={handleTokenSelection}
tokensListDetected={tokensListDetected}
chainId={currentNetwork.chainId}
/>
);
})}
</Box>
)}
</Popover>
);
Expand Down
Loading

0 comments on commit dae3926

Please sign in to comment.