Skip to content

Commit

Permalink
fix: crosschain native amount wrong (#2154)
Browse files Browse the repository at this point in the history
  • Loading branch information
nguyenhoaidanh authored Aug 10, 2023
1 parent fc3a4c8 commit b4eb153
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 28 deletions.
12 changes: 6 additions & 6 deletions src/components/SearchModal/CurrencySearch.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -385,13 +385,13 @@ export function CurrencySearch({
const removeImportedToken = useCallback(
(token: Token) => {
removeToken(chainId, token.address)

toggleFavoriteToken({
chainId,
address: token.address,
})
if (favoriteTokens?.some(el => el.toLowerCase() === token.address.toLowerCase()))
toggleFavoriteToken({
chainId,
address: token.address,
})
},
[chainId, toggleFavoriteToken, removeToken],
[chainId, toggleFavoriteToken, removeToken, favoriteTokens],
)

const removeAllImportToken = () => {
Expand Down
9 changes: 9 additions & 0 deletions src/hooks/bridge/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,29 @@ export const useEthBalanceOfAnotherChain = (chainId: ChainId | undefined) => {
const { readProvider } = useKyberSwapConfig(chainId)
const { account } = useActiveWeb3React()
const [balance, setBalance] = useState<CurrencyAmount<Currency>>()

useEffect(() => {
const controller = new AbortController()
async function getBalance() {
try {
if (!readProvider || !account || !chainId) {
setBalance(undefined)
return
}
const balance = await readProvider.getBalance(account)
if (controller.signal.aborted) {
return
}
setBalance(CurrencyAmount.fromRawAmount(NativeCurrencies[chainId], JSBI.BigInt(balance)))
} catch (error) {
if (controller.signal.aborted) {
return
}
setBalance(undefined)
}
}
getBalance()
return () => controller.abort()
}, [chainId, readProvider, account])

return balance
Expand Down
22 changes: 0 additions & 22 deletions src/pages/CrossChain/TransfersHistory/HistoryTable/Desktop.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { Trans } from '@lingui/macro'
import { Flex } from 'rebass'
import styled, { css } from 'styled-components'

import { ITEMS_PER_PAGE } from 'pages/Bridge/consts'
import TransactionItem from 'pages/CrossChain/TransfersHistory/HistoryTable/TransactionItem'

import { Props } from './index'
Expand Down Expand Up @@ -46,26 +45,6 @@ export const TableRow = styled.div`
`

const Desktop: React.FC<Props> = ({ transfers }) => {
const renderInvisibleRows = () => {
// don't need invisible rows for upToExtraSmall screens
if (transfers.length === ITEMS_PER_PAGE) {
return null
}

return Array(ITEMS_PER_PAGE - transfers.length)
.fill(0)
.map((_, i) => {
return (
<TableRow
key={i}
style={{
visibility: 'hidden',
}}
/>
)
})
}

return (
<Flex flexDirection="column" style={{ flex: 1 }}>
<TableHeader>
Expand All @@ -88,7 +67,6 @@ const Desktop: React.FC<Props> = ({ transfers }) => {
{transfers.map(transfer => (
<TransactionItem data={transfer} key={transfer.srcTxHash} />
))}
{renderInvisibleRows()}
</Flex>
)
}
Expand Down

0 comments on commit b4eb153

Please sign in to comment.