Skip to content

Commit

Permalink
chore: move hd_entropy_index check to getHdEntropyIndex() function
Browse files Browse the repository at this point in the history
  • Loading branch information
PatrykLucka committed Feb 24, 2025
1 parent b59a6ec commit d8e4908
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
3 changes: 1 addition & 2 deletions app/scripts/lib/transaction/metrics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -985,9 +985,8 @@ async function buildEventFragmentProperties({
getSwapAndSendMetricsProps(transactionMeta);

// Add Entropy Properties
const hdEntropyIndex = transactionMetricsRequest.getHDEntropyIndex();
const hdEntropyProperties = {
hd_entropy_index: hdEntropyIndex === -1 ? undefined : hdEntropyIndex,
hd_entropy_index: transactionMetricsRequest.getHDEntropyIndex(),
};

/** The transaction status property is not considered sensitive and is now included in the non-anonymous event */
Expand Down
6 changes: 4 additions & 2 deletions app/scripts/metamask-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -5419,16 +5419,18 @@ export default class MetamaskController extends EventEmitter {
/**
* Returns the index of the HD keyring containing the selected account.
*
* @returns {number} The index of the HD keyring containing the selected account.
* @returns {number | undefined} The index of the HD keyring containing the selected account.
*/
getHDEntropyIndex() {
const selectedAccount = this.accountsController.getSelectedAccount();
const hdKeyrings = this.keyringController.state.keyrings.filter(
(keyring) => keyring.type === KeyringTypes.hd,
);
return hdKeyrings.findIndex((keyring) =>
const index = hdKeyrings.findIndex((keyring) =>
keyring.accounts.includes(selectedAccount.address),
);

return index === -1 ? undefined : index;
}

//=============================================================================
Expand Down

0 comments on commit d8e4908

Please sign in to comment.