Skip to content

Commit

Permalink
refactor: use feeContract as address to search balances
Browse files Browse the repository at this point in the history
  • Loading branch information
TravellerOnTheRun committed Sep 14, 2023
1 parent 6178c26 commit f35d1f1
Showing 1 changed file with 6 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import { useCallback, useEffect, useMemo, useState } from 'react'
import { useTranslation } from 'react-i18next'
import { Alert, StyleSheet, View } from 'react-native'
import { useSafeAreaInsets } from 'react-native-safe-area-context'
import { RIF_TOKEN_ADDRESS_TESTNET } from '@rsksmart/rif-relay-light-sdk'

import { balanceToDisplay, convertTokenToUSD } from 'lib/utils'

Expand All @@ -18,7 +17,7 @@ import { TransactionSummaryScreenProps } from 'screens/transactionSummary'
import { TransactionSummaryComponent } from 'screens/transactionSummary/TransactionSummaryComponent'
import { sharedColors } from 'shared/constants'
import { chainTypesById } from 'shared/constants/chainConstants'
import { errorHandler } from 'shared/utils'
import { castStyle, errorHandler } from 'shared/utils'
import { selectWalletState } from 'store/slices/settingsSlice'
import { ChainTypeEnum } from 'store/slices/settingsSlice/types'
import { selectUsdPrices } from 'store/slices/usdPricesSlice'
Expand Down Expand Up @@ -150,11 +149,10 @@ export const ReviewTransactionContainer = ({

if (tokenToBoolMap.get(symbol as TokenSymbol)) {
insufficientFunds =
Number(value) + Number(feeValue) >
Number(balances[RIF_TOKEN_ADDRESS_TESTNET].balance)
Number(value) + Number(feeValue) > Number(balances[feeContract].balance)
} else {
insufficientFunds =
Number(feeValue) > Number(balances[RIF_TOKEN_ADDRESS_TESTNET].balance)
Number(feeValue) > Number(balances[feeContract].balance)
}

if (insufficientFunds) {
Expand Down Expand Up @@ -205,6 +203,7 @@ export const ReviewTransactionContainer = ({
functionName,
}
}, [
feeContract,
balances,
txCostInRif,
value,
Expand All @@ -231,10 +230,10 @@ export const ReviewTransactionContainer = ({
}

const styles = StyleSheet.create({
container: {
container: castStyle.view({
width: '100%',
height: '100%',
zIndex: 999,
position: 'absolute',
},
}),
})

0 comments on commit f35d1f1

Please sign in to comment.