Skip to content

Commit

Permalink
fix sending jesse and usdrif tokens
Browse files Browse the repository at this point in the history
  • Loading branch information
rodrigoncalves committed Sep 19, 2023
1 parent 831a0a7 commit d23623d
Showing 1 changed file with 25 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -80,19 +80,38 @@ export const ReviewTransactionContainer = ({
const feeSymbol = isMainnet ? TokenSymbol.RIF : TokenSymbol.TRIF
const feeContract = getTokenAddress(feeSymbol, chainTypesById[chainId])

const getTokenBySymbol = useCallback(
(symb: string) => {
const result = Object.values(balances).find(
token => token.symbol.toUpperCase() === symb.toUpperCase(),
)
if (!result) {
throw new Error(
`Token with the symbol ${symb} not found on ${chainId}.`,
)
}
return result
},
[balances, chainId],
)

const tokenContract = useMemo(() => {
const rbtcAddress = constants.AddressZero
if (symbol === rbtcSymbol) {
return rbtcAddress
}
if (symbol) {
return getTokenAddress(symbol, chainTypesById[chainId])
try {
return getTokenAddress(symbol, chainTypesById[chainId])
} catch {
return getTokenBySymbol(symbol).contractAddress
}
}
return feeContract
}, [symbol, rbtcSymbol, feeContract, chainId])
}, [symbol, rbtcSymbol, feeContract, chainId, getTokenBySymbol])

const tokenQuote = tokenPrices[tokenContract].price
const feeQuote = tokenPrices[feeContract].price
const tokenQuote = tokenPrices[tokenContract]?.price
const feeQuote = tokenPrices[feeContract]?.price

useEffect(() => {
if (txRequest.to && !isAddress(txRequest.to)) {
Expand Down Expand Up @@ -146,12 +165,10 @@ export const ReviewTransactionContainer = ({
}, [onCancel, request])

const data: TransactionSummaryScreenProps = useMemo(() => {
const convertToUSD = (tokenValue: number, quote: number) =>
const convertToUSD = (tokenValue: number, quote = 0) =>
convertTokenToUSD(tokenValue, quote, true).toFixed(2)

const feeValue = txCostInRif
? `${balanceToDisplay(txCostInRif, 18, 0)}`
: '0'
const feeValue = txCostInRif ? balanceToDisplay(txCostInRif, 18, 0) : '0'

let insufficientFunds = false

Expand Down

0 comments on commit d23623d

Please sign in to comment.