Skip to content

Commit

Permalink
Drop ENABLE_UPDATED_DAPP_CONNECTIONS feature flag
Browse files Browse the repository at this point in the history
It is enabled and shall remain so!
  • Loading branch information
Shadowfiend committed Aug 11, 2023
1 parent 6b8e4b0 commit 8537e3e
Show file tree
Hide file tree
Showing 15 changed files with 65 additions and 584 deletions.
1 change: 0 additions & 1 deletion .env.defaults
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,3 @@ SUPPORT_SWAP_QUOTE_REFRESH=false
SUPPORT_ACHIEVEMENTS_BANNER=false
SUPPORT_NFT_SEND=false
USE_MAINNET_FORK=false
ENABLE_UPDATED_DAPP_CONNECTIONS=true
2 changes: 0 additions & 2 deletions background/features.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ export const RuntimeFlag = {
SUPPORT_SWAP_QUOTE_REFRESH: process.env.SUPPORT_SWAP_QUOTE_REFRESH === "true",
SUPPORT_CUSTOM_NETWORKS: process.env.SUPPORT_CUSTOM_NETWORKS === "true",
SUPPORT_CUSTOM_RPCS: process.env.SUPPORT_CUSTOM_RPCS === "true",
ENABLE_UPDATED_DAPP_CONNECTIONS:
process.env.ENABLE_UPDATED_DAPP_CONNECTIONS === "true",
} as const

type BuildTimeFlagType = keyof typeof BuildTimeFlag
Expand Down
15 changes: 0 additions & 15 deletions ui/_locales/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -797,15 +797,6 @@
},
"reviewSwap": "Review swap"
},
"switchWallet": {
"title": "Want to use another wallet instead?",
"tooltip": "You are seeing this because Taho is set as default wallet, you can change this option in the main menu.",
"confirmSwitchWallet": "Yes, switch wallet",
"notDefaultWalletMessage": "Taho not Default",
"disableWalletExplainer": "We disabled Taho as the default wallet for you. You can always re-enable it from Menu ☰ at any time.",
"useTahoAsDefaultPrompt": "Use Taho as default wallet",
"closeButton": "Close window"
},
"toggle": {
"collapse": "Collapse",
"viewAll": "View all"
Expand Down Expand Up @@ -921,12 +912,6 @@
}
},
"dAppConnect": {
"switchWallet": {
"title": "Taho not Default",
"descFirstPart": "We disabled Taho as default wallet for you. You can always enable it back from Settings",
"descSecondPart": "at any time.",
"toggleTitle": "Use Taho as default wallet"
},
"defaultConnectionPopover": {
"title": "Connecting with Taho",
"activeWallet": "Your active wallet is Taho.",
Expand Down
132 changes: 4 additions & 128 deletions ui/components/TopMenu/TopMenu.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,5 @@
import React, { ReactElement, useState, useEffect, useCallback } from "react"
import { browser } from "@tallyho/tally-background"
import { PermissionRequest } from "@tallyho/provider-bridge-shared"
import { selectAllowedPages } from "@tallyho/tally-background/redux-slices/selectors"
import {
FeatureFlags,
isDisabled,
isEnabled,
} from "@tallyho/tally-background/features"
import { denyOrRevokePermission } from "@tallyho/tally-background/redux-slices/dapp"
import React, { ReactElement, useState } from "react"
import { FeatureFlags, isDisabled } from "@tallyho/tally-background/features"
import { useTranslation } from "react-i18next"
import { setSelectedNetwork } from "@tallyho/tally-background/redux-slices/ui"
import TopMenuProtocolSwitcher from "./TopMenuProtocolSwitcher"
Expand All @@ -16,10 +8,9 @@ import TopMenuProfileButton from "./TopMenuProfileButton"
import BonusProgramModal from "../BonusProgram/BonusProgramModal"
import AccountsNotificationPanel from "../AccountsNotificationPanel/AccountsNotificationPanel"
import SharedSlideUpMenu from "../Shared/SharedSlideUpMenu"
import TopMenuConnectedDAppInfo from "./TopMenuConnectedDAppInfo"
import TopMenuProtocolList from "./TopMenuProtocolList"

import { useBackgroundDispatch, useBackgroundSelector } from "../../hooks"
import { useBackgroundDispatch } from "../../hooks"
import DAppConnection from "../DAppConnection/DAppConnection"

export default function TopMenu(): ReactElement {
Expand All @@ -29,80 +20,10 @@ export default function TopMenu(): ReactElement {
const [isNotificationsOpen, setIsNotificationsOpen] = useState(false)
const [isBonusProgramOpen, setIsBonusProgramOpen] = useState(false)

const [isActiveDAppConnectionInfoOpen, setIsActiveDAppConnectionInfoOpen] =
useState(false)

const dispatch = useBackgroundDispatch()

const [currentPermission, setCurrentPermission] = useState<PermissionRequest>(
{} as PermissionRequest
)
const [isConnectedToDApp, setIsConnectedToDApp] = useState(false)
const allowedPages = useBackgroundSelector((state) =>
selectAllowedPages(state)
)

const initPermissionAndOrigin = useCallback(async () => {
const { url } = await browser.tabs
.query({
active: true,
lastFocusedWindow: true,
})
.then((tabs) =>
tabs[0] ? tabs[0] : { url: "", favIconUrl: "", title: "" }
)
if (!url) return

const { origin } = new URL(url)

const allowPermission = allowedPages.find(
(permission) => permission.origin === origin
)

if (allowPermission) {
setCurrentPermission(allowPermission)
setIsConnectedToDApp(true)
} else {
setIsConnectedToDApp(false)
}
}, [allowedPages, setCurrentPermission])

useEffect(() => {
initPermissionAndOrigin()
}, [initPermissionAndOrigin])

const deny = useCallback(async () => {
if (typeof currentPermission !== "undefined") {
// Deletes all permissions corresponding to the currently selected
// account and origin
await Promise.all(
allowedPages.map(async (permission) => {
if (permission.origin === currentPermission.origin) {
return dispatch(
denyOrRevokePermission({ ...permission, state: "deny" })
)
}
return undefined
})
)
}
}, [dispatch, currentPermission, allowedPages])

return (
<>
{isDisabled(FeatureFlags.ENABLE_UPDATED_DAPP_CONNECTIONS) &&
isActiveDAppConnectionInfoOpen ? (
<TopMenuConnectedDAppInfo
title={currentPermission.title}
url={currentPermission.origin}
faviconUrl={currentPermission.faviconUrl}
close={() => {
setIsActiveDAppConnectionInfoOpen(false)
}}
disconnect={deny}
isConnected={isConnectedToDApp}
/>
) : null}
<BonusProgramModal
isOpen={isBonusProgramOpen}
onClose={() => {
Expand Down Expand Up @@ -135,31 +56,10 @@ export default function TopMenu(): ReactElement {
onCurrentAddressChange={() => setIsNotificationsOpen(false)}
/>
</SharedSlideUpMenu>
{isEnabled(FeatureFlags.ENABLE_UPDATED_DAPP_CONNECTIONS) && (
<DAppConnection />
)}
<DAppConnection />
<nav>
<TopMenuProtocolSwitcher onClick={() => setIsProtocolListOpen(true)} />
<div className="profile_group">
{isDisabled(FeatureFlags.ENABLE_UPDATED_DAPP_CONNECTIONS) && (
<button
type="button"
aria-label={t("showCurrentDappConnection")}
className="connection_button"
onClick={() => {
setIsActiveDAppConnectionInfoOpen(
!isActiveDAppConnectionInfoOpen
)
}}
>
{isEnabled(FeatureFlags.SUPPORT_WALLET_CONNECT) &&
isConnectedToDApp ? (
<div className="connected-wc" />
) : (
<div className="connection_img" />
)}
</button>
)}
{isDisabled(FeatureFlags.HIDE_TOKEN_FEATURES) && (
<button
type="button"
Expand Down Expand Up @@ -203,30 +103,6 @@ export default function TopMenu(): ReactElement {
button:hover {
background-color: var(--green-80);
}
.connection_button:hover .connection_img {
background-color: var(--success);
}
.connection_button {
width: 32px;
height: 32px;
}
.connection_img {
mask-image: url("./images/[email protected]");
mask-repeat: no-repeat;
mask-position: center;
mask-size: cover;
mask-size: 35%;
width: 32px;
height: 32px;
background-color: var(
--${isConnectedToDApp ? "success" : "green-20"}
);
}
.connected-wc {
background: url("./images/connected-wc.svg") center / 24px no-repeat;
width: 32px;
height: 32px;
}
.gift_button {
background: url("./images/[email protected]") center no-repeat;
background-size: 24px 24px;
Expand Down
9 changes: 1 addition & 8 deletions ui/components/TopMenu/TopMenuConnectedDAppInfo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import DAppConnectionDefaultToggle from "../DAppConnection/DAppConnectionDefault
import SharedAccordion from "../Shared/SharedAccordion"
import SharedLink from "../Shared/SharedLink"
import SharedPanelSwitcher from "../Shared/SharedPanelSwitcher"
import { WalletDefaultToggle } from "../Wallet/WalletToggleDefaultBanner"

function ConnectionDAppGuideline({
isConnected,
Expand Down Expand Up @@ -81,13 +80,7 @@ function ConnectionDAppGuideline({
<li>
<span className="wallet_toggle_wrap">
{t("guideline.step1")}
{isEnabled(
FeatureFlags.ENABLE_UPDATED_DAPP_CONNECTIONS
) ? (
<DAppConnectionDefaultToggle alwaysForceSelection="taho" />
) : (
<WalletDefaultToggle />
)}
<DAppConnectionDefaultToggle alwaysForceSelection="taho" />
</span>
</li>
<li>{t("guideline.step2")}</li>
Expand Down
43 changes: 43 additions & 0 deletions ui/components/Wallet/WalletDefaultToggle.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import {
selectDefaultWallet,
setNewDefaultWalletValue,
setSnackbarMessage,
} from "@tallyho/tally-background/redux-slices/ui"
import React, { ReactElement } from "react"
import { useTranslation } from "react-i18next"
import { useDispatch } from "react-redux"
import { useBackgroundSelector } from "../../hooks"
import SharedToggleButton from "../Shared/SharedToggleButton"
import SharedTooltip from "../Shared/SharedTooltip"

export default function WalletDefaultToggle(): ReactElement {
const { t } = useTranslation("translation", {
keyPrefix: "wallet.defaultToggle",
})
const dispatch = useDispatch()
const isDefaultWallet = useBackgroundSelector(selectDefaultWallet)

const toggleDefaultWallet = (defaultWalletValue: boolean) => {
dispatch(setNewDefaultWalletValue(defaultWalletValue))
if (defaultWalletValue) {
dispatch(setSnackbarMessage(t("snackbar")))
}
}

return (
<>
<SharedTooltip width={200}>{t("tooltip")}</SharedTooltip>
<div className="toggle">
<SharedToggleButton
onChange={(toggleValue) => toggleDefaultWallet(toggleValue)}
value={isDefaultWallet}
/>
</div>
<style jsx>{`
.toggle {
margin-left: auto;
}
`}</style>
</>
)
}
116 changes: 0 additions & 116 deletions ui/components/Wallet/WalletToggleDefaultBanner.tsx

This file was deleted.

Loading

0 comments on commit 8537e3e

Please sign in to comment.