Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add privacy setting to disable external name sources #21045

Merged
merged 42 commits into from
Oct 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
f41e25f
Add petnames metrics
matthewwalsh0 Sep 20, 2023
d8d2bd3
Update metrics
matthewwalsh0 Sep 21, 2023
75b3827
Add user trait
matthewwalsh0 Sep 21, 2023
be83db9
Fix linting
matthewwalsh0 Sep 21, 2023
1c4d20f
Merge branch 'develop' into feat/petnames-metrics
matthewwalsh0 Sep 21, 2023
97761f7
Merge branch 'develop' into feat/petnames-metrics
matthewwalsh0 Sep 21, 2023
3b8d34b
Remove proposed name from name component
matthewwalsh0 Sep 25, 2023
cece879
Fix name clearing
matthewwalsh0 Sep 25, 2023
c834ed3
Update name controller
matthewwalsh0 Sep 26, 2023
a89cda4
Add settings toggle to disable external name providers
matthewwalsh0 Sep 26, 2023
edd5403
Update name controller
matthewwalsh0 Sep 26, 2023
233be51
Update name controller
matthewwalsh0 Sep 27, 2023
eed4d40
Update yarn lock
matthewwalsh0 Sep 27, 2023
897d278
Merge branch 'develop' into feat/petnames-metrics
matthewwalsh0 Sep 27, 2023
4db917e
Display checksum addresses
matthewwalsh0 Sep 27, 2023
f1e5778
Update name controller
matthewwalsh0 Sep 27, 2023
18566b8
Add unit tests
matthewwalsh0 Sep 27, 2023
5e701d0
Merge branch 'feat/petnames-metrics' into feat/external-name-sources-…
matthewwalsh0 Sep 27, 2023
3b332f6
Fix linting
matthewwalsh0 Sep 27, 2023
37d52f1
Merge branch 'feat/petnames-metrics' into feat/external-name-sources-…
matthewwalsh0 Sep 27, 2023
7062cc8
Fix unit tests
matthewwalsh0 Sep 27, 2023
e0e324f
Merge branch 'feat/petnames-metrics' into feat/external-name-sources-…
matthewwalsh0 Sep 27, 2023
881e17a
Update text
matthewwalsh0 Sep 28, 2023
0609838
Update name controller
matthewwalsh0 Sep 28, 2023
7f2a158
Merge branch 'feat/petnames-metrics' into feat/external-name-sources-…
matthewwalsh0 Sep 28, 2023
eeb00a2
Merge branch 'develop' into feat/petnames-metrics
matthewwalsh0 Sep 29, 2023
52e3c71
Merge branch 'feat/petnames-metrics' into feat/external-name-sources-…
matthewwalsh0 Sep 29, 2023
0504df9
Send open metric after proposed names are loaded
matthewwalsh0 Sep 29, 2023
f93fd5e
Use released name controller
matthewwalsh0 Sep 29, 2023
9ade0d0
Skip displayed metric if part of modal
matthewwalsh0 Sep 29, 2023
24cbc7d
Merge branch 'feat/petnames-metrics' into feat/external-name-sources-…
matthewwalsh0 Sep 29, 2023
8d1c873
Update policies
matthewwalsh0 Sep 29, 2023
b2e05a9
Merge branch 'feat/petnames-metrics' into feat/external-name-sources-…
matthewwalsh0 Sep 29, 2023
633a467
Fix E2E test
matthewwalsh0 Sep 29, 2023
59013c3
Merge branch 'feat/petnames-metrics' into feat/external-name-sources-…
matthewwalsh0 Sep 29, 2023
b11e751
Update snapshot
matthewwalsh0 Sep 29, 2023
5f67213
Fix unit test
matthewwalsh0 Sep 29, 2023
a585e1e
Merge branch 'feat/petnames-metrics' into feat/external-name-sources-…
matthewwalsh0 Sep 29, 2023
35cd3ac
Refactor E2E tests
matthewwalsh0 Sep 29, 2023
b596e4e
Merge branch 'develop' into feat/petnames-metrics
matthewwalsh0 Sep 29, 2023
d70efc7
Merge branch 'feat/petnames-metrics' into feat/external-name-sources-…
matthewwalsh0 Sep 30, 2023
bad1b19
Merge branch 'develop' into feat/external-name-sources-toggle
matthewwalsh0 Oct 2, 2023
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
9 changes: 9 additions & 0 deletions app/_locales/en/messages.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions app/scripts/controllers/preferences.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,9 @@ export default class PreferencesController {
snapsAddSnapAccountModalDismissed: false,
///: END:ONLY_INCLUDE_IN
isLineaMainnetReleased: false,
///: BEGIN:ONLY_INCLUDE_IN(petnames)
useExternalNameSources: true,
///: END:ONLY_INCLUDE_IN
...opts.initState,
};

Expand Down Expand Up @@ -261,6 +264,19 @@ export default class PreferencesController {
}
///: END:ONLY_INCLUDE_IN

///: BEGIN:ONLY_INCLUDE_IN(petnames)
/**
* Setter for the `useExternalNameSources` property
*
* @param {boolean} useExternalNameSources - Whether or not to use external name providers in the name controller.
*/
setUseExternalNameSources(useExternalNameSources) {
this.store.updateState({
useExternalNameSources,
});
}
///: END:ONLY_INCLUDE_IN

/**
* Setter for the `advancedGasFee` property
*
Expand Down
17 changes: 17 additions & 0 deletions app/scripts/controllers/preferences.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -419,4 +419,21 @@ describe('preferences controller', () => {
});
});
});

///: BEGIN:ONLY_INCLUDE_IN(petnames)
describe('setUseExternalNameSources', () => {
it('should default to true', () => {
expect(
preferencesController.store.getState().useExternalNameSources,
).toStrictEqual(true);
});

it('should set the useExternalNameSources property in state', () => {
preferencesController.setUseExternalNameSources(false);
expect(
preferencesController.store.getState().useExternalNameSources,
).toStrictEqual(false);
});
});
///: END:ONLY_INCLUDE_IN
});
15 changes: 12 additions & 3 deletions app/scripts/metamask-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -1537,6 +1537,9 @@ export default class MetamaskController extends EventEmitter {
);

///: BEGIN:ONLY_INCLUDE_IN(petnames)
const isExternalNameSourcesEnabled = () =>
this.preferencesController.store.getState().useExternalNameSources;

this.nameController = new NameController({
messenger: this.controllerMessenger.getRestricted({
name: 'NameController',
Expand All @@ -1548,9 +1551,9 @@ export default class MetamaskController extends EventEmitter {
this.ensController,
),
}),
new EtherscanNameProvider({}),
new TokenNameProvider({}),
new LensNameProvider(),
new EtherscanNameProvider({ isEnabled: isExternalNameSourcesEnabled }),
new TokenNameProvider({ isEnabled: isExternalNameSourcesEnabled }),
new LensNameProvider({ isEnabled: isExternalNameSourcesEnabled }),
new SnapsNameProvider({
messenger: this.controllerMessenger.getRestricted({
name: 'SnapsNameProvider',
Expand Down Expand Up @@ -2404,6 +2407,12 @@ export default class MetamaskController extends EventEmitter {
preferencesController,
),
///: END:ONLY_INCLUDE_IN
///: BEGIN:ONLY_INCLUDE_IN(petnames)
setUseExternalNameSources:
preferencesController.setUseExternalNameSources.bind(
preferencesController,
),
///: END:ONLY_INCLUDE_IN
setIpfsGateway: preferencesController.setIpfsGateway.bind(
preferencesController,
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1313,6 +1313,81 @@ exports[`Security Tab should match snapshot 1`] = `
</div>
</div>
</div>
<span
class="settings-page__security-tab-sub-header"
>
Signature requests
</span>
<div
class="settings-page__content-padded"
>
<div
class="mm-box settings-page__content-row mm-box--display-flex mm-box--gap-4 mm-box--flex-direction-row mm-box--justify-content-space-between"
>
<div
class="settings-page__content-item"
>
<span>
Suggest address names
</span>
<div
class="settings-page__content-description"
>
We pull data from third parties like Etherscan, Infura, and Lens Protocol, to suggest names for addresses on signatures requests. Turning on name suggestions exposes your IP address to these third parties.
</div>
</div>
<div
class="settings-page__content-item-col"
data-testid="useExternalNameSources"
>
<label
class="toggle-button toggle-button--off"
tabindex="0"
>
<div
style="display: flex; width: 52px; align-items: center; justify-content: flex-start; position: relative; cursor: pointer; background-color: transparent; border: 0px; padding: 0px; user-select: none;"
>
<div
style="width: 40px; height: 24px; padding: 0px; border-radius: 26px; display: flex; align-items: center; justify-content: center; background-color: rgb(242, 244, 246);"
>
<div
style="font-size: 11px; display: flex; align-items: center; justify-content: center; font-family: 'Helvetica Neue', Helvetica, sans-serif; position: relative; color: rgb(250, 250, 250); margin-top: auto; margin-bottom: auto; line-height: 0; opacity: 0; width: 26px; height: 20px; left: 4px;"
/>
<div
style="font-size: 11px; display: flex; align-items: center; justify-content: center; font-family: 'Helvetica Neue', Helvetica, sans-serif; position: relative; color: rgba(255, 255, 255, 0.6); bottom: 0px; margin-top: auto; margin-bottom: auto; padding-right: 5px; line-height: 0; width: 26px; height: 20px; opacity: 1;"
/>
</div>
<div
style="position: absolute; height: 100%; top: 0px; left: 0px; display: flex; flex: 1; align-self: stretch; align-items: center; justify-content: flex-start;"
>
<div
style="width: 18px; height: 18px; display: flex; align-self: center; box-shadow: none; border-radius: 50%; box-sizing: border-box; position: relative; background-color: rgb(106, 115, 125); left: 3px;"
/>
</div>
<input
style="border: 0px; height: 1px; margin: -1px; overflow: hidden; padding: 0px; position: absolute; width: 1px;"
type="checkbox"
value="false"
/>
</div>
<div
class="toggle-button__status"
>
<span
class="toggle-button__label-off"
>
Off
</span>
<span
class="toggle-button__label-on"
>
On
</span>
</div>
</label>
</div>
</div>
</div>
<span
class="settings-page__security-tab-sub-header"
>
Expand Down
56 changes: 56 additions & 0 deletions ui/pages/settings/security-tab/security-tab.component.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,10 @@ export default class SecurityTab extends PureComponent {
setUseCurrencyRateCheck: PropTypes.func.isRequired,
useAddressBarEnsResolution: PropTypes.bool.isRequired,
setUseAddressBarEnsResolution: PropTypes.func.isRequired,
///: BEGIN:ONLY_INCLUDE_IN(petnames)
useExternalNameSources: PropTypes.bool.isRequired,
setUseExternalNameSources: PropTypes.func.isRequired,
///: END:ONLY_INCLUDE_IN
};

state = {
Expand Down Expand Up @@ -813,6 +817,43 @@ export default class SecurityTab extends PureComponent {
);
}

///: BEGIN:ONLY_INCLUDE_IN(petnames)
renderExternalNameSourcesToggle() {
const { t } = this.context;
const { useExternalNameSources, setUseExternalNameSources } = this.props;

return (
<Box
ref={this.settingsRefs[13]}
className="settings-page__content-row"
display={Display.Flex}
flexDirection={FlexDirection.Row}
justifyContent={JustifyContent.spaceBetween}
gap={4}
>
<div className="settings-page__content-item">
<span>{t('externalNameSourcesSetting')}</span>
<div className="settings-page__content-description">
{t('externalNameSourcesSettingDescription')}
</div>
</div>

<div
className="settings-page__content-item-col"
data-testid="useExternalNameSources"
>
<ToggleButton
value={useExternalNameSources}
onToggle={(value) => setUseExternalNameSources(!value)}
offLabel={t('off')}
onLabel={t('on')}
/>
</div>
</Box>
);
}
///: END:ONLY_INCLUDE_IN

render() {
const { warning } = this.props;

Expand All @@ -835,6 +876,7 @@ export default class SecurityTab extends PureComponent {
<div className="settings-page__content-padded">
{this.renderPhishingDetectionToggle()}
</div>

<div>
<span className="settings-page__security-tab-sub-header">
{this.context.t('smartContracts')}
Expand All @@ -843,6 +885,7 @@ export default class SecurityTab extends PureComponent {
<div className="settings-page__content-padded">
{this.renderUse4ByteResolutionToggle()}
</div>

<span className="settings-page__security-tab-sub-header">
{this.context.t('transactions')}
</span>
Expand Down Expand Up @@ -870,6 +913,19 @@ export default class SecurityTab extends PureComponent {
{this.renderNftDetectionToggle()}
</div>

{
///: BEGIN:ONLY_INCLUDE_IN(petnames)
}
<span className="settings-page__security-tab-sub-header">
{this.context.t('settingsSubHeadingSignatures')}
</span>
<div className="settings-page__content-padded">
{this.renderExternalNameSourcesToggle()}
</div>
{
///: END:ONLY_INCLUDE_IN
}

<span className="settings-page__security-tab-sub-header">
{this.context.t('metrics')}
</span>
Expand Down
14 changes: 14 additions & 0 deletions ui/pages/settings/security-tab/security-tab.container.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ import {
setUseNftDetection,
setUse4ByteResolution,
setUseSafeChainsListValidation,
///: BEGIN:ONLY_INCLUDE_IN(petnames)
setUseExternalNameSources,
///: END:ONLY_INCLUDE_IN
} from '../../../store/actions';
import { getAllNetworks } from '../../../selectors';
import SecurityTab from './security-tab.component';
Expand All @@ -37,6 +40,9 @@ const mapStateToProps = (state) => {
openSeaEnabled,
useNftDetection,
use4ByteResolution,
///: BEGIN:ONLY_INCLUDE_IN(petnames)
useExternalNameSources,
///: END:ONLY_INCLUDE_IN
} = metamask;

const allNetworks = getAllNetworks(state);
Expand All @@ -56,6 +62,9 @@ const mapStateToProps = (state) => {
openSeaEnabled,
useNftDetection,
use4ByteResolution,
///: BEGIN:ONLY_INCLUDE_IN(petnames)
useExternalNameSources,
///: END:ONLY_INCLUDE_IN
};
};

Expand All @@ -80,6 +89,11 @@ const mapDispatchToProps = (dispatch) => {
setUse4ByteResolution: (value) => {
return dispatch(setUse4ByteResolution(value));
},
///: BEGIN:ONLY_INCLUDE_IN(petnames)
setUseExternalNameSources: (value) => {
return dispatch(setUseExternalNameSources(value));
},
///: END:ONLY_INCLUDE_IN
};
};

Expand Down
10 changes: 10 additions & 0 deletions ui/store/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4449,6 +4449,16 @@ export async function setAddSnapAccountEnabled(value: boolean): Promise<void> {
}
///: END:ONLY_INCLUDE_IN

///: BEGIN:ONLY_INCLUDE_IN(petnames)
export function setUseExternalNameSources(val: boolean): void {
try {
submitRequestToBackground('setUseExternalNameSources', [val]);
} catch (error) {
logErrorWithMessage(error);
}
}
///: END:ONLY_INCLUDE_IN

export function setFirstTimeUsedNetwork(chainId: string) {
return submitRequestToBackground('setFirstTimeUsedNetwork', [chainId]);
}
Expand Down
20 changes: 10 additions & 10 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3029,12 +3029,12 @@ __metadata:
linkType: hard

"@jest/expect@npm:^29.1.2":
version: 29.1.2
resolution: "@jest/expect@npm:29.1.2"
version: 29.6.2
resolution: "@jest/expect@npm:29.6.2"
dependencies:
expect: "npm:^29.1.2"
jest-snapshot: "npm:^29.1.2"
checksum: 7bb80bf176f39becdbd2ef54be615c3e7010f3230ccc419f22c97fa5b66e0fa14bb6b05019840d01cd1892e42be8158bea4c94487f05da1dd2b85a4ac097dd15
expect: "npm:^29.6.2"
jest-snapshot: "npm:^29.6.2"
checksum: 2beed96e3d24945a72aa2ae4843c99f4c631564569258fdde6746fae3efcbfbff96dbf92ed28d6531299bd12b2766075bacaaae88ebf84b99316e77151b43a9f
languageName: node
linkType: hard

Expand Down Expand Up @@ -16386,7 +16386,7 @@ __metadata:
languageName: node
linkType: hard

"expect@npm:^29.0.0, expect@npm:^29.1.2, expect@npm:^29.6.2":
"expect@npm:^29.0.0, expect@npm:^29.6.2":
version: 29.6.2
resolution: "expect@npm:29.6.2"
dependencies:
Expand Down Expand Up @@ -16678,13 +16678,13 @@ __metadata:
linkType: hard

"fast-xml-parser@npm:^4.1.3":
version: 4.2.5
resolution: "fast-xml-parser@npm:4.2.5"
version: 4.2.4
resolution: "fast-xml-parser@npm:4.2.4"
dependencies:
strnum: "npm:^1.0.5"
bin:
fxparser: src/cli/cli.js
checksum: 4be7ebe24d6a9a60c278e1423cd86a7da9a77ec64c95563e2c552363caf7a777e0c87c9de1255c2f4e8dea9bce8905dc2bdc58a34e9f2b73c4693654456ad284
checksum: 157f64a142d37f2c937d5308d62668119e40218dab41a07d1a9563c3f92663c81fd08db0efc9fe484e0bc4dfea59827f319adc510426ff9b97c83a779d511b6f
languageName: node
linkType: hard

Expand Down Expand Up @@ -21456,7 +21456,7 @@ __metadata:
languageName: node
linkType: hard

"jest-snapshot@npm:^29.1.2":
"jest-snapshot@npm:^29.1.2, jest-snapshot@npm:^29.6.2":
version: 29.6.2
resolution: "jest-snapshot@npm:29.6.2"
dependencies:
Expand Down
Loading