diff --git a/apps/ledger-live-desktop/src/renderer/families/aptos/SendAmountFields.tsx b/apps/ledger-live-desktop/src/renderer/families/aptos/SendAmountFields.tsx deleted file mode 100644 index d90d482cf017..000000000000 --- a/apps/ledger-live-desktop/src/renderer/families/aptos/SendAmountFields.tsx +++ /dev/null @@ -1,100 +0,0 @@ -import invariant from "invariant"; -import React, { useState, useCallback, useRef, useMemo } from "react"; -import { useTranslation } from "react-i18next"; -import { Transaction } from "@ledgerhq/live-common/generated/types"; -import Button from "~/renderer/components/Button"; -import Box from "~/renderer/components/Box"; -import Label from "~/renderer/components/Label"; -import { getAccountBridge } from "@ledgerhq/live-common/bridge/index"; -import { getMainAccount } from "@ledgerhq/live-common/account/index"; -import SequenceNumberField from "./SequenceNumberField"; -import ExpirationTimestampField from "./ExpirationTimestampField"; -import { AptosFamily } from "./types"; - -type AptosTransaction = Extract; - -type Props = NonNullable["component"]; - -const Fields: Props = ({ account, parentAccount, transaction, updateTransaction, status }) => { - invariant(transaction.family === "aptos", "SendAmountFields: aptos family expected"); - const mainAccount = getMainAccount(account, parentAccount); - invariant(mainAccount, "Account required"); - const { t } = useTranslation(); - - const [isSettings, setIsSettings] = useState(true); - - const sequenceNumberElement = useRef<{ resetData: () => void }>(); - const expirationTimestampElement = useRef<{ resetData: () => void }>(); - - const resetSettings = useCallback(() => { - sequenceNumberElement.current?.resetData(); - expirationTimestampElement.current?.resetData(); - - const bridge = getAccountBridge(mainAccount); - updateTransaction((transaction: AptosTransaction) => - bridge.updateTransaction(transaction, { - options: { - ...transaction.options, - sequenceNumber: "", - expirationTimestampSecs: "", - }, - errors: Object.assign({}, transaction.errors, { - sequenceNumber: "", - expirationTimestampSecs: "", - }), - }), - ); - }, [mainAccount, updateTransaction]); - - const wrapperProps = useMemo(() => { - const props = Object.create(null); - if (transaction.amount.isZero()) props.style = { opacity: 0.2, pointerEvents: "none" }; - return props; - }, [transaction.amount]); - - return ( - - - - - - - - - - - - - ); -}; -export default { - component: Fields, - fields: ["gasUnitPrice", "maxGasAmount", "sequenceNumber", "expirationTimestampSecs"], -}; diff --git a/apps/ledger-live-desktop/src/renderer/families/aptos/SequenceNumberField.tsx b/apps/ledger-live-desktop/src/renderer/families/aptos/SequenceNumberField.tsx deleted file mode 100644 index 0460950e0409..000000000000 --- a/apps/ledger-live-desktop/src/renderer/families/aptos/SequenceNumberField.tsx +++ /dev/null @@ -1,85 +0,0 @@ -import React, { forwardRef, useCallback, useImperativeHandle, useState } from "react"; -import { useTranslation } from "react-i18next"; -import { BigNumber } from "bignumber.js"; -import invariant from "invariant"; -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 { Account } from "@ledgerhq/types-live"; -import { Transaction, TransactionStatus } from "@ledgerhq/live-common/generated/types"; -import { Result } from "@ledgerhq/live-common/bridge/useBridgeTransaction"; - -type AptosTransaction = Extract; -type Props = { - account: Account; - parentAccount: Account | null | undefined; - transaction: AptosTransaction; - status: TransactionStatus; - updateTransaction: Result["updateTransaction"]; -}; - -const SequenceNumberField = forwardRef(function SequenceNumberFieldComponent( - { account, parentAccount, transaction, status, updateTransaction }: Props, - ref, -) { - invariant(transaction.family === "aptos", "SequenceNumber: 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(""); - }, - })); - - const onSequenceNumberChange = useCallback( - (str: string) => { - if (str && !BigNumber(str).isFinite()) { - return; - } - setLocalValue(str); - updateTransaction((transaction: AptosTransaction) => - bridge.updateTransaction(transaction, { - options: { - ...transaction.options, - sequenceNumber: str, - }, - errors: Object.assign({}, transaction.errors, { sequenceNumber: "" }), - }), - ); - }, - [updateTransaction, bridge], - ); - - const sequenceNumber = transaction.firstEmulation ? "" : localValue ?? ""; - const { sequenceNumber: sequenceNumberError } = status.errors; - const { sequenceNumber: sequenceNumberWarning } = status.warnings; - - return ( - - - - - - - - - ); -}); - -export default SequenceNumberField; diff --git a/apps/ledger-live-desktop/src/renderer/families/aptos/index.ts b/apps/ledger-live-desktop/src/renderer/families/aptos/index.ts index 8a65592ea948..481721d45aa3 100644 --- a/apps/ledger-live-desktop/src/renderer/families/aptos/index.ts +++ b/apps/ledger-live-desktop/src/renderer/families/aptos/index.ts @@ -1,8 +1,5 @@ -import sendAmountFields from "./SendAmountFields"; import { AptosFamily } from "./types"; -const family: AptosFamily = { - sendAmountFields, -}; +const family: AptosFamily = {}; export default family; diff --git a/apps/ledger-live-desktop/static/i18n/en/app.json b/apps/ledger-live-desktop/static/i18n/en/app.json index 5bcf2124d1be..6eb7e74d87b5 100644 --- a/apps/ledger-live-desktop/static/i18n/en/app.json +++ b/apps/ledger-live-desktop/static/i18n/en/app.json @@ -2356,10 +2356,6 @@ "aptosGasLimit": "Gas Limit", "aptosGasPrice": "Gas Price (OCTAS)", "aptosSetOptimalGas": "SET OPTIMAL GAS", - "aptosAdditionalSettings": "Additional settings", - "aptosSequenceNumber": "Sequence Number", - "aptosExpTimestamp": "Exp. Timestamp", - "aptosResetSettings": "RESET SETTINGS", "nextBlock": "Next block", "suggested": "Suggested", "unitPerByte": "{{unit}} per byte",