Skip to content

Commit

Permalink
Merge branch 'develop' into stabilize-test-chloe
Browse files Browse the repository at this point in the history
  • Loading branch information
chloeYue authored Oct 3, 2023
2 parents c2b1ab9 + 0482ab6 commit cdb5a82
Show file tree
Hide file tree
Showing 13 changed files with 282 additions and 192 deletions.
12 changes: 12 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.

43 changes: 2 additions & 41 deletions app/scripts/controllers/mmi-controller.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import EventEmitter from 'events';
import log from 'loglevel';
import { captureException } from '@sentry/browser';
import { isEqual } from 'lodash';
import { CUSTODIAN_TYPES } from '@metamask-institutional/custody-keyring';
import {
updateCustodianTransactions,
Expand All @@ -11,17 +10,10 @@ import {
REFRESH_TOKEN_CHANGE_EVENT,
INTERACTIVE_REPLACEMENT_TOKEN_CHANGE_EVENT,
} from '@metamask-institutional/sdk';
import {
handleMmiPortfolio,
setDashboardCookie,
} from '@metamask-institutional/portfolio-dashboard';
import { handleMmiPortfolio } from '@metamask-institutional/portfolio-dashboard';
import { toChecksumHexAddress } from '../../../shared/modules/hexstring-utils';
import { CHAIN_IDS } from '../../../shared/constants/network';
import {
BUILD_QUOTE_ROUTE,
CONNECT_HARDWARE_ROUTE,
} from '../../../ui/helpers/constants/routes';
import { previousValueComparator } from '../lib/util';
import { CONNECT_HARDWARE_ROUTE } from '../../../ui/helpers/constants/routes';
import { getPermissionBackgroundApiMethods } from './permissions';

export default class MMIController extends EventEmitter {
Expand Down Expand Up @@ -63,17 +55,6 @@ export default class MMIController extends EventEmitter {
});
}

this.preferencesController.store.subscribe(
previousValueComparator(async (prevState, currState) => {
const { identities: prevIdentities } = prevState;
const { identities: currIdentities } = currState;
if (isEqual(prevIdentities, currIdentities)) {
return;
}
await this.prepareMmiPortfolio();
}, this.preferencesController.store.getState()),
);

this.signatureController.hub.on(
'personal_sign:signed',
async ({ signature, messageId }) => {
Expand Down Expand Up @@ -584,20 +565,6 @@ export default class MMIController extends EventEmitter {
});
}

async prepareMmiPortfolio() {
if (!process.env.IN_TEST) {
try {
const mmiDashboardData = await this.handleMmiDashboardData();
const cookieSetUrls =
this.mmiConfigurationController.store.mmiConfiguration?.portfolio
?.cookieSetUrls || [];
setDashboardCookie(mmiDashboardData, cookieSetUrls);
} catch (error) {
console.error(error);
}
}
}

async newUnsignedMessage(msgParams, req, version) {
// The code path triggered by deferSetAsSigned: true is for custodial accounts
const accountDetails = this.custodyController.getAccountDetails(
Expand Down Expand Up @@ -673,12 +640,6 @@ export default class MMIController extends EventEmitter {
return true;
}

async handleMmiOpenSwaps(origin, address, chainId) {
await this.setAccountAndNetwork(origin, address, chainId);
this.platform.openExtensionInBrowser(BUILD_QUOTE_ROUTE);
return true;
}

async handleMmiOpenAddHardwareWallet() {
await this.appStateController.getUnlockPromise(true);
this.platform.openExtensionInBrowser(CONNECT_HARDWARE_ROUTE);
Expand Down
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
});
2 changes: 0 additions & 2 deletions app/scripts/lib/rpc-method-middleware/handlers/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import watchAsset from './watch-asset';
import mmiSupported from './institutional/mmi-supported';
import mmiAuthenticate from './institutional/mmi-authenticate';
import mmiPortfolio from './institutional/mmi-portfolio';
import mmiOpenSwaps from './institutional/mmi-open-swaps';
import mmiCheckIfTokenIsPresent from './institutional/mmi-check-if-token-is-present';
import mmiSetAccountAndNetwork from './institutional/mmi-set-account-and-network';
import mmiOpenAddHardwareWallet from './institutional/mmi-open-add-hardware-wallet';
Expand All @@ -30,7 +29,6 @@ const handlers = [
mmiAuthenticate,
mmiSupported,
mmiPortfolio,
mmiOpenSwaps,
mmiCheckIfTokenIsPresent,
mmiSetAccountAndNetwork,
mmiOpenAddHardwareWallet,
Expand Down

This file was deleted.

18 changes: 12 additions & 6 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 Expand Up @@ -4347,9 +4356,6 @@ export default class MetamaskController extends EventEmitter {
handleMmiDashboardData: this.mmiController.handleMmiDashboardData.bind(
this.mmiController,
),
handleMmiOpenSwaps: this.mmiController.handleMmiOpenSwaps.bind(
this.mmiController,
),
handleMmiSetAccountAndNetwork:
this.mmiController.setAccountAndNetwork.bind(this.mmiController),
handleMmiOpenAddHardwareWallet:
Expand Down
12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -226,14 +226,14 @@
"@keystonehq/metamask-airgapped-keyring": "^0.13.1",
"@lavamoat/snow": "^1.5.0",
"@material-ui/core": "^4.11.0",
"@metamask-institutional/custody-controller": "^0.2.12",
"@metamask-institutional/custody-keyring": "^1.0.2",
"@metamask-institutional/extension": "^0.3.5",
"@metamask-institutional/institutional-features": "^1.2.4",
"@metamask-institutional/custody-controller": "^0.2.14",
"@metamask-institutional/custody-keyring": "^1.0.3",
"@metamask-institutional/extension": "^0.3.7",
"@metamask-institutional/institutional-features": "^1.2.6",
"@metamask-institutional/portfolio-dashboard": "^1.4.0",
"@metamask-institutional/rpc-allowlist": "^1.0.0",
"@metamask-institutional/sdk": "^0.1.18",
"@metamask-institutional/transaction-update": "^0.1.27",
"@metamask-institutional/sdk": "^0.1.19",
"@metamask-institutional/transaction-update": "^0.1.29",
"@metamask/address-book-controller": "^3.0.0",
"@metamask/announcement-controller": "^4.0.0",
"@metamask/approval-controller": "^3.4.0",
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
Loading

0 comments on commit cdb5a82

Please sign in to comment.