From 9456967b9530c92f3574280d3743d06afe390a87 Mon Sep 17 00:00:00 2001 From: MetaMask Bot <37885440+metamaskbot@users.noreply.github.com> Date: Fri, 24 Jan 2025 15:07:05 -0500 Subject: [PATCH] Version v12.10.2 RC (#29875) :package: :rocket: --------- Co-authored-by: MetaMask Bot Co-authored-by: Matthew Walsh Co-authored-by: Micaela Estabillo <100321200+micaelae@users.noreply.github.com> Co-authored-by: Dan J Miller Co-authored-by: Nidhi Kumari Co-authored-by: Derek Brans --- CHANGELOG.md | 10 +++++- package.json | 2 +- ui/hooks/bridge/useBridging.ts | 2 +- .../hooks/useConfirmationNavigation.test.ts | 13 ++++++++ .../hooks/useConfirmationNavigation.ts | 6 ++-- ui/pages/home/home.component.js | 4 +-- .../permissions-connect.component.js | 32 ++++++++++++++----- .../prepare-swap-page/prepare-swap-page.js | 2 +- 8 files changed, 55 insertions(+), 16 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9f78659c6afd..54498f2dc8b2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [12.10.2] +### Fixed +- Updated permissions header to be consistent (#29880) ([#29880](https://github.com/MetaMask/metamask-extension/pull/29880)) +- Fixed Route to bridge page from swaps ([#29883](https://github.com/MetaMask/metamask-extension/pull/29883)) +- Re-added missing smart transaction status confirmation (#29860) ([#29860](https://github.com/MetaMask/metamask-extension/pull/29860)) + + ## [12.10.1] ### Changed - Stop publishing MMI builds to the release page ([#29732](https://github.com/MetaMask/metamask-extension/pull/29732)) @@ -5557,7 +5564,8 @@ Update styles and spacing on the critical error page ([#20350](https://github.c - Added the ability to restore accounts from seed words. -[Unreleased]: https://github.com/MetaMask/metamask-extension/compare/v12.10.1...HEAD +[Unreleased]: https://github.com/MetaMask/metamask-extension/compare/v12.10.2...HEAD +[12.10.2]: https://github.com/MetaMask/metamask-extension/compare/v12.10.1...v12.10.2 [12.10.1]: https://github.com/MetaMask/metamask-extension/compare/v12.10.0...v12.10.1 [12.10.0]: https://github.com/MetaMask/metamask-extension/compare/v12.9.3...v12.10.0 [12.9.3]: https://github.com/MetaMask/metamask-extension/compare/v12.9.2...v12.9.3 diff --git a/package.json b/package.json index b7be2b7423c0..7de4b065c9e7 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "metamask-crx", - "version": "12.10.1", + "version": "12.10.2", "private": true, "repository": { "type": "git", diff --git a/ui/hooks/bridge/useBridging.ts b/ui/hooks/bridge/useBridging.ts index f48a4e515ec6..654bd3f12db3 100644 --- a/ui/hooks/bridge/useBridging.ts +++ b/ui/hooks/bridge/useBridging.ts @@ -90,7 +90,7 @@ const useBridging = () => { }, }); history.push( - `${CROSS_CHAIN_SWAP_ROUTE}${PREPARE_SWAP_ROUTE}?token=${token.address.toLowerCase()}`, + `${CROSS_CHAIN_SWAP_ROUTE}${PREPARE_SWAP_ROUTE}?token=${token.address?.toLowerCase()}`, ); } else { const portfolioUrl = getPortfolioUrl( diff --git a/ui/pages/confirmations/hooks/useConfirmationNavigation.test.ts b/ui/pages/confirmations/hooks/useConfirmationNavigation.test.ts index 9804e14a0e00..f832b451572f 100644 --- a/ui/pages/confirmations/hooks/useConfirmationNavigation.test.ts +++ b/ui/pages/confirmations/hooks/useConfirmationNavigation.test.ts @@ -116,6 +116,19 @@ describe('useConfirmationNavigation', () => { ); }); + it('does not navigate to template route if approval flow and pending approval', () => { + const result = renderHook(ApprovalType.Transaction, undefined, [ + {} as never, + ]); + + result.navigateToId(APPROVAL_ID_MOCK); + + expect(history.replace).toHaveBeenCalledTimes(1); + expect(history.replace).toHaveBeenCalledWith( + `${CONFIRM_TRANSACTION_ROUTE}/${APPROVAL_ID_MOCK}`, + ); + }); + it('navigates to connect route', () => { const result = renderHook(ApprovalType.WalletRequestPermissions); diff --git a/ui/pages/confirmations/hooks/useConfirmationNavigation.ts b/ui/pages/confirmations/hooks/useConfirmationNavigation.ts index 95bc1d93cd34..ef081c6497c9 100644 --- a/ui/pages/confirmations/hooks/useConfirmationNavigation.ts +++ b/ui/pages/confirmations/hooks/useConfirmationNavigation.ts @@ -76,12 +76,14 @@ export function navigateToConfirmation( hasApprovalFlows: boolean, history: ReturnType, ) { - if (hasApprovalFlows) { + const hasNoConfirmations = confirmations?.length <= 0 || !confirmationId; + + if (hasApprovalFlows && hasNoConfirmations) { history.replace(`${CONFIRMATION_V_NEXT_ROUTE}`); return; } - if (confirmations?.length <= 0 || !confirmationId) { + if (hasNoConfirmations) { return; } diff --git a/ui/pages/home/home.component.js b/ui/pages/home/home.component.js index df4ebaca0776..41f315a1fb5a 100644 --- a/ui/pages/home/home.component.js +++ b/ui/pages/home/home.component.js @@ -306,9 +306,9 @@ export default class Home extends PureComponent { history.push(AWAITING_SWAP_ROUTE); } else if (canRedirect && (haveSwapsQuotes || swapsFetchParams)) { history.push(PREPARE_SWAP_ROUTE); - } else if (pendingApprovals.length) { + } else if (pendingApprovals.length || hasApprovalFlows) { navigateToConfirmation( - pendingApprovals[0].id, + pendingApprovals?.[0]?.id, pendingApprovals, hasApprovalFlows, history, diff --git a/ui/pages/permissions-connect/permissions-connect.component.js b/ui/pages/permissions-connect/permissions-connect.component.js index abb75ad747df..15afcc43acb0 100644 --- a/ui/pages/permissions-connect/permissions-connect.component.js +++ b/ui/pages/permissions-connect/permissions-connect.component.js @@ -126,6 +126,9 @@ export default class PermissionConnect extends Component { this.props.permissionsRequest, ), permissionsApproved: null, + origin: this.props.origin, + targetSubjectMetadata: this.props.targetSubjectMetadata || {}, + snapsInstallPrivacyWarningShown: this.props.snapsInstallPrivacyWarningShown, }; componentDidMount() { @@ -148,6 +151,7 @@ export default class PermissionConnect extends Component { history.replace(DEFAULT_ROUTE); return; } + // if this is an incremental permission request for permitted chains, skip the account selection if ( permissionsRequest?.diff?.permissionDiffMap?.[ @@ -156,6 +160,7 @@ export default class PermissionConnect extends Component { ) { history.replace(confirmPermissionPath); } + if (history.location.pathname === connectPath && !isRequestingAccounts) { switch (requestType) { case 'wallet_installSnap': @@ -177,8 +182,17 @@ export default class PermissionConnect extends Component { } componentDidUpdate(prevProps) { - const { permissionsRequest, lastConnectedInfo, origin } = this.props; - const { redirecting } = this.state; + const { permissionsRequest, lastConnectedInfo, targetSubjectMetadata } = + this.props; + const { redirecting, origin } = this.state; + + // We cache the last known good targetSubjectMetadata since it may be null when the approval is cleared + if ( + targetSubjectMetadata?.origin && + prevProps.targetSubjectMetadata?.origin !== targetSubjectMetadata?.origin + ) { + this.setState({ targetSubjectMetadata }); + } if (!permissionsRequest && prevProps.permissionsRequest && !redirecting) { const accountsLastApprovedTime = @@ -264,7 +278,7 @@ export default class PermissionConnect extends Component { } renderTopBar(permissionsRequestId) { - const { targetSubjectMetadata } = this.props; + const { targetSubjectMetadata } = this.state; const handleCancelFromHeader = () => { this.cancelPermissionsRequest(permissionsRequestId); }; @@ -321,12 +335,14 @@ export default class PermissionConnect extends Component { rejectPendingApproval, setSnapsInstallPrivacyWarningShownStatus, approvePermissionsRequest, - snapsInstallPrivacyWarningShown, - origin, history, } = this.props; - const { selectedAccountAddresses, permissionsApproved, redirecting } = - this.state; + const { + selectedAccountAddresses, + permissionsApproved, + redirecting, + snapsInstallPrivacyWarningShown, + } = this.state; const isRequestingSnap = isSnapId(permissionsRequest?.metadata?.origin); @@ -368,7 +384,7 @@ export default class PermissionConnect extends Component { rejectPermissionsRequest={(requestId) => this.cancelPermissionsRequest(requestId) } - activeTabOrigin={origin} + activeTabOrigin={this.state.origin} request={permissionsRequest} permissionsRequestId={permissionsRequestId} approveConnection={this.approveConnection} diff --git a/ui/pages/swaps/prepare-swap-page/prepare-swap-page.js b/ui/pages/swaps/prepare-swap-page/prepare-swap-page.js index a100b490b4d6..f911986dc88f 100644 --- a/ui/pages/swaps/prepare-swap-page/prepare-swap-page.js +++ b/ui/pages/swaps/prepare-swap-page/prepare-swap-page.js @@ -1065,7 +1065,7 @@ export default function PrepareSwapPage({ marginTop={2} fontWeight={FontWeight.Normal} onClick={() => { - openBridgeExperience('Swaps', fromToken); + openBridgeExperience('Swaps', selectedFromToken); }} target="_blank" data-testid="prepare-swap-page-cross-chain-swaps-link"