diff --git a/packages/extension/src/providers/bitcoin/ui/send-transaction/index.vue b/packages/extension/src/providers/bitcoin/ui/send-transaction/index.vue index e52a41789..8d309b56d 100644 --- a/packages/extension/src/providers/bitcoin/ui/send-transaction/index.vue +++ b/packages/extension/src/providers/bitcoin/ui/send-transaction/index.vue @@ -389,7 +389,7 @@ const inputAmount = (inputAmount: string) => { } const inputAmountBn = new BigNumber(inputAmount); isMaxSelected.value = false; - amount.value = inputAmountBn.lt(0) ? "0" : inputAmountBn.toFixed(); + amount.value = inputAmountBn.lt(0) ? "0" : inputAmount; }; const toggleSelectFee = () => { diff --git a/packages/extension/src/providers/common/ui/send-transaction/send-input-amount.vue b/packages/extension/src/providers/common/ui/send-transaction/send-input-amount.vue index a0df84c6b..66adba85f 100644 --- a/packages/extension/src/providers/common/ui/send-transaction/send-input-amount.vue +++ b/packages/extension/src/providers/common/ui/send-transaction/send-input-amount.vue @@ -3,9 +3,10 @@ @@ -31,7 +32,7 @@ import SwitchArrowIcon from "@action/icons/send/switch-arrow-icon.vue"; import BigNumber from "bignumber.js"; const emit = defineEmits<{ - (e: "update:inputAmount", address: string): void; + (e: "update:inputAmount", value: string): void; (e: "update:inputSetMax"): void; }>(); @@ -64,10 +65,18 @@ const fiatEquivalent = computed(() => { const amount = computed({ get: () => props.amount, set: (value) => { - emit("update:inputAmount", value.toString()); + let fValue = value.toString(); + if (fValue === ".") fValue = "0."; + emit("update:inputAmount", fValue); }, }); +const onlyNumber = ($event: KeyboardEvent) => { + const keyCode = $event.keyCode ? $event.keyCode : $event.which; + if ((keyCode < 48 || keyCode > 57) && keyCode !== 46) { + $event.preventDefault(); + } +}; const changeFocus = () => { isFocus.value = !isFocus.value; }; 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 45b551633..e87798c72 100644 --- a/packages/extension/src/providers/ethereum/ui/send-transaction/index.vue +++ b/packages/extension/src/providers/ethereum/ui/send-transaction/index.vue @@ -614,7 +614,7 @@ const inputAmount = (inputAmount: string) => { } const inputAmountBn = new BigNumber(inputAmount); isMaxSelected.value = false; - amount.value = inputAmountBn.lt(0) ? "0" : inputAmountBn.toFixed(); + amount.value = inputAmountBn.lt(0) ? "0" : inputAmount; if (isInputsValid.value) { updateTransactionFees(Tx.value); } diff --git a/packages/extension/src/providers/kadena/ui/send-transaction/components/send-input-amount.vue b/packages/extension/src/providers/kadena/ui/send-transaction/components/send-input-amount.vue deleted file mode 100644 index 8124653ea..000000000 --- a/packages/extension/src/providers/kadena/ui/send-transaction/components/send-input-amount.vue +++ /dev/null @@ -1,168 +0,0 @@ - - - - - diff --git a/packages/extension/src/providers/kadena/ui/send-transaction/index.vue b/packages/extension/src/providers/kadena/ui/send-transaction/index.vue index 50d5507f8..e64dcf0b1 100644 --- a/packages/extension/src/providers/kadena/ui/send-transaction/index.vue +++ b/packages/extension/src/providers/kadena/ui/send-transaction/index.vue @@ -65,8 +65,9 @@ @@ -103,7 +104,7 @@ import SendContactsList from "./components/send-contacts-list.vue"; import SendFromContactsList from "./components/send-from-contacts-list.vue"; import SendTokenSelect from "./components/send-token-select.vue"; import AssetsSelectList from "@action/views/assets-select-list/index.vue"; -import SendInputAmount from "./components/send-input-amount.vue"; +import SendInputAmount from "@/providers/common/ui/send-transaction/send-input-amount.vue"; import SendFeeSelect from "./components/send-fee-select.vue"; import SendAlert from "./components/send-alert.vue"; import BaseButton from "@action/components/base-button/index.vue"; @@ -399,9 +400,13 @@ const selectToken = (token: KDAToken | Partial) => { isOpenSelectToken.value = false; }; -const inputAmount = (number: string | undefined) => { +const inputAmount = (inputAmount: string) => { + if (inputAmount === "") { + inputAmount = "0"; + } + const inputAmountBn = new BigNumber(inputAmount); sendMax.value = false; - amount.value = number ? (parseFloat(number) < 0 ? "" : number) : number; + amount.value = inputAmountBn.lt(0) ? "0" : inputAmount; }; const sendButtonTitle = computed(() => { diff --git a/packages/extension/src/providers/polkadot/ui/send-transaction/components/send-input-amount.vue b/packages/extension/src/providers/polkadot/ui/send-transaction/components/send-input-amount.vue deleted file mode 100644 index 535dcd24e..000000000 --- a/packages/extension/src/providers/polkadot/ui/send-transaction/components/send-input-amount.vue +++ /dev/null @@ -1,169 +0,0 @@ - - - - - diff --git a/packages/extension/src/providers/polkadot/ui/send-transaction/index.vue b/packages/extension/src/providers/polkadot/ui/send-transaction/index.vue index 927f75aa4..36e767183 100644 --- a/packages/extension/src/providers/polkadot/ui/send-transaction/index.vue +++ b/packages/extension/src/providers/polkadot/ui/send-transaction/index.vue @@ -63,6 +63,7 @@ ) => { isOpenSelectToken.value = false; }; -const inputAmount = (number: string | undefined) => { +const inputAmount = (inputAmount: string) => { + if (inputAmount === "") { + inputAmount = "0"; + } + const inputAmountBn = new BigNumber(inputAmount); sendMax.value = false; - amount.value = number ? (parseFloat(number) < 0 ? "0" : number) : number; + amount.value = inputAmountBn.lt(0) ? "0" : inputAmount; validateFields(); }; @@ -423,12 +428,7 @@ const sendButtonTitle = computed(() => { return title; }); -const setSendMax = (max: boolean) => { - if (!max) { - sendMax.value = false; - return; - } - +const setSendMax = () => { if (selectedAsset.value) { const humanBalance = fromBase( selectedAsset.value.balance!, diff --git a/packages/extension/src/ui/action/views/swap/components/swap-token-amount-input/components/swap-token-amount-input.vue b/packages/extension/src/ui/action/views/swap/components/swap-token-amount-input/components/swap-token-amount-input.vue index 7b28fd736..c24bd72b3 100644 --- a/packages/extension/src/ui/action/views/swap/components/swap-token-amount-input/components/swap-token-amount-input.vue +++ b/packages/extension/src/ui/action/views/swap/components/swap-token-amount-input/components/swap-token-amount-input.vue @@ -2,19 +2,19 @@