Skip to content

Commit

Permalink
fix: too many decimals
Browse files Browse the repository at this point in the history
  • Loading branch information
kvhnuke committed Dec 13, 2023
1 parent b05cddc commit 29029ee
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 7 deletions.
1 change: 1 addition & 0 deletions packages/extension/configs/browser-build.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ const setConfig = (config) => {
args[0]["process.env"] = {
..._base,
PACKAGE_VERSION: JSON.stringify(package.version),
BUILD_TIME: new Date().toLocaleString().replace(/\D/g, ""),
IS_DEV: process.env.NODE_ENV === "development",
IS_FIREFOX: BROWSER === browserNames.firefox,
PREFILL_PASSWORD:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,10 @@ onMounted(async () => {
});
const nativeBalanceAfterTransaction = computed(() => {
if (selectedAsset.value) {
if (
selectedAsset.value &&
isValidDecimals(sendAmount.value, selectedAsset.value.decimals!)
) {
return toBN(selectedAsset.value.balance ?? "0").sub(
toBN(toBase(sendAmount.value ?? "0", selectedAsset.value.decimals!)).add(
toBN(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,8 @@ const nativeBalanceAfterTransaction = computed(() => {
nativeBalance.value &&
selectedAsset.value &&
selectedAsset.value.contract &&
amount.value !== ""
amount.value !== "" &&
isValidDecimals(sendAmount.value, selectedAsset.value.decimals!)
) {
let endingAmount = toBN(nativeBalance.value);
Expand Down Expand Up @@ -471,7 +472,9 @@ const assetMaxValue = computed(() => {
});
const setMaxValue = () => {
isMaxSelected.value = true;
updateTransactionFees(Tx.value);
if (isInputsValid.value) {
updateTransactionFees(Tx.value);
}
};
const inputAddressFrom = (text: string) => {
addressFrom.value = text;
Expand Down Expand Up @@ -527,7 +530,9 @@ const inputAmount = (inputAmount: string) => {
const inputAmountBn = new BigNumber(inputAmount);
isMaxSelected.value = false;
amount.value = inputAmountBn.lt(0) ? "0" : inputAmountBn.toFixed();
updateTransactionFees(Tx.value);
if (isInputsValid.value) {
updateTransactionFees(Tx.value);
}
};
const toggleSelectFee = () => {
Expand All @@ -537,7 +542,8 @@ const toggleSelectFee = () => {
const selectFee = (type: GasPriceTypes) => {
selectedFee.value = type;
isOpenSelectFee.value = false;
if (isMaxSelected.value) updateTransactionFees(Tx.value);
if (isMaxSelected.value && isInputsValid.value)
updateTransactionFees(Tx.value);
};
const sendAction = async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
</div>

<div class="settings__copyright">
<p>Version {{ version }}</p>
<p>Version {{ version }} ({{ buildTime }})</p>
<p>© {{ new Date().getFullYear() }} by MyEtherWallet Inc.</p>
</div>

Expand Down Expand Up @@ -65,6 +65,7 @@ import ModalForgot from "@action/views/modal-forgot/index.vue";
const isOpenSign = ref(false);
const isForgot = ref(false);
const version = process.env.PACKAGE_VERSION;
const buildTime = process.env.BUILD_TIME;
defineEmits<{
(e: "action:reset"): void;
(e: "action:support"): void;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

<script setup lang="ts">
import { computed, ref, onMounted } from "vue";
import BigNumber from "bignumber.js";
const isFocus = ref(false);
const swapAmountInput = ref(null);
Expand Down Expand Up @@ -59,7 +60,7 @@ onMounted(() => {
const emit = defineEmits(["update:value"]);
const textValue = computed({
get: () => props.value,
set: (value) => emit("update:value", value.toString()),
set: (value) => emit("update:value", BigNumber(value).toFixed()),
});
const changeFocus = () => {
isFocus.value = !isFocus.value;
Expand Down

1 comment on commit 29029ee

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.