Skip to content

Commit

Permalink
fix: token
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisling-dev committed Sep 17, 2024
1 parent 320b0d1 commit 75351ee
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import {
import { SeparatedAccountSelector } from '@/components/SeparatedAccountSelector'
import { selectedCurrencyState } from '@/domains/balances'
import { cn } from '@/lib/utils'
import { useTokens } from '@talismn/balances-react'
import { Decimal } from '@talismn/math'
import { Surface } from '@talismn/ui'
import { Wallet } from '@talismn/web-icons'
Expand All @@ -39,12 +38,6 @@ export const FromAccount: React.FC<Props> = ({ fastBalance }) => {
const [toEvmAddress, setToEvmAddress] = useAtom(toEvmAddressAtom)
const [toSubstrateAddress, setToSubstrateAddress] = useAtom(toSubstrateAddressAtom)

const tokens = useTokens()
const token = useMemo(() => {
if (!fromAsset) return null
return tokens[fromAsset.id]
}, [fromAsset, tokens])

const onChangeAddress = useCallback(
(address: string | null) => {
if (!address) return
Expand Down Expand Up @@ -116,7 +109,13 @@ export const FromAccount: React.FC<Props> = ({ fastBalance }) => {
<p className="text-[14px] text-gray-500">Origin Account</p>
<SeparatedAccountSelector
accountsType={
fromAsset.id === 'btc-native' ? 'btc' : !token ? 'all' : token.evmNetwork ? 'ethereum' : 'substrate'
fromAsset.id === 'btc-native'
? 'btc'
: !fromAsset
? 'all'
: fromAsset.networkType === 'evm'
? 'ethereum'
: 'substrate'
}
disableBtc
substrateAccountPrefix={0}
Expand Down
14 changes: 7 additions & 7 deletions apps/portal/src/components/widgets/chainflip-swap/ToAccount.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,6 @@ export const ToAccount: React.FC = () => {
const setEvmAddress = useSetAtom(toEvmAddressAtom)
const setSubstrate = useSetAtom(toSubstrateAddressAtom)
const setBtcAddress = useSetAtom(toBtcAddressAtom)
const tokens = useTokens()

const token = useMemo(() => {
if (!toAsset) return null
return tokens[toAsset.id]
}, [toAsset, tokens])

return (
<div className="w-full">
Expand All @@ -34,7 +28,13 @@ export const ToAccount: React.FC = () => {
<SeparatedAccountSelector
allowInput
accountsType={
toAsset.id === 'btc-native' ? 'btc' : !token ? 'all' : token?.evmNetwork ? 'ethereum' : 'substrate'
toAsset.id === 'btc-native'
? 'btc'
: !toAsset
? 'all'
: toAsset.networkType === 'evm'
? 'ethereum'
: 'substrate'
}
substrateAccountsFilter={a => !a.readonly}
substrateAccountPrefix={0}
Expand Down

0 comments on commit 75351ee

Please sign in to comment.