Skip to content

Commit

Permalink
Merge pull request #8665 from LedgerHQ/fix/live-15143-revert
Browse files Browse the repository at this point in the history
Revert "fix(lld): use a debounce on memotag field"
  • Loading branch information
KVNLS authored Dec 10, 2024
2 parents c8c382f + c403d9e commit f5af5bb
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 36 deletions.
5 changes: 0 additions & 5 deletions .changeset/seven-ravens-rest.md

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,6 @@ import { render, screen, fireEvent } from "tests/testUtils";
import MemoTagField from "../components/MemoTagField";

describe("MemoTagField", () => {
beforeAll(() => {
jest.useFakeTimers();
});

afterAll(() => {
jest.useRealTimers();
});

it("renders MemoTagField with label and text field", () => {
render(<MemoTagField showLabel={true} />);
expect(screen.getByText(/Tag \/ Memo/gi)).toBeInTheDocument();
Expand All @@ -27,14 +19,12 @@ describe("MemoTagField", () => {
expect(screen.queryByText(/Tag \/ Memo/gi)).not.toBeInTheDocument();
});

it("should call onChange when input value changes with a debounce", () => {
it("should call onChange when input value changes", () => {
const handleChange = jest.fn();
render(<MemoTagField onChange={handleChange} />);
fireEvent.change(screen.getByPlaceholderText(/Enter Tag \/ Memo/gi), {
target: { value: "new memo" },
});
expect(handleChange).not.toHaveBeenCalled();
jest.runAllTimers();
expect(handleChange).toHaveBeenCalledTimes(1);
});

Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import React, { useState, useEffect } from "react";
import React from "react";
import Input, { Props as InputBaseProps } from "~/renderer/components/Input";
import { useDebounce } from "@ledgerhq/live-common//hooks/useDebounce";
import Label from "~/renderer/components/Label";
import Box from "~/renderer/components/Box";
import { useTranslation } from "react-i18next";
import { Flex, Text, Tooltip } from "@ledgerhq/react-ui";
import styled from "styled-components";
import InfoCircle from "~/renderer/icons/InfoCircle";

const TooltipContainer = styled(Box)`
background-color: ${({ theme }) => theme.colors.palette.neutral.c100};
padding: 10px;
Expand All @@ -30,7 +30,6 @@ type MemoTagFieldProps = InputBaseProps & {
placeholder?: string;
label?: string;
tooltipText?: string;
validationHandler?: (newValue: string) => string;
};

const MemoTagField = ({
Expand All @@ -45,20 +44,8 @@ const MemoTagField = ({
placeholder,
label,
tooltipText,
validationHandler,
}: MemoTagFieldProps) => {
const { t } = useTranslation();
const [memoValue, setMemoValue] = useState(value);
const debouncedMemoValue = useDebounce(memoValue, 300);

useEffect(() => {
if (debouncedMemoValue !== value) onChange?.(debouncedMemoValue || "");
}, [debouncedMemoValue, onChange, value]);

const handleChange = (newValue: string) => {
setMemoValue(validationHandler ? validationHandler(newValue) : newValue);
};

return (
<Box flow={1}>
{showLabel && (
Expand All @@ -81,10 +68,10 @@ const MemoTagField = ({
<Flex justifyContent="end">{CaracterCountComponent && <CaracterCountComponent />}</Flex>
<Input
placeholder={placeholder ?? t("MemoTagField.placeholder")}
onChange={handleChange}
onChange={onChange}
warning={warning}
error={error}
value={memoValue}
value={value}
spellCheck="false"
ff="Inter"
maxMemoLength={maxMemoLength}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const MemoField = ({ onChange, account, transaction, status, autoFocus }: MemoTa

const onTransferIdFieldChange = useCallback(
(value: string) => {
value = value.replace(/\D/g, "");
if (value !== "") onChange(bridge.updateTransaction(transaction, { transferId: value }));
else onChange(bridge.updateTransaction(transaction, { transferId: undefined }));
},
Expand All @@ -31,7 +32,6 @@ const MemoField = ({ onChange, account, transaction, status, autoFocus }: MemoTa
onChange={onTransferIdFieldChange}
spellCheck="false"
autoFocus={autoFocus}
validationHandler={newValue => newValue.replace(/\D/g, "")}
/>
);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const TagField = ({ onChange, account, transaction, autoFocus }: Props) => {
const onChangeTag = useCallback(
(str: string) => {
const bridge = getAccountBridge(account);
const tag = BigNumber(str);
const tag = BigNumber(str.replace(/[^0-9]/g, ""));
const patch = {
tag:
!tag.isNaN() &&
Expand All @@ -37,7 +37,6 @@ const TagField = ({ onChange, account, transaction, autoFocus }: Props) => {
value={String(transaction.tag || "")}
onChange={onChangeTag}
autoFocus={autoFocus}
validationHandler={str => str.replace(/[^0-9]/g, "")}
/>
);
};
Expand Down

2 comments on commit f5af5bb

@github-actions
Copy link

Choose a reason for hiding this comment

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

[Bot] Evm on Staging ($0.00) ⏲ 20.2s

What is the bot and how does it work? Everything is documented here!

3 critical spec errors

Spec Ethereum failed!

Error: getaddrinfo ENOTFOUND atlas-stg.ledger-test.com

Spec Ethereum Sepolia failed!

Error: getaddrinfo ENOTFOUND atlas-stg.ledger-test.com

Spec Ethereum Holesky failed!

Error: getaddrinfo ENOTFOUND atlas-stg.ledger-test.com
Details of the 0 mutations

Spec Ethereum (failed)


Spec Ethereum Sepolia (failed)


Spec Ethereum Holesky (failed)


Details of the 9 uncovered mutations

Spec Ethereum (3)

  • move 50%:
  • send max:
  • move some ERC20 like (ERC20, BEP20, etc...):

Spec Ethereum Sepolia (3)

  • move 50%:
  • send max:
  • move some ERC20 like (ERC20, BEP20, etc...):

Spec Ethereum Holesky (3)

  • move 50%:
  • send max:
  • move some ERC20 like (ERC20, BEP20, etc...):
Portfolio ($0.00) – Details of the 3 currencies
Spec (accounts) State Remaining Runs (est) funds?
Ethereum (0) 0 ops , 🤷‍♂️ ``
Ethereum Sepolia (0) 0 ops , 🤷‍♂️ ``
Ethereum Holesky (0) 0 ops , 🤷‍♂️ ``

Performance ⏲ 20.2s

Time spent for each spec: (total across mutations)

Spec (accounts) preload scan re-sync tx status sign op broadcast test destination test
TOTAL 1031ms N/A N/A N/A N/A N/A N/A N/A
Ethereum (0) 722ms N/A N/A N/A N/A N/A N/A N/A
Ethereum Sepolia (0) 120ms N/A N/A N/A N/A N/A N/A N/A
Ethereum Holesky (0) 189ms N/A N/A N/A N/A N/A N/A N/A

What is the bot and how does it work? Everything is documented here!

@github-actions
Copy link

Choose a reason for hiding this comment

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

[Bot] Bitcoin on Staging ($0.00) ⏲ 56.7s

What is the bot and how does it work? Everything is documented here!

13 critical spec errors

Spec Bitcoin failed!

TransportStatusError: Ledger device: UNKNOWN_ERROR (0x6a86)

Spec Bitcoin Testnet failed!

Error: getaddrinfo ENOTFOUND atlas-stg.ledger-test.com

Spec Bitcoin Cash failed!

Error: getaddrinfo ENOTFOUND atlas-stg.ledger-test.com

Spec Bitcoin Gold failed!

Error: getaddrinfo ENOTFOUND atlas-stg.ledger-test.com

Spec Dash failed!

Error: getaddrinfo ENOTFOUND atlas-stg.ledger-test.com

Spec Digibyte failed!

Error: getaddrinfo ENOTFOUND atlas-stg.ledger-test.com

Spec DogeCoin failed!

Error: getaddrinfo ENOTFOUND atlas-stg.ledger-test.com

Spec Komodo failed!

Error: getaddrinfo ENOTFOUND atlas-stg.ledger-test.com

Spec Litecoin failed!

Error: getaddrinfo ENOTFOUND atlas-stg.ledger-test.com

Spec Qtum failed!

Error: getaddrinfo ENOTFOUND atlas-stg.ledger-test.com

Spec ZCash failed!

Error: getaddrinfo ENOTFOUND atlas-stg.ledger-test.com

Spec Horizen failed!

Error: getaddrinfo ENOTFOUND atlas-stg.ledger-test.com

Spec Decred failed!

Error: getaddrinfo ENOTFOUND atlas-stg.ledger-test.com
Details of the 0 mutations

Spec Bitcoin (failed)


Spec Bitcoin Testnet (failed)


Spec Bitcoin Cash (failed)


Spec Bitcoin Gold (failed)


Spec Dash (failed)


Spec Digibyte (failed)


Spec DogeCoin (failed)


Spec Komodo (failed)


Spec Litecoin (failed)


Spec Qtum (failed)


Spec ZCash (failed)


Spec Horizen (failed)


Spec Decred (failed)


Details of the 65 uncovered mutations

Spec Bitcoin (5)

  • move ~50%:
  • optimize-size:
  • send 1 utxo:
  • send OP_RETURN transaction:
  • send max:

Spec Bitcoin Testnet (5)

  • move ~50%:
  • optimize-size:
  • send 1 utxo:
  • send OP_RETURN transaction:
  • send max:

Spec Bitcoin Cash (5)

  • move ~50%:
  • optimize-size:
  • send 1 utxo:
  • send OP_RETURN transaction:
  • send max:

Spec Bitcoin Gold (5)

  • move ~50%:
  • optimize-size:
  • send 1 utxo:
  • send OP_RETURN transaction:
  • send max:

Spec Dash (5)

  • move ~50%:
  • optimize-size:
  • send 1 utxo:
  • send OP_RETURN transaction:
  • send max:

Spec Digibyte (5)

  • move ~50%:
  • optimize-size:
  • send 1 utxo:
  • send OP_RETURN transaction:
  • send max:

Spec DogeCoin (5)

  • move ~50%:
  • optimize-size:
  • send 1 utxo:
  • send OP_RETURN transaction:
  • send max:

Spec Komodo (5)

  • move ~50%:
  • optimize-size:
  • send 1 utxo:
  • send OP_RETURN transaction:
  • send max:

Spec Litecoin (5)

  • move ~50%:
  • optimize-size:
  • send 1 utxo:
  • send OP_RETURN transaction:
  • send max:

Spec Qtum (5)

  • move ~50%:
  • optimize-size:
  • send 1 utxo:
  • send OP_RETURN transaction:
  • send max:

Spec ZCash (5)

  • move ~50%:
  • optimize-size:
  • send 1 utxo:
  • send OP_RETURN transaction:
  • send max:

Spec Horizen (5)

  • move ~50%:
  • optimize-size:
  • send 1 utxo:
  • send OP_RETURN transaction:
  • send max:

Spec Decred (5)

  • move ~50%:
  • optimize-size:
  • send 1 utxo:
  • send OP_RETURN transaction:
  • send max:
Portfolio ($0.00) – Details of the 13 currencies
Spec (accounts) State Remaining Runs (est) funds?
Bitcoin (0) 0 ops , 🤷‍♂️ ``
Bitcoin Testnet (0) 0 ops , 🤷‍♂️ ``
Bitcoin Cash (0) 0 ops , 🤷‍♂️ ``
Bitcoin Gold (0) 0 ops , 🤷‍♂️ ``
Dash (0) 0 ops , 🤷‍♂️ ``
Digibyte (0) 0 ops , 🤷‍♂️ ``
DogeCoin (0) 0 ops , 🤷‍♂️ ``
Komodo (0) 0 ops , 🤷‍♂️ ``
Litecoin (0) 0 ops , 🤷‍♂️ ``
Qtum (0) 0 ops , 🤷‍♂️ ``
ZCash (0) 0 ops , 🤷‍♂️ ``
Horizen (0) 0 ops , 🤷‍♂️ ``
Decred (0) 0 ops , 🤷‍♂️ ``

Performance ⏲ 56.7s

Time spent for each spec: (total across mutations)

Spec (accounts) preload scan re-sync tx status sign op broadcast test destination test
TOTAL 6ms N/A N/A N/A N/A N/A N/A N/A
Bitcoin (0) 0.65ms N/A N/A N/A N/A N/A N/A N/A
Bitcoin Testnet (0) 0.20ms N/A N/A N/A N/A N/A N/A N/A
Bitcoin Cash (0) 2.37ms N/A N/A N/A N/A N/A N/A N/A
Bitcoin Gold (0) 0.18ms N/A N/A N/A N/A N/A N/A N/A
Dash (0) 0.22ms N/A N/A N/A N/A N/A N/A N/A
Digibyte (0) 0.66ms N/A N/A N/A N/A N/A N/A N/A
DogeCoin (0) 0.30ms N/A N/A N/A N/A N/A N/A N/A
Komodo (0) 0.41ms N/A N/A N/A N/A N/A N/A N/A
Litecoin (0) 0.17ms N/A N/A N/A N/A N/A N/A N/A
Qtum (0) 0.21ms N/A N/A N/A N/A N/A N/A N/A
ZCash (0) 0.28ms N/A N/A N/A N/A N/A N/A N/A
Horizen (0) 0.15ms N/A N/A N/A N/A N/A N/A N/A
Decred (0) 0.14ms N/A N/A N/A N/A N/A N/A N/A

What is the bot and how does it work? Everything is documented here!

Please sign in to comment.