Skip to content

Commit

Permalink
updated index
Browse files Browse the repository at this point in the history
  • Loading branch information
NidhiKJha authored and darkwing committed May 8, 2024
1 parent 9a64150 commit ef8a63d
Showing 1 changed file with 29 additions and 31 deletions.
60 changes: 29 additions & 31 deletions ui/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -194,38 +194,36 @@ async function startApp(metamaskState, backgroundConnection, opts) {
},
};

if (process.env.MULTICHAIN) {
// This block autoswitches chains based on the last chain used
// for a given dapp, when there are no pending confimrations
// This allows the user to be connected on one chain
// for one dapp, and automatically change for another
const state = store.getState();
const networkIdToSwitchTo = getNetworkToAutomaticallySwitchTo(state);
if (networkIdToSwitchTo) {
await store.dispatch(
actions.automaticallySwitchNetwork(
networkIdToSwitchTo,
getOriginOfCurrentTab(state),
),
);
} else if (getSwitchedNetworkDetails(state)) {
// It's possible that old details could exist if the user
// opened the toast but then didn't close it
// Clear out any existing switchedNetworkDetails
// if the user didn't just change the dapp network
await store.dispatch(actions.clearSwitchedNetworkDetails());
}
// This block autoswitches chains based on the last chain used
// for a given dapp, when there are no pending confimrations
// This allows the user to be connected on one chain
// for one dapp, and automatically change for another
const state = store.getState();
const networkIdToSwitchTo = getNetworkToAutomaticallySwitchTo(state);
if (networkIdToSwitchTo) {
await store.dispatch(
actions.automaticallySwitchNetwork(
networkIdToSwitchTo,
getOriginOfCurrentTab(state),
),
);
} else if (getSwitchedNetworkDetails(state)) {
// It's possible that old details could exist if the user
// opened the toast but then didn't close it
// Clear out any existing switchedNetworkDetails
// if the user didn't just change the dapp network
await store.dispatch(actions.clearSwitchedNetworkDetails());
}

// Register this window as the current popup
// and set in background state
if (
getUseRequestQueue(state) &&
getEnvironmentType() === ENVIRONMENT_TYPE_POPUP
) {
const thisPopupId = Date.now();
global.metamask.id = thisPopupId;
await store.dispatch(actions.setCurrentExtensionPopupId(thisPopupId));
}
// Register this window as the current popup
// and set in background state
if (
getUseRequestQueue(state) &&
getEnvironmentType() === ENVIRONMENT_TYPE_POPUP
) {
const thisPopupId = Date.now();
global.metamask.id = thisPopupId;
await store.dispatch(actions.setCurrentExtensionPopupId(thisPopupId));
}

// start app
Expand Down

0 comments on commit ef8a63d

Please sign in to comment.