-
Notifications
You must be signed in to change notification settings - Fork 400
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
Mezoification: Add base state and UI elements #3785
Open
hyphenized
wants to merge
17
commits into
main
Choose a base branch
from
campaign-1
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
5bb9810
Add active campaigns to UI state
hyphenized 0f25b31
Add onDismiss option to notifications dispatcher
hyphenized 0a7d996
Added campaign eligibility checks and notifications
hyphenized 0ac12cf
Watch for borrowing transactions
hyphenized 141f7de
Expose analytics uuid
hyphenized 9c2ac79
Add campaign banner
hyphenized 52bd1e9
Fix broken notifications handlers
hyphenized ee66fe0
Update notifications text
hyphenized 6422370
Add campaign banners
hyphenized 789b942
Fix flaky test
hyphenized ef04377
Add new protocol ui badge
hyphenized ae1f3c5
Update banners
hyphenized 09361e2
Update display hierarchy
hyphenized 77f3ba0
Remove stale comment
hyphenized 4a9f079
Default to show test network visibility
hyphenized e56f90d
Do not allow hidden testnet to remain as current network
hyphenized 4671a6e
Force-toggle testnets visibility in network switcher (#3793)
Shadowfiend File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,7 +16,10 @@ import { | |
import { EVMNetwork, sameNetwork } from "@tallyho/tally-background/networks" | ||
import { selectCurrentNetwork } from "@tallyho/tally-background/redux-slices/selectors" | ||
import { selectShowTestNetworks } from "@tallyho/tally-background/redux-slices/ui" | ||
import { selectProductionEVMNetworks } from "@tallyho/tally-background/redux-slices/selectors/networks" | ||
import { | ||
selectProductionEVMNetworks, | ||
selectTestnetNetworks, | ||
} from "@tallyho/tally-background/redux-slices/selectors/networks" | ||
import { useTranslation } from "react-i18next" | ||
import { useBackgroundSelector } from "../../hooks" | ||
import TopMenuProtocolListItem from "./TopMenuProtocolListItem" | ||
|
@@ -25,7 +28,6 @@ import { i18n } from "../../_locales/i18n" | |
|
||
export const productionNetworkInfo = { | ||
[ETHEREUM.chainID]: i18n.t("protocol.mainnet"), | ||
[MEZO_TESTNET.chainID]: i18n.t("protocol.mezoTestnet"), | ||
[POLYGON.chainID]: i18n.t("protocol.l2"), | ||
[OPTIMISM.chainID]: i18n.t("protocol.l2"), | ||
[ARBITRUM_ONE.chainID]: i18n.t("protocol.l2"), | ||
|
@@ -37,35 +39,26 @@ export const productionNetworkInfo = { | |
|
||
const disabledChainIDs = [ARBITRUM_NOVA.chainID] | ||
|
||
const testNetworks = [ | ||
{ | ||
network: SEPOLIA, | ||
info: i18n.t("protocol.testnet"), | ||
isDisabled: false, | ||
}, | ||
{ | ||
network: ARBITRUM_SEPOLIA, | ||
info: i18n.t("protocol.testnet"), | ||
isDisabled: false, | ||
}, | ||
] | ||
const testNetworkInfo = { | ||
[MEZO_TESTNET.chainID]: i18n.t("protocol.mezoTestnet"), | ||
[SEPOLIA.chainID]: i18n.t("protocol.testnet"), | ||
[ARBITRUM_SEPOLIA.chainID]: i18n.t("protocol.testnet"), | ||
} | ||
|
||
type TopMenuProtocolListProps = { | ||
onProtocolChange: (network: EVMNetwork) => void | ||
} | ||
|
||
/** | ||
* Places Ethereum and Mezo network above other networks | ||
* Places Mezo network above other networks | ||
*/ | ||
const sortByNetworkPriority = (a: EVMNetwork, b: EVMNetwork) => { | ||
const getPriority = (network: EVMNetwork) => { | ||
switch (true) { | ||
case sameNetwork(ETHEREUM, network): | ||
return 0 | ||
case sameNetwork(MEZO_TESTNET, network): | ||
return 1 | ||
return 0 | ||
default: | ||
return 2 | ||
return 1 | ||
} | ||
} | ||
return getPriority(a) - getPriority(b) | ||
|
@@ -78,15 +71,16 @@ export default function TopMenuProtocolList({ | |
const currentNetwork = useBackgroundSelector(selectCurrentNetwork) | ||
const showTestNetworks = useBackgroundSelector(selectShowTestNetworks) | ||
const productionNetworks = useBackgroundSelector(selectProductionEVMNetworks) | ||
const testnetNetworks = useBackgroundSelector(selectTestnetNetworks) | ||
|
||
const builtinNetworks = productionNetworks | ||
.filter(isBuiltInNetwork) | ||
.sort(sortByNetworkPriority) | ||
const builtinNetworks = productionNetworks.filter(isBuiltInNetwork) | ||
|
||
const customNetworks = productionNetworks.filter( | ||
(network) => !isBuiltInNetwork(network), | ||
) | ||
|
||
const testNetworks = testnetNetworks.sort(sortByNetworkPriority) | ||
|
||
return ( | ||
<div className="container"> | ||
<div className="networks_list"> | ||
|
@@ -131,14 +125,13 @@ export default function TopMenuProtocolList({ | |
</div> | ||
<div className="divider_line" /> | ||
</li> | ||
{testNetworks.map((info) => ( | ||
{testNetworks.map((network) => ( | ||
<TopMenuProtocolListItem | ||
isSelected={sameNetwork(currentNetwork, info.network)} | ||
key={info.network.name} | ||
network={info.network} | ||
info={info.info} | ||
isSelected={sameNetwork(currentNetwork, network)} | ||
key={network.name} | ||
network={network} | ||
info={testNetworkInfo[network.chainID]} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I know this is descriptively named |
||
onSelect={onProtocolChange} | ||
isDisabled={info.isDisabled ?? false} | ||
/> | ||
))} | ||
</> | ||
|
File renamed without changes
File renamed without changes
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Ngl I would love to kill this sort function. Its main purpose is to boost matsnet in the list if people have previously added it, is that right?
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.
Yup that's pretty much all it does. Currently testnets are hardcoded so we could remove it and use the hardcoded order but that seems a bit dirty 👀
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.
Does it work even if the user had previously added it as a custom network? If so, then let's rely on the hardcoded order for now.