diff --git a/apps/wallet-mobile/src/features/Swap/useCases/StartSwapScreen/ListOrders/OpenOrders.tsx b/apps/wallet-mobile/src/features/Swap/useCases/StartSwapScreen/ListOrders/OpenOrders.tsx
index 3fbc84324c..1d1fd95609 100644
--- a/apps/wallet-mobile/src/features/Swap/useCases/StartSwapScreen/ListOrders/OpenOrders.tsx
+++ b/apps/wallet-mobile/src/features/Swap/useCases/StartSwapScreen/ListOrders/OpenOrders.tsx
@@ -184,7 +184,7 @@ export const OpenOrders = () => {
const keys = await Promise.all(signers.map(async (signer) => createRawTxSigningKey(rootKey, signer)))
const response = await wallet.signRawTx(cbor, keys)
if (!response) return
- const hexBase64 = new Buffer(response).toString('base64')
+ const hexBase64 = Buffer.from(response).toString('base64')
return {txBase64: hexBase64}
}
@@ -194,19 +194,12 @@ export const OpenOrders = () => {
const getFee = React.useCallback(
async (utxo: string, collateralUtxo: string, bech32Address: string) => {
- let fee = '0'
setIsLoading(true)
-
- try {
- fee = await getCancellationOrderFee(wallet, cancelOrder, {orderUtxo: utxo, collateralUtxo, bech32Address})
- } catch (error) {
- Alert.alert(strings.generalErrorTitle, strings.generalErrorMessage(error))
- }
-
+ const fee = await getCancellationOrderFee(wallet, cancelOrder, {orderUtxo: utxo, collateralUtxo, bech32Address})
setIsLoading(false)
return fee
},
- [cancelOrder, strings, wallet],
+ [cancelOrder, wallet],
)
const openCancellationModal = async (order: MappedOpenOrder) => {
@@ -230,24 +223,31 @@ export const OpenOrders = () => {
const totalReturned = `${fromTokenAmount} ${fromTokenInfo?.ticker}`
const collateralUtxo = await getCollateralUtxo()
- const fee = await getFee(utxo, collateralUtxo, bech32Address)
-
- openModal(
- strings.listOrdersSheetTitle,
- }
- assetToIcon={}
- onConfirm={() => onOrderCancelConfirm(order)}
- onBack={closeModal}
- assetFromLabel={assetFromLabel}
- assetToLabel={assetToLabel}
- assetAmount={`${tokenAmount} ${assetToLabel}`}
- assetPrice={`${tokenPrice} ${assetFromLabel}`}
- totalReturned={totalReturned}
- fee={fee}
- />,
- 460,
- )
+ try {
+ const fee = await getFee(utxo, collateralUtxo, bech32Address)
+ openModal(
+ strings.listOrdersSheetTitle,
+ }
+ assetToIcon={}
+ onConfirm={() => onOrderCancelConfirm(order)}
+ onBack={closeModal}
+ assetFromLabel={assetFromLabel}
+ assetToLabel={assetToLabel}
+ assetAmount={`${tokenAmount} ${assetToLabel}`}
+ assetPrice={`${tokenPrice} ${assetFromLabel}`}
+ totalReturned={totalReturned}
+ fee={fee}
+ />,
+ 460,
+ )
+ } catch (error) {
+ if (error instanceof Error) {
+ Alert.alert(strings.generalErrorTitle, strings.generalErrorMessage(error.message))
+ } else {
+ Alert.alert(strings.generalErrorTitle, strings.generalErrorMessage(JSON.stringify(error)))
+ }
+ }
}
return (
diff --git a/apps/wallet-mobile/src/features/Swap/useCases/StartSwapScreen/ListOrders/helpers.ts b/apps/wallet-mobile/src/features/Swap/useCases/StartSwapScreen/ListOrders/helpers.ts
index 8bfb1f67f0..1dc3fd6e84 100644
--- a/apps/wallet-mobile/src/features/Swap/useCases/StartSwapScreen/ListOrders/helpers.ts
+++ b/apps/wallet-mobile/src/features/Swap/useCases/StartSwapScreen/ListOrders/helpers.ts
@@ -19,11 +19,12 @@ export const getCancellationOrderFee = async (
) => {
const address = await CardanoMobile.Address.fromBech32(options.bech32Address)
const bytes = await address.toBytes()
- const addressHex = new Buffer(bytes).toString('hex')
+ const addressHex = Buffer.from(bytes).toString('hex')
const cbor = await cancelOrder({
utxos: {collateral: options.collateralUtxo, order: options.orderUtxo},
address: addressHex,
})
+ if (!cbor) throw new Error(`Failed to get CBOR from REST API for address ${options.bech32Address}`)
const tx = await CardanoMobile.Transaction.fromBytes(Buffer.from(cbor, 'hex'))
const feeNumber = await tx.body().then((b) => b.fee())
return Quantities.denominated(
diff --git a/apps/wallet-mobile/translations/messages/src/features/Swap/common/strings.json b/apps/wallet-mobile/translations/messages/src/features/Swap/common/strings.json
index ddc07dd5f9..6a2eb41305 100644
--- a/apps/wallet-mobile/translations/messages/src/features/Swap/common/strings.json
+++ b/apps/wallet-mobile/translations/messages/src/features/Swap/common/strings.json
@@ -331,7 +331,7 @@
},
{
"id": "swap.swapScreen.swapMinAda",
- "defaultMessage": "!!!Min-ADA is the minimum ADA amount required to be contained when holding or sending Cardano native tokens.",
+ "defaultMessage": "!!!Min-ADA is the minimum ADA amount required to be contained when holding or sending Cardano native assets.",
"file": "src/features/Swap/common/strings.ts",
"start": {
"line": 222,
@@ -406,7 +406,7 @@
},
{
"id": "swap.swapScreen.swapMinReceived",
- "defaultMessage": "!!!Minimum amount of tokens you can get because of the slippage tolerance.",
+ "defaultMessage": "!!!Minimum amount of assets you can get because of the slippage tolerance.",
"file": "src/features/Swap/common/strings.ts",
"start": {
"line": 243,