Skip to content

Commit 8480950

Browse files
committed
Squashed commit of the following:
commit 3b39af1 Author: Jorge Luis <[email protected]> Date: Tue Mar 11 10:00:17 2025 -0500 Rename campaigns selector commit 46214cb Author: Jorge Luis <[email protected]> Date: Tue Mar 11 09:59:58 2025 -0500 Rename type guard commit 1895a67 Author: Jorge Luis <[email protected]> Date: Tue Mar 11 09:57:24 2025 -0500 Change notifications toggler description commit 0c6b995 Author: Jorge Luis <[email protected]> Date: Tue Mar 11 09:48:26 2025 -0500 Remove testnet sorting, use hardcoded order commit 9c6bbd8 Author: Jorge Luis <[email protected]> Date: Tue Mar 11 09:47:45 2025 -0500 Guard safe switch of test network commit 23971ce Author: Jorge Luis <[email protected]> Date: Tue Mar 11 09:36:07 2025 -0500 Update copy commit 646ccf2 Merge: 4671a6e 62a2801 Author: Antonio Salazar Cardozo <[email protected]> Date: Tue Mar 11 08:47:08 2025 -0400 Move active campaign concerns to campaign service (#3794) This moves campaign related logic out of the main service into a dedicated service. It also causes dismissing campaign banners to clear and stop triggering notifications about the same topic. Campaign state is kept within the service db and updates are pushed to state in redux. Latest build: [extension-builds-3794](https://github.com/tahowallet/extension/suites/35331061341/artifacts/2708368343) (as of Fri, 07 Mar 2025 03:08:56 GMT).
1 parent 63d4368 commit 8480950

File tree

9 files changed

+26
-37
lines changed

9 files changed

+26
-37
lines changed

background/networks.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -423,6 +423,6 @@ export const isEnrichedEVMTransactionRequest = (
423423
): transactionRequest is EnrichedEVMTransactionRequest =>
424424
"annotation" in transactionRequest
425425

426-
export const isTransactionWithReceipt = (
426+
export const isConfirmedEVMTransaction = (
427427
transaction: AnyEVMTransaction,
428428
): transaction is ConfirmedEVMTransaction => "status" in transaction

background/redux-slices/selectors/uiSelectors.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ export const selectShowingActivityDetail = createSelector(
3636
},
3737
)
3838

39-
export const selectActiveCampaigns = createSelector(
39+
export const selectCampaigns = createSelector(
4040
(state: RootState) => state.ui.campaigns,
4141
(campaigns) => campaigns,
4242
)

background/redux-slices/ui.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -400,17 +400,17 @@ export const setSelectedNetwork = createBackgroundAsyncThunk(
400400

401401
export const toggleShowTestNetworks = createBackgroundAsyncThunk(
402402
"ui/toggleShowTestNetworks",
403-
async (value: boolean, { dispatch, getState }) => {
403+
async (updatedValue: boolean, { dispatch, getState }) => {
404404
const state = getState() as RootState
405405

406406
const currentNetwork = state.ui.selectedAccount.network
407407

408408
// If user is on one of the built-in test networks, don't leave them stranded
409-
if (TEST_NETWORK_BY_CHAIN_ID.has(currentNetwork.chainID)) {
409+
if (!updatedValue && TEST_NETWORK_BY_CHAIN_ID.has(currentNetwork.chainID)) {
410410
dispatch(setSelectedNetwork(ETHEREUM))
411411
}
412412

413-
await emitter.emit("toggleShowTestNetworks", value)
413+
await emitter.emit("toggleShowTestNetworks", updatedValue)
414414
},
415415
)
416416

background/services/campaign/index.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import PreferenceService from "../preferences"
1212
import { ServiceCreatorFunction, ServiceLifecycleEvents } from "../types"
1313
import { CampaignDatabase, getOrCreateDB } from "./db"
1414
import MEZO_CAMPAIGN, { MezoClaimStatus } from "./matsnet-nft"
15-
import { isTransactionWithReceipt } from "../../networks"
15+
import { isConfirmedEVMTransaction } from "../../networks"
1616
import { Campaigns } from "./types"
1717

1818
dayjs.extend(isBetween)
@@ -83,7 +83,7 @@ export default class CampaignService extends BaseService<Events> {
8383
}
8484

8585
if (
86-
isTransactionWithReceipt(transaction) &&
86+
isConfirmedEVMTransaction(transaction) &&
8787
checkIsBorrowingTx(transaction)
8888
) {
8989
await this.db.updateCampaignData(MEZO_CAMPAIGN.id, {

ui/_locales/en/messages.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -563,7 +563,7 @@
563563
},
564564
"mainMenu": "Settings",
565565
"signing": "Signing",
566-
"showNotifications": "Show Mezo notifications",
566+
"showNotifications": "Show notifications",
567567
"hideSmallAssetBalance": "Hide asset balances under {{sign}}{{amount}}",
568568
"setAsDefault": "Use Taho as default wallet",
569569
"enableTestNetworks": "Show testnet networks",

ui/components/TopMenu/TopMenuProtocolList.tsx

+9-20
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import {
1212
POLYGON,
1313
ROOTSTOCK,
1414
MEZO_TESTNET,
15+
TEST_NETWORK_BY_CHAIN_ID,
1516
} from "@tallyho/tally-background/constants"
1617
import { EVMNetwork, sameNetwork } from "@tallyho/tally-background/networks"
1718
import { selectCurrentNetwork } from "@tallyho/tally-background/redux-slices/selectors"
@@ -26,7 +27,7 @@ import TopMenuProtocolListItem from "./TopMenuProtocolListItem"
2627
import TopMenuProtocolListFooter from "./TopMenuProtocolListFooter"
2728
import { i18n } from "../../_locales/i18n"
2829

29-
export const productionNetworkInfo = {
30+
export const productionNetworkDescription = {
3031
[ETHEREUM.chainID]: i18n.t("protocol.mainnet"),
3132
[POLYGON.chainID]: i18n.t("protocol.l2"),
3233
[OPTIMISM.chainID]: i18n.t("protocol.l2"),
@@ -39,7 +40,7 @@ export const productionNetworkInfo = {
3940

4041
const disabledChainIDs = [ARBITRUM_NOVA.chainID]
4142

42-
const testNetworkInfo = {
43+
const testNetworkDescription = {
4344
[MEZO_TESTNET.chainID]: i18n.t("protocol.mezoTestnet"),
4445
[SEPOLIA.chainID]: i18n.t("protocol.testnet"),
4546
[ARBITRUM_SEPOLIA.chainID]: i18n.t("protocol.testnet"),
@@ -49,21 +50,6 @@ type TopMenuProtocolListProps = {
4950
onProtocolChange: (network: EVMNetwork) => void
5051
}
5152

52-
/**
53-
* Places Mezo network above other networks
54-
*/
55-
const sortByNetworkPriority = (a: EVMNetwork, b: EVMNetwork) => {
56-
const getPriority = (network: EVMNetwork) => {
57-
switch (true) {
58-
case sameNetwork(MEZO_TESTNET, network):
59-
return 0
60-
default:
61-
return 1
62-
}
63-
}
64-
return getPriority(a) - getPriority(b)
65-
}
66-
6753
export default function TopMenuProtocolList({
6854
onProtocolChange,
6955
}: TopMenuProtocolListProps): ReactElement {
@@ -79,7 +65,10 @@ export default function TopMenuProtocolList({
7965
(network) => !isBuiltInNetwork(network),
8066
)
8167

82-
const testNetworks = testnetNetworks.sort(sortByNetworkPriority)
68+
const testNetworks = [...TEST_NETWORK_BY_CHAIN_ID].flatMap(
69+
(chainId) =>
70+
testnetNetworks.find((network) => network.chainID === chainId) ?? [],
71+
)
8372

8473
return (
8574
<div className="container">
@@ -91,7 +80,7 @@ export default function TopMenuProtocolList({
9180
key={network.name}
9281
network={network}
9382
info={
94-
productionNetworkInfo[network.chainID] ||
83+
productionNetworkDescription[network.chainID] ||
9584
t("protocol.compatibleChain")
9685
}
9786
onSelect={onProtocolChange}
@@ -130,7 +119,7 @@ export default function TopMenuProtocolList({
130119
isSelected={sameNetwork(currentNetwork, network)}
131120
key={network.name}
132121
network={network}
133-
info={testNetworkInfo[network.chainID]}
122+
info={testNetworkDescription[network.chainID]}
134123
onSelect={onProtocolChange}
135124
/>
136125
))}

ui/components/Wallet/Banner/WalletCampaignBanner.tsx

+5-5
Original file line numberDiff line numberDiff line change
@@ -17,19 +17,19 @@ const claimStateBanners = {
1717
eligible: {
1818
bannerId: MEZO_CAMPAIGN.bannerIds.eligible,
1919
title: "Get the gift of sats",
20-
body: "Enjoy 20,000 sats on the Mezo testnet. Try borrow and get an exclusive Taho x Mezo NFT.",
20+
body: "Enjoy 20,000 sats on the Mezo testnet. Try Mezo borrow and get an exclusive Taho x Mezo NFT.",
2121
action: "Login to claim",
2222
},
2323
"can-borrow": {
2424
bannerId: MEZO_CAMPAIGN.bannerIds.canBorrow,
25-
title: "Bank on yourself",
26-
body: "Use testnet sats to borrow mUSD and spend in the Mezo store. An exclusive NFT awaits.",
25+
title: "Put those sats to work",
26+
body: "Use testnet sats to borrow mUSD and spend it in the Mezo Market. The exclusive NFT awaits.",
2727
action: "Borrow mUSD",
2828
},
2929
"can-claim-nft": {
3030
bannerId: MEZO_CAMPAIGN.bannerIds.canClaimNFT,
31-
title: "Treat yourself with mUSD",
32-
body: "Spend testnet mUSD in the Mezo store. How about an exclusive Taho x Mezo NFT?",
31+
title: "The exclusive NFT awaits",
32+
body: "Spend testnet mUSD in the Mezo Market. How about an exclusive Taho x Mezo NFT?",
3333
action: "Visit the Mezo Store",
3434
},
3535
} as const

ui/pages/Settings/SettingsAddCustomAsset.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ import SharedNetworkIcon from "../../components/Shared/SharedNetworkIcon"
3434
import SharedPageHeader from "../../components/Shared/SharedPageHeader"
3535
import SharedSlideUpMenu from "../../components/Shared/SharedSlideUpMenu"
3636
import SharedTooltip from "../../components/Shared/SharedTooltip"
37-
import { productionNetworkInfo } from "../../components/TopMenu/TopMenuProtocolList"
37+
import { productionNetworkDescription } from "../../components/TopMenu/TopMenuProtocolList"
3838
import TopMenuProtocolListItem from "../../components/TopMenu/TopMenuProtocolListItem"
3939
import { useBackgroundDispatch, useBackgroundSelector } from "../../hooks"
4040
import { useSetState } from "../../hooks/react-hooks"
@@ -270,7 +270,7 @@ export default function SettingsAddCustomAsset(): ReactElement {
270270
}}
271271
showSelectedText={false}
272272
info={
273-
productionNetworkInfo[network.chainID] ||
273+
productionNetworkDescription[network.chainID] ||
274274
sharedT("protocol.compatibleChain")
275275
}
276276
/>

ui/pages/Wallet.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import dayjs from "dayjs"
33
import isBetween from "dayjs/plugin/isBetween"
44

55
import {
6-
selectActiveCampaigns,
6+
selectCampaigns,
77
selectCurrentAccountActivities,
88
selectCurrentAccountBalances,
99
selectCurrentNetwork,
@@ -50,7 +50,7 @@ export default function Wallet(): ReactElement {
5050
const claimState = useBackgroundSelector((state) => state.claim)
5151
const selectedNetwork = useBackgroundSelector(selectCurrentNetwork)
5252
const showUnverifiedAssets = useBackgroundSelector(selectShowUnverifiedAssets)
53-
const activeCampaigns = useBackgroundSelector(selectActiveCampaigns)
53+
const activeCampaigns = useBackgroundSelector(selectCampaigns)
5454

5555
useEffect(() => {
5656
dispatch(

0 commit comments

Comments
 (0)