From 11d9a05ed8c397d0130685b61ba28e84e9a97303 Mon Sep 17 00:00:00 2001 From: Lyka Labrada Date: Thu, 19 Oct 2023 19:47:59 +0800 Subject: [PATCH 1/3] fix(core): handle auto-conversion of utxo to dfi token --- .../screens/Portfolio/screens/SendScreen.tsx | 24 ++++++++++++++----- 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/mobile-app/app/screens/AppNavigator/screens/Portfolio/screens/SendScreen.tsx b/mobile-app/app/screens/AppNavigator/screens/Portfolio/screens/SendScreen.tsx index 181dea740c..5a21fa80af 100644 --- a/mobile-app/app/screens/AppNavigator/screens/Portfolio/screens/SendScreen.tsx +++ b/mobile-app/app/screens/AppNavigator/screens/Portfolio/screens/SendScreen.tsx @@ -115,14 +115,27 @@ export function SendScreen({ route, navigation }: Props): JSX.Element { }); const { address } = watch(); const amountToSend = getValues("amount"); + const isEvmAddress = + getAddressCategory(getValues("address"), networkName) === + AddressCategory.ETH; + const [addressType, setAddressType] = useState(); + const getInputTokenType = () => { + if (isEvmAddress) { + return "token"; + } else if (token?.id === "0_unified") { + return "utxo"; + } else { + return "others"; + } + }; const { isConversionRequired, conversionAmount } = useConversion({ inputToken: { - type: token?.id === "0_unified" ? "utxo" : "others", + type: getInputTokenType(), amount: new BigNumber(amountToSend), }, - deps: [amountToSend, JSON.stringify(token)], + deps: [amountToSend, JSON.stringify(token), isEvmAddress], }); const reservedDFI = 0.1; @@ -144,9 +157,6 @@ export function SendScreen({ route, navigation }: Props): JSX.Element { let infoText; let themedProps; let status = TransactionCardStatus.Default; - const isEvmAddress = - getAddressCategory(getValues("address"), networkName) === - AddressCategory.ETH; if (new BigNumber(amountToSend).isGreaterThan(token?.amount ?? 0)) { infoText = "Insufficient balance"; @@ -299,7 +309,9 @@ export function SendScreen({ route, navigation }: Props): JSX.Element { if (isConversionRequired) { queueConvertTransaction( { - mode: ConvertDirection.accountToUtxos, + mode: isEvmAddress + ? ConvertDirection.utxosToAccount + : ConvertDirection.accountToUtxos, amount: conversionAmount, }, dispatch, From 9d8029c0e4f4d0e19169cb7cbcc5c720331d67c0 Mon Sep 17 00:00:00 2001 From: Lyka Labrada Date: Thu, 19 Oct 2023 19:54:53 +0800 Subject: [PATCH 2/3] update getinputtokentype if-condition --- .../AppNavigator/screens/Portfolio/screens/SendScreen.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/mobile-app/app/screens/AppNavigator/screens/Portfolio/screens/SendScreen.tsx b/mobile-app/app/screens/AppNavigator/screens/Portfolio/screens/SendScreen.tsx index 5a21fa80af..a88ebcca72 100644 --- a/mobile-app/app/screens/AppNavigator/screens/Portfolio/screens/SendScreen.tsx +++ b/mobile-app/app/screens/AppNavigator/screens/Portfolio/screens/SendScreen.tsx @@ -124,11 +124,11 @@ export function SendScreen({ route, navigation }: Props): JSX.Element { const getInputTokenType = () => { if (isEvmAddress) { return "token"; - } else if (token?.id === "0_unified") { + } + if (token?.id === "0_unified") { return "utxo"; - } else { - return "others"; } + return "others"; }; const { isConversionRequired, conversionAmount } = useConversion({ inputToken: { From 89c6b7a37920383f839a08f85541979ff6a94078 Mon Sep 17 00:00:00 2001 From: Harsh Date: Thu, 19 Oct 2023 18:26:35 +0530 Subject: [PATCH 3/3] updated getInputTokenType condition for send token --- .../AppNavigator/screens/Portfolio/screens/SendScreen.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/mobile-app/app/screens/AppNavigator/screens/Portfolio/screens/SendScreen.tsx b/mobile-app/app/screens/AppNavigator/screens/Portfolio/screens/SendScreen.tsx index a88ebcca72..72c924ae96 100644 --- a/mobile-app/app/screens/AppNavigator/screens/Portfolio/screens/SendScreen.tsx +++ b/mobile-app/app/screens/AppNavigator/screens/Portfolio/screens/SendScreen.tsx @@ -122,10 +122,10 @@ export function SendScreen({ route, navigation }: Props): JSX.Element { const [addressType, setAddressType] = useState(); const getInputTokenType = () => { - if (isEvmAddress) { - return "token"; - } if (token?.id === "0_unified") { + if (isEvmAddress) { + return "token"; + } return "utxo"; } return "others";