-
Notifications
You must be signed in to change notification settings - Fork 202
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: autodetect LayerZero tokens (#1909)
- Loading branch information
1 parent
bf46d79
commit 5d67bf4
Showing
7 changed files
with
133 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
.../arb-token-bridge-ui/src/components/TransferPanel/hooks/useSelectedTokenIsWithdrawOnly.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import useSWRImmutable from 'swr/immutable' | ||
import { useMemo } from 'react' | ||
|
||
import { useAppState } from '../../../state' | ||
import { useNetworks } from '../../../hooks/useNetworks' | ||
import { useNetworksRelationship } from '../../../hooks/useNetworksRelationship' | ||
import { isWithdrawOnlyToken } from '../../../util/WithdrawOnlyUtils' | ||
|
||
export function useSelectedTokenIsWithdrawOnly() { | ||
const { | ||
app: { selectedToken } | ||
} = useAppState() | ||
const [networks] = useNetworks() | ||
const { isDepositMode, parentChain, childChain } = | ||
useNetworksRelationship(networks) | ||
|
||
const queryKey = useMemo(() => { | ||
if (!selectedToken) { | ||
return null | ||
} | ||
if (!isDepositMode) { | ||
return null | ||
} | ||
return [ | ||
selectedToken.address.toLowerCase(), | ||
parentChain.id, | ||
childChain.id | ||
] as const | ||
}, [selectedToken, isDepositMode, parentChain.id, childChain.id]) | ||
|
||
const { data: isSelectedTokenWithdrawOnly, isLoading } = useSWRImmutable( | ||
queryKey, | ||
([parentChainErc20Address, parentChainId, childChainId]) => | ||
isWithdrawOnlyToken({ | ||
parentChainErc20Address, | ||
parentChainId, | ||
childChainId | ||
}) | ||
) | ||
|
||
return { | ||
isSelectedTokenWithdrawOnly, | ||
isSelectedTokenWithdrawOnlyLoading: isLoading | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters