Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ import {
import { useSentry } from "./hooks/sentry"

const Web3EventHandlerComponent = () => {
useSubscribeToERC20TransferEvent(Token.TBTCV2)
useSubscribeToERC20TransferEvent(Token.TBTC)
useSubscribeToDepositRevealedEvent()
useSubscribeToOptimisticMintingFinalizedEvent()
useSubscribeToOptimisticMintingRequestedEvent()
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
20 changes: 10 additions & 10 deletions src/contexts/TokenContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { useTokenState } from "../hooks/useTokenState"
import { useTokensBalanceCall } from "../hooks/useTokensBalanceCall"
import { Token } from "../enums"
import { TokenState } from "../types"
import { useTBTCv2TokenContract } from "../web3/hooks/useTBTCv2TokenContract"
import { useTBTCTokenContract } from "../web3/hooks/useTBTCTokenContract"

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

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

const {
fetchTokenPriceUSD,
setTokenBalance,
tbtcv2: tbtcv2Data,
tbtc: tbtcData,
} = useTokenState()

const tokenContracts = [tbtcv2]
const tokenContracts = [tbtc]

const fetchBalances = useTokensBalanceCall(
tokenContracts,
Expand All @@ -54,8 +54,8 @@ export const TokenContextProvider: React.FC = ({ children }) => {
//
React.useEffect(() => {
if (active) {
fetchBalances().then(([tbtcv2Balance]) => {
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
Expand All @@ -71,9 +71,9 @@ export const TokenContextProvider: React.FC = ({ children }) => {
return (
<TokenContext.Provider
value={{
[Token.TBTCV2]: {
contract: tbtcv2,
...tbtcv2Data,
[Token.TBTC]: {
contract: tbtc,
...tbtcData,
},
}}
>
Expand Down
4 changes: 2 additions & 2 deletions src/enums/token.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
export enum Token {
TBTCV2 = "TBTCV2",
TBTC = "TBTC",
}

export enum CoingeckoID {
TBTCV2 = "tbtc",
TBTC = "tbtc",
}
6 changes: 3 additions & 3 deletions src/hooks/useFetchTvl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { formatUnits } from "@ethersproject/units"
import { useToken } from "./useToken"
import { Token } from "../enums"
import { toUsdBalance } from "../utils/getUsdBalance"
import { useTBTCv2TokenContract } from "../web3/hooks/useTBTCv2TokenContract"
import { useTBTCTokenContract } from "../web3/hooks/useTBTCTokenContract"

interface TvlRawData {
tBTC: string
Expand All @@ -26,8 +26,8 @@ export const useFetchTvl = (): [
const [rawData, setRawData] = useState<TvlRawData>(initialState)
const { tBTC: tBTCTvl } = rawData

const tbtcTokenContract = useTBTCv2TokenContract()
const tBTCToken = useToken(Token.TBTCV2)
const tbtcTokenContract = useTBTCTokenContract()
const tBTCToken = useToken(Token.TBTC)

const fetchTvlData = useCallback(async () => {
const tBTCTokenTotalSupply: BigNumberish =
Expand Down
4 changes: 2 additions & 2 deletions src/hooks/useTBTCTokenAddress.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useTBTCv2TokenContract } from "../web3/hooks/useTBTCv2TokenContract"
import { useTBTCTokenContract } from "../web3/hooks/useTBTCTokenContract"

export const useTBTCTokenAddress = () => {
const tbtcContract = useTBTCv2TokenContract()
const tbtcContract = useTBTCTokenContract()

return tbtcContract.address
}
4 changes: 2 additions & 2 deletions src/hooks/useTokenState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { Token } from "../enums"
import { UseTokenState } from "../types/token"

export const useTokenState: UseTokenState = () => {
const tbtcv2 = useSelector((state: RootState) => state.token[Token.TBTCV2])
const tbtc = useSelector((state: RootState) => state.token[Token.TBTC])

const dispatch = useDispatch()

Expand All @@ -23,7 +23,7 @@ export const useTokenState: UseTokenState = () => {
dispatch(fetchTokenPriceAction({ token }))

return {
tbtcv2,
tbtc,
fetchTokenPriceUSD,
setTokenBalance,
setTokenLoading,
Expand Down
2 changes: 1 addition & 1 deletion src/pages/tBTC/Bridge/TbtcBalanceCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export const TbtcBalanceCard: FC<ComponentProps<typeof Card>> = ({
}) => {
return (
<TokenBalanceCard
token={Token.TBTCV2}
token={Token.TBTC}
title={
<>
<Box as="span" textTransform="lowercase">
Expand Down
2 changes: 1 addition & 1 deletion src/pages/tBTC/Bridge/Unmint.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ import { UnmintDetails } from "./UnmintDetails"
import { BridgeProcessEmptyState } from "./components/BridgeProcessEmptyState"

const UnmintFormPage: PageComponent = ({}) => {
const { balance } = useToken(Token.TBTCV2)
const { balance } = useToken(Token.TBTC)
const { openModal } = useModal()
const threshold = useThreshold()

Expand Down
2 changes: 1 addition & 1 deletion src/store/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const rootReducer: Reducer = (state: RootState, action: AnyAction) => {
registerTBTCListeners()
state = {
token: {
TBTCV2: { ...state.token.TBTCV2, balance: 0 },
TBTC: { ...state.token.TBTC, balance: 0 },
},
} as RootState
}
Expand Down
2 changes: 1 addition & 1 deletion src/store/tokens/tokenSlice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const toUsdBalance = (token: TokenState) => {
export const tokenSlice = createSlice({
name: "tokens",
initialState: {
[Token.TBTCV2]: {
[Token.TBTC]: {
loading: false,
balance: 0,
usdConversion: 0,
Expand Down
2 changes: 1 addition & 1 deletion src/types/token.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export type TokenActionTypes = SetTokenBalance | SetTokenLoading

export interface UseTokenState {
(): {
tbtcv2: TokenState
tbtc: TokenState
setTokenBalance: (
token: Token,
balance: number | string
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useThreshold } from "../../contexts/ThresholdContext"

export const useTBTCv2TokenContract = () => {
export const useTBTCTokenContract = () => {
const threshold = useThreshold()
return threshold.tbtc.tokenContract
}