Skip to content

Commit

Permalink
[Wallet] Remove fee calculation for CELO withdrawals (#5042)
Browse files Browse the repository at this point in the history
### Description

The fee estimation was being done using cUSD so users were seeing a "Insufficient balance" error if they didn't have a cUSD balance even if the withdrawal was possible anyways.

In the exchange flow the fee is hard coded as a 0, we don't have fee estimation calculation for CELO yet, so I switched the calculation for a hard coded 0 here as well for now.

### Tested

In the simulator

I'll add e2e tests soon for an account without cUSD balance that will cover this case. Depends on this PR: #4989
  • Loading branch information
gnardini authored Sep 16, 2020
1 parent e67eba1 commit 6dc16d1
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 58 deletions.
40 changes: 10 additions & 30 deletions packages/mobile/src/exchange/WithdrawCeloSummary.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,12 @@ import BigNumber from 'bignumber.js'
import * as React from 'react'
import { useTranslation } from 'react-i18next'
import { View, ViewStyle } from 'react-native'
import { useSelector } from 'react-redux'
import CurrencyDisplay from 'src/components/CurrencyDisplay'
import FeeDrawer from 'src/components/FeeDrawer'
import LineItemRow from 'src/components/LineItemRow.v2'
import TotalLineItem from 'src/components/TotalLineItem.v2'
import { FeeType } from 'src/fees/actions'
import CalculateFee from 'src/fees/CalculateFee'
import { getFeeDollars } from 'src/fees/selectors'
import { CURRENCIES, CURRENCY_ENUM } from 'src/geth/consts'
import { Namespaces } from 'src/i18n'
import { currentAccountSelector } from 'src/web3/selectors'

interface WithdrawCeloProps {
style?: ViewStyle
Expand All @@ -29,7 +24,8 @@ export default function WithdrawCeloSummary({
recipientAddress,
}: WithdrawCeloProps) {
const { t } = useTranslation(Namespaces.exchangeFlow9)
const currentAccount = useSelector(currentAccountSelector)
// TODO: Estimate real fee.
const fee = new BigNumber(0)

return (
<View style={style}>
Expand All @@ -45,30 +41,14 @@ export default function WithdrawCeloSummary({
/>
}
/>
<CalculateFee
feeType={FeeType.SEND}
account={currentAccount || ''}
amount={amount}
comment=""
recipientAddress={recipientAddress}
includeDekFee={false}
>
{(asyncFee) => {
const fee = getFeeDollars(asyncFee.result)
return (
<FeeDrawer
testID={'feeDrawer/WithdrawCelo'}
currency={CURRENCY_ENUM.GOLD}
isExchange={false}
isEstimate={true}
feeLoading={asyncFee.loading}
feeHasError={!!asyncFee.error}
securityFee={fee}
totalFee={fee}
/>
)
}}
</CalculateFee>
<FeeDrawer
testID={'feeDrawer/WithdrawCelo'}
currency={CURRENCY_ENUM.GOLD}
isExchange={false}
isEstimate={true}
securityFee={fee}
totalFee={fee}
/>
<TotalLineItem
amount={{
value: amount,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -295,24 +295,35 @@ exports[`WithdrawCeloReviewScreen renders correctly 1`] = `
</Text>
</View>
<View
<Text
style={
Object {
"transform": Array [
Array [
Object {
"color": "#2E3338",
"fontFamily": "Inter-Regular",
"fontSize": 16,
"lineHeight": 22,
},
undefined,
]
}
>
<Text
numberOfLines={1}
style={
Array [
undefined,
Object {
"scale": 0.7,
"color": undefined,
},
],
]
}
}
>
<ActivityIndicator
animating={true}
color="#42D689"
hidesWhenStopped={true}
size="small"
/>
</View>
>
0
</Text>
</Text>
</View>
</View>
</View>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,24 +187,35 @@ exports[`WithdrawCeloSummary renders correctly 1`] = `
</Text>
</View>
<View
<Text
style={
Object {
"transform": Array [
Array [
Object {
"color": "#2E3338",
"fontFamily": "Inter-Regular",
"fontSize": 16,
"lineHeight": 22,
},
undefined,
]
}
>
<Text
numberOfLines={1}
style={
Array [
undefined,
Object {
"scale": 0.7,
"color": undefined,
},
],
]
}
}
>
<ActivityIndicator
animating={true}
color="#42D689"
hidesWhenStopped={true}
size="small"
/>
</View>
>
0
</Text>
</Text>
</View>
</View>
</View>
Expand Down

0 comments on commit 6dc16d1

Please sign in to comment.