From 270f74c209941c8226e0d290a943fbaf923e007b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Albert=20Oliv=C3=A9?= Date: Mon, 24 Jul 2023 15:14:56 +0200 Subject: [PATCH] [MMI] Connect MMI flow in one step less (#20143) * First approach to fix the issue that we are displaying one extra step * Fixed issues --- ui/pages/institutional/custody/custody.js | 156 +++++++++++----------- 1 file changed, 81 insertions(+), 75 deletions(-) diff --git a/ui/pages/institutional/custody/custody.js b/ui/pages/institutional/custody/custody.js index 07a171866..2c62d8df6 100644 --- a/ui/pages/institutional/custody/custody.js +++ b/ui/pages/institutional/custody/custody.js @@ -73,7 +73,7 @@ const CustodyPage = () => { const [jwtList, setJwtList] = useState([]); const [apiUrl, setApiUrl] = useState(''); const [addNewTokenClicked, setAddNewTokenClicked] = useState(false); - const [chainId, setChainId] = useState(0); + const [chainId, setChainId] = useState(parseInt(currentChainId, 16)); const [connectRequest, setConnectRequest] = useState(undefined); const [accounts, setAccounts] = useState(); const address = useSelector(getSelectedAddress); @@ -133,7 +133,7 @@ const CustodyPage = () => { @@ -476,7 +456,33 @@ const CustodyPage = () => { block data-testid="jwt-form-connect-button" size={BUTTON_SIZES.LG} - onClick={connect} + onClick={async () => { + try { + setConnectError(''); + + const accountsValue = await dispatch( + mmiActions.getCustodianAccounts( + currentJwt || jwtList[0], + apiUrl, + selectedCustodianType, + true, + ), + ); + + setAccounts(accountsValue); + trackEvent({ + category: MetaMetricsEventCategory.MMI, + event: MetaMetricsEventName.CustodianConnected, + properties: { + custodian: selectedCustodianName, + apiUrl, + rpc: Boolean(connectRequest), + }, + }); + } catch (e) { + handleConnectError(e); + } + }} disabled={ !selectedCustodianName || (addNewTokenClicked && !currentJwt)