Skip to content

Commit

Permalink
Merge branch 'develop' into jl/mmp-1033/preferences-controller-networ…
Browse files Browse the repository at this point in the history
…k-meta
  • Loading branch information
jiexi committed Sep 21, 2023
2 parents 2d13a1d + 31262a0 commit 5158d01
Show file tree
Hide file tree
Showing 37 changed files with 1,027 additions and 573 deletions.
2 changes: 1 addition & 1 deletion app/scripts/controllers/mmi-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ export default class MMIController extends EventEmitter {

// FIXME: status maps are not a thing anymore
this.custodyController.storeCustodyStatusMap(
custodian.name,
custodian.envName,
keyring.getStatusMap(),
);

Expand Down
31 changes: 24 additions & 7 deletions app/scripts/lib/ens-ipfs/setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,18 +58,21 @@ export default function setupEnsIpfsResolver({
const ipfsGateway = getIpfsGateway();
const useAddressBarEnsResolution = getUseAddressBarEnsResolution();

if (!useAddressBarEnsResolution || ipfsGateway === '') {
return;
}
const ensSiteUrl = `https://app.ens.domains/name/${name}`;

browser.tabs.update(tabId, { url: `loading.html` });
// We cannot show this if useAddressBarEnsResolution is off...
if (useAddressBarEnsResolution && ipfsGateway) {
browser.tabs.update(tabId, { url: 'loading.html' });
}

let url = `https://app.ens.domains/name/${name}`;
let url = ensSiteUrl;

// If we're testing ENS domain resolution support,
// we assume the ENS domains URL
if (process.env.IN_TEST) {
browser.tabs.update(tabId, { url });
if (useAddressBarEnsResolution || ipfsGateway) {
browser.tabs.update(tabId, { url });
}
return;
}

Expand All @@ -79,6 +82,12 @@ export default function setupEnsIpfsResolver({
name,
});
if (type === 'ipfs-ns' || type === 'ipns-ns') {
// If the ENS is via IPFS and that setting is disabled,
// Do not resolve the ENS
if (ipfsGateway === '') {
url = null;
return;
}
const resolvedUrl = `https://${hash}.${type.slice(
0,
4,
Expand Down Expand Up @@ -121,7 +130,15 @@ export default function setupEnsIpfsResolver({
} catch (err) {
console.warn(err);
} finally {
browser.tabs.update(tabId, { url });
// Only forward to destination URL if a URL exists and
// useAddressBarEnsResolution is properly
if (
url &&
(useAddressBarEnsResolution ||
(!useAddressBarEnsResolution && url !== ensSiteUrl))
) {
browser.tabs.update(tabId, { url });
}
}
}
}
3 changes: 3 additions & 0 deletions app/scripts/lib/setupSentry.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,9 @@ export const SENTRY_BACKGROUND_STATE = {
keyrings: false,
keyringTypes: false,
},
LoggingController: {
logs: false,
},
MetaMetricsController: {
eventsBeforeMetricsOptIn: false,
fragments: false,
Expand Down
35 changes: 23 additions & 12 deletions app/scripts/metamask-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,12 @@ import {
SelectedNetworkController,
createSelectedNetworkMiddleware,
} from '@metamask/selected-network-controller';
import { LoggingController } from '@metamask/logging-controller';

///: BEGIN:ONLY_INCLUDE_IN(snaps)
import { encrypt, decrypt } from '@metamask/browser-passworder';
import { RateLimitController } from '@metamask/rate-limit-controller';
import { NotificationController } from '@metamask/notification-controller';

import {
CronjobController,
JsonSnapsRegistry,
Expand Down Expand Up @@ -347,6 +347,13 @@ export default class MetamaskController extends EventEmitter {
],
});

this.loggingController = new LoggingController({
messenger: this.controllerMessenger.getRestricted({
name: 'LoggingController',
}),
state: initState.LoggingController,
});

///: BEGIN:ONLY_INCLUDE_IN(build-mmi)
this.mmiConfigurationController = new MmiConfigurationController({
initState: initState.MmiConfigurationController,
Expand All @@ -369,23 +376,22 @@ export default class MetamaskController extends EventEmitter {
if (initState.NetworkController) {
initialNetworkControllerState = initState.NetworkController;
} else if (process.env.IN_TEST) {
const networkConfig = {
chainId: CHAIN_IDS.LOCALHOST,
nickname: 'Localhost 8545',
rpcPrefs: {},
rpcUrl: 'http://localhost:8545',
ticker: 'ETH',
id: 'networkConfigurationId',
};
initialNetworkControllerState = {
providerConfig: {
chainId: CHAIN_IDS.LOCALHOST,
nickname: 'Localhost 8545',
rpcPrefs: {},
rpcUrl: 'http://localhost:8545',
ticker: 'ETH',
...networkConfig,
type: 'rpc',
},
networkConfigurations: {
networkConfigurationId: {
chainId: CHAIN_IDS.LOCALHOST,
nickname: 'Localhost 8545',
rpcPrefs: {},
rpcUrl: 'http://localhost:8545',
ticker: 'ETH',
networkConfigurationId: 'networkConfigurationId',
...networkConfig,
},
},
};
Expand Down Expand Up @@ -1103,6 +1109,8 @@ export default class MetamaskController extends EventEmitter {
'SnapController:snapInstalled',
'SnapController:snapUpdated',
'SnapController:snapRemoved',
'SnapController:snapEnabled',
'SnapController:snapDisabled',
],
allowedActions: [
`${this.permissionController.name}:getPermissions`,
Expand Down Expand Up @@ -1720,6 +1728,7 @@ export default class MetamaskController extends EventEmitter {
NftController: this.nftController,
PhishingController: this.phishingController,
SelectedNetworkController: this.selectedNetworkController,
LoggingController: this.loggingController,
///: BEGIN:ONLY_INCLUDE_IN(snaps)
SnapController: this.snapController,
CronjobController: this.cronjobController,
Expand Down Expand Up @@ -1768,6 +1777,7 @@ export default class MetamaskController extends EventEmitter {
SmartTransactionsController: this.smartTransactionsController,
NftController: this.nftController,
SelectedNetworkController: this.selectedNetworkController,
LoggingController: this.loggingController,
///: BEGIN:ONLY_INCLUDE_IN(snaps)
SnapController: this.snapController,
CronjobController: this.cronjobController,
Expand Down Expand Up @@ -2716,6 +2726,7 @@ export default class MetamaskController extends EventEmitter {
),
dismissNotifications: this.dismissNotifications.bind(this),
markNotificationsAsRead: this.markNotificationsAsRead.bind(this),
updateCaveat: this.updateCaveat.bind(this),
///: END:ONLY_INCLUDE_IN
///: BEGIN:ONLY_INCLUDE_IN(keyring-snaps)
updateSnapRegistry: this.preferencesController.updateSnapRegistry.bind(
Expand Down
4 changes: 2 additions & 2 deletions builds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ buildTypes:
- SEGMENT_FLASK_WRITE_KEY
- ALLOW_LOCAL_SNAPS: true
- REQUIRE_SNAPS_ALLOWLIST: false
- IFRAME_EXECUTION_ENVIRONMENT_URL: https://execution.consensys.io/0.38.3-flask.1/index.html
- IFRAME_EXECUTION_ENVIRONMENT_URL: https://execution.consensys.io/0.39.0-flask.1/index.html
- SUPPORT_LINK: https://metamask-flask.zendesk.com/hc
- SUPPORT_REQUEST_LINK: https://metamask-flask.zendesk.com/hc/en-us/requests/new
- INFURA_ENV_KEY_REF: INFURA_FLASK_PROJECT_ID
Expand All @@ -77,7 +77,7 @@ buildTypes:
- SEGMENT_FLASK_WRITE_KEY
- ALLOW_LOCAL_SNAPS: true
- REQUIRE_SNAPS_ALLOWLIST: false
- IFRAME_EXECUTION_ENVIRONMENT_URL: https://execution.consensys.io/0.38.3-flask.1/index.html
- IFRAME_EXECUTION_ENVIRONMENT_URL: https://execution.consensys.io/0.39.0-flask.1/index.html
- SUPPORT_LINK: https://metamask-flask.zendesk.com/hc
- SUPPORT_REQUEST_LINK: https://metamask-flask.zendesk.com/hc/en-us/requests/new
- INFURA_ENV_KEY_REF: INFURA_FLASK_PROJECT_ID
Expand Down
36 changes: 28 additions & 8 deletions lavamoat/browserify/beta/policy.json
Original file line number Diff line number Diff line change
Expand Up @@ -922,25 +922,39 @@
"setTimeout": true
},
"packages": {
"@metamask/eth-json-rpc-middleware>@metamask/utils": true,
"@metamask/eth-json-rpc-middleware>@metamask/eth-sig-util": true,
"@metamask/eth-json-rpc-middleware>clone": true,
"@metamask/eth-json-rpc-middleware>pify": true,
"@metamask/eth-json-rpc-middleware>safe-stable-stringify": true,
"@metamask/eth-snap-keyring>@metamask/eth-sig-util": true,
"@metamask/utils": true,
"eth-rpc-errors": true,
"json-rpc-engine": true
}
},
"@metamask/eth-json-rpc-middleware>@metamask/utils": {
"@metamask/eth-json-rpc-middleware>@metamask/eth-sig-util": {
"packages": {
"@ethereumjs/tx>@ethereumjs/util": true,
"@metamask/eth-json-rpc-middleware>@metamask/eth-sig-util>ethereum-cryptography": true,
"bn.js": true,
"browserify>buffer": true,
"eth-sig-util>ethereumjs-util>ethjs-util": true,
"eth-sig-util>tweetnacl": true,
"eth-sig-util>tweetnacl-util": true
}
},
"@metamask/eth-json-rpc-middleware>@metamask/eth-sig-util>ethereum-cryptography": {
"globals": {
"TextDecoder": true,
"TextEncoder": true
"crypto": true
},
"packages": {
"browserify>buffer": true,
"nock>debug": true,
"semver": true,
"superstruct": true
"@metamask/eth-json-rpc-middleware>@metamask/eth-sig-util>ethereum-cryptography>@noble/hashes": true
}
},
"@metamask/eth-json-rpc-middleware>@metamask/eth-sig-util>ethereum-cryptography>@noble/hashes": {
"globals": {
"TextEncoder": true,
"crypto": true
}
},
"@metamask/eth-json-rpc-middleware>clone": {
Expand Down Expand Up @@ -1614,6 +1628,12 @@
"ethereumjs-util>rlp": true
}
},
"@metamask/logging-controller": {
"packages": {
"@metamask/base-controller": true,
"uuid": true
}
},
"@metamask/logo": {
"globals": {
"addEventListener": true,
Expand Down
Loading

0 comments on commit 5158d01

Please sign in to comment.