Skip to content

Commit ebb48c4

Browse files
authored
fix: network name in token details (#25106)
<!-- Please submit this PR as a draft initially. Do not mark it as "Ready for review" until the template has been completely filled out, and PR status checks have passed at least once. --> ## **Description** <!-- Write a short description of the changes included in this pull request, also include relevant motivation and context. Have in mind the following questions: 1. What is the reason for the change? 2. What is the improvement/solution? --> Changed code to use exclusively the chain name of the token that is being viewed. ## **Changelog** <!-- If this PR is not End-User-Facing and should not show up in the CHANGELOG, you can choose to either: 1. Write `CHANGELOG entry: null` 2. Label with `no-changelog` If this PR is End-User-Facing, please write a short User-Facing description in the past tense like: `CHANGELOG entry: Added a new tab for users to see their NFTs` `CHANGELOG entry: Fixed a bug that was causing some NFTs to flicker` (This helps the Release Engineer do their job more quickly and accurately) --> CHANGELOG entry: Fixed a bug in the network name for the token detail page ## **Related issues** Fixes: #25100 ## **Manual testing steps** ```gherkin Feature: my feature name Scenario: user [verb for user action] Given [describe expected initial app state] When user [verb for user action] Then [describe expected outcome] ``` ## **Screenshots/Recordings** <!-- If applicable, add screenshots and/or recordings to visualize the before and after of your change. --> ### **Before** <!-- [screenshots/recordings] --> https://github.com/user-attachments/assets/f572de39-939e-4241-9859-fda885f4273e ### **After** <!-- [screenshots/recordings] --> https://github.com/user-attachments/assets/f007756e-d19e-4b8e-8916-60df581a8b97 ## **Pre-merge author checklist** - [ ] I’ve followed [MetaMask Contributor Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Mobile Coding Standards](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/CODING_GUIDELINES.md). - [ ] I've completed the PR template to the best of my ability - [ ] I’ve included tests if applicable - [ ] I’ve documented my code using [JSDoc](https://jsdoc.app/) format if applicable - [ ] I’ve applied the right labels on the PR (see [labeling guidelines](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/LABELING_GUIDELINES.md)). Not required for external contributors. ## **Pre-merge reviewer checklist** - [ ] I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed). - [ ] I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots. <!-- CURSOR_SUMMARY --> --- > [!NOTE] > Fixes network name display in Asset Details by sourcing it directly from the network configuration for the current `chainId`. > > - Replace provider/all-networks-based resolution with `selectNetworkConfigurationByChainId` and `networkConfigurationByChainId?.name` > - Remove unused imports/selectors and `getNetworkName` callback; simplify state selection > - Use `networkName` in the inline header and in the "Network" section rendering > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit c8923de. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY -->
1 parent e3951e9 commit ebb48c4

1 file changed

Lines changed: 3 additions & 30 deletions

File tree

app/components/Views/AssetDetails/index.tsx

Lines changed: 3 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ import { IconName as ComponentLibraryIconName } from '../../../component-library
3030
import EthereumAddress from '../../UI/EthereumAddress';
3131
import Icon from 'react-native-vector-icons/Feather';
3232
import TokenImage from '../../UI/TokenImage';
33-
import Networks, { getDecimalChainId } from '../../../util/networks';
33+
import { getDecimalChainId } from '../../../util/networks';
3434
import Engine from '../../../core/Engine';
3535
import Logger from '../../../util/Logger';
3636
import NotificationManager from '../../../core/NotificationManager';
@@ -44,12 +44,7 @@ import WarningMessage from '../confirmations/legacy/components/WarningMessage';
4444
import { useTheme } from '../../../util/theme';
4545
import { MetaMetricsEvents } from '../../../core/Analytics';
4646
import Routes from '../../../constants/navigation/Routes';
47-
import {
48-
selectProviderConfig,
49-
selectNetworkConfigurationByChainId,
50-
selectIsAllNetworks,
51-
selectEvmNetworkConfigurationsByChainId,
52-
} from '../../../selectors/networkController';
47+
import { selectNetworkConfigurationByChainId } from '../../../selectors/networkController';
5348
import {
5449
selectCurrentCurrency,
5550
selectConversionRateBySymbol,
@@ -165,7 +160,6 @@ const AssetDetails = (props: InnerProps) => {
165160
const styles = createStyles(colors);
166161
const navigation = useNavigation<NavigationProp<PerpsNavigationParamList>>();
167162
const { toastRef } = useContext(ToastContext);
168-
const providerConfig = useSelector(selectProviderConfig);
169163
const selectedAccountAddressEvm = useSelector(selectLastSelectedEvmAccount);
170164

171165
// Perps Discovery Banner
@@ -174,16 +168,10 @@ const AssetDetails = (props: InnerProps) => {
174168
const selectedAccountAddress = selectedAccountAddressEvm?.address;
175169
const chainId = networkId;
176170

177-
const networkConfigurations = useSelector(
178-
selectEvmNetworkConfigurationsByChainId,
179-
);
180-
const isAllNetworks = useSelector(selectIsAllNetworks);
181-
182-
const tokenNetworkConfig = networkConfigurations[networkId]?.name;
183-
184171
const networkConfigurationByChainId = useSelector((state: RootState) =>
185172
selectNetworkConfigurationByChainId(state, chainId),
186173
);
174+
const networkName = networkConfigurationByChainId?.name;
187175
const conversionRateBySymbol = useSelector((state: RootState) =>
188176
selectConversionRateBySymbol(
189177
state,
@@ -221,22 +209,7 @@ const AssetDetails = (props: InnerProps) => {
221209
}
222210
}, [marketData, navigation]);
223211

224-
const getNetworkName = useCallback(() => {
225-
let name = '';
226-
if (isAllNetworks) {
227-
name = tokenNetworkConfig;
228-
} else if (providerConfig.nickname) {
229-
name = providerConfig.nickname;
230-
} else {
231-
name =
232-
(Networks as Record<string, { name: string }>)[providerConfig.type]
233-
?.name || { ...Networks.rpc, color: null }.name;
234-
}
235-
return name;
236-
}, [isAllNetworks, tokenNetworkConfig, providerConfig]);
237-
238212
const insets = useSafeAreaInsets();
239-
const networkName = getNetworkName();
240213

241214
const copyAddressToClipboard = async () => {
242215
await ClipboardManager.setString(address);

0 commit comments

Comments
 (0)