-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
fix(per-dapp-selected-network): restore per-dapp network picker in permissions view #13686
base: main
Are you sure you want to change the base?
Conversation
…ature can work when its feature flags are enabled make sure to include all env vars: export MM_MULTICHAIN_V1_ENABLED="true" export MM_CHAIN_PERMISSIONS="true" export MM_PER_DAPP_SELECTED_NETWORK="1" export MULTICHAIN_V1="true"
- Replace direct checks of process.env.MM_PER_DAPP_SELECTED_NETWORK in AccountPermissionsConnected.tsx with the isPerDappSelectedNetworkEnabled function. - Update ethereum-chain-utils.js to use isPerDappSelectedNetworkEnabled when switching networks. - Modify selectedNetworkController selectors to use isPerDappSelectedNetworkEnabled for feature flag checks. - Add the isPerDappSelectedNetworkEnabled utility in util/networks/index.js. This change centralizes the per-DApp network logic for better consistency and maintainability.
Add a touchable favicon to the permission summary header that enables network switching for dapps. This combines the dapp's identity (favicon/token) with network selection in a single interactive component. - Replace static WebsiteIcon with touchable BadgeWrapper pattern - Add network badge to indicate current network - Enable network switching via network selector bottom sheet - Add fallback to AvatarToken when favicon unavailable - Guard implementation behind per-dapp network selection feature flag - Preserve original WebsiteIcon when feature disabled This matches the interaction pattern from AccountPermissionsConnected, providing a consistent way to manage dapp-specific networks across the app.
…flag The domain logo container view was incorrectly placed outside the per-dapp network feature flag check. This change moves the container view inside the feature flag condition to ensure consistent UI behavior when the feature is enabled/disabled. - Moved View wrapper inside isPerDappSelectedNetworkEnabled() check - Simplified conditional rendering logic - Maintains existing functionality but with proper feature flag control
…permission sumamry is displayed, keep showing the WebsiteIcon rather than the AvatarFavicon.
…1Enabled rather than its 'corresponding' env variable MULTICHAIN_V1
CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes. |
|
|
Remove the permission check for non-permitted network flows in dapps, paving the way for the per-dapp-selected-network feature. Temporary screens handling these flows are pending removal upon feature completion.
- Replace global network selectors with origin-specific useNetworkInfo hook - Update network name and image source to be origin-aware - Update test snapshot for network name changes
- Add origin prop to AccountFromToInfoCard for per-dapp network info - Add debug logs for transaction review flow
In regards to switching from the wallet, 008 bug pointed it didnt, but per dapp, it looks like it does as expected
|
// FIXME: this could be the wrong selector, probably needs to be per dapp (per origin) | ||
// console.log('>>> AddressFrom origin', origin); | ||
const { networkName, networkImageSource } = useNetworkInfo(origin); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤔 if you're passing in the origin here, the useNetworkInfo
selector should be selecting the correct state based on that parameter. Is the comment outdated?
return isPerDappSelectedNetworkEnabled() ? ( | ||
<View style={[styles.domainLogoContainer, styles.assetLogoContainer]}> | ||
<TouchableOpacity | ||
onPress={switchNetwork} | ||
testID={ConnectedAccountsSelectorsIDs.NETWORK_PICKER} | ||
> | ||
<BadgeWrapper | ||
badgeElement={ | ||
<Badge | ||
variant={BadgeVariant.Network} | ||
name={networkName} | ||
imageSource={networkImageSource} | ||
/> | ||
} | ||
> | ||
{icon ? ( | ||
<AvatarFavicon | ||
imageSource={{ | ||
uri: typeof icon === 'string' ? icon : icon?.uri, | ||
}} | ||
size={AvatarSize.Md} | ||
/> | ||
) : ( | ||
<AvatarToken | ||
name={iconTitle} | ||
isHaloEnabled | ||
size={AvatarSize.Md} | ||
/> | ||
)} | ||
</BadgeWrapper> | ||
</TouchableOpacity> | ||
</View> | ||
) : ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why is this conditional required? Not understanding what's changed here. Could you explain?
@@ -700,8 +642,6 @@ export const BrowserTab: React.FC<BrowserTabProps> = ({ | |||
name: siteInfo.title, | |||
url: getMaskedUrl(siteInfo.url, sessionENSNamesRef.current), | |||
}); | |||
|
|||
checkTabPermissions(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why is this no longer required?
} else { | ||
const { networkClientId } = rpcEndpoints[defaultRpcEndpointIndex]; | ||
try { | ||
await MultichainNetworkController.setActiveNetwork(networkClientId); | ||
} catch (error) { | ||
Logger.error(new Error(`Error in setActiveNetwork: ${error}`)); | ||
Logger.error(new Error(`Error i setActiveNetwork: ${error}`)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤔 whats this change about?
const relevantNetworkClientId = | ||
domainNetworkClientId || globalNetworkClientId; | ||
|
||
const relevantChainId = chainIdToUse || chainId; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const relevantChainId = chainIdToUse || chainId; | |
const relevantChainId = chainIdToUse || globalChainId; |
@@ -77,6 +83,34 @@ const selectProviderNetworkImageSource = createSelector( | |||
}), | |||
); | |||
|
|||
const selectChainIdToUse = createSelector( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const selectChainIdToUse = createSelector( | |
const selectOriginSelectedChainId = createSelector( |
Description
This PR fixes the regression on PR #10788, and then restores the network picker functionality in the permissions view that was previously removed, while properly integrating with the per-dapp network selection feature. Changes include:
Add a touchable favicon to the permission summary header that enables network
switching for dapps. This combines the dapp's identity (favicon/token) with
network selection in a single interactive component.
Related issues
Contributes to: https://github.com/MetaMask/MetaMask-planning/issues/4104
Manual testing steps
Testing:
Make sure to include all env vars:
Screenshots/Recordings
Pre-merge author checklist
Pre-merge reviewer checklist