From 86fcadcbeb131c2812c61212e0c123c694a62c6f Mon Sep 17 00:00:00 2001 From: nickkelly1 Date: Wed, 27 Nov 2024 11:36:28 -0600 Subject: [PATCH 1/5] fix: evm solana send low balance error messages --- .../providers/ethereum/ui/send-transaction/index.vue | 11 ++++++++--- .../providers/solana/ui/send-transaction/index.vue | 12 +++++++++--- .../components/best-offer-warning.vue | 2 ++ 3 files changed, 19 insertions(+), 6 deletions(-) diff --git a/packages/extension/src/providers/ethereum/ui/send-transaction/index.vue b/packages/extension/src/providers/ethereum/ui/send-transaction/index.vue index d042451b8..9309e999b 100644 --- a/packages/extension/src/providers/ethereum/ui/send-transaction/index.vue +++ b/packages/extension/src/providers/ethereum/ui/send-transaction/index.vue @@ -104,7 +104,10 @@ /> +// TODO: Is this component deprecated? + import WarningIcon from '@action/icons/send/warning-icon.vue'; defineProps({ feeWarning: { From c5db516f74d86613d6a0d680c50a429e6eda5386 Mon Sep 17 00:00:00 2001 From: nickkelly1 Date: Wed, 27 Nov 2024 16:00:32 -0600 Subject: [PATCH 2/5] chore: cleanup --- .../src/providers/ethereum/ui/send-transaction/index.vue | 8 ++++---- .../src/providers/solana/ui/send-transaction/index.vue | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/packages/extension/src/providers/ethereum/ui/send-transaction/index.vue b/packages/extension/src/providers/ethereum/ui/send-transaction/index.vue index 01027320e..6ae4b528c 100644 --- a/packages/extension/src/providers/ethereum/ui/send-transaction/index.vue +++ b/packages/extension/src/providers/ethereum/ui/send-transaction/index.vue @@ -393,10 +393,10 @@ const nativeBalanceAfterTransactionInBaseUnits = computed(() => { }); /** - * Native balance after the transaction in the base unit of the + * Native balance after the transaction in the main unit of the * native currency (eg in ETH, SOL, BTC, ...) */ -const nativeBalanceAfterTransactionInCoreUnits = computed(() => { +const nativeBalanceAfterTransactionInMainUnits = computed(() => { return fromBase( nativeBalanceAfterTransactionInBaseUnits.value.abs().toString(), props.network.decimals, @@ -410,7 +410,7 @@ const dstAssetNativePriceInNativeCurrency = computed(() => { const priceDifferenceUsd = computed(() => { return new BigNumber( - nativeBalanceAfterTransactionInCoreUnits.value.toString(), + nativeBalanceAfterTransactionInMainUnits.value.toString(), ) .times(dstAssetNativePriceInNativeCurrency.value ?? '0') .toFixed(); @@ -430,7 +430,7 @@ const errorMsg = computed(() => { nativeBalanceAfterTransactionInBaseUnits.value.isNeg() ) { return `Not enough funds. You are - ~${formatFloatingPointValue(nativeBalanceAfterTransactionInCoreUnits.value).value} + ~${formatFloatingPointValue(nativeBalanceAfterTransactionInMainUnits.value).value} ${props.network.currencyName} ($ ${ formatFiatValue(priceDifferenceUsd.value).value }) short.`; diff --git a/packages/extension/src/providers/solana/ui/send-transaction/index.vue b/packages/extension/src/providers/solana/ui/send-transaction/index.vue index 06290c73c..4d1c9ce0a 100644 --- a/packages/extension/src/providers/solana/ui/send-transaction/index.vue +++ b/packages/extension/src/providers/solana/ui/send-transaction/index.vue @@ -336,10 +336,10 @@ const nativeBalanceAfterTransactionInBaseUnits = computed(() => { }); /** - * Native balance after the transaction in the base unit of the + * Native balance after the transaction in the main unit of the * native currency (eg in ETH, SOL, BTC, ...) */ -const nativeBalanceAfterTransactionInCoreUnits = computed(() => { +const nativeBalanceAfterTransactionInMainUnits = computed(() => { return fromBase( nativeBalanceAfterTransactionInBaseUnits.value.abs().toString(), props.network.decimals, @@ -353,7 +353,7 @@ const dstAssetNativePriceInNativeCurrency = computed(() => { const priceDifferenceUsd = computed(() => { return new BigNumber( - nativeBalanceAfterTransactionInCoreUnits.value.toString(), + nativeBalanceAfterTransactionInMainUnits.value.toString(), ) .times(dstAssetNativePriceInNativeCurrency.value ?? '0') .toFixed(); @@ -373,7 +373,7 @@ const errorMsg = computed(() => { nativeBalanceAfterTransactionInBaseUnits.value.isNeg() ) { return `Not enough funds. You are - ~${formatFloatingPointValue(nativeBalanceAfterTransactionInCoreUnits.value).value} + ~${formatFloatingPointValue(nativeBalanceAfterTransactionInMainUnits.value).value} ${props.network.currencyName} ($ ${ formatFiatValue(priceDifferenceUsd.value).value }) short.`; From 787a7fca8c6f956393d4dae009fce471c5a37979 Mon Sep 17 00:00:00 2001 From: nickkelly1 Date: Wed, 27 Nov 2024 16:01:43 -0600 Subject: [PATCH 3/5] chore: cleanup --- .../src/providers/ethereum/ui/send-transaction/index.vue | 8 ++++---- .../src/providers/solana/ui/send-transaction/index.vue | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/packages/extension/src/providers/ethereum/ui/send-transaction/index.vue b/packages/extension/src/providers/ethereum/ui/send-transaction/index.vue index 6ae4b528c..beac594a0 100644 --- a/packages/extension/src/providers/ethereum/ui/send-transaction/index.vue +++ b/packages/extension/src/providers/ethereum/ui/send-transaction/index.vue @@ -393,10 +393,10 @@ const nativeBalanceAfterTransactionInBaseUnits = computed(() => { }); /** - * Native balance after the transaction in the main unit of the + * Native balance after the transaction in the human unit of the * native currency (eg in ETH, SOL, BTC, ...) */ -const nativeBalanceAfterTransactionInMainUnits = computed(() => { +const nativeBalanceAfterTransactionInHumanUnits = computed(() => { return fromBase( nativeBalanceAfterTransactionInBaseUnits.value.abs().toString(), props.network.decimals, @@ -410,7 +410,7 @@ const dstAssetNativePriceInNativeCurrency = computed(() => { const priceDifferenceUsd = computed(() => { return new BigNumber( - nativeBalanceAfterTransactionInMainUnits.value.toString(), + nativeBalanceAfterTransactionInHumanUnits.value.toString(), ) .times(dstAssetNativePriceInNativeCurrency.value ?? '0') .toFixed(); @@ -430,7 +430,7 @@ const errorMsg = computed(() => { nativeBalanceAfterTransactionInBaseUnits.value.isNeg() ) { return `Not enough funds. You are - ~${formatFloatingPointValue(nativeBalanceAfterTransactionInMainUnits.value).value} + ~${formatFloatingPointValue(nativeBalanceAfterTransactionInHumanUnits.value).value} ${props.network.currencyName} ($ ${ formatFiatValue(priceDifferenceUsd.value).value }) short.`; diff --git a/packages/extension/src/providers/solana/ui/send-transaction/index.vue b/packages/extension/src/providers/solana/ui/send-transaction/index.vue index 4d1c9ce0a..8c1b4bf41 100644 --- a/packages/extension/src/providers/solana/ui/send-transaction/index.vue +++ b/packages/extension/src/providers/solana/ui/send-transaction/index.vue @@ -336,10 +336,10 @@ const nativeBalanceAfterTransactionInBaseUnits = computed(() => { }); /** - * Native balance after the transaction in the main unit of the + * Native balance after the transaction in the human unit of the * native currency (eg in ETH, SOL, BTC, ...) */ -const nativeBalanceAfterTransactionInMainUnits = computed(() => { +const nativeBalanceAfterTransactionInHumanUnits = computed(() => { return fromBase( nativeBalanceAfterTransactionInBaseUnits.value.abs().toString(), props.network.decimals, @@ -353,7 +353,7 @@ const dstAssetNativePriceInNativeCurrency = computed(() => { const priceDifferenceUsd = computed(() => { return new BigNumber( - nativeBalanceAfterTransactionInMainUnits.value.toString(), + nativeBalanceAfterTransactionInHumanUnits.value.toString(), ) .times(dstAssetNativePriceInNativeCurrency.value ?? '0') .toFixed(); @@ -373,7 +373,7 @@ const errorMsg = computed(() => { nativeBalanceAfterTransactionInBaseUnits.value.isNeg() ) { return `Not enough funds. You are - ~${formatFloatingPointValue(nativeBalanceAfterTransactionInMainUnits.value).value} + ~${formatFloatingPointValue(nativeBalanceAfterTransactionInHumanUnits.value).value} ${props.network.currencyName} ($ ${ formatFiatValue(priceDifferenceUsd.value).value }) short.`; From 3293012e6c750a450de8cf74f1be3314147fdf04 Mon Sep 17 00:00:00 2001 From: nickkelly1 Date: Wed, 27 Nov 2024 16:03:11 -0600 Subject: [PATCH 4/5] chore: cleanup --- .../src/providers/ethereum/ui/send-transaction/index.vue | 5 ++--- .../src/providers/solana/ui/send-transaction/index.vue | 5 ++--- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/packages/extension/src/providers/ethereum/ui/send-transaction/index.vue b/packages/extension/src/providers/ethereum/ui/send-transaction/index.vue index beac594a0..98ac68f01 100644 --- a/packages/extension/src/providers/ethereum/ui/send-transaction/index.vue +++ b/packages/extension/src/providers/ethereum/ui/send-transaction/index.vue @@ -403,8 +403,7 @@ const nativeBalanceAfterTransactionInHumanUnits = computed(() => { ); }); -/** Destination assets price in the native currency of the network */ -const dstAssetNativePriceInNativeCurrency = computed(() => { +const nativeCurrencyUsdPrice = computed(() => { return accountAssets.value[0]?.price || '0'; }); @@ -412,7 +411,7 @@ const priceDifferenceUsd = computed(() => { return new BigNumber( nativeBalanceAfterTransactionInHumanUnits.value.toString(), ) - .times(dstAssetNativePriceInNativeCurrency.value ?? '0') + .times(nativeCurrencyUsdPrice.value ?? '0') .toFixed(); }); diff --git a/packages/extension/src/providers/solana/ui/send-transaction/index.vue b/packages/extension/src/providers/solana/ui/send-transaction/index.vue index 8c1b4bf41..ca7d20562 100644 --- a/packages/extension/src/providers/solana/ui/send-transaction/index.vue +++ b/packages/extension/src/providers/solana/ui/send-transaction/index.vue @@ -346,8 +346,7 @@ const nativeBalanceAfterTransactionInHumanUnits = computed(() => { ); }); -/** Destination assets price in the native currency of the network */ -const dstAssetNativePriceInNativeCurrency = computed(() => { +const nativeCurrencyUsdPrice = computed(() => { return accountAssets.value[0]?.price || '0'; }); @@ -355,7 +354,7 @@ const priceDifferenceUsd = computed(() => { return new BigNumber( nativeBalanceAfterTransactionInHumanUnits.value.toString(), ) - .times(dstAssetNativePriceInNativeCurrency.value ?? '0') + .times(nativeCurrencyUsdPrice.value ?? '0') .toFixed(); }); From 7a4a9699f5385e467bca8f2115a333f3daef00cf Mon Sep 17 00:00:00 2001 From: nickkelly1 Date: Wed, 27 Nov 2024 16:04:01 -0600 Subject: [PATCH 5/5] chore: cleanup --- .../src/providers/ethereum/ui/send-transaction/index.vue | 4 ++-- .../src/providers/solana/ui/send-transaction/index.vue | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/extension/src/providers/ethereum/ui/send-transaction/index.vue b/packages/extension/src/providers/ethereum/ui/send-transaction/index.vue index 98ac68f01..a00efafc0 100644 --- a/packages/extension/src/providers/ethereum/ui/send-transaction/index.vue +++ b/packages/extension/src/providers/ethereum/ui/send-transaction/index.vue @@ -407,7 +407,7 @@ const nativeCurrencyUsdPrice = computed(() => { return accountAssets.value[0]?.price || '0'; }); -const priceDifferenceUsd = computed(() => { +const balanceAfterInUsd = computed(() => { return new BigNumber( nativeBalanceAfterTransactionInHumanUnits.value.toString(), ) @@ -431,7 +431,7 @@ const errorMsg = computed(() => { return `Not enough funds. You are ~${formatFloatingPointValue(nativeBalanceAfterTransactionInHumanUnits.value).value} ${props.network.currencyName} ($ ${ - formatFiatValue(priceDifferenceUsd.value).value + formatFiatValue(balanceAfterInUsd.value).value }) short.`; } diff --git a/packages/extension/src/providers/solana/ui/send-transaction/index.vue b/packages/extension/src/providers/solana/ui/send-transaction/index.vue index ca7d20562..38c6a9594 100644 --- a/packages/extension/src/providers/solana/ui/send-transaction/index.vue +++ b/packages/extension/src/providers/solana/ui/send-transaction/index.vue @@ -350,7 +350,7 @@ const nativeCurrencyUsdPrice = computed(() => { return accountAssets.value[0]?.price || '0'; }); -const priceDifferenceUsd = computed(() => { +const balanceAfterInUsd = computed(() => { return new BigNumber( nativeBalanceAfterTransactionInHumanUnits.value.toString(), ) @@ -374,7 +374,7 @@ const errorMsg = computed(() => { return `Not enough funds. You are ~${formatFloatingPointValue(nativeBalanceAfterTransactionInHumanUnits.value).value} ${props.network.currencyName} ($ ${ - formatFiatValue(priceDifferenceUsd.value).value + formatFiatValue(balanceAfterInUsd.value).value }) short.`; }