From 3376ea4e95ca8a8d69dc16978460c1aa7b37be5d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Albert=20Oliv=C3=A9?= Date: Thu, 31 Aug 2023 17:45:07 +0200 Subject: [PATCH] [MMI] Adding missing logic to handle custodian approval in token allowance (#20662) --- app/scripts/controllers/mmi-controller.js | 7 +-- ui/pages/confirm-approve/confirm-approve.js | 10 ++++- ui/selectors/institutional/selectors.js | 47 ++++++++++++++------- 3 files changed, 44 insertions(+), 20 deletions(-) diff --git a/app/scripts/controllers/mmi-controller.js b/app/scripts/controllers/mmi-controller.js index bfeca6a24..355d4ad27 100644 --- a/app/scripts/controllers/mmi-controller.js +++ b/app/scripts/controllers/mmi-controller.js @@ -641,9 +641,10 @@ export default class MMIController extends EventEmitter { async setAccountAndNetwork(origin, address, chainId) { await this.appStateController.getUnlockPromise(true); + const addressToLowerCase = address.toLowerCase(); const selectedAddress = this.preferencesController.getSelectedAddress(); - if (selectedAddress.toLowerCase() !== address.toLowerCase()) { - this.preferencesController.setSelectedAddress(address); + if (selectedAddress.toLowerCase() !== addressToLowerCase) { + this.preferencesController.setSelectedAddress(addressToLowerCase); } const selectedChainId = parseInt( this.networkController.state.providerConfig.chainId, @@ -667,7 +668,7 @@ export default class MMIController extends EventEmitter { getPermissionBackgroundApiMethods( this.permissionController, - ).addPermittedAccount(origin, address); + ).addPermittedAccount(origin, addressToLowerCase); return true; } diff --git a/ui/pages/confirm-approve/confirm-approve.js b/ui/pages/confirm-approve/confirm-approve.js index 0faacf441..04782895c 100644 --- a/ui/pages/confirm-approve/confirm-approve.js +++ b/ui/pages/confirm-approve/confirm-approve.js @@ -176,7 +176,14 @@ export default function ConfirmApprove({ if (assetStandard === undefined) { return ; } - if (assetStandard === TokenStandard.ERC20) { + + let tokenAllowanceImprovements = true; + + ///: BEGIN:ONLY_INCLUDE_IN(build-mmi) + tokenAllowanceImprovements = false; + ///: END:ONLY_INCLUDE_IN + + if (tokenAllowanceImprovements && assetStandard === TokenStandard.ERC20) { return ( @@ -224,6 +231,7 @@ export default function ConfirmApprove({ ); } + return (