Skip to content

Commit

Permalink
fix: do not throw UserRefusedOnDevice disabled_transaction_boradcast (#…
Browse files Browse the repository at this point in the history
…6554)

fix: add DisabledTransactionBroadcastError

add DisabledTransactionBroadcastError

add changeset

chore: tests
  • Loading branch information
liviuciulinaru committed Mar 29, 2024
1 parent 9cd6f7d commit dd1d17f
Show file tree
Hide file tree
Showing 7 changed files with 2,019 additions and 1,323 deletions.
6 changes: 6 additions & 0 deletions .changeset/itchy-rivers-flow.md
@@ -0,0 +1,6 @@
---
"@ledgerhq/errors": patch
"ledger-live-desktop": patch
---

Implement DisabledTransactionBroadcastError to handle a specific development scenario where transaction broadcasts are disabled
Expand Up @@ -12,7 +12,7 @@ import Box from "~/renderer/components/Box";
import { BodyContent, BodyContentProps } from "./BodyContent";
import { BigNumber } from "bignumber.js";
import { AccountLike } from "@ledgerhq/types-live";
import { UserRefusedOnDevice } from "@ledgerhq/errors";
import { DisabledTransactionBroadcastError } from "@ledgerhq/errors";
import { useRedirectToSwapHistory } from "~/renderer/screens/exchange/Swap2/utils";
import { getEnv } from "@ledgerhq/live-env";

Expand Down Expand Up @@ -150,7 +150,7 @@ const Body = ({ data, onClose }: { data: Data; onClose?: () => void | undefined
});

if (getEnv("DISABLE_TRANSACTION_BROADCAST")) {
return onCancel(new UserRefusedOnDevice());
return onCancel(new DisabledTransactionBroadcastError());
}
}
onResult(operation);
Expand Down
3 changes: 3 additions & 0 deletions libs/ledgerjs/packages/errors/src/index.ts
Expand Up @@ -175,6 +175,9 @@ export const DBWrongPassword = createCustomErrorClass("DBWrongPassword");
export const DBNotReset = createCustomErrorClass("DBNotReset");

export const SequenceNumberError = createCustomErrorClass("SequenceNumberError");
export const DisabledTransactionBroadcastError = createCustomErrorClass(
"DisabledTransactionBroadcastError",
);

// Represents the type of all the classes created with createCustomErrorClass
export type CustomErrorClassType = ReturnType<typeof createCustomErrorClass>;
Expand Down

0 comments on commit dd1d17f

Please sign in to comment.