From 40c87706a8e798979206202c428de61c7eeb7c39 Mon Sep 17 00:00:00 2001 From: Pedro Semeano Date: Fri, 20 Dec 2024 12:08:34 +0000 Subject: [PATCH] fix: remove unused files --- .../renderer/families/aptos/GasPriceField.tsx | 83 ------------------ .../families/aptos/MaxGasAmountField.tsx | 86 ------------------- 2 files changed, 169 deletions(-) delete mode 100644 apps/ledger-live-desktop/src/renderer/families/aptos/GasPriceField.tsx delete mode 100644 apps/ledger-live-desktop/src/renderer/families/aptos/MaxGasAmountField.tsx diff --git a/apps/ledger-live-desktop/src/renderer/families/aptos/GasPriceField.tsx b/apps/ledger-live-desktop/src/renderer/families/aptos/GasPriceField.tsx deleted file mode 100644 index 73ec773009d7..000000000000 --- a/apps/ledger-live-desktop/src/renderer/families/aptos/GasPriceField.tsx +++ /dev/null @@ -1,83 +0,0 @@ -import React, { useCallback, useState, forwardRef, useImperativeHandle } from "react"; -import { BigNumber } from "bignumber.js"; -import { Result } from "@ledgerhq/live-common/bridge/useBridgeTransaction"; -import invariant from "invariant"; -import { Account } from "@ledgerhq/types-live"; -import { getAccountBridge } from "@ledgerhq/live-common/bridge/index"; -import { getMainAccount } from "@ledgerhq/live-common/account/index"; -import Box from "~/renderer/components/Box"; -import Input from "~/renderer/components/Input"; -import Label from "~/renderer/components/Label"; -import { Transaction, TransactionStatus } from "@ledgerhq/live-common/generated/types"; -import { DEFAULT_GAS_PRICE } from "@ledgerhq/live-common/families/aptos/logic"; -import { useTranslation } from "react-i18next"; - -type AptosTransaction = Extract; -type Props = { - account: Account; - parentAccount: Account | null | undefined; - transaction: Transaction; - status: TransactionStatus; - updateTransaction: Result["updateTransaction"]; -}; - -const FeesField = forwardRef(function FeesFieldComponent( - { account, parentAccount, transaction, status, updateTransaction }: Props, - ref, -) { - invariant(transaction.family === "aptos", "FeeField: aptos family expected"); - const mainAccount = getMainAccount(account, parentAccount); - invariant(mainAccount, "Account required"); - const { t } = useTranslation(); - const [localValue, setLocalValue] = useState(null); - const bridge = getAccountBridge(mainAccount); - - useImperativeHandle(ref, () => ({ - resetData: () => { - setLocalValue(transaction.estimate.gasUnitPrice); - }, - })); - - const onGasPriceChange = useCallback( - (str: string) => { - if (str && !BigNumber(str).isFinite()) return; - setLocalValue(str); - updateTransaction((transaction: AptosTransaction) => - bridge.updateTransaction(transaction, { - options: { - ...transaction.options, - gasUnitPrice: str || transaction.estimate.gasUnitPrice, - }, - }), - ); - }, - [updateTransaction, bridge], - ); - - const gasUnitPrice = transaction.firstEmulation - ? transaction.estimate.gasUnitPrice - : localValue ?? transaction.options.gasUnitPrice ?? transaction.estimate.gasUnitPrice; - const { gasUnitPrice: gasPriceError } = status.errors; - const { gasUnitPrice: gasPriceWarning } = status.warnings; - return ( - - - - - - - - - ); -}); -export default FeesField; diff --git a/apps/ledger-live-desktop/src/renderer/families/aptos/MaxGasAmountField.tsx b/apps/ledger-live-desktop/src/renderer/families/aptos/MaxGasAmountField.tsx deleted file mode 100644 index a6fc090da057..000000000000 --- a/apps/ledger-live-desktop/src/renderer/families/aptos/MaxGasAmountField.tsx +++ /dev/null @@ -1,86 +0,0 @@ -import React, { forwardRef, useCallback, useState, useImperativeHandle } from "react"; -import { Transaction, TransactionStatus } from "@ledgerhq/live-common/generated/types"; -import { Result } from "@ledgerhq/live-common/bridge/useBridgeTransaction"; -import { getAccountBridge } from "@ledgerhq/live-common/bridge/index"; -import { getMainAccount } from "@ledgerhq/live-common/account/index"; -import { Account, AccountLike } from "@ledgerhq/types-live"; -import { useTranslation } from "react-i18next"; -import { BigNumber } from "bignumber.js"; -import invariant from "invariant"; -import Box from "~/renderer/components/Box"; -import Input from "~/renderer/components/Input"; -import Label from "~/renderer/components/Label"; - -import { DEFAULT_GAS } from "@ledgerhq/live-common/families/aptos/logic"; - -type AptosTransaction = Extract; -type Props = { - transaction: AptosTransaction; - account: AccountLike; - parentAccount: Account | null | undefined; - status: TransactionStatus; - updateTransaction: Result["updateTransaction"]; -}; - -const MaxGasAmountField = forwardRef(function MaxGasAmountFieldComponent( - { account, parentAccount, transaction, status, updateTransaction }: Props, - ref, -) { - invariant(transaction.family === "aptos", "MaxGasAmount: aptos family expected"); - const mainAccount = getMainAccount(account, parentAccount); - invariant(mainAccount, "Account required"); - const bridge = getAccountBridge(mainAccount); - const { t } = useTranslation(); - const [localValue, setLocalValue] = useState(null); - - useImperativeHandle(ref, () => ({ - resetData: () => { - setLocalValue(transaction.estimate.maxGasAmount); - }, - })); - - const onMaxGasAmountChange = useCallback( - (str: string) => { - if (str && !BigNumber(str).isFinite()) return; - setLocalValue(str); - updateTransaction((transaction: AptosTransaction) => - bridge.updateTransaction(transaction, { - options: { - ...transaction.options, - maxGasAmount: str || transaction.estimate.maxGasAmount, - }, - }), - ); - }, - [bridge, updateTransaction], - ); - - const maxGasAmount = transaction.firstEmulation - ? transaction.estimate.maxGasAmount - : localValue ?? transaction.options.maxGasAmount ?? transaction.estimate.maxGasAmount; - const { maxGasAmount: maxGasAmountError } = status.errors; - const { maxGasAmount: maxGasAmountWarning } = status.warnings; - - return ( - - - - - - - - - ); -}); - -export default MaxGasAmountField;