Skip to content

Commit

Permalink
chore: Pass along hashed rpcUrl during CustomNetworkAdded event (#…
Browse files Browse the repository at this point in the history
…26203)

## **Description**

Pass along hashed `rpcUrl` when added as a custom network. We are
hashing the rpcUrl for privacy reasons, so that no custom `rpcUrls` get
leaked. For instance, this would be important for those running their
own ETH nodes.

When leveraging this new value, analytics should also hash `rpcUrls` of
common rpc's on chainlist, then compare the hashes. Note that I opted
_not_ to use the `URL` constructor, since it will enforce trailing `/`
on base urls when I am noticing that most urls on `chainlist` do not
have this: https://chainlist.org/chain/1

[![Open in GitHub
Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/MetaMask/metamask-extension/pull/26203?quickstart=1)

## **Related issues**

Fixes: MMASSETS-298 mobile PR also needs to be added.

## **Manual testing steps**

Add CustomNetwork and ensure that the proper payload is sent in the
network tab when `CustomNetworkAdded` event fires off.

## **Screenshots/Recordings**

N/A

## **Pre-merge author checklist**

- [x] I've followed [MetaMask Contributor
Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask
Extension Coding
Standards](https://github.com/MetaMask/metamask-extension/blob/develop/.github/guidelines/CODING_GUIDELINES.md).
- [x] I've completed the PR template to the best of my ability
- [x] I’ve included tests if applicable
- [x] I’ve documented my code using [JSDoc](https://jsdoc.app/) format
if applicable
- [x] I’ve applied the right labels on the PR (see [labeling
guidelines](https://github.com/MetaMask/metamask-extension/blob/develop/.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.

---------

Co-authored-by: Brian Bergeron <[email protected]>
  • Loading branch information
gambinish and bergeron authored Jul 30, 2024
1 parent d4f018a commit 5bf8aa7
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions ui/pages/settings/networks-tab/networks-form/networks-form.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ import {
import { getLocalNetworkMenuRedesignFeatureFlag } from '../../../../helpers/utils/feature-flags';
import { ACTION_MODES } from '../../../../components/multichain/network-list-menu/network-list-menu';
import InfoTooltip from '../../../../components/ui/info-tooltip';
import { sha256 } from '../../../../../shared/modules/hash.utils';

/**
* Attempts to convert the given chainId to a decimal string, for display
Expand Down Expand Up @@ -968,6 +969,9 @@ const NetworksForm = ({
MetaMetricsNetworkEventSource.CustomNetworkForm,
token_symbol: ticker,
},
sensitiveProperties: {
rpcUrl: await sha256(rpcUrl),
},
});
if (networkMenuRedesign) {
dispatch(
Expand Down

0 comments on commit 5bf8aa7

Please sign in to comment.