Skip to content

Commit f4cd43d

Browse files
committed
refactor: Remove unnecessary undefined check in RPC tracking
selectedRpcEndpoint cannot be undefined here because: - Save button is disabled without rpcEndpoints - trackRpcUpdateFromBanner only set for existing networks - Existing networks always have valid RPC endpoints
1 parent d5c8601 commit f4cd43d

File tree

2 files changed

+8
-14
lines changed

2 files changed

+8
-14
lines changed

ui/pages/settings/networks-tab/networks-form/networks-form.test.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -88,11 +88,7 @@ describe('NetworkForm Component', () => {
8888
});
8989

9090
beforeEach(() => {
91-
// Clear mock call history to ensure test isolation and accurate assertions
92-
// Each test verifies these actions are called with specific arguments
93-
updateNetwork.mockClear(); // Reset calls from network update tests
94-
addNetwork.mockClear(); // Reset calls from network creation tests
95-
setTokenNetworkFilter.mockClear(); // Reset calls from token filter tests
91+
jest.clearAllMocks();
9692

9793
nock('https://chainid.network:443', { encodedQueryParams: true })
9894
.get('/chains.json')

ui/pages/settings/networks-tab/networks-form/networks-form.tsx

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -316,18 +316,16 @@ export const NetworksForm = ({
316316
// Track RPC update from network connection banner
317317
if (trackRpcUpdateFromBanner) {
318318
const selectedRpcEndpoint =
319-
networkPayload.rpcEndpoints?.[
319+
networkPayload.rpcEndpoints[
320320
networkPayload.defaultRpcEndpointIndex
321321
];
322322
const chainIdAsDecimal = hexToNumber(chainIdHex);
323-
const sanitizedRpcUrl =
324-
selectedRpcEndpoint &&
325-
isPublicEndpointUrl(
326-
selectedRpcEndpoint.url,
327-
infuraProjectId ?? '',
328-
)
329-
? onlyKeepHost(selectedRpcEndpoint.url)
330-
: 'custom';
323+
const sanitizedRpcUrl = isPublicEndpointUrl(
324+
selectedRpcEndpoint.url,
325+
infuraProjectId ?? '',
326+
)
327+
? onlyKeepHost(selectedRpcEndpoint.url)
328+
: 'custom';
331329

332330
trackEvent({
333331
category: MetaMetricsEventCategory.Network,

0 commit comments

Comments
 (0)