Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge master into v12.11.0 #29928

Merged
merged 4 commits into from
Jan 27, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- fix: increase gas limit validation threshold ([#29264](https://github.com/MetaMask/metamask-extension/pull/29264))
- test: [POM] Privacy Mode spec ([#29263](https://github.com/MetaMask/metamask-extension/pull/29263))

## [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))
Expand Down Expand Up @@ -5733,7 +5740,8 @@ Update styles and spacing on the critical error page ([#20350](https://github.c


[Unreleased]: https://github.com/MetaMask/metamask-extension/compare/v12.11.0...HEAD
[12.11.0]: https://github.com/MetaMask/metamask-extension/compare/v12.10.1...v12.11.0
[12.11.0]: https://github.com/MetaMask/metamask-extension/compare/v12.10.2...v12.11.0
[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
Expand Down
13 changes: 13 additions & 0 deletions ui/pages/confirmations/hooks/useConfirmationNavigation.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
6 changes: 4 additions & 2 deletions ui/pages/confirmations/hooks/useConfirmationNavigation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,14 @@ export function navigateToConfirmation(
hasApprovalFlows: boolean,
history: ReturnType<typeof useHistory>,
) {
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;
}

Expand Down
4 changes: 2 additions & 2 deletions ui/pages/home/home.component.js
Original file line number Diff line number Diff line change
Expand Up @@ -315,9 +315,9 @@ export default class Home extends PureComponent {
history.push(PREPARE_SWAP_ROUTE);
} else if (canRedirect && haveBridgeQuotes) {
history.push(CROSS_CHAIN_SWAP_ROUTE + PREPARE_SWAP_ROUTE);
} else if (pendingApprovals.length) {
} else if (pendingApprovals.length || hasApprovalFlows) {
navigateToConfirmation(
pendingApprovals[0].id,
pendingApprovals?.[0]?.id,
pendingApprovals,
hasApprovalFlows,
history,
Expand Down
32 changes: 24 additions & 8 deletions ui/pages/permissions-connect/permissions-connect.component.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -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?.[
Expand All @@ -156,6 +160,7 @@ export default class PermissionConnect extends Component {
) {
history.replace(confirmPermissionPath);
}

if (history.location.pathname === connectPath && !isRequestingAccounts) {
switch (requestType) {
case 'wallet_installSnap':
Expand All @@ -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 =
Expand Down Expand Up @@ -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);
};
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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}
Expand Down
Loading