Skip to content

Commit

Permalink
update useNetworksRelationships hook for now
Browse files Browse the repository at this point in the history
  • Loading branch information
fionnachan committed Jan 13, 2025
1 parent dc209ea commit 05b81dc
Showing 1 changed file with 11 additions and 13 deletions.
24 changes: 11 additions & 13 deletions packages/arb-token-bridge-ui/src/hooks/useNetworksRelationship.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ import { StaticJsonRpcProvider } from '@ethersproject/providers'
import { useMemo } from 'react'
import { Chain } from 'wagmi'
import { UseNetworksState } from './useNetworks'
import { isDepositMode } from '../util/isDepositMode'
import { isValidTeleportChainPair } from '@/token-bridge-sdk/teleport'
import { getTransferMode } from '../util/getTransferMode'

type UseNetworksRelationshipState = {
childChain: Chain
Expand All @@ -22,25 +21,24 @@ export function useNetworksRelationship({
destinationChainProvider
}: UseNetworksState): UseNetworksRelationshipState {
return useMemo(() => {
const _isDepositMode = isDepositMode({
const transferMode = getTransferMode({
sourceChainId: sourceChain.id,
destinationChainId: destinationChain.id
})

const isTeleportMode = isValidTeleportChainPair({
sourceChainId: sourceChain.id,
destinationChainId: destinationChain.id
})
const isDepositMode = transferMode === 'deposit'
const isTeleportMode = transferMode === 'teleport'
const isWithdrawalMode = transferMode === 'withdrawal'

if (_isDepositMode || isTeleportMode) {
if (isDepositMode || transferMode === 'teleport') {
return {
childChain: destinationChain,
childChainProvider: destinationChainProvider,
parentChain: sourceChain,
parentChainProvider: sourceChainProvider,
isDepositMode: _isDepositMode,
isDepositMode,
isTeleportMode,
isWithdrawalMode: false,
isWithdrawalMode,
isDepositOrTeleportMode: true
}
}
Expand All @@ -50,9 +48,9 @@ export function useNetworksRelationship({
childChainProvider: sourceChainProvider,
parentChain: destinationChain,
parentChainProvider: destinationChainProvider,
isDepositMode: _isDepositMode,
isTeleportMode,
isWithdrawalMode: true,
isDepositMode: false,
isTeleportMode: false,
isWithdrawalMode,
isDepositOrTeleportMode: false
}
}, [
Expand Down

0 comments on commit 05b81dc

Please sign in to comment.