Skip to content

Commit ccf1740

Browse files
authored
Merge pull request #24852 from MetaMask/Version-v11.16.2
v11.16.2
2 parents b478b62 + e607797 commit ccf1740

File tree

18 files changed

+204
-91
lines changed

18 files changed

+204
-91
lines changed

CHANGELOG.md

+8-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
66

77
## [Unreleased]
88

9+
## [11.16.2]
10+
### Fixed
11+
- Fix gas fee displays on the Scroll network ([#24854](https://github.com/MetaMask/metamask-extension/pull/24854))
12+
913
## [11.16.1]
14+
### Changed
15+
- Update Smart Transactions opt-in moda ([#24771](https://github.com/MetaMask/metamask-extension/pull/24771))
1016

1117
## [11.16.0]
1218
### Added
@@ -4750,7 +4756,8 @@ Update styles and spacing on the critical error page ([#20350](https://github.c
47504756
- Added the ability to restore accounts from seed words.
47514757

47524758

4753-
[Unreleased]: https://github.com/MetaMask/metamask-extension/compare/v11.16.1...HEAD
4759+
[Unreleased]: https://github.com/MetaMask/metamask-extension/compare/v11.16.2...HEAD
4760+
[11.16.2]: https://github.com/MetaMask/metamask-extension/compare/v11.16.1...v11.16.2
47544761
[11.16.1]: https://github.com/MetaMask/metamask-extension/compare/v11.16.0...v11.16.1
47554762
[11.16.0]: https://github.com/MetaMask/metamask-extension/compare/v11.15.6...v11.16.0
47564763
[11.15.6]: https://github.com/MetaMask/metamask-extension/compare/v11.15.5...v11.15.6

app/scripts/background.js

+10-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,11 @@ import rawFirstTimeState from './first-time-state';
6161
import getFirstPreferredLangCode from './lib/get-first-preferred-lang-code';
6262
import getObjStructure from './lib/getObjStructure';
6363
import setupEnsIpfsResolver from './lib/ens-ipfs/setup';
64-
import { deferredPromise, getPlatform } from './lib/util';
64+
import {
65+
deferredPromise,
66+
getPlatform,
67+
shouldEmitDappViewedEvent,
68+
} from './lib/util';
6569

6670
/* eslint-enable import/first */
6771

@@ -466,6 +470,11 @@ function emitDappViewedMetricEvent(
466470
connectSitePermissions,
467471
preferencesController,
468472
) {
473+
const { metaMetricsId } = controller.metaMetricsController.state;
474+
if (!shouldEmitDappViewedEvent(metaMetricsId)) {
475+
return;
476+
}
477+
469478
// A dapp may have other permissions than eth_accounts.
470479
// Since we are only interested in dapps that use Ethereum accounts, we bail out otherwise.
471480
if (!hasProperty(connectSitePermissions.permissions, 'eth_accounts')) {

app/scripts/controllers/app-state.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ export default class AppStateController extends EventEmitter {
5252
showAccountBanner: true,
5353
trezorModel: null,
5454
currentPopupId: undefined,
55+
newPrivacyPolicyToastClickedOrClosed: null,
56+
newPrivacyPolicyToastShownDate: null,
5557
// This key is only used for checking if the user had set advancedGasFee
5658
// prior to Migration 92.3 where we split out the setting to support
5759
// multiple networks.
@@ -65,8 +67,6 @@ export default class AppStateController extends EventEmitter {
6567
'0x539': true,
6668
},
6769
surveyLinkLastClickedOrClosed: null,
68-
newPrivacyPolicyToastClickedOrClosed: null,
69-
newPrivacyPolicyToastShownDate: null,
7070
signatureSecurityAlertResponses: {},
7171
// States used for displaying the changed network toast
7272
switchedNetworkDetails: null,

app/scripts/lib/rpc-method-middleware/handlers/request-accounts.js

+15-12
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import {
44
MetaMetricsEventName,
55
MetaMetricsEventCategory,
66
} from '../../../../../shared/constants/metametrics';
7+
import { shouldEmitDappViewedEvent } from '../../util';
78

89
/**
910
* This method attempts to retrieve the Ethereum accounts available to the
@@ -114,18 +115,20 @@ async function requestEthereumAccountsHandler(
114115
const isFirstVisit = !Object.keys(metamaskState.permissionHistory).includes(
115116
origin,
116117
);
117-
sendMetrics({
118-
event: MetaMetricsEventName.DappViewed,
119-
category: MetaMetricsEventCategory.InpageProvider,
120-
referrer: {
121-
url: origin,
122-
},
123-
properties: {
124-
is_first_visit: isFirstVisit,
125-
number_of_accounts: Object.keys(metamaskState.accounts).length,
126-
number_of_accounts_connected: numberOfConnectedAccounts,
127-
},
128-
});
118+
if (shouldEmitDappViewedEvent(metamaskState.metaMetricsId)) {
119+
sendMetrics({
120+
event: MetaMetricsEventName.DappViewed,
121+
category: MetaMetricsEventCategory.InpageProvider,
122+
referrer: {
123+
url: origin,
124+
},
125+
properties: {
126+
is_first_visit: isFirstVisit,
127+
number_of_accounts: Object.keys(metamaskState.accounts).length,
128+
number_of_accounts_connected: numberOfConnectedAccounts,
129+
},
130+
});
131+
}
129132
} else {
130133
// This should never happen, because it should be caught in the
131134
// above catch clause

app/scripts/lib/util.test.js

+14
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import {
1515
} from '../../../shared/constants/app';
1616
import { isPrefixedFormattedHexString } from '../../../shared/modules/network.utils';
1717
import {
18+
shouldEmitDappViewedEvent,
1819
addUrlProtocolPrefix,
1920
deferredPromise,
2021
formatTxMetaForRpcResult,
@@ -255,6 +256,19 @@ describe('app utils', () => {
255256
});
256257
});
257258

259+
describe('shouldEmitDappViewedEvent', () => {
260+
it('should return true for valid metrics IDs', () => {
261+
expect(shouldEmitDappViewedEvent('fake-metrics-id-fd20')).toStrictEqual(
262+
true,
263+
);
264+
});
265+
it('should return false for invalid metrics IDs', () => {
266+
expect(
267+
shouldEmitDappViewedEvent('fake-metrics-id-invalid'),
268+
).toStrictEqual(false);
269+
});
270+
});
271+
258272
describe('formatTxMetaForRpcResult', () => {
259273
it('should correctly format the tx meta object (EIP-1559)', () => {
260274
const txMeta = {

app/scripts/lib/util.ts

+19
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,25 @@ export function isWebUrl(urlString: string): boolean {
276276
);
277277
}
278278

279+
/**
280+
* Determines whether to emit a MetaMetrics event for a given metaMetricsId.
281+
* Relies on the last 4 characters of the metametricsId. Assumes the IDs are evenly distributed.
282+
* If metaMetricsIds are distributed evenly, this should be a 1% sample rate
283+
*
284+
* @param metaMetricsId - The metametricsId to use for the event.
285+
* @returns Whether to emit the event or not.
286+
*/
287+
export function shouldEmitDappViewedEvent(metaMetricsId: string): boolean {
288+
if (metaMetricsId === null) {
289+
return false;
290+
}
291+
292+
const lastFourCharacters = metaMetricsId.slice(-4);
293+
const lastFourCharactersAsNumber = parseInt(lastFourCharacters, 16);
294+
295+
return lastFourCharactersAsNumber % 100 === 0;
296+
}
297+
279298
type FormattedTransactionMeta = {
280299
blockHash: string | null;
281300
blockNumber: string | null;

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "metamask-crx",
3-
"version": "11.16.1",
3+
"version": "11.16.2",
44
"private": true,
55
"repository": {
66
"type": "git",

test/e2e/tests/metrics/dapp-viewed.spec.js

+34-6
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,34 @@ const waitForDappConnected = async (driver) => {
6565
};
6666

6767
describe('Dapp viewed Event @no-mmi', function () {
68+
const validFakeMetricsId = 'fake-metrics-fd20';
69+
it('is not sent when metametrics ID is not valid', async function () {
70+
async function mockSegment(mockServer) {
71+
return [await mockedDappViewedEndpoint(mockServer)];
72+
}
73+
74+
await withFixtures(
75+
{
76+
dapp: true,
77+
fixtures: new FixtureBuilder()
78+
.withMetaMetricsController({
79+
metaMetricsId: 'invalid-metrics-id',
80+
participateInMetaMetrics: true,
81+
})
82+
.build(),
83+
title: this.test.fullTitle(),
84+
testSpecificMock: mockSegment,
85+
},
86+
async ({ driver, mockedEndpoint: mockedEndpoints }) => {
87+
await driver.navigate();
88+
await unlockWallet(driver);
89+
await connectToDapp(driver);
90+
const events = await getEventPayloads(driver, mockedEndpoints);
91+
assert.equal(events.length, 0);
92+
},
93+
);
94+
});
95+
6896
it('is sent when navigating to dapp with no account connected', async function () {
6997
async function mockSegment(mockServer) {
7098
return [await mockedDappViewedEndpoint(mockServer)];
@@ -75,7 +103,7 @@ describe('Dapp viewed Event @no-mmi', function () {
75103
dapp: true,
76104
fixtures: new FixtureBuilder()
77105
.withMetaMetricsController({
78-
metaMetricsId: 'fake-metrics-id',
106+
metaMetricsId: validFakeMetricsId, // 1% sample rate for dapp viewed event
79107
participateInMetaMetrics: true,
80108
})
81109
.build(),
@@ -110,7 +138,7 @@ describe('Dapp viewed Event @no-mmi', function () {
110138
dapp: true,
111139
fixtures: new FixtureBuilder()
112140
.withMetaMetricsController({
113-
metaMetricsId: 'fake-metrics-id',
141+
metaMetricsId: validFakeMetricsId,
114142
participateInMetaMetrics: true,
115143
})
116144
.build(),
@@ -148,7 +176,7 @@ describe('Dapp viewed Event @no-mmi', function () {
148176
dapp: true,
149177
fixtures: new FixtureBuilder()
150178
.withMetaMetricsController({
151-
metaMetricsId: 'fake-metrics-id',
179+
metaMetricsId: validFakeMetricsId,
152180
participateInMetaMetrics: true,
153181
})
154182
.build(),
@@ -191,7 +219,7 @@ describe('Dapp viewed Event @no-mmi', function () {
191219
dapp: true,
192220
fixtures: new FixtureBuilder()
193221
.withMetaMetricsController({
194-
metaMetricsId: 'fake-metrics-id',
222+
metaMetricsId: validFakeMetricsId,
195223
participateInMetaMetrics: true,
196224
})
197225
.build(),
@@ -228,7 +256,7 @@ describe('Dapp viewed Event @no-mmi', function () {
228256
dapp: true,
229257
fixtures: new FixtureBuilder()
230258
.withMetaMetricsController({
231-
metaMetricsId: 'fake-metrics-id',
259+
metaMetricsId: validFakeMetricsId,
232260
participateInMetaMetrics: true,
233261
})
234262
.build(),
@@ -282,7 +310,7 @@ describe('Dapp viewed Event @no-mmi', function () {
282310
dapp: true,
283311
fixtures: new FixtureBuilder()
284312
.withMetaMetricsController({
285-
metaMetricsId: 'fake-metrics-id',
313+
metaMetricsId: validFakeMetricsId,
286314
participateInMetaMetrics: true,
287315
})
288316
.build(),

test/e2e/tests/metrics/permissions-approved.spec.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ describe('Permissions Approved Event', function () {
5050
dapp: true,
5151
fixtures: new FixtureBuilder()
5252
.withMetaMetricsController({
53-
metaMetricsId: 'fake-metrics-id',
53+
metaMetricsId: 'fake-metrics-fd20',
5454
participateInMetaMetrics: true,
5555
})
5656
.build(),
+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
// This date indicates the date of the latest privacy policy document
2-
const PRIVACY_POLICY_DATE = '2024-06-04T00:00:00Z';
2+
const PRIVACY_POLICY_DATE = '2099-06-04T00:00:00Z';
33

44
export { PRIVACY_POLICY_DATE };

ui/pages/confirmations/components/confirm-gas-display/confirm-legacy-gas-display/confirm-legacy-gas-display.js

+14-43
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,12 @@ import {
2323
TextColor,
2424
} from '../../../../../helpers/constants/design-system';
2525
import { useDraftTransactionWithTxParams } from '../../../hooks/useDraftTransactionWithTxParams';
26-
import { getNativeCurrency } from '../../../../../ducks/metamask/metamask';
27-
import MultilayerFeeMessage from '../../multilayer-fee-message/multi-layer-fee-message';
2826
import {
2927
Icon,
3028
IconName,
3129
Text,
3230
} from '../../../../../components/component-library';
31+
import { addHexes } from '../../../../../../shared/modules/conversion.utils';
3332

3433
const renderHeartBeatIfNotInTest = () =>
3534
process.env.IN_TEST ? null : <LoadingHeartBeat />;
@@ -41,54 +40,26 @@ const ConfirmLegacyGasDisplay = ({ 'data-testid': dataTestId } = {}) => {
4140
const isMainnet = useSelector(getIsMainnet);
4241
const useCurrencyRateCheck = useSelector(getUseCurrencyRateCheck);
4342
const { useNativeCurrencyAsPrimaryCurrency } = useSelector(getPreferences);
44-
const nativeCurrency = useSelector(getNativeCurrency);
4543
const unapprovedTxs = useSelector(getUnapprovedTransactions);
4644
const transactionData = useDraftTransactionWithTxParams();
4745
const txData = useSelector((state) => txDataSelector(state));
48-
const { id: transactionId, dappSuggestedGasFees } = txData;
46+
const { id: transactionId, dappSuggestedGasFees, layer1GasFee } = txData;
4947
const transaction = Object.keys(transactionData).length
5048
? transactionData
5149
: unapprovedTxs[transactionId] || {};
5250
const { hexMinimumTransactionFee, hexMaximumTransactionFee } = useSelector(
5351
(state) => transactionFeeSelector(state, transaction),
5452
);
55-
const { layer1GasFee } = txData;
56-
const hasLayer1GasFee = layer1GasFee !== undefined;
5753

58-
if (hasLayer1GasFee) {
59-
return [
60-
<TransactionDetailItem
61-
key="legacy-total-item"
62-
data-testid={dataTestId}
63-
detailTitle={t('transactionDetailLayer2GasHeading')}
64-
detailTotal={
65-
<UserPreferencedCurrencyDisplay
66-
type={PRIMARY}
67-
value={hexMinimumTransactionFee}
68-
hideLabel={!useNativeCurrencyAsPrimaryCurrency}
69-
numberOfDecimals={18}
70-
/>
71-
}
72-
detailText={
73-
useCurrencyRateCheck && (
74-
<UserPreferencedCurrencyDisplay
75-
type={SECONDARY}
76-
value={hexMinimumTransactionFee}
77-
hideLabel={Boolean(useNativeCurrencyAsPrimaryCurrency)}
78-
/>
79-
)
80-
}
81-
noBold
82-
flexWidthValues
83-
/>,
84-
<MultilayerFeeMessage
85-
key="confirm-layer-1"
86-
transaction={txData}
87-
layer2fee={hexMinimumTransactionFee}
88-
nativeCurrency={nativeCurrency}
89-
/>,
90-
];
91-
}
54+
const estimatedHexMinFeeTotal = addHexes(
55+
hexMinimumTransactionFee,
56+
layer1GasFee ?? '0x0',
57+
);
58+
59+
const estimatedHexMaxFeeTotal = addHexes(
60+
hexMaximumTransactionFee,
61+
layer1GasFee ?? '0x0',
62+
);
9263

9364
return (
9465
<TransactionDetailItem
@@ -141,7 +112,7 @@ const ConfirmLegacyGasDisplay = ({ 'data-testid': dataTestId } = {}) => {
141112
{renderHeartBeatIfNotInTest()}
142113
<UserPreferencedCurrencyDisplay
143114
type={SECONDARY}
144-
value={hexMinimumTransactionFee}
115+
value={estimatedHexMinFeeTotal}
145116
hideLabel={Boolean(useNativeCurrencyAsPrimaryCurrency)}
146117
/>
147118
</div>
@@ -152,7 +123,7 @@ const ConfirmLegacyGasDisplay = ({ 'data-testid': dataTestId } = {}) => {
152123
{renderHeartBeatIfNotInTest()}
153124
<UserPreferencedCurrencyDisplay
154125
type={PRIMARY}
155-
value={hexMinimumTransactionFee}
126+
value={estimatedHexMinFeeTotal}
156127
hideLabel={!useNativeCurrencyAsPrimaryCurrency}
157128
numberOfDecimals={6}
158129
/>
@@ -168,7 +139,7 @@ const ConfirmLegacyGasDisplay = ({ 'data-testid': dataTestId } = {}) => {
168139
<UserPreferencedCurrencyDisplay
169140
key="editGasSubTextFeeAmount"
170141
type={PRIMARY}
171-
value={hexMaximumTransactionFee}
142+
value={estimatedHexMaxFeeTotal}
172143
hideLabel={!useNativeCurrencyAsPrimaryCurrency}
173144
/>
174145
</div>

0 commit comments

Comments
 (0)