Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make sure all non-cli broadcasts use broadcast config param #8892

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changeset/red-actors-explode.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"ledger-live-desktop": patch
"live-mobile": patch
---

feat: make sure all transaction broadcast use the broadcastconfig parameter
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Dispatch } from "redux";
import { useSelector } from "react-redux";
import { TFunction } from "i18next";
import { Account, AccountLike, Operation, SignedOperation } from "@ledgerhq/types-live";
import { addPendingOperation, getMainAccount } from "@ledgerhq/live-common/account/index";
Expand All @@ -17,6 +18,7 @@ import { OperationDetails } from "~/renderer/drawers/OperationDetails";
import { setDrawer } from "~/renderer/drawers/Provider";
import { track } from "~/renderer/analytics/segment";
import { WalletState } from "@ledgerhq/live-wallet/store";
import { mevProtectionSelector } from "~/renderer/reducers/settings";

const trackingLiveAppSDKLogic = trackingWrapper(track);

Expand Down Expand Up @@ -70,6 +72,7 @@ export const broadcastTransactionLogic = (
): Promise<string> => {
const bridge = getAccountBridge(account, parentAccount);
const mainAccount = getMainAccount(account, parentAccount);
const mevProtected = useSelector(mevProtectionSelector);
Copy link
Contributor

@Justkant Justkant Jan 17, 2025

Choose a reason for hiding this comment

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

I wouldn't use a useSelector in here if possible, it's not a react component and we cannot expect it to work correctly in all cases

Copy link
Contributor

Choose a reason for hiding this comment

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

You would probably want to add this in the WebPlatformContext


let optimisticOperation: Operation = signedOperation.operation;

Expand All @@ -79,6 +82,7 @@ export const broadcastTransactionLogic = (
optimisticOperation = await bridge.broadcast({
account: mainAccount,
signedOperation,
broadcastConfig: { mevProtected },
});
tracking.platformBroadcastSuccess(manifest);
} catch (error) {
Expand Down
3 changes: 3 additions & 0 deletions apps/ledger-live-mobile/src/logic/screenTransactionHooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ export const useSignWithDevice = ({
const { deviceId, transaction } = route.params || {};
const bridge = getAccountBridge(account, parentAccount);
const mainAccount = getMainAccount(account, parentAccount);
const mevProtected = useSelector(mevProtectionSelector);

navigation.setOptions({
gestureEnabled: false,
});
Expand Down Expand Up @@ -122,6 +124,7 @@ export const useSignWithDevice = ({
.broadcast({
account: mainAccount,
signedOperation: (e as { signedOperation: SignedOperation }).signedOperation,
broadcastConfig: { mevProtected },
})
.then(operation => ({
type: "broadcasted",
Expand Down
Loading