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

chore: Merge master into v12.0.0 #25427

Merged
merged 18 commits into from
Jun 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
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
2,630 changes: 2,630 additions & 0 deletions .yarn/patches/@metamask-gas-fee-controller-npm-15.1.2-db4d2976aa.patch

Large diffs are not rendered by default.

9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]

## [12.0.0]
## [11.16.12]

## [11.16.11]
### Fixed
- Ensure network requests for phishing lists are not sent if the Basic Functionality Toggle is off ([#25306](https://github.com/MetaMask/metamask-extension/pull/25306))

## [11.16.10]
### Fixed
- Capture Segment errors during initialization ([#25253](https://github.com/MetaMask/metamask-extension/pull/25253))
Expand Down Expand Up @@ -4812,6 +4818,9 @@ Update styles and spacing on the critical error page ([#20350](https://github.c
[Unreleased]: https://github.com/MetaMask/metamask-extension/compare/v12.0.0...HEAD
[12.0.0]: https://github.com/MetaMask/metamask-extension/compare/v11.16.7...v12.0.0
[Unreleased]: https://github.com/MetaMask/metamask-extension/compare/v11.16.10...HEAD
[Unreleased]: https://github.com/MetaMask/metamask-extension/compare/v11.16.12...HEAD
[11.16.12]: https://github.com/MetaMask/metamask-extension/compare/v11.16.11...v11.16.12
[11.16.11]: https://github.com/MetaMask/metamask-extension/compare/v11.16.10...v11.16.11
[11.16.10]: https://github.com/MetaMask/metamask-extension/compare/v11.16.9...v11.16.10
[11.16.9]: https://github.com/MetaMask/metamask-extension/compare/v11.16.8...v11.16.9
[11.16.8]: https://github.com/MetaMask/metamask-extension/compare/v11.16.7...v11.16.8
Expand Down
46 changes: 46 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.

7 changes: 7 additions & 0 deletions app/scripts/controllers/app-state.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ export default class AppStateController extends EventEmitter {
showAccountBanner: true,
trezorModel: null,
currentPopupId: undefined,
onboardingDate: null,
newPrivacyPolicyToastClickedOrClosed: null,
newPrivacyPolicyToastShownDate: null,
// This key is only used for checking if the user had set advancedGasFee
Expand Down Expand Up @@ -186,6 +187,12 @@ export default class AppStateController extends EventEmitter {
});
}

setOnboardingDate() {
this.store.updateState({
onboardingDate: Date.now(),
});
}

setNewPrivacyPolicyToastClickedOrClosed() {
this.store.updateState({
newPrivacyPolicyToastClickedOrClosed: true,
Expand Down
11 changes: 11 additions & 0 deletions app/scripts/controllers/metametrics.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ export default class MetaMetricsController {
this.store = new ObservableStore({
participateInMetaMetrics: null,
metaMetricsId: null,
dataCollectionForMarketing: null,
eventsBeforeMetricsOptIn: [],
traits: {},
previousUserTraits: {},
Expand Down Expand Up @@ -475,6 +476,12 @@ export default class MetaMetricsController {
return metaMetricsId;
}

setDataCollectionForMarketing(dataCollectionForMarketing) {
const { metaMetricsId } = this.state;
this.store.updateState({ dataCollectionForMarketing });
return metaMetricsId;
}

get state() {
return this.store.getState();
}
Expand Down Expand Up @@ -828,6 +835,10 @@ export default class MetaMetricsController {
metamaskState.securityAlertsEnabled ? ['blockaid'] : [],
[MetaMetricsUserTrait.PetnameAddressCount]:
this._getPetnameAddressCount(metamaskState),
[MetaMetricsUserTrait.IsMetricsOptedIn]:
metamaskState.participateInMetaMetrics,
[MetaMetricsUserTrait.HasMarketingConsent]:
metamaskState.dataCollectionForMarketing,
};

if (!previousUserTraits) {
Expand Down
2 changes: 2 additions & 0 deletions app/scripts/lib/setupSentry.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ export const SENTRY_BACKGROUND_STATE = {
browserEnvironment: true,
connectedStatusPopoverHasBeenShown: true,
currentPopupId: false,
onboardingDate: false,
currentExtensionPopupId: false,
defaultHomeActiveTabName: true,
fullScreenGasPollTokens: true,
Expand Down Expand Up @@ -169,6 +170,7 @@ export const SENTRY_BACKGROUND_STATE = {
previousUserTraits: false,
segmentApiCalls: false,
traits: false,
dataCollectionForMarketing: false,
},
NameController: {
names: false,
Expand Down
27 changes: 23 additions & 4 deletions app/scripts/metamask-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,11 @@ import { toChecksumHexAddress } from '../../shared/modules/hexstring-utils';
///: END:ONLY_INCLUDE_IF

import { AssetType, TokenStandard } from '../../shared/constants/transaction';
import { SWAPS_CLIENT_ID } from '../../shared/constants/swaps';
import {
GAS_API_BASE_URL,
GAS_DEV_API_BASE_URL,
SWAPS_CLIENT_ID,
} from '../../shared/constants/swaps';
import {
CHAIN_IDS,
NETWORK_TYPES,
Expand Down Expand Up @@ -781,6 +785,10 @@ export default class MetamaskController extends EventEmitter {
allowedEvents: ['NetworkController:stateChange'],
});

const gasApiBaseUrl = process.env.SWAPS_USE_DEV_APIS
? GAS_DEV_API_BASE_URL
: GAS_API_BASE_URL;

this.gasFeeController = new GasFeeController({
state: initState.GasFeeController,
interval: 10000,
Expand All @@ -800,12 +808,13 @@ export default class MetamaskController extends EventEmitter {
),
getCurrentAccountEIP1559Compatibility:
this.getCurrentAccountEIP1559Compatibility.bind(this),
legacyAPIEndpoint: `${gasApiBaseUrl}/networks/<chain_id>/gasPrices`,
EIP1559APIEndpoint: `${gasApiBaseUrl}/networks/<chain_id>/suggestedGasFees`,
getCurrentNetworkLegacyGasAPICompatibility: () => {
const { chainId } = this.networkController.state.providerConfig;
return chainId === CHAIN_IDS.BSC;
},
getChainId: () => this.networkController.state.providerConfig.chainId,
infuraAPIKey: opts.infuraProjectId,
});

this.appStateController = new AppStateController({
Expand Down Expand Up @@ -859,8 +868,6 @@ export default class MetamaskController extends EventEmitter {
stalelistRefreshInterval: process.env.IN_TEST ? 30 * SECOND : undefined,
});

this.phishingController.maybeUpdateState();

///: BEGIN:ONLY_INCLUDE_IF(blockaid)
this.ppomController = new PPOMController({
messenger: this.controllerMessenger.getRestricted({
Expand Down Expand Up @@ -2345,7 +2352,13 @@ export default class MetamaskController extends EventEmitter {
}

postOnboardingInitialization() {
const { usePhishDetect } = this.preferencesController.store.getState();

this.networkController.lookupNetwork();

if (usePhishDetect) {
this.phishingController.maybeUpdateState();
}
}

triggerNetworkrequests() {
Expand Down Expand Up @@ -3067,6 +3080,10 @@ export default class MetamaskController extends EventEmitter {
metaMetricsController.setParticipateInMetaMetrics.bind(
metaMetricsController,
),
setDataCollectionForMarketing:
metaMetricsController.setDataCollectionForMarketing.bind(
metaMetricsController,
),
setCurrentLocale: preferencesController.setCurrentLocale.bind(
preferencesController,
),
Expand Down Expand Up @@ -3273,6 +3290,8 @@ export default class MetamaskController extends EventEmitter {
appStateController.setSurveyLinkLastClickedOrClosed.bind(
appStateController,
),
setOnboardingDate:
appStateController.setOnboardingDate.bind(appStateController),
setNewPrivacyPolicyToastClickedOrClosed:
appStateController.setNewPrivacyPolicyToastClickedOrClosed.bind(
appStateController,
Expand Down
1 change: 0 additions & 1 deletion lavamoat/browserify/beta/policy.json
Original file line number Diff line number Diff line change
Expand Up @@ -1469,7 +1469,6 @@
"@metamask/eth-query": true,
"@metamask/gas-fee-controller>@metamask/controller-utils": true,
"bn.js": true,
"browserify>buffer": true,
"uuid": true
}
},
Expand Down
1 change: 0 additions & 1 deletion lavamoat/browserify/desktop/policy.json
Original file line number Diff line number Diff line change
Expand Up @@ -1614,7 +1614,6 @@
"@metamask/eth-query": true,
"@metamask/gas-fee-controller>@metamask/controller-utils": true,
"bn.js": true,
"browserify>buffer": true,
"uuid": true
}
},
Expand Down
1 change: 0 additions & 1 deletion lavamoat/browserify/flask/policy.json
Original file line number Diff line number Diff line change
Expand Up @@ -1614,7 +1614,6 @@
"@metamask/eth-query": true,
"@metamask/gas-fee-controller>@metamask/controller-utils": true,
"bn.js": true,
"browserify>buffer": true,
"uuid": true
}
},
Expand Down
1 change: 0 additions & 1 deletion lavamoat/browserify/main/policy.json
Original file line number Diff line number Diff line change
Expand Up @@ -1469,7 +1469,6 @@
"@metamask/eth-query": true,
"@metamask/gas-fee-controller>@metamask/controller-utils": true,
"bn.js": true,
"browserify>buffer": true,
"uuid": true
}
},
Expand Down
1 change: 0 additions & 1 deletion lavamoat/browserify/mmi/policy.json
Original file line number Diff line number Diff line change
Expand Up @@ -1754,7 +1754,6 @@
"@metamask/eth-query": true,
"@metamask/gas-fee-controller>@metamask/controller-utils": true,
"bn.js": true,
"browserify>buffer": true,
"uuid": true
}
},
Expand Down
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -256,11 +256,12 @@
"@expo/config-plugins/glob": "^10.3.10",
"@metamask/network-controller": "patch:@metamask/network-controller@npm%3A18.1.2#~/.yarn/patches/@metamask-network-controller-npm-18.1.2-1bcb8d8610.patch",
"@solana/web3.js/rpc-websockets": "^8.0.1",
"@metamask/nonce-tracker@npm:^5.0.0": "patch:@metamask/nonce-tracker@npm%3A5.0.0#~/.yarn/patches/@metamask-nonce-tracker-npm-5.0.0-d81478218e.patch"
"@metamask/nonce-tracker@npm:^5.0.0": "patch:@metamask/nonce-tracker@npm%3A5.0.0#~/.yarn/patches/@metamask-nonce-tracker-npm-5.0.0-d81478218e.patch",
"@metamask/gas-fee-controller@npm:^15.1.1": "patch:@metamask/gas-fee-controller@npm%3A15.1.2#~/.yarn/patches/@metamask-gas-fee-controller-npm-15.1.2-db4d2976aa.patch"
},
"dependencies": {
"@babel/runtime": "patch:@babel/runtime@npm%3A7.24.0#~/.yarn/patches/@babel-runtime-npm-7.24.0-7eb1dd11a2.patch",
"@blockaid/ppom_release": "^1.4.6",
"@blockaid/ppom_release": "^1.4.7",
"@contentful/rich-text-html-renderer": "^16.3.5",
"@ensdomains/content-hash": "^2.5.7",
"@ethereumjs/tx": "^4.1.1",
Expand Down Expand Up @@ -308,7 +309,7 @@
"@metamask/ethjs": "^0.6.0",
"@metamask/ethjs-contract": "^0.4.1",
"@metamask/ethjs-query": "^0.7.1",
"@metamask/gas-fee-controller": "^15.1.2",
"@metamask/gas-fee-controller": "patch:@metamask/gas-fee-controller@npm%3A15.1.2#~/.yarn/patches/@metamask-gas-fee-controller-npm-15.1.2-db4d2976aa.patch",
"@metamask/jazzicon": "^2.0.0",
"@metamask/keyring-api": "^6.3.1",
"@metamask/keyring-controller": "patch:@metamask/keyring-controller@npm%3A15.0.0#~/.yarn/patches/@metamask-keyring-controller-npm-15.0.0-fa070ce311.patch",
Expand Down
2 changes: 1 addition & 1 deletion privacy-snapshot.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"etherscan.io",
"execution.metamask.io",
"fonts.gstatic.com",
"gas.api.infura.io",
"gas.api.cx.metamask.io",
"github.com",
"goerli.infura.io",
"localhost:8000",
Expand Down
9 changes: 9 additions & 0 deletions shared/constants/metametrics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,14 @@ export type MetaMetricsUserTraits = {
};

export enum MetaMetricsUserTrait {
/**
* Identifies if the user has opted in for MetaMetrics
*/
IsMetricsOptedIn = 'is_metrics_opted_in',
/**
* Identifies is the user has given marketing consent
*/
HasMarketingConsent = 'has_marketing_consent',
/**
* Identified when the user adds or modifies addresses in the address book.
*/
Expand Down Expand Up @@ -505,6 +513,7 @@ export enum MetaMetricsEventName {
AccountRenamed = 'Account Renamed',
ActivityDetailsOpened = 'Activity Details Opened',
ActivityDetailsClosed = 'Activity Details Closed',
AnalyticsPreferenceSelected = 'Analytics Preference Selected',
AppInstalled = 'App Installed',
AppUnlocked = 'App Unlocked',
AppUnlockedFailed = 'App Unlocked Failed',
Expand Down
2 changes: 1 addition & 1 deletion shared/constants/swaps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ const SWAPS_TESTNET_CHAIN_ID = '0x539';
export const SWAPS_API_V2_BASE_URL = 'https://swap.api.cx.metamask.io';
export const SWAPS_DEV_API_V2_BASE_URL = 'https://swap.dev-api.cx.metamask.io';
export const TOKEN_API_BASE_URL = 'https://tokens.api.cx.metamask.io';
export const GAS_API_BASE_URL = 'https://gas.api.infura.io';
export const GAS_API_BASE_URL = 'https://gas.api.cx.metamask.io';
export const GAS_DEV_API_BASE_URL = 'https://gas.uat-api.cx.metamask.io';

const BSC_DEFAULT_BLOCK_EXPLORER_URL = 'https://bscscan.com/';
Expand Down
3 changes: 2 additions & 1 deletion shared/lib/swaps-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import log from 'loglevel';
import { CHAIN_IDS } from '../constants/network';
import {
GAS_API_BASE_URL,
GAS_DEV_API_BASE_URL,
SWAPS_API_V2_BASE_URL,
SWAPS_CHAINID_DEFAULT_TOKEN_MAP,
SWAPS_CLIENT_ID,
Expand Down Expand Up @@ -130,7 +131,7 @@ const getBaseUrlForNewSwapsApi = (type, chainId) => {
const v2ApiBaseUrl = useDevApis
? SWAPS_DEV_API_V2_BASE_URL
: SWAPS_API_V2_BASE_URL;
const gasApiBaseUrl = GAS_API_BASE_URL;
const gasApiBaseUrl = useDevApis ? GAS_DEV_API_BASE_URL : GAS_API_BASE_URL;
const tokenApiBaseUrl = TOKEN_API_BASE_URL;
const noNetworkSpecificTypes = ['refreshTime']; // These types don't need network info in the URL.
if (noNetworkSpecificTypes.includes(type)) {
Expand Down
3 changes: 3 additions & 0 deletions test/e2e/default-fixture.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,8 @@ function defaultFixture(inputChainId = CHAIN_IDS.LOCALHOST) {
'__FIXTURE_SUBSTITUTION__currentDateInMilliseconds',
showTestnetMessageInDropdown: true,
trezorModel: null,
newPrivacyPolicyToastClickedOrClosed: true,
newPrivacyPolicyToastShownDate: Date.now(),
usedNetworks: {
[CHAIN_IDS.MAINNET]: true,
[CHAIN_IDS.LINEA_MAINNET]: true,
Expand Down Expand Up @@ -140,6 +142,7 @@ function defaultFixture(inputChainId = CHAIN_IDS.LOCALHOST) {
metaMetricsId: null,
participateInMetaMetrics: false,
traits: {},
dataCollectionForMarketing: false,
},
NetworkController: {
selectedNetworkClientId: 'networkConfigurationId',
Expand Down
Loading
Loading