{isLoading ?
: null}
{!isLoading && isNetworkLoading ?
: null}
diff --git a/ui/pages/routes/routes.container.js b/ui/pages/routes/routes.container.js
index baa22c162504..c132bcfa87c7 100644
--- a/ui/pages/routes/routes.container.js
+++ b/ui/pages/routes/routes.container.js
@@ -18,6 +18,7 @@ import {
setCurrentCurrency,
setLastActiveTime,
setMouseUserState,
+ toggleAccountMenu,
} from '../../store/actions';
import { pageChanged } from '../../ducks/history/history';
import { prepareToLeaveSwaps } from '../../ducks/swaps/swaps';
@@ -55,6 +56,7 @@ function mapStateToProps(state) {
forgottenPassword: state.metamask.forgottenPassword,
isCurrentProviderCustom: isCurrentProviderCustom(state),
completedOnboarding,
+ isAccountMenuOpen: state.metamask.isAccountMenuOpen,
};
}
@@ -67,6 +69,7 @@ function mapDispatchToProps(dispatch) {
setLastActiveTime: () => dispatch(setLastActiveTime()),
pageChanged: (path) => dispatch(pageChanged(path)),
prepareToLeaveSwaps: () => dispatch(prepareToLeaveSwaps()),
+ toggleAccountMenu: () => dispatch(toggleAccountMenu()),
};
}
diff --git a/ui/selectors/permissions.js b/ui/selectors/permissions.js
index 27f5c4c88f6a..d4b3d90de780 100644
--- a/ui/selectors/permissions.js
+++ b/ui/selectors/permissions.js
@@ -100,6 +100,24 @@ export function getConnectedSubjectsForSelectedAddress(state) {
return connectedSubjects;
}
+export function getConnectedSubjectsForAllAddresses(state) {
+ const subjects = getPermissionSubjects(state);
+ const subjectMetadata = getSubjectMetadata(state);
+
+ const accountsToConnections = {};
+ Object.entries(subjects).forEach(([subjectKey, subjectValue]) => {
+ const exposedAccounts = getAccountsFromSubject(subjectValue);
+ exposedAccounts.forEach((address) => {
+ if (!accountsToConnections[address]) {
+ accountsToConnections[address] = [];
+ }
+ accountsToConnections[address].push(subjectMetadata[subjectKey] || {});
+ });
+ });
+
+ return accountsToConnections;
+}
+
export function getSubjectsWithPermission(state, permissionName) {
const subjects = getPermissionSubjects(state);
From cedef121a36184cde4eae448ef510733fa301072 Mon Sep 17 00:00:00 2001
From: Nidhi Kumari
Date: Wed, 22 Mar 2023 16:39:58 +0530
Subject: [PATCH 10/20] updated keyringType (#18273)
---
.storybook/test-data.js | 8 +++-----
.../account-list-item/account-list-item.js | 18 ++++++++----------
2 files changed, 11 insertions(+), 15 deletions(-)
diff --git a/.storybook/test-data.js b/.storybook/test-data.js
index a7a893354e12..3f133fcba5e3 100644
--- a/.storybook/test-data.js
+++ b/.storybook/test-data.js
@@ -1182,11 +1182,9 @@ const state = {
],
},
{
- type: HardwareKeyringTypes.ledger,
- accounts: [
- '0x9d0ba4ddac06032527b140912ec808ab9451b788'
- ],
- }
+ type: KeyringType.ledger,
+ accounts: ['0x9d0ba4ddac06032527b140912ec808ab9451b788'],
+ },
],
networkConfigurations: {
'test-networkConfigurationId-1': {
diff --git a/ui/components/multichain/account-list-item/account-list-item.js b/ui/components/multichain/account-list-item/account-list-item.js
index f0a2aea8c820..bbfd277a4570 100644
--- a/ui/components/multichain/account-list-item/account-list-item.js
+++ b/ui/components/multichain/account-list-item/account-list-item.js
@@ -30,10 +30,8 @@ import {
Size,
BorderColor,
} from '../../../helpers/constants/design-system';
-import {
- HardwareKeyringTypes,
- HardwareKeyringNames,
-} from '../../../../shared/constants/hardware-wallets';
+import { HardwareKeyringNames } from '../../../../shared/constants/hardware-wallets';
+import { KeyringType } from '../../../../shared/constants/keyring';
import UserPreferencedCurrencyDisplay from '../../app/user-preferenced-currency-display/user-preferenced-currency-display.component';
import { SECONDARY, PRIMARY } from '../../../helpers/constants/common';
import { findKeyringForAddress } from '../../../ducks/metamask/metamask';
@@ -45,15 +43,15 @@ const MAXIMUM_CHARACTERS_WITHOUT_TOOLTIP = 17;
function getLabel(keyring = {}, t) {
const { type } = keyring;
switch (type) {
- case HardwareKeyringTypes.qr:
+ case KeyringType.qr:
return HardwareKeyringNames.qr;
- case HardwareKeyringTypes.imported:
+ case KeyringType.imported:
return t('imported');
- case HardwareKeyringTypes.trezor:
+ case KeyringType.trezor:
return HardwareKeyringNames.trezor;
- case HardwareKeyringTypes.ledger:
+ case KeyringType.ledger:
return HardwareKeyringNames.ledger;
- case HardwareKeyringTypes.lattice:
+ case KeyringType.lattice:
return HardwareKeyringNames.lattice;
default:
return null;
@@ -212,7 +210,7 @@ export const AccountListItem = ({
blockExplorerUrlSubTitle={blockExplorerUrlSubTitle}
identity={identity}
onClose={() => setAccountOptionsMenuOpen(false)}
- isRemovable={keyring?.type !== HardwareKeyringTypes.hdKeyTree}
+ isRemovable={keyring?.type !== KeyringType.hdKeyTree}
closeMenu={closeMenu}
/>
) : null}
From 735f86cac23680792711e07b6f995a84660dfbe1 Mon Sep 17 00:00:00 2001
From: Matthew Walsh
Date: Wed, 22 Mar 2023 12:18:17 +0000
Subject: [PATCH 11/20] Remove personal message manager (#18260)
---
app/scripts/lib/personal-message-manager.js | 370 ------------------
.../lib/personal-message-manager.test.js | 182 ---------
2 files changed, 552 deletions(-)
delete mode 100644 app/scripts/lib/personal-message-manager.js
delete mode 100644 app/scripts/lib/personal-message-manager.test.js
diff --git a/app/scripts/lib/personal-message-manager.js b/app/scripts/lib/personal-message-manager.js
deleted file mode 100644
index bb0a2b0c1e04..000000000000
--- a/app/scripts/lib/personal-message-manager.js
+++ /dev/null
@@ -1,370 +0,0 @@
-import EventEmitter from 'events';
-import { ObservableStore } from '@metamask/obs-store';
-import { bufferToHex } from 'ethereumjs-util';
-import { ethErrors } from 'eth-rpc-errors';
-import log from 'loglevel';
-import { MESSAGE_TYPE } from '../../../shared/constants/app';
-import { METAMASK_CONTROLLER_EVENTS } from '../metamask-controller';
-import createId from '../../../shared/modules/random-id';
-import { EVENT } from '../../../shared/constants/metametrics';
-import { detectSIWE } from '../../../shared/modules/siwe';
-import { stripHexPrefix } from '../../../shared/modules/hexstring-utils';
-import { addHexPrefix } from './util';
-
-const hexRe = /^[0-9A-Fa-f]+$/gu;
-
-/**
- * Represents, and contains data about, an 'personal_sign' type signature request. These are created when a
- * signature for an personal_sign call is requested.
- *
- * @see {@link https://web3js.readthedocs.io/en/1.0/web3-eth-personal.html#sign}
- * @typedef {object} PersonalMessage
- * @property {number} id An id to track and identify the message object
- * @property {object} msgParams The parameters to pass to the personal_sign method once the signature request is
- * approved.
- * @property {object} msgParams.metamaskId Added to msgParams for tracking and identification within MetaMask.
- * @property {string} msgParams.data A hex string conversion of the raw buffer data of the signature request
- * @property {number} time The epoch time at which the this message was created
- * @property {string} status Indicates whether the signature request is 'unapproved', 'approved', 'signed' or 'rejected'
- * @property {string} type The json-prc signing method for which a signature request has been made. A 'Message' will
- * always have a 'personal_sign' type.
- */
-
-export default class PersonalMessageManager extends EventEmitter {
- /**
- * Controller in charge of managing - storing, adding, removing, updating - PersonalMessage.
- *
- * @param options
- * @param options.metricsEvent
- * @param options.securityProviderRequest
- */
- constructor({ metricsEvent, securityProviderRequest }) {
- super();
- this.memStore = new ObservableStore({
- unapprovedPersonalMsgs: {},
- unapprovedPersonalMsgCount: 0,
- });
-
- this.resetState = () => {
- this.memStore.updateState({
- unapprovedPersonalMsgs: {},
- unapprovedPersonalMsgCount: 0,
- });
- };
-
- this.messages = [];
- this.metricsEvent = metricsEvent;
- this.securityProviderRequest = securityProviderRequest;
- }
-
- /**
- * A getter for the number of 'unapproved' PersonalMessages in this.messages
- *
- * @returns {number} The number of 'unapproved' PersonalMessages in this.messages
- */
- get unapprovedPersonalMsgCount() {
- return Object.keys(this.getUnapprovedMsgs()).length;
- }
-
- /**
- * A getter for the 'unapproved' PersonalMessages in this.messages
- *
- * @returns {object} An index of PersonalMessage ids to PersonalMessages, for all 'unapproved' PersonalMessages in
- * this.messages
- */
- getUnapprovedMsgs() {
- return this.messages
- .filter((msg) => msg.status === 'unapproved')
- .reduce((result, msg) => {
- result[msg.id] = msg;
- return result;
- }, {});
- }
-
- /**
- * Creates a new PersonalMessage with an 'unapproved' status using the passed msgParams. this.addMsg is called to add
- * the new PersonalMessage to this.messages, and to save the unapproved PersonalMessages from that list to
- * this.memStore.
- *
- * @param {object} msgParams - The params for the eth_sign call to be made after the message is approved.
- * @param {object} [req] - The original request object possibly containing the origin
- * @returns {promise} When the message has been signed or rejected
- */
- addUnapprovedMessageAsync(msgParams, req) {
- return new Promise((resolve, reject) => {
- if (!msgParams.from) {
- reject(
- new Error('MetaMask Message Signature: from field is required.'),
- );
- return;
- }
- this.addUnapprovedMessage(msgParams, req).then((msgId) => {
- this.once(`${msgId}:finished`, (data) => {
- switch (data.status) {
- case 'signed':
- resolve(data.rawSig);
- return;
- case 'rejected':
- reject(
- ethErrors.provider.userRejectedRequest(
- 'MetaMask Message Signature: User denied message signature.',
- ),
- );
- return;
- case 'errored':
- reject(new Error(`MetaMask Message Signature: ${data.error}`));
- return;
- default:
- reject(
- new Error(
- `MetaMask Message Signature: Unknown problem: ${JSON.stringify(
- msgParams,
- )}`,
- ),
- );
- }
- });
- });
- });
- }
-
- /**
- * Creates a new PersonalMessage with an 'unapproved' status using the passed msgParams. this.addMsg is called to add
- * the new PersonalMessage to this.messages, and to save the unapproved PersonalMessages from that list to
- * this.memStore.
- *
- * @param {object} msgParams - The params for the eth_sign call to be made after the message is approved.
- * @param {object} [req] - The original request object possibly containing the origin
- * @returns {number} The id of the newly created PersonalMessage.
- */
- async addUnapprovedMessage(msgParams, req) {
- log.debug(
- `PersonalMessageManager addUnapprovedMessage: ${JSON.stringify(
- msgParams,
- )}`,
- );
- // add origin from request
- if (req) {
- msgParams.origin = req.origin;
- }
- msgParams.data = this.normalizeMsgData(msgParams.data);
-
- // check for SIWE message
- const siwe = detectSIWE(msgParams);
- msgParams.siwe = siwe;
-
- // create txData obj with parameters and meta data
- const time = new Date().getTime();
- const msgId = createId();
- const msgData = {
- id: msgId,
- msgParams,
- time,
- status: 'unapproved',
- type: MESSAGE_TYPE.PERSONAL_SIGN,
- };
- this.addMsg(msgData);
-
- const securityProviderResponse = await this.securityProviderRequest(
- msgData,
- msgData.type,
- );
-
- msgData.securityProviderResponse = securityProviderResponse;
-
- // signal update
- this.emit('update');
- return msgId;
- }
-
- /**
- * Adds a passed PersonalMessage to this.messages, and calls this._saveMsgList() to save the unapproved PersonalMessages from that
- * list to this.memStore.
- *
- * @param {Message} msg - The PersonalMessage to add to this.messages
- */
- addMsg(msg) {
- this.messages.push(msg);
- this._saveMsgList();
- }
-
- /**
- * Returns a specified PersonalMessage.
- *
- * @param {number} msgId - The id of the PersonalMessage to get
- * @returns {PersonalMessage|undefined} The PersonalMessage with the id that matches the passed msgId, or undefined
- * if no PersonalMessage has that id.
- */
- getMsg(msgId) {
- return this.messages.find((msg) => msg.id === msgId);
- }
-
- /**
- * Approves a PersonalMessage. Sets the message status via a call to this.setMsgStatusApproved, and returns a promise
- * with any the message params modified for proper signing.
- *
- * @param {object} msgParams - The msgParams to be used when eth_sign is called, plus data added by MetaMask.
- * @param {object} msgParams.metamaskId - Added to msgParams for tracking and identification within MetaMask.
- * @returns {Promise
setShowNicknamePopovers(true)}
>
{recipientToRender}
diff --git a/ui/components/app/transaction-decoding/components/decoding/address/index.scss b/ui/components/app/transaction-decoding/components/decoding/address/index.scss
index ca821dae80e2..71bf88fadc64 100644
--- a/ui/components/app/transaction-decoding/components/decoding/address/index.scss
+++ b/ui/components/app/transaction-decoding/components/decoding/address/index.scss
@@ -1,12 +1,13 @@
-.tx-insight-content {
- .tx-insight-component-address {
- display: flex;
- align-items: center;
- cursor: pointer;
- overflow: visible;
+.tx-insight-component-address {
+ display: flex;
+ align-items: center;
+ overflow: visible;
+
+ &__sender-icon {
+ padding-right: 5px;
+ }
- &__sender-icon {
- padding-right: 5px;
- }
+ &__name {
+ cursor: pointer;
}
}
diff --git a/ui/pages/confirm-signature-request/__snapshots__/index.test.js.snap b/ui/pages/confirm-signature-request/__snapshots__/index.test.js.snap
index e795ab35d5f7..fbf3c10c168d 100644
--- a/ui/pages/confirm-signature-request/__snapshots__/index.test.js.snap
+++ b/ui/pages/confirm-signature-request/__snapshots__/index.test.js.snap
@@ -368,7 +368,7 @@ exports[`Signature Request Component render should match snapshot 1`] = `