Skip to content

Commit 5064ba3

Browse files
authored
Merge branch 'main' into user_ctrl_update
2 parents 0378f4d + 478b45f commit 5064ba3

File tree

141 files changed

+2941
-484
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

141 files changed

+2941
-484
lines changed

app/_locales/en/messages.json

Lines changed: 20 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/_locales/en_GB/messages.json

Lines changed: 20 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/scripts/lib/createRPCMethodTrackingMiddleware.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,7 @@ export default function createRPCMethodTrackingMiddleware({
239239
snapAndHardwareMessenger,
240240
appStateController,
241241
metaMetricsController,
242+
getHDEntropyIndex,
242243
}) {
243244
return async function rpcMethodTrackingMiddleware(
244245
/** @type {any} */ req,
@@ -306,6 +307,7 @@ export default function createRPCMethodTrackingMiddleware({
306307

307308
if (event === MetaMetricsEventName.SignatureRequested) {
308309
eventProperties.signature_type = method;
310+
eventProperties.hd_entropy_index = getHDEntropyIndex();
309311

310312
// In personal messages the first param is data while in typed messages second param is data
311313
// if condition below is added to ensure that the right params are captured as data and address.
@@ -502,7 +504,10 @@ export default function createRPCMethodTrackingMiddleware({
502504
abandoned: event === eventType.REJECTED,
503505
};
504506
const fragmentPayload = {
505-
properties,
507+
properties: {
508+
...properties,
509+
hd_entropy_index: getHDEntropyIndex(),
510+
},
506511
sensitiveProperties: sensitiveEventProperties,
507512
};
508513

app/scripts/lib/createRPCMethodTrackingMiddleware.test.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ const createHandler = (opts) =>
110110
globalRateLimitMaxAmount: 0,
111111
appStateController,
112112
metaMetricsController,
113+
getHDEntropyIndex: jest.fn(),
113114
...opts,
114115
});
115116

@@ -313,6 +314,7 @@ describe('createRPCMethodTrackingMiddleware', () => {
313314
category: MetaMetricsEventCategory.InpageProvider,
314315
event: MetaMetricsEventName.SignatureRequested,
315316
properties: {
317+
hd_entropy_index: undefined,
316318
signature_type: MESSAGE_TYPE.ETH_SIGN_TYPED_DATA_V4,
317319
security_alert_response: BlockaidResultType.Malicious,
318320
security_alert_reason: BlockaidReason.maliciousDomain,

app/scripts/lib/transaction/metrics.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ const mockTransactionMetricsRequest = {
9191
getSmartTransactionByMinedTxHash: jest.fn(),
9292
getMethodData: jest.fn(),
9393
getIsConfirmationAdvancedDetailsOpen: jest.fn(),
94+
getHDEntropyIndex: jest.fn(),
9495
} as TransactionMetricsRequest;
9596

9697
describe('Transaction metrics', () => {

app/scripts/lib/transaction/metrics.ts

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -328,12 +328,17 @@ export const createTransactionEventFragmentWithTxId = async (
328328
* @param transactionMetricsRequest - Contains controller actions
329329
* @param transactionMetricsRequest.getParticipateInMetrics - Returns whether the user has opted into metrics
330330
* @param transactionMetricsRequest.trackEvent - MetaMetrics track event function
331+
* @param transactionMetricsRequest.getHDEntropyIndex - Returns Index of the currently selected HD Keyring
331332
* @param transactionEventPayload - The event payload
332333
* @param transactionEventPayload.transactionMeta - The updated transaction meta
333334
* @param transactionEventPayload.approvalTransactionMeta - The updated approval transaction meta
334335
*/
335336
export const handlePostTransactionBalanceUpdate = async (
336-
{ getParticipateInMetrics, trackEvent }: TransactionMetricsRequest,
337+
{
338+
getParticipateInMetrics,
339+
trackEvent,
340+
getHDEntropyIndex,
341+
}: TransactionMetricsRequest,
337342
{
338343
transactionMeta,
339344
approvalTransactionMeta,
@@ -345,9 +350,12 @@ export const handlePostTransactionBalanceUpdate = async (
345350
if (getParticipateInMetrics() && transactionMeta.swapMetaData) {
346351
if (transactionMeta.txReceipt?.status === '0x0') {
347352
trackEvent({
348-
event: 'Swap Failed',
349-
sensitiveProperties: { ...transactionMeta.swapMetaData },
353+
event: MetaMetricsEventName.SwapFailed,
350354
category: MetaMetricsEventCategory.Swaps,
355+
sensitiveProperties: { ...transactionMeta.swapMetaData },
356+
properties: {
357+
hd_entropy_index: getHDEntropyIndex(),
358+
},
351359
});
352360
} else {
353361
const tokensReceived = getSwapsTokensReceivedFromTxMeta(
@@ -401,6 +409,9 @@ export const handlePostTransactionBalanceUpdate = async (
401409
token_to_amount:
402410
transactionMeta.swapMetaData.token_to_amount.toString(10),
403411
},
412+
properties: {
413+
hd_entropy_index: getHDEntropyIndex(),
414+
},
404415
});
405416
}
406417
}
@@ -981,6 +992,11 @@ async function buildEventFragmentProperties({
981992
const swapAndSendMetricsProperties =
982993
getSwapAndSendMetricsProps(transactionMeta);
983994

995+
// Add Entropy Properties
996+
const hdEntropyProperties = {
997+
hd_entropy_index: transactionMetricsRequest.getHDEntropyIndex(),
998+
};
999+
9841000
/** The transaction status property is not considered sensitive and is now included in the non-anonymous event */
9851001
let properties = {
9861002
chain_id: chainId,
@@ -1013,6 +1029,7 @@ async function buildEventFragmentProperties({
10131029
: [],
10141030
...smartTransactionMetricsProperties,
10151031
...swapAndSendMetricsProperties,
1032+
...hdEntropyProperties,
10161033
// TODO: Replace `any` with type
10171034
// eslint-disable-next-line @typescript-eslint/no-explicit-any
10181035
} as Record<string, any>;

app/scripts/metamask-controller.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5654,6 +5654,23 @@ export default class MetamaskController extends EventEmitter {
56545654
});
56555655
}
56565656

5657+
/**
5658+
* Returns the index of the HD keyring containing the selected account.
5659+
*
5660+
* @returns {number | undefined} The index of the HD keyring containing the selected account.
5661+
*/
5662+
getHDEntropyIndex() {
5663+
const selectedAccount = this.accountsController.getSelectedAccount();
5664+
const hdKeyrings = this.keyringController.state.keyrings.filter(
5665+
(keyring) => keyring.type === KeyringTypes.hd,
5666+
);
5667+
const index = hdKeyrings.findIndex((keyring) =>
5668+
keyring.accounts.includes(selectedAccount.address),
5669+
);
5670+
5671+
return index === -1 ? undefined : index;
5672+
}
5673+
56575674
//=============================================================================
56585675
// PASSWORD MANAGEMENT
56595676
//=============================================================================
@@ -6231,6 +6248,7 @@ export default class MetamaskController extends EventEmitter {
62316248
createRPCMethodTrackingMiddleware({
62326249
getAccountType: this.getAccountType.bind(this),
62336250
getDeviceModel: this.getDeviceModel.bind(this),
6251+
getHDEntropyIndex: this.getHDEntropyIndex.bind(this),
62346252
getHardwareTypeForMetric: this.getHardwareTypeForMetric.bind(this),
62356253
snapAndHardwareMessenger: this.controllerMessenger.getRestricted({
62366254
name: 'SnapAndHardwareMessenger',
@@ -7331,6 +7349,7 @@ export default class MetamaskController extends EventEmitter {
73317349
return this.preferencesController.state.preferences
73327350
.showConfirmationAdvancedDetails;
73337351
},
7352+
getHDEntropyIndex: this.getHDEntropyIndex.bind(this),
73347353
};
73357354
return {
73367355
...controllerActions,

shared/constants/metametrics.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -687,6 +687,7 @@ export enum MetaMetricsEventName {
687687
EncryptionPublicKeyRequested = 'Encryption Requested',
688688
ErrorOccured = 'Error occured',
689689
ExternalLinkClicked = 'External Link Clicked',
690+
ImportSecretRecoveryPhraseClicked = 'Import Secret Recovery Phrase Clicked',
690691
KeyExportSelected = 'Key Export Selected',
691692
KeyExportRequested = 'Key Export Requested',
692693
KeyExportFailed = 'Key Export Failed',
@@ -751,6 +752,9 @@ export enum MetaMetricsEventName {
751752
ProviderMethodCalled = 'Provider Method Called',
752753
PublicAddressCopied = 'Public Address Copied',
753754
QuoteError = 'Quote Error',
755+
SecretRecoveryPhrasePickerClicked = 'Secret Recovery Phrase Picker Clicked',
756+
SecretRecoveryPhrasePickerDetailsClicked = 'Secret Recovery Phrase Details Clicked',
757+
SecretRecoveryPhrasePickerSelected = 'Secret Recovery Phrase Picker Selected',
754758
SettingsUpdated = 'Settings Updated',
755759
SignatureApproved = 'Signature Approved',
756760
SignatureFailed = 'Signature Failed',
@@ -843,7 +847,9 @@ export enum MetaMetricsEventName {
843847
TransactionFinalized = 'Transaction Finalized',
844848
ConfirmationQueued = 'Confirmation Queued',
845849
ExitedSwaps = 'Exited Swaps',
850+
MakeAnotherSwap = 'Make Another Swap',
846851
SwapError = 'Swap Error',
852+
SwapFailed = 'Swap Failed',
847853
SnapInstallStarted = 'Snap Install Started',
848854
SnapInstallFailed = 'Snap Install Failed',
849855
SnapInstallRejected = 'Snap Install Rejected',

shared/constants/network.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -975,6 +975,14 @@ export const CHAIN_ID_TOKEN_IMAGE_MAP = {
975975
[CHAINLIST_CHAIN_IDS_MAP.UNICHAIN_SEPOLIA]: ETH_TOKEN_IMAGE_URL,
976976
} as const;
977977

978+
/**
979+
* A mapping for networks with enabled profolio landing page to their URLs.
980+
*/
981+
export const CHAIN_ID_PROFOLIO_LANDING_PAGE_URL_MAP: Record<Hex, string> = {
982+
[CHAIN_IDS.LINEA_MAINNET]:
983+
'https://portfolio.metamask.io/explore/networks/linea',
984+
} as const;
985+
978986
export const INFURA_BLOCKED_KEY = 'countryBlocked';
979987

980988
const defaultEtherscanDomain = 'etherscan.io';

shared/modules/metametrics.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ const createTransactionMetricsRequest = (customProps = {}) => {
4242
getSmartTransactionByMinedTxHash: jest.fn(),
4343
getMethodData: jest.fn(),
4444
getIsConfirmationAdvancedDetailsOpen: jest.fn(),
45+
getHDEntropyIndex: jest.fn(),
4546
...customProps,
4647
} as TransactionMetricsRequest;
4748
};

0 commit comments

Comments
 (0)