From 0dc84aafa710174fa4ad9569a18bf965ce3e45e7 Mon Sep 17 00:00:00 2001 From: Jiexi Luan Date: Wed, 18 Sep 2024 14:59:43 -0700 Subject: [PATCH] permission-page-container named vars --- .../permission-page-container.component.js | 25 ++++++++++--------- 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/ui/components/app/permission-page-container/permission-page-container.component.js b/ui/components/app/permission-page-container/permission-page-container.component.js index 27dbc9f71c32..b9f97c8a8ff7 100644 --- a/ui/components/app/permission-page-container/permission-page-container.component.js +++ b/ui/components/app/permission-page-container/permission-page-container.component.js @@ -141,21 +141,22 @@ export default class PermissionPageContainer extends Component { selectedAccounts, } = this.props; + const approvedAccounts = selectedAccounts.map( + (selectedAccount) => selectedAccount.address, + ) + + const permittedChainsPermission = _request.permissions[ + PermissionNames.permittedChains + ] + const approvedChainIds = permittedChainsPermission?.caveats.find( + (caveat) => caveat.type === CaveatTypes.restrictNetworkSwitching, + )?.value + const request = { ..._request, permissions: { ..._request.permissions }, - ...(_request.permissions.eth_accounts && { - approvedAccounts: selectedAccounts.map( - (selectedAccount) => selectedAccount.address, - ), - }), - ...(_request.permissions[PermissionNames.permittedChains] && { - approvedChainIds: _request.permissions[ - PermissionNames.permittedChains - ]?.caveats.find( - (caveat) => caveat.type === CaveatTypes.restrictNetworkSwitching, - )?.value, - }), + ...(_request.permissions.eth_accounts && { approvedAccounts }), + ...(_request.permissions[PermissionNames.permittedChains] && { approvedChainIds }), }; if (Object.keys(request.permissions).length > 0) {