Skip to content
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

Clean-up v2 #27

Merged
merged 27 commits into from
Jan 25, 2024
Merged
Show file tree
Hide file tree
Changes from 24 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
092bc1d
Remove all things related to tokens other thn tbtc
michalsmiarowski Jan 15, 2024
743626f
Remove unnecessary useMulticall call
michalsmiarowski Jan 15, 2024
b04e2a0
Remove unnecessary things from threshold-ts lib
michalsmiarowski Jan 15, 2024
407dcee
Remove unnecessary feature flags
michalsmiarowski Jan 15, 2024
a8a0a4a
Remove modal queue from store
michalsmiarowski Jan 15, 2024
dc87183
Remove `EthStateData` interface
michalsmiarowski Jan 15, 2024
5a7cb07
Remove rewards slice
michalsmiarowski Jan 15, 2024
7d82e60
Remove coverage-pools
michalsmiarowski Jan 16, 2024
048080b
Remove @keep-network/tbtc
michalsmiarowski Jan 16, 2024
6051a37
Remove @keep-network/random-beacon
michalsmiarowski Jan 16, 2024
28d3f22
Remove @keep-network/keep-ecdsa
michalsmiarowski Jan 16, 2024
a0022ff
Remove @threshold-network/solidity-contracts
michalsmiarowski Jan 16, 2024
c8a83b7
Remove @keep-network/keep-core
michalsmiarowski Jan 16, 2024
e5a12e9
Remove crypto-js lib
michalsmiarowski Jan 16, 2024
5e73576
Remove focus-visible lib
michalsmiarowski Jan 16, 2024
afdcd34
Remove web-vitals
michalsmiarowski Jan 16, 2024
a82d468
Change all tbtcv2 occurences to tbtc
michalsmiarowski Jan 16, 2024
422a935
Remove unnecessary `focus-visible` import
michalsmiarowski Jan 16, 2024
9598540
Merge branch 'main-cleanup-v2' into change-tbtcv2-to-tbtc
michalsmiarowski Jan 16, 2024
425ed8f
Remove .storybook folder
michalsmiarowski Jan 16, 2024
eef1309
Merge pull request #28 from threshold-network/change-tbtcv2-to-tbtc
kpyszkowski Jan 16, 2024
470d197
Remove `useMemo` from Sidebar.
michalsmiarowski Jan 24, 2024
0a75567
Remove unnecessary icons
michalsmiarowski Jan 24, 2024
302cfdb
Merge branch 'main' into main-cleanup-v2
kpyszkowski Jan 25, 2024
782f8ce
Remove `useContract` test
michalsmiarowski Jan 25, 2024
d3af03f
Merge branch 'main' into main-cleanup-v2
kpyszkowski Jan 25, 2024
a349f98
Remove TBTCV2 lefover
michalsmiarowski Jan 25, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@ REACT_APP_ETH_HOSTNAME_WS=ws://localhost:8545
REACT_APP_MULTICALL_ADDRESS=$MULTICALL_ADDRESS
REACT_APP_DAPP_DEVELOPMENT_TESTNET_CONTRACTS=$DAPP_DEVELOPMENT_TESTNET_CONTRACTS

REACT_APP_FEATURE_FLAG_TBTC_V2=true
REACT_APP_FEATURE_FLAG_TBTC_V2_REDEMPTION=true
REACT_APP_FEATURE_FLAG_MULTI_APP_STAKING=true
REACT_APP_FEATURE_FLAG_POSTHOG=false
REACT_APP_FEATURE_FLAG_SENTRY=$SENTRY_SUPPORT
REACT_APP_FEATURE_FLAG_LEDGER_LIVE=true
Expand Down
3 changes: 0 additions & 3 deletions .env.production
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@ REACT_APP_ETH_HOSTNAME_HTTP=$ETH_HOSTNAME_HTTP
REACT_APP_ETH_HOSTNAME_WS=$ETH_HOSTNAME_WS
REACT_APP_DAPP_DEVELOPMENT_TESTNET_CONTRACTS=$DAPP_DEVELOPMENT_TESTNET_CONTRACTS

REACT_APP_FEATURE_FLAG_TBTC_V2=true
REACT_APP_FEATURE_FLAG_TBTC_V2_REDEMPTION=true
REACT_APP_FEATURE_FLAG_MULTI_APP_STAKING=true
REACT_APP_FEATURE_FLAG_POSTHOG=$POSTHOG_SUPPORT
REACT_APP_POSTHOG_API_KEY=$POSTHOG_API_KEY
REACT_APP_POSTHOG_HOSTNAME_HTTP=$POSTHOG_HOSTNAME_HTTP
Expand Down
9 changes: 0 additions & 9 deletions .storybook/main.js

This file was deleted.

18 changes: 0 additions & 18 deletions .storybook/preview.js

This file was deleted.

12 changes: 1 addition & 11 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,6 @@
"@ethersproject/constants": "^5.5.0",
"@fontsource/ibm-plex-mono": "^4.5.13",
"@fontsource/inter": "^4.5.10",
"@keep-network/coverage-pools": "development",
"@keep-network/keep-core": "development",
"@keep-network/keep-ecdsa": "development",
"@keep-network/random-beacon": "development",
"@keep-network/tbtc": "development",
"@keep-network/tbtc-v2.ts": "^2.3.0",
"@ledgerhq/connect-kit-loader": "^1.1.2",
"@reduxjs/toolkit": "^1.6.1",
Expand All @@ -29,8 +24,6 @@
"@testing-library/react": "^11.1.0",
"@testing-library/user-event": "^12.1.10",
"@threshold-network/components": "development",
"@threshold-network/coverage-pools": "npm:@keep-network/coverage-pools@development",
"@threshold-network/solidity-contracts": "development",
"@types/jest": "^27.0.1",
"@types/node": "^16.9.1",
"@types/numeral": "^2.0.2",
Expand All @@ -45,10 +38,8 @@
"@web3-react/walletlink-connector": "^6.2.13",
"axios": "^0.24.0",
"bitcoin-address-validation": "^2.2.1",
"crypto-js": "^4.1.1",
"ethereum-blockies-base64": "^1.0.2",
"ethers": "^5.4.7",
"focus-visible": "^5.2.0",
"formik": "^2.2.9",
"framer-motion": "^4",
"numeral": "^2.0.6",
Expand All @@ -62,8 +53,7 @@
"react-redux": "^7.2.5",
"react-router-dom": "6.2.1",
"react-scripts": "4.0.3",
"typescript": "^4.4.3",
"web-vitals": "^1.0.1"
"typescript": "^4.4.3"
},
"scripts": {
"start": "craco --openssl-legacy-provider start",
Expand Down
4 changes: 1 addition & 3 deletions src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import "focus-visible/dist/focus-visible"
import "@fontsource/inter/700.css"
import "@fontsource/inter/600.css"
import "@fontsource/inter/500.css"
Expand All @@ -22,7 +21,6 @@ import reduxStore, { resetStoreAction } from "./store"
import ModalRoot from "./components/Modal"
import Sidebar from "./components/Sidebar"
import Navbar from "./components/Navbar"
import { fetchETHPriceUSD } from "./store/eth"
import { PageComponent } from "./types"
import { Token } from "./enums"
import getLibrary from "./web3/library"
Expand All @@ -41,7 +39,7 @@ import {
import { useSentry } from "./hooks/sentry"

const Web3EventHandlerComponent = () => {
useSubscribeToERC20TransferEvent(Token.TBTCV2)
useSubscribeToERC20TransferEvent(Token.TBTC)
useSubscribeToDepositRevealedEvent()
useSubscribeToOptimisticMintingFinalizedEvent()
useSubscribeToOptimisticMintingRequestedEvent()
Expand Down
26 changes: 8 additions & 18 deletions src/components/Sidebar/index.tsx
Original file line number Diff line number Diff line change
@@ -1,28 +1,18 @@
import { NavItemDetail } from "./NavItem"
import { useLocation } from "react-router-dom"
import { useMemo } from "react"
import DesktopSidebar from "./DesktopSidebar"
import MobileSidebar from "./MobileSidebar"
import { tBTCFill } from "../../static/icons/tBTCFill"
import { tBTCOutline } from "../../static/icons/tBTCOutline"
import { featureFlags } from "../../constants"

const Sidebar = () => {
const { pathname } = useLocation()
const navItems: NavItemDetail[] = useMemo(() => {
const navItems = []

if (featureFlags.TBTC_V2) {
navItems.push({
text: "tBTC",
activeIcon: tBTCFill,
passiveIcon: tBTCOutline,
href: "/tBTC/how-it-works",
} as NavItemDetail)
}

return navItems
}, [pathname])
const navItems: NavItemDetail[] = [
{
text: "tBTC",
activeIcon: tBTCFill,
passiveIcon: tBTCOutline,
href: "/tBTC/how-it-works",
},
]

return (
<>
Expand Down
4 changes: 2 additions & 2 deletions src/components/TokenBalanceCard/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { tBTCFillBlack } from "../../static/icons/tBTCFillBlack"
import { TokenBalanceProps } from "../TokenBalance"

export type TokenBalanceCardProps = {
token: Extract<Token, Token.TBTCV2>
token: Extract<Token, Token.TBTC>
title?: string | JSX.Element
tokenSymbol?: string
withSymbol?: boolean
Expand All @@ -16,7 +16,7 @@ export type TokenBalanceCardProps = {
>

const tokenToIconMap = {
[Token.TBTCV2]: tBTCFillBlack,
[Token.TBTC]: tBTCFillBlack,
}

const TokenBalanceCard: FC<TokenBalanceCardProps> = ({
Expand Down
9 changes: 0 additions & 9 deletions src/constants/featureFlags.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,11 @@
import { EnvVariable } from "../enums"
import { getEnvVariable } from "../utils/getEnvVariable"

export const TBTC_V2 =
getEnvVariable(EnvVariable.FEATURE_FLAG_TBTC_V2) === "true"

export const MULTI_APP_STAKING =
getEnvVariable(EnvVariable.FEATURE_FLAG_MULTI_APP_STAKING) === "true"

export const POSTHOG =
getEnvVariable(EnvVariable.FEATURE_FLAG_POSTHOG) === "true" &&
!window.location.href.includes("dashboard.test")

export const SENTRY = getEnvVariable(EnvVariable.FEATURE_FLAG_SENTRY) === "true"

export const TBTC_V2_REDEMPTION =
getEnvVariable(EnvVariable.FEATURE_FLAG_TBTC_V2_REDEMPTION) === "true"

export const LEDGER_LIVE =
getEnvVariable(EnvVariable.FEATURE_FLAG_LEDGER_LIVE) === "true"
2 changes: 0 additions & 2 deletions src/constants/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
export * as vendingMachine from "./vendingMachine"
export * as stakingBonus from "./stakingBonus"
export * as web3 from "./web3"
export * as featureFlags from "./featureFlags"
4 changes: 0 additions & 4 deletions src/constants/stakingBonus.ts

This file was deleted.

7 changes: 0 additions & 7 deletions src/constants/vendingMachine.ts

This file was deleted.

54 changes: 6 additions & 48 deletions src/contexts/TokenContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,11 @@ import { AddressZero } from "@ethersproject/constants"
import { Contract } from "@ethersproject/contracts"
import { useWeb3React } from "@web3-react/core"
import React, { createContext } from "react"
import { featureFlags } from "../constants"
import { useKeep } from "../web3/hooks/useKeep"
import { useNu } from "../web3/hooks/useNu"
import { useT } from "../web3/hooks/useT"
import { useTokenState } from "../hooks/useTokenState"
import { useTokensBalanceCall } from "../hooks/useTokensBalanceCall"
import { Token } from "../enums"
import { TokenState } from "../types"
import { useTBTCTokenContract } from "../web3/hooks"
import { useTBTCv2TokenContract } from "../web3/hooks/useTBTCv2TokenContract"
import { useTBTCTokenContract } from "../web3/hooks/useTBTCTokenContract"

interface TokenContextState extends TokenState {
contract: Contract | null
Expand All @@ -20,36 +15,22 @@ interface TokenContextState extends TokenState {
export const TokenContext = createContext<{
[key in Token]: TokenContextState
}>({
[Token.Keep]: {} as TokenContextState,
[Token.Nu]: {} as TokenContextState,
[Token.T]: {} as TokenContextState,
[Token.TBTC]: {} as TokenContextState,
[Token.TBTCV2]: {} as TokenContextState,
})

// Context that handles data fetching when a user connects their wallet or
// switches their network
export const TokenContextProvider: React.FC = ({ children }) => {
const keep = useKeep()
const nu = useNu()
const t = useT()
const tbtc = useTBTCTokenContract()
const tbtcv2 = useTBTCv2TokenContract()
const { active, chainId, account } = useWeb3React()

const {
fetchTokenPriceUSD,
setTokenBalance,
keep: keepData,
nu: nuData,
t: tData,
tbtc: tbtcData,
tbtcv2: tbtcv2Data,
} = useTokenState()

const tokenContracts = [keep.contract!, nu.contract!, t.contract!]

if (featureFlags.TBTC_V2) tokenContracts.push(tbtcv2)
const tokenContracts = [tbtc]

const fetchBalances = useTokensBalanceCall(
tokenContracts,
Expand All @@ -73,16 +54,9 @@ export const TokenContextProvider: React.FC = ({ children }) => {
//
React.useEffect(() => {
if (active) {
fetchBalances().then(
([keepBalance, nuBalance, tBalance, tbtcv2Balance]) => {
setTokenBalance(Token.Keep, keepBalance.toString())
setTokenBalance(Token.Nu, nuBalance.toString())
setTokenBalance(Token.T, tBalance.toString())
if (featureFlags.TBTC_V2) {
setTokenBalance(Token.TBTCV2, tbtcv2Balance.toString())
}
}
)
fetchBalances().then(([tbtcBalance]) => {
setTokenBalance(Token.TBTC, tbtcBalance.toString())
})
} else {
// set all token balances to 0 if the user disconnects the wallet
for (const token in Token) {
Expand All @@ -97,26 +71,10 @@ export const TokenContextProvider: React.FC = ({ children }) => {
return (
<TokenContext.Provider
value={{
[Token.Keep]: {
...keep,
...keepData,
},
[Token.Nu]: {
...nu,
...nuData,
},
[Token.T]: {
...t,
...tData,
},
[Token.TBTC]: {
...tbtc,
contract: tbtc,
...tbtcData,
},
[Token.TBTCV2]: {
contract: tbtcv2,
...tbtcv2Data,
},
}}
>
{children}
Expand Down
3 changes: 0 additions & 3 deletions src/enums/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@ const envVariables = [
"SUPPORTED_CHAIN_ID",
"ETH_HOSTNAME_HTTP",
"ETH_HOSTNAME_WS",
"FEATURE_FLAG_TBTC_V2",
"FEATURE_FLAG_TBTC_V2_REDEMPTION",
"FEATURE_FLAG_MULTI_APP_STAKING",
"FEATURE_FLAG_POSTHOG",
"FEATURE_FLAG_LEDGER_LIVE",
"POSTHOG_HOSTNAME_HTTP",
Expand Down
10 changes: 0 additions & 10 deletions src/enums/token.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,7 @@
export enum Token {
Keep = "KEEP",
Nu = "NU",
T = "T",
TBTC = "TBTC",
TBTCV2 = "TBTCV2",
}

export enum CoingeckoID {
KEEP = "keep-network",
NU = "nucypher",
T = "threshold-network-token",
ETH = "ethereum",
TBTC = "tbtc",
// TODO: add prope tbtc-v2 id when it lands on coingecko
TBTCV2 = "tbtc",
}
6 changes: 0 additions & 6 deletions src/enums/transactionType.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
export enum TransactionType {
ApproveKeep = "APPROVE_KEEP",
ApproveNu = "APPROVE_NU",
ApproveT = "APPROVE_T",
}

export enum TransactionStatus {
Idle = "IDLE",
PendingWallet = "PENDING_WALLET",
Expand Down
7 changes: 0 additions & 7 deletions src/hooks/useETHData.ts

This file was deleted.

Loading
Loading