Skip to content

Commit

Permalink
CP-8423: fix btc send issue (#1236)
Browse files Browse the repository at this point in the history
  • Loading branch information
ruijialin-avalabs authored and atn4z7 committed Mar 28, 2024
1 parent b3e364c commit a91a318
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
2 changes: 1 addition & 1 deletion packages/core-mobile/app/components/EditFees.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ const EditFees = ({
}
}

const saveDisabled = !!feeError || newFees.gasLimit === 0
const saveDisabled = !!feeError || (newFees.gasLimit === 0 && !isBtcNetwork)

const sanitized = (text: string): string => text.replace(/[^0-9]/g, '')

Expand Down
3 changes: 2 additions & 1 deletion packages/core-mobile/app/components/NetworkFeeSelector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ const NetworkFeeSelector = ({
// customFees init value.
// NetworkFee is not immediately available hence the useEffect
useEffect(() => {
if (!customFees && networkFee && gasLimit > 0) {
if (!customFees && networkFee && (gasLimit > 0 || isBtcNetwork)) {
const initialCustomFees = getInitialCustomFees(networkFee)
setCustomFees(initialCustomFees)
setCalculatedFees(initialCustomFees)
Expand All @@ -112,6 +112,7 @@ const NetworkFeeSelector = ({
customFees,
gasLimit,
getInitialCustomFees,
isBtcNetwork,
nativeTokenPrice,
networkFee,
onFeesChange,
Expand Down
14 changes: 12 additions & 2 deletions packages/core-mobile/app/screens/send/ReviewSend.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import AnalyticsService from 'services/analytics/AnalyticsService'
import { Button, Text, View } from '@avalabs/k2-mobile'
import { useSelector } from 'react-redux'
import { selectActiveNetwork } from 'store/network'
import { NetworkVMType } from '@avalabs/chains-sdk'

type NavigationProp = SendTokensScreenProps<
typeof AppNavigation.Send.Review
Expand All @@ -38,6 +39,7 @@ export default function ReviewSend({
appHook: { currencyFormatter }
} = useApplicationContext()
const activeNetwork = useSelector(selectActiveNetwork)
const isBtcNetwork = Boolean(activeNetwork?.vmName === NetworkVMType.BITCOIN)
const { goBack } = useNavigation<NavigationProp>()
const {
sendToken,
Expand All @@ -52,6 +54,14 @@ export default function ReviewSend({
sendStatusMsg
} = useSendTokenContext()

const maxFeePerGas = isBtcNetwork
? fees.maxFeePerGas.toSubUnit().toString()
: fees.maxFeePerGas.toFeeUnit()

const maxPriorityFeePerGas = isBtcNetwork
? fees.maxPriorityFeePerGas.toSubUnit().toString()
: fees.maxPriorityFeePerGas.toFeeUnit()

function handleSend(): void {
onSendNow()
}
Expand Down Expand Up @@ -145,8 +155,8 @@ export default function ReviewSend({
content={
<PoppableGasAndLimit
gasLimit={fees.gasLimit ?? 0}
maxFeePerGas={fees.maxFeePerGas.toFeeUnit()}
maxPriorityFeePerGas={fees.maxPriorityFeePerGas.toFeeUnit()}
maxFeePerGas={maxFeePerGas}
maxPriorityFeePerGas={maxPriorityFeePerGas}
/>
}
position={'right'}
Expand Down

0 comments on commit a91a318

Please sign in to comment.