From d95328c0a7d7889b803e8646dc9ca30cf377618b Mon Sep 17 00:00:00 2001 From: Fernando Paredes Garcia Date: Mon, 1 Apr 2024 03:20:37 -0500 Subject: [PATCH 01/15] Add Syscoin and Rollux networks support (Testnets and Mainnets) --- .../providers/etherscan/configs.ts | 4 ++++ .../src/providers/ethereum/networks/index.ts | 8 +++++++ .../src/providers/ethereum/networks/rlx.ts | 23 +++++++++++++++++++ .../src/providers/ethereum/networks/sys.ts | 23 +++++++++++++++++++ .../src/providers/ethereum/networks/trlx.ts | 23 +++++++++++++++++++ .../src/providers/ethereum/networks/tsys.ts | 23 +++++++++++++++++++ packages/types/src/networks.ts | 4 ++++ 7 files changed, 108 insertions(+) create mode 100644 packages/extension/src/providers/ethereum/networks/rlx.ts create mode 100644 packages/extension/src/providers/ethereum/networks/sys.ts create mode 100644 packages/extension/src/providers/ethereum/networks/trlx.ts create mode 100644 packages/extension/src/providers/ethereum/networks/tsys.ts diff --git a/packages/extension/src/providers/ethereum/libs/activity-handlers/providers/etherscan/configs.ts b/packages/extension/src/providers/ethereum/libs/activity-handlers/providers/etherscan/configs.ts index 54b8bcf51..30181213d 100644 --- a/packages/extension/src/providers/ethereum/libs/activity-handlers/providers/etherscan/configs.ts +++ b/packages/extension/src/providers/ethereum/libs/activity-handlers/providers/etherscan/configs.ts @@ -49,6 +49,10 @@ const NetworkEndpoints: Record = { [NetworkNames.FormTestnet]: "https://testnet-explorer.form.network/", [NetworkNames.ArtheraTest]: "https://explorer-test.arthera.net/", [NetworkNames.Arthera]: "https://explorer.arthera.net/", + [NetworkNames.SyscoinTest]: "https://tanenbaum.io/", + [NetworkNames.Syscoin]: "https://explorer.syscoin.org/", + [NetworkNames.RolluxTest]: "https://rollux.tanenbaum.io/", + [NetworkNames.Rollux]: "https://explorer.rollux.com/", }; export { NetworkEndpoints }; diff --git a/packages/extension/src/providers/ethereum/networks/index.ts b/packages/extension/src/providers/ethereum/networks/index.ts index e45505591..b486777fc 100644 --- a/packages/extension/src/providers/ethereum/networks/index.ts +++ b/packages/extension/src/providers/ethereum/networks/index.ts @@ -32,6 +32,10 @@ import shibNode from "./shib"; import artheraNode from "./aa"; import formTestnet from "./form-testnet"; import artheraTestNode from "./aat"; +import syscoinTestNode from "./tsys"; +import syscoinNode from "./sys"; +import rolluxTestNode from "./trlx"; +import rolluxNode from "./rlx"; export default { sepolia: sepoliaNode, @@ -77,4 +81,8 @@ export default { arthera: artheraNode, formTestnet: formTestnet, artheraTest: artheraTestNode, + syscoinTest: syscoinTestNode, + syscoin: syscoinNode, + rolluxTest: rolluxTestNode, + rollux: rolluxNode, }; diff --git a/packages/extension/src/providers/ethereum/networks/rlx.ts b/packages/extension/src/providers/ethereum/networks/rlx.ts new file mode 100644 index 000000000..52b459d00 --- /dev/null +++ b/packages/extension/src/providers/ethereum/networks/rlx.ts @@ -0,0 +1,23 @@ +import { NetworkNames } from "@enkryptcom/types"; +import { EvmNetwork, EvmNetworkOptions } from "../types/evm-network"; +import { EtherscanActivity } from "../libs/activity-handlers"; +import wrapActivityHandler from "@/libs/activity-state/wrap-activity-handler"; + +const rolluxOptions: EvmNetworkOptions = { + name: NetworkNames.Rollux, + name_long: "Syscoin ROLLUX", + homePage: "https://www.rollux.com/", + blockExplorerTX: "https://explorer.rollux.com/tx/[[txHash]]", + blockExplorerAddr: "https://explorer.rollux.com/address/[[address]]", + chainID: "0x23a", + isTestNetwork: false, + currencyName: "SYS", + currencyNameLong: "Syscoin", + node: "wss://rpc.rollux.com/wss", + icon: require("./icons/sys_rollux.svg"), + activityHandler: wrapActivityHandler(EtherscanActivity), +}; + +const rollux = new EvmNetwork(rolluxOptions); + +export default rollux; diff --git a/packages/extension/src/providers/ethereum/networks/sys.ts b/packages/extension/src/providers/ethereum/networks/sys.ts new file mode 100644 index 000000000..a5140c443 --- /dev/null +++ b/packages/extension/src/providers/ethereum/networks/sys.ts @@ -0,0 +1,23 @@ +import { NetworkNames } from "@enkryptcom/types"; +import { EvmNetwork, EvmNetworkOptions } from "../types/evm-network"; +import { EtherscanActivity } from "../libs/activity-handlers"; +import wrapActivityHandler from "@/libs/activity-state/wrap-activity-handler"; + +const syscoinOptions: EvmNetworkOptions = { + name: NetworkNames.Syscoin, + name_long: "Syscoin NEVM", + homePage: "https://www.syscoin.org/", + blockExplorerTX: "https://explorer.syscoin.org/tx/[[txHash]]", + blockExplorerAddr: "https://explorer.syscoin.org/address/[[address]]", + chainID: "0x39", + isTestNetwork: false, + currencyName: "SYS", + currencyNameLong: "Syscoin", + node: "wss://rpc.syscoin.org/wss", + icon: require("./icons/sys_nevm.svg"), + activityHandler: wrapActivityHandler(EtherscanActivity), +}; + +const syscoin = new EvmNetwork(syscoinOptions); + +export default syscoin; diff --git a/packages/extension/src/providers/ethereum/networks/trlx.ts b/packages/extension/src/providers/ethereum/networks/trlx.ts new file mode 100644 index 000000000..1b4e7245a --- /dev/null +++ b/packages/extension/src/providers/ethereum/networks/trlx.ts @@ -0,0 +1,23 @@ +import { NetworkNames } from "@enkryptcom/types"; +import { EvmNetwork, EvmNetworkOptions } from "../types/evm-network"; +import { EtherscanActivity } from "../libs/activity-handlers"; +import wrapActivityHandler from "@/libs/activity-state/wrap-activity-handler"; + +const rolluxTestOptions: EvmNetworkOptions = { + name: NetworkNames.RolluxTest, + name_long: "Syscoin ROLLUX Testnet", + homePage: "https://www.rollux.com/", + blockExplorerTX: "https://rollux.tanenbaum.io/tx/[[txHash]]", + blockExplorerAddr: "https://rollux.tanenbaum.io/address/[[address]]", + chainID: "0xdea8", + isTestNetwork: false, + currencyName: "TSYS", + currencyNameLong: "Test Syscoin", + node: "wss://rpc-tanenbaum.rollux.com/wss", + icon: require("./icons/tsys_rollux.svg"), + activityHandler: wrapActivityHandler(EtherscanActivity), +}; + +const rolluxTest = new EvmNetwork(rolluxTestOptions); + +export default rolluxTest; diff --git a/packages/extension/src/providers/ethereum/networks/tsys.ts b/packages/extension/src/providers/ethereum/networks/tsys.ts new file mode 100644 index 000000000..25bcc3770 --- /dev/null +++ b/packages/extension/src/providers/ethereum/networks/tsys.ts @@ -0,0 +1,23 @@ +import { NetworkNames } from "@enkryptcom/types"; +import { EvmNetwork, EvmNetworkOptions } from "../types/evm-network"; +import { EtherscanActivity } from "../libs/activity-handlers"; +import wrapActivityHandler from "@/libs/activity-state/wrap-activity-handler"; + +const syscoinTestOptions: EvmNetworkOptions = { + name: NetworkNames.SyscoinTest, + name_long: "Syscoin NEVM Testnet", + homePage: "https://www.syscoin.org/", + blockExplorerTX: "https://tanenbaum.io/tx/[[txHash]]", + blockExplorerAddr: "https://tanenbaum.io/address/[[address]]", + chainID: "0x1644", + isTestNetwork: false, + currencyName: "TSYS", + currencyNameLong: "Test Syscoin", + node: "wss://rpc.tanenbaum.io/wss", + icon: require("./icons/tsys_nevm.svg"), + activityHandler: wrapActivityHandler(EtherscanActivity), +}; + +const syscoinTest = new EvmNetwork(syscoinTestOptions); + +export default syscoinTest; diff --git a/packages/types/src/networks.ts b/packages/types/src/networks.ts index 6669787db..6ce780d76 100644 --- a/packages/types/src/networks.ts +++ b/packages/types/src/networks.ts @@ -64,6 +64,10 @@ export enum NetworkNames { FormTestnet = "FormTestnet", AssetHubDOT = "AssetHubDOT", AssetHubKSM = "AssetHubKSM", + SyscoinTest = "TSYS", + Syscoin = "SYS", + RolluxTest = "TRLX", + Rollux = "RLX", } export enum CoingeckoPlatform { From 3f08a4bd4e3994ed9602c756a4582509589bae6e Mon Sep 17 00:00:00 2001 From: Fernando Paredes Garcia Date: Mon, 1 Apr 2024 17:42:07 -0500 Subject: [PATCH 02/15] Add Syscoin and Rollux icons --- .../ethereum/networks/icons/sys_nevm.svg | 56 +++++++++++++++++++ .../ethereum/networks/icons/sys_rollux.svg | 36 ++++++++++++ .../ethereum/networks/icons/tsys_nevm.svg | 52 +++++++++++++++++ .../ethereum/networks/icons/tsys_rollux.svg | 34 +++++++++++ 4 files changed, 178 insertions(+) create mode 100644 packages/extension/src/providers/ethereum/networks/icons/sys_nevm.svg create mode 100644 packages/extension/src/providers/ethereum/networks/icons/sys_rollux.svg create mode 100644 packages/extension/src/providers/ethereum/networks/icons/tsys_nevm.svg create mode 100644 packages/extension/src/providers/ethereum/networks/icons/tsys_rollux.svg diff --git a/packages/extension/src/providers/ethereum/networks/icons/sys_nevm.svg b/packages/extension/src/providers/ethereum/networks/icons/sys_nevm.svg new file mode 100644 index 000000000..235f7571d --- /dev/null +++ b/packages/extension/src/providers/ethereum/networks/icons/sys_nevm.svg @@ -0,0 +1,56 @@ + + + + + + + + + + + + + + + + + diff --git a/packages/extension/src/providers/ethereum/networks/icons/sys_rollux.svg b/packages/extension/src/providers/ethereum/networks/icons/sys_rollux.svg new file mode 100644 index 000000000..40f6876f6 --- /dev/null +++ b/packages/extension/src/providers/ethereum/networks/icons/sys_rollux.svg @@ -0,0 +1,36 @@ + + + + + + + + + + + + + diff --git a/packages/extension/src/providers/ethereum/networks/icons/tsys_nevm.svg b/packages/extension/src/providers/ethereum/networks/icons/tsys_nevm.svg new file mode 100644 index 000000000..82f6622ff --- /dev/null +++ b/packages/extension/src/providers/ethereum/networks/icons/tsys_nevm.svg @@ -0,0 +1,52 @@ + + + + + + + + + + + + + + + diff --git a/packages/extension/src/providers/ethereum/networks/icons/tsys_rollux.svg b/packages/extension/src/providers/ethereum/networks/icons/tsys_rollux.svg new file mode 100644 index 000000000..5650aa0a4 --- /dev/null +++ b/packages/extension/src/providers/ethereum/networks/icons/tsys_rollux.svg @@ -0,0 +1,34 @@ + + + + + + + + + + + From aa7bf5745e725867aadd10fa4d49071b02d9961a Mon Sep 17 00:00:00 2001 From: kvhnuke <10602065+kvhnuke@users.noreply.github.com> Date: Thu, 2 May 2024 14:21:34 -0700 Subject: [PATCH 03/15] feat: add swap to base and maticzk --- packages/swap/src/common/supportedNetworks.ts | 24 +++++++++++++++++++ packages/swap/src/configs.ts | 2 ++ packages/swap/src/providers/oneInch/index.ts | 4 ++++ packages/swap/src/providers/paraswap/index.ts | 8 +++++++ packages/swap/src/providers/zerox/index.ts | 4 ++++ packages/swap/src/types/index.ts | 2 ++ 6 files changed, 44 insertions(+) diff --git a/packages/swap/src/common/supportedNetworks.ts b/packages/swap/src/common/supportedNetworks.ts index ab58b68bc..e7a16d346 100644 --- a/packages/swap/src/common/supportedNetworks.ts +++ b/packages/swap/src/common/supportedNetworks.ts @@ -50,6 +50,18 @@ const NetworkDetails: Record = { signerType: [SignerType.secp256k1], type: NetworkType.EVM, }, + [SupportedNetworkName.MaticZK]: { + id: SupportedNetworkName.MaticZK, + cgId: "matic-network", + decimals: 18, + logoURI: + "https://tokens.1inch.io/0x7d1afa7b718fb893db30a3abc0cfc608aacfebb0.png", + name: "Polygon ZK", + symbol: "MATIC", + rank: 4, + signerType: [SignerType.secp256k1], + type: NetworkType.EVM, + }, [SupportedNetworkName.Optimism]: { id: SupportedNetworkName.Optimism, cgId: "optimism", @@ -62,6 +74,18 @@ const NetworkDetails: Record = { signerType: [SignerType.secp256k1], type: NetworkType.EVM, }, + [SupportedNetworkName.Base]: { + id: SupportedNetworkName.Base, + cgId: "ethereum", + decimals: 18, + logoURI: + "https://assets.coingecko.com/asset_platforms/images/131/large/base.jpeg", + name: "Base", + signerType: [SignerType.secp256k1], + type: NetworkType.EVM, + rank: 6, + symbol: "ETH", + }, [SupportedNetworkName.Arbitrum]: { id: SupportedNetworkName.Arbitrum, cgId: "ethereum", diff --git a/packages/swap/src/configs.ts b/packages/swap/src/configs.ts index 90405a66b..ded2ffc0b 100644 --- a/packages/swap/src/configs.ts +++ b/packages/swap/src/configs.ts @@ -61,6 +61,8 @@ const TOKEN_LISTS: { [NetworkNames.Gnosis]: `https://raw.githubusercontent.com/enkryptcom/dynamic-data/main/swaplists/${SupportedNetworkName.Gnosis}.json`, [NetworkNames.Klaytn]: `https://raw.githubusercontent.com/enkryptcom/dynamic-data/main/swaplists/${SupportedNetworkName.Klaytn}.json`, [NetworkNames.ZkSync]: `https://raw.githubusercontent.com/enkryptcom/dynamic-data/main/swaplists/${SupportedNetworkName.Zksync}.json`, + [NetworkNames.Base]: `https://raw.githubusercontent.com/enkryptcom/dynamic-data/main/swaplists/${SupportedNetworkName.Base}.json`, + [NetworkNames.MaticZK]: `https://raw.githubusercontent.com/enkryptcom/dynamic-data/main/swaplists/${SupportedNetworkName.MaticZK}.json`, }; const CHANGELLY_LIST = diff --git a/packages/swap/src/providers/oneInch/index.ts b/packages/swap/src/providers/oneInch/index.ts index 22f1bb508..ddd1cadc2 100644 --- a/packages/swap/src/providers/oneInch/index.ts +++ b/packages/swap/src/providers/oneInch/index.ts @@ -79,6 +79,10 @@ const supportedNetworks: { approvalAddress: ONEINCH_APPROVAL_ADDRESS, chainId: "42161", }, + [SupportedNetworkName.Base]: { + approvalAddress: ONEINCH_APPROVAL_ADDRESS, + chainId: "8453", + }, [SupportedNetworkName.Zksync]: { approvalAddress: "0x6fd4383cb451173d5f9304f041c7bcbf27d561ff", chainId: "324", diff --git a/packages/swap/src/providers/paraswap/index.ts b/packages/swap/src/providers/paraswap/index.ts index 6eeff90e8..817c42f7c 100644 --- a/packages/swap/src/providers/paraswap/index.ts +++ b/packages/swap/src/providers/paraswap/index.ts @@ -68,6 +68,14 @@ const supportedNetworks: { approvalAddress: PARASWAP_APPROVAL_ADDRESS, chainId: "42161", }, + [SupportedNetworkName.Base]: { + approvalAddress: "0x93aAAe79a53759cD164340E4C8766E4Db5331cD7", + chainId: "8453", + }, + [SupportedNetworkName.MaticZK]: { + approvalAddress: "0xc8a21fcd5a100c3ecc037c97e2f9c53a8d3a02a1", + chainId: "1101", + }, }; const BASE_URL = "https://apiv5.paraswap.io/"; diff --git a/packages/swap/src/providers/zerox/index.ts b/packages/swap/src/providers/zerox/index.ts index b1ddc1a7e..174c30f83 100644 --- a/packages/swap/src/providers/zerox/index.ts +++ b/packages/swap/src/providers/zerox/index.ts @@ -65,6 +65,10 @@ const supportedNetworks: { approvalAddress: "0xdef1c0ded9bec7f1a1670819833240f027b25eff", chainId: "42161", }, + [SupportedNetworkName.Base]: { + approvalAddress: "0xdef1c0ded9bec7f1a1670819833240f027b25eff", + chainId: "1101", + }, }; const BASE_URL = "https://partners.mewapi.io/zerox/"; diff --git a/packages/swap/src/types/index.ts b/packages/swap/src/types/index.ts index ac1e38b84..d4397e207 100644 --- a/packages/swap/src/types/index.ts +++ b/packages/swap/src/types/index.ts @@ -27,6 +27,8 @@ export enum SupportedNetworkName { Klaytn = NetworkNames.Klaytn, Aurora = NetworkNames.Aurora, Zksync = NetworkNames.ZkSync, + Base = NetworkNames.Base, + MaticZK = NetworkNames.MaticZK, } // eslint-disable-next-line no-shadow From 84ae8b9eaca33a1fff71be7e62a447dae54410fd Mon Sep 17 00:00:00 2001 From: kvhnuke <10602065+kvhnuke@users.noreply.github.com> Date: Mon, 6 May 2024 14:57:26 -0700 Subject: [PATCH 04/15] fix: number input decimal error --- .../bitcoin/ui/send-transaction/index.vue | 2 +- .../ui/send-transaction/send-input-amount.vue | 15 +- .../ethereum/ui/send-transaction/index.vue | 2 +- .../components/send-input-amount.vue | 168 ----------------- .../kadena/ui/send-transaction/index.vue | 13 +- .../components/send-input-amount.vue | 169 ------------------ .../polkadot/ui/send-transaction/index.vue | 18 +- .../components/swap-token-amount-input.vue | 16 +- 8 files changed, 45 insertions(+), 358 deletions(-) delete mode 100644 packages/extension/src/providers/kadena/ui/send-transaction/components/send-input-amount.vue delete mode 100644 packages/extension/src/providers/polkadot/ui/send-transaction/components/send-input-amount.vue 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 @@